本文整理汇总了PHP中newznab\db\Settings::escapeString方法的典型用法代码示例。如果您正苦于以下问题:PHP Settings::escapeString方法的具体用法?PHP Settings::escapeString怎么用?PHP Settings::escapeString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类newznab\db\Settings
的用法示例。
在下文中一共展示了Settings::escapeString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add
/**
* Add new files for a release ID.
*
* @param int $id The ID of the release.
* @param string $name Name of the file.
* @param int $size Size of the file.
* @param int $createdTime Unix time the file was created.
* @param int $hasPassword Does it have a password (see Releases class constants)?
*
* @return mixed
*/
public function add($id, $name, $size, $createdTime, $hasPassword)
{
$insert = 0;
$duplicateCheck = $this->pdo->queryOneRow(sprintf('
SELECT id
FROM releasefiles
WHERE releaseid = %d AND name = %s', $id, $this->pdo->escapeString(utf8_encode($name))));
if ($duplicateCheck === false) {
$insert = $this->pdo->queryInsert(sprintf("\n\t\t\t\t\t\tINSERT INTO releasefiles\n\t\t\t\t\t\t(releaseid, name, size, createddate, passworded)\n\t\t\t\t\t\tVALUES\n\t\t\t\t\t\t(%d, %s, %s, %s, %d)", $id, $this->pdo->escapeString(utf8_encode($name)), $this->pdo->escapeString($size), $this->pdo->from_unixtime($createdTime), $hasPassword));
}
return $insert;
}
示例2: add
/**
* Add a forum post.
*/
public function add($parentid, $userid, $subject, $message, $locked = 0, $sticky = 0, $replies = 0)
{
if ($message == "") {
return -1;
}
if ($parentid != 0) {
$par = $this->getParent($parentid);
if ($par == false) {
return -1;
}
$this->pdo->queryExec(sprintf("update forumpost set replies = replies + 1, updateddate = now() where id = %d", $parentid));
}
$this->pdo->queryInsert(sprintf("INSERT INTO forumpost (forumid, parentid, userid, subject, message, locked, sticky, replies, createddate, updateddate) VALUES ( 1, %d, %d, %s, %s, %d, %d, %d,NOW(), NOW())", $parentid, $userid, $this->pdo->escapeString($subject), $this->pdo->escapeString($message), $locked, $sticky, $replies));
}
示例3: getEpisodeInfoByName
/**
* Get an episodeinfo row by name.
*/
public function getEpisodeInfoByName($showtitle, $fullep, $epabsolute = '0')
{
$db = new Settings();
if ($epabsolute == '0') {
//as string - not int.
if (!preg_match('/[21]\\d{3}\\/\\d{2}\\/\\d{2}/', $fullep)) {
$additionalSql = sprintf('AND fullep = %s', $db->escapeString($fullep));
} else {
$additionalSql = sprintf('AND airdate LIKE %s', $db->escapeString($fullep . ' %'));
}
} else {
$additionalSql = sprintf('AND epabsolute = %s', $db->escapeString($epabsolute));
}
return $db->queryOneRow(sprintf('SELECT * FROM episodeinfo WHERE showtitle = %s %s', $db->escapeString($showtitle), $additionalSql));
}
示例4: updateMovie
public function updateMovie($uid, $imdbid, $catid = array())
{
$db = new Settings();
$catid = !empty($catid) ? $db->escapeString(implode('|', $catid)) : "null";
$sql = sprintf("update usermovies set categoryid = %s where userid = %d and imdbid = %d", $catid, $uid, $imdbid);
$db->queryExec($sql);
}
示例5: insertNewComment
/**
* Fetch a comment and insert it.
*
* @param string $messageID Message-ID for the article.
* @param string $siteID id of the site.
*
* @return bool
*/
protected function insertNewComment(&$messageID, &$siteID)
{
// Get the article body.
$body = $this->nntp->getMessages(self::group, $messageID);
// Check if there's an error.
if ($this->nntp->isError($body)) {
return false;
}
// Decompress the body.
$body = @gzinflate($body);
if ($body === false) {
return false;
}
// JSON Decode the body.
$body = json_decode($body, true);
if ($body === false) {
return false;
}
// Just in case.
if (!isset($body['USER']) || !isset($body['SID']) || !isset($body['RID']) || !isset($body['TIME']) | !isset($body['BODY'])) {
return false;
}
$cid = md5($body['SID'] . $body['USER'] . $body['TIME'] . $siteID);
// Insert the comment.
if ($this->pdo->queryExec(sprintf('
INSERT IGNORE INTO releasecomment
(text, createddate, issynced, shareid, cid, gid, nzb_guid, siteid, username, userid, releaseid, shared, host, sourceID)
VALUES (%s, %s, 1, %s, %s, %s, %s, %s, %s, 0, 0, 2, "", 999)', $this->pdo->escapeString($body['BODY']), $this->pdo->from_unixtime($body['TIME'] > time() ? time() : $body['TIME']), $this->pdo->escapeString($body['SID']), $this->pdo->escapeString($cid), $this->pdo->escapeString($body['RID']), $this->pdo->escapeString($body['RID']), $this->pdo->escapeString($siteID), $this->pdo->escapeString(substr($body['USER'], 0, 3) === 'sn-' ? 'SH_ANON' : 'SH_' . $body['USER'])))) {
return true;
}
return false;
}
示例6: insertGenre
/**
* Inserts Genre and returns last affected row (Genre id)
*
* @param $genre
*
* @return bool
*/
private function insertGenre($genre)
{
$res = '';
if (isset($genre)) {
$res = $this->pdo->queryInsert(sprintf("INSERT INTO genres (title, type, disabled) VALUES (%s ,%d ,%d)", $this->pdo->escapeString($genre), 6000, 0));
}
return $res;
}
示例7: addFull
public function addFull($id, $xml)
{
$row = $this->getFull($id);
if ($row) {
return -1;
}
return $this->pdo->queryInsert(sprintf("INSERT INTO releaseextrafull (releaseid, mediainfo) VALUES (%d, %s)", $id, $this->pdo->escapeString($xml)));
}
示例8: _getGroupID
/**
* Get a group id for a group name.
*
* @param string $groupName
*
* @return mixed
*
* @access protected
*/
protected function _getGroupID($groupName)
{
if (!isset($this->_groupList[$groupName])) {
$group = $this->_pdo->queryOneRow(sprintf('SELECT id FROM groups WHERE name = %s', $this->_pdo->escapeString($groupName)));
$this->_groupList[$groupName] = $group['id'];
}
return $this->_groupList[$groupName];
}
示例9: _updateSingleColumn
/** This function updates a single variable column in releases
* The first parameter is the column to update, the second is the value
* The final parameter is the id of the release to update
*
* @param string $column
* @param string|int $status
* @param int $id
**/
private function _updateSingleColumn($column = '', $status = 0, $id = 0)
{
if ($column !== '' && $id !== 0) {
$this->pdo->queryExec(sprintf('
UPDATE releases
SET %s = %s
WHERE id = %d', $column, is_numeric($status) ? $status : $this->pdo->escapeString($status), $id));
}
}
示例10: updateName
/**
* update a release name
*
* @param Settings $pdo
* @param $id
* @param $oldname
* @param $newname
*/
private function updateName(Settings $pdo, $id, $oldname, $newname)
{
if ($this->verbose) {
echo sprintf("OLD : %s\nNEW : %s\n\n", $oldname, $newname);
}
if (!$this->echoonly) {
$this->pdo->queryExec(sprintf("update releases set name=%s, searchname = %s WHERE id = %d", $this->pdo->escapeString($newname), $this->pdo->escapeString($newname), $id));
}
}
示例11: 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));
}
示例12: getAlternate
/**
* Retrieve alternate release with same or similar searchname
*
* @param string $guid
* @param string $searchname
* @param string $userid
* @return string
*/
public function getAlternate($guid, $searchname, $userid)
{
//status values
// 0/false = successfully downloaded
// 1/true = failed download
$this->pdo->queryInsert(sprintf("INSERT IGNORE INTO dnzb_failures (userid, guid) VALUES (%d, %s)", $userid, $this->pdo->escapeString($guid)));
$alternate = $this->pdo->queryOneRow(sprintf('SELECT * FROM releases r
WHERE r.searchname %s
AND r.guid NOT IN (SELECT guid FROM failed_downloads WHERE userid = %d)', $this->pdo->likeString($searchname), $userid));
return $alternate;
}
示例13: updateAniDBInfoEps
/**
* Updates existing anime info in anidb info/episodes tables
*
* @param array $AniDBInfoArray
*
* @return string
*/
private function updateAniDBInfoEps($AniDBInfoArray = array())
{
$this->pdo->queryExec(sprintf('
UPDATE anidb_info
SET type = %s, startdate = %s, enddate = %s, related = %s,
similar = %s, creators = %s, description = %s,
rating = %s, picture = %s, categories = %s, characters = %s,
updated = NOW()
WHERE anidbid = %d', $this->pdo->escapeString($AniDBInfoArray['type']), $this->pdo->escapeString($AniDBInfoArray['startdate']), $this->pdo->escapeString($AniDBInfoArray['enddate']), $this->pdo->escapeString($AniDBInfoArray['related']), $this->pdo->escapeString($AniDBInfoArray['similar']), $this->pdo->escapeString($AniDBInfoArray['creators']), $this->pdo->escapeString($AniDBInfoArray['description']), $this->pdo->escapeString($AniDBInfoArray['rating']), $this->pdo->escapeString($AniDBInfoArray['picture']), $this->pdo->escapeString($AniDBInfoArray['categories']), $this->pdo->escapeString($AniDBInfoArray['characters']), $this->anidbId));
$this->insertAniDBEpisodes($AniDBInfoArray['epsarr']);
return $AniDBInfoArray['picture'];
}
示例14: deleteRelease
/**
* Delete release from Sphinx RT tables.
* @param array $identifiers ['g' => Release GUID(mandatory), 'id' => ReleaseID(optional, pass false)]
* @param \newznab\db\Settings $pdo
*/
public function deleteRelease($identifiers, Settings $pdo)
{
if (!is_null($this->sphinxQL)) {
if ($identifiers['i'] === false) {
$identifiers['i'] = $pdo->queryOneRow(sprintf('SELECT id FROM releases WHERE guid = %s', $pdo->escapeString($identifiers['g'])));
if ($identifiers['i'] !== false) {
$identifiers['i'] = $identifiers['i']['id'];
}
}
if ($identifiers['i'] !== false) {
$this->sphinxQL->queryExec(sprintf('DELETE FROM releases_rt WHERE id = %d', $identifiers['i']));
}
}
}
示例15: proc_query
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;
}
}