summaryrefslogtreecommitdiff
path: root/lib/exe/mediamanager.php
blob: 23140ee3cc2bcc487261ff813f4d951e3b13e7d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?
    if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/');
    define('DOKU_MEDIAMANAGER',1);
    require_once(DOKU_INC.'inc/init.php');
    require_once(DOKU_INC.'inc/lang/en/lang.php');
    require_once(DOKU_INC.'inc/lang/'.$conf['lang'].'/lang.php');
    require_once(DOKU_INC.'inc/media.php');
    require_once(DOKU_INC.'inc/common.php');
    require_once(DOKU_INC.'inc/search.php');
    require_once(DOKU_INC.'inc/template.php');
    require_once(DOKU_INC.'inc/auth.php');
    session_write_close();  //close session


    // get namespace to display (either direct or from deletion order)
    if($_REQUEST['delete']){
        $DEL = cleanID($_REQUEST['delete']);
        $NS  = getNS($DEL);
    }elseif($_REQUEST['edit']){
        $IMG = cleanID($_REQUEST['edit']);
        $NS  = getNS($IMG);
    }elseif($_REQUEST['img']){
        $IMG = cleanID($_REQUEST['img']);
        $NS  = getNS($IMG);
    }else{
        $NS = $_REQUEST['ns'];
        $NS = cleanID($NS);
    }

    // check auth
    $AUTH = auth_quickaclcheck("$NS:*");

    // create the given namespace (just for beautification)
    if($AUTH >= AUTH_UPLOAD) io_makeFileDir(mediaFN("$NS:xxx"));

    // handle upload
    if($_FILES['upload']['tmp_name']){
        $JUMPTO = media_upload($NS,$AUTH);
        if($JUMPTO) $NS = getNS($JUMPTO);
    }

    // handle meta saving
    if($IMG && $_REQUEST['do']['save']){
        $JUMPTO = media_metasave($IMG,$AUTH,$_REQUEST['meta']);
    }

    // handle deletion
    if($DEL) {
        $INUSE = media_delete($DEL,$AUTH);
    }

    // finished - start output
    header('Content-Type: text/html; charset=utf-8');
    include(template('mediamanager.php'));