move.php
10.3 KB
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
<?php
/*
* move.php
*
* Move a folder or a file to a new destination
*
* Copyright (c) 1999-2002 The Owl Project Team
* Licensed under the GNU GPL. For full terms see the file COPYING.
*
* $Id$
*/
require("./config/owl.php");
require("./lib/owl.lib.php");
require("./config/html.php");
require("./lib/security.lib.php");
//
global $order, $sortorder, $sortname;
switch ($order) {
case "name":
$sortorder = 'sortname';
break;
case "major_revision":
$sortorder = 'sortver';
break;
case "filename" :
$sortorder = 'sortfilename';
break;
case "size" :
$sortorder = 'sortsize';
break;
case "creatorid" :
$sortorder = 'sortposted';
break;
case "smodified" :
$sortorder = 'sortmod';
break;
case "checked_out":
$sortorder = 'sortcheckedout';
break;
default:
break;
}
// END 496814 Column Sorts are not persistant
if($action == "file") {
//if the user does not have permission to modify the file
if(check_auth($id, "file_modify", $userid) == 0) {
include("./lib/header.inc");
print("<TABLE WIDTH=$default->table_expand_width BGCOLOR=$default->main_header_bgcolor CELLSPACING=0 CELLPADDING=0 BORDER=$default->table_border HEIGHT=30>");
?>
<TR><TD ALIGN=LEFT>
<?php print("$lang_user: ");
//if the user has access to his/her preferences
//print a link to the user's preferences
if(prefaccess($userid)) {
print("<A HREF='prefs.php?owluser=$userid&sess=$sess&expand=$expand&order=$order&sortname=$sortname'>");
}
print uid_to_name($userid);
print ("</A>");
?>
<FONT SIZE=-1>
<?php print("<A HREF='index.php?login=logout&sess=$sess'>$lang_logout</A>");?>
</FONT></TD>
<TD ALIGN=RIGHT><?php print("<A HREF='browse.php?sess=$sess&parent=$parent&expand=$expand&order=$order&$sortorder=$sortname'>
<IMG SRC='$default->owl_root_url/locale/$language/graphics/btn_browse.gif' BORDER=0></A>"); ?>
</TD></TR></TABLE><BR><BR><CENTER>
<?php
exit($lang_nofilemod);
}
} else {
//if the user does not have permission to modify the folder
if(check_auth($id, "folder_modify", $userid) == 0) {
include("./lib/header.inc");
print("<TABLE WIDTH=$default->table_expand_width BGCOLOR=$default->main_header_bgcolor CELLSPACING=0 CELLPADDING=0 BORDER=$default->table_border HEIGHT=30>");
?>
<TR><TD ALIGN=LEFT>
<?php print("$lang_user: ");
//if the user has access to his/her preferences
//print a link to the user's preferences
if(prefaccess($userid)) {
print("<A HREF='prefs.php?owluser=$userid&sess=$sess&expand=$expand&order=$order&sortname=$sortname'>");
}
print uid_to_name($userid);
print ("</A>");
?>
<FONT SIZE=-1>
<?php print("<A HREF='index.php?login=logout&sess=$sess'>$lang_logout</A>");?>
</FONT></TD>
<TD ALIGN=RIGHT><?php print("<A HREF='browse.php?sess=$sess&parent=$parent&expand=$expand&order=$order&$sortorder=$sortname'><IMG SRC='$default->owl_root_url/locale/$language/graphics/btn_browse.gif' BORDER=0></A>"); ?>
</TD></TR></TABLE><BR><BR><CENTER>
<?php
exit($lang_nofilemod);
}
}
/**
* Check for new folders. Sets $newFolder to the new folder id
*/
function checkForNewFolder() {
global $HTTP_POST_VARS, $newFolder;
if (!is_array($HTTP_POST_VARS))
{
return;
}
while (list($key, $value) = each ($HTTP_POST_VARS)) {
if (substr($key,0,2)=="ID") {
$newFolder = intval(substr($key,2));
break;
}
}
}
/**
* Display all the sub-folders in a folder
*
* @param $fid folder id
* @param $folder folder name
*
*/
function showFoldersIn($fid, $folder) {
global $folderList, $fCount, $fDepth, $excludeID, $action, $id, $default, $userid ;
for ($c=0 ;$c < ($fDepth-1) ; $c++) print "<img src='$default->owl_root_url/locale/$default->owl_lang/graphics/icons/blank.gif' height=16 width=18 align=top>";
if ($fDepth) print "<img src='$default->owl_root_url/locale/$default->owl_lang/graphics/icons/link.gif' height=16 width=16 align=top>";
$gray=0; // Work out when to gray out folders ...
//current parent for all moves
if ($fid==$excludeID)
{
$gray=1;
}
//subtree for folder moves
//can't move a folder to itself
if (($action=="folder") && ($fid==$id))
{
$gray=1;
}
//check for permissions
//if you don't have folder modify permissions
if (check_auth($fid, "folder_modify", $userid) == 0)
{
$gray = 1;
}
if ($gray) {
print "<img src='$default->owl_root_url/locale/$default->owl_lang/graphics/icons/folder_gray.gif' height=16 width=16 align=top>";
print " <font color=\"silver\">$folder</font><br>\n";
}
else
{
print "<input type='image' border=0 src='$default->owl_root_url/locale/$default->owl_lang/graphics/icons/folder_closed.gif' height=16 width=16 align=top name=\"ID";
print "$fid\"> $folder<br>\n";
}
//Don't show subtree of selected folder as target for folder move
if (($action=="folder") && ($fid==$id))
{
return;
}
//recurse through all the folders in the current folder and
//display their sub-folders
for ($c=0; $c < $fCount; $c++) {
if ($folderList[$c][2]==$fid) {
$fDepth++;
showFoldersIn( $folderList[$c][0] , $folderList[$c][1] );
$fDepth--;
}
}
}
if ($action=="$lang_cancel_button") {
header("Location: browse.php?sess=$sess&parent=$parent&expand=$expand&order=$order&$sortorder=$sortname");
exit();
}
checkForNewFolder();
//if there is a new folder
if (isset($newFolder)) {
$sql = new Owl_DB;
$source="";
$fID=$parent;
do {
//build the directory path from the root folder to the current parent folder
$sql->query("select name,parent from $default->owl_folders_table where id='$fID'");
while($sql->next_record()) {
$tName = $sql->f("name");
$fID = $sql->f("parent");
}
$source=$tName."/".$source;
} while ($fID != 0);
$dest="";
$fID=$newFolder;
do {
//build the directory path from the root folder to the new folder
$sql->query("select name,parent from $default->owl_folders_table where id='$fID'");
while($sql->next_record()) {
$tName = $sql->f("name");
$fID = $sql->f("parent");
}
$dest=$tName."/".$dest;
} while ($fID != 0);
if ($action=="file") {
$sql = new Owl_DB;
$sql->query("select filename, parent from $default->owl_files_table where id = '$id'");
while($sql->next_record()) {
$fname = $sql->f("filename");
$parent = $sql->f("parent");
}
} else {
$sql = new Owl_DB;
$sql->query("select name, parent from $default->owl_folders_table where id='$id'");
while($sql->next_record()) {
$fname = $sql->f("name");
$parent = $sql->f("parent");
}
}
//if we're using the file system
//then move the file
if($default->owl_use_fs) {
if ($type != "url") {
if (!file_exists("$default->owl_FileDir/$dest$fname")) {
if (substr(php_uname(), 0, 7) != "Windows") {
$cmd="mv \"$default->owl_FileDir/$source$fname\" \"$default->owl_FileDir/$dest\" 2>&1";
$lines=array();$errco=0;
$result = myExec($cmd,$lines,$errco);
if ( $errco != 0 )
printError($lang_err_movecancel, $result);
}
else {
// IF Windows just do a rename and hope for the best
rename ("$default->owl_FileDir/$source$fname", "$default->owl_FileDir/$dest/$fname");
}
}
else
printError($lang_err_fileexists,$result);
}
}
if ($action=="file") {
$sql->query("update $default->owl_files_table set parent='$newFolder' where id='$id'");
} else {
$sql->query("update $default->owl_folders_table set parent='$newFolder' where id='$id'");
}
header("Location: browse.php?sess=$sess&parent=$parent&expand=$expand&order=$order&$sortorder=$sortname");
}
// First time through. Generate screen for selecting target directory
include("./lib/header.inc");
print("<TABLE WIDTH=$default->table_expand_width BGCOLOR=$default->main_header_bgcolor CELLSPACING=0 CELLPADDING=0 BORDER=$default->table_border HEIGHT=30>");
?>
<TR><TD ALIGN=LEFT>
<?php print("$lang_user: ");
if(prefaccess($userid)) {
print("<A HREF='prefs.php?owluser=$userid&sess=$sess&expand=$expand&order=$order&sortname=$sortname'>");
}
print uid_to_name($userid);
print ("</A>");
?>
<FONT SIZE=-1>
<?php print("<A HREF='index.php?login=logout&sess=$sess'>$lang_logout</A>");?>
</FONT></TD><TD ALIGN=RIGHT>
<?php print("<A HREF='browse.php?sess=$sess&parent=$parent&expand=$expand&order=$order&$sortorder=$sortname'><IMG SRC='$default->owl_root_url/locale/$language/graphics/btn_browse.gif' BORDER=0>");?>
</A></TD></TR></TABLE>
<?php
print("<CENTER>");
// Get information about file or directory we want to move
if ($action=="file") {
$sql = new Owl_DB;
$sql->query("select filename, parent from $default->owl_files_table where id='$id'");
} else {
$sql = new Owl_DB;
$sql->query("select name, parent from $default->owl_folders_table where id='$id'");
}
while($sql->next_record()) {
if($action == "file") $fname = $sql->f("filename");
if($action == "folder") $fname = $sql->f("name");
$parent = $sql->f("parent");
}
//print "<p>$lang_moving $action $fname. $lang_select</p>";
print "<p>$lang_moving $fname. $lang_select</p>";
?>
<div align="center">
<form method="POST">
<input type="hidden" name="parent" value="<?php print $parent; ?>">
<input type="hidden" name="expand" value="<?php print $expand; ?>">
<input type="hidden" name="order" value="<?php print $order; ?>">
<input type="hidden" name="action" value="<?php print $action; ?>">
<input type="hidden" name="fname" value="<?php print $fname; ?>">
<input type="hidden" name="id" value="<?php print $id; ?>">
<table cellspacing=0 border=1 cellpadding=4><tr><td align=left><p>
<?php
// Get list of folders sorted by name
$sql->query("select id,name,parent from $default->owl_folders_table order by name");
$i=0;
while($sql->next_record()) {
$folderList[$i][0] = $sql->f("id");
$folderList[$i][1] = $sql->f("name");
$folderList[$i][2] = $sql->f("parent");
$i++;
}
$fCount = count($folderList);
$fDepth=0;
$excludeID=$parent; // current location should not be a offered as a target
showFoldersIn(1, fid_to_name("1"));
?>
</p></td></tr></table>
<br>
<input TYPE="submit" name="action" VALUE="<?php print $lang_cancel_button; ?>">
</form>
</div>
<?php
include("./lib/footer.inc");
?>