Files
wizzardRedux/sites/c64com.php

90 lines
1.9 KiB
PHP
Raw Permalink Normal View History

<?php
// Original code: The Wizard of DATz
$url = array(
'demos' => 'http://www.c64.com/demos/demos_show.php?showid=',
'games' => 'http://www.c64.com/games/no-frame.php?showid=',
);
$r_query = array_flip($r_query);
$demos_start = explode("=", $r_query[0]);
$demos_start = $demos_start[1];
$games_start = explode("=", $r_query[1]);
$games_start = $games_start[1];
2016-03-13 04:47:00 -07:00
echo "<table>\n";
$demos_end = parse_games("demos", $demos_start);
$games_end = parse_games("games", $games_start);
2016-03-13 04:47:00 -07:00
echo "</table>\n";
if (sizeof($found) > 0)
{
echo "<h2>New files:</h2>";
}
foreach ($found as $row)
{
echo "<a href='".$row[1]."'>".$row[0]."</a><br/>\n";
}
2016-03-13 04:47:00 -07:00
echo "<br/>\n";
2016-03-13 04:47:00 -07:00
function parse_games($type, $x)
{
2016-03-13 04:47:00 -07:00
GLOBAL $found, $url;
echo "<tr><td colspan=2>".$type."</td></tr>";
2016-03-13 04:47:00 -07:00
while (true)
{
2016-03-13 04:47:00 -07:00
echo "<tr><td>".$url[$type].$x."</td>";
$query = get_data($url[$type].$x);
2016-03-13 04:47:00 -07:00
if (preg_match("/Download\s+now/s", $query) !== 1)
{
break;
}
if ($type == 'demos')
{
2016-03-13 04:47:00 -07:00
preg_match("/<td height=\"41\" align=\"center\" valign=\"middle\" bgcolor=\"#535353\">(.*?)<\/td>/s", $query, $query);
$query = $query[1];
}
else
{
2016-03-13 04:47:00 -07:00
preg_match("/<td height=\"41\" colspan=\"2\">(.*?)<\/td>/s", $query, $query);
$query = $query[1];
}
2016-03-13 04:47:00 -07:00
preg_match("/<span class=\"headline_1\">(.*?)<\/span>/s", $query, $gametitle);
$gametitle = trim($gametitle[1]);
2016-03-13 04:47:00 -07:00
preg_match_all("/<a.*?>(.*?)<\/a>/s", $query, $addinfo);
$infos = array();
2016-03-13 04:47:00 -07:00
foreach ($addinfo[1] as $info)
{
2016-03-13 04:47:00 -07:00
$info = str_replace(array('(', ')', '?'), array('', '', 'x'), trim(strip_tags($info)));
if ($info !== "")
{
2016-03-13 04:47:00 -07:00
$infos[] = $info;
}
}
2016-03-13 04:47:00 -07:00
if (sizeof($infos) > 0)
{
$gametitle = $gametitle." (".implode(") (", $infos).")";
}
2016-03-13 04:47:00 -07:00
$found[] = array("{".$type."-".$x."}".$gametitle.".zip", "http://www.c64.com/".$type."/download.php?id=".$x);
$last = $x;
echo "<td>Found new: 1, old: 0</tr>\n";
$x++;
}
return $start;
}
?>