-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexport.php
58 lines (45 loc) · 1.3 KB
/
export.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
ob_start('ob_gzhandler');
$handle = fopen("hash.dat", "r");
while ($hashinfo = fscanf($handle, "%s\n")) {
list ($info_hash) = $hashinfo;
include("config.php");
function dbconn()
{
global $mysql_host, $mysql_user, $mysql_pass, $mysql_db;
if (!@mysql_connect($mysql_host, $mysql_user, $mysql_pass))
{
die('dbconn: mysql_connect: ' . mysql_error());
}
mysql_select_db($mysql_db)
or die('dbconn: mysql_select_db: ' + mysql_error());
}
function hex2bin($hexdata)
{
$bindata = "";
for ($i=0;$i<strlen($hexdata);$i+=2)
{
$bindata.=chr(hexdec(substr($hexdata,$i,2)));
}
return $bindata;
}
dbconn();
header("Content-Type: text/plain");
$source = fopen("cache.dat","r");
$i=0;
while ($info = fscanf ($source, "%d %d %d\n")) {
list ($seeders, $completed,$leechers) = $info;
if (mysql_query("
UPDATE `namemap` SET `seeds` = '$seeders',
`leechers` = '$leechers',
`finished` = '$completed',
`lastupdate` = NOW( ) WHERE `info_hash` = '$info_hash' LIMIT 1 ;
"))
$i++;
else mysql_error();
}
echo "Successfully exported $i torrents\n";
fclose($source);
}
fclose($handle);
?>