forked from openenergymonitor/learn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
imglist.php
58 lines (50 loc) · 2.03 KB
/
imglist.php
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
<?php
die;
$result = scandir("view");
for ($i=2; $i<count($result); $i++) {
$dir = $result[$i];
$nicename = str_replace("-"," ",$dir);
if (is_dir("view/$dir")) {
$l2 = scandir("view/$dir");
for ($i2=2; $i2<count($l2); $i2++) {
$dir2 = $l2[$i2];
$nicename = str_replace("-"," ",$dir2);
if (is_dir("view/$dir/$dir2")) {
$l3 = scandir("view/$dir/$dir2");
for ($i3=2; $i3<count($l3); $i3++) {
$dir3 = $l3[$i3];
$nicename = str_replace("-"," ",$dir3);
$nicename = str_replace(".html","",$nicename);
$nicename = str_replace(".php","",$nicename);
if (is_file("view/$dir/$dir2/$dir3")) {
$body = file_get_contents("view/$dir/$dir2/$dir3");
$results = array();
strpos_recursive($body,".gif",0,$results);
foreach ($results as $line) {
print $line." ";
if (file_exists("files/$line")) {
print "ok";
exec("cp files/$line f2/$line");
}
print "\n";
}
}
}
echo "</ul></div>";
}
}
echo "</div>";
}
}
function strpos_recursive($haystack, $needle, $offset = 0, &$results = array()) {
$offset = strpos($haystack, $needle, $offset);
if($offset === false) {
return $results;
} else {
$maxlen = 200;
$str = substr($haystack,$offset-$maxlen,$maxlen+4);
$parts = explode("/",$str);
$results[] = $parts[count($parts)-1];
return strpos_recursive($haystack, $needle, ($offset + 1), $results);
}
}