xref: /dokuwiki/lib/exe/mediamanager.php (revision dee0b27a898a3e30494c101a6b8c9917ee402fd9)
1<?php
2    if(!defined('DOKU_INC')) define('DOKU_INC',dirname(__FILE__).'/../../');
3    define('DOKU_MEDIAMANAGER',1);
4    require_once(DOKU_INC.'inc/init.php');
5    require_once(DOKU_INC.'inc/lang/en/lang.php');
6    require_once(DOKU_INC.'inc/lang/'.$conf['lang'].'/lang.php');
7    require_once(DOKU_INC.'inc/media.php');
8    require_once(DOKU_INC.'inc/common.php');
9    require_once(DOKU_INC.'inc/search.php');
10    require_once(DOKU_INC.'inc/template.php');
11    require_once(DOKU_INC.'inc/auth.php');
12    session_write_close();  //close session
13
14    // handle passed message
15    if($_REQUEST['msg1']) msg(hsc($_REQUEST['msg1']),1);
16
17
18    // get namespace to display (either direct or from deletion order)
19    if($_REQUEST['delete']){
20        $DEL = cleanID($_REQUEST['delete']);
21        $IMG = $DEL;
22        $NS  = getNS($DEL);
23    }elseif($_REQUEST['edit']){
24        $IMG = cleanID($_REQUEST['edit']);
25        $NS  = getNS($IMG);
26    }elseif($_REQUEST['img']){
27        $IMG = cleanID($_REQUEST['img']);
28        $NS  = getNS($IMG);
29    }else{
30        $NS = $_REQUEST['ns'];
31        $NS = cleanID($NS);
32    }
33
34    // check auth
35    $AUTH = auth_quickaclcheck("$NS:*");
36
37    // create the given namespace (just for beautification)
38    if($AUTH >= AUTH_UPLOAD) { io_createNamespace("$NS:xxx", 'media'); }
39
40    // handle upload
41    if($_FILES['upload']['tmp_name']){
42        $JUMPTO = media_upload($NS,$AUTH);
43        if($JUMPTO) $NS = getNS($JUMPTO);
44    }
45
46    // handle meta saving
47    if($IMG && $_REQUEST['do']['save']){
48        $JUMPTO = media_metasave($IMG,$AUTH,$_REQUEST['meta']);
49    }
50
51    // handle deletion
52    if($DEL) {
53        $INUSE = media_delete($DEL,$AUTH);
54    }
55
56    // finished - start output
57    header('Content-Type: text/html; charset=utf-8');
58    include(template('mediamanager.php'));
59