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