$c = new Console(); $con = $c->getConsoleInfo($data['consoleinfoid']); } $AniDBAPIArray = ''; if ($data["anidbid"] > 0) { $AniDB = new AniDB(['Settings' => $releases->pdo]); $AniDBAPIArray = $AniDB->getAnimeInfo($data["anidbid"]); } $predbQuery = ''; if ($data["preid"] > 0) { $PreDB = new PreDB(); $predbQuery = $PreDB->getByID($data["preid"]); } $prehash = new PreHash(); $pre = $prehash->getForRelease($data["prehashid"]); $rf = new ReleaseFiles(); $releasefiles = $rf->get($data["id"]); $page->smarty->assign('releasefiles', $releasefiles); $page->smarty->assign('release', $data); $page->smarty->assign('reVideo', $reVideo); $page->smarty->assign('reAudio', $reAudio); $page->smarty->assign('reSubs', $reSubs); $page->smarty->assign('nfo', $nfo); $page->smarty->assign('rage', $rage); $page->smarty->assign('movie', $mov); $page->smarty->assign('xxx', $xxx); $page->smarty->assign('episode', $episodeArray); $page->smarty->assign('anidb', $AniDBAPIArray); $page->smarty->assign('music', $mus); $page->smarty->assign('con', $con); $page->smarty->assign('game', $game);
/** * Attempt to get a better name from a par2 file and categorize the release. * * @note Called from NZBContents.php * * @param string $messageID MessageID from NZB file. * @param int $relID id of the release. * @param int $groupID Group id of the release. * @param \NNTP $nntp Class NNTP * @param int $show Only show result or apply iy. * * @return bool */ public function parsePAR2($messageID, $relID, $groupID, &$nntp, $show) { if ($messageID === '') { return false; } $query = $this->pdo->queryOneRow(sprintf(' SELECT id, groupid, categoryid, name, searchname, UNIX_TIMESTAMP(postdate) AS post_date, id AS releaseid FROM releases WHERE isrenamed = 0 AND id = %d', $relID)); if ($query === false) { return false; } // Only get a new name if the category is OTHER. $foundName = true; if (!in_array((int) $query['categoryid'], array(\Category::CAT_BOOK_OTHER, \Category::CAT_GAME_OTHER, \Category::CAT_MOVIE_OTHER, \Category::CAT_MUSIC_OTHER, \Category::CAT_PC_MOBILEOTHER, \Category::CAT_TV_OTHER, \Category::CAT_MISC_HASHED, \Category::CAT_XXX_OTHER, \Category::CAT_MISC_OTHER))) { $foundName = false; } // Get the PAR2 file. $par2 = $nntp->getMessages($this->groups->getByNameByID($groupID), $messageID, $this->alternateNNTP); if ($nntp->isError($par2)) { return false; } // Put the PAR2 into Par2Info, check if there's an error. $this->_par2Info->setData($par2); if ($this->_par2Info->error) { return false; } // Get the file list from Par2Info. $files = $this->_par2Info->getFileList(); if ($files !== false && count($files) > 0) { $filesAdded = 0; // Loop through the files. foreach ($files as $file) { if (!isset($file['name'])) { continue; } // If we found a name and added 10 files, stop. if ($foundName === true && $filesAdded > 10) { break; } if ($this->addpar2) { // Add to release files. if ($filesAdded < 11 && $this->pdo->queryOneRow(sprintf(' SELECT id FROM releasefiles WHERE releaseid = %d AND name = %s', $relID, $this->pdo->escapeString($file['name']))) === false) { // Try to add the files to the DB. if ($this->releaseFiles->add($relID, $file['name'], $file['size'], $query['post_date'], 0)) { $filesAdded++; } } } else { $filesAdded++; } // Try to get a new name. if ($foundName === false) { $query['textstring'] = $file['name']; if ($this->nameFixer->checkName($query, 1, 'PAR2, ', 1, $show) === true) { $foundName = true; } } } // If we found some files. if ($filesAdded > 0) { $this->debugging->log(get_class(), __FUNCTION__, 'Added ' . $filesAdded . ' releasefiles from PAR2 for ' . $query['searchname'], \Logger::LOG_INFO); // Update the file count with the new file count + old file count. $this->pdo->queryExec(sprintf(' UPDATE releases SET rarinnerfilecount = rarinnerfilecount + %d WHERE id = %d', $filesAdded, $relID)); } if ($foundName === true) { return true; } } return false; }
/** * Get file info from inside PAR2, store it in DB, attempt to get a release name. * * @param string $fileLocation */ protected function _siftPAR2Info($fileLocation) { $this->_par2Info->open($fileLocation); if ($this->_par2Info->error) { return; } $releaseInfo = $this->pdo->queryOneRow(sprintf(' SELECT UNIX_TIMESTAMP(postdate) AS postdate, proc_pp FROM releases WHERE id = %d', $this->_release['id'])); if ($releaseInfo === false) { return; } // Only get a new name if the category is OTHER. $foundName = true; if (NN_RENAME_PAR2 && $releaseInfo['proc_pp'] == 0 && in_array((int) $this->_release['categoryid'], [\Category::CAT_BOOK_OTHER, \Category::CAT_GAME_OTHER, \Category::CAT_MOVIE_OTHER, \Category::CAT_MUSIC_OTHER, \Category::CAT_PC_MOBILEOTHER, \Category::CAT_TV_OTHER, \Category::CAT_MISC_HASHED, \Category::CAT_XXX_OTHER, \Category::CAT_MISC_OTHER])) { $foundName = false; } $filesAdded = 0; $files = $this->_par2Info->getFileList(); foreach ($files as $file) { if (!isset($file['name'])) { continue; } // If we found a name and added 10 files, stop. if ($foundName === true && $filesAdded > 10) { break; } // Add to release files. if ($this->_addPAR2Files) { if ($filesAdded < 11 && $this->pdo->queryOneRow(sprintf('SELECT id FROM releasefiles WHERE releaseid = %d AND name = %s', $this->_release['id'], $this->pdo->escapeString($file['name']))) === false) { // Try to add the files to the DB. if ($this->_releaseFiles->add($this->_release['id'], $file['name'], $file['size'], $releaseInfo['postdate'], 0)) { $filesAdded++; } } } else { $filesAdded++; } // Try to get a new name. if ($foundName === false) { $this->_release['textstring'] = $file['name']; $this->_release['releaseid'] = $this->_release['id']; if ($this->_nameFixer->checkName($this->_release, $this->_echoCLI ? 1 : 0, 'PAR2, ', 1, 1) === true) { $foundName = true; } } } // Update the file count with the new file count + old file count. $this->pdo->queryExec(sprintf('UPDATE releases SET rarinnerfilecount = rarinnerfilecount + %d WHERE id = %d', $filesAdded, $this->_release['id'])); $this->_foundPAR2Info = true; }
/** * @param $id * @param bool $isGuid */ public function delete($id, $isGuid = false) { $users = new Users(); $s = new Settings(); $nfo = new Nfo(); $rf = new ReleaseFiles(); $re = new ReleaseExtra(); $rc = new ReleaseComments(); $ri = new ReleaseImage(); if (!is_array($id)) { $id = array($id); } foreach ($id as $identifier) { // // delete from disk. // $rel = $isGuid ? $this->getByGuid($identifier) : $this->getById($identifier); $nzbpath = ""; if ($isGuid) { $nzbpath = $s->getSetting('nzbpath') . substr($identifier, 0, 1) . "/" . $identifier . ".nzb.gz"; } elseif ($rel) { $nzbpath = $s->getSetting('nzbpath') . substr($rel["guid"], 0, 1) . "/" . $rel["guid"] . ".nzb.gz"; } if ($nzbpath != "" && file_exists($nzbpath)) { unlink($nzbpath); } $audiopreviewpath = ""; if ($isGuid) { $audiopreviewpath = WWW_DIR . 'covers/audio/' . $identifier . ".mp3"; } elseif ($rel) { $audiopreviewpath = WWW_DIR . 'covers/audio/' . $rel["guid"] . ".mp3"; } if ($audiopreviewpath && file_exists($audiopreviewpath)) { unlink($audiopreviewpath); } if ($rel) { $nfo->deleteReleaseNfo($rel['id']); $rc->deleteCommentsForRelease($rel['id']); $users->delCartForRelease($rel['id']); $users->delDownloadRequestsForRelease($rel['id']); $rf->delete($rel['id']); $re->delete($rel['id']); $re->deleteFull($rel['id']); $ri->delete($rel['guid']); $this->pdo->queryExec(sprintf("DELETE FROM releases WHERE id = %d", $rel['id'])); } } }
function preName($argv, $argc) { global $pdo; $groups = new \Groups(['Settings' => $pdo]); $category = new \Categorize(['Settings' => $pdo]); $internal = $external = $pre = 0; $show = 2; if ($argv[$argc - 1] === 'show') { $show = 1; } else { if ($argv[$argc - 1] === 'bad') { $show = 3; } } $counter = 0; $pdo->log = new \ColorCLI(); $full = $all = $usepre = false; $what = $where = ''; if ($argv[1] === 'full') { $full = true; } else { if ($argv[1] === 'all') { $all = true; } else { if ($argv[1] === 'preid') { $usepre = true; } else { if (is_numeric($argv[1])) { $what = ' AND adddate > NOW() - INTERVAL ' . $argv[1] . ' HOUR'; } } } } if ($usepre === true) { $where = ''; $why = ' WHERE prehashid = 0 AND nzbstatus = 1'; } else { if (isset($argv[1]) && is_numeric($argv[1])) { $where = ''; $why = ' WHERE nzbstatus = 1 AND isrenamed = 0'; } else { if (isset($argv[2]) && is_numeric($argv[2]) && $full === true) { $where = ' AND groupid = ' . $argv[2]; $why = ' WHERE nzbstatus = 1 AND isrenamed = 0'; } else { if (isset($argv[2]) && preg_match('/\\([\\d, ]+\\)/', $argv[2]) && $full === true) { $where = ' AND groupid IN ' . $argv[2]; $why = ' WHERE nzbstatus = 1 AND isrenamed = 0'; } else { if (isset($argv[2]) && preg_match('/\\([\\d, ]+\\)/', $argv[2]) && $all === true) { $where = ' AND groupid IN ' . $argv[2]; $why = ' WHERE nzbstatus = 1'; } else { if (isset($argv[2]) && is_numeric($argv[2]) && $all === true) { $where = ' AND groupid = ' . $argv[2]; $why = ' WHERE nzbstatus = 1 and prehashid = 0'; } else { if (isset($argv[2]) && is_numeric($argv[2])) { $where = ' AND groupid = ' . $argv[2]; $why = ' WHERE nzbstatus = 1 AND isrenamed = 0'; } else { if ($full === true) { $why = ' WHERE nzbstatus = 1 AND (isrenamed = 0 OR categoryid between 8000 AND 8999)'; } else { if ($all === true) { $why = ' WHERE nzbstatus = 1'; } else { $why = ' WHERE 1=1'; } } } } } } } } } resetSearchnames(); echo $pdo->log->header("SELECT id, name, searchname, fromname, size, groupid, categoryid FROM releases" . $why . $what . $where . ";\n"); $res = $pdo->queryDirect("SELECT id, name, searchname, fromname, size, groupid, categoryid FROM releases" . $why . $what . $where); $total = $res->rowCount(); if ($total > 0) { $consoletools = new \ConsoleTools(['ColorCLI' => $pdo->log]); foreach ($res as $row) { $groupname = $groups->getByNameByID($row['groupid']); $cleanerName = releaseCleaner($row['name'], $row['fromname'], $row['size'], $groupname, $usepre); $preid = 0; $predb = $predbfile = $increment = false; if (!is_array($cleanerName)) { $cleanName = trim((string) $cleanerName); $propername = $increment = true; if ($cleanName != '' && $cleanerName != false) { $run = $pdo->queryOneRow("SELECT id FROM prehash WHERE title = " . $pdo->escapeString($cleanName)); if (isset($run['id'])) { $preid = $run['id']; $predb = true; } } } else { $cleanName = trim($cleanerName["cleansubject"]); $propername = $cleanerName["properlynamed"]; if (isset($cleanerName["increment"])) { $increment = $cleanerName["increment"]; } if (isset($cleanerName["predb"])) { $preid = $cleanerName["predb"]; $predb = true; } } if ($cleanName != '') { if (preg_match('/alt\\.binaries\\.e\\-?book(\\.[a-z]+)?/', $groupname)) { if (preg_match('/^[0-9]{1,6}-[0-9]{1,6}-[0-9]{1,6}$/', $cleanName, $match)) { $rf = new \ReleaseFiles($pdo); $files = $rf->get($row['id']); foreach ($files as $f) { if (preg_match('/^(?P<title>.+?)(\\[\\w\\[\\]\\(\\). -]+)?\\.(pdf|htm(l)?|epub|mobi|azw|tif|doc(x)?|lit|txt|rtf|opf|fb2|prc|djvu|cb[rz])/', $f["name"], $match)) { $cleanName = $match['title']; break; } } } } //try to match clean name against predb filename $prefile = $pdo->queryOneRow("SELECT id, title FROM prehash WHERE filename = " . $pdo->escapeString($cleanName)); if (isset($prefile['id'])) { $preid = $prefile['id']; $cleanName = $prefile['title']; $predbfile = true; $propername = true; } if ($cleanName != $row['name'] && $cleanName != $row['searchname']) { if (strlen(utf8_decode($cleanName)) <= 3) { } else { $determinedcat = $category->determineCategory($row["groupid"], $cleanName); if ($propername == true) { $pdo->queryExec(sprintf("UPDATE releases SET rageid = -1, seriesfull = NULL, season = NULL, episode = NULL, tvtitle = NULL, tvairdate = NULL, imdbid = NULL, musicinfoid = NULL, consoleinfoid = NULL, bookinfoid = NULL, anidbid = NULL, " . "iscategorized = 1, isrenamed = 1, searchname = %s, categoryid = %d, prehashid = " . $preid . " WHERE id = %d", $pdo->escapeString($cleanName), $determinedcat, $row['id'])); } else { $pdo->queryExec(sprintf("UPDATE releases SET rageid = -1, seriesfull = NULL, season = NULL, episode = NULL, tvtitle = NULL, tvairdate = NULL, imdbid = NULL, musicinfoid = NULL, consoleinfoid = NULL, bookinfoid = NULL, anidbid = NULL, " . "iscategorized = 1, searchname = %s, categoryid = %d, prehashid = " . $preid . " WHERE id = %d", $pdo->escapeString($cleanName), $determinedcat, $row['id'])); } if ($increment === true) { $internal++; } else { if ($predb === true) { $pre++; } else { if ($predbfile === true) { $pre++; } else { if ($propername === true) { $external++; } } } } if ($show === 1) { $oldcatname = $category->getNameByID($row["categoryid"]); $newcatname = $category->getNameByID($determinedcat); \NameFixer::echoChangedReleaseName(array('new_name' => $cleanName, 'old_name' => $row["searchname"], 'new_category' => $newcatname, 'old_category' => $oldcatname, 'group' => $groupname, 'release_id' => $row["id"], 'method' => 'lib/testing/Dev/renametopre.php')); } } } else { if ($show === 3 && preg_match('/^\\[?\\d*\\].+?yEnc/i', $row['name'])) { echo $pdo->log->primary($row['name']); } } } if ($cleanName == $row['name']) { $pdo->queryExec(sprintf("UPDATE releases SET isrenamed = 1, iscategorized = 1 WHERE id = %d", $row['id'])); } if ($show === 2 && $usepre === false) { $consoletools->overWritePrimary("Renamed Releases: [Internal=" . number_format($internal) . "][External=" . number_format($external) . "][Predb=" . number_format($pre) . "] " . $consoletools->percentString(++$counter, $total)); } else { if ($show === 2 && $usepre === true) { $consoletools->overWritePrimary("Renamed Releases: [" . number_format($pre) . "] " . $consoletools->percentString(++$counter, $total)); } } } } echo $pdo->log->header("\n" . number_format($pre) . " renamed using preDB Match\n" . number_format($external) . " renamed using ReleaseCleaning.php\n" . number_format($internal) . " using renametopre.php\nout of " . number_format($total) . " releases.\n"); if (isset($argv[1]) && is_numeric($argv[1]) && !isset($argv[2])) { echo $pdo->log->header("Categorizing all releases using searchname from the last {$argv[1]} hours. This can take a while, be patient."); } else { if (isset($argv[1]) && $argv[1] !== "all" && isset($argv[2]) && !is_numeric($argv[2]) && !preg_match('/\\([\\d, ]+\\)/', $argv[2])) { echo $pdo->log->header("Categorizing all non-categorized releases in other->misc using searchname. This can take a while, be patient."); } else { if (isset($argv[1]) && isset($argv[2]) && (is_numeric($argv[2]) || preg_match('/\\([\\d, ]+\\)/', $argv[2]))) { echo $pdo->log->header("Categorizing all non-categorized releases in {$argv[2]} using searchname. This can take a while, be patient."); } else { echo $pdo->log->header("Categorizing all releases using searchname. This can take a while, be patient."); } } } $timestart = TIME(); if (isset($argv[1]) && is_numeric($argv[1])) { $relcount = catRelease("searchname", "WHERE (iscategorized = 0 OR categoryid = 8010) AND adddate > NOW() - INTERVAL " . $argv[1] . " HOUR", true); } else { if (isset($argv[2]) && preg_match('/\\([\\d, ]+\\)/', $argv[2]) && $full === true) { $relcount = catRelease("searchname", str_replace(" AND", "WHERE", $where) . " AND iscategorized = 0 ", true); } else { if (isset($argv[2]) && preg_match('/\\([\\d, ]+\\)/', $argv[2]) && $all === true) { $relcount = catRelease("searchname", str_replace(" AND", "WHERE", $where), true); } else { if (isset($argv[2]) && is_numeric($argv[2]) && $argv[1] == "full") { $relcount = catRelease("searchname", str_replace(" AND", "WHERE", $where) . " AND iscategorized = 0 ", true); } else { if (isset($argv[2]) && is_numeric($argv[2]) && $argv[1] == "all") { $relcount = catRelease("searchname", str_replace(" AND", "WHERE", $where), true); } else { if (isset($argv[1]) && $argv[1] == "full") { $relcount = catRelease("searchname", "WHERE categoryid = 8010 OR iscategorized = 0", true); } else { if (isset($argv[1]) && $argv[1] == "all") { $relcount = catRelease("searchname", "", true); } else { if (isset($argv[1]) && $argv[1] == "preid") { $relcount = catRelease("searchname", "WHERE prehashid = 0 AND nzbstatus = 1", true); } else { $relcount = catRelease("searchname", "WHERE (iscategorized = 0 OR categoryid = 8010) AND adddate > NOW() - INTERVAL " . $argv[1] . " HOUR", true); } } } } } } } } $consoletools = new \ConsoleTools(['ColorCLI' => $pdo->log]); $time = $consoletools->convertTime(TIME() - $timestart); echo $pdo->log->header("Finished categorizing " . number_format($relcount) . " releases in " . $time . " seconds, using the usenet subject.\n"); resetSearchnames(); }
$music = new Music(['Settings' => $page->settings]); $mus = $music->getMusicInfo($data['musicinfoid']); } if ($data['consoleinfoid'] != '') { $c = new Console(['Settings' => $page->settings]); $con = $c->getConsoleInfo($data['consoleinfoid']); } if ($data['gamesinfo_id'] != '') { $g = new Games(['Settings' => $page->settings]); $game = $g->getgamesInfo($data['gamesinfo_id']); } if ($data['bookinfoid'] != '') { $b = new Books(['Settings' => $page->settings]); $boo = $b->getBookInfo($data['bookinfoid']); } $rf = new ReleaseFiles($page->settings); $releasefiles = $rf->get($data['id']); $predb = new PreDb(['Settings' => $page->settings]); $pre = $predb->getForRelease($data['preid']); $user = $page->users->getById($page->users->currentUserId()); $page->smarty->assign('cpapi', $user['cp_api']); $page->smarty->assign('cpurl', $user['cp_url']); $page->smarty->assign('releasefiles', $releasefiles); $page->smarty->assign('release', $data); $page->smarty->assign('reVideo', $reVideo); $page->smarty->assign('reAudio', $reAudio); $page->smarty->assign('reSubs', $reSubs); $page->smarty->assign('nfo', $nfo); $page->smarty->assign('rage', $rage); $page->smarty->assign('movie', $mov); $page->smarty->assign('xxx', $xxx);
/** * Work out all files contained inside a rar */ public function processReleaseFiles($fetchedBinary, $relid) { $retval = array(); $rar = new \ArchiveInfo(); $rf = new ReleaseFiles(); $rar->setData($fetchedBinary, true); if ($rar->error) { return false; } $files = $rar->getArchiveFileList(); if ($files !== false) { foreach ($files as $file) { if (isset($file['name'])) { $rf->add($relid, utf8_encode($file['name']), isset($file['size']) ? $file['size'] : "", isset($file['date']) ? $file['date'] : "", isset($file['pass']) ? $file['pass'] : ""); $retval[] = $file['name']; } } } unset($fetchedBinary); return $retval; }
<?php require_once WWW_DIR . "/lib/releasefiles.php"; if (!$users->isLoggedIn()) { $page->show403(); } if (!isset($_REQUEST["id"])) { $page->show404(); } $rf = new ReleaseFiles(); $files = $rf->getByGuid($_REQUEST["id"]); if (count($files) == 0) { print "No files"; } else { //print "<h3 class=\"tooltiphead\">rar archive contains...</h3>\n"; print "<ul>\n"; foreach ($files as $f) { print "<li>" . htmlentities($f["name"], ENT_QUOTES) . " " . ($f["passworded"] == 1 ? "<img width=\"12\" src=\"" . WWW_TOP . "/views/images/icons/lock.gif\" />" : "") . "</li>\n"; } print "</ul>"; }
$mov['director'] = $movie->makeFieldLinks($mov, 'director'); } } $mus = ''; if ($data['musicinfoID'] != '') { require_once WWW_DIR . "/lib/music.php"; $music = new Music(); $mus = $music->getMusicInfo($data['musicinfoID']); } $con = ''; if ($data['consoleinfoID'] != '') { require_once WWW_DIR . "/lib/console.php"; $c = new Console(); $con = $c->getConsoleInfo($data['consoleinfoID']); } $rf = new ReleaseFiles(); $releasefiles = $rf->get($data["ID"]); $page->smarty->assign('releasefiles', $releasefiles); $page->smarty->assign('release', $data); $page->smarty->assign('reVideo', $reVideo); $page->smarty->assign('reAudio', $reAudio); $page->smarty->assign('reSubs', $reSubs); $page->smarty->assign('nfo', $nfo); $page->smarty->assign('rage', $rage); $page->smarty->assign('movie', $mov); $page->smarty->assign('anidb', $AniDBAPIArray); $page->smarty->assign('music', $mus); $page->smarty->assign('con', $con); $page->smarty->assign('comments', $comments); $page->smarty->assign('similars', $similars); $page->smarty->assign('searchname', $releases->getSimilarName($data['searchname']));
public function processReleaseFiles($fetchedBinary, $relid) { $retval = array(); $rar = new RarInfo(); $rf = new ReleaseFiles(); echo "Checking Release Contents (" . $relid . ")\n"; if ($rar->setData($fetchedBinary)) { $files = $rar->getFileList(); foreach ($files as $file) { $rf->add($relid, $file['name'], $file['size'], $file['date'], $file['pass']); echo "-Found {$file['name']}\n"; $retval[] = $file['name']; } } unset($fetchedBinary); return $retval; }
public function delete($id, $isGuid = false) { $db = new DB(); $users = new Users(); $s = new Sites(); $nfo = new Nfo(); $site = $s->get(); $rf = new ReleaseFiles(); $re = new ReleaseExtra(); $rc = new ReleaseComments(); $ri = new ReleaseImage(); if (!is_array($id)) { $id = array($id); } foreach ($id as $identifier) { // // delete from disk. // $rel = $isGuid ? $this->getByGuid($identifier) : $this->getById($identifier); if ($rel && file_exists($site->nzbpath . $rel["guid"] . ".nzb.gz")) { unlink($site->nzbpath . $rel["guid"] . ".nzb.gz"); } $nfo->deleteReleaseNfo($rel['ID']); $rc->deleteCommentsForRelease($rel['ID']); $users->delCartForRelease($rel['ID']); $rf->delete($rel['ID']); $re->delete($rel['ID']); $re->deleteFull($rel['ID']); $ri->delete($rel['guid']); $db->query(sprintf("delete from releases where id = %d", $rel['ID'])); } }