本文整理汇总了PHP中sql_value函数的典型用法代码示例。如果您正苦于以下问题:PHP sql_value函数的具体用法?PHP sql_value怎么用?PHP sql_value使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sql_value函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: helppageurl
function helppageurl($ocpage)
{
global $opt;
$help_locale = $opt['template']['locale'];
$helppage = sql_value("SELECT `helppage` FROM `helppages`\n\t WHERE `ocpage`='&1' AND `language`='&2'", "", $ocpage, $help_locale);
if ($helppage == "") {
$helppage = sql_value("SELECT `helppage` FROM `helppages`\n\t\t WHERE `ocpage`='&1' AND `language`='*'", "", $ocpage);
}
if ($helppage == "") {
$helppage = sql_value("SELECT `helppage` FROM `helppages`\n\t\t WHERE `ocpage`='&1' AND `language`='&2'", "", $ocpage, $opt['template']['default']['fallback_locale']);
if ($helppage != "") {
$help_locale = $opt['template']['default']['fallback_locale'];
}
}
if ($helppage == "" && isset($opt['locale'][$opt['template']['locale']]['help'][$ocpage])) {
$helppage = $opt['locale'][$opt['template']['locale']]['help'][$ocpage];
}
if (substr($helppage, 0, 1) == "!") {
substr($helppage, 1);
} else {
if ($helppage != "" && isset($opt['locale'][$help_locale]['helpwiki'])) {
return $opt['locale'][$help_locale]['helpwiki'] . str_replace(' ', '_', $helppage);
} else {
return "";
}
}
}
示例2: CheckThrottle
function CheckThrottle()
{
global $opt, $tpl;
$ip_string = $_SERVER['REMOTE_ADDR'];
$ip_blocks = mb_split('\\.', $ip_string);
$ip_numeric = $ip_blocks[3] + $ip_blocks[2] * 256 + $ip_blocks[1] * 65536 + $ip_blocks[0] * 16777216;
sql('CREATE TABLE IF NOT EXISTS &tmpdb.`sys_accesslog`
(`id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, `ip` INT UNSIGNED NOT NULL,
`access_time` TIMESTAMP NOT NULL, INDEX (`access_time`), INDEX (`ip`)) ENGINE = MEMORY');
$rsStaus = sql("SHOW STATUS LIKE 'Threads_connected'");
$rStatus = sql_fetch_array($rsStaus);
sql_free_result($rsStaus);
if ($rStatus) {
if ($rStatus[1] > $opt['db']['throttle_connection_count']) {
$access_count = sql_value("SELECT COUNT(*) FROM &tmpdb.`sys_accesslog` WHERE ip ='&1'", 0, $ip_numeric);
if ($access_count > $opt['db']['throttle_access_count']) {
$tpl->error(ERROR_THROOTLE);
}
}
}
// remove old entries every 100st call
if (mt_rand(0, 100) == 50) {
sql("DELETE FROM &tmpdb.`sys_accesslog` WHERE `access_time`<CURRENT_TIMESTAMP()-'&2'", $ip_numeric, $opt['db']['throttle_access_time']);
}
sql("INSERT INTO &tmpdb.`sys_accesslog` (`ip`, `access_time`) VALUES ('&1', CURRENT_TIMESTAMP())", $ip_numeric);
}
示例3: showApproval
function showApproval($result)
{
$approval = sql_value("SELECT approval_status AS value FROM resource WHERE ref = {$result['ref']}", FALSE);
$approval_form_id = sql_value("SELECT ref AS value FROM resource_type_field WHERE name = 'approval_form'", FALSE);
if (!$approval_form_id) {
return;
}
$approval_form = TidyList(get_data_by_field($result['ref'], $approval_form_id));
if (empty($approval) and strpos($approval_form, 'Yes') !== FALSE) {
$approval = 'waiting';
}
if ($approval) {
switch ($approval) {
case 'waiting':
$title = 'Awaiting Approval';
break;
case 'minor':
$title = 'Minor Changes Needed';
break;
case 'major':
$title = 'Major Changes Needed';
break;
case 'approved':
$title = 'Approved';
break;
}
echo '<span class="rps-approval rps-approval-' . $approval . '" title="' . $title . '"></span>';
}
}
示例4: run
public function run()
{
// cleanup XML session data
sql_temp_table('tmpsessiondata');
sql('CREATE TEMPORARY TABLE &tmpsessiondata ENGINE=MEMORY
SELECT DISTINCT `xmlsession_data`.`session_id` FROM `xmlsession_data`
LEFT JOIN `xmlsession` ON `xmlsession`.`id`=`xmlsession_data`.`session_id`
WHERE `xmlsession`.`id` IS NULL');
$count = sql_value('SELECT COUNT(*) FROM `xmlsession_data`
WHERE `session_id` IN (SELECT `session_id` FROM &tmpsessiondata)', 0);
if ($count) {
sql("DELETE FROM `xmlsession_data`\n WHERE `session_id` IN (SELECT `session_id` FROM &tmpsessiondata)");
echo 'orphan_cleanup: dropped ' . $count . " record(s) from xmlsession_data\n";
}
sql_drop_temp_table('tmpsessiondata');
// cleanup map data
sql_temp_table('tmpsessiondata');
sql('CREATE TEMPORARY TABLE &tmpsessiondata ENGINE=MEMORY
SELECT DISTINCT `map2_data`.`result_id` FROM `map2_data`
LEFT JOIN `map2_result` ON `map2_result`.`result_id`=`map2_data`.`result_id`
WHERE `map2_result`.`result_id` IS NULL');
$count = sql_value("SELECT COUNT(*) FROM `map2_data`\n WHERE `result_id` IN (SELECT `result_id` FROM &tmpsessiondata)", 0);
if ($count) {
sql("DELETE FROM `map2_data`\n WHERE `result_id` IN (SELECT `result_id` FROM &tmpsessiondata)");
echo 'orphan_cleanup: dropped ' . $count . " record(s) from map2_data\n";
}
sql_drop_temp_table('tmpsessiondata');
}
示例5: cleanup_mapresult2
function cleanup_mapresult2($slaveId)
{
global $opt;
// cleanup old entries
$rs = sql("SELECT SQL_BUFFER_RESULT `result_id` FROM `map2_result` WHERE DATE_ADD(`date_created`, INTERVAL '&1' SECOND)<NOW()", $opt['map']['maxcacheage']);
while ($r = sql_fetch_assoc($rs)) {
sql("DELETE FROM `map2_result` WHERE `result_id`='&1'", $r['result_id']);
}
sql_free_result($rs);
// now reduce table size? (29 bytes is the average row size)
if (sql_value_slave("SELECT COUNT(*) FROM `map2_data`", 0) > $opt['map']['maxcachesize'] / 29) {
while (sql_value_slave("SELECT COUNT(*) FROM `map2_data`", 0) > $opt['map']['maxcachereducedsize'] / 29) {
$resultId = sql_value("SELECT `result_id` FROM `map2_result` WHERE `slave_id`='&1' ORDER BY `date_lastqueried` DESC LIMIT 1", 0, $slaveId);
if ($resultId == 0) {
return;
}
sql("DELETE FROM `map2_result` WHERE `result_id`='&1'", $resultId);
}
}
$nMinId = sql_value("SELECT MIN(`result_id`) FROM `map2_result`", 0);
if ($nMinId == 0) {
sql("DELETE FROM `map2_data`");
} else {
sql("DELETE FROM `map2_data` WHERE `result_id`<'&1'", $nMinId);
}
}
示例6: userMayModify
public function userMayModify($cacheid)
{
global $login;
$login->verify();
$cacheOwner = sql_value("SELECT `user_id` FROM `caches` WHERE `cache_id`=&1", -1, $cacheid);
return $cacheOwner == $login->userid;
}
示例7: HookAction_datesPagestoolscron_copy_hitcountAddplugincronjob
function HookAction_datesPagestoolscron_copy_hitcountAddplugincronjob()
{
global $lang, $action_dates_restrictfield, $action_dates_deletefield, $resource_deletion_state, $action_dates_reallydelete, $action_dates_email_admin_days, $email_notify, $email_from, $applicationname;
$allowable_fields = sql_array("select ref as value from resource_type_field where type in (4,6,10)");
# Check that this is a valid date field to use
if (in_array($action_dates_restrictfield, $allowable_fields)) {
$restrict_resources = sql_query("select resource, value from resource_data where resource_type_field = '{$action_dates_restrictfield}'");
$emailrefs = array();
foreach ($restrict_resources as $resource) {
$ref = $resource["resource"];
if ($action_dates_email_admin_days != "") {
$action_dates_email_admin_seconds = intval($action_dates_email_admin_days) * 60 * 60 * 24;
if (time() >= strtotime($resource["value"]) - $action_dates_email_admin_seconds && time() <= strtotime($resource["value"]) - $action_dates_email_admin_seconds + 86400) {
$emailrefs[] = $ref;
}
}
if (time() >= strtotime($resource["value"])) {
# Restrict access to the resource as date has been reached
$existing_access = sql_value("select access as value from resource where ref='{$ref}'", "");
if ($existing_access == 0) {
echo "restricting resource " . $ref . "\r\n";
sql_query("update resource set access=1 where ref='{$ref}'");
resource_log($ref, 'a', '', $lang['action_dates_restrict_logtext'], $existing_access, 1);
}
}
}
if (count($emailrefs) > 0) {
global $baseurl;
# Send email as the date is within the specified number of days
$subject = $lang['action_dates_email_subject'];
$message = str_replace("%%DAYS", $action_dates_email_admin_days, $lang['action_dates_email_text']) . "\r\n";
$message .= $baseurl . "?r=" . implode("\r\n" . $baseurl . "?r=", $emailrefs) . "\r\n";
$templatevars['message'] = $message;
echo "Sending email to " . $email_notify . "\r\n";
send_mail($email_notify, $subject, $message, $applicationname, $email_from, "emailexpiredresources", $templatevars, $applicationname);
}
}
if (in_array($action_dates_deletefield, $allowable_fields)) {
$delete_resources = sql_query("select resource, value from resource_data where resource_type_field = '{$action_dates_deletefield}'");
foreach ($delete_resources as $resource) {
$ref = $resource["resource"];
if (time() >= strtotime($resource["value"])) {
# Delete the resource as date has been reached
echo "deleting resource " . $ref . "\r\n";
if ($action_dates_reallydelete) {
delete_resource($ref);
} else {
if (!isset($resource_deletion_state)) {
$resource_deletion_state = 3;
}
sql_query("update resource set archive='" . $resource_deletion_state . "' where ref='" . $ref . "'");
}
# Remove the resource from any collections
sql_query("delete from collection_resource where resource='{$ref}'");
resource_log($ref, 'x', '', $lang['action_dates_delete_logtext']);
}
}
}
}
示例8: deactivate_plugin
/**
* Deactivate a named plugin.
*
* Blanks the inst_version field in the plugins database, which has the effect
* of deactivating the plugin while maintaining any configuration that is stored
* in the database.
*
* @param string $name Name of plugin to be deativated.
* @return bool Returns true if plugin is deactivated.
* @see activate_plugin
*/
function deactivate_plugin($name)
{
$inst_version = sql_value("SELECT inst_version as value FROM plugins WHERE name='{$name}'", '');
if ($inst_version >= 0) {
# Remove the version field. Leaving the rest of the plugin information. This allows for a config column to remain (future).
sql_query("UPDATE plugins set inst_version=NULL WHERE name='{$name}'");
}
}
示例9: run
function run()
{
global $opt;
$rsCache = sql("SELECT `caches`.`cache_id`, `caches`.`latitude`, `caches`.`longitude` FROM `caches` LEFT JOIN `cache_location` ON `caches`.`cache_id`=`cache_location`.`cache_id` WHERE ISNULL(`cache_location`.`cache_id`) UNION SELECT `caches`.`cache_id`, `caches`.`latitude`, `caches`.`longitude` FROM `caches` INNER JOIN `cache_location` ON `caches`.`cache_id`=`cache_location`.`cache_id` WHERE `caches`.`last_modified`>`cache_location`.`last_modified`");
while ($rCache = sql_fetch_assoc($rsCache)) {
$sCode = '';
$rsLayers = sql("SELECT `level`, `code`, AsText(`shape`) AS `geometry` FROM `nuts_layer` WHERE WITHIN(GeomFromText('&1'), `shape`) ORDER BY `level` DESC", 'POINT(' . $rCache['longitude'] . ' ' . $rCache['latitude'] . ')');
while ($rLayers = sql_fetch_assoc($rsLayers)) {
if (gis::ptInLineRing($rLayers['geometry'], 'POINT(' . $rCache['longitude'] . ' ' . $rCache['latitude'] . ')')) {
$sCode = $rLayers['code'];
break;
}
}
sql_free_result($rsLayers);
if ($sCode != '') {
$adm1 = null;
$code1 = null;
$adm2 = null;
$code2 = null;
$adm3 = null;
$code3 = null;
$adm4 = null;
$code4 = null;
if (mb_strlen($sCode) > 5) {
$sCode = mb_substr($sCode, 0, 5);
}
if (mb_strlen($sCode) == 5) {
$code4 = $sCode;
$adm4 = sql_value("SELECT `name` FROM `nuts_codes` WHERE `code`='&1'", null, $sCode);
$sCode = mb_substr($sCode, 0, 4);
}
if (mb_strlen($sCode) == 4) {
$code3 = $sCode;
$adm3 = sql_value("SELECT `name` FROM `nuts_codes` WHERE `code`='&1'", null, $sCode);
$sCode = mb_substr($sCode, 0, 3);
}
if (mb_strlen($sCode) == 3) {
$code2 = $sCode;
$adm2 = sql_value("SELECT `name` FROM `nuts_codes` WHERE `code`='&1'", null, $sCode);
$sCode = mb_substr($sCode, 0, 2);
}
if (mb_strlen($sCode) == 2) {
$code1 = $sCode;
// try to get localised name first
$adm1 = sql_value("SELECT IFNULL(`sys_trans_text`.`text`, `countries`.`name`)\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t FROM `countries`\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN `sys_trans` ON `countries`.`trans_id`=`sys_trans`.`id` AND `countries`.`name`=`sys_trans`.`text`\r\n\t\t\t\t\t\t\t\t\t\t\t\t\tLEFT JOIN `sys_trans_text` ON `sys_trans`.`id`=`sys_trans_text`.`trans_id` AND `sys_trans_text`.`lang`='&2'\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\tWHERE `countries`.`short`='&1'", null, $sCode, $opt['template']['default']['locale']);
if ($adm1 == null) {
$adm1 = sql_value("SELECT `name` FROM `nuts_codes` WHERE `code`='&1'", null, $sCode);
}
}
sql("INSERT INTO `cache_location` (`cache_id`, `adm1`, `adm2`, `adm3`, `adm4`, `code1`, `code2`, `code3`, `code4`) VALUES ('&1', '&2', '&3', '&4', '&5', '&6', '&7', '&8', '&9') ON DUPLICATE KEY UPDATE `adm1`='&2', `adm2`='&3', `adm3`='&4', `adm4`='&5', `code1`='&6', `code2`='&7', `code3`='&8', `code4`='&9'", $rCache['cache_id'], $adm1, $adm2, $adm3, $adm4, $code1, $code2, $code3, $code4);
} else {
$sCountry = sql_value("SELECT IFNULL(`sys_trans_text`.`text`, `countries`.`name`)\r\n\t\t\t\t FROM `caches` \r\n\t\t\t\t INNER JOIN `countries` ON `caches`.`country`=`countries`.`short`\r\n\t\t\t\t LEFT JOIN `sys_trans` ON `countries`.`trans_id`=`sys_trans`.`id` AND `countries`.`name`=`sys_trans`.`text`\r\n\t\t\t\t LEFT JOIN `sys_trans_text` ON `sys_trans`.`id`=`sys_trans_text`.`trans_id` AND `sys_trans_text`.`lang`='&2'\r\n\t\t\t\t WHERE `caches`.`cache_id`='&1'", null, $rCache['cache_id'], $opt['template']['default']['locale']);
$sCode1 = sql_value("SELECT `caches`.`country` FROM `caches` WHERE `caches`.`cache_id`='&1'", null, $rCache['cache_id']);
sql("INSERT INTO `cache_location` (`cache_id`, `adm1`, `code1`) VALUES ('&1', '&2', '&3') ON DUPLICATE KEY UPDATE `adm1`='&2', `adm2`=NULL, `adm3`=NULL, `adm4`=NULL, `code1`='&3', `code2`=NULL, `code3`=NULL, `code4`=NULL", $rCache['cache_id'], $sCountry, $sCode1);
}
}
sql_free_result($rsCache);
}
示例10: HookGrant_editAllCustomediteaccess
function HookGrant_editAllCustomediteaccess()
{
global $ref, $userref;
$access = sql_value("select resource value from grant_edit where resource='{$ref}' and user='{$userref}' and (expiry is null or expiry>=NOW())", "");
if ($access != "") {
return true;
}
return false;
}
示例11: HookGrant_editViewBeforepermissionscheck
function HookGrant_editViewBeforepermissionscheck()
{
global $ref, $userref, $access;
$grant_edit = sql_value("select resource value from grant_edit where resource='{$ref}' and user='{$userref}' and (expiry is null or expiry>=NOW())", "");
if ($grant_edit != "") {
$access = 0;
}
return true;
}
示例12: get_youtube_access_token
function get_youtube_access_token($refresh = false)
{
global $baseurl, $userref, $youtube_publish_client_id, $youtube_publish_client_secret, $youtube_publish_callback_url, $code;
$url = 'https://accounts.google.com/o/oauth2/token';
if ($refresh) {
$refresh_token = sql_value("select youtube_refresh_token as value from user where ref='{$userref}'", "");
if ($refresh_token == "") {
get_youtube_authorization_code();
exit;
}
$params = array("client_id" => $youtube_publish_client_id, "client_secret" => $youtube_publish_client_secret, "refresh_token" => $refresh_token, "grant_type" => "refresh_token");
} else {
$params = array("code" => $code, "client_id" => $youtube_publish_client_id, "client_secret" => $youtube_publish_client_secret, "redirect_uri" => $baseurl . $youtube_publish_callback_url, "grant_type" => "authorization_code");
}
$curl = curl_init("https://accounts.google.com/o/oauth2/token");
curl_setopt($curl, CURLOPT_HEADER, "Content-Type:application/x-www-form-urlencoded");
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $params);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 1);
$response = json_decode(curl_exec($curl), true);
curl_close($curl);
//exit (print_r($response));
if (isset($response["error"])) {
sql_query("update user set youtube_access_token='' where ref='{$userref}'");
//exit("ERROR: bad response" . print_r($response));
get_youtube_authorization_code();
exit;
}
if (isset($response["access_token"])) {
$access_token = escape_check($response["access_token"]);
sql_query("update user set youtube_access_token='{$access_token}' where ref='{$userref}'");
if (isset($response["refresh_token"])) {
$refresh_token = escape_check($response["refresh_token"]);
sql_query("update user set youtube_refresh_token='{$refresh_token}' where ref='{$userref}'");
}
debug("YouTube plugin: Access token: " . $access_token);
debug("YouTube plugin: Refresh token: " . $refresh_token);
}
# Get user account details and store these so we can tell which account they will be uploading to
$headers = array("Authorization: Bearer " . $access_token, "GData-Version: 2");
$curl = curl_init("https://gdata.youtube.com/feeds/api/users/default");
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_HTTPGET, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 1);
#$response = json_decode( curl_exec( $curl ), true );
$response = curl_exec($curl);
$userdataxml = new SimpleXmlElement($response, LIBXML_NOCDATA);
//exit(print_r($userdataxml));
$youtube_username = escape_check($userdataxml->title);
sql_query("update user set youtube_username='{$youtube_username}' where ref='{$userref}'");
return $access_token;
}
示例13: get_mapped_user_by_field
function get_mapped_user_by_field($id, $value)
{
$query = sprintf('
SELECT user_id AS value
FROM assign_request_map
WHERE field_id = \'%s\'
AND field_value = \'%s\';
', $id, $value);
return sql_value($query, 0);
}
示例14: HookDiscount_codePurchase_callbackPayment_complete
function HookDiscount_codePurchase_callbackPayment_complete()
{
# Find out the discount code applied to this collection.
$code = sql_value("select discount_code value from collection_resource where collection='" . getvalescaped("custom", "") . "' limit 1", "");
# Find out the purchasing user
# As this is a callback script being called by PayPal, there is no login/authentication and we can't therefore simply use $userref.
$user = sql_value("select ref value from user where current_collection='" . getvalescaped("custom", "") . "'", 0);
# Insert used discount code row
sql_query("insert into discount_code_used (code,user) values ('" . escape_check($code) . "','{$user}')");
}
示例15: getOptValue
public function getOptValue($pId)
{
if ($pId == USR_OPT_SHOWSTATS && sql_value("SELECT `is_active_flag` FROM `user` WHERE `user_id`='&1'", 0, $this->nUserId) == 0) {
// User profile options are deleted when an account is disabled. This will
// enable USR_OPT_SHOWSTATS which is 1 by default. We encounter this by
// forcing USR_OPT_SHOWSTATS = 0 for disabled users.
return 0;
} elseif (array_key_exists($pId, $this->nOptions)) {
return $this->nOptions[$pId]['option_value'];
}
return false;
}