1 |
<?php |
2 |
|
3 |
/* |
4 |
backup.php -- make a backup of docman site using mass downloader |
5 |
|
6 |
Dobrica Pavlinusic <dpavlin@rot13.org> |
7 |
v0.0 2001-05-25 |
8 |
|
9 |
Usage: |
10 |
|
11 |
rename this script to .backup.php in same dir where .index.php is |
12 |
|
13 |
$ wget -r -np http://docman.site.com/.backup.php?secret |
14 |
|
15 |
where "secret" is password defined below! |
16 |
|
17 |
*/ |
18 |
|
19 |
|
20 |
// change this to password |
21 |
$password="secret"; |
22 |
|
23 |
$dir=dirname($SCRIPT_FILENAME); |
24 |
$dir_len=strlen($dir)-strlen(dirname($SCRIPT_NAME)); |
25 |
|
26 |
|
27 |
////////////////////////////////////////////////////////////////// |
28 |
|
29 |
function urlpath($url) { |
30 |
$url=urlencode(StripSlashes("$url")); |
31 |
$url=str_replace("%2F","/",$url); |
32 |
$url=str_replace("+","%20",$url); |
33 |
return($url); |
34 |
} |
35 |
|
36 |
////////////////////////////////////////////////////////////////// |
37 |
|
38 |
|
39 |
print "<html> |
40 |
<head> |
41 |
<title>backup docman site</title> |
42 |
</head> |
43 |
<body>"; |
44 |
|
45 |
if ($QUERY_STRING != $password) { |
46 |
print "you are not allowed to do backup!"; |
47 |
} else { |
48 |
|
49 |
print "<h1>Files to backup:</h1><ul>"; |
50 |
|
51 |
$dirs = array( $dir ); |
52 |
|
53 |
while ($dirs) { |
54 |
|
55 |
$dir=array_shift($dirs); |
56 |
$handle=opendir($dir); |
57 |
while ($file = readdir($handle)) { |
58 |
if (substr($file,0,1) != ".") { |
59 |
if (is_dir("$dir/$file")) |
60 |
array_push($dirs,"$dir/$file"); |
61 |
else |
62 |
$url=urlpath(substr("$dir",$dir_len,strlen($dir)-$dir_len)."/$file"); |
63 |
if ($url != "") { |
64 |
print "<li><a href=\"$url\">$url</a> [$dir/$file]\n"; |
65 |
} |
66 |
} |
67 |
} |
68 |
closedir($handle); |
69 |
} |
70 |
|
71 |
print "</ul>"; |
72 |
} |
73 |
|
74 |
print " |
75 |
</body> |
76 |
</html> |
77 |
"; |