当前位置: 首页>>代码示例>>PHP>>正文


PHP Settings::queryDirect方法代码示例

本文整理汇总了PHP中newznab\db\Settings::queryDirect方法的典型用法代码示例。如果您正苦于以下问题:PHP Settings::queryDirect方法的具体用法?PHP Settings::queryDirect怎么用?PHP Settings::queryDirect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在newznab\db\Settings的用法示例。


在下文中一共展示了Settings::queryDirect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: processAnimeReleases

    /**
     * Queues anime releases for processing
     */
    public function processAnimeReleases()
    {
        $results = $this->pdo->queryDirect(sprintf('
							SELECT searchname, id
							FROM releases
							WHERE nzbstatus = %d
							AND anidbid IS NULL
							AND categoryid = %d
							ORDER BY postdate DESC
							LIMIT %d', \Enzebe::NZB_ADDED, \Category::CAT_TV_ANIME, $this->aniqty));
        if ($results instanceof \Traversable) {
            $this->doRandomSleep();
            $this->padb = new \newznab\db\populate\AniDB(['Echo' => $this->echooutput, 'Settings' => $this->pdo]);
            foreach ($results as $release) {
                $matched = $this->matchAnimeRelease($release);
                if ($matched === false) {
                    $this->pdo->queryExec(sprintf('
									UPDATE releases
									SET anidbid = %d
									WHERE id = %d', $this->status, $release['id']));
                }
            }
        } else {
            $this->pdo->log->doEcho($this->pdo->log->info("No work to process."), true);
        }
    }
开发者ID:engine9-,项目名称:newznab-tmux,代码行数:29,代码来源:AniDB.php

示例2: processGamesReleases

    public function processGamesReleases()
    {
        $res = $this->pdo->queryDirect(sprintf('
				SELECT searchname, id
				FROM releases
				WHERE nzbstatus = 1 %s
				AND gamesinfo_id = 0
				AND categoryid = 4050
				ORDER BY postdate DESC
				LIMIT %d', $this->renamed, $this->gameQty));
        if ($res instanceof \Traversable && $res->rowCount() > 0) {
            if ($this->echoOutput) {
                $this->pdo->log->doEcho($this->pdo->log->header("Processing " . $res->rowCount() . ' games release(s).'));
            }
            foreach ($res as $arr) {
                // Reset maxhitrequest
                $this->maxHitRequest = false;
                $startTime = microtime(true);
                $usedgb = false;
                $gameInfo = $this->parseTitle($arr['searchname']);
                if ($gameInfo !== false) {
                    if ($this->echoOutput) {
                        $this->pdo->log->doEcho($this->pdo->log->headerOver('Looking up: ') . $this->pdo->log->primary($gameInfo['title'] . ' (PC)'));
                    }
                    // Check for existing games entry.
                    $gameCheck = $this->getGamesInfoByName($gameInfo['title']);
                    if ($gameCheck === false) {
                        $gameId = $this->updateGamesInfo($gameInfo);
                        $usedgb = true;
                        if ($gameId === false) {
                            $gameId = -2;
                            // Leave gamesinfo_id 0 to parse again
                            if ($this->maxHitRequest === true) {
                                $gameId = 0;
                            }
                        }
                    } else {
                        $gameId = $gameCheck['id'];
                    }
                    // Update release.
                    $this->pdo->queryExec(sprintf('UPDATE releases SET gamesinfo_id = %d WHERE id = %d', $gameId, $arr['id']));
                } else {
                    // Could not parse release title.
                    $this->pdo->queryExec(sprintf('UPDATE releases SET gamesinfo_id = %d WHERE id = %d', -2, $arr['id']));
                    if ($this->echoOutput) {
                        echo '.';
                    }
                }
                // Sleep to not flood giantbomb.
                $diff = floor((microtime(true) - $startTime) * 1000000);
                if ($this->sleepTime * 1000 - $diff > 0 && $usedgb === true) {
                    usleep($this->sleepTime * 1000 - $diff);
                }
            }
        } else {
            if ($this->echoOutput) {
                $this->pdo->log->doEcho($this->pdo->log->header('No games releases to process.'));
            }
        }
    }
开发者ID:engine9-,项目名称:newznab-tmux,代码行数:60,代码来源:Games.php

示例3: categorizeRelease

function categorizeRelease($update = true, $where, $echooutput = false)
{
    $pdo = new Settings();
    $cat = new Categorize();
    $consoletools = new consoleTools();
    $relcount = $chgcount = 0;
    $c = new ColorCLI();
    echo $c->primary("SELECT id, searchname, groupid, categoryid FROM releases " . $where);
    $resrel = $pdo->queryDirect("SELECT id, searchname, groupid, categoryid FROM releases " . $where);
    $total = $resrel->rowCount();
    if ($total > 0) {
        foreach ($resrel as $rowrel) {
            $catId = $cat->determineCategory($rowrel['groupid'], $rowrel['searchname']);
            if ($rowrel['categoryid'] != $catId) {
                if ($update === true) {
                    $pdo->queryExec(sprintf("\n\t\t\t\t\t\t\tUPDATE releases\n\t\t\t\t\t\t\tSET iscategorized = 1,\n\t\t\t\t\t\t\t\trageid = -1,\n\t\t\t\t\t\t\t\tseriesfull = NULL,\n\t\t\t\t\t\t\t\tseason = NULL,\n\t\t\t\t\t\t\t\tepisode = NULL,\n\t\t\t\t\t\t\t\ttvtitle = NULL,\n\t\t\t\t\t\t\t\ttvairdate = NULL,\n\t\t\t\t\t\t\t\timdbid = NULL,\n\t\t\t\t\t\t\t\tmusicinfoid = NULL,\n\t\t\t\t\t\t\t\tconsoleinfoid = NULL,\n\t\t\t\t\t\t\t\tgamesinfo_id = 0,\n\t\t\t\t\t\t\t\txxxinfo_id = 0,\n\t\t\t\t\t\t\t\tbookinfoid = NULL,\n\t\t\t\t\t\t\t\tanidbid = NULL,\n\t\t\t\t\t\t\t\tcategoryid = %d\n\t\t\t\t\t\t\tWHERE id = %d", $catId, $rowrel['id']));
                }
                $chgcount++;
            }
            $relcount++;
            if ($echooutput) {
                $consoletools->overWritePrimary("Re-Categorized: [" . number_format($chgcount) . "] " . $consoletools->percentString($relcount, $total));
            }
        }
    }
    if ($echooutput !== false && $relcount > 0) {
        echo "\n";
    }
    return $chgcount;
}
开发者ID:engine9-,项目名称:newznab-tmux,代码行数:30,代码来源:recategorize.php

示例4: getCalendar

 public function getCalendar($date = "")
 {
     if (!preg_match('/\\d{4}-\\d{2}-\\d{2}/', $date)) {
         $date = date("Y-m-d");
     }
     $sql = $this->pdo->queryDirect(sprintf("\n\t\t\t\t\t\tSELECT *\n\t\t\t\t\t\tFROM episodeinfo\n\t\t\t\t\t\tWHERE DATE(airdate) = %s\n\t\t\t\t\t\tORDER BY airdate ASC", $this->pdo->escapeString($date)));
     return $sql;
 }
开发者ID:RickDB,项目名称:newznab-tmux,代码行数:8,代码来源:TvRage.php

示例5: processMovieReleases

 /**
  * Process all untagged movies to link them to a movieinfo row.
  */
 public function processMovieReleases()
 {
     $ret = 0;
     $nfo = new Nfo();
     $res = $this->pdo->queryDirect(sprintf("SELECT searchname, id from releases where imdbid IS NULL and categoryid in ( select id from category where parentid = %d ) ORDER BY postdate DESC LIMIT 100", Category::CAT_PARENT_MOVIE));
     if ($this->pdo->getNumRows($res) > 0) {
         if ($this->echooutput) {
             echo "MovProc : Processing " . $this->pdo->getNumRows($res) . " movie releases\n";
         }
         while ($arr = $this->pdo->getAssocArray($res)) {
             $imdbID = false;
             /* Preliminary IMDB id Detection from NFO file */
             $rawnfo = '';
             if ($nfo->getNfo($arr['id'], $rawnfo)) {
                 $imdbID = $this->parseImdbFromNfo($rawnfo);
             }
             if ($imdbID !== false) {
                 // Set IMDB (if found in nfo) and move along
                 $this->pdo->queryExec(sprintf("update releases set imdbid = %s where id = %d", $this->pdo->escapeString($imdbID), $arr["id"]));
                 //check for existing movie entry
                 $movCheck = $this->getMovieInfo($imdbID);
                 if ($movCheck === false || isset($movCheck['updateddate']) && time() - strtotime($movCheck['updateddate']) > 2592000) {
                     $movieId = $this->updateMovieInfo($imdbID);
                 }
                 continue;
             }
             $moviename = $this->parseMovieName($arr['searchname']);
             if ($moviename !== false) {
                 if ($this->echooutput) {
                     echo 'MovProc : ' . $moviename . ' [' . $arr['searchname'] . ']' . "\n";
                 }
                 //$buffer = getUrl("https://www.google.com/search?source=ig&hl=en&rlz=&btnG=Google+Search&aq=f&oq=&q=".urlencode($moviename.' site:imdb.com'));
                 $buffer = Utility::getUrl(['url' => 'http://www.bing.com/search?&q=' . urlencode($moviename . ' site:imdb.com')]);
                 // make sure we got some data
                 if ($buffer !== false && strlen($buffer)) {
                     $imdbId = $this->parseImdbFromNfo($buffer);
                     if ($imdbId !== false) {
                         //update release with imdb id
                         $this->pdo->queryExec(sprintf("update releases SET imdbid = %s WHERE id = %d", $this->pdo->escapeString($imdbId), $arr["id"]));
                         //check for existing movie entry
                         $movCheck = $this->getMovieInfo($imdbId);
                         if ($movCheck === false || isset($movCheck['updateddate']) && time() - strtotime($movCheck['updateddate']) > 2592000) {
                             $movieId = $this->updateMovieInfo($imdbId);
                         }
                     } else {
                         //no imdb id found, set to all zeros so we dont process again
                         $this->pdo->queryExec(sprintf("update releases SET imdbid = %d WHERE id = %d", 0, $arr["id"]));
                     }
                 } else {
                     //url fetch failed, will try next run
                 }
             } else {
                 //no valid movie name found, set to all zeros so we dont process again
                 $this->pdo->queryExec(sprintf("update releases SET imdbid = %d WHERE id = %d", 0, $arr["id"]));
             }
         }
     }
 }
开发者ID:engine9-,项目名称:newznab-tmux,代码行数:61,代码来源:Movie.php

示例6: processMusicReleases

 /**
  *
  */
 public function processMusicReleases($local = false)
 {
     $res = $this->pdo->queryDirect(sprintf('SELECT searchname, id FROM releases ' . 'WHERE musicinfoid IS NULL AND nzbstatus = 1 %s AND categoryid IN (3010, 3040, 3050) ' . 'ORDER BY postdate DESC LIMIT %d', $this->renamed, $this->musicqty));
     if ($res instanceof \Traversable && $res->rowCount() > 0) {
         if ($this->echooutput) {
             $this->pdo->log->doEcho($this->pdo->log->header("Processing " . $res->rowCount() . ' music release(s).'));
         }
         foreach ($res as $arr) {
             $startTime = microtime(true);
             $usedAmazon = false;
             $album = $this->parseArtist($arr['searchname']);
             if ($album !== false) {
                 $newname = $album["name"] . ' (' . $album["year"] . ')';
                 if ($this->echooutput) {
                     $this->pdo->log->doEcho($this->pdo->log->headerOver('Looking up: ') . $this->pdo->log->primary($newname));
                 }
                 // Do a local lookup first
                 $musicCheck = $this->getMusicInfoByName('', $album["name"]);
                 if ($musicCheck === false && in_array($album['name'] . $album['year'], $this->failCache)) {
                     // Lookup recently failed, no point trying again
                     if ($this->echooutput) {
                         $this->pdo->log->doEcho($this->pdo->log->headerOver('Cached previous failure. Skipping.') . PHP_EOL);
                     }
                     $albumId = -2;
                 } else {
                     if ($musicCheck === false && $local === false) {
                         $albumId = $this->updateMusicInfo($album['name'], $album['year']);
                         $usedAmazon = true;
                         if ($albumId === false) {
                             $albumId = -2;
                             $this->failCache[] = $album['name'] . $album['year'];
                         }
                     } else {
                         $albumId = $musicCheck['id'];
                     }
                 }
                 // Update release.
                 $this->pdo->queryExec(sprintf("UPDATE releases SET musicinfoid = %d WHERE id = %d", $albumId, $arr["id"]));
             } else {
                 $this->pdo->queryExec(sprintf("UPDATE releases SET musicinfoid = %d WHERE id = %d", -2, $arr["id"]));
                 echo '.';
             }
             // Sleep to not flood amazon.
             $diff = floor((microtime(true) - $startTime) * 1000000);
             if ($this->sleeptime * 1000 - $diff > 0 && $usedAmazon === true) {
                 usleep($this->sleeptime * 1000 - $diff);
             }
         }
         if ($this->echooutput) {
             echo "\n";
         }
     } else {
         if ($this->echooutput) {
             $this->pdo->log->doEcho($this->pdo->log->header('No music releases to process.'));
         }
     }
 }
开发者ID:engine9-,项目名称:newznab-tmux,代码行数:60,代码来源:Musik.php

示例7: add

 public function add($form)
 {
     $content = $this->row2Object($form);
     $content = $this->validate($content);
     if ($content->ordinal == 1) {
         $this->pdo->queryDirect("UPDATE content SET ordinal = ordinal + 1 WHERE ordinal > 0");
     }
     return $this->data_add($content);
 }
开发者ID:RickDB,项目名称:newznab-tmux,代码行数:9,代码来源:Contents.php

示例8: getAnimeList

    /**
     * Retrieves a list of Anime titles, optionally filtered by starting character and title
     *
     * @param string $letter
     * @param string $animetitle
     * @return array|bool
     */
    public function getAnimeList($letter = '', $animetitle = '')
    {
        $regex = 'REGEXP';
        $rsql = '';
        if ($letter != '') {
            if ($letter == '0-9') {
                $letter = '[0-9]';
            }
            $rsql .= sprintf('AND at.title %s %s', $regex, $this->pdo->escapeString('^' . $letter));
        }
        $tsql = '';
        if ($animetitle != '') {
            $tsql .= sprintf('AND at.title %s', $this->pdo->likeString($animetitle, true, true));
        }
        return $this->pdo->queryDirect(sprintf('SELECT at.anidbid, at.title, ai.type, ai.categories, ai.rating, ai.startdate, ai.enddate
					FROM anidb_titles AS at LEFT JOIN anidb_info AS ai USING (anidbid)
					WHERE at.anidbid > 0 %s %s
					GROUP BY at.anidbid
					ORDER BY at.title ASC', $rsql, $tsql));
    }
开发者ID:RickDB,项目名称:newznab-tmux,代码行数:27,代码来源:AniDB.php

示例9: removeSpecial

 /**
  * Removes funky chars from beginning and end of string
  */
 public function removeSpecial()
 {
     $sql = "select id, searchname from releases where 1 = 1 ";
     $sql .= $this->limited ? "AND adddate BETWEEN NOW() - INTERVAL 1 DAY AND NOW()" : "";
     $sql .= " order by postdate desc";
     $res = $this->pdo->queryDirect($sql);
     while ($r = $this->pdo->getAssocArray($res)) {
         $oldname = $r['searchname'];
         if (preg_match('/^(\\:|\\"|\\-| )+/', $r['searchname'])) {
             while (preg_match('/^(\\:|\\"|\\-| |\\_)+/', $r['searchname'])) {
                 $r['searchname'] = substr($r['searchname'], 1);
             }
             $this->updateName($this->pdo, $r['id'], $oldname, $r['searchname']);
         }
         if (preg_match('/^000\\-/', $r['searchname'])) {
             while (preg_match('/^000\\-/', $r['searchname'])) {
                 $r['searchname'] = substr($r['searchname'], 4);
             }
             $this->updateName($this->pdo, $r['id'], $oldname, $r['searchname']);
         }
         if (preg_match('/(\\:|\\"|\\-| |\\/)$/', $r['searchname'])) {
             while (preg_match('/(\\:|\\"|\\-| |\\/)$/', $r['searchname'])) {
                 $r['searchname'] = substr($r['searchname'], 0, -1);
             }
             $this->updateName($this->pdo, $r['id'], $oldname, $r['searchname']);
         }
         if (preg_match('/\\"/', $r['searchname'])) {
             while (preg_match('/\\"/', $r['searchname'])) {
                 $r['searchname'] = str_replace('"', '', $r['searchname']);
             }
             $this->updateName($this->pdo, $r['id'], $oldname, $r['searchname']);
         }
         if (preg_match('/\\-\\d{1}$/', $r['searchname'])) {
             while (preg_match('/\\-\\d{1}$/', $r['searchname'])) {
                 $r['searchname'] = preg_replace('/\\-\\d{1}$/', '', $r['searchname']);
             }
             $this->updateName($this->pdo, $r['id'], $oldname, $r['searchname']);
         }
         if (preg_match('/\\!+.*?mom.*?\\!+/i', $r['searchname'])) {
             while (preg_match('/\\!+.*?mom.*?\\!+/i', $r['searchname'])) {
                 $r['searchname'] = preg_replace('/\\!+.*?mom.*?\\!+/i', '', $r['searchname']);
             }
             $this->updateName($this->pdo, $r['id'], $oldname, $r['searchname']);
         }
         if (preg_match('/(\\/)/i', $r['searchname'])) {
             while (preg_match('/(\\/)/i', $r['searchname'])) {
                 $r['searchname'] = preg_replace('/(\\/)/i', '', $r['searchname']);
             }
             $this->updateName($this->pdo, $r['id'], $oldname, $r['searchname']);
         }
     }
 }
开发者ID:engine9-,项目名称:newznab-tmux,代码行数:55,代码来源:Parsing.php

示例10: parseTitles

 /**
  * Matches the hashes within the predb table to release files and subjects (names) which are hashed.
  *
  * @param $time
  * @param $echo
  * @param $cats
  * @param $namestatus
  * @param $show
  *
  * @return int
  */
 public function parseTitles($time, $echo, $cats, $namestatus, $show)
 {
     $namefixer = new NameFixer(['Echo' => $this->echooutput, 'ConsoleTools' => $this->pdo->log, 'Settings' => $this->pdo]);
     $consoletools = new ConsoleTools(['ColorCLI' => $this->pdo->log]);
     $updated = $checked = 0;
     $tq = '';
     if ($time == 1) {
         $tq = 'AND r.adddate > (NOW() - INTERVAL 3 HOUR) ORDER BY rf.releaseid, rf.size DESC';
     }
     $ct = '';
     if ($cats == 1) {
         $ct = 'AND r.categoryid IN (1090, 2020, 3050, 6050, 5050, 7050, 8010)';
     }
     if ($this->echooutput) {
         $te = '';
         if ($time == 1) {
             $te = ' in the past 3 hours';
         }
         echo $this->pdo->log->header('Fixing search names' . $te . " using the predb hash.");
     }
     $regex = "AND (r.ishashed = 1 OR rf.ishashed = 1)";
     if ($cats === 3) {
         $query = sprintf('SELECT r.id AS releaseid, r.name, r.searchname, r.categoryid, r.groupid, ' . 'dehashstatus, rf.name AS filename FROM releases r ' . 'LEFT OUTER JOIN releasefiles rf ON r.id = rf.releaseid ' . 'WHERE nzbstatus = 1 AND dehashstatus BETWEEN -6 AND 0 AND prehashid = 0 %s', $regex);
     } else {
         $query = sprintf('SELECT r.id AS releaseid, r.name, r.searchname, r.categoryid, r.groupid, ' . 'dehashstatus, rf.name AS filename FROM releases r ' . 'LEFT OUTER JOIN releasefiles rf ON r.id = rf.releaseid ' . 'WHERE nzbstatus = 1 AND isrenamed = 0 AND dehashstatus BETWEEN -6 AND 0 %s %s %s', $regex, $ct, $tq);
     }
     $res = $this->pdo->queryDirect($query);
     $total = $res->rowCount();
     echo $this->pdo->log->primary(number_format($total) . " releases to process.");
     if ($res instanceof Traversable) {
         foreach ($res as $row) {
             if (preg_match('/[a-fA-F0-9]{32,40}/i', $row['name'], $matches)) {
                 $updated = $updated + $namefixer->matchPredbHash($matches[0], $row, $echo, $namestatus, $this->echooutput, $show);
             } else {
                 if (preg_match('/[a-fA-F0-9]{32,40}/i', $row['filename'], $matches)) {
                     $updated = $updated + $namefixer->matchPredbHash($matches[0], $row, $echo, $namestatus, $this->echooutput, $show);
                 }
             }
             if ($show === 2) {
                 $consoletools->overWritePrimary("Renamed Releases: [" . number_format($updated) . "] " . $consoletools->percentString(++$checked, $total));
             }
         }
     }
     if ($echo == 1) {
         echo $this->pdo->log->header("\n" . $updated . " releases have had their names changed out of: " . number_format($checked) . " files.");
     } else {
         echo $this->pdo->log->header("\n" . $updated . " releases could have their names changed. " . number_format($checked) . " files were checked.");
     }
     return $updated;
 }
开发者ID:engine9-,项目名称:newznab-tmux,代码行数:61,代码来源:PreHash.php

示例11: testRegex

 public function testRegex($regex, $groupname, $poster, $ignorematched, $matchagainstbins)
 {
     $cat = new Categorize();
     $groups = new Groups();
     $groupID = $groups->getByNameByID($groupname);
     $group = $groups->getCBPTableNames($this->tablePerGroup, $groupID);
     $catList = $cat->getForSelect();
     $matches = [];
     if ($groupname === 0) {
         $groupname = '.*';
     }
     if ($matchagainstbins !== '') {
         $sql = sprintf("select b.*, '0' as size, '0' as blacklistID, g.name as groupname from %s b left join groups g on g.id = b.groupid where b.groupid IN (select g.id from groups g where g.name REGEXP %s) order by b.date desc", $group['bname'], $this->pdo->escapeString('^' . $groupname . '$'));
     } else {
         $sql = sprintf("select rrt.* from releaseregextesting rrt where rrt.groupname REGEXP %s order by rrt.date desc", $this->pdo->escapeString('^' . $groupname . '$'));
     }
     $resbin = $this->pdo->queryDirect($sql);
     while ($rowbin = $this->pdo->getAssocArray($resbin)) {
         if ($ignorematched !== '' && ($rowbin['regexid'] != '' || $rowbin['blacklistid'] == 1)) {
             continue;
         }
         $regexarr = ["id" => "", 'regex' => $regex, 'poster' => $poster, "categoryid" => ""];
         $regexCheck = $this->performMatch($regexarr, $rowbin['name'], $rowbin['fromname']);
         if ($regexCheck !== false) {
             $relname = $regexCheck['name'];
             $relparts = explode("/", $regexCheck['parts']);
             $matches[$relname]['name'] = $relname;
             $matches[$relname]['parts'] = $regexCheck['parts'];
             $matches[$relname]['bincount'] = isset($matches[$relname]['bincount']) ? $matches[$relname]['bincount'] + 1 : 1;
             $matches[$relname]['bininfo'][] = $rowbin;
             $matches[$relname]['binsize'][] = $rowbin['size'];
             $matches[$relname]['totalsize'] = array_sum($matches[$relname]['binsize']);
             $matches[$relname]['relparts'][$relparts[1]] = $relparts[1];
             $matches[$relname]['reltotalparts'] = array_sum($matches[$relname]['relparts']);
             $matches[$relname]['regexid'] = $regexCheck['regexid'];
             if (ctype_digit($regexCheck['regcatid'])) {
                 $matches[$relname]['catname'] = $catList[$regexCheck['regcatid']];
             } else {
                 $matches[$relname]['catname'] = $catList[$cat->determineCategory($groupname, $relname)];
             }
         }
     }
     //echo '<pre>';
     //print_r(array_pop($matches));
     //echo '</pre>';
     return $matches;
 }
开发者ID:RickDB,项目名称:newznab-tmux,代码行数:47,代码来源:ReleaseRegex.php

示例12: purge

 /**
  * Purge a single group or all groups.
  *
  * @param int|string|bool $id The group id. If false, purge all groups.
  */
 public function purge($id = false)
 {
     if ($id === false) {
         $this->resetall();
     } else {
         $this->reset($id);
     }
     $releaseArray = $this->pdo->queryDirect(sprintf("SELECT id, guid FROM releases %s", $id === false ? '' : 'WHERE groupid = ' . $id));
     if ($releaseArray instanceof \Traversable) {
         $releases = new \Releases(['Settings' => $this->pdo, 'Groups' => $this]);
         $nzb = new \NZB($this->pdo);
         $releaseImage = new \ReleaseImage($this->pdo);
         foreach ($releaseArray as $release) {
             $releases->deleteSingle(['g' => $release['guid'], 'i' => $release['id']], $nzb, $releaseImage);
         }
     }
 }
开发者ID:engine9-,项目名称:newznab-tmux,代码行数:22,代码来源:Groups.php

示例13: writeNZBforReleaseId

    /**
     * Write an NZB to the hard drive for a single release.
     *
     * @param int    $relID   The id of the release in the DB.
     * @param string $relGuid The guid of the release.
     * @param string $name    The name of the release.
     * @param string $cTitle  The name of the category this release is in.
     *
     * @return bool Have we successfully written the NZB to the hard drive?
     *
     * @access public
     */
    public function writeNZBforReleaseId($relID, $relGuid, $name, $cTitle)
    {
        $path = $this->buildNZBPath($relGuid, $this->nzbSplitLevel, true) . $relGuid . '.nzb.gz';
        $fp = gzopen($path, 'wb7');
        if ($fp) {
            $nzb_guid = '';
            gzwrite($fp, sprintf($this->_nzbHeadString, htmlspecialchars($cTitle, ENT_QUOTES, 'utf-8'), htmlspecialchars($name, ENT_QUOTES, 'utf-8')));
            $binaries = $this->pdo->queryDirect($this->_binariesQuery . $relID . ' ORDER BY name');
            if ($binaries instanceof \Traversable) {
                foreach ($binaries as $binary) {
                    $poster = htmlspecialchars($binary['fromname'], ENT_QUOTES, 'utf-8');
                    if ($binary instanceof \Traversable) {
                        foreach ($binary as $bin) {
                            // Buffer segment writes, increases performance.
                            $string = '';
                            $parts = $this->pdo->queryDirect(sprintf($this->_partsQuery, $bin['id']));
                            if ($parts instanceof \Traversable) {
                                foreach ($parts as $part) {
                                    if ($nzb_guid === '') {
                                        $nzb_guid = $part['messageid'];
                                    }
                                    $string .= '  <segment bytes="' . $part['size'] . '" number="' . $part['partnumber'] . '">' . htmlspecialchars($part['messageid'], ENT_QUOTES, 'utf-8') . "</segment>\n";
                                }
                            }
                            gzwrite($fp, '<file poster="' . $poster . '" date="' . $bin['udate'] . '" subject="' . htmlspecialchars($bin['name'], ENT_QUOTES, 'utf-8') . ' (1/' . $bin['totalparts'] . ")\">\n <groups>\n  <group>" . $bin['groupname'] . "</group>\n </groups>\n <segments>\n" . $string . " </segments>\n</file>\n");
                        }
                    }
                }
            }
            gzwrite($fp, '</nzb>');
            gzclose($fp);
            if (is_file($path)) {
                $this->pdo->queryExec(sprintf('
						UPDATE releases SET nzbstatus = %d %s WHERE id = %d', NZB::NZB_ADDED, $nzb_guid === '' ? '' : ', nzb_guid = UNHEX( ' . $this->pdo->escapestring(md5($nzb_guid)) . ' )', $relID));
                // Chmod to fix issues some users have with file permissions.
                chmod($path, 0777);
                return true;
            } else {
                echo "ERROR: {$path} does not exist.\n";
            }
        }
        return false;
    }
开发者ID:RickDB,项目名称:newznab-tmux,代码行数:55,代码来源:Enzebe.php

示例14: processReleases

 /**
  * Process all untagged releases to see if they are found in predb.
  */
 public function processReleases($daysback = 3)
 {
     if ($this->echooutput) {
         echo "Predb   : Updating releases with pre data\n";
     }
     $matched = 0;
     $releasesQuery = $this->pdo->queryDirect(sprintf('SELECT id, searchname FROM releases WHERE preid IS NULL AND adddate > DATE_SUB(NOW(), INTERVAL %d DAY)', $daysback));
     while ($arr = $this->pdo->getAssocArray($releasesQuery)) {
         $arr['searchname'] = str_replace(' ', '_', $arr['searchname']);
         $sql = sprintf("SELECT id FROM predb WHERE dirname = %s LIMIT 1", $this->pdo->escapeString($arr['searchname']));
         $predbQuery = $this->pdo->queryOneRow($sql);
         if ($predbQuery) {
             $this->pdo->queryExec(sprintf('UPDATE releases SET preid = %d WHERE id = %d', $predbQuery['id'], $arr['id']));
             $matched++;
         }
     }
     if ($this->echooutput) {
         echo "Predb   : Matched pre data to " . $matched . " releases\n";
     }
 }
开发者ID:RickDB,项目名称:newznab-tmux,代码行数:23,代码来源:PreDB.php

示例15: getPreFileNames

    public function getPreFileNames($args = [])
    {
        $timestart = time();
        $counter = $counted = 0;
        $limit = $orderby = '';
        $show = isset($args[2]) && $args[2] === 'show' ? 1 : 0;
        if (isset($args[1]) && is_numeric($args[1])) {
            $orderby = "ORDER BY r.id DESC";
            $limit = "LIMIT " . $args[1];
        }
        echo $this->pdo->log->header("\nMatch PreFiles ({$args[1]}) Started at " . date('g:i:s'));
        echo $this->pdo->log->primary("Matching predb filename to cleaned releasefiles.name.\n");
        $query = $this->pdo->queryDirect(sprintf('
							SELECT r.id AS releaseid, r.name, r.searchname,
								r.groupid, r.categoryid,
								rf.name AS filename
							FROM releases r
							INNER JOIN releasefiles rf ON r.id = rf.releaseid
							AND rf.name IS NOT NULL
							WHERE r.prehashid = 0
							GROUP BY r.id
							%s %s', $orderby, $limit));
        if ($query !== false) {
            $total = $query->rowCount();
            if ($total > 0 && $query instanceof Traversable) {
                echo $this->pdo->log->header("\n" . number_format($total) . ' releases to process.');
                foreach ($query as $row) {
                    $success = $this->matchPredbFiles($row, 1, 1, true, $show);
                    if ($success === 1) {
                        $counted++;
                    }
                    if ($show === 0) {
                        $this->consoletools->overWritePrimary("Renamed Releases: [" . number_format($counted) . "] " . $this->consoletools->percentString(++$counter, $total));
                    }
                }
                echo $this->pdo->log->header("\nRenamed " . number_format($counted) . " releases in " . $this->consoletools->convertTime(TIME() - $timestart) . ".");
            } else {
                echo $this->pdo->log->info("\nNothing to do.");
            }
        }
    }
开发者ID:RickDB,项目名称:newznab-tmux,代码行数:41,代码来源:NameFixer.php


注:本文中的newznab\db\Settings::queryDirect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。