Repository navigation
Expand file tree
/
Copy pathstack.php
More file actions
87 lines (68 loc) · 2.43 KB
/
Copy pathstack.php
File metadata and controls
87 lines (68 loc) · 2.43 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
<?php
/*
Created @ 19.10.2010 by TheFox@fox21.at
Copyright (c) 2010 TheFox
This file is part of PHPDL.
PHPDL is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
PHPDL is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with PHPDL. If not, see <http://www.gnu.org/licenses/>.
*/
define('ANTIHACK', 1);
if(isset($_SERVER['SERVER_ADDR'])) die('Hacking attempt.');
include_once('./lib/config.php');
include_once('./lib/functions.php');
include_once('./lib/class.dlpacket.php');
include_once('./lib/class.dlfile.php');
while(true){
$dbh = dbConnect();
#$packets = getDbTable($dbh, 'packets', "where archive = '0'");
$resdls = mysql_fetch_assoc(mysql_query("select count(id) c from files where stime != '0' and ftime = '0';", $dbh));
if($resdls['c'] >= $CONFIG['DL_SLOTS']){
print "no free download slots\n";
}
else{
$res = mysql_query("select id from packets where archive = '0' order by id;", $dbh);
while($row = mysql_fetch_assoc($res)){
$packet = new dlpacket($CONFIG['DB_HOST'], $CONFIG['DB_NAME'], $CONFIG['DB_USER'], $CONFIG['DB_PASS']);
if($packet->loadById($row['id'])){
print "packet ".$packet->get('id')."\n";
if(!$packet->fileErrors() && !$packet->get('ftime')){
if($packet->loadFiles()){
if($packet->filesUnfinished()){
if(!$packet->get('stime'))
$packet->save('stime', mktime());
if($nextfile = $packet->getFileNextUnfinished()){
$nextfile->set('error', $DLFILE_ERROR_NO_ERROR);
$nextfile->set('stime', mktime());
$nextfile->set('ftime', 0);
$nextfile->save();
print "\tstart download ".$nextfile->get('id')."\n";
system('php wget.php '.$nextfile->get('id').' &> /dev/null &');
break;
}
else
print "\tno next file\n";
}
else{
print "\tall files finished\n";
$packet->save('ftime', mktime());
$packet->md5Verify();
}
}
}
}
unset($packet);
}
}
dbClose($dbh);
print "sleep 1\n\n";
sleep(1);
}
?>