本文整理汇总了PHP中newznab\db\Settings::ping方法的典型用法代码示例。如果您正苦于以下问题:PHP Settings::ping方法的具体用法?PHP Settings::ping怎么用?PHP Settings::ping使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类newznab\db\Settings
的用法示例。
在下文中一共展示了Settings::ping方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _updatePre
/**
* Updates PRE data in the DB.
*
* @access protected
*/
protected function _updatePre()
{
if (empty($this->_curPre['title'])) {
return;
}
$query = 'UPDATE prehash SET ';
$query .= !empty($this->_curPre['size']) ? 'size = ' . $this->_pdo->escapeString($this->_curPre['size']) . ', ' : '';
$query .= !empty($this->_curPre['source']) ? 'source = ' . $this->_pdo->escapeString($this->_curPre['source']) . ', ' : '';
$query .= !empty($this->_curPre['files']) ? 'files = ' . $this->_pdo->escapeString($this->_curPre['files']) . ', ' : '';
$query .= !empty($this->_curPre['reason']) ? 'nukereason = ' . $this->_pdo->escapeString($this->_curPre['reason']) . ', ' : '';
$query .= !empty($this->_curPre['reqid']) ? 'requestid = ' . $this->_curPre['reqid'] . ', ' : '';
$query .= !empty($this->_curPre['group_id']) ? 'groupid = ' . $this->_curPre['group_id'] . ', ' : '';
$query .= !empty($this->_curPre['predate']) ? 'predate = ' . $this->_curPre['predate'] . ', ' : '';
$query .= !empty($this->_curPre['nuked']) ? 'nuked = ' . $this->_curPre['nuked'] . ', ' : '';
$query .= !empty($this->_curPre['filename']) ? 'filename = ' . $this->_pdo->escapeString($this->_curPre['filename']) . ', ' : '';
$query .= empty($this->_oldPre['category']) && !empty($this->_curPre['category']) ? 'category = ' . $this->_pdo->escapeString($this->_curPre['category']) . ', ' : '';
if ($query === 'UPDATE prehash SET ') {
return;
}
$query .= 'title = ' . $this->_pdo->escapeString($this->_curPre['title']);
$query .= ' WHERE title = ' . $this->_pdo->escapeString($this->_curPre['title']);
$this->_pdo->ping(true);
$this->_pdo->queryExec($query);
$this->_doEcho(false);
}
示例2: createReleases
/**
* Create releases from complete binaries.
*
* @param int|string $groupID (optional)
*
* @return int
* @access public
*/
public function createReleases($groupID)
{
$startTime = time();
$group = $this->groups->getCBPTableNames($this->tablePerGroup, $groupID);
$page = new Page();
$this->pdo->log->doEcho($this->pdo->log->primary('Creating releases from complete binaries'));
$this->pdo->ping(true);
//
// Get out all distinct relname, group from binaries
//
$categorize = new \Categorize(['Settings' => $this->pdo]);
$returnCount = $duplicate = 0;
$result = $this->pdo->queryDirect(sprintf("SELECT %s.*, g.name AS group_name, count(%s.id) AS parts FROM %s INNER JOIN groups g ON g.id = %s.groupid WHERE %s procstat = %d AND relname IS NOT NULL GROUP BY relname, g.name, groupid, fromname ORDER BY COUNT(%s.id) DESC LIMIT %d", $group['bname'], $group['bname'], $group['bname'], $group['bname'], !empty($groupID) ? ' groupid = ' . $groupID . ' AND ' : ' ', Releases::PROCSTAT_READYTORELEASE, $group['bname'], $this->releaseCreationLimit));
while ($row = $this->pdo->getAssocArray($result)) {
$relguid = $this->createGUID();
// Clean release name
$releaseCleaning = new ReleaseCleaning();
$cleanRelName = $this->cleanReleaseName($row['relname']);
$cleanedName = $releaseCleaning->releaseCleaner($row['relname'], $row['fromname'], $row['group_name']);
if (is_array($cleanedName)) {
$properName = $cleanedName['properlynamed'];
$prehashID = isset($cleanerName['predb']) ? $cleanerName['predb'] : false;
$isReqID = isset($cleanerName['requestid']) ? $cleanerName['requestid'] : false;
$cleanedName = $cleanedName['cleansubject'];
} else {
$properName = true;
$isReqID = $prehashID = false;
}
if ($prehashID === false && $cleanedName !== '') {
// try to match the cleaned searchname to predb title or filename here
$preHash = new PreHash();
$preMatch = $preHash->matchPre($cleanedName);
if ($preMatch !== false) {
$cleanedName = $preMatch['title'];
$prehashID = $preMatch['prehashid'];
$properName = true;
}
}
$relid = $this->insertRelease(['name' => $this->pdo->escapeString($cleanRelName), 'searchname' => $this->pdo->escapeString(utf8_encode($cleanedName)), 'totalpart' => $row["parts"], 'groupid' => $row["groupid"], 'guid' => $this->pdo->escapeString($relguid), 'categoryid' => $categorize->determineCategory($groupID, $cleanedName), 'regexid' => $row["regexid"], 'postdate' => $this->pdo->escapeString($row['date']), 'fromname' => $this->pdo->escapeString($row['fromname']), 'reqid' => $row["reqid"], 'passwordstatus' => $page->settings->getSetting('checkpasswordedrar') > 0 ? -1 : 0, 'nzbstatus' => \Enzebe::NZB_NONE, 'isrenamed' => $properName === true ? 1 : 0, 'reqidstatus' => $isReqID === true ? 1 : 0, 'prehashid' => $prehashID === false ? 0 : $prehashID]);
//
// Tag every binary for this release with its parent release id
//
$this->pdo->queryExec(sprintf("UPDATE %s SET procstat = %d, releaseid = %d WHERE relname = %s AND procstat = %d AND %s fromname=%s", $group['bname'], Releases::PROCSTAT_RELEASED, $relid, $this->pdo->escapeString($row["relname"]), Releases::PROCSTAT_READYTORELEASE, !empty($groupID) ? ' groupid = ' . $groupID . ' AND ' : ' ', $this->pdo->escapeString($row["fromname"])));
$cat = new \Categorize(['Settings' => $this->pdo]);
//
// Write the nzb to disk
//
$catId = $cat->determineCategory($groupID, $cleanRelName);
$nzbfile = $this->nzb->getNZBPath($relguid, $page->settings->getSetting('nzbpath'), true);
$this->nzb->writeNZBforreleaseID($relid, $cleanRelName, $catId, $nzbfile, $groupID);
//
// Remove used binaries
//
$this->pdo->queryDelete(sprintf("DELETE %s, %s FROM %s JOIN %s ON %s.id = %s.binaryid WHERE releaseid = %d ", $group['pname'], $group['bname'], $group['pname'], $group['bname'], $group['bname'], $group['pname'], $relid));
//
// If nzb successfully written, then load it and get size completion from it
//
$nzbInfo = new NZBInfo();
if (!$nzbInfo->loadFromFile($nzbfile)) {
$this->pdo->log->doEcho($this->pdo->log->primary('Failed to write nzb file (bad perms?) ' . $nzbfile . ''));
$this->delete($relid);
} else {
// Check if gid already exists
$dupes = $this->pdo->queryOneRow(sprintf("SELECT EXISTS(SELECT 1 FROM releases WHERE gid = %s) AS total", $this->pdo->escapeString($nzbInfo->gid)));
if ($dupes['total'] > 0) {
$this->pdo->log->doEcho($this->pdo->log->primary('Duplicate - ' . $cleanRelName . ''));
$this->delete($relid);
$duplicate++;
} else {
$this->pdo->queryExec(sprintf("UPDATE releases SET totalpart = %d, size = %s, COMPLETION = %d, GID=%s , nzb_guid = %s WHERE id = %d", $nzbInfo->filecount, $nzbInfo->filesize, $nzbInfo->completion, $this->pdo->escapeString($nzbInfo->gid), $this->pdo->escapeString($nzbInfo->gid), $relid));
$this->pdo->log->doEcho($this->pdo->log->primary('Added release ' . $cleanRelName . ''));
$returnCount++;
if ($this->echoCLI) {
$this->pdo->log->doEcho($this->pdo->log->primary('Added ' . $returnCount . 'releases.'));
}
}
}
}
if ($this->echoCLI) {
$this->pdo->log->doEcho($this->pdo->log->primary(PHP_EOL . number_format($returnCount) . ' Releases added and ' . number_format($duplicate) . ' duplicate releases deleted in ' . $this->consoleTools->convertTime(time() - $startTime)), true);
}
return ['added' => $returnCount, 'dupes' => $duplicate];
}
示例3: COUNT
//totals per category in db, results by parentid
$catcntqry = "SELECT c.parentid AS parentid, COUNT(r.id) AS count FROM category c, releases r WHERE r.categoryid = c.id GROUP BY c.parentid";
//create timers and set to now
$runVar['timers']['timer1'] = $runVar['timers']['timer2'] = $runVar['timers']['timer3'] = $runVar['timers']['timer4'] = $runVar['timers']['timer5'] = time();
$runVar['timers']['query']['tmux_time'] = $runVar['timers']['query']['split_time'] = $runVar['timers']['query']['init_time'] = $runVar['timers']['query']['proc1_time'] = $runVar['timers']['query']['proc2_time'] = $runVar['timers']['query']['proc3_time'] = $runVar['timers']['query']['split1_time'] = $runVar['timers']['query']['init1_time'] = $runVar['timers']['query']['proc11_time'] = $runVar['timers']['query']['proc21_time'] = $runVar['timers']['query']['proc31_time'] = $runVar['timers']['query']['tpg_time'] = $runVar['timers']['query']['tpg1_time'] = 0;
// Analyze tables
printf($pdo->log->info("\nAnalyzing your tables to refresh your indexes."));
$pdo->optimise(false, 'analyze', false, ['releases']);
passthru('clear');
$runVar['settings']['monitor'] = 0;
$runVar['counts']['iterations'] = 1;
$runVar['modsettings']['fc']['firstrun'] = true;
$runVar['modsettings']['fc']['num'] = 0;
while ($runVar['counts']['iterations'] > 0) {
//check the db connection
if ($pdo->ping(true) == false) {
unset($pdo);
$pdo = new Settings();
}
$timer01 = time();
// These queries are very fast, run every loop -- tmux and site settings
$runVar['settings'] = $pdo->queryOneRow($tRun->getMonitorSettings(), false);
$runVar['timers']['query']['tmux_time'] = time() - $timer01;
$runVar['settings']['book_reqids'] = !empty($runVar['settings']['book_reqids']) ? $runVar['settings']['book_reqids'] : \Category::CAT_PARENT_BOOK;
//get usenet connection info
$runVar['connections'] = $tOut->getConnectionsInfo($runVar['constants']);
$runVar['modsettings']['clean'] = $runVar['settings']['post_non'] == 2 ? ' clean ' : ' ';
$runVar['constants']['pre_lim'] = $runVar['counts']['iterations'] > 1 ? '7' : '';
//assign scripts
$runVar['scripts']['releases'] = $runVar['constants']['tablepergroup'] == 0 ? "{$runVar['commands']['_php']} {$runVar['paths']['misc']}update_scripts/nix_scripts/tmux/bin/update_releases.php 1 false" : "{$runVar['commands']['_php']} {$runVar['paths']['misc']}update_scripts/nix_scripts/multiprocessing/releases.php";
switch ((int) $runVar['settings']['binaries_run']) {