Example #1
0
 /**
  * Look for an .nfo file in the NZB, return the NFO message id.
  * Gets the NZB completion.
  * Looks for PAR2 files in the NZB.
  *
  * @param string $guid
  * @param string $relID
  * @param int    $groupID
  * @param string $groupName
  *
  * @return bool
  *
  * @access public
  */
 public function getNfoFromNZB($guid, $relID, $groupID, $groupName)
 {
     $fetchedBinary = false;
     $messageID = $this->parseNZB($guid, $relID, $groupID, true);
     if ($messageID !== false) {
         $fetchedBinary = $this->nntp->getMessages($groupName, $messageID['ID'], $this->alternateNNTP);
         if ($this->nntp->isError($fetchedBinary)) {
             // NFO download failed, increment attempts.
             $this->pdo->queryExec(sprintf('UPDATE releases SET nfostatus = nfostatus - 1 WHERE id = %d', $relID));
             if ($this->echooutput) {
                 echo 'f';
             }
             return false;
         }
         if ($this->nfo->isNFO($fetchedBinary, $guid) === true) {
             if ($this->echooutput) {
                 echo $messageID['hidden'] === false ? '+' : '*';
             }
         } else {
             if ($this->echooutput) {
                 echo '-';
             }
             $this->pdo->queryExec(sprintf('UPDATE releases SET nfostatus = %d WHERE id = %d', Nfo::NFO_NONFO, $relID));
             $fetchedBinary = false;
         }
     } else {
         if ($this->echooutput) {
             echo '-';
         }
         $this->pdo->queryExec(sprintf('UPDATE releases SET nfostatus = %d WHERE id = %d', Nfo::NFO_NONFO, $relID));
     }
     return $fetchedBinary;
 }
Example #2
0
 public function proc_query($qry, $bookreqids, $request_hours, $db_name)
 {
     switch ((int) $qry) {
         case 1:
             return sprintf("SELECT\n\t\t\t\t\tSUM(IF(nzbstatus = 1 AND categoryid BETWEEN 5000 AND 5999 AND rageid = -1,1,0)) AS processtvrage,\n\t\t\t\t\tSUM(IF(nzbstatus = 1 AND categoryid = 5070 AND anidbid IS NULL,1,0)) AS processanime,\n\t\t\t\t\tSUM(IF(nzbstatus = 1 AND categoryid BETWEEN 2000 AND 2999 AND imdbid IS NULL,1,0)) AS processmovies,\n\t\t\t\t\tSUM(IF(nzbstatus = 1 AND categoryid IN (3010, 3040, 3050) AND musicinfoid IS NULL,1,0)) AS processmusic,\n\t\t\t\t\tSUM(IF(nzbstatus = 1 AND categoryid BETWEEN 1000 AND 1999 AND consoleinfoid IS NULL,1,0)) AS processconsole,\n\t\t\t\t\tSUM(IF(nzbstatus = 1 AND categoryid IN (%s) AND bookinfoid IS NULL,1,0)) AS processbooks,\n\t\t\t\t\tSUM(IF(nzbstatus = 1 AND categoryid = 4050 AND gamesinfo_id = 0,1,0)) AS processgames,\n\t\t\t\t\tSUM(IF(nzbstatus = 1 AND categoryid BETWEEN 6000 AND 6040 AND xxxinfo_id = 0,1,0)) AS processxxx,\n\t\t\t\t\tSUM(IF(1=1 %s,1,0)) AS processnfo,\n\t\t\t\t\tSUM(IF(nzbstatus = 1 AND nfostatus = 1,1,0)) AS nfo,\n\t\t\t\t\tSUM(IF(nzbstatus = 1 AND isrequestid = 1 AND preid = 0 AND\n\t\t\t\t\t\t((reqidstatus = 0) OR (reqidstatus = -1) OR (reqidstatus = -3 AND adddate > NOW() - INTERVAL %s HOUR)),1,0)) AS requestid_inprogress,\n\t\t\t\t\tSUM(IF(preid > 0 AND nzbstatus = 1 AND isrequestid = 1 AND reqidstatus = 1,1,0)) AS requestid_matched,\n\t\t\t\t\tSUM(IF(preid > 0 AND searchname IS NOT NULL,1,0)) AS predb_matched,\n\t\t\t\t\tCOUNT(DISTINCT(preid)) AS distinct_predb_matched\n\t\t\t\t\tFROM releases r", $bookreqids, Nfo::NfoQueryString($this->pdo), $request_hours);
         case 2:
             return "SELECT\n\t\t\t\t\t(SELECT COUNT(*) FROM releases r\n\t\t\t\t\t\tINNER JOIN category c ON c.id = r.categoryid\n\t\t\t\t\t\tWHERE r.nzbstatus = 1\n\t\t\t\t\t\tAND r.passwordstatus BETWEEN -6 AND -1 AND r.haspreview = -1 AND c.disablepreview = 0\n\t\t\t\t\t) AS work,\n\t\t\t\t\t(SELECT COUNT(*) FROM groups WHERE active = 1) AS active_groups,\n\t\t\t\t\t(SELECT COUNT(*) FROM groups WHERE name IS NOT NULL) AS all_groups";
         case 4:
             return sprintf("\n\t\t\t\t\tSELECT\n\t\t\t\t\t(SELECT TABLE_ROWS FROM information_schema.TABLES WHERE table_name = 'predb' AND TABLE_SCHEMA = %1\$s) AS predb,\n\t\t\t\t\t(SELECT TABLE_ROWS FROM information_schema.TABLES WHERE table_name = 'missed_parts' AND TABLE_SCHEMA = %1\$s) AS missed_parts_table,\n\t\t\t\t\t(SELECT TABLE_ROWS FROM information_schema.TABLES WHERE table_name = 'parts' AND TABLE_SCHEMA = %1\$s) AS parts_table,\n\t\t\t\t\t(SELECT TABLE_ROWS FROM information_schema.TABLES WHERE table_name = 'binaries' AND TABLE_SCHEMA = %1\$s) AS binaries_table,\n\t\t\t\t\t(SELECT TABLE_ROWS FROM information_schema.TABLES WHERE table_name = 'collections' AND TABLE_SCHEMA = %1\$s) AS collections_table,\n\t\t\t\t\t(SELECT TABLE_ROWS FROM information_schema.TABLES WHERE table_name = 'releases' AND TABLE_SCHEMA = %1\$s) AS releases,\n\t\t\t\t\t(SELECT COUNT(*) FROM groups WHERE first_record IS NOT NULL AND backfill = 1\n\t\t\t\t\t\tAND (now() - INTERVAL backfill_target DAY) < first_record_postdate\n\t\t\t\t\t) AS backfill_groups_days,\n\t\t\t\t\t(SELECT COUNT(*) FROM groups WHERE first_record IS NOT NULL AND backfill = 1 AND (now() - INTERVAL datediff(curdate(),\n\t\t\t\t\t(SELECT VALUE FROM settings WHERE setting = 'safebackfilldate')) DAY) < first_record_postdate) AS backfill_groups_date", $this->pdo->escapeString($db_name));
         case 6:
             return "SELECT\n\t\t\t\t\t(SELECT searchname FROM releases ORDER BY id DESC LIMIT 1) AS newestrelname,\n\t\t\t\t\t(SELECT UNIX_TIMESTAMP(MIN(dateadded)) FROM collections) AS oldestcollection,\n\t\t\t\t\t(SELECT UNIX_TIMESTAMP(MAX(predate)) FROM predb) AS newestpre,\n\t\t\t\t\t(SELECT UNIX_TIMESTAMP(adddate) FROM releases ORDER BY id DESC LIMIT 1) AS newestrelease";
         default:
             return false;
     }
 }
Example #3
0
 /**
  * Check if we should process NFO's.
  * @return bool
  */
 private function checkProcessNfo()
 {
     if ($this->pdo->getSetting('lookupnfo') == 1) {
         $this->nfoQueryString = Nfo::NfoQueryString($this->pdo);
         return $this->pdo->queryOneRow(sprintf('SELECT r.id FROM releases r WHERE 1=1 %s LIMIT 1', $this->nfoQueryString)) === false ? false : true;
     }
     return false;
 }
Example #4
0
 /**
  * Verify a file is a NFO and add it to the database.
  *
  * @param string $fileLocation
  */
 protected function _processNfoFile($fileLocation)
 {
     $data = @file_get_contents($fileLocation);
     if ($data !== false) {
         if ($this->_nfo->isNFO($data, $this->_release['guid']) === true) {
             if ($this->_nfo->addAlternateNfo($data, $this->_release, $this->_nntp) === true) {
                 $this->_releaseHasNoNFO = false;
             }
         }
     }
 }
Example #5
0
 /**
  * Process nfo files.
  *
  * @param \nzedb\NNTP   $nntp
  * @param string $groupID  (Optional) ID of a group to work on.
  * @param string $guidChar (Optional) First letter of a release GUID to use to get work.
  *
  * @return void
  */
 public function processNfos(&$nntp, $groupID = '', $guidChar = '')
 {
     if ($this->pdo->getSetting('lookupnfo') == 1) {
         $this->Nfo->processNfoFiles($nntp, $groupID, $guidChar, (int) $this->pdo->getSetting('lookupimdb'), (int) $this->pdo->getSetting('lookuptvrage'));
     }
 }