xref: /dokuwiki/lib/exe/mediamanager.php (revision d186898bc9d253d2f0227785ece22080e2005280)
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        $NS  = getNS($DEL);
22    }elseif($_REQUEST['edit']){
23        $IMG = cleanID($_REQUEST['edit']);
24        $NS  = getNS($IMG);
25    }elseif($_REQUEST['img']){
26        $IMG = cleanID($_REQUEST['img']);
27        $NS  = getNS($IMG);
28    }else{
29        $NS = $_REQUEST['ns'];
30        $NS = cleanID($NS);
31    }
32
33    // check auth
34    $AUTH = auth_quickaclcheck("$NS:*");
35
36    // create the given namespace (just for beautification)
37    if($AUTH >= AUTH_UPLOAD) { io_createNamespace("$NS:xxx", 'media'); }
38
39    // handle upload
40    if($_FILES['upload']['tmp_name']){
41        $JUMPTO = media_upload($NS,$AUTH);
42        if($JUMPTO) $NS = getNS($JUMPTO);
43    }
44
45    // handle meta saving
46    if($IMG && $_REQUEST['do']['save']){
47        $JUMPTO = media_metasave($IMG,$AUTH,$_REQUEST['meta']);
48    }
49
50    // handle deletion
51    if($DEL) {
52        $INUSE = media_delete($DEL,$AUTH);
53    }
54
55    // finished - start output
56    header('Content-Type: text/html; charset=utf-8');
57    include(template('mediamanager.php'));
58