2 if(!defined('DOKU_INC')) define('DOKU_INC',dirname(__FILE__
).'/../../');
3 define('DOKU_MEDIAMANAGER',1);
6 @ini_set
('session.use_only_cookies',0);
8 require_once(DOKU_INC
.'inc/init.php');
9 require_once(DOKU_INC
.'inc/lang/en/lang.php');
10 require_once(DOKU_INC
.'inc/lang/'.$conf['lang'].'/lang.php');
11 require_once(DOKU_INC
.'inc/media.php');
12 require_once(DOKU_INC
.'inc/common.php');
13 require_once(DOKU_INC
.'inc/search.php');
14 require_once(DOKU_INC
.'inc/template.php');
15 require_once(DOKU_INC
.'inc/auth.php');
17 trigger_event('MEDIAMANAGER_STARTED',$tmp=array());
18 session_write_close(); //close session
20 // handle passed message
21 if($_REQUEST['msg1']) msg(hsc($_REQUEST['msg1']),1);
22 if($_REQUEST['err']) msg(hsc($_REQUEST['err']),-1);
25 // get namespace to display (either direct or from deletion order)
26 if($_REQUEST['delete']){
27 $DEL = cleanID($_REQUEST['delete']);
30 }elseif($_REQUEST['edit']){
31 $IMG = cleanID($_REQUEST['edit']);
33 }elseif($_REQUEST['img']){
34 $IMG = cleanID($_REQUEST['img']);
37 $NS = $_REQUEST['ns'];
42 $AUTH = auth_quickaclcheck("$NS:*");
44 // create the given namespace (just for beautification)
45 if($AUTH >= AUTH_UPLOAD
) { io_createNamespace("$NS:xxx", 'media'); }
47 // handle flash upload
48 if(isset($_FILES['Filedata'])){
49 $_FILES['upload'] =& $_FILES['Filedata'];
50 $JUMPTO = media_upload($NS,$AUTH);
52 header("HTTP/1.0 400 Bad Request");
59 // give info on PHP catched upload errors
60 if($_FILES['upload']['error']){
61 switch($_FILES['upload']['error']){
64 msg(sprintf($lang['uploadsize'],
65 filesize_h(php_to_byte(ini_get('upload_max_filesize')))),-1);
68 msg($lang['uploadfail'].' ('.$_FILES['upload']['error'].')',-1);
70 unset($_FILES['upload']);
74 if($_FILES['upload']['tmp_name']){
75 $JUMPTO = media_upload($NS,$AUTH);
76 if($JUMPTO) $NS = getNS($JUMPTO);
80 if($IMG && $_REQUEST['do']['save']){
81 $JUMPTO = media_metasave($IMG,$AUTH,$_REQUEST['meta']);
86 $INUSE = media_inuse($DEL);
88 if(media_delete($DEL,$AUTH)) {
89 msg(sprintf($lang['deletesucc'],noNS($DEL)),1);
91 msg(sprintf($lang['deletefail'],noNS($DEL)),-1);
94 if(!$conf['refshow']) {
96 msg(sprintf($lang['mediainuse'],noNS($DEL)),0);
101 // finished - start output
102 header('Content-Type: text/html; charset=utf-8');
103 include(template('mediamanager.php'));
105 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */