本文整理匯總了PHP中nzedb\db\Settings::escapeString方法的典型用法代碼示例。如果您正苦於以下問題:PHP Settings::escapeString方法的具體用法?PHP Settings::escapeString怎麽用?PHP Settings::escapeString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類nzedb\db\Settings
的用法示例。
在下文中一共展示了Settings::escapeString方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: 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)
{
$rel = $this->pdo->queryOneRow(sprintf('
SELECT id, categoryid
FROM releases
WHERE guid = %s', $this->pdo->escapeString($guid)));
// Specifying LAST_INSERT_ID on releaseid will return the releaseid
// if the row was actually inserted and not updated
$insert = $this->pdo->queryInsert(sprintf('
INSERT INTO dnzb_failures (release_id, userid, failed)
VALUES (LAST_INSERT_ID(%d), %d, 1)
ON DUPLICATE KEY UPDATE failed = failed + 1', $rel['id'], $userid));
// If we didn't actually insert the row, don't add a comment
if ((int) $insert > 0) {
$this->postComment($rel['id'], $userid);
}
$alternate = $this->pdo->queryOneRow(sprintf('
SELECT r.*
FROM releases r
LEFT JOIN dnzb_failures df ON r.id = df.release_id
WHERE r.searchname %s
AND df.release_id IS NULL
AND r.categoryid = %d', $this->pdo->likeString($searchname, true, true), $rel['categoryid'], $userid));
return $alternate;
}
示例2: getAlternate
/**
* Retrieve alternate release with same or similar searchname
*
* @param string $guid
* @param string $userid
* @return string
*/
public function getAlternate($guid, $userid)
{
$rel = $this->pdo->queryOneRow(sprintf('
SELECT id, searchname, categoryid
FROM releases
WHERE guid = %s', $this->pdo->escapeString($guid)));
if ($rel === false) {
return false;
}
$insert = $this->pdo->queryInsert(sprintf('
INSERT IGNORE INTO dnzb_failures (release_id, userid, failed)
VALUES (%d, %d, 1)', $rel['id'], $userid));
// If we didn't actually insert the row, don't add a comment
if (is_numeric($insert) && $insert > 0) {
$this->postComment($rel['id'], $userid);
}
$alternate = $this->pdo->queryOneRow(sprintf('
SELECT r.guid
FROM releases r
LEFT JOIN dnzb_failures df ON r.id = df.release_id
WHERE r.searchname %s
AND df.release_id IS NULL
AND r.categoryid = %d
AND r.id != %d
ORDER BY r.postdate DESC', $this->pdo->likeString($rel['searchname'], true, true), $rel['categoryid'], $rel['id']));
return $alternate;
}
示例3: 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)
{
$this->pdo->queryInsert(sprintf("INSERT IGNORE INTO dnzb_failures (userid, guid) VALUES (%d, %s)", $userid, $this->pdo->escapeString($guid)));
$rel = $this->pdo->queryOneRow(sprintf('SELECT id FROM releases WHERE guid = %s', $this->pdo->escapeString($guid)));
$this->postComment($rel['id'], $userid);
$alternate = $this->pdo->queryOneRow(sprintf('SELECT * FROM releases r
WHERE r.searchname %s
AND r.guid NOT IN (SELECT guid FROM dnzb_failures WHERE userid = %d)', $this->pdo->likeString($searchname), $userid));
return $alternate;
}
示例4: 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)
{
$duplicateCheck = $this->pdo->queryOneRow(sprintf('
SELECT id
FROM release_files
WHERE releaseid = %d AND name = %s', $id, $this->pdo->escapeString(utf8_encode($name))));
if ($duplicateCheck === false) {
return $this->pdo->queryInsert(sprintf("\n\t\t\t\t\tINSERT INTO release_files\n\t\t\t\t\t(releaseid, name, size, createddate, passworded)\n\t\t\t\t\tVALUES\n\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 0;
}
示例5: addComment
public function addComment($id, $text, $userid, $host)
{
if ($this->pdo->getSetting('storeuserips') != "1") {
$host = "";
}
$username = $this->pdo->queryOneRow(sprintf('SELECT username FROM users WHERE id = %d', $userid));
$username = $username === false ? 'ANON' : $username['username'];
$comid = $this->pdo->queryInsert(sprintf("\n\t\t\t\tINSERT INTO release_comments (releaseid, text, user_id, createddate, host, username)\n\t\t\t\tVALUES (%d, %s, %d, NOW(), %s, %s)", $id, $this->pdo->escapeString($text), $userid, $this->pdo->escapeString($host), $this->pdo->escapeString($username)));
$this->updateReleaseCommentCount($id);
return $comid;
}
示例6: add
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));
}
return $this->pdo->queryInsert(sprintf("\n\t\t\t\tINSERT INTO forumpost (forumid, parentid, user_id, subject, message, locked, sticky, replies, createddate, updateddate)\n\t\t\t\tVALUES (1, %d, %d, %s, %s, %d, %d, %d, NOW(), NOW())", $parentid, $userid, $this->pdo->escapeString($subject), $this->pdo->escapeString($message), $locked, $sticky, $replies));
}
示例7: addBulk
/**
* Update the list of newsgroups and return an array of messages.
*
* @param string $groupList
* @param int $active
* @param int $backfill
*
* @return array
*/
public function addBulk($groupList, $active = 1, $backfill = 1)
{
if (preg_match('/^\\s*$/m', $groupList)) {
$ret = "No group list provided.";
} else {
$nntp = new NNTP(['Echo' => false]);
if ($nntp->doConnect() !== true) {
return 'Problem connecting to usenet.';
}
$groups = $nntp->getGroups();
$nntp->doQuit();
if ($nntp->isError($groups)) {
return 'Problem fetching groups from usenet.';
}
$regFilter = '/' . $groupList . '/i';
$ret = [];
foreach ($groups as $group) {
if (preg_match($regFilter, $group['group']) > 0) {
$res = $this->pdo->queryOneRow(sprintf('SELECT id FROM groups WHERE name = %s', $this->pdo->escapeString($group['group'])));
if ($res === false) {
$this->pdo->queryInsert(sprintf('INSERT INTO groups (name, active, backfill) VALUES (%s, %d, %d)', $this->pdo->escapeString($group['group']), $active, $backfill));
$ret[] = ['group' => $group['group'], 'msg' => 'Created'];
}
}
}
if (count($ret) === 0) {
$ret = 'No groups found with your regex, try again!';
}
}
return $ret;
}
示例8: addFull
public function addFull($id, $xml)
{
$ckid = $this->pdo->queryOneRow(sprintf('SELECT releaseid FROM releaseextrafull WHERE releaseid = %s', $id));
if (!isset($ckid['releaseid'])) {
return $this->pdo->queryExec(sprintf('INSERT INTO releaseextrafull (releaseid, mediainfo) VALUES (%d, %s)', $id, $this->pdo->escapeString($xml)));
}
}
示例9: insertGenre
/**
* Inserts Genre and returns last affected row (Genre ID)
*
* @param $genre
*
* @return bool
*/
private function insertGenre($genre)
{
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;
}
}
示例10: insertNewComment
/**
* Fetch a comment and insert it.
*
* @param string $messageID Message-ID for the article.
* @param string $siteID ID of the site.
*
* @return bool
*
* @access protected
*/
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;
}
// Insert the comment.
if ($this->pdo->queryExec(sprintf('
INSERT INTO release_comments
(text, createddate, shareid, nzb_guid, siteid, username, user_id, releaseid, shared, host)
VALUES (%s, %s, %s, UNHEX(%s), %s, %s, 0, 0, 2, "")', $this->pdo->escapeString($body['BODY']), $this->pdo->from_unixtime($body['TIME'] > time() ? time() : $body['TIME']), $this->pdo->escapeString($body['SID']), $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;
}
示例11: _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 integer $status
* @param integer $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));
}
}
示例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: _fetchRegex
/**
* Get the regex from the DB, cache them locally for 15 mins.
* Cache them also in the cache server, as this script might be terminated.
*
* @param string $groupName
*/
protected function _fetchRegex($groupName)
{
// Check if we need to do an initial cache or refresh our cache.
if (isset($this->_regexCache[$groupName]['ttl']) && time() - $this->_regexCache[$groupName]['ttl'] < 900) {
return;
}
// Get all regex from DB which match the current group name. Cache them for 15 minutes. #CACHEDQUERY#
$this->_regexCache[$groupName]['regex'] = $this->pdo->query(sprintf('SELECT r.regex%s FROM %s r WHERE %s REGEXP r.group_regex AND r.status = 1 ORDER BY r.ordinal ASC, r.group_regex ASC', $this->tableName === 'category_regexes' ? ', r.category_id' : '', $this->tableName, $this->pdo->escapeString($groupName)), true, 900);
// Set the TTL.
$this->_regexCache[$groupName]['ttl'] = time();
}
示例14: 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));
}
示例15: updateAniDBInfoEps
/**
* Updates existing anime info in anidb info/episodes tables
*
* @param array $AniDBInfoArray
*
* @return string
*/
private function updateAniDBInfoEps($AniDBInfoArray = [])
{
$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'];
}