-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcsdb-idrepair.php
76 lines (62 loc) · 1.88 KB
/
csdb-idrepair.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
<?php
require_once("scripts-bootstrap.inc.php");
function fixCSDBFromDownloadID( $prod )
{
printf("pouet: %6d | ",$prod->id);
if (!preg_match("/csdb\.dk\/release\/download\.php\?id=(\d+)/",$prod->download,$m))
{
printf("regex error");
return false;
}
printf("%6d -> ",$m[1]);
$csdbResponse = @file_get_contents(sprintf("https://csdb.dk/misc/getreleaseidfromdownloadid.php?dlid=%d",$m[1]));
$csdbID = (int)$csdbResponse;
if (!$csdbID)
{
printf("error: '%s'",$csdbResponse);
return false;
}
printf("csdb: %d",$csdbID);
SQLLib::UpdateRow("prods",array("csdb"=>(int)$csdbID),sprintf_esc("id=%d",$prod->id));
return true;
}
function fixCSDBFromGetinternalfileID( $prod )
{
printf("pouet: %6d | ",$prod->id);
if (!preg_match("/csdb\.dk\/getinternalfile\.php\/(\d+)\//",$prod->download,$m))
{
printf("regex error");
return false;
}
printf("%6d -> ",$m[1]);
$csdbResponse = @file_get_contents(sprintf("https://csdb.dk/misc/getreleaseidfromdownloadid.php?gifid=%d",$m[1]));
$csdbID = (int)$csdbResponse;
if (!$csdbID)
{
printf("error: '%s'",$csdbResponse);
return false;
}
printf("csdb: %d",$csdbID);
SQLLib::UpdateRow("prods",array("csdb"=>(int)$csdbID),sprintf_esc("id=%d",$prod->id));
return true;
}
$prods = SQLLib::SelectRows("select * from prods ".
" where download like '%csdb.dk/release/download.php%' and csdb = 0");
printf("download.php links: %d\n",count($prods));
$i = 0;
foreach($prods as $prod)
{
printf("%5d / %5d | ",$i++,count($prods));
fixCSDBFromDownloadID($prod);
printf("\n");
}
$prods = SQLLib::SelectRows("select * from prods ".
" where download like '%csdb.dk/getinternalfile.php%' and csdb = 0");
printf("getinternalfile.php links: %d\n",count($prods));
$i = 0;
foreach($prods as $prod)
{
printf("%5d / %5d | ",$i++,count($prods));
fixCSDBFromGetinternalfileID($prod);
printf("\n");
}