From 8ed274d7c96e501c7f8a30e6706eeeee1fdf827d Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Sun, 13 Mar 2016 04:47:00 -0700 Subject: [PATCH] Clean up c64com online checker --- wizzardRedux/admin/onlinecheck.php | 2 +- wizzardRedux/sites/C64ch.php | 3 - wizzardRedux/sites/c64com.php | 100 +++++++++++++---------------- 3 files changed, 47 insertions(+), 58 deletions(-) diff --git a/wizzardRedux/admin/onlinecheck.php b/wizzardRedux/admin/onlinecheck.php index daa9543..0737574 100644 --- a/wizzardRedux/admin/onlinecheck.php +++ b/wizzardRedux/admin/onlinecheck.php @@ -28,7 +28,7 @@ TODO: Document all required GET and POST vars for each page TODO: VideopacNL uses a cookie to be able to access the board. This means you need to log in to the site and then copy the cookie as a param TODO: Can we run all online checks in a coherent way (in series, that is)? TODO: Once all checkers are certainly using the new table and found format, standardize $found and move to this file -TODO: Last updated - C64ch +TODO: Last updated - c64com ------------------------------------------------------------------------------------ */ ini_set('max_execution_time', 0); // Set the execution time to infinite. This is a bad idea in production. diff --git a/wizzardRedux/sites/C64ch.php b/wizzardRedux/sites/C64ch.php index efdaec6..3a526e0 100644 --- a/wizzardRedux/sites/C64ch.php +++ b/wizzardRedux/sites/C64ch.php @@ -2,9 +2,6 @@ // Original code: The Wizard of DATz -// TODO: Fix naming issue (comes up with "Array" for one part) -// TODO: Find end of list without having to add start - $x = implode('', array_flip($r_query)); echo "\n"; diff --git a/wizzardRedux/sites/c64com.php b/wizzardRedux/sites/c64com.php index 525f6e5..800e0df 100644 --- a/wizzardRedux/sites/c64com.php +++ b/wizzardRedux/sites/c64com.php @@ -2,10 +2,6 @@ // Original code: The Wizard of DATz -print "
";
-print "load demos\n";
-print "load games\n";
-	
 $url = array(
 	'demos' => 'http://www.c64.com/demos/demos_show.php?showid=',
 	'games' => 'http://www.c64.com/games/no-frame.php?showid=',
@@ -17,80 +13,76 @@ $demos_start = $demos_start[1];
 $games_start = explode("=", $r_query[1]);
 $games_start = $games_start[1];
 
+echo "
\n"; $demos_end = parse_games("demos", $demos_start); $games_end = parse_games("games", $games_start); +echo "
\n"; -/* -// Handy AFTER we automatically download -$handle = fopen("../sites/".$source.".txt", "w"); -fwrite($handle, "demos=".$demos_end); -fwrite($handle, "games=".$games_end); -fclose($handle); -*/ - -function parse_games($type, $start) +if (sizeof($found) > 0) { - print "loading ".$type."\n"; + echo "

New files:

"; +} + +foreach ($found as $row) +{ + echo "".$row[0]."
\n"; +} + +echo "
\n"; - for ($x = $start; $x < $start + 50; $x++) +function parse_games($type, $x) +{ + GLOBAL $found, $url; + + echo "".$type.""; + + while (true) { + echo "".$url[$type].$x.""; + $query = get_data($url[$type].$x); + + if (preg_match("/Download\s+now/s", $query) !== 1) + { + break; + } + if ($type == 'demos') { - $query = explode('', $query); - $query = explode('', $query[1]); - $query = $query[0]; + preg_match("/(.*?)<\/td>/s", $query, $query); + $query = $query[1]; } else { - $query = explode('', $query); - $query = explode('', $query[1]); - $query = $query[0]; + preg_match("/(.*?)<\/td>/s", $query, $query); + $query = $query[1]; } - $gametitle = explode('', $query); - $gametitle = explode('', $gametitle[1]); - $gametitle = trim($gametitle[0]); + preg_match("/(.*?)<\/span>/s", $query, $gametitle); + $gametitle = trim($gametitle[1]); - $addinfo = explode('(.*?)<\/a>/s", $query, $addinfo); $infos = array(); - - foreach ($addinfo as $info) + foreach ($addinfo[1] as $info) { - if ($info) + $info = str_replace(array('(', ')', '?'), array('', '', 'x'), trim(strip_tags($info))); + if ($info !== "") { - $info = explode('', $info); - $info = str_replace(array('(', ')', '?'), array('', '', 'x'), trim(strip_tags(' 0) { $gametitle = $gametitle." (".implode(") (", $infos).")"; } - if ($gametitle) - { - print $x."\t".$gametitle.".zip\n"; - $last = $x; - } - else - { - print $x."\tnot found\n"; - } - } - - if ($last) - { - $start = $last + 1; - - print "\nnext startnr\t".$start.""; + $found[] = array("{".$type."-".$x."}".$gametitle.".zip", "http://www.c64.com/".$type."/download.php?id=".$x); + $last = $x; + + echo "Found new: 1, old: 0\n"; + + $x++; } return $start;