-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdater.php
More file actions
55 lines (42 loc) · 1.7 KB
/
updater.php
File metadata and controls
55 lines (42 loc) · 1.7 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
<?php // $Id:,v 2.0 2012/05/20 16:10:00 Serafim Panov
require_once("../../config.php");
require_once("lib.php");
$rm = array();
if ($handle = opendir($CFG->dataroot)) {
make_upload_directory('reader/images');
/* This is the correct way to loop over the directory. */
while (false !== ($entry = readdir($handle))) {
if (is_number($entry)){
if(is_dir($CFG->dataroot."/".$entry."/images")){
if ($handle2 = opendir($CFG->dataroot."/".$entry."/images")) {
while (false !== ($entry2 = readdir($handle2))) {
if (is_file($CFG->dataroot."/".$entry."/images/".$entry2)){
echo "$entry2<br />";
copy($CFG->dataroot."/".$entry."/images/".$entry2, $CFG->dataroot.'/reader/images/'.$entry2);
}
}
}
rrmdir($CFG->dataroot."/".$entry."/images");
$rm[] = $CFG->dataroot."/".$entry;
}
}
}
closedir($handle);
}
sleep(2);
foreach($rm as $rm_){
@rmdir($rm_);
}
echo '<br />All images was moved to new location. Please delete this file. reader/updater.php<br /><br />';
function rrmdir($dir) {
if (is_dir($dir)) {
$objects = scandir($dir);
foreach ($objects as $object) {
if ($object != "." && $object != "..") {
if (filetype($dir."/".$object) == "dir") rrmdir($dir."/".$object); else unlink($dir."/".$object);
}
}
reset($objects);
rmdir($dir);
}
}