site = $s->get();
$this->echooutput = $echooutput;
$this->db = new DB();
$this->c = new ColorCLI;
}
// Retrieve pre info from predb sources and store them in the DB.
// Returns the quantity of new titles retrieved.
public function combinePre($nntp)
{
$db = new DB();
$f = new Functions();
$newnames = 0;
$newestrel = $db->queryOneRow("SELECT adddate, ID FROM prehash ORDER BY adddate DESC LIMIT 1");
if (strtotime($newestrel["adddate"]) < time()-600 || is_null($newestrel['adddate']))
{
if ($this->echooutput)
echo "Retrieving titles from preDB sources.\n";
$newwomble = $this->retrieveWomble();
if ($this->echooutput)
echo $newwomble." Retrieved from Womble.\n";
$newomgwtf = $this->retrieveOmgwtfnzbs();
if ($this->echooutput)
echo $newomgwtf." Retrieved from Omgwtfnzbs.\n";
$newzenet = $this->retrieveZenet();
if ($this->echooutput)
echo $newzenet." Retrieved from Zenet.\n";
$newprelist = $this->retrievePrelist();
if ($this->echooutput)
echo $newprelist." Retrieved from Prelist.\n";
$neworly = $this->retrieveOrlydb();
if ($this->echooutput)
echo $neworly." Retrieved from Orlydb.\n";
$newsrr = $this->retrieveSrr();
if ($this->echooutput)
echo $newsrr." Retrieved from Srrdb.\n";
$newpdme = $this->retrievePredbme();
if ($this->echooutput)
echo $newpdme." Retrieved from Predb.me.\n";
$this->retrieveAllfilledMoovee();
$this->retrieveAllfilledTeevee();
$this->retrieveAllfilledErotica();
$this->retrieveAllfilledForeign();
$newnames = $newwomble+$newomgwtf+$newzenet+$newprelist+$neworly+$newsrr+$newpdme;
if(count($newnames) > 0)
$db->exec(sprintf("UPDATE prehash SET adddate = now() where ID = %d", $newestrel["ID"]));
}
$matched = $this->matchPredb();
if ($matched > 0 && $this->echooutput)
echo "\nMatched ".$matched." prehash titles to release search names.\n";
$nfos = $this->matchNfo();
if ($nfos > 0 && $this->echooutput)
echo "\nAdded ".$nfos." missing NFOs from prehash sources.\n";
return $newnames;
}
public function retrieveWomble()
{
$db = new DB();
$f = new Functions();
$newnames = $updated = 0;
$buffer = getUrl("http://www.newshost.co.za");
if ($buffer !== false && strlen($buffer))
{
if (preg_match_all('/
.+?<\/tr>/s', $buffer, $matches))
{
foreach ($matches as $match)
{
foreach ($match as $m)
{
if (preg_match('/
.+?(?P.+?)<\/td>(.+?right>(?P.+?) (?P.+?)<\/td.+?)?(?P.+?)<\/td.+?nfo<\/a>.+)?(?P.+?)<\/td.+tr>/s', $m, $matches2))
{
$md5 = md5($matches2["title"]);
$oldname = $db->queryOneRow(sprintf("SELECT title, source, ID, nfo FROM prehash WHERE title = %s", $db->escapeString($md5)));
if ($oldname !== false && $oldname["md5"] == $md5)
{
if ($oldname["nfo"] != NULL)
continue;
else
{
if (!isset($matches2["size1"]) && empty($matches2["size1"]))
$size = "NULL";
else
$size = $db->escapeString($matches2["size1"].$matches2["size2"]);
if ($matches2["nfo"] == "")
$nfo = "NULL";
else
$nfo = $db->escapeString("http://nzb.isasecret.com/".$matches2["nfo"]);
$db->exec(sprintf("UPDATE prehash SET nfo = %s, size = %s, category = %s, predate = %s, adddate = now(), source = %s where ID = %d", $nfo, $size, $db->escapeString($matches2["category"]), $db->from_unixtime(strtotime($matches2["date"])), $db->escapeString("womble"), $oldname["ID"]));
}
}
else
{
if (!isset($matches2["size1"]) && empty($matches2["size1"]))
$size = "NULL";
else
$size = $db->escapeString($matches2["size1"].$matches2["size2"]);
if ($matches2["nfo"] == "")
$nfo = "NULL";
else
$nfo = $db->escapeString("http://nzb.isasecret.com/".$matches2["nfo"]);
$db->exec(sprintf("INSERT INTO prehash (title, nfo, size, category, predate, adddate, source, hash) VALUES (%s, %s, %s, %s, FROM_UNIXTIME(".strtotime($matches2["date"])."), now(), %s, %s)", $db->escapeString($matches2["title"]), $nfo, $size, $db->escapeString($matches2["category"]), $db->escapeString("womble"), $db->escapeString(md5($matches2["title"]))));
$newnames++;
}
}
}
}
}
}
return $newnames;
}
public function retrieveOmgwtfnzbs()
{
$db = new DB();
$f = new Functions();
$newnames = $updated = 0;
$buffer = getUrl("http://rss.omgwtfnzbs.org/rss-info.php");
if ($buffer !== false && strlen($buffer))
{
if (preg_match_all('/- .+?<\/item>/s', $buffer, $matches))
{
foreach ($matches as $match)
{
foreach ($match as $m)
{
if (preg_match('/(?P.+?)<\/title.+?pubDate>(?P.+?)<\/pubDate.+?gory:<\/b> (?P.+?)
(?P.+?) (?P[a-zA-Z]+)queryOneRow(sprintf("SELECT title, source, ID FROM prehash WHERE title = %s", $db->escapeString($md5)));
if ($oldname !== false && $oldname["md5"] == $md5)
{
if ($oldname["source"] == "womble")
{
continue;
}
else
{
$size = $db->escapeString(round($matches2["size1"]).$matches2["size2"]);
$db->exec(sprintf("UPDATE prehash SET size = %s, category = %s, predate = FROM_UNIXTIME(".strtotime($matches2["date"])."), adddate = now(), source = %s where ID = %d", $size, $db->escapeString($matches2["category"]), $db->escapeString("omgwtfnzbs"), $oldname["ID"]));
$newnames++;
}
}
else
{
$size = $db->escapeString(round($matches2["size1"]).$matches2["size2"]);
$title = preg_replace("/ - omgwtfnzbs.org/", "", $matches2["title"]);
$db->exec(sprintf("INSERT INTO prehash (title, size, category, predate, adddate, source, hash) VALUES (%s, %s, %s, FROM_UNIXTIME(".strtotime($matches2["date"])."), now(), %s, %s)", $db->escapeString($title), $size, $db->escapeString($matches2["category"]), $db->escapeString("omgwtfnzbs"), $db->escapeString($md5)));
$newnames++;
}
}
}
}
}
}
return $newnames;
}
public function retrieveZenet()
{
$db = new DB();
$f = new Functions();
$newnames = $updated = 0;
$buffer = getUrl("http://pre.zenet.org/live.php");
if ($buffer !== false && strlen($buffer))
{
if (preg_match_all('/ | | |