source: documentation/trunk/packages/dokuwiki-2011-05-25a/lib/exe/mediamanager.php@ 30098

Last change on this file since 30098 was 25027, checked in by jmt12, 12 years ago

Adding the packages directory, and within it a configured version of dokuwiki all ready to run

File size: 3.3 KB
Line 
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 trigger_event('MEDIAMANAGER_STARTED',$tmp=array());
11 session_write_close(); //close session
12
13 // handle passed message
14 if($_REQUEST['msg1']) msg(hsc($_REQUEST['msg1']),1);
15 if($_REQUEST['err']) msg(hsc($_REQUEST['err']),-1);
16
17
18 // get namespace to display (either direct or from deletion order)
19 if($_REQUEST['delete']){
20 $DEL = cleanID($_REQUEST['delete']);
21 $IMG = $DEL;
22 $NS = getNS($DEL);
23 }elseif($_REQUEST['edit']){
24 $IMG = cleanID($_REQUEST['edit']);
25 $NS = getNS($IMG);
26 }elseif($_REQUEST['img']){
27 $IMG = cleanID($_REQUEST['img']);
28 $NS = getNS($IMG);
29 }else{
30 $NS = $_REQUEST['ns'];
31 $NS = cleanID($NS);
32 }
33
34 // check auth
35 $AUTH = auth_quickaclcheck("$NS:*");
36
37 // do not display the manager if user does not have read access
38 if($AUTH < AUTH_READ) {
39 header('HTTP/1.0 403 Forbidden');
40 die($lang['accessdenied']);
41 }
42
43 // create the given namespace (just for beautification)
44 if($AUTH >= AUTH_UPLOAD) { io_createNamespace("$NS:xxx", 'media'); }
45
46 // handle flash upload
47 if(isset($_FILES['Filedata'])){
48 $_FILES['upload'] =& $_FILES['Filedata'];
49 $JUMPTO = media_upload($NS,$AUTH);
50 if($JUMPTO == false){
51 header("HTTP/1.0 400 Bad Request");
52 echo 'Upload failed';
53 }
54 echo 'ok';
55 exit;
56 }
57
58 // give info on PHP catched upload errors
59 if($_FILES['upload']['error']){
60 switch($_FILES['upload']['error']){
61 case 1:
62 case 2:
63 msg(sprintf($lang['uploadsize'],
64 filesize_h(php_to_byte(ini_get('upload_max_filesize')))),-1);
65 break;
66 default:
67 msg($lang['uploadfail'].' ('.$_FILES['upload']['error'].')',-1);
68 }
69 unset($_FILES['upload']);
70 }
71
72 // handle upload
73 if($_FILES['upload']['tmp_name']){
74 $JUMPTO = media_upload($NS,$AUTH);
75 if($JUMPTO) $NS = getNS($JUMPTO);
76 }
77
78 // handle meta saving
79 if($IMG && $_REQUEST['do']['save']){
80 $JUMPTO = media_metasave($IMG,$AUTH,$_REQUEST['meta']);
81 }
82
83 // handle deletion
84 if($DEL) {
85 $res = 0;
86 if(checkSecurityToken()) {
87 $res = media_delete($DEL,$AUTH);
88 }
89 if ($res & DOKU_MEDIA_DELETED) {
90 $msg = sprintf($lang['deletesucc'], noNS($DEL));
91 if ($res & DOKU_MEDIA_EMPTY_NS) {
92 // current namespace was removed. redirecting to root ns passing msg along
93 send_redirect(DOKU_URL.'lib/exe/mediamanager.php?msg1='.
94 rawurlencode($msg).'&edid='.$_REQUEST['edid']);
95 }
96 msg($msg,1);
97 } elseif ($res & DOKU_MEDIA_INUSE) {
98 if(!$conf['refshow']) {
99 msg(sprintf($lang['mediainuse'],noNS($DEL)),0);
100 }
101 } else {
102 msg(sprintf($lang['deletefail'],noNS($DEL)),-1);
103 }
104 }
105
106 // finished - start output
107 header('Content-Type: text/html; charset=utf-8');
108 include(template('mediamanager.php'));
109
110/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
Note: See TracBrowser for help on using the repository browser.