-
Notifications
You must be signed in to change notification settings - Fork 0
/
sceneorg-link-upgrade.php
89 lines (84 loc) · 2.14 KB
/
sceneorg-link-upgrade.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
<?
require_once("scripts-bootstrap.inc.php");
function replace_sceneorg_url( $urlIn, &$urlOut )
{
if(strstr($urlIn,"scene.org/file.php") !== false)
{
$url = parse_url($urlIn);
parse_str($url["query"],$res);
if ($res["file"])
{
$urlOut = "https://files.scene.org/view/".ltrim($res["file"],"/");
return true;
}
}
else if(strstr($urlIn,"scene.org/dir.php") !== false)
{
$url = parse_url($urlIn);
parse_str($url["query"],$res);
if ($res["dir"])
{
$urlOut = "https://files.scene.org/browse/".ltrim($res["dir"],"/");
return true;
}
}
else if(strstr($urlIn,"scene.org/file_dl.php") !== false)
{
$url = parse_url($urlIn);
parse_str($url["query"],$res);
if ($res["url"])
{
//$urlOut = "https://files.scene.org/browse/".ltrim($res["dir"],"/");
$mirrors = array(
"ftp://ftp.scene.org/pub/",
"ftp://ftp.de.scene.org/pub/",
"http://http.de.scene.org/pub/",
"http://http.fr.scene.org/",
"http://http.se.scene.org/pub/demos/scene.org/",
);
foreach($mirrors as $m)
{
if (strpos($res["url"],$m)===0)
{
$urlOut = "https://files.scene.org/view/".str_replace($m,"",$res["url"]);
return true;
}
}
}
}
return false;
}
function doReplace($table,$field)
{
echo "\nParsing ".$table.".".$field."\n";
$rows = SQLLib::SelectRows("select id,".$field." from ".$table." where ".$field." like '%scene.org/file%' or ".$field." like '%scene.org/dir%'");
$a = array();
foreach($rows as $row)
{
$url = "";
if (replace_sceneorg_url($row->{$field},$url))
{
printf("%s\n-> %s\n",$row->{$field},$url);
$row = array();
$row["id"] = $row->id;
$row[$field] = $url;
$a[] = $row;
}
if (count($a) >= 100)
{
echo "Update...\n";
//SQLLib::UpdateRowMulti($table,"id",$a);
$a = array();
}
}
if (count($a) >= 0)
{
echo "Final update...\n";
//SQLLib::UpdateRowMulti($table,"id",$a);
$a = array();
}
}
doReplace("prods","download");
doReplace("downloadlinks","link");
doReplace("partylinks","download");
?>