$query="SELECT id, name, image1 , seeders, leechers, category, size FROM torrents WHERE banned ='no' AND visible='yes' AND image1 <> '' ORDER BY added DESC limit 45";
//===| Scrape External Torrents
if ($row["external"]=='yes'){
print ("<td width='160' align='right' valign='top'><table><tr>");
if ($scrape =='1'){
print("<td class='table_col1' width='150' valign='middle'>
<div style='margin-top:5px; margin-bottom:10px; font:bold 16px Times' align='center'><font color='#FF2000'>".T_("EXTERNAL_TORRENT")."</font></div>");
//===| UDP Scraper
$resu = SQL_Query_exec("SELECT id, info_hash FROM torrents WHERE external = 'yes' AND id = $id");
while ($rowu = mysql_fetch_array($resu)) {
$TorrentInfo = ParseTorrent("$site_config[torrent_dir]/$rowu[id].torrent");
$ann = $TorrentInfo[0];
$annlist = array();
if ($TorrentInfo[6]) {
foreach ($TorrentInfo[6] as $ann) {
$annlist[] = $ann[0];
}
} else
$annlist = array($ann);
$seeders = $leechers = $downloaded = null;
foreach ($annlist as $ann) {
$tracker = explode("/", $ann);
$path = array_pop($tracker);
$oldpath = $path;
$path = str_replace("announce", "scrape", $path);
$tracker = implode("/", $tracker)."/".$path;
if ($oldpath == $path) {
continue;
}
if ($openbittorrent_done)
continue;
if (preg_match("/thepiratebay.org/i", $tracker) || preg_match("/prq.to/", $tracker)) {
$tracker = "http://tracker.openbittorrent.com/scrape";
$openbittorrent_done = 1;
}
if(preg_match('%udp://([^:/]*)(?:[0-9]*))?(?:/)?%si', $tracker)) {
$udp=true;
try
{
$timeout = 5;
$udp= new udptscraper($timeout);
$stats=$udp->scrape($tracker,$rowu["info_hash"]);
foreach ($stats as $idu=>$scrape) {
$seeders += $scrape['seeders'];
$leechers += $scrape['leechers'];
$downloaded += $scrape['completed'];
}
}
catch(ScraperException $e) {
$e->isConnectionError();
}
} else {
$stats = torrent_scrape_url($tracker, $rowu["info_hash"]);
}
if ($stats['seeds'] != -1) {
$seeders += $stats['seeds'];
$leechers += $stats['peers'];
$downloaded += $stats['downloaded'];
SQL_Query_exec("UPDATE `announce` SET `online` = 'yes', `seeders` = $stats[seeds], `leechers` = $stats[peers], `times_completed` = $stats[downloaded] WHERE `url` = ".sqlesc($ann)." AND `torrent` = $rowu[id]");
} else {
SQL_Query_exec("UPDATE `announce` SET `online` = 'no' WHERE `url` = ".sqlesc($ann)." AND `torrent` = $rowu[id]");
}
}
if ($seeders !== null) {
SQL_Query_exec("UPDATE torrents SET leechers = '".$leechers."', seeders = '".$seeders."', times_completed = '".$downloaded."', last_action = '".get_date_time()."', visible = 'yes' WHERE id = '".$rowu['id']."'");
} else {
SQL_Query_exec("UPDATE torrents SET last_action = '".get_date_time()."' WHERE id='".$rowu['id']."'");
}
}
//===| End UDP Scraper "Storm, post: 93989":if you have root access to your server check your apache error logs, it will tell you in there what is causing the http 500 error
//===| Scrape External Torrents
if ($row["external"]=='yes')
{
print ("<td width='160' align='right' valign='top'><table><tr>");
if ($scrape =='1')
{
print("<td class='table_col1' width='150' valign='middle'>
<div style='margin-top:5px; margin-bottom:10px; font:bold 16px Times' align='center'><font color='#FF2000'>".T_("EXTERNAL_TORRENT")."</font></div>");
//===| UDP Scraper
$resu = SQL_Query_exec("SELECT id, info_hash FROM torrents WHERE external = 'yes' AND id = $id");
while ($rowu = mysql_fetch_array($resu))
{
$TorrentInfo = ParseTorrent("$site_config[torrent_dir]/$rowu[id].torrent");
$ann = $TorrentInfo[0];
$annlist = array();
if ($TorrentInfo[6])
{
foreach ($TorrentInfo[6] as $ann)
{
$annlist[] = $ann[0];
}
}
else
$annlist = array($ann);
$seeders = $leechers = $downloaded = null;
foreach ($annlist as $ann)
{
$tracker = explode("/", $ann);
$path = array_pop($tracker);
$oldpath = $path;
$path = str_replace("announce", "scrape", $path);
$tracker = implode("/", $tracker)."/".$path;
if ($oldpath == $path)
{
continue;
}
if ($openbittorrent_done)
continue;
if (preg_match("/thepiratebay.org/i", $tracker) || preg_match("/prq.to/", $tracker))
{
$tracker = "http://tracker.openbittorrent.com/scrape";
$openbittorrent_done = 1;
}
if(preg_match('%udp://([^:/]*)(?:[0-9]*))?(?:/)?%si', $tracker))
{
$udp=true;
try
{
$timeout = 5;
$udp= new udptscraper($timeout);
$stats=$udp->scrape($tracker,$rowu["info_hash"]);
foreach ($stats as $idu=>$scrape)
{
$seeders += $scrape['seeders'];
$leechers += $scrape['leechers'];
$downloaded += $scrape['completed'];
}
}
catch(ScraperException $e)
{
$e->isConnectionError();
}
}
else
{
$stats = torrent_scrape_url($tracker, $rowu["info_hash"]);
}
if ($stats['seeds'] != -1)
{
$seeders += $stats['seeds'];
$leechers += $stats['peers'];
$downloaded += $stats['downloaded'];
SQL_Query_exec("UPDATE `announce` SET `online` = 'yes', `seeders` = $stats[seeds], `leechers` = $stats[peers], `times_completed` = $stats[downloaded] WHERE `url` = ".sqlesc($ann)." AND `torrent` = $rowu[id]");
}
else
{
SQL_Query_exec("UPDATE `announce` SET `online` = 'no' WHERE `url` = ".sqlesc($ann)." AND `torrent` = $rowu[id]");
}
}
if ($seeders !== null)
{
SQL_Query_exec("UPDATE torrents SET leechers = '".$leechers."', seeders = '".$seeders."', times_completed = '".$downloaded."', last_action = '".get_date_time()."', visible = 'yes' WHERE id = '".$rowu['id']."'");
}
else
{
SQL_Query_exec("UPDATE torrents SET last_action = '".get_date_time()."' WHERE id='".$rowu['id']."'");
}
}
//===| End UDP Scraper "UFFENO1, post: 93925":And all mysql_query should be SQL_Query_exec
echo "<center><table align='center' width='100%' height='200' border='0'><tr>";