xref: /dokuwiki/lib/exe/mediamanager.php (revision a249681d366126d65ce7207509e2c53223140862)
1cf6894dfSAndreas Gohr<?php
2d0a27cb0SAndreas Gohr    if(!defined('DOKU_INC')) define('DOKU_INC',dirname(__FILE__).'/../../');
33df72098SAndreas Gohr    define('DOKU_MEDIAMANAGER',1);
4d00ec455SAndreas Gohr
53df72098SAndreas Gohr    require_once(DOKU_INC.'inc/init.php');
63df72098SAndreas Gohr    require_once(DOKU_INC.'inc/lang/en/lang.php');
73df72098SAndreas Gohr    require_once(DOKU_INC.'inc/lang/'.$conf['lang'].'/lang.php');
83df72098SAndreas Gohr    require_once(DOKU_INC.'inc/media.php');
93df72098SAndreas Gohr    require_once(DOKU_INC.'inc/common.php');
103df72098SAndreas Gohr    require_once(DOKU_INC.'inc/search.php');
113df72098SAndreas Gohr    require_once(DOKU_INC.'inc/template.php');
123df72098SAndreas Gohr    require_once(DOKU_INC.'inc/auth.php');
13*a249681dSAndreas Gohr
14*a249681dSAndreas Gohr    trigger_event('MEDIAMANAGER_STARTED',$tmp=array());
153df72098SAndreas Gohr    session_write_close();  //close session
163df72098SAndreas Gohr
17d186898bSAndreas Gohr    // handle passed message
18d186898bSAndreas Gohr    if($_REQUEST['msg1']) msg(hsc($_REQUEST['msg1']),1);
19d00ec455SAndreas Gohr    if($_REQUEST['err']) msg(hsc($_REQUEST['err']),-1);
20d186898bSAndreas Gohr
213df72098SAndreas Gohr
223df72098SAndreas Gohr    // get namespace to display (either direct or from deletion order)
233df72098SAndreas Gohr    if($_REQUEST['delete']){
243df72098SAndreas Gohr        $DEL = cleanID($_REQUEST['delete']);
25a05e297aSAndreas Gohr        $IMG = $DEL;
263df72098SAndreas Gohr        $NS  = getNS($DEL);
273df72098SAndreas Gohr    }elseif($_REQUEST['edit']){
283df72098SAndreas Gohr        $IMG = cleanID($_REQUEST['edit']);
293df72098SAndreas Gohr        $NS  = getNS($IMG);
303df72098SAndreas Gohr    }elseif($_REQUEST['img']){
313df72098SAndreas Gohr        $IMG = cleanID($_REQUEST['img']);
323df72098SAndreas Gohr        $NS  = getNS($IMG);
333df72098SAndreas Gohr    }else{
343df72098SAndreas Gohr        $NS = $_REQUEST['ns'];
353df72098SAndreas Gohr        $NS = cleanID($NS);
363df72098SAndreas Gohr    }
373df72098SAndreas Gohr
383df72098SAndreas Gohr    // check auth
393df72098SAndreas Gohr    $AUTH = auth_quickaclcheck("$NS:*");
403df72098SAndreas Gohr
413df72098SAndreas Gohr    // create the given namespace (just for beautification)
42cc7d0c94SBen Coburn    if($AUTH >= AUTH_UPLOAD) { io_createNamespace("$NS:xxx", 'media'); }
433df72098SAndreas Gohr
44d00ec455SAndreas Gohr    // handle flash upload
45d00ec455SAndreas Gohr    if($_FILES['Filedata']['tmp_name']){
46d00ec455SAndreas Gohr        $_FILES['upload'] =& $_FILES['Filedata'];
47d00ec455SAndreas Gohr        $JUMPTO = media_upload($NS,$AUTH);
48d00ec455SAndreas Gohr        if($JUMPTO == false){
49d00ec455SAndreas Gohr            header("HTTP/1.0 400 Bad Request");
50d00ec455SAndreas Gohr            echo 'Upload failed';
51d00ec455SAndreas Gohr        }
52d00ec455SAndreas Gohr        echo 'ok';
53d00ec455SAndreas Gohr        exit;
54d00ec455SAndreas Gohr    }
55d00ec455SAndreas Gohr
56d00ec455SAndreas Gohr
573df72098SAndreas Gohr    // handle upload
583df72098SAndreas Gohr    if($_FILES['upload']['tmp_name']){
593df72098SAndreas Gohr        $JUMPTO = media_upload($NS,$AUTH);
607b877f51SAndreas Gohr        if($JUMPTO) $NS = getNS($JUMPTO);
613df72098SAndreas Gohr    }
623df72098SAndreas Gohr
633df72098SAndreas Gohr    // handle meta saving
643df72098SAndreas Gohr    if($IMG && $_REQUEST['do']['save']){
653df72098SAndreas Gohr        $JUMPTO = media_metasave($IMG,$AUTH,$_REQUEST['meta']);
663df72098SAndreas Gohr    }
673df72098SAndreas Gohr
683df72098SAndreas Gohr    // handle deletion
693df72098SAndreas Gohr    if($DEL) {
703df72098SAndreas Gohr        $INUSE = media_delete($DEL,$AUTH);
713df72098SAndreas Gohr    }
723df72098SAndreas Gohr
733df72098SAndreas Gohr    // finished - start output
743df72098SAndreas Gohr    header('Content-Type: text/html; charset=utf-8');
753df72098SAndreas Gohr    include(template('mediamanager.php'));
76