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 updatePre()
{
$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()-1200 || is_null($newestrel['adddate']))
{
if ($this->echooutput)
{
echo $this->c->header("Retrieving titles from preDB sources.");
}
$newwomble = $this->retrieveWomble();
if ($this->echooutput)
{
echo $this->c->primary($newwomble . " \tRetrieved from Womble.");
}
$newomgwtf = $this->retrieveOmgwtfnzbs();
if ($this->echooutput)
{
echo $this->c->primary($newomgwtf . " \tRetrieved from Omgwtfnzbs.");
}
$newzenet = $this->retrieveZenet();
if ($this->echooutput)
{
echo $this->c->primary($newzenet . " \tRetrieved from Zenet.");
}
$newprelist = $this->retrievePrelist();
if ($this->echooutput)
{
echo $this->c->primary($newprelist . " \tRetrieved from Prelist.");
}
$neworly = $this->retrieveOrlydb();
if ($this->echooutput)
{
echo $this->c->primary($neworly . " \tRetrieved from Orlydb.");
}
$newsrr = $this->retrieveSrr();
if ($this->echooutput)
{
echo $this->c->primary($newsrr . " \tRetrieved from Srrdb.");
}
$newpdme = $this->retrievePredbme();
if ($this->echooutput)
{
echo $this->c->primary($newpdme . " \tRetrieved from Predbme.");
}
$this->retrieveAllfilledMoovee();
$this->retrieveAllfilledTeevee();
$this->retrieveAllfilledErotica();
$this->retrieveAllfilledForeign();
$abgx = $this->retrieveAbgx();
if ($this->echooutput)
{
echo $this->c->primary($abgx . " \tRetrieved from abgx.");
}
$newUsenetCrawler = $this->retrieveUsenetCrawler();
if ($this->echooutput) {
echo $this->c->primary($newUsenetCrawler . " \tRetrieved from Usenet-Crawler.");
}
$this->retrieveAllfilledMoovee();
$this->retrieveAllfilledTeevee();
$this->retrieveAllfilledErotica();
$this->retrieveAllfilledForeign();
$newnames = $newwomble + $newomgwtf + $newzenet + $newprelist + $neworly + $newsrr + $newpdme + $abgx + $newUsenetCrawler;
if (count($newnames) > 0) {
$db->exec(sprintf('UPDATE prehash SET adddate = NOW() WHERE ID = %d', $newestrel['ID']));
}
return $newnames;
}
}
// Attempts to match predb to releases.
public function checkPre($nntp)
{
$matched = $this->matchPredb();
if ($this->echooutput)
{
$count = ($matched > 0) ? $matched : 0;
echo $this->c->header('Matched ' . number_format($count) . ' prehash titles to release search names.');
}
$nfos = $this->matchNfo($nntp);
if ($this->echooutput)
{
$count = ($nfos > 0) ? $nfos : 0;
echo $this->c->header("\nAdded " . number_format($count) . ' missing NFOs from preDB sources.');
}
}
public function retrieveWomble()
{
$db = new DB();
$f = new Functions();
$newnames = $updated = 0;
$matches2 = $matches = $match = $m = '';
$buffer = $this->fileContents('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://newshost.co.za/".$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"]));
$updated++;
}
}
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://newshost.co.za/".$matches2["nfo"]);
if (strlen($matches2['title']) > 15) {
if($db->exec(sprintf("INSERT IGNORE INTO prehash (title, nfo, size, category, predate, adddate, source, md5) 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++;
}
}
}
}
}
}
}
echo $this->c->primary($updated . " \tUpdated from Womble.");
}
else
{
echo $this->c->error("Update from Womble failed.");
}
return $newnames;
}
public function retrieveOmgwtfnzbs()
{
$db = new DB();
$f = new Functions();
$newnames = $updated = 0;
$matches2 = $matches = $match = $m = '';
$buffer = $this->fileContents('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 md5, source, ID FROM prehash WHERE md5 = %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"]));
$updated++;
}
}
else
{
$size = $db->escapeString(round($matches2["size1"]).$matches2["size2"]);
if (strlen($title) > 15) {
if($db->exec(sprintf("INSERT IGNORE INTO prehash (title, size, category, predate, adddate, source, md5) 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++;
}
}
}
}
}
}
}
echo $this->c->primary($updated . " \tUpdated from Omgwtfnzbs.");
}
else
{
echo $this->c->error("Update from Omgwtfnzbs failed.");
}
return $newnames;
}
public function retrieveZenet()
{
$db = new DB();
$f = new Functions();
$newnames = $updated = 0;
$matches2 = $matches = $match = $m = '';
$buffer = $this->fileContents('http://pre.zenet.org/live.php');
if ($buffer !== false && strlen($buffer))
{
if (preg_match_all('/ | | |