本文整理汇总了PHP中newznab\db\Settings::getAssocArray方法的典型用法代码示例。如果您正苦于以下问题:PHP Settings::getAssocArray方法的具体用法?PHP Settings::getAssocArray怎么用?PHP Settings::getAssocArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类newznab\db\Settings
的用法示例。
在下文中一共展示了Settings::getAssocArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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"]));
}
}
}
}
示例2: 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']);
}
}
}
示例3: applyRegex
/**
* @param int|string $groupID (optional)
*/
public function applyRegex($groupID)
{
//
// Get all regexes for all groups which are to be applied to new binaries
// in order of how they should be applied
//
$group = $this->groups->getCBPTableNames($this->tablePerGroup, $groupID);
$activeGroups = $this->groups->getActive();
$this->releaseRegex->get();
$this->pdo->log->doEcho($this->pdo->log->primary('Applying regex to binaries'), true);
foreach ($activeGroups as $groupArr) {
//check if regexes have already been applied during update binaries
if ($groupArr['regexmatchonly'] == 1) {
continue;
}
$groupRegexes = $this->releaseRegex->getForGroup($groupArr['name']);
$this->pdo->log->doEcho($this->pdo->log->primary('Applying ' . sizeof($groupRegexes) . ' regexes to group ' . $groupArr['name']), true);
// Get out all binaries of STAGE0 for current group
$newUnmatchedBinaries = array();
$ressql = sprintf('SELECT id, name, date, totalparts, procstat, fromname FROM %s b
WHERE groupid = %d AND procstat IN (%d, %d) AND regexid IS NULL ORDER BY b.date ASC', $group['bname'], $groupArr['id'], Releases::PROCSTAT_NEW, Releases::PROCSTAT_TITLENOTMATCHED);
$resbin = $this->pdo->queryDirect($ressql);
$matchedbins = 0;
while ($rowbin = $this->pdo->getAssocArray($resbin)) {
$regexMatches = array();
foreach ($groupRegexes as $groupRegex) {
$regexCheck = $this->releaseRegex->performMatch($groupRegex, $rowbin['name']);
if ($regexCheck !== false) {
$regexMatches = $regexCheck;
break;
}
}
if (!empty($regexMatches)) {
$matchedbins++;
$relparts = explode("/", $regexMatches['parts']);
$this->pdo->queryExec(sprintf("UPDATE %s SET relname = replace(%s, '_', ' '), relpart = %d, reltotalpart = %d, procstat=%d, categoryid=%s, regexid=%d, reqid=%s WHERE id = %d", $group['bname'], $this->pdo->escapeString($regexMatches['name']), $relparts[0], $relparts[1], Releases::PROCSTAT_TITLEMATCHED, $regexMatches['regcatid'], $regexMatches['regexid'], $this->pdo->escapeString($regexMatches['reqid']), $rowbin["id"]));
} else {
if ($rowbin['procstat'] == Releases::PROCSTAT_NEW) {
$newUnmatchedBinaries[] = $rowbin['id'];
}
}
}
//mark as not matched
if (!empty($newUnmatchedBinaries)) {
$this->pdo->queryExec(sprintf("UPDATE %s SET procstat=%d WHERE id IN (%s)", $group['bname'], Releases::PROCSTAT_TITLENOTMATCHED, implode(',', $newUnmatchedBinaries)));
}
}
}
示例4: 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;
}
示例5: 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";
}
}
示例6: processConsoleReleases
/**
* Check all untagged console releases for their extended metadata.
*/
public function processConsoleReleases()
{
$ret = 0;
$numlookedup = 0;
$res = $this->pdo->queryDirect(sprintf("SELECT searchname, id from releases where consoleinfoid IS NULL and categoryid in ( select id from category where parentid = %d ) ORDER BY postdate DESC LIMIT 100", Category::CAT_PARENT_GAME));
if ($this->pdo->getNumRows($res) > 0) {
if ($this->echooutput) {
echo "ConsPrc : Processing " . $this->pdo->getNumRows($res) . " console releases\n";
}
while ($arr = $this->pdo->getAssocArray($res)) {
if ($numlookedup > Console::NUMTOPROCESSPERTIME) {
return;
}
$gameInfo = $this->parseTitle($arr['searchname']);
if ($gameInfo !== false) {
if ($this->echooutput) {
echo 'ConsPrc : ' . $gameInfo["title"] . ' (' . $gameInfo["platform"] . ')' . "\n";
}
//check for existing console entry
$gameCheck = $this->getConsoleInfoByName($gameInfo["title"], $gameInfo["platform"]);
if ($gameCheck === false) {
$numlookedup++;
$gameId = $this->updateConsoleInfo($gameInfo);
if ($gameId === false) {
$gameId = -2;
}
} else {
$gameId = $gameCheck["id"];
}
//update release
$this->pdo->queryExec(sprintf("update releases SET consoleinfoid = %d WHERE id = %d", $gameId, $arr["id"]));
} else {
//could not parse release title
$this->pdo->queryExec(sprintf("update releases SET consoleinfoid = %d WHERE id = %d", -2, $arr["id"]));
}
}
}
}
示例7: processMusicReleases
/**
* Process all untagged releases to see if musicinfo exists for them.
*/
public function processMusicReleases()
{
$ret = 0;
$numlookedup = 0;
$res = $this->pdo->queryDirect(sprintf("SELECT searchname, id from releases where musicinfoid IS NULL and categoryid in ( select id from category where parentid = %d ) ORDER BY postdate DESC LIMIT 1000", Category::CAT_PARENT_MUSIC));
if ($this->pdo->getNumRows($res) > 0) {
if ($this->echooutput) {
echo "MusicPr : Processing " . $this->pdo->getNumRows($res) . " audio releases\n";
}
while ($arr = $this->pdo->getAssocArray($res)) {
if ($numlookedup > Music::NUMTOPROCESSPERTIME) {
return;
}
$albumId = -2;
$album = $this->parseArtist($arr['searchname']);
if ($album !== false) {
if ($this->echooutput) {
echo 'MusicPr : Looking up: ' . $album["artist"] . ' - ' . $album["album"] . "\n";
}
//check for existing music entry
$albumCheck = $this->getMusicInfoByName($album["artist"], $album["album"]);
if ($albumCheck === false) {
//
// get from amazon
//
$numlookedup++;
$ret = $this->updateMusicInfo($album["artist"], $album["album"], $album['year']);
if ($ret !== false) {
$albumId = $ret;
}
} else {
$albumId = $albumCheck["id"];
}
}
$this->pdo->queryExec(sprintf("update releases SET musicinfoid = %d WHERE id = %d", $albumId, $arr["id"]));
}
}
}
示例8: processBookReleases
/**
* Process all untagged book releases for additional metadata.
*/
public function processBookReleases()
{
$numlookedup = 0;
$res = $this->pdo->queryDirect(sprintf("SELECT searchname, id from releases where bookinfoid IS NULL and categoryid = %d ORDER BY postdate DESC LIMIT 100", Category::CAT_BOOK_EBOOK));
if ($this->pdo->getNumRows($res) > 0) {
if ($this->echooutput) {
echo "BookPrc : Processing " . $this->pdo->getNumRows($res) . " book releases\n";
}
while ($arr = $this->pdo->getAssocArray($res)) {
if ($numlookedup > Book::NUMTOPROCESSPERTIME) {
return;
}
$bookId = -2;
$book = $this->parseAuthor($arr['searchname']);
if ($book !== false) {
if ($this->echooutput) {
echo 'BookPrc : ' . $book["author"] . ' - ' . $book["title"] . "\n";
}
//check for existing book entry
$bookCheck = $this->getBookInfoByName($book["author"], $book["title"]);
if ($bookCheck === false) {
//
// get from amazon
//
$numlookedup++;
$ret = $this->updateBookInfo($book["author"], $book["title"]);
if ($ret !== false) {
$bookId = $ret;
}
} else {
$bookId = $bookCheck["id"];
}
}
$this->pdo->queryExec(sprintf("update releases SET bookinfoid = %d WHERE id = %d", $bookId, $arr["id"]));
}
}
}
示例9: processReleases
/**
*
*/
public function processReleases()
{
$results = $this->pdo->queryDirect(sprintf("SELECT id, searchname, rageid, anidbid, seriesfull, season, episode, tvtitle FROM releases WHERE episodeinfoid IS NULL AND categoryid IN ( SELECT id FROM category WHERE parentid = %d ) LIMIT 150", Category::CAT_PARENT_TV));
if ($this->pdo->getNumRows($results) > 0) {
if ($this->echooutput) {
echo "TheTVDB : Looking up last " . $this->pdo->getNumRows($results) . " releases\n";
}
while ($arr = $this->pdo->getAssocArray($results)) {
unset($TheTVDBAPIArray, $episodeArray, $fullep, $epabsolute, $additionalSql);
$seriesName = '';
if ($arr['rageid'] > 0) {
$seriesName = $this->pdo->queryOneRow(sprintf('SELECT releasetitle AS seriesName FROM tvrage WHERE rageid = %d', $arr['rageid']));
} elseif ($arr['anidbid'] > 0) {
$seriesName = $this->pdo->queryOneRow(sprintf('SELECT title AS seriesName FROM anidb WHERE anidbid = %d', $arr['anidbid']));
}
if (empty($seriesName) || !$seriesName) {
$this->notFound($seriesName, "", $arr['id'], false);
continue;
}
$seriesName = str_replace('`', '\'', $seriesName['seriesName']);
if (!preg_match('/[21]\\d{3}\\/\\d{2}\\/\\d{2}/', $arr['seriesfull'])) {
$fullep = str_pad(str_replace('S', '', $arr['season']), 2, '0', STR_PAD_LEFT) . 'x' . str_pad(str_replace('E', '', $arr['episode']), 2, '0', STR_PAD_LEFT);
} else {
$fullep = str_replace('/', '-', $arr['seriesfull']);
}
$TheTVDBAPIArray = $this->getSeriesInfoByName($seriesName);
if (!$TheTVDBAPIArray) {
$seriesid = $this->lookupSeriesID($seriesName);
if ($seriesid > 0) {
$TheTVDBAPIArray = $this->TheTVDBAPI($seriesid, $seriesName);
if ($TheTVDBAPIArray) {
$this->addSeries($TheTVDBAPIArray);
$this->addEpisodes($TheTVDBAPIArray);
} else {
$this->addEmptySeries($seriesName);
$this->notFound($seriesName, $fullep, $arr['id']);
continue;
}
} else {
$this->addEmptySeries($seriesName);
$this->notFound($seriesName, $fullep, $arr['id']);
continue;
}
} else {
if ($TheTVDBAPIArray['tvdbid'] > 0 && time() - strtotime($TheTVDBAPIArray['createddate']) > 604800) {
$TheTVDBAPIArray = $this->TheTVDBAPI($TheTVDBAPIArray['tvdbid'], $seriesName);
$this->updateSeries($TheTVDBAPIArray['tvdbid'], $TheTVDBAPIArray['actors'], $TheTVDBAPIArray['airsday'], $TheTVDBAPIArray['airstime'], $TheTVDBAPIArray['contentrating'], $TheTVDBAPIArray['firstaired'], $TheTVDBAPIArray['genre'], $TheTVDBAPIArray['imdbid'], $TheTVDBAPIArray['network'], $TheTVDBAPIArray['overview'], $TheTVDBAPIArray['rating'], $TheTVDBAPIArray['ratingcount'], $TheTVDBAPIArray['runtime'], $TheTVDBAPIArray['seriesname'], $TheTVDBAPIArray['status']);
$this->addEpisodes($TheTVDBAPIArray);
}
}
if ($TheTVDBAPIArray['tvdbid'] > 0) {
$epabsolute = '0';
if ($arr['anidbid'] > 0) {
if (preg_match('/S(?P<season>\\d+)[ED](?P<episode>\\d+)/', $arr['episode'], $seasonEpisode)) {
$arr['season'] = $seasonEpisode['season'];
$arr['episode'] = $seasonEpisode['episode'];
} else {
$epabsolute = $arr['episode'];
}
}
$Episode = new Episode();
$episodeArray = $Episode->getEpisodeInfoByName($seriesName, $fullep, (string) $epabsolute);
if (!$episodeArray) {
$this->notFound($seriesName, $fullep, $arr['id']);
continue;
}
} else {
$this->notFound($seriesName, $fullep, $arr['id']);
continue;
}
$additionalSql = '';
if ($arr['anidbid'] > 0 && $episodeArray['epabsolute'] > 0) {
$additionalSql = sprintf(', season = NULL, episode = %d, tvtitle = %s, tvairdate = %s', $episodeArray['epabsolute'], $this->pdo->escapeString($episodeArray['epabsolute'] . ' - ' . str_replace('\'', '`', $episodeArray['eptitle'])), $this->pdo->escapeString($episodeArray['airdate']));
}
$this->pdo->queryExec(sprintf('UPDATE releases SET tvdbid = %d, episodeinfoid = %d %s WHERE id = %d', $TheTVDBAPIArray['tvdbid'], $episodeArray['id'], $additionalSql, $arr['id']));
if ($this->echooutput) {
echo 'TheTVDB : ' . $seriesName . ' ' . $fullep . " returned " . $episodeArray['tvdbid'] . "\n";
}
}
}
}
示例10: dirname
//This script will rerun all releases against Category.php
require_once dirname(__FILE__) . '/../../www/config.php';
use newznab\db\Settings;
$db = new Settings();
$category = new Categorize();
$changedcount = 0;
$rescount = 0;
//
// [1] change for all where the regex isnt aimed at a specific category (affects most releases)
//
//$res = $db->queryDirect("select r.id as id, r.searchname as searchname, g.name as groupname, r.categoryID as rcat from releases r, releaseregex rr, groups g where r.regexid=rr.id and g.ID = r.groupID and rr.categoryid is null");
//
// [2] update for all in a category
//
//$res = $db->queryDirect("select r.id as id, r.searchname as searchname, g.name as groupname, r.categoryID as rcat from releases r inner join groups g on g.ID = r.groupID where r.categoryID in (6010, 6020, 6030, 6040)");
//
// [3] reset all flac with hashed names
//
//$res = $db->queryDirect("select releases.ID as id, searchname as searchname, groups.name as groupname, releases.categoryID as rcat from releases join groups on groups.ID = releases.groupID where length(searchname) = 40 and groups.name like 'alt.binaries.sounds.flac'");
while ($rel = $db->getAssocArray($res)) {
$rescount++;
$categoryID = $category->determineCategory($rel['groupname'], $rel['searchname']);
if ($categoryID != $rel['rcat'] && $categoryID != '7900') {
$changedcount++;
echo "Changing category for " . $rel['searchname'] . " New (" . $categoryID . ") Old (" . $rel['rcat'] . ")\n";
$db->exec(sprintf("update releases SET categoryID = %d WHERE ID = %d", $categoryID, $rel['id']));
}
}
echo $rescount . " releases \n";
echo $changedcount . " releases changed\n";
示例11: filemtime
$i["isdir"] = is_dir($f) ? 1 : 0;
$i["fullname"] = $f;
$i["webpath"] = $webpath . "/" . $i["name"] . ($i["isdir"] == 1 ? "/" : "");
$i["mtime"] = filemtime($f);
$i["pathinfo"] = pathinfo($f);
if ($i["isdir"] == 1) {
$i["pathinfo"]["extension"] = "";
$dirs[] = $i["name"];
} else {
$i["size"] = filesize($f);
}
$items[$i["name"]] = $i;
}
if (!$listmode) {
$relres = $r->getByNames($dirs);
while ($rel = $pdo->getAssocArray($relres)) {
if (isset($items[$rel["searchname"]])) {
$items[$rel["searchname"]]["release"] = $rel;
}
}
}
uasort($items, 'sortbymodified');
$page->smarty->assign('results', $items);
$page->smarty->assign('lm', $listmode);
if ($subpath != "") {
$page->smarty->assign('subpath', $subpath . "/");
}
$parentpath = "";
if ($subpath != "") {
$pos = strrpos($subpath, "/");
if ($pos !== false) {
示例12: AdminPage
<?php
require_once "config.php";
use newznab\db\Settings;
$page = new AdminPage();
$page->title = "Admin Hangout";
$statusmsgs = array();
//
// status messages
//
//
// mysql config settings
//
$db = new Settings();
$result = $db->queryDirect("SELECT @@group_concat_max_len, @@max_allowed_packet");
$data = $db->getAssocArray($result);
if ($data['@@group_concat_max_len'] < 8192) {
$statusmsgs[] = addmsg("MySql my.cnf setting group_concat_max_len is too low, should be >= 8192.", "http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html#sysvar_group_concat_max_len");
}
if ($data['@@max_allowed_packet'] < 12582912) {
$statusmsgs[] = addmsg("MySql my.cnf setting max_allowed_packet is too low, should be >= 12582912.", "http://dev.mysql.com/doc/refman/5.1/en/server-system-variables.html#sysvar_max_allowed_packet");
}
//
// default keys not changed
//
if ($page->settings->getSetting('amazonpubkey') == "AKIAIPDNG5EU7LB4AD3Q" && $page->settings->getSetting('lookupmusic') + $page->settings->getSetting('lookupgames') + $page->settings->getSetting('lookupbooks') != 0) {
$statusmsgs[] = addmsg("Amazon shared key in use. Not using your own Amazon API key will result in failed amazon lookups.", "http://newznab.readthedocs.org/en/latest/faq/");
}
if ($page->settings->getSetting('rawretentiondays') > 10) {
$statusmsgs[] = addmsg("Binary header retention is set at " . $page->settings->getSetting('rawretentiondays') . ". Having this value any higher than 2 can cause the database to grow very large.", "site-edit.php");
}
示例13: searchDirect
/**
* Query the indexer directly. Returns an array of the results, unless
* there was an error in which case ``false`` is returned. However, if
* Sphinx returns an "invalid query" error (1064), then an empty result
* array is returned. Note that an empty "result array" is not the same as
* an empty array and will instead look like::
*
* array({"_totalrows": 0})
*
* If ``$lookupQuery`` is an empty string, then the results returned will
* be the data from the index--this is not guaranteed to be the most recent
* data that is in the MySQL database. If you absolutely need the most
* recent data from MySQL, then ``$lookupQuery`` should be a valid SQL
* query that has contains "releases.id IN (%s)".
*
* @param string $sphinxQuery The raw SphinxQL query.
* @param string $lookupQuery The SQL to use to lookup the results.
* @param bool/int $useCache The ttl to store the item in the cache.
* @return array|false
*/
public function searchDirect($sphinxQuery, $lookupQuery = "", $useCache = false)
{
$cache = new Cache();
if ($useCache !== false && $cache->enabled && $cache->exists($sphinxQuery)) {
$ret = $cache->fetch($sphinxQuery);
if ($ret !== false) {
return $ret;
}
}
// Connect to Sphinx
$hostport = explode(":", $this->pdo->getSetting('sphinxserverhost'));
$sdb = mysqli_connect($hostport[0], "root", "", "", $hostport[1]);
if (!$sdb) {
// Couldn't connect to Sphinx.
return false;
}
// Get the results from Sphinx.
$lev = error_reporting();
error_reporting(0);
$result = mysqli_query($sdb, $sphinxQuery);
error_reporting($lev);
$error = mysqli_error($sdb);
// A 1064 error means that the query is invalid, so we don't care
// about that.
if ($error && mysqli_errno($sdb) != 1064) {
// All other errors we will considered a failure.
return false;
}
// Get the query metadata.
$meta = [];
$mresult = mysqli_query($sdb, "SHOW META");
if (!$mresult) {
return false;
}
while ($row = mysqli_fetch_row($mresult)) {
$meta[$row[0]] = $row[1];
}
$results = [];
if ($result) {
while ($row = mysqli_fetch_assoc($result)) {
if ($lookupQuery) {
// Save the IDs for a batch lookup.
$results[] = $row["id"];
} else {
$results[] = $row;
}
}
}
if ($lookupQuery && count($results) > 0) {
$ndb = new newznab\db\Settings();
$sql = sprintf($lookupQuery, implode(",", $results));
$result = $ndb->queryDirect($sql);
if ($result) {
$results = [];
while ($row = $ndb->getAssocArray($result)) {
$results[] = $row;
}
}
}
$count = 0;
if (count($results) > 0 && array_key_exists("total", $meta)) {
$count = (int) $meta["total_found"];
$results[0]["_totalrows"] = $count > MAX_MATCHES ? MAX_MATCHES : $count;
}
if ($useCache !== false && $cache->enabled) {
$cache->store($sphinxQuery, $results, $useCache);
}
return $results;
}
示例14: writeNZBforReleaseId
/**
* Writes out the nzb when processing releases. Performed outside of smarty due to memory issues
* of holding all parts in an array.
*/
function writeNZBforReleaseId($relid, $name, $catId, $path, $groupID)
{
$db = new Settings();
$cat = new Category();
$this->groupID = $groupID;
// Set table names
if ($this->tablePerGroup === true) {
if ($this->groupID == '') {
exit("{$this->groupID} is missing\n");
}
$bName = 'binaries_' . $this->groupID;
$pName = 'parts_' . $this->groupID;
} else {
$bName = 'binaries';
$pName = 'parts';
}
$catrow = $cat->getById($catId);
$site = new Sites();
$fp = gzopen($path, "w");
if ($fp) {
$nzb_guid = '';
gzwrite($fp, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
gzwrite($fp, "<!DOCTYPE nzb PUBLIC \"-//newzBin//DTD NZB 1.1//EN\" \"http://www.newzbin.com/DTD/nzb/nzb-1.1.dtd\">\n");
gzwrite($fp, "<nzb xmlns=\"http://www.newzbin.com/DTD/2003/nzb\">\n\n");
gzwrite($fp, "<head>\n");
if ($catrow) {
gzwrite($fp, " <meta type=\"category\">" . htmlspecialchars($catrow["title"], ENT_QUOTES, 'utf-8') . "</meta>\n");
}
if ($name != "") {
gzwrite($fp, " <meta type=\"name\">" . htmlspecialchars($name, ENT_QUOTES, 'utf-8') . "</meta>\n");
}
gzwrite($fp, "</head>\n\n");
$result = $db->queryDirect(sprintf("SELECT %s.*, UNIX_TIMESTAMP(date) AS unixdate, groups.name as groupname FROM %s inner join groups on %s.groupid = groups.id WHERE %s.releaseid = %d ORDER BY %s.name", $bName, $bName, $bName, $bName, $relid, $bName));
while ($binrow = $this->pdo->getAssocArray($result)) {
$groups = array();
$groupsRaw = explode(' ', $binrow['xref']);
foreach ($groupsRaw as $grp) {
if (preg_match('/^([a-z0-9\\.\\-_]+):(\\d+)?$/i', $grp, $match) && strtolower($grp) !== 'xref') {
$groups[] = $match[1];
}
}
if (count($groups) == 0) {
$groups[] = $binrow["groupname"];
}
gzwrite($fp, "<file poster=\"" . htmlspecialchars($binrow["fromname"], ENT_QUOTES, 'utf-8') . "\" date=\"" . $binrow["unixdate"] . "\" subject=\"" . htmlspecialchars($binrow["name"], ENT_QUOTES, 'utf-8') . " (1/" . $binrow["totalparts"] . ")\">\n");
gzwrite($fp, " <groups>\n");
foreach ($groups as $group) {
gzwrite($fp, " <group>" . $group . "</group>\n");
}
gzwrite($fp, " </groups>\n");
gzwrite($fp, " <segments>\n");
$resparts = $db->queryDirect(sprintf("SELECT DISTINCT(messageid), size, partnumber FROM %s WHERE binaryid = %d ORDER BY partnumber", $pName, $binrow["id"]));
while ($partsrow = $db->getAssocArray($resparts)) {
if ($nzb_guid === '') {
$nzb_guid = $partsrow['messageid'];
}
gzwrite($fp, " <segment bytes=\"" . $partsrow["size"] . "\" number=\"" . $partsrow["partnumber"] . "\">" . htmlspecialchars($partsrow["messageid"], ENT_QUOTES, 'utf-8') . "</segment>\n");
}
gzwrite($fp, " </segments>\n</file>\n");
}
gzwrite($fp, "<!-- generated by newznab " . $site->version() . " -->\n</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";
}
}
}
示例15: dirname
<?php
//This script will update all records in the cosole table
require_once dirname(__FILE__) . '/../../www/config.php';
use newznab\db\Settings;
$console = new Console(['Echo' => true, 'Settings' => $pdo]);
$db = new Settings();
$res = $db->queryDirect(sprintf("SELECT searchname, id from releases where consoleinfoid IS NULL and categoryid in ( select ID from category where parentid = %d ) ORDER BY id DESC LIMIT %d", Category::CAT_PARENT_GAME, Console::NUMTOPROCESSPERTIME));
if ($res != null) {
while ($arr = $db->getAssocArray($res)) {
$gameInfo = $console->parseTitle($arr['searchname']);
if ($gameInfo !== false) {
echo 'Searching ' . $gameInfo['release'] . '<br />';
$game = $console->updateConsoleInfo($gameInfo);
if ($game !== false) {
echo "<pre>";
print_r($game);
echo "</pre>";
} else {
echo '<br />Game not found<br /><br />';
}
}
}
}