Die functionaliteit heb ik mijn eigen filemanager ook gegeven! Superhandig, als je bijvoorbeeld op het werk niet kan downloaden van een bepaalde site
Dit is wat ik heb, doe ermee wat je wilt.
Het is wat oude code dus wellicht dat ik het beter kan

Tipz zijn altijd welkom
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
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
| function processdownload() {
// Processes the URL-download
global $storepath, $DB_site;
$url=$_POST[geturl];
/*/ Display message before downloading
echo '<td class="upload"><p class="error"><br /><br />Attempting to download from:<br />'.$url.'<br /></p></td>';
flush;*/
// Delete other temp files
cleanup();
// Download requested file(s)
$execcmd='wget -nv -T30 -t3 --passive-ftp --directory-prefix=\''.$storepath.'dltemp\' '.escapeshellarg($url);
exec($execcmd);
// Generate filelist for users acknowledgement
$files='';
$i=0;
$downloads=dir($storepath.'dltemp');
while (false !== ($entry = $downloads->read())) {
if ($entry!="." and $entry!="..") {
$i++;
$file['name'][$i]=$entry;
$file['size'][$i]=filesize($storepath.'dltemp/'.$entry);
$files.="<strong>{$file['name'][$i]}</strong> (".(intval(($file['size'][$i]/1024)*100)/100)." kB)<br />";
}
}
$downloads->close();
// Download success, but does they need to be saved?
include('./header.inc.php');
if ($i>=1) {
$return ='<strong>Successfully downloaded this file(s):</strong><br />'.$files.'<br /><br /><strong>Do you want to save this download(s)?</strong>';
$return.='<form name="storeform" id="storeform" action="'.$_SERVER[PHP_SELF].'" method="POST"><input type="hidden" name="action" value="savefiles">';
$return.='<p class="strong"><a href="javascript:void()" onclick="document.storeform.submit();">[ Yes ]</a> <a href="?action=cleanup">[ No ]</a><br /><br /></p></form>';
echo '<td class="upload"><p class="strong"><br /><br />'.$return.'<br /></p></td>';
} else {
$return ='Error: Download failed; no files saved!';
echo '<td class="upload"><p class="error"><br /><br />'.$return.'<br /></p></td>';
}
include('./footer.inc.php');
exit;
}
function storedownload() {
// Store the downloaded files into the database
global $storepath, $DB_site;
$files='';
$i=0;
$downloads=dir($storepath.'dltemp');
while (false !== ($entry = $downloads->read())) {
if ($entry!="." and $entry!="..") {
$fileid=getfileid();
$source=$storepath.'dltemp/'.$entry;
$target=$storepath."stor".$fileid;
// Get info for database
$filename=$entry;
$filesize=filesize($source);
$comments=addslashes($_POST[comments]);
// Move from download dir to storage dir
rename($source,$target);
// All fine, add database entry
$DB_site->query("INSERT INTO filenames (id,filename,size,fileid,dateline,comments)
VALUES ('0','".$filename."','".$filesize."','".$fileid."','".time()."','".$comments."')");
}
}
$downloads->close();
message('File(s) successfully stored!',"strong","?");
exit;
}
function cleanup() {
// Deletes all files in /dltemp under $storepath
global $storepath;
$oldtemps=dir($storepath.'dltemp');
while (false !== ($entry = $oldtemps->read())) {
if ($entry!="." and $entry!="..") {
unlink($storepath.'dltemp/'.$entry);
}
}
$oldtemps->close();
} |
Korte uitleg algemene werking van mijn Filemanager: Bestanden worden in $storepath opgeslagen met een random ID. De echte filename wordt in de database opgeslagen.
[
Voor 174% gewijzigd door
Room42 op 01-02-2005 01:22
]