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['id'] = ''; 37 $JSINFO['namespace'] = ''; 38 $AUTH = $INFO['perm']; // shortcut for historical reasons 39 40 $tmp = array(); 41 trigger_event('MEDIAMANAGER_STARTED', $tmp); 42 session_write_close(); //close session 43 44 // do not display the manager if user does not have read access 45 if($AUTH < AUTH_READ && !$fullscreen) { 46 http_status(403); 47 die($lang['accessdenied']); 48 } 49 50 // handle flash upload 51 if(isset($_FILES['Filedata'])){ 52 $_FILES['upload'] =& $_FILES['Filedata']; 53 $JUMPTO = media_upload($NS,$AUTH); 54 if($JUMPTO == false){ 55 http_status(400); 56 echo 'Upload failed'; 57 } 58 echo 'ok'; 59 exit; 60 } 61 62 // give info on PHP caught upload errors 63 if(!empty($_FILES['upload']['error'])){ 64 switch($_FILES['upload']['error']){ 65 case 1: 66 case 2: 67 msg(sprintf($lang['uploadsize'], 68 filesize_h(php_to_byte(ini_get('upload_max_filesize')))),-1); 69 break; 70 default: 71 msg($lang['uploadfail'].' ('.$_FILES['upload']['error'].')',-1); 72 } 73 unset($_FILES['upload']); 74 } 75 76 // handle upload 77 if(!empty($_FILES['upload']['tmp_name'])){ 78 $JUMPTO = media_upload($NS,$AUTH); 79 if($JUMPTO) $NS = getNS($JUMPTO); 80 } 81 82 // handle meta saving 83 if($IMG && @array_key_exists('save', $INPUT->arr('do'))){ 84 $JUMPTO = media_metasave($IMG,$AUTH,$INPUT->arr('meta')); 85 } 86 87 if($IMG && ($INPUT->str('mediado') == 'save' || @array_key_exists('save', $INPUT->arr('mediado')))) { 88 $JUMPTO = media_metasave($IMG,$AUTH,$INPUT->arr('meta')); 89 } 90 91 if ($INPUT->int('rev') && $conf['mediarevisions']) $REV = $INPUT->int('rev'); 92 93 if($INPUT->str('mediado') == 'restore' && $conf['mediarevisions']){ 94 $JUMPTO = media_restore($INPUT->str('image'), $REV, $AUTH); 95 } 96 97 // handle deletion 98 if($DEL) { 99 $res = 0; 100 if(checkSecurityToken()) { 101 $res = media_delete($DEL,$AUTH); 102 } 103 if ($res & DOKU_MEDIA_DELETED) { 104 $msg = sprintf($lang['deletesucc'], noNS($DEL)); 105 if ($res & DOKU_MEDIA_EMPTY_NS && !$fullscreen) { 106 // current namespace was removed. redirecting to root ns passing msg along 107 send_redirect(DOKU_URL.'lib/exe/mediamanager.php?msg1='. 108 rawurlencode($msg).'&edid='.$INPUT->str('edid')); 109 } 110 msg($msg,1); 111 } elseif ($res & DOKU_MEDIA_INUSE) { 112 if(!$conf['refshow']) { 113 msg(sprintf($lang['mediainuse'],noNS($DEL)),0); 114 } 115 } else { 116 msg(sprintf($lang['deletefail'],noNS($DEL)),-1); 117 } 118 } 119 // finished - start output 120 121 if (!$fullscreen) { 122 header('Content-Type: text/html; charset=utf-8'); 123 include(template('mediamanager.php')); 124 } 125 126/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ 127