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