1<?php 2 if(!defined('DOKU_INC')) define('DOKU_INC',dirname(__FILE__).'/../../'); 3 define('DOKU_MEDIAMANAGER',1); 4 5 6 require_once(DOKU_INC.'inc/init.php'); 7 require_once(DOKU_INC.'inc/lang/en/lang.php'); 8 require_once(DOKU_INC.'inc/lang/'.$conf['lang'].'/lang.php'); 9 require_once(DOKU_INC.'inc/media.php'); 10 require_once(DOKU_INC.'inc/common.php'); 11 require_once(DOKU_INC.'inc/search.php'); 12 require_once(DOKU_INC.'inc/template.php'); 13 require_once(DOKU_INC.'inc/auth.php'); 14 session_write_close(); //close session 15 16 // handle passed message 17 if($_REQUEST['msg1']) msg(hsc($_REQUEST['msg1']),1); 18 if($_REQUEST['err']) msg(hsc($_REQUEST['err']),-1); 19 20 21 // get namespace to display (either direct or from deletion order) 22 if($_REQUEST['delete']){ 23 $DEL = cleanID($_REQUEST['delete']); 24 $IMG = $DEL; 25 $NS = getNS($DEL); 26 }elseif($_REQUEST['edit']){ 27 $IMG = cleanID($_REQUEST['edit']); 28 $NS = getNS($IMG); 29 }elseif($_REQUEST['img']){ 30 $IMG = cleanID($_REQUEST['img']); 31 $NS = getNS($IMG); 32 }else{ 33 $NS = $_REQUEST['ns']; 34 $NS = cleanID($NS); 35 } 36 37 // check auth 38 $AUTH = auth_quickaclcheck("$NS:*"); 39 40 // create the given namespace (just for beautification) 41 if($AUTH >= AUTH_UPLOAD) { io_createNamespace("$NS:xxx", 'media'); } 42 43 // handle flash upload 44 if($_FILES['Filedata']['tmp_name']){ 45 $_FILES['upload'] =& $_FILES['Filedata']; 46 $JUMPTO = media_upload($NS,$AUTH); 47 if($JUMPTO == false){ 48 header("HTTP/1.0 400 Bad Request"); 49 echo 'Upload failed'; 50 } 51 echo 'ok'; 52 exit; 53 } 54 55 56 // handle upload 57 if($_FILES['upload']['tmp_name']){ 58 $JUMPTO = media_upload($NS,$AUTH); 59 if($JUMPTO) $NS = getNS($JUMPTO); 60 } 61 62 // handle meta saving 63 if($IMG && $_REQUEST['do']['save']){ 64 $JUMPTO = media_metasave($IMG,$AUTH,$_REQUEST['meta']); 65 } 66 67 // handle deletion 68 if($DEL) { 69 $INUSE = media_delete($DEL,$AUTH); 70 } 71 72 // finished - start output 73 header('Content-Type: text/html; charset=utf-8'); 74 include(template('mediamanager.php')); 75