Ejemplo n.º 1
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 prehashid = 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(prehashid > 0 AND nzbstatus = 1 AND isrequestid = 1 AND reqidstatus = 1,1,0)) AS requestid_matched,\n\t\t\t\t\tSUM(IF(prehashid > 0 AND searchname IS NOT NULL,1,0)) AS prehash_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\tCOUNT(DISTINCT(prehashid)) AS distinct_prehash_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 WHERE nzbstatus = 1 AND nfostatus = 1) AS nfo,\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 = 'prehash' AND TABLE_SCHEMA = %1\$s) AS prehash,\n\t\t\t\t\t(SELECT TABLE_ROWS FROM INFORMATION_SCHEMA.TABLES WHERE table_name = 'partrepair' AND TABLE_SCHEMA = %1\$s) AS partrepair_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 = '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(MAX(predate)) FROM prehash) AS newestprehash,\n\t\t\t\t\t(SELECT UNIX_TIMESTAMP(MAX(ctime)) FROM predb) AS newestpredb,\n\t\t\t\t\t(SELECT UNIX_TIMESTAMP(adddate) FROM releases ORDER BY id DESC LIMIT 1) AS newestrelease";
         default:
             return false;
     }
 }
Ejemplo n.º 2
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;
 }