Beispiel #1
0
 /**
  * Get all groups used by releaseregexes for use in dropdownlist.
  */
 public function getGroupsForSelect()
 {
     $categories = $this->pdo->query("SELECT distinct coalesce(groupname,'all') as groupname from releaseregex order by groupname ");
     $temp_array = [];
     $temp_array[-1] = "--Please Select--";
     foreach ($categories as $category) {
         $temp_array[$category["groupname"]] = $category["groupname"];
     }
     return $temp_array;
 }
Beispiel #2
0
 /**
  * @param bool $activeOnly
  *
  * @return array
  */
 public function getGenres($activeOnly = false)
 {
     if ($activeOnly) {
         return $this->pdo->query("SELECT musicgenre.* FROM musicgenre INNER JOIN (SELECT DISTINCT musicgenreid FROM musicinfo) x ON x.musicgenreID = musicgenre.id ORDER BY title");
     } else {
         return $this->pdo->query("SELECT * FROM musicgenre ORDER BY title");
     }
 }
Beispiel #3
0
 /**
  * @param        $start
  * @param        $num
  * @param string $seriesname
  *
  * @return array
  */
 public function getSeriesRange($start, $num, $seriesname = '')
 {
     $limit = $start === false ? '' : " LIMIT " . $start . "," . $num;
     $rsql = '';
     if ($seriesname != '') {
         $rsql .= sprintf("AND thetvdb.seriesname LIKE %s ", $this->pdo->escapeString("%" . $seriesname . "%"));
     }
     return $this->pdo->query(sprintf(" SELECT id, tvdbid, seriesname, overview FROM thetvdb WHERE 1=1 %s AND tvdbid > %d ORDER BY tvdbid ASC" . $limit, $rsql, 0));
 }
Beispiel #4
0
    /**
     * Retrieves all info for a specific AniDB id
     *
     * @param int $anidbID
     * @return
     */
    public function getAnimeInfo($anidbID)
    {
        $animeInfo = $this->pdo->query(sprintf('SELECT at.anidbid, at.lang, at.title,
				ai.startdate, ai.enddate, ai.updated, ai.related, ai.creators, ai.description,
				ai.rating, ai.picture, ai.categories, ai.characters, ai.type
				FROM anidb_titles AS at LEFT JOIN anidb_info ai USING (anidbid)
				WHERE at.anidbid = %d', $anidbID));
        return isset($animeInfo[0]) ? $animeInfo[0] : false;
    }
Beispiel #5
0
 public function data_getForMenuByTypeAndRole($id, $role)
 {
     if ($role == Users::ROLE_ADMIN) {
         $role = "";
     } else {
         $role = sprintf("AND (role = %d OR role = 0)", $role);
     }
     return $this->pdo->query(sprintf("SELECT * FROM content WHERE showinmenu = 1 AND status = 1 AND contenttype = %d %s ", $id, $role));
 }
 /**
  * Get comments for a user by limit.
  */
 public function getCommentsForUserRange($uid, $start, $num)
 {
     if ($start === false) {
         $limit = "";
     } else {
         $limit = " LIMIT " . $start . "," . $num;
     }
     return $this->pdo->query(sprintf("SELECT release_comments.*, r.guid, r.searchname, users.username FROM release_comments INNER JOIN releases r ON r.id = release_comments.releaseid LEFT OUTER JOIN users ON users.id = release_comments.userid WHERE userid = %d ORDER BY release_comments.createddate DESC " . $limit, $uid));
 }
Beispiel #7
0
 /**
  * Get forum posts for a user for paged list in profile.
  */
 public function getForUserRange($uid, $start, $num)
 {
     if ($start === false) {
         $limit = "";
     } else {
         $limit = " LIMIT " . $start . "," . $num;
     }
     return $this->pdo->query(sprintf(" SELECT forumpost.*, users.username FROM forumpost LEFT OUTER JOIN users ON users.id = forumpost.userid where userid = %d order by forumpost.createddate desc " . $limit, $uid));
 }
Beispiel #8
0
 /**
  * Get predb rows by limit and filter.
  */
 public function getPreRange($start = 0, $num, $dirname = '', $category = '')
 {
     // Only use Sphinx if this is a search request
     if ($dirname) {
         if ($this->pdo->getSetting('sphinxenabled') && $this->pdo->getSetting('sphinxindexpredb')) {
             // Search using Sphinx
             $sphinx = new Sphinx();
             $results = $sphinx->getPreRange($start, $num, $dirname, $category);
             if (is_array($results)) {
                 return $results;
             }
         }
     }
     $dirname = str_replace(' ', '%', $dirname);
     $dirname = empty($dirname) ? '' : sprintf('WHERE dirname LIKE %s', $this->pdo->escapeString('%' . $dirname . '%'));
     $category = empty($category) ? '' : sprintf((empty($dirname) ? 'WHERE' : ' AND') . " category = %s", $this->pdo->escapeString($category));
     $sql = sprintf('SELECT p.*, r.guid FROM predb p left outer join releases r on p.id = r.preid %s %s ORDER BY ctime DESC LIMIT %d,%d', $dirname, $category, $start, $num);
     return $this->pdo->query($sql, true);
 }
Beispiel #9
0
 /**
  * Get all genres for search-filter.tpl
  *
  * @param bool $activeOnly
  *
  * @return array|null
  */
 public function getAllGenres($activeOnly = false)
 {
     $res = $ret = null;
     if ($activeOnly) {
         $res = $this->pdo->query("SELECT title FROM genres WHERE disabled = 0 AND type = 6000 ORDER BY title");
     } else {
         $res = $this->pdo->query("SELECT title FROM genres WHERE disabled = 1 AND type = 6000 ORDER BY title");
     }
     foreach ($res as $arr => $value) {
         $ret[] = $value['title'];
     }
     return $ret;
 }
Beispiel #10
0
 /**
  * Get all groups in the DB.
  *
  * @return bool
  * @access protected
  */
 protected function getAllGroups()
 {
     $this->allGroups = [];
     $groups = $this->pdo->query("SELECT id, name FROM groups");
     foreach ($groups as $group) {
         $this->allGroups[$group["name"]] = $group["id"];
     }
     if (count($this->allGroups) === 0) {
         $this->echoOut('You have no groups in your database!');
         return false;
     }
     return true;
 }
Beispiel #11
0
    /**
     * Match added comments to releases.
     */
    protected function matchComments()
    {
        $res = $this->pdo->query('
			SELECT r.id, r.nzb_guid
			FROM releases r
			INNER JOIN releasecomment rc ON rc.nzb_guid = r.nzb_guid
			WHERE rc.releaseid = 0');
        $found = count($res);
        if ($found > 0) {
            foreach ($res as $row) {
                $this->pdo->queryExec(sprintf("UPDATE releasecomment SET releaseid = %d WHERE nzb_guid = %s", $row['id'], $this->pdo->escapeString($row['nzb_guid'])));
                $this->pdo->queryExec(sprintf('UPDATE releases SET comments = comments + 1 WHERE id = %d', $row['id']));
            }
            echo '(Sharing) Matched ' . $found . ' comments.' . PHP_EOL;
        }
    }
Beispiel #12
0
 /**
  * Process all releases tagged as musicinfoid -2 to attempt to retrieve properties from mediainfo xml.
  */
 public function processMusicReleaseFromMediaInfo()
 {
     $res = $this->pdo->query("SELECT r.searchname, ref.releaseid, ref.mediainfo FROM releaseextrafull ref INNER JOIN releases r ON r.id = ref.releaseid WHERE r.musicinfoid = -2");
     $rescount = sizeof($res);
     if ($rescount > 0) {
         if ($this->echooutput) {
             echo "MusicPr : Processing " . $rescount . " audio releases via mediainfo\n";
         }
         //load genres
         $gen = new Genres();
         $defaultGenres = $gen->getGenres(Genres::MUSIC_TYPE);
         $genreassoc = array();
         foreach ($defaultGenres as $dg) {
             $genreassoc[$dg['id']] = strtolower($dg['title']);
         }
         foreach ($res as $rel) {
             $albumId = -3;
             $mi = null;
             $mi = @simplexml_load_string($rel["mediainfo"]);
             if ($mi != null) {
                 $artist = (string) $mi->File->track[0]->Performer;
                 $album = (string) $mi->File->track[0]->Album;
                 $year = (string) $mi->File->track[0]->Recorded_date;
                 $genre = (string) $mi->File->track[0]->Genre;
                 $publisher = (string) $mi->File->track[0]->Publisher;
                 $albumCheck = $this->getMusicInfoByName($artist, $album);
                 if ($albumCheck === false) {
                     //
                     // insert new musicinfo
                     //
                     $genreKey = -1;
                     if ($genre != "") {
                         $albumId = $this->addUpdateMusicInfo($album, "", "", "null", $artist, $publisher, "null", "", $year, $genreKey, "", 0);
                     }
                 } else {
                     $albumId = $albumCheck["id"];
                 }
             }
             $sql = sprintf("update releases set musicinfoid = %d where id = %d", $albumId, $rel["releaseid"]);
             $this->pdo->queryExec($sql);
         }
     }
     return true;
 }
Beispiel #13
0
 public function getConsoleRange($cat, $start, $num, $orderby, $excludedcats = [])
 {
     $browseby = $this->getBrowseBy();
     if ($start === false) {
         $limit = "";
     } else {
         $limit = " LIMIT " . $num . " OFFSET " . $start;
     }
     $catsrch = '';
     if (count($cat) > 0 && $cat[0] != -1) {
         $catsrch = (new \Category(['Settings' => $this->pdo]))->getCategorySearch($cat);
     }
     $exccatlist = "";
     if (count($excludedcats) > 0) {
         $exccatlist = " AND r.categoryid NOT IN (" . implode(",", $excludedcats) . ")";
     }
     $order = $this->getConsoleOrder($orderby);
     return $this->pdo->query(sprintf("SELECT GROUP_CONCAT(r.id ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_id, " . "GROUP_CONCAT(r.rarinnerfilecount ORDER BY r.postdate DESC SEPARATOR ',') as grp_rarinnerfilecount, " . "GROUP_CONCAT(r.haspreview ORDER BY r.postdate DESC SEPARATOR ',') AS grp_haspreview, " . "GROUP_CONCAT(r.passwordstatus ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_password, " . "GROUP_CONCAT(r.guid ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_guid, " . "GROUP_CONCAT(rn.id ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_nfoid, " . "GROUP_CONCAT(groups.name ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_grpname, " . "GROUP_CONCAT(r.searchname ORDER BY r.postdate DESC SEPARATOR '#') AS grp_release_name, " . "GROUP_CONCAT(r.postdate ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_postdate, " . "GROUP_CONCAT(r.size ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_size, " . "GROUP_CONCAT(r.totalpart ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_totalparts, " . "GROUP_CONCAT(r.comments ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_comments, " . "GROUP_CONCAT(r.grabs ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_grabs, " . "GROUP_CONCAT(r.failed ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_failed," . "con.*, r.consoleinfoid, groups.name AS group_name, rn.id as nfoid FROM releases r " . "LEFT OUTER JOIN groups ON groups.id = r.groupid " . "LEFT OUTER JOIN releasenfo rn ON rn.releaseid = r.id " . "INNER JOIN consoleinfo con ON con.id = r.consoleinfoid " . "INNER JOIN genres ON con.genreid = genres.id " . "WHERE r.nzbstatus = 1 AND con.title != '' AND " . "r.passwordstatus %s AND %s %s %s " . "GROUP BY con.id ORDER BY %s %s" . $limit, Releases::showPasswords($this->pdo), $browseby, $catsrch, $exccatlist, $order[0], $order[1]), true, NN_CACHE_EXPIRY_MEDIUM);
 }
Beispiel #14
0
    /**
     * Match added comments to releases.
     *
     * @access protected
     */
    protected function matchComments()
    {
        $res = $this->pdo->query('
			SELECT r.id
			FROM release_comments rc
			INNER JOIN releases r USING (nzb_guid)
			WHERE rc.releaseid = 0');
        $found = count($res);
        if ($found > 0) {
            foreach ($res as $row) {
                $this->pdo->queryExec(sprintf("\n\t\t\t\t\t\tUPDATE release_comments rc\n\t\t\t\t\t\tINNER JOIN releases r USING (nzb_guid)\n\t\t\t\t\t\tSET rc.releaseid = %d, r.comments = r.comments + 1\n\t\t\t\t\t\tWHERE r.id = %d\n\t\t\t\t\t\tAND rc.releaseid = 0", $row['id'], $row['id']));
            }
            if (NN_ECHOCLI) {
                echo "(Sharing) Matched {$found}  comments." . PHP_EOL;
            }
        }
        // Update first time seen.
        $this->pdo->queryExec(sprintf("\n\t\t\t\t\tUPDATE sharing_sites ss\n\t\t\t\t\tINNER JOIN\n\t\t\t\t\t\t(SELECT siteid, createddate\n\t\t\t\t\t\tFROM release_comments\n\t\t\t\t\t\tWHERE createddate > '2005-01-01'\n\t\t\t\t\t\tGROUP BY siteid\n\t\t\t\t\t\tORDER BY createddate ASC) rc\n\t\t\t\t\tON ss.site_guid = rc.siteid\n\t\t\t\t\tSET ss.first_time = rc.createddate\n\t\t\t\t\tWHERE ss.first_time IS NULL OR ss.first_time > rc.createddate"));
    }
Beispiel #15
0
 /**
  * Get range of consoleinfo rows for browse list.
  */
 public function getConsoleRange($cat, $start, $num, $orderby, $maxage = -1, $excludedcats = [])
 {
     $browseby = $this->getBrowseBy();
     if ($start === false) {
         $limit = "";
     } else {
         $limit = " LIMIT " . $start . "," . $num;
     }
     $catsrch = "";
     if (count($cat) > 0 && $cat[0] != -1) {
         $catsrch = " (";
         foreach ($cat as $category) {
             if ($category != -1) {
                 $categ = new Category();
                 if ($categ->isParent($category)) {
                     $children = $categ->getChildren($category);
                     $chlist = "-99";
                     foreach ($children as $child) {
                         $chlist .= ", " . $child["id"];
                     }
                     if ($chlist != "-99") {
                         $catsrch .= " r.categoryid in (" . $chlist . ") or ";
                     }
                 } else {
                     $catsrch .= sprintf(" r.categoryid = %d or ", $category);
                 }
             }
         }
         $catsrch .= "1=2 )";
     }
     $maxagesql = "";
     if ($maxage > 0) {
         $maxagesql = sprintf(" and r.postdate > now() - interval %d day ", $maxage);
     }
     $exccatlist = "";
     if (count($excludedcats) > 0) {
         $exccatlist = " and r.categoryid not in (" . implode(",", $excludedcats) . ")";
     }
     $order = $this->getConsoleOrder($orderby);
     $sql = sprintf(" SELECT r.*, r.id as releaseid, con.*, g.title as genre, groups.name as group_name, concat(cp.title, ' > ', c.title) as category_name, concat(cp.id, ',', c.id) as category_ids, rn.id as nfoid from releases r left outer join groups on groups.id = r.groupid inner join consoleinfo con on con.id = r.consoleinfoid left outer join releasenfo rn on rn.releaseid = r.id and rn.nfo is not null left outer join category c on c.id = r.categoryid left outer join category cp on cp.id = c.parentid left outer join genres g on g.id = con.genreid where r.passwordstatus <= (select value from settings where setting='showpasswordedrelease') and %s %s %s %s order by %s %s" . $limit, $browseby, $catsrch, $maxagesql, $exccatlist, $order[0], $order[1]);
     return $this->pdo->query($sql, true);
 }
    /**
     * Get all releases that need to be processed.
     *
     * @param int|string $groupID
     * @param string     $guidChar
     *
     * @void
     */
    protected function _fetchReleases($groupID, &$guidChar)
    {
        $this->_releases = $this->pdo->query(sprintf('
				SELECT r.id, r.guid, r.name, c.disablepreview, r.size, r.groupid, r.nfostatus, r.completion, r.categoryid, r.searchname, r.prehashid
				FROM releases r
				LEFT JOIN category c ON c.id = r.categoryid
				WHERE r.nzbstatus = 1
				%s %s %s %s
				AND r.passwordstatus BETWEEN -6 AND -1
				AND r.haspreview = -1
				AND c.disablepreview = 0
				ORDER BY r.passwordstatus ASC, r.postdate DESC
				LIMIT %d', $this->_maxSize, $this->_minSize, $groupID === '' ? '' : 'AND r.groupid = ' . $groupID, $guidChar === '' ? '' : 'AND r.guid ' . $this->pdo->likeString($guidChar, false, true), $this->_queryLimit));
        if (is_array($this->_releases)) {
            $this->_totalReleases = count($this->_releases);
        } else {
            $this->_releases = [];
            $this->_totalReleases = 0;
        }
    }
Beispiel #17
0
    /**
     * Return all blacklists.
     *
     * @param bool   $activeOnly Only display active blacklists ?
     * @param int    $opType     Optional, get white or black lists (use Binaries constants).
     * @param string $groupName  Optional, group.
     * @param bool   $groupRegex Optional Join groups / binaryblacklist using regexp for equals.
     *
     * @return array
     */
    public function getBlacklist($activeOnly = true, $opType = -1, $groupName = '', $groupRegex = false)
    {
        switch ($opType) {
            case self::OPTYPE_BLACKLIST:
                $opType = 'AND binaryblacklist.optype = ' . self::OPTYPE_BLACKLIST;
                break;
            case self::OPTYPE_WHITELIST:
                $opType = 'AND binaryblacklist.optype = ' . self::OPTYPE_WHITELIST;
                break;
            default:
                $opType = '';
                break;
        }
        return $this->_pdo->query(sprintf('
				SELECT
					binaryblacklist.id, binaryblacklist.optype, binaryblacklist.status, binaryblacklist.description,
					binaryblacklist.groupname AS groupname, binaryblacklist.regex, groups.id AS group_id, binaryblacklist.msgcol,
					binaryblacklist.last_activity as last_activity
				FROM binaryblacklist
				LEFT OUTER JOIN groups ON groups.name %s binaryblacklist.groupname
				WHERE 1=1 %s %s %s
				ORDER BY coalesce(groupname,\'zzz\')', $groupRegex ? 'REGEXP' : '=', $activeOnly ? 'AND binaryblacklist.status = 1' : '', $opType, $groupName ? 'AND groups.name REGEXP ' . $this->_pdo->escapeString($groupName) : ''));
    }
Beispiel #18
0
 public function getBookRange($cat, $start, $num, $orderby, $excludedcats = [])
 {
     $browseby = $this->getBrowseBy();
     if ($start === false) {
         $limit = '';
     } else {
         $limit = ' LIMIT ' . $num . ' OFFSET ' . $start;
     }
     $catsrch = '';
     if (count($cat) > 0 && $cat[0] != -1) {
         $catsrch = (new \Category(['Settings' => $this->pdo]))->getCategorySearch($cat);
     }
     $maxage = '';
     if ($maxage > 0) {
         $maxage = sprintf(' AND r.postdate > NOW() - INTERVAL %d DAY ', $maxage);
     }
     $exccatlist = '';
     if (count($excludedcats) > 0) {
         $exccatlist = ' AND r.categoryid NOT IN (' . implode(',', $excludedcats) . ')';
     }
     $order = $this->getBookOrder($orderby);
     $sql = sprintf("SELECT GROUP_CONCAT(r.id ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_id, " . "GROUP_CONCAT(r.rarinnerfilecount ORDER BY r.postdate DESC SEPARATOR ',') as grp_rarinnerfilecount, " . "GROUP_CONCAT(r.haspreview ORDER BY r.postdate DESC SEPARATOR ',') AS grp_haspreview, " . "GROUP_CONCAT(r.passwordstatus ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_password, " . "GROUP_CONCAT(r.guid ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_guid, " . "GROUP_CONCAT(rn.id ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_nfoid, " . "GROUP_CONCAT(groups.name ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_grpname, " . "GROUP_CONCAT(r.searchname ORDER BY r.postdate DESC SEPARATOR '#') AS grp_release_name, " . "GROUP_CONCAT(r.postdate ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_postdate, " . "GROUP_CONCAT(r.size ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_size, " . "GROUP_CONCAT(r.totalpart ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_totalparts, " . "GROUP_CONCAT(r.comments ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_comments, " . "GROUP_CONCAT(r.grabs ORDER BY r.postdate DESC SEPARATOR ',') AS grp_release_grabs, " . "boo.*, r.bookinfoid, groups.name AS group_name, rn.id as nfoid FROM releases r " . "LEFT OUTER JOIN groups ON groups.id = r.groupid " . "LEFT OUTER JOIN releasenfo rn ON rn.releaseid = r.id " . "INNER JOIN bookinfo boo ON boo.id = r.bookinfoid " . "WHERE r.nzbstatus = 1 AND boo.cover = 1 AND boo.title != '' AND " . "r.passwordstatus %s AND %s %s %s %s " . "GROUP BY boo.id ORDER BY %s %s" . $limit, Releases::showPasswords($this->pdo), $browseby, $catsrch, $maxage, $exccatlist, $order[0], $order[1]);
     return $this->pdo->query($sql, true, NN_CACHE_EXPIRY_MEDIUM);
 }
if (isset($argv[1]) && ($argv[1] == "true" || $argv[1] == "drop")) {
    $pdo->queryExec("UPDATE groups SET first_record = 0, first_record_postdate = NULL, last_record = 0, last_record_postdate = NULL, last_updated = NULL");
    echo $pdo->log->primary("Reseting all groups completed.");
    $arr = array("parts", "partrepair", "binaries");
    foreach ($arr as &$value) {
        $rel = $pdo->queryExec("TRUNCATE TABLE {$value}");
        if ($rel !== false) {
            echo $pdo->log->primary("Truncating {$value} completed.");
        }
    }
    unset($value);
    $tpg = $pdo->getSetting('tablepergroup');
    $tablepergroup = !empty($tpg) ? $tpg : 0;
    if ($tablepergroup == 1) {
        $sql = 'SHOW table status';
        $tables = $pdo->query($sql);
        foreach ($tables as $row) {
            $tbl = $row['name'];
            if (preg_match('/binaries_\\d+/', $tbl) || preg_match('/parts_\\d+/', $tbl) || preg_match('/partrepair_\\d+/', $tbl) || preg_match('/\\d+_binaries/', $tbl) || preg_match('/\\d+_parts/', $tbl) || preg_match('/\\d+_partrepair_\\d+/', $tbl)) {
                if ($argv[1] == "drop") {
                    $rel = $pdo->queryDirect(sprintf('DROP TABLE %s', $tbl));
                    if ($rel !== false) {
                        echo $pdo->log->primary("Dropping {$tbl} completed.");
                    }
                } else {
                    $rel = $pdo->queryDirect(sprintf('TRUNCATE TABLE %s', $tbl));
                    if ($rel !== false) {
                        echo $pdo->log->primary("Truncating {$tbl} completed.");
                    }
                }
            }
Beispiel #20
0
 private function scan_releases(&$processed, &$total, $limit = Null)
 {
     // Scan all nzb files whos releases match against data
     // that has no nfo files associated with it.
     //
     // nzb files are further parsed for nfo segments that can
     // be extracted and applied to the release
     $nzb = new NZB();
     $db = new Settings();
     // How many releases to handle at a time
     $batch = Nfo::NNTP_BATCH_COUNT;
     // Build NFO List
     $nfometa = array();
     // Missing NFO Query (oldest first so they don't expire on us)
     $mnfo = "SELECT id,guid, name FROM releases r " . "WHERE r.releasenfoid = " . Nfo::FLAG_NFO_PENDING . " ORDER BY postdate DESC";
     if ($limit !== Null && $limit > 0) {
         $mnfo .= " LIMIT {$limit}";
     }
     $res = $db->query($mnfo);
     if ($res) {
         foreach ($res as $r) {
             $nzbfile = $nzb->getNZBPath($r["guid"]);
             if (!is_file($nzbfile)) {
                 if ($this->verbose) {
                     echo sprintf("%s Missing NZB File: %d/%s ...\n", 'NfoProc', intval($r["id"]), $r["name"]);
                 }
                 $this->setNfoMissing($r["id"]);
                 continue;
             }
             $nzbInfo = new NzbInfo();
             if (!$nzbInfo->loadFromFile($nzbfile)) {
                 if ($this->verbose) {
                     echo sprintf("%s Unable to parse NZB File: %d/%s ...\n", 'NfoProc', intval($r["id"]), $r["name"]);
                 }
                 $this->setNfoMissing($r["id"]);
                 continue;
             }
             $total += 1;
             $filename = basename($nzbfile);
             if ($this->verbose) {
                 echo sprintf("NfoProc : Scanning %s - ", $r["name"]);
             }
             $matches = $this->nfo_scan($nzbInfo);
             unset($nzbInfo);
             if (is_array($matches)) {
                 if (!count($matches)) {
                     if ($this->verbose) {
                         echo "nfo missing.\n";
                     }
                     $this->setNfoMissing($r["id"]);
                     continue;
                 }
             } else {
                 if ($this->verbose) {
                     echo "corrupt nzb.\n";
                 }
                 $this->setNfoMissing($r["id"]);
                 continue;
             }
             if ($this->verbose) {
                 echo count($matches) . " possible nfo(s).\n";
             }
             $processed++;
             // Hash Matches by Release id
             $nfometa[(string) $r["id"]] = $matches;
             if (!($processed % $batch)) {
                 $nfoblob = array();
                 if ($this->verbose) {
                     echo "NfoProc : Retrieval ...";
                 }
                 if ($this->nfo_grab($nfometa, $nfoblob)) {
                     $before = array_keys($nfoblob);
                     $this->parse_blobs($nfometa, $nfoblob);
                     $after = array_keys($nfoblob);
                     $removed = array_diff($before, $after);
                     $this->store_blob($nfometa, $nfoblob, $removed);
                 }
                 if ($this->verbose) {
                     echo "\n";
                 }
                 // Reset nfo list array
                 $nfometa = array();
             }
         }
         if ($processed % $batch) {
             $nfoblob = array();
             if ($this->verbose) {
                 echo "NfoProc : Retrieval ...";
             }
             if ($this->nfo_grab($nfometa, $nfoblob)) {
                 $before = array_keys($nfoblob);
                 $this->parse_blobs($nfometa, $nfoblob);
                 $after = array_keys($nfoblob);
                 $removed = array_diff($before, $after);
                 $this->store_blob($nfometa, $nfoblob, $removed);
             }
             if ($this->verbose) {
                 echo "\n";
             }
         }
     }
     return true;
 }
Beispiel #21
0
 /**
  * Get all binaries for a release.
  */
 public function getForReleaseId($id)
 {
     $db = new Settings();
     return $db->query(sprintf("select binaries.* from binaries where releaseid = %d order by relpart", $id));
 }
Beispiel #22
0
 /**
  * Get a list of categories.
  */
 public function get($activeonly = false, $excludedcats = [])
 {
     $db = new newznab\db\Settings();
     $exccatlist = "";
     if (count($excludedcats) > 0) {
         $exccatlist = " and c.id not in (" . implode(",", $excludedcats) . ")";
     }
     $act = "";
     if ($activeonly) {
         $act = sprintf(" where c.status = %d ", Category::STATUS_ACTIVE);
     }
     if ($exccatlist != "") {
         $act .= $exccatlist;
     }
     return $db->query("select c.id, concat(cp.title, ' > ',c.title) as title, cp.id as parentid, c.status from category c inner join category cp on cp.id = c.parentid " . $act . " ORDER BY c.id", true);
 }
Beispiel #23
0
<?php

/*
Filesize Fix Script
If after import you have a bunch of zero sized releases run this
Author: lordgnu <*****@*****.**>
*/
require_once dirname(__FILE__) . '/../../www/config.php';
use newznab\db\Settings;
$pdo = new Settings();
$nzb = new NZB();
$items = $pdo->query("SELECT id,guid FROM releases WHERE size = 0");
$total = count($items);
$compl = 0;
echo "Updating file size for " . count($items) . " release(s)\n";
while ($item = array_pop($items)) {
    $nzbpath = $nzb->getNZBPath($item['guid'], $pdo->getSetting('nzbpath'));
    ob_start();
    @readgzfile($nzbpath);
    $nzbfile = ob_get_contents();
    ob_end_clean();
    $ret = $nzb->nzbFileList($nzbfile);
    $filesize = '0';
    foreach ($ret as $file) {
        $filesize = bcadd($filesize, $file['size']);
    }
    $pdo->queryExec("UPDATE releases SET size = '{$filesize}' WHERE id = '{$item['id']}' LIMIT 1");
    $compl++;
    echo sprintf("[%6d / %6d] %0.2f", $compl, $total, $compl / $total * 100) . '%' . "\n";
}
Beispiel #24
0
 /**
  * Return site setting for hiding/showing passworded releases.
  *
  * @param Settings $pdo
  *
  * @return string
  */
 public static function showPasswords(Settings $pdo)
 {
     $setting = $pdo->query("SELECT value FROM settings WHERE setting = 'showpasswordedrelease'", true, NN_CACHE_EXPIRY_LONG);
     switch (isset($setting[0]['value']) && is_numeric($setting[0]['value']) ? $setting[0]['value'] : 10) {
         case 0:
             // Show releases that may have passwords (does not hide unprocessed releases).
             return '<= ' . Releases::PASSWD_POTENTIAL;
         case 1:
             // Show releases that definitely have no passwords (hides unprocessed releases).
             return '= ' . Releases::PASSWD_NONE;
         case 2:
             // Show releases that definitely have no passwords (does not hide unprocessed releases).
             return '<= ' . Releases::PASSWD_NONE;
         case 10:
             // Shows everything.
         // Shows everything.
         default:
             return '<= ' . Releases::PASSWD_RAR;
     }
 }
Beispiel #25
0
 /**
  * Perform cleanup of names and categories.
  */
 public function cleanup()
 {
     echo "PostPrc : Performing cleanup \n";
     $catsql = "select id from groups";
     $res = $this->pdo->query($catsql);
     foreach ($res as $r2) {
         $sql = sprintf("select r.id, name, searchname, categoryid, size, totalpart, musicinfoid, preid, groupid, rn.id as nfoid from releases r left outer join releasenfo rn ON rn.releaseid = r.id where groupid = %d", $r2['id']) . " %s ";
         $unbuf = $this->pdo->queryDirect(sprintf($sql, $this->limited ? " and r.adddate BETWEEN NOW() - INTERVAL 1 DAY AND NOW() " : ""));
         while ($r = $this->pdo->getAssocArray($unbuf)) {
             ///
             ///This Section will remove releases based on specific criteria
             ///
             //Remove releases if they include Parts info in the release name, as they are not full releases.
             if (preg_match('/(\\[|\\()\\d{1,4}\\/\\d{1,4}(\\]|\\))/', $r['name'])) {
                 $this->handleClean($r, "Modifying Release due to Parts in Release Name: " . $r['name'] . " - ", true);
                 continue;
             }
             //Remove releases if they include file of in  the release name, as they are not full releases.
             if (preg_match('/file \\d+ of \\d+/i', $r['name'])) {
                 $this->handleClean($r, "Modifying Release due to File of in Release Name: " . $r['name'] . " - ", true);
                 continue;
             }
             //Remove releases if they include file of in  the release name, as they are not full releases.
             if (preg_match('/\\[\\d+ of \\d+\\]/i', $r['name'])) {
                 $this->handleClean($r, "Modifying Release due to 23 of 23 in Release Name: " . $r['name'] . " - ", true);
                 continue;
             }
             //Remove releases if the name is numbers only.
             if (preg_match('/^[0-9\\.\\ \\-\\_\\[\\]\\(\\)\\@\\#]+$/', $r['name'])) {
                 $this->handleClean($r, "Modifying Release because it is Number Only in Release Name: " . $r['name'] . " - ");
                 continue;
             }
             //Remove releases if it starts with a IMDBID.
             if (preg_match('/^tt\\d{6}/i', $r['name'])) {
                 $this->handleClean($r, "Modifying Release because it starts with a IMDB id: " . $r['name'] . " - ");
                 continue;
             }
             //Remove releases if the name contains http(s): .
             if (preg_match('/http(s|)\\:/i', $r['name'])) {
                 $this->handleClean($r, "Modifying Release because it contains HTTP in the Release Name: " . $r['name'] . " - ", true);
                 continue;
             }
             //Remove releases if the name contains http(s): .
             // try stripos, its faster than preg_match
             if (preg_match('/sample/i', $r['name']) && $r['categoryid'] > 5000 && $r['categoryid'] < 5999) {
                 $this->handleClean($r, "Modifying Release because it contains Sample in the Release Name: " . $r['name'] . " - ", true);
                 continue;
             }
             ///
             ///End of Remove by name section
             ///
             ///
             ///This section will cleanup releases based on the category and things such as release size and release name length
             ///
             switch ($r['categoryid']) {
                 //CONSOLE
                 case Category::CAT_GAME_NDS:
                     //NDS
                     if ($r['size'] < 2000000) {
                         $this->handleClean($r, "Modifying Release Due to NDS Size: " . $r['name'] . " - ", true);
                         continue;
                     }
                     if (strlen($r['name']) < 11 && !preg_match('/\\([a-z]{2,3}\\)/i', $r['name']) && !$r['preid']) {
                         $this->handleClean($r, "Modifying Release Due to NDS Release Length: " . $r['name'] . " - ");
                         continue;
                     }
                     break;
                 case Category::CAT_GAME_PSP:
                     //PSP
                     if ($r['size'] < 100000 && $r['name'] != 'DLC') {
                         $this->handleClean($r, "Modifying Release Due to PSP Size: " . $r['name'] . " - ", true);
                         continue;
                     }
                     if (strlen($r['name']) < 13 && !$r['preid']) {
                         $this->handleClean($r, "Modifying Release PSP Due to Release Length: " . $r['name'] . " - ");
                         continue;
                     }
                     break;
                 case Category::CAT_GAME_WII:
                     //Wii
                     if ($r['size'] < 9000000 && $r['totalpart'] < 10) {
                         $this->handleClean($r, "Modifying Release Wii Size: " . $r['name'] . " - ", true);
                         continue;
                     }
                     if (strlen($r['name']) < 14 && !$r['preid']) {
                         $this->handleClean($r, "Modifying Release Wii ReleaseLEN: " . $r['name'] . " - ");
                         continue;
                     }
                     break;
                 case Category::CAT_GAME_XBOX:
                     //Xbox
                     if ($r['size'] < 1500000) {
                         $this->handleClean($r, "Modifying Release Xbox Size: " . $r['name'] . " - ", true);
                         continue;
                     }
                     if (strlen($r['name']) < 14 && !$r['preid']) {
                         $this->handleClean($r, "Modifying Release Xbox ReleaseLEN: " . $r['name'] . " - ");
                         continue;
                     }
                     break;
                 case Category::CAT_GAME_XBOX360:
                     //Xbox 360
                     if ($r['size'] < 50000000) {
                         $this->handleClean($r, "Modifying Release Xbox360 Size: " . $r['name'] . " - ", true);
                         continue;
                     }
                     if (strlen($r['name']) < 14 && !$r['preid']) {
                         $this->handleClean($r, "Modifying Release Xbox360 ReleaseLEN: " . $r['name'] . " - ");
                         continue;
                     }
                     break;
                 case Category::CAT_GAME_WIIWARE:
                     //WiiWare + VC
                     if ($r['size'] < 1000000 && $r['totalpart'] <= 1) {
                         $this->handleClean($r, "Modifying Release Wiiware Size: " . $r['name'] . " - ", true);
                         continue;
                     }
                     if (strlen($r['name']) < 14 && !$r['preid']) {
                         $this->handleClean($r, "Modifying Release Wiiware ReleaseLEN: " . $r['name'] . " - ");
                         continue;
                     }
                     break;
                 case Category::CAT_GAME_XBOX360DLC:
                     //Xbox 360DLC
                     if ($r['size'] < 50000000) {
                         //I Haven't figured out what to do for this group yet...
                         //handleClean($r,true);
                         continue;
                     }
                     if (strlen($r['name']) < 16 && !$r['preid']) {
                         $this->handleClean($r, "Modifying Release Xbox 360 DLC ReleaseLEN: " . $r['name'] . " - ");
                         continue;
                     }
                     break;
                 case Category::CAT_GAME_PS3:
                     //PS3
                     if ($r['size'] < 100000) {
                         $this->handleClean($r, "Modifying Release Due to PS3 Size: " . $r['name'] . " - ", true);
                         continue;
                     }
                     if (strlen($r['name']) < 14 && !$r['preid']) {
                         $this->handleClean($r, "Modifying Release PS3 Due to Release Length: " . $r['name'] . " - ");
                         continue;
                     }
                     break;
                     //MOVIES
                 //MOVIES
                 case Category::CAT_MOVIE_FOREIGN:
                     //Foreign Movies
                     if (($r['size'] < 10000000 || $r['totalpart'] <= 6) && !preg_match('/(fix|pack)/i', $r['name'])) {
                         $this->handleClean($r, "Modifying Release Foreign Movie Size: " . $r['name'] . " - ", true);
                         continue;
                     }
                     if (strlen($r['name']) < 16 && !preg_match('/(fix|pack|\\b((19|20)\\d{2})\\b)/i', $r['name']) && !$r['preid']) {
                         $this->handleClean($r, "Modifying Release Foreign Movies ReleaseLEN: " . $r['name'] . " - ");
                         continue;
                     }
                     break;
                 case Category::CAT_MOVIE_OTHER:
                     //Other Movies
                     if (($r['size'] < 10000000 || $r['totalpart'] <= 6) && !preg_match('/(fix|pack)/i', $r['name'])) {
                         $this->handleClean($r, "Modifying Release Other Movies Size: " . $r['name'] . " - ", true);
                         continue;
                     }
                     if (strlen($r['name']) < 24 && !preg_match('/(fix|pack|\\b((19|20)\\d{2})\\b)/i', $r['name']) && !$r['preid']) {
                         $this->handleClean($r, "Modifying Release Other Movies ReleaseLEN: " . $r['name'] . " - ");
                         continue;
                     }
                     break;
                 case Category::CAT_MOVIE_SD:
                     //SD Movies
                     if (($r['size'] < 10000000 || $r['totalpart'] <= 6) && !preg_match('/(fix|pack)/i', $r['name'])) {
                         $this->handleClean($r, "Modifying Release SD Movie Size: " . $r['name'] . " - ", true);
                         continue;
                     }
                     if (strlen($r['name']) < 21 && !preg_match('/(fix|pack|\\b((19|20)\\d{2})\\b)/i', $r['name']) && !$r['preid']) {
                         $this->handleClean($r, "Modifying Release SD Movies ReleaseLEN: " . $r['name'] . " - ");
                         continue;
                     }
                     break;
                 case Category::CAT_MOVIE_HD:
                     //HD Movies
                     if (($r['size'] < 60000000 || $r['totalpart'] <= 6) && !preg_match('/(fix|pack)/i', $r['name'])) {
                         $this->handleClean($r, "Modifying Release HD Movie Size: " . $r['name'] . " - ", true);
                         continue;
                     }
                     if (strlen($r['name']) < 21 && !preg_match('/(fix|pack|\\b((19|20)\\d{2})\\b)/i', $r['name']) && !$r['preid']) {
                         $this->handleClean($r, "Modifying Release HD Movies ReleaseLEN: " . $r['name'] . " - ");
                         continue;
                     }
                     break;
                 case Category::CAT_MOVIE_BLURAY:
                     //Bluray Movies
                     if (($r['size'] < 60000000 || $r['totalpart'] <= 6) && !preg_match('/(fix|pack)/i', $r['name'])) {
                         $this->handleClean($r, "Modifying Release Bluray Movie Size: " . $r['name'] . " - ", true);
                         continue;
                     }
                     if (strlen($r['name']) < 21 && !preg_match('/(fix|pack|\\b((19|20)\\d{2})\\b)/i', $r['name']) && !$r['preid']) {
                         $this->handleClean($r, "Modifying Release Bluray Movies ReleaseLEN: " . $r['name'] . " - ");
                         continue;
                     }
                     break;
                 case Category::CAT_MOVIE_3D:
                     //3D Movies
                     if (($r['size'] < 60000000 || $r['totalpart'] <= 6) && !preg_match('/(fix|pack)/i', $r['name'])) {
                         $this->handleClean($r, true);
                         continue;
                     }
                     if (strlen($r['name']) < 15 && !preg_match('/(fix|pack|\\b((19|20)\\d{2})\\b)/i', $r['name']) && !$r['preid']) {
                         $this->handleClean($r, "Modifying Release 3D Movies ReleaseLEN: " . $r['name'] . " - ");
                         continue;
                     }
                     break;
                     //AUDIO
                 //AUDIO
                 case Category::CAT_MUSIC_MP3:
                     // MP3
                     if (preg_match('/m3u/i', $r['name'])) {
                         $this->handleClean($r, "Modifying Release Audio MP3 Due to M3U in the name: " . $r['name'] . " - ", true);
                         continue;
                     }
                     if ($r['size'] < 5000000) {
                         $this->handleClean($r, "Modifying Release Audio MP3 Size: " . $r['name'] . " - ", true);
                         continue;
                     }
                     if (strlen($r['name']) < 25 && !preg_match('/(discography|\\b((19|20)\\d{2})\\b)/i', $r['name']) && $r['musicinfoid'] == '-2' && !$r['preid']) {
                         $this->handleClean($r, "Modifying Release Audio MP3 ReleaseLEN: " . $r['name'] . " - ");
                         continue;
                     }
                     break;
                 case Category::CAT_MUSIC_VIDEO:
                     // Video
                     if ($r['size'] < 10000000) {
                         $this->handleClean($r, "Modifying Release Audio Video Size: " . $r['name'] . " - ", true);
                         continue;
                     }
                     if (strlen($r['name']) < 20 && !preg_match('/(discography|\\b((19|20)\\d{2})\\b)/i', $r['name']) && $r['musicinfoid'] == '-2' && !$r['preid']) {
                         //echo "Modifying Release Audio Video ReleaseLEN: ".$r['name']." - ";
                         //handleClean($r); not sure what to
                         continue;
                     }
                     break;
                 case Category::CAT_MUSIC_AUDIOBOOK:
                     // Audiobook
                     if ($r['size'] < 10000000) {
                         $this->handleClean($r, "Modifying Release Audiobook Size: " . $r['name'] . " - ", true);
                         continue;
                     }
                     if (strlen($r['name']) < 20 && !preg_match('/(discography|\\b((19|20)\\d{2})\\b)/i', $r['name']) && $r['musicinfoid'] == '-2' && !$r['preid']) {
                         $this->handleClean($r, "Modifying Release Audiobook ReleaseLEN: " . $r['name'] . " - ");
                         continue;
                     }
                     break;
                 case Category::CAT_MUSIC_LOSSLESS:
                     // Lossless
                     if ($r['size'] < 10000000) {
                         //echo "Modifying Release Audio Lossless Size: ".$r['name']." - ";
                         //handleClean($r,true);
                         continue;
                     }
                     if (strlen($r['name']) < 20 && !preg_match('/(discography|\\b((19|20)\\d{2})\\b)/i', $r['name']) && $r['musicinfoid'] == '-2' && !$r['preid']) {
                         //echo "Modifying Release Audio Lossless ReleaseLEN: ".$r['name']." - ";
                         //handleClean($r);
                         continue;
                     }
                     break;
                     // PC
                 // PC
                 case Category::CAT_PC_0DAY:
                     // 0Day
                     if ($r['size'] < 1500000) {
                         $this->handleClean($r, "Modifying Release PC 0Day Size: " . $r['name'] . " - ", true);
                         continue;
                     }
                     if (strlen($r['name']) < 20 && $r['nfoid'] == null && !$r['preid']) {
                         $this->handleClean($r, "Modifying Release PC 0Day ReleaseLEN: " . $r['name'] . " - ");
                         continue;
                     }
                     break;
                 case Category::CAT_PC_ISO:
                     // ISO
                     if ($r['size'] < 1000000) {
                         $this->handleClean($r, "Modifying Release PC ISO Size: " . $r['name'] . " - ", true);
                         continue;
                     }
                     if (strlen($r['name']) < 20 && !$r['preid']) {
                         $this->handleClean($r, "Modifying Release PC ISO ReleaseLEN: " . $r['name'] . " - ");
                         continue;
                     }
                     break;
                 case Category::CAT_PC_MAC:
                     // Mac
                     if ($r['size'] < 500000) {
                         $this->handleClean($r, "Modifying Release PC Mac Size: " . $r['name'] . " - ", true);
                         continue;
                     }
                     if (strlen($r['name']) < 15 && !$r['preid']) {
                         //echo "Modifying Release PC Mac ReleaseLEN: ".$r['name']." - ";
                         //handleClean($r); Not sure about this yet
                         continue;
                     }
                     break;
                 case Category::CAT_PC_MOBILEOTHER:
                     // Mobile Other
                     if ($r['size'] < 500000) {
                         $this->handleClean($r, "Modifying Release PC Mobile Other Size: " . $r['name'] . " - ", true);
                         continue;
                     }
                     if (strlen($r['name']) < 20 && !$r['preid']) {
                         $this->handleClean($r, "Modifying Release PC Mobile Other ReleaseLEN: " . $r['name'] . " - ");
                         continue;
                     }
                     break;
                 case Category::CAT_PC_GAMES:
                     // Games
                     if ($r['size'] < 1000000) {
                         $this->handleClean($r, "Modifying Release PC Games Size: " . $r['name'] . " - ", true);
                         continue;
                     }
                     if (strlen($r['name']) < 15 && !$r['preid']) {
                         //echo "Modifying Release PC Games ReleaseLEN: ".$r['name']." - ";
                         //handleClean($r); Not sure about this yet
                         continue;
                     }
                     break;
                 case Category::CAT_PC_MOBILEIOS:
                     // Ios
                     if ($r['size'] < 600000) {
                         $this->handleClean($r, "Modifying Release PC Ios Size: " . $r['name'] . " - ", true);
                         continue;
                     }
                     if (strlen($r['name']) < 21 && !$r['preid']) {
                         $this->handleClean($r, "Modifying Release PC Ios ReleaseLEN: " . $r['name'] . " - ");
                         continue;
                     }
                     break;
                 case Category::CAT_PC_MOBILEANDROID:
                     // Android
                     if ($r['size'] < 600000) {
                         $this->handleClean($r, "Modifying Release PC Android Size: " . $r['name'] . " - ", true);
                         continue;
                     }
                     if (strlen($r['name']) < 15 && !$r['preid']) {
                         //echo "Modifying Release PC Android ReleaseLEN: ".$r['name']." - ";
                         //handleClean($r); Not sure about this yet
                         continue;
                     }
                     break;
                     // TV
                 // TV
                 case Category::CAT_TV_FOREIGN:
                     // Foreign
                     if ($r['size'] < 20000000 && !preg_match('/(fix|pack)/i', $r['name'])) {
                         $this->handleClean($r, "Modifying Release TV Foreign Size: " . $r['name'] . " - ", true);
                         continue;
                     }
                     if (strlen($r['name']) < 18 && !$r['preid']) {
                         $this->handleClean($r, "Modifying Release TV Foreign ReleaseLEN: " . $r['name'] . " - ");
                         continue;
                     }
                     break;
                 case Category::CAT_TV_SD:
                     // SD
                     if ($r['size'] < 20000000 && !preg_match('/(fix|pack)/i', $r['name'])) {
                         $this->handleClean($r, "Modifying Release TV SD Size: " . $r['name'] . " - ", true);
                         continue;
                     }
                     if (strlen($r['name']) < 20 && !$r['preid']) {
                         $this->handleClean($r, "Modifying Release TV SD ReleaseLEN: " . $r['name'] . " - ");
                         continue;
                     }
                     break;
                 case Category::CAT_TV_HD:
                     // HD
                     if ($r['size'] < 20000000 && !preg_match('/(fix|pack)/i', $r['name'])) {
                         $this->handleClean($r, "Modifying Release TV HD Size: " . $r['name'] . " - ", true);
                         continue;
                     }
                     if (strlen($r['name']) < 15 && !$r['preid']) {
                         $this->handleClean($r, "Modifying Release TV HD ReleaseLEN: " . $r['name'] . " - ");
                         continue;
                     }
                     break;
                 case Category::CAT_TV_OTHER:
                     // Other
                     if ($r['size'] < 20000000 && !preg_match('/(fix|pack)/i', $r['name'])) {
                         $this->handleClean($r, "Modifying Release TV Other Size: " . $r['name'] . " - ", true);
                         continue;
                     }
                     if (strlen($r['name']) < 15 && !$r['preid']) {
                         $this->handleClean($r, "Modifying Release TV Other ReleaseLEN: " . $r['name'] . " - ");
                         continue;
                     }
                     break;
                 case Category::CAT_TV_SPORT:
                     // Sport
                     if ($r['size'] < 20000000 && !preg_match('/(fix|pack)/i', $r['name'])) {
                         $this->handleClean($r, "Modifying Release TV Sport Size: " . $r['name'] . " - ", true);
                         continue;
                     }
                     if (strlen($r['name']) < 19 && !$r['preid']) {
                         $this->handleClean($r, "Modifying Release TV Sport ReleaseLEN: " . $r['name'] . " - ");
                         continue;
                     }
                     break;
                 case Category::CAT_TV_ANIME:
                     // Anime
                     if ($r['size'] < 20000000 && !preg_match('/(fix|pack)/i', $r['name'])) {
                         $this->handleClean($r, "Modifying Release TV Anime Size: " . $r['name'] . " - ", true);
                         continue;
                     }
                     if (strlen($r['name']) < 15 && !$r['preid']) {
                         $this->handleClean($r, "Modifying Release TV Anime ReleaseLEN: " . $r['name'] . " - ");
                         continue;
                     }
                     break;
                 case Category::CAT_TV_DOCU:
                     // Docu
                     if ($r['size'] < 20000000 && !preg_match('/(fix|pack)/i', $r['name'])) {
                         $this->handleClean($r, "Modifying Release TV Docu Size: " . $r['name'] . " - ", true);
                         continue;
                     }
                     if (strlen($r['name']) < 15 && !$r['preid']) {
                         $this->handleClean($r, "Modifying Release TV Docu ReleaseLEN: " . $r['name'] . " - ");
                         continue;
                     }
                     break;
                     // XXX
                 // XXX
                 case Category::CAT_XXX_DVD:
                     // DVD
                     if ($r['size'] < 20000000 && !preg_match('/(fix|pack)/i', $r['name'])) {
                         $this->handleClean($r, "Modifying Release XXX DVD Size: " . $r['name'] . " - ", true);
                         continue;
                     }
                     if (strlen($r['name']) < 20 && !$r['preid']) {
                         $this->handleClean($r, "Modifying Release XXX DVD ReleaseLEN: " . $r['name'] . " - ");
                         continue;
                     }
                     break;
                 case Category::CAT_XXX_WMV:
                     // WMV
                     if ($r['size'] < 20000000 && !preg_match('/(fix|pack)/i', $r['name'])) {
                         $this->handleClean($r, "Modifying Release XXX WMV Size: " . $r['name'] . " - ", true);
                         continue;
                     }
                     if (strlen($r['name']) < 20 && !$r['preid']) {
                         $this->handleClean($r, "Modifying Release XXX WMV ReleaseLEN: " . $r['name'] . " - ");
                         continue;
                     }
                     break;
                 case Category::CAT_XXX_XVID:
                     // XVID
                     if ($r['size'] < 20000000 && !preg_match('/(fix|pack)/i', $r['name'])) {
                         $this->handleClean($r, "Modifying Release XXX XVID Size: " . $r['name'] . " - ", true);
                         continue;
                     }
                     if (strlen($r['name']) < 14 && !$r['preid']) {
                         $this->handleClean($r, "Modifying Release XXX XVID ReleaseLEN: " . $r['name'] . " - ");
                         continue;
                     }
                     break;
                 case Category::CAT_XXX_X264:
                     // X264
                     if ($r['size'] < 20000000 && !preg_match('/(fix|pack)/i', $r['name'])) {
                         $this->handleClean($r, "Modifying Release XXX X264 Size: " . $r['name'] . " - ", true);
                         continue;
                     }
                     if (strlen($r['name']) < 15 && !$r['preid']) {
                         $this->handleClean($r, "Modifying Release XXX X264 ReleaseLEN: " . $r['name'] . " - ");
                         continue;
                     }
                     break;
                 case Category::CAT_XXX_PACK:
                     // PACK
                     if ($r['size'] < 20000000 && !preg_match('/(fix|pack)/i', $r['name'])) {
                         $this->handleClean($r, "Modifying Release XXX PACK Size: " . $r['name'] . " - ", true);
                         continue;
                     }
                     if (strlen($r['name']) < 15 && !$r['preid']) {
                         $this->handleClean($r, "Modifying Release XXX PACK ReleaseLEN: " . $r['name'] . " - ");
                         continue;
                     }
                     break;
                 case Category::CAT_XXX_IMAGESET:
                     // IMAGESET
                     if ($r['size'] < 3000000 && !preg_match('/(fix|pack)/i', $r['name'])) {
                         $this->handleClean($r, "Modifying Release XXX IMAGESET Size: " . $r['name'] . " - ", true);
                         continue;
                     }
                     if (strlen($r['name']) < 15 && !$r['preid']) {
                         $this->handleClean($r, "Modifying Release XXX IMAGESET ReleaseLEN: " . $r['name'] . " - ");
                         continue;
                     }
                     break;
                 case Category::CAT_BOOK_EBOOK:
                     // Ebook
                     if ($r['size'] < 50000 && !preg_match('/(fix|pack)/i', $r['name'])) {
                         $this->handleClean($r, "Modifying Release Misc Ebook Size: " . $r['name'] . " - ", true);
                         continue;
                     }
                     if (strlen($r['name']) < 12 && !$r['preid']) {
                         $this->handleClean($r, "Modifying Release Misc Ebook ReleaseLEN: " . $r['name'] . " - ");
                         continue;
                     }
                     break;
                 case Category::CAT_BOOK_COMICS:
                     // Comic
                     if ($r['size'] < 50000 && !preg_match('/(fix|pack)/i', $r['name'])) {
                         //echo "Modifying Release MISC Comic Size: ".$r['name']." - ";
                         //handleClean($r,true);
                         continue;
                     }
                     if (strlen($r['name']) < 7 && !$r['preid']) {
                         //echo "Modifying Release MISC Comic ReleaseLEN: ".$r['name']." - ";
                         //handleClean($r);
                         continue;
                     }
                     break;
                     //OTHER
                 //OTHER
                 case Category::CAT_MISC_OTHER:
                     if ($r['size'] < 1000000 && !preg_match('/(fix|pack)/i', $r['name'])) {
                         $this->handleClean($r, "Modifying Release Misc Other Size: " . $r['name'] . " - ", true);
                         continue;
                     }
                     if (strlen($r['name']) < 15 && !$r['preid']) {
                         //echo "Modifying Release MISC Other ReleaseLEN: ".$r['name']." - ";
                         //handleClean($r); Not sure what to do with this
                         continue;
                     }
                     break;
             }
             ///
             ///End of Remove by name section
             ///
         }
         $this->doClean();
         gc_collect_cycles();
     }
 }
Beispiel #26
0
 /**
  * @return array
  */
 public function getRecentlyAdded()
 {
     return $this->pdo->query("SELECT concat(cp.title, ' > ', category.title) AS title, COUNT(*) AS count\n                            FROM category\n                            LEFT OUTER JOIN category cp ON cp.id = category.parentid\n                            INNER JOIN releases ON releases.categoryid = category.id\n                            WHERE releases.adddate > NOW() - INTERVAL 1 WEEK\n                            GROUP BY concat(cp.title, ' > ', category.title)\n                            ORDER BY COUNT(*) DESC");
 }
Beispiel #27
0
    /**
     * Attempt to find NFO files inside the NZB's of releases.
     *
     * @param object $nntp           Instance of class NNTP.
     * @param string $groupID        (optional) Group id.
     * @param string $guidChar       (optional) First character of the release GUID (used for multi-processing).
     * @param int    $processImdb    (optional) Attempt to find IMDB id's in the NZB?
     * @param int    $processTvrage  (optional) Attempt to find TvRage id's in the NZB?
     *
     * @return int                   How many NFO's were processed?
     *
     * @access public
     */
    public function processNfoFiles($nntp, $groupID = '', $guidChar = '', $processImdb = 1, $processTvrage = 1)
    {
        $ret = 0;
        $guidCharQuery = $guidChar === '' ? '' : 'AND r.guid ' . $this->pdo->likeString($guidChar, false, true);
        $groupIDQuery = $groupID === '' ? '' : 'AND r.groupid = ' . $groupID;
        $optionsQuery = self::NfoQueryString($this->pdo);
        $res = $this->pdo->query(sprintf('
				SELECT r.id, r.guid, r.groupid, r.name
				FROM releases r
				WHERE 1=1 %s %s %s
				ORDER BY r.nfostatus ASC, r.postdate DESC
				LIMIT %d', $optionsQuery, $guidCharQuery, $groupIDQuery, $this->nzbs));
        $nfoCount = count($res);
        if ($nfoCount > 0) {
            $this->pdo->log->doEcho($this->pdo->log->primary(PHP_EOL . ($guidChar === '' ? '' : '[' . $guidChar . '] ') . ($groupID === '' ? '' : '[' . $groupID . '] ') . 'Processing ' . $nfoCount . ' NFO(s), starting at ' . $this->nzbs . ' * = hidden NFO, + = NFO, - = no NFO, f = download failed.'));
            if ($this->echo) {
                // Get count of releases per nfo status
                $nfoStats = $this->pdo->queryDirect(sprintf('
						SELECT r.nfostatus AS status, COUNT(*) AS count
						FROM releases r
						WHERE 1=1 %s %s %s
						GROUP BY r.nfostatus
						ORDER BY r.nfostatus ASC', $optionsQuery, $guidCharQuery, $groupIDQuery));
                if ($nfoStats instanceof Traversable) {
                    $outString = PHP_EOL . 'Available to process';
                    foreach ($nfoStats as $row) {
                        $outString .= ', ' . $row['status'] . ' = ' . number_format($row['count']);
                    }
                    $this->pdo->log->doEcho($this->pdo->log->header($outString . '.'));
                }
            }
            $groups = new Groups(['Settings' => $this->pdo]);
            $nzbContents = new NZBContents(['Echo' => $this->echo, 'NNTP' => $nntp, 'Nfo' => $this, 'Settings' => $this->pdo, 'PostProcess' => new PostProcess(['Echo' => $this->echo, 'Nfo' => $this, 'Settings' => $this->pdo])]);
            $movie = new Movie(['Echo' => $this->echo, 'Settings' => $this->pdo]);
            $tvRage = new TvRage(['Echo' => $this->echo, 'Settings' => $this->pdo]);
            foreach ($res as $arr) {
                $fetchedBinary = $nzbContents->getNFOfromNZB($arr['guid'], $arr['id'], $arr['groupid'], $groups->getByNameByID($arr['groupid']));
                if ($fetchedBinary !== false) {
                    // Insert nfo into database.
                    $cp = 'COMPRESS(%s)';
                    $nc = $this->pdo->escapeString($fetchedBinary);
                    $ckreleaseid = $this->pdo->queryOneRow(sprintf('SELECT id FROM releasenfo WHERE releaseid = %d', $arr['id']));
                    if (!isset($ckreleaseid['id'])) {
                        $this->pdo->queryInsert(sprintf('INSERT INTO releasenfo (nfo, releaseid) VALUES (' . $cp . ', %d)', $nc, $arr['id']));
                    }
                    $this->pdo->queryExec(sprintf('UPDATE releases SET nfostatus = %d WHERE id = %d', self::NFO_FOUND, $arr['id']));
                    $ret++;
                    $movie->doMovieUpdate($fetchedBinary, 'nfo', $arr['id'], $processImdb);
                    // If set scan for tvrage info.
                    if ($processTvrage == 1) {
                        $rageId = $this->parseRageId($fetchedBinary);
                        if ($rageId !== false) {
                            $show = $tvRage->parseNameEpSeason($arr['name']);
                            if (is_array($show) && $show['name'] != '') {
                                // Update release with season, ep, and air date info (if available) from release title.
                                $tvRage->updateEpInfo($show, $arr['id']);
                                $rid = $tvRage->getByRageID($rageId);
                                if (!$rid) {
                                    $tvrShow = $tvRage->getRageInfoFromService($rageId);
                                    $tvRage->updateRageInfo($rageId, $show, $tvrShow, $arr['id']);
                                }
                            }
                        }
                    }
                }
            }
        }
        // Remove nfo that we cant fetch after 5 attempts.
        $releases = $this->pdo->queryDirect(sprintf('SELECT r.id
				FROM releases r
				WHERE r.nzbstatus = %d
				AND r.nfostatus < %d %s %s', NZB::NZB_ADDED, $this->maxRetries, $groupIDQuery, $guidCharQuery));
        if ($releases instanceof Traversable) {
            foreach ($releases as $release) {
                $this->pdo->queryExec(sprintf('DELETE FROM releasenfo WHERE nfo IS NULL AND releaseid = %d', $release['id']));
            }
        }
        // Set releases with no NFO.
        $this->pdo->queryExec(sprintf('
				UPDATE releases r
				SET r.nfostatus = %d
				WHERE r.nzbstatus = %d
				AND r.nfostatus < %d %s %s', self::NFO_FAILED, NZB::NZB_ADDED, $this->maxRetries, $groupIDQuery, $guidCharQuery));
        if ($this->echo) {
            if ($nfoCount > 0) {
                echo PHP_EOL;
            }
            if ($ret > 0) {
                $this->pdo->log->doEcho($ret . ' NFO file(s) found/processed.', true);
            }
        }
        return $ret;
    }
Beispiel #28
0
 /**
  * Get all PRE's for a release.
  *
  * @param int $preID
  *
  * @return array
  */
 public function getForRelease($preID)
 {
     return $this->pdo->query(sprintf('SELECT * FROM prehash WHERE id = %d', $preID));
 }
Beispiel #29
0
 public function getDefaultValue($table, $field)
 {
     $db = new Settings();
     return $db->query(sprintf("SHOW COLUMNS FROM %s WHERE field = %s", $table, $db->escapeString($field)));
 }
<?php

require_once dirname(__FILE__) . "/../../../bin/config.php";
use newznab\db\Settings;
/* This script will update the groups table to get the new article numbers for each group you have activated.
  It will also truncate the parts, binaries, collections, and partrepair tables.
 */
// TODO: Make this threaded so it goes faster.
$pdo = new Settings();
if (!isset($argv[1]) || $argv[1] != 'true') {
    printf($pdo->log->setColor('Yellow') . "This script is used when you have switched UseNet Providers(USP) so you can pickup where you left off, rather than resetting all the groups.\nOnly use this script after you have updated your config.php file with your new USP info!!\nMake sure you " . $pdo->log->setColor('Red', 'Bold') . "DO NOT" . $pdo->log->setcolor('Yellow') . " have any update or postprocess scripts running when running this script!\n\n" . $pdo->log->setColor('Cyan') . "Usage: php change_USP_provider true\n");
    exit;
}
$groups = $pdo->query("SELECT id, name, first_record_postdate, last_record_postdate FROM groups WHERE active = 1");
$numofgroups = count($groups);
$guesstime = $numofgroups * 2;
$totalstart = microtime(true);
echo "You have {$numofgroups} active, it takes about 2 minutes on average to processes each group.\n";
foreach ($groups as $group) {
    $starttime = microtime(true);
    $nntp = new \NNTP(['Settings' => $pdo]);
    if ($nntp->doConnect() !== true) {
        return;
    }
    //printf("Updating group ".$group['name']."..\n");
    $bfdays = daysOldstr($group['first_record_postdate']);
    $currdays = daysOldstr($group['last_record_postdate']);
    $bfartnum = daytopost($nntp, $group['name'], $bfdays, true, true);
    echo "Our Current backfill postdate was: " . $pdo->log->setColor('Yellow') . date('r', strtotime($group['first_record_postdate'])) . $pdo->log->rsetcolor() . "\n";
    $currartnum = daytopost($nntp, $group['name'], $currdays, true, false);
    echo "Our Current current postdate was: " . $pdo->log->setColor('Yellow') . date('r', strtotime($group['last_record_postdate'])) . $pdo->log->rsetcolor() . "\n";