1<?php 2 if(!defined('DOKU_INC')) define('DOKU_INC',dirname(__FILE__).'/../../'); 3 define('DOKU_MEDIAMANAGER',1); 4 5 // for multi uploader: 6 @ini_set('session.use_only_cookies',0); 7 8 require_once(DOKU_INC.'inc/init.php'); 9 10 global $INPUT; 11 global $lang; 12 global $conf; 13 // handle passed message 14 if($INPUT->str('msg1')) msg(hsc($INPUT->str('msg1')),1); 15 if($INPUT->str('err')) msg(hsc($INPUT->str('err')),-1); 16 17 global $DEL; 18 // get namespace to display (either direct or from deletion order) 19 if($INPUT->str('delete')){ 20 $DEL = cleanID($INPUT->str('delete')); 21 $IMG = $DEL; 22 $NS = getNS($DEL); 23 }elseif($INPUT->str('edit')){ 24 $IMG = cleanID($INPUT->str('edit')); 25 $NS = getNS($IMG); 26 }elseif($INPUT->str('img')){ 27 $IMG = cleanID($INPUT->str('img')); 28 $NS = getNS($IMG); 29 }else{ 30 $NS = cleanID($INPUT->str('ns')); 31 $IMG = null; 32 } 33 34 global $INFO, $JSINFO; 35 $INFO = !empty($INFO) ? array_merge($INFO, mediainfo()) : mediainfo(); 36 $JSINFO = array('id' => '', 'namespace' => ''); 37 $AUTH = $INFO['perm']; // shortcut for historical reasons 38 39 $tmp = array(); 40 trigger_event('MEDIAMANAGER_STARTED', $tmp); 41 session_write_close(); //close session 42 43 // do not display the manager if user does not have read access 44 if($AUTH < AUTH_READ && !$fullscreen) { 45 http_status(403); 46 die($lang['accessdenied']); 47 } 48 49 // handle flash upload 50 if(isset($_FILES['Filedata'])){ 51 $_FILES['upload'] =& $_FILES['Filedata']; 52 $JUMPTO = media_upload($NS,$AUTH); 53 if($JUMPTO == false){ 54 http_status(400); 55 echo 'Upload failed'; 56 } 57 echo 'ok'; 58 exit; 59 } 60 61 // give info on PHP caught upload errors 62 if(!empty($_FILES['upload']['error'])){ 63 switch($_FILES['upload']['error']){ 64 case 1: 65 case 2: 66 msg(sprintf($lang['uploadsize'], 67 filesize_h(php_to_byte(ini_get('upload_max_filesize')))),-1); 68 break; 69 default: 70 msg($lang['uploadfail'].' ('.$_FILES['upload']['error'].')',-1); 71 } 72 unset($_FILES['upload']); 73 } 74 75 // handle upload 76 if(!empty($_FILES['upload']['tmp_name'])){ 77 $JUMPTO = media_upload($NS,$AUTH); 78 if($JUMPTO) $NS = getNS($JUMPTO); 79 } 80 81 // handle meta saving 82 if($IMG && @array_key_exists('save', $INPUT->arr('do'))){ 83 $JUMPTO = media_metasave($IMG,$AUTH,$INPUT->arr('meta')); 84 } 85 86 if($IMG && ($INPUT->str('mediado') == 'save' || @array_key_exists('save', $INPUT->arr('mediado')))) { 87 $JUMPTO = media_metasave($IMG,$AUTH,$INPUT->arr('meta')); 88 } 89 90 if ($INPUT->int('rev') && $conf['mediarevisions']) $REV = $INPUT->int('rev'); 91 92 if($INPUT->str('mediado') == 'restore' && $conf['mediarevisions']){ 93 $JUMPTO = media_restore($INPUT->str('image'), $REV, $AUTH); 94 } 95 96 // handle deletion 97 if($DEL) { 98 $res = 0; 99 if(checkSecurityToken()) { 100 $res = media_delete($DEL,$AUTH); 101 } 102 if ($res & DOKU_MEDIA_DELETED) { 103 $msg = sprintf($lang['deletesucc'], noNS($DEL)); 104 if ($res & DOKU_MEDIA_EMPTY_NS && !$fullscreen) { 105 // current namespace was removed. redirecting to root ns passing msg along 106 send_redirect(DOKU_URL.'lib/exe/mediamanager.php?msg1='. 107 rawurlencode($msg).'&edid='.$INPUT->str('edid')); 108 } 109 msg($msg,1); 110 } elseif ($res & DOKU_MEDIA_INUSE) { 111 if(!$conf['refshow']) { 112 msg(sprintf($lang['mediainuse'],noNS($DEL)),0); 113 } 114 } else { 115 msg(sprintf($lang['deletefail'],noNS($DEL)),-1); 116 } 117 } 118 // finished - start output 119 120 if (!$fullscreen) { 121 header('Content-Type: text/html; charset=utf-8'); 122 include(template('mediamanager.php')); 123 } 124 125/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ 126