本文整理汇总了PHP中db_string函数的典型用法代码示例。如果您正苦于以下问题:PHP db_string函数的具体用法?PHP db_string怎么用?PHP db_string使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了db_string函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: num_compare
function num_compare($Field, $Operand, $Num1, $Num2 = '')
{
if ($Num1 != 0) {
$Num1 = db_string($Num1);
}
if ($Num2 != 0) {
$Num2 = db_string($Num2);
}
$Return = array();
switch ($Operand) {
case 'equal':
$Return[] = " {$Field} = '{$Num1}' ";
break;
case 'above':
$Return[] = " {$Field} > '{$Num1}' ";
break;
case 'below':
$Return[] = " {$Field} < '{$Num1}' ";
break;
case 'between':
$Return[] = " {$Field} > '{$Num1}' ";
$Return[] = " {$Field} < '{$Num2}' ";
break;
default:
print_r($Return);
die;
}
return $Return;
}
示例2: send
function send()
{
global $keystring, $login, $email;
$hash = md5('#RANDOM_PREFIX#' . mtime() . '#RANDOM_SEPARATOR#' . $login . '#WITH#' . $email . '#RANDOM_SUFFIX#');
if ($_SESSION['CAPTCHA_Keystring'] == '' || strtolower($keystring) != $_SESSION['CAPTCHA_Keystring']) {
add_info('Вы не прошли тест Тьюринга на подтверждение того, что вы не бот.');
return false;
}
$r = db_row_value('user', "(`login` =\"{$login}\") AND (`email`=\"{$email}\") AND (`authorized`=1)");
if ($r['id'] == '') {
add_info('Неверное сочетание login <-> email');
return false;
}
$s = unserialize($r['settings']);
if ($s['restore_timestamp'] && time() - $s['restore_timestamp'] < config_get('restore-timeout')) {
add_info('Вы не можете просить восстановку пароля так часто');
return false;
}
$s['restore_hash'] = $hash;
$s['restore_timestamp'] = time();
db_update('user', array('settings' => db_string(serialize($s))), '`id`=' . $r['id']);
$link = config_get('http-document-root') . '/login/restore/confirm/?id=' . $r['id'] . '&hash=' . $hash;
sendmail_tpl(stripslashes($email), 'Восстановление пароля в системе ' . config_get('site-name'), 'restore', array('login' => stripslashes($login), 'email' => stripslashes($email), 'link' => $link));
return true;
}
示例3: edit
/**
* Edit a comment
* @param int $PostID
* @param string $NewBody
* @param bool $SendPM If true, send a PM to the author of the comment informing him about the edit
* @todo move permission check out of here/remove hardcoded error(404)
*/
public static function edit($PostID, $NewBody, $SendPM = false)
{
$QueryID = G::$DB->get_query_id();
G::$DB->query("\n\t\t\tSELECT\n\t\t\t\tBody,\n\t\t\t\tAuthorID,\n\t\t\t\tPage,\n\t\t\t\tPageID,\n\t\t\t\tAddedTime\n\t\t\tFROM comments\n\t\t\tWHERE ID = {$PostID}");
if (!G::$DB->has_results()) {
return false;
}
list($OldBody, $AuthorID, $Page, $PageID, $AddedTime) = G::$DB->next_record();
if (G::$LoggedUser['ID'] != $AuthorID && !check_perms('site_moderate_forums')) {
return false;
}
G::$DB->query("\n\t\t\tSELECT CEIL(COUNT(ID) / " . TORRENT_COMMENTS_PER_PAGE . ") AS Page\n\t\t\tFROM comments\n\t\t\tWHERE Page = '{$Page}'\n\t\t\t\tAND PageID = {$PageID}\n\t\t\t\tAND ID <= {$PostID}");
list($CommPage) = G::$DB->next_record();
// Perform the update
G::$DB->query("\n\t\t\tUPDATE comments\n\t\t\tSET\n\t\t\t\tBody = '" . db_string($NewBody) . "',\n\t\t\t\tEditedUserID = " . G::$LoggedUser['ID'] . ",\n\t\t\t\tEditedTime = '" . sqltime() . "'\n\t\t\tWHERE ID = {$PostID}");
// Update the cache
$CatalogueID = floor((TORRENT_COMMENTS_PER_PAGE * $CommPage - TORRENT_COMMENTS_PER_PAGE) / THREAD_CATALOGUE);
G::$Cache->delete_value($Page . '_comments_' . $PageID . '_catalogue_' . $CatalogueID);
if ($Page == 'collages') {
// On collages, we also need to clear the collage key (collage_$CollageID), because it has the comments in it... (why??)
G::$Cache->delete_value('collage_' . $PageID);
}
G::$DB->query("\n\t\t\tINSERT INTO comments_edits (Page, PostID, EditUser, EditTime, Body)\n\t\t\tVALUES ('{$Page}', {$PostID}, " . G::$LoggedUser['ID'] . ", '" . sqltime() . "', '" . db_string($OldBody) . "')");
G::$DB->set_query_id($QueryID);
if ($SendPM && G::$LoggedUser['ID'] != $AuthorID) {
// Send a PM to the user to notify them of the edit
$PMSubject = "Your comment #{$PostID} has been edited";
$PMurl = site_url() . "comments.php?action=jump&postid={$PostID}";
$ProfLink = '[url=' . site_url() . 'user.php?id=' . G::$LoggedUser['ID'] . ']' . G::$LoggedUser['Username'] . '[/url]';
$PMBody = "One of your comments has been edited by {$ProfLink}: [url]{$PMurl}[/url]";
Misc::send_pm($AuthorID, 0, $PMSubject, $PMBody);
}
return true;
// TODO: this should reflect whether or not the update was actually successful, e.g. by checking G::$DB->affected_rows after the UPDATE query
}
示例4: update_sphinx_requests
/**
* Update the sphinx requests delta table for a request.
*
* @param $RequestID
*/
public static function update_sphinx_requests($RequestID)
{
$QueryID = G::$DB->get_query_id();
G::$DB->query("\n\t\t\tSELECT REPLACE(t.Name, '.', '_')\n\t\t\tFROM tags AS t\n\t\t\t\tJOIN requests_tags AS rt ON t.ID = rt.TagID\n\t\t\tWHERE rt.RequestID = {$RequestID}");
$TagList = G::$DB->collect(0, false);
$TagList = db_string(implode(' ', $TagList));
G::$DB->query("\n\t\t\tREPLACE INTO sphinx_requests_delta (\n\t\t\t\tID, UserID, TimeAdded, LastVote, CategoryID, Title, TagList,\n\t\t\t\tYear, ReleaseType, CatalogueNumber, RecordLabel, BitrateList,\n\t\t\t\tFormatList, MediaList, LogCue, FillerID, TorrentID,\n\t\t\t\tTimeFilled, Visible, Votes, Bounty)\n\t\t\tSELECT\n\t\t\t\tID, r.UserID, UNIX_TIMESTAMP(TimeAdded) AS TimeAdded,\n\t\t\t\tUNIX_TIMESTAMP(LastVote) AS LastVote, CategoryID, Title, '{$TagList}',\n\t\t\t\tYear, ReleaseType, CatalogueNumber, RecordLabel, BitrateList,\n\t\t\t\tFormatList, MediaList, LogCue, FillerID, TorrentID,\n\t\t\t\tUNIX_TIMESTAMP(TimeFilled) AS TimeFilled, Visible,\n\t\t\t\tCOUNT(rv.UserID) AS Votes, SUM(rv.Bounty) >> 10 AS Bounty\n\t\t\tFROM requests AS r\n\t\t\t\tLEFT JOIN requests_votes AS rv ON rv.RequestID = r.ID\n\t\t\tWHERE ID = {$RequestID}\n\t\t\tGROUP BY r.ID");
G::$DB->query("\n\t\t\tUPDATE sphinx_requests_delta\n\t\t\tSET ArtistList = (\n\t\t\t\t\tSELECT GROUP_CONCAT(aa.Name SEPARATOR ' ')\n\t\t\t\t\tFROM requests_artists AS ra\n\t\t\t\t\t\tJOIN artists_alias AS aa ON aa.AliasID = ra.AliasID\n\t\t\t\t\tWHERE ra.RequestID = {$RequestID}\n\t\t\t\t\tGROUP BY NULL\n\t\t\t\t\t)\n\t\t\tWHERE ID = {$RequestID}");
G::$DB->set_query_id($QueryID);
G::$Cache->delete_value("request_{$RequestID}");
}
示例5: getSiteOption
/**
* Get a site option
*
* @param string $Name The option name
* @param string $DefaultValue The value to default to if the name can't be found in the cache
*/
public static function getSiteOption($Name, $DefaultValue)
{
$Value = G::$Cache->get_value('site_option_' . $Name);
if ($Value === false) {
G::$DB->query("SELECT Value FROM site_options WHERE Name = '" . db_string($Name) . "'");
if (G::$DB->has_results()) {
list($Value) = G::$DB->next_record();
G::$Cache->cache_value('site_option_' . $Name, $Value);
}
}
return $Value === false ? $DefaultValue : $Value;
}
示例6: unlock_account
/**
* Unlock an account
*
* @param int $UserID The ID of the user to unlock
* @param int $Type The lock type, should be a constant value. Used for database verification
* to avoid deleting the wrong lock type
* @param string $Reason The reason for unlock
* @param int $UnlockedByUserID The ID of the staff member unlocking $UserID's account. 0 for system
*/
public static function unlock_account($UserID, $Type, $Message, $Reason, $UnlockedByUserID)
{
if ($UnlockedByUserID == 0) {
$Username = "System";
} else {
G::$DB->query("SELECT Username FROM users_main WHERE ID = '" . $UnlockedByUserID . "'");
list($Username) = G::$DB->next_record();
}
G::$DB->query("DELETE FROM locked_accounts WHERE UserID = '{$UserID}' AND Type = '" . $Type . "'");
if (G::$DB->affected_rows() == 1) {
G::$Cache->delete_value("user_info_" . $UserID);
Tools::update_user_notes($UserID, sqltime() . " - " . db_string($Message) . " by {$Username}\nReason: " . db_string($Reason) . "\n\n");
}
}
示例7: WT_PutChecker
function WT_PutChecker()
{
global $id, $err, $desc;
if (!WT_IPC_CheckLogin()) {
return;
}
if ($id == '') {
print 'Void filename for WT_PutChecker()';
return;
}
$data = db_row_value('tester_checkers', "`id`={$id}");
$s = unserialize($data['settings']);
$s['ERR'] = $err;
$s['DESC'] = $desc;
db_update('tester_checkers', array('uploaded' => 'TRUE', 'settings' => db_string(serialize($s))), "`id`={$id}");
}
示例8: build_search
function build_search($SearchStr,$Field,$Exact=false,$SQLWhere='',$FullText=0,&$FilterString='') {
if($SQLWhere!='') { $AddWhere=false; } else { $AddWhere=true; }
if(!$Exact) {
if ($FullText && preg_match('/[^a-zA-Z0-9 ]/i',$SearchStr)) { $FullText=0; }
$SearchLength=strlen(trim($SearchStr));
$SearchStr=preg_replace('/\s\s+/',' ',trim($SearchStr));
$SearchStr=preg_replace_callback('/"(([^"])*)"/','quotes',$SearchStr);
$SearchStr=explode(" ",$SearchStr);
$FilterString="(.+?)";
foreach($SearchStr as $SearchVal) {
if(trim($SearchVal)!='') {
$SearchVal=trim($SearchVal);
$SearchVal=str_replace("{{SPACE}}"," ",$SearchVal);
// Choose between fulltext or LIKE based off length of the string
if ($FullText && strlen($SearchVal)>2) {
if($SQLWhere!='') { $SQLWhere.=" AND "; }
if (substr($SearchVal,0,1)=='-') {
$SQLWhere.="MATCH (".$Field.") AGAINST ('".db_string($SearchVal)."' IN BOOLEAN MODE)";
} else {
$SQLWhere.="MATCH (".$Field.") AGAINST ('".db_string($SearchVal)."')";
}
} else {
if($SQLWhere!='') { $SQLWhere.=" AND "; }
if (substr($SearchVal,0,1)=="-") {
$SQLWhere.=$Field." NOT LIKE '%".db_string(substr($SearchVal,1))."%'";
} else {
$SQLWhere.=$Field." LIKE '%".db_string($SearchVal)."%'";
}
}
$FilterString.="(".$SearchVal.")(.+?)";
}
}
} else {
if($SQLWhere!='') { $SQLWhere.=" AND "; }
$SQLWhere.=$Field." LIKE '".db_string($SearchStr)."'";
$FilterString.="(.+?)(".$SearchStr.")(.+?)";
}
$Search = 1;
$FilterString="/".$FilterString."/si";
if($SQLWhere!='' && $AddWhere) { $SQLWhere="WHERE ".$SQLWhere; }
return $SQLWhere;
}
示例9: create_personal_collage
public static function create_personal_collage()
{
G::$DB->query("\n\t\t\tSELECT\n\t\t\t\tCOUNT(ID)\n\t\t\tFROM collages\n\t\t\tWHERE UserID = '" . G::$LoggedUser['ID'] . "'\n\t\t\t\tAND CategoryID = '0'\n\t\t\t\tAND Deleted = '0'");
list($CollageCount) = G::$DB->next_record();
if ($CollageCount >= G::$LoggedUser['Permissions']['MaxCollages']) {
// TODO: fix this, the query was for COUNT(ID), so I highly doubt that this works... - Y
list($CollageID) = G::$DB->next_record();
header('Location: collage.php?id=' . $CollageID);
die;
}
$NameStr = db_string(G::$LoggedUser['Username'] . "'s personal collage" . ($CollageCount > 0 ? ' no. ' . ($CollageCount + 1) : ''));
$Description = db_string('Personal collage for ' . G::$LoggedUser['Username'] . '. The first 5 albums will appear on his or her [url=' . site_url() . 'user.php?id= ' . G::$LoggedUser['ID'] . ']profile[/url].');
G::$DB->query("\n\t\t\tINSERT INTO collages\n\t\t\t\t(Name, Description, CategoryID, UserID)\n\t\t\tVALUES\n\t\t\t\t('{$NameStr}', '{$Description}', '0', " . G::$LoggedUser['ID'] . ")");
$CollageID = G::$DB->inserted_id();
header('Location: collage.php?id=' . $CollageID);
die;
}
示例10: update_event
public static function update_event($ID, $Title, $Body, $Category, $Importance, $Team, $StartDate, $EndDate = null)
{
if (!is_number($ID) || empty($Title) || empty($Body) || !is_number($Category) || !is_number($Importance) || !is_number($Team) || empty($StartDate)) {
error("Error updating event");
}
$ID = (int) $ID;
$Title = db_string($Title);
$Body = db_string($Body);
$Category = (int) $Category;
$Importance = (int) $Importance;
$Team = (int) $Team;
$StartDate = db_string($StartDate);
$EndDate = db_string($EndDate);
$QueryID = G::$DB->get_query_id();
G::$DB->query("\n\t\t\t\t\t\tUPDATE calendar\n\t\t\t\t\t\tSET\n\t\t\t\t\t\t\tTitle = '{$Title}',\n\t\t\t\t\t\t\tBody = '{$Body}',\n\t\t\t\t\t\t\tCategory = '{$Category}',\n\t\t\t\t\t\t\tImportance = '{$Importance}',\n\t\t\t\t\t\t\tTeam = '{$Team}',\n\t\t\t\t\t\t\tStartDate = '{$StartDate}',\n\t\t\t\t\t\t\tEndDate = '{$EndDate}'\n\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\tID = '{$ID}'");
G::$DB->set_query_id($QueryID);
}
示例11: btc_address
function btc_address($UserID, $GenAddress = false)
{
global $DB;
$UserID = (int) $UserID;
$DB->query("\n\t\tSELECT BitcoinAddress\n\t\tFROM users_info\n\t\tWHERE UserID = '{$UserID}'");
list($Addr) = $DB->next_record();
if (!empty($Addr)) {
return $Addr;
} elseif ($GenAddress) {
if (empty($NewAddr)) {
error(0);
}
$DB->query("\n\t\t\tUPDATE users_info\n\t\t\tSET BitcoinAddress = '" . db_string($NewAddr) . "'\n\t\t\tWHERE UserID = '{$UserID}'\n\t\t\t\tAND BitcoinAddress IS NULL");
return $NewAddr;
} else {
return false;
}
}
示例12: WT_PutSolution
function WT_PutSolution()
{
global $id, $lid, $ERRORS, $POINTS, $XPFS;
$optional_params = array('REPORT');
$update_params = array('COMPILER_MESSAGES', 'TESTS');
if (!WT_IPC_CheckLogin()) {
return;
}
if (!isset($id) || !isset($lid)) {
print 'Void filename for WT_PutSOlution';
return;
}
$r = db_row_value('tester_solutions', "`id`={$id} AND `lid`={$lid}");
$p = unserialize($r['parameters']);
for ($i = 0; $i < count($update_params); $i++) {
if (isset($_POST[$update_params[$i]])) {
$p[$update_params[$i]] = stripslashes($_POST[$update_params[$i]]);
}
}
if ($POINTS == '') {
$POINTS = 0;
}
$n = count($optional_params);
for ($i = 0; $i < $n; $i++) {
$p[$optional_params[$i]] = stripslashes($GLOBALS[$optional_params[$i]]);
}
unset($p['force_status']);
$data = array();
if (isset($_POST['SOLUTION_OUTPUT'])) {
$data['outputs'] = stripslashes($_POST['SOLUTION_OUTPUT']);
}
if (isset($_POST['CHECKER_OUTPUT'])) {
$data['checker_outputs'] = stripslashes($_POST['CHECKER_OUTPUT']);
}
if (count($data) > 0) {
$path = '/tester/testing/';
$XPFS->CreateDirWithParents($path);
$XPFS->removeItem($path . '/' . $id);
$XPFS->createFile($path, $id, 0, db_pack($data));
}
db_update('tester_solutions', array('status' => 2, 'points' => $POINTS, 'errors' => db_string($ERRORS), 'parameters' => db_string(serialize($p))), "`id`={$id} AND `lid`={$lid}");
}
示例13: WT_PutProblem
function WT_PutProblem()
{
global $id, $lid, $err, $desc;
if (!WT_IPC_CheckLogin()) {
return;
}
if ($id == '') {
print 'Void filename for WT_PutProblem()';
return;
}
if ($lid == '') {
print 'Void library identifier for WT_PutProblem()';
return;
}
$data = db_row_value('tester_problems', "(`id`={$id}) AND (`lid`={$lid})");
$s = unserialize($data['settings']);
$s['ERR'] = $err;
$s['DESC'] = $desc;
unset($s['filename']);
db_update('tester_problems', array('uploaded' => $err != 'OK' ? 1 : 2, 'settings' => db_string(serialize($s))), "(`id`={$id}) AND (`lid`={$lid})");
}
示例14: reset_image
function reset_image($UserID, $Type, $AdminComment, $PrivMessage)
{
if ($Type === 'avatar') {
$CacheKey = "user_info_{$UserID}";
$DBTable = 'users_info';
$DBColumn = 'Avatar';
$PMSubject = 'Your avatar has been automatically reset';
} elseif ($Type === 'avatar2') {
$CacheKey = "donor_info_{$UserID}";
$DBTable = 'donor_rewards';
$DBColumn = 'SecondAvatar';
$PMSubject = 'Your second avatar has been automatically reset';
} elseif ($Type === 'donoricon') {
$CacheKey = "donor_info_{$UserID}";
$DBTable = 'donor_rewards';
$DBColumn = 'CustomIcon';
$PMSubject = 'Your donor icon has been automatically reset';
}
$UserInfo = G::$Cache->get_value($CacheKey, true);
if ($UserInfo !== false) {
if ($UserInfo[$DBColumn] === '') {
// This image has already been reset
return;
}
$UserInfo[$DBColumn] = '';
G::$Cache->cache_value($CacheKey, $UserInfo, 2592000);
// cache for 30 days
}
// reset the avatar or donor icon URL
G::$DB->query("\n\t\tUPDATE {$DBTable}\n\t\tSET {$DBColumn} = ''\n\t\tWHERE UserID = '{$UserID}'");
// write comment to staff notes
G::$DB->query("\n\t\tUPDATE users_info\n\t\tSET AdminComment = CONCAT('" . sqltime() . ' - ' . db_string($AdminComment) . "\n\n', AdminComment)\n\t\tWHERE UserID = '{$UserID}'");
// clear cache keys
G::$Cache->delete_value($CacheKey);
Misc::send_pm($UserID, 0, $PMSubject, $PrivMessage);
}
示例15: get_address
/**
* Get a user's existing bitcoin address or generate a new one
*
* @param int $UserID
* @param bool $GenAddress whether to create a new address if it doesn't exist
* @return false if no address exists and $GenAddress is false
* string bitcoin address otherwise
*/
public static function get_address($UserID, $GenAddress = false)
{
$UserID = (int) $UserID;
$QueryID = G::$DB->get_query_id();
G::$DB->query("\n\t\t\tSELECT BitcoinAddress\n\t\t\tFROM users_info\n\t\t\tWHERE UserID = '{$UserID}'");
list($Addr) = G::$DB->next_record();
G::$DB->set_query_id($QueryID);
if (!empty($Addr)) {
return $Addr;
} elseif ($GenAddress) {
if (defined('BITCOIN_RPC_URL')) {
$NewAddr = BitcoinRpc::getnewaddress();
}
if (empty($NewAddr)) {
error(0);
}
$QueryID = G::$DB->get_query_id();
G::$DB->query("\n\t\t\t\tUPDATE users_info\n\t\t\t\tSET BitcoinAddress = '" . db_string($NewAddr) . "'\n\t\t\t\tWHERE UserID = '{$UserID}'\n\t\t\t\t\tAND BitcoinAddress IS NULL");
G::$DB->set_query_id($QueryID);
return $NewAddr;
} else {
return false;
}
}