1cf6894dfSAndreas Gohr<?php 2d0a27cb0SAndreas Gohr if(!defined('DOKU_INC')) define('DOKU_INC',dirname(__FILE__).'/../../'); 33df72098SAndreas Gohr define('DOKU_MEDIAMANAGER',1); 4d00ec455SAndreas Gohr 5a5de816fSAndreas Gohr // for multi uploader: 6a5de816fSAndreas Gohr @ini_set('session.use_only_cookies',0); 7a5de816fSAndreas Gohr 83df72098SAndreas Gohr require_once(DOKU_INC.'inc/init.php'); 9a249681dSAndreas Gohr 10a249681dSAndreas Gohr trigger_event('MEDIAMANAGER_STARTED',$tmp=array()); 113df72098SAndreas Gohr session_write_close(); //close session 123df72098SAndreas Gohr 13d186898bSAndreas Gohr // handle passed message 14d186898bSAndreas Gohr if($_REQUEST['msg1']) msg(hsc($_REQUEST['msg1']),1); 15d00ec455SAndreas Gohr if($_REQUEST['err']) msg(hsc($_REQUEST['err']),-1); 16d186898bSAndreas Gohr 173df72098SAndreas Gohr 183df72098SAndreas Gohr // get namespace to display (either direct or from deletion order) 193df72098SAndreas Gohr if($_REQUEST['delete']){ 203df72098SAndreas Gohr $DEL = cleanID($_REQUEST['delete']); 21a05e297aSAndreas Gohr $IMG = $DEL; 223df72098SAndreas Gohr $NS = getNS($DEL); 233df72098SAndreas Gohr }elseif($_REQUEST['edit']){ 243df72098SAndreas Gohr $IMG = cleanID($_REQUEST['edit']); 253df72098SAndreas Gohr $NS = getNS($IMG); 263df72098SAndreas Gohr }elseif($_REQUEST['img']){ 273df72098SAndreas Gohr $IMG = cleanID($_REQUEST['img']); 283df72098SAndreas Gohr $NS = getNS($IMG); 293df72098SAndreas Gohr }else{ 303df72098SAndreas Gohr $NS = $_REQUEST['ns']; 313df72098SAndreas Gohr $NS = cleanID($NS); 323df72098SAndreas Gohr } 333df72098SAndreas Gohr 343df72098SAndreas Gohr // check auth 353df72098SAndreas Gohr $AUTH = auth_quickaclcheck("$NS:*"); 363df72098SAndreas Gohr 37*0b34c70fSGina Haeussge // do not display the manager if user does not have read access 38*0b34c70fSGina Haeussge if($AUTH < AUTH_READ) { 39*0b34c70fSGina Haeussge header('HTTP/1.0 403 Forbidden'); 40*0b34c70fSGina Haeussge die($lang['accessdenied']); 41*0b34c70fSGina Haeussge } 42*0b34c70fSGina Haeussge 433df72098SAndreas Gohr // create the given namespace (just for beautification) 44cc7d0c94SBen Coburn if($AUTH >= AUTH_UPLOAD) { io_createNamespace("$NS:xxx", 'media'); } 453df72098SAndreas Gohr 46d00ec455SAndreas Gohr // handle flash upload 4758b091deSAndreas Gohr if(isset($_FILES['Filedata'])){ 48d00ec455SAndreas Gohr $_FILES['upload'] =& $_FILES['Filedata']; 49d00ec455SAndreas Gohr $JUMPTO = media_upload($NS,$AUTH); 50d00ec455SAndreas Gohr if($JUMPTO == false){ 51d00ec455SAndreas Gohr header("HTTP/1.0 400 Bad Request"); 52d00ec455SAndreas Gohr echo 'Upload failed'; 53d00ec455SAndreas Gohr } 54d00ec455SAndreas Gohr echo 'ok'; 55d00ec455SAndreas Gohr exit; 56d00ec455SAndreas Gohr } 57d00ec455SAndreas Gohr 58a93e6f85SAndreas Gohr // give info on PHP catched upload errors 5999766eefSAndreas Gohr if($_FILES['upload']['error']){ 6099766eefSAndreas Gohr switch($_FILES['upload']['error']){ 61a93e6f85SAndreas Gohr case 1: 62a93e6f85SAndreas Gohr case 2: 63a93e6f85SAndreas Gohr msg(sprintf($lang['uploadsize'], 64a93e6f85SAndreas Gohr filesize_h(php_to_byte(ini_get('upload_max_filesize')))),-1); 65a93e6f85SAndreas Gohr break; 66a93e6f85SAndreas Gohr default: 6799766eefSAndreas Gohr msg($lang['uploadfail'].' ('.$_FILES['upload']['error'].')',-1); 6899766eefSAndreas Gohr } 6999766eefSAndreas Gohr unset($_FILES['upload']); 70a93e6f85SAndreas Gohr } 71d00ec455SAndreas Gohr 723df72098SAndreas Gohr // handle upload 733df72098SAndreas Gohr if($_FILES['upload']['tmp_name']){ 743df72098SAndreas Gohr $JUMPTO = media_upload($NS,$AUTH); 757b877f51SAndreas Gohr if($JUMPTO) $NS = getNS($JUMPTO); 763df72098SAndreas Gohr } 773df72098SAndreas Gohr 783df72098SAndreas Gohr // handle meta saving 793df72098SAndreas Gohr if($IMG && $_REQUEST['do']['save']){ 803df72098SAndreas Gohr $JUMPTO = media_metasave($IMG,$AUTH,$_REQUEST['meta']); 813df72098SAndreas Gohr } 823df72098SAndreas Gohr 833df72098SAndreas Gohr // handle deletion 843df72098SAndreas Gohr if($DEL) { 85666cdec5SMichael Klier $INUSE = media_inuse($DEL); 86666cdec5SMichael Klier if(!$INUSE) { 87666cdec5SMichael Klier if(media_delete($DEL,$AUTH)) { 8807ae50bfSAndreas Gohr msg(sprintf($lang['deletesucc'],noNS($DEL)),1); 89666cdec5SMichael Klier } else { 90d5b31577SChristian Marg msg(sprintf($lang['deletefail'],noNS($DEL)),-1); 91666cdec5SMichael Klier } 92666cdec5SMichael Klier } else { 93666cdec5SMichael Klier if(!$conf['refshow']) { 94666cdec5SMichael Klier unset($INUSE); 95d5b31577SChristian Marg msg(sprintf($lang['mediainuse'],noNS($DEL)),0); 96666cdec5SMichael Klier } 97666cdec5SMichael Klier } 983df72098SAndreas Gohr } 993df72098SAndreas Gohr 1003df72098SAndreas Gohr // finished - start output 1013df72098SAndreas Gohr header('Content-Type: text/html; charset=utf-8'); 1023df72098SAndreas Gohr include(template('mediamanager.php')); 103365be586SAndreas Gohr 104365be586SAndreas Gohr/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ 105