本文整理汇总了PHP中sqlValue函数的典型用法代码示例。如果您正苦于以下问题:PHP sqlValue函数的具体用法?PHP sqlValue怎么用?PHP sqlValue使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sqlValue函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getLink
function getLink($table = '', $linkField = '', $pk = '', $id = '', $path = '')
{
if (!$id || !$table || !$linkField || !$pk) {
// default link to return
exit;
}
if (preg_match('/^Lookup: (.*?)::(.*?)::(.*?)$/', $path, $m)) {
$linkID = makeSafe(sqlValue("select `{$linkField}` from `{$table}` where `{$pk}`='{$id}'"));
$link = sqlValue("select `{$m[3]}` from `{$m[1]}` where `{$m[2]}`='{$linkID}'");
} else {
$link = sqlValue("select `{$linkField}` from `{$table}` where `{$pk}`='{$id}'");
}
if (!$link) {
exit;
}
if (preg_match('/^(http|ftp)/i', $link)) {
// if the link points to an external url, don't prepend path
$path = '';
} elseif (!is_file(dirname(__FILE__) . "/{$path}{$link}")) {
// if the file doesn't exist in the given path, try to find it without the path
$path = '';
}
@header("Location: {$path}{$link}");
exit;
}
示例2: smtp_mail
/**
* This hook function is called when send mail.
* @param $mail_info
* An array contains mail information : to,cc,bcc,subject,message
**/
function smtp_mail($mail_info)
{
/* include phpmailer library */
require dirname(__FILE__) . "/phpmailer/class.phpmailer.php";
require dirname(__FILE__) . "/phpmailer/class.smtp.php";
/* create mail_log table if it doesn't exist */
$database_tabels = str_split(sqlValue("SHOW TABLES"));
$exist = in_array('mail_log', $database_tabels) ? True : False;
if (!$exist) {
$sql = "CREATE TABLE IF NOT EXISTS `mail_log` (\r\n\t\t\t\t\t`mail_id` int(15) NOT NULL AUTO_INCREMENT,\r\n\t\t\t\t\t`to` varchar(225) NOT NULL,\r\n\t\t\t\t\t`cc` varchar(225) NOT NULL,\r\n\t\t\t\t\t`bcc` varchar(225) NOT NULL,\r\n\t\t\t\t\t`subject` varchar(225) NOT NULL,\r\n\t\t\t\t\t`body` text NOT NULL,\r\n\t\t\t\t\t`senttime` int(15) NOT NULL,\r\n\t\t\t\t\tPRIMARY KEY (`mail_id`)\r\n\t\t\t\t ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;\r\n\t\t\t\t ";
sql($sql, $eo);
}
/* SMTP configuration*/
$mail = new PHPMailer();
$mail->isSMTP();
// telling the class to use SMTP
$mail->SMTPAuth = true;
// Enable SMTP authentication
$mail->isHTML(true);
// Set email format to HTML
$mail->SMTPDebug = 0;
// Enable verbose debug output
$mail->Username = SMTP_USER;
// SMTP username
$mail->Password = SMTP_PASSWORD;
// SMTP password
$mail->SMTPSecure = SMTP_SECURE;
// Enable TLS encryption, `ssl` also accepted
$mail->Port = SMTP_PORT;
// TCP port to connect to
$mail->FromName = SMTP_FROM_NAME;
$mail->From = SMTP_FROM;
$mail->Host = SMTP_SERVER;
// SMTP server
$mail->setFrom(SMTP_FROM, SMTP_FROM_NAME);
/* send to */
$mail->addAddress($mail_info['to']);
$mail->addCC($mail_info['cc']);
$mail->addBCC(SMTP_BCC);
$mail->Subject = $mail_info['subject'];
$mail->Body = $mail_info['message'];
if (!$mail->send()) {
return FALSE;
}
/* protect against malicious SQL injection attacks */
$to = makeSafe($mail_info['to']);
$cc = makeSafe($mail_info['cc']);
$bcc = makeSafe(SMTP_BCC);
$subject = makeSafe($mail_info['subject']);
$message = makeSafe($mail_info['message']);
sql("INSERT INTO `mail_log` (`to`,`cc`,`bcc`,`subject`,`body`,`senttime`) VALUES ('{$to}','{$cc}','{$bcc}','{$subject}','{$message}',unix_timestamp(NOW()))", $eo);
return TRUE;
}
示例3: auth_user
function auth_user()
{
global $usr, $login;
$login->verify();
if ($login->userid != 0) {
//set up $usr array
$usr['userid'] = $login->userid;
$usr['email'] = sqlValue("SELECT `email` FROM `user` WHERE `user_id`='" . sql_escape($login->userid) . "'", '');
$usr['username'] = $login->username;
} else {
$usr = false;
}
return;
}
示例4: sqlValue
$statusCond = "(m.isApproved=1 and m.isBanned=0)";
break;
case 3:
$statusCond = "(m.isApproved=1 and m.isBanned=1)";
break;
default:
$statusCond = "";
}
if ($where != '' && $statusCond != '') {
$where .= " and {$statusCond}";
} else {
$where = "where {$statusCond}";
}
}
# NEXT: Add a dateAfter and dateBefore filter [??]
$numMembers = sqlValue("select count(1) from membership_users m left join membership_groups g on m.groupID=g.groupID {$where}");
if (!$numMembers) {
echo "<div class=\"status\">No matching results found.</div>";
$noResults = TRUE;
$page = 1;
} else {
$noResults = FALSE;
}
$page = intval($_GET['page']);
if ($page < 1) {
$page = 1;
} elseif ($page > ceil($numMembers / $adminConfig['membersPerPage']) && !$noResults) {
redirect("pageViewMembers.php?page=" . ceil($numMembers / $adminConfig['membersPerPage']));
}
$start = ($page - 1) * $adminConfig['membersPerPage'];
?>
示例5: tpl_set_var
}
if ($longitude == 0) {
tpl_set_var('lon_message', $error_long_not_ok);
$error = true;
$lon_min_not_ok = true;
}
} else {
tpl_set_var('lon_message', $error_long_not_ok);
$lon_h_not_ok = true;
$lon_min_not_ok = true;
}
$lon_not_ok = $lon_min_not_ok || $lon_h_not_ok;
$lat_not_ok = $lat_min_not_ok || $lat_h_not_ok;
// check for duplicate coords
if (!($lon_not_ok || $lat_not_ok)) {
$duplicate_wpoc = sqlValue("SELECT MIN(wp_oc) FROM `caches`\n\t\t\t\t\t\t WHERE `status`=1\n\t\t\t\t\t\t AND ROUND(`longitude`,6)=ROUND('" . sql_escape($longitude) . "',6)\n\t\t\t\t\t\t AND ROUND(`latitude`,6)=ROUND('" . sql_escape($latitude) . "',6)", null);
if ($duplicate_wpoc) {
tpl_set_var('lon_message', mb_ereg_replace('%1', $duplicate_wpoc, $error_duplicate_coords));
$lon_not_ok = true;
}
}
//check effort
$time_not_ok = true;
if (is_numeric($search_time) || $search_time == '') {
$time_not_ok = false;
}
if ($time_not_ok) {
tpl_set_var('effort_message', $time_not_ok_message);
$error = true;
}
$way_length_not_ok = true;
示例6: is_allowed_username
function is_allowed_username($username)
{
$username = trim(strtolower($username));
if (!preg_match('/^[a-z0-9][a-z0-9 _.@]{3,19}$/', $username) || preg_match('/(@@| |\\.\\.|___)/', $username)) {
return false;
}
if (sqlValue("select count(1) from membership_users where lcase(memberID)='{$username}'")) {
return false;
}
return $username;
}
示例7:
?>
<div class="row">
<div class="col-sm-6 col-lg-8" id="login_splash">
<!-- customized splash content here -->
</div>
<div class="col-sm-6 col-lg-4">
<div class="panel panel-success">
<div class="panel-heading">
<h1 class="panel-title"><strong><?php
echo $Translation['sign in here'];
?>
</strong></h1>
<?php
if (sqlValue("select count(1) from membership_groups where allowSignup=1")) {
?>
<a class="btn btn-success pull-right" href="membership_signup.php"><?php
echo $Translation['sign up'];
?>
</a>
<?php
}
?>
<div class="clearfix"></div>
</div>
<div class="panel-body">
<form method="post" action="index.php">
<div class="form-group">
<label class="control-label" for="username"><?php
示例8: LCASE
$permissionsWhere = $permissionsJoin = '';
if ($permChild[2] == 1) {
// user can view only his own records
$permissionsWhere = "`{$ChildTable}`.`{$userPCConfig[$ChildTable][$ChildLookupField]['child-primary-key']}`=`membership_userrecords`.`pkValue` AND `membership_userrecords`.`tableName`='{$ChildTable}' AND LCASE(`membership_userrecords`.`memberID`)='" . getLoggedMemberID() . "'";
} elseif ($permChild[2] == 2) {
// user can view only his group's records
$permissionsWhere = "`{$ChildTable}`.`{$userPCConfig[$ChildTable][$ChildLookupField]['child-primary-key']}`=`membership_userrecords`.`pkValue` AND `membership_userrecords`.`tableName`='{$ChildTable}' AND `membership_userrecords`.`groupID`='" . getLoggedGroupID() . "'";
} elseif ($permChild[2] == 3) {
// user can view all records
/* that's the only case remaining ... no need to modify the query in this case */
}
$permissionsJoin = $permissionsWhere ? ", `membership_userrecords`" : '';
// build the count query
$forcedWhere = $userPCConfig[$ChildTable][$ChildLookupField]['forced-where'];
$query = preg_replace('/^select .* from /i', 'SELECT count(1) FROM ', $userPCConfig[$ChildTable][$ChildLookupField]['query']) . $permissionsJoin . " WHERE " . ($permissionsWhere ? "( {$permissionsWhere} )" : "( 1=1 )") . " AND " . ($forcedWhere ? "( {$forcedWhere} )" : "( 2=2 )") . " AND " . "`{$ChildTable}`.`{$ChildLookupField}`='" . makeSafe($SelectedID) . "'";
$totalMatches = sqlValue($query);
// make sure $Page is <= max pages
$maxPage = ceil($totalMatches / $userPCConfig[$ChildTable][$ChildLookupField]['records-per-page']);
if ($Page > $maxPage) {
$Page = $maxPage;
}
// initiate output data array
$data = array('config' => $userPCConfig[$ChildTable][$ChildLookupField], 'parameters' => array('ChildTable' => $ChildTable, 'ChildLookupField' => $ChildLookupField, 'SelectedID' => $SelectedID, 'Page' => $Page, 'SortBy' => $SortBy, 'SortDirection' => $SortDirection, 'Operation' => 'get-records'), 'records' => array(), 'totalMatches' => $totalMatches);
// build the data query
if ($totalMatches) {
// if we have at least one record, proceed with fetching data
$startRecord = $userPCConfig[$ChildTable][$ChildLookupField]['records-per-page'] * ($Page - 1);
$data['query'] = $userPCConfig[$ChildTable][$ChildLookupField]['query'] . $permissionsJoin . " WHERE " . ($permissionsWhere ? "( {$permissionsWhere} )" : "( 1=1 )") . " AND " . ($forcedWhere ? "( {$forcedWhere} )" : "( 2=2 )") . " AND " . "`{$ChildTable}`.`{$ChildLookupField}`='" . makeSafe($SelectedID) . "'" . ($SortBy !== false && $userPCConfig[$ChildTable][$ChildLookupField]['sortable-fields'][$SortBy] ? " ORDER BY {$userPCConfig[$ChildTable][$ChildLookupField]['sortable-fields'][$SortBy]} {$SortDirection}" : '') . " LIMIT {$startRecord}, {$userPCConfig[$ChildTable][$ChildLookupField]['records-per-page']}";
$res = sql($data['query'], $eo);
while ($row = db_fetch_row($res)) {
$data['records'][$row[$userPCConfig[$ChildTable][$ChildLookupField]['child-primary-key-index']]] = $row;
示例9: create_uuid
}
$cache_uuid = create_uuid();
mysql_query("SET NAMES 'utf8'");
//add record to caches table
sql("INSERT INTO `caches` (\n `cache_id`,\n `user_id`,\n `name`,\n `longitude`,\n `latitude`,\n `last_modified`,\n `date_created`,\n `type` ,\n `status` ,\n `country` ,\n `date_hidden` ,\n `date_activate` ,\n `founds` ,\n `notfounds` ,\n `notes` ,\n `last_found` ,\n `size` ,\n `difficulty` ,\n `terrain`,\n `uuid`,\n `logpw`,\n `search_time`,\n `way_length`,\n `wp_gc`,\n `wp_nc`,\n `wp_ge`,\n `wp_tc`,\n `node`\n ) VALUES (\n '', '&1', '&2', '&3', '&4', NOW(), NOW(), '&5', '&6', '&7', '&8', {$activation_date}, '0', '0', '0', NULL ,\n '&9', '&10', '&11', '&12', '&13', '&14', '&15', '&16', '&17', '&18','&19','&20')", $usr['userid'], $name, $longitude, $latitude, $sel_type, $sel_status, $sel_country, date('Y-m-d', $hidden_date), $sel_size, $difficulty, $terrain, $cache_uuid, $log_pw, $search_time, $way_length, $wp_gc, $wp_nc, $wp_ge, $wp_tc, $oc_nodeid);
$cache_id = mysql_insert_id($dblink);
// insert cache_location
$code1 = $sel_country;
$adm1 = sqlvalue("SELECT `countries`.{$lang}\n FROM `countries`\n WHERE `countries`.`short`='{$code1}'", 0);
// check if selected country has no districts, then use $default_region
if ($sel_region == -1) {
$sel_region = $default_region;
}
if ($sel_region != "0") {
$code3 = $sel_region;
$adm3 = sqlValue("SELECT `name` FROM `nuts_codes` WHERE `code`='" . sql_escape($sel_region) . "'", 0);
} else {
$code3 = null;
$adm3 = null;
}
sql("INSERT INTO `cache_location` (cache_id,adm1,adm3,code1,code3) VALUES ('&1','&2','&3','&4','&5')", $cache_id, $adm1, $adm3, $code1, $code3);
// update cache last modified, it is for work of cache_locations update information
sql("UPDATE `caches` SET `last_modified`=NOW() WHERE `cache_id`='&1'", $cache_id);
// waypoint erstellen
setCacheWaypoint($cache_id, $oc_waypoint);
$desc_uuid = create_uuid();
//add record to cache_desc table
$desc = userInputFilter::purifyHtmlString($desc);
$query = "INSERT INTO `cache_desc` (\n `cache_id`,\n `language`,\n `desc`,\n `hint`,\n `short_desc`,\n `last_modified`,\n `uuid`,\n `node`\n ) VALUES (:1, :2, :3, :4, :5, NOW(), :6, :7)";
$db->multiVariableQuery($query, $cache_id, $sel_lang, $desc, nl2br(htmlspecialchars($hints, ENT_COMPAT, 'UTF-8')), $short_desc, $desc_uuid, $oc_nodeid);
setCacheDefaultDescLang($cache_id);
示例10: sqlValue
@mail($adminConfig['senderEmail'], '[real estate] New member signup', "A new member has signed up for real estate.\n\nMember name: {$memberID}\nMember group: " . sqlValue("select name from membership_groups where groupID='{$groupID}'") . "\nMember email: {$email}\nIP address: {$_SERVER['REMOTE_ADDR']}\nCustom fields:\n" . ($adminConfig['custom1'] ? "{$adminConfig['custom1']}: {$custom1}\n" : '') . ($adminConfig['custom2'] ? "{$adminConfig['custom2']}: {$custom2}\n" : '') . ($adminConfig['custom3'] ? "{$adminConfig['custom3']}: {$custom3}\n" : '') . ($adminConfig['custom4'] ? "{$adminConfig['custom4']}: {$custom4}\n" : ''), "From: {$adminConfig['senderEmail']}\r\n\r\n");
} elseif ($adminConfig['notifyAdminNewMembers'] >= 1 && $needsApproval) {
@mail($adminConfig['senderEmail'], '[real estate] New member awaiting approval', "A new member has signed up for real estate.\n\nMember name: {$memberID}\nMember group: " . sqlValue("select name from membership_groups where groupID='{$groupID}'") . "\nMember email: {$email}\nIP address: {$_SERVER['REMOTE_ADDR']}\nCustom fields:\n" . ($adminConfig['custom1'] ? "{$adminConfig['custom1']}: {$custom1}\n" : '') . ($adminConfig['custom2'] ? "{$adminConfig['custom2']}: {$custom2}\n" : '') . ($adminConfig['custom3'] ? "{$adminConfig['custom3']}: {$custom3}\n" : '') . ($adminConfig['custom4'] ? "{$adminConfig['custom4']}: {$custom4}\n" : ''), "From: {$adminConfig['senderEmail']}\r\n\r\n");
}
// hook: member_activity
if (function_exists('member_activity')) {
$args = array();
member_activity(getMemberInfo($memberID), $needsApproval ? 'pending' : 'automatic', $args);
}
// redirect to thanks page
$redirect = $needsApproval ? '' : '?redir=1';
redirect("membership_thankyou.php{$redirect}");
exit;
}
// drop-down of groups allowing self-signup
$groupsDropDown = preg_replace('/<option.*?value="".*?><\\/option>/i', '', htmlSQLSelect('groupID', "select groupID, concat(name, if(needsApproval=1, ' *', ' ')) from membership_groups where allowSignup=1 order by name", $cg == 1 ? sqlValue("select groupID from membership_groups where allowSignup=1 order by name limit 1") : 0));
$groupsDropDown = str_replace('<select ', '<select class="form-control" ', $groupsDropDown);
?>
<?php
if (!$noSignup) {
?>
<div class="row">
<div class="hidden-xs col-sm-4 col-md-6 col-lg-8" id="signup_splash">
<!-- customized splash content here -->
</div>
<div class="col-sm-8 col-md-6 col-lg-4">
<div class="panel panel-success">
<div class="panel-heading">
示例11: setlocale
<?php
global $lang, $rootpath;
if (!isset($rootpath)) {
$rootpath = './';
}
//include template handling
require_once $rootpath . 'lib/common.inc.php';
setlocale(LC_TIME, 'pl_PL.UTF-8');
$userscount = sqlValue('SELECT COUNT(DISTINCT user_id) FROM caches WHERE (status=1 OR `status`=2 OR `status`=3)', 0);
$cachescount = sqlValue('SELECT COUNT(*) FROM `caches` WHERE (`status`=1 OR `status`=2 OR `status`=3) AND `caches`.`type`<>6', 0);
echo '<table width="97%"><tr><td align="center"><center><b> ' . tr('ranking_by_number_of_created_caches') . '</b><br><br /> ' . tr('users_who_created_caches') . ':';
echo $userscount;
echo ' .::. ' . tr('number_of_caches') . ': ';
echo $cachescount;
echo '</center><br /></td></tr></table><table border="1" bgcolor="white" width="97%">' . "\n";
$r = sql("SELECT COUNT(*) `count`, `user`.`username` `username`, `user`.`user_id` `user_id` FROM `caches` INNER JOIN `user` ON `caches`.`user_id`=`user`.`user_id` WHERE (`caches`.`status`=1 OR `caches`.`status`=2 OR `caches`.`status`=3 ) AND `caches`.`type`<>6 AND user.stat_ban = 0 GROUP BY `user`.`user_id` ORDER BY `count` DESC, `user`.`username` ASC");
echo '<tr class="bgcolor2"><td align="right"> <b>' . tr('ranking') . '</b> </td><td align="center"> <b>' . tr('number_of_caches') . '</b> </td><td align="center"> <b>' . tr('username') . '</b> </td></tr>';
echo '<tr><td height="2">';
$l2 = "";
$licznik = 0;
while ($line = sql_fetch_array($r)) {
$l1 = $line[count];
$licznik++;
if ($l2 != $l1) {
echo '</td></tr>';
echo '<tr class="bgcolor2"><td align="right"> <b>' . $licznik . '</b> </td><td align="right"> <b>' . $l1 . '</b> </td><td><a href="viewprofile.php?userid=' . $line[user_id] . '">' . htmlspecialchars($line[username]) . '</a>';
$l2 = $l1;
} else {
echo ', <a href="viewprofile.php?userid=' . $line[user_id] . '">' . htmlspecialchars($line[username]) . '</a>';
}
示例12: sql
}
// add group
sql("insert into membership_groups set name='{$name}', description='{$description}', allowSignup='{$allowSignup}', needsApproval='{$needsApproval}'", $eo);
// get new groupID
$groupID = db_insert_id(db_link());
} else {
// old group
// validate groupID
$groupID = intval($_POST['groupID']);
if ($groupID == $anonGroupID) {
$name = $adminConfig['anonymousGroup'];
$allowSignup = 0;
$needsApproval = 0;
}
// make sure group name is unique
if (sqlValue("select count(1) from membership_groups where name='{$name}' and groupID!='{$groupID}'")) {
echo "<div class=\"alert alert-danger\">Error: Group name already exists. You must choose a unique group name.</div>";
include "{$currDir}/incFooter.php";
}
// update group
sql("update membership_groups set name='{$name}', description='{$description}', allowSignup='{$allowSignup}', needsApproval='{$needsApproval}' where groupID='{$groupID}'", $eo);
// reset then add group permissions
sql("delete from membership_grouppermissions where groupID='{$groupID}' and tableName='customers'", $eo);
sql("delete from membership_grouppermissions where groupID='{$groupID}' and tableName='employees'", $eo);
sql("delete from membership_grouppermissions where groupID='{$groupID}' and tableName='orders'", $eo);
sql("delete from membership_grouppermissions where groupID='{$groupID}' and tableName='order_details'", $eo);
sql("delete from membership_grouppermissions where groupID='{$groupID}' and tableName='products'", $eo);
sql("delete from membership_grouppermissions where groupID='{$groupID}' and tableName='categories'", $eo);
sql("delete from membership_grouppermissions where groupID='{$groupID}' and tableName='suppliers'", $eo);
sql("delete from membership_grouppermissions where groupID='{$groupID}' and tableName='shippers'", $eo);
}
示例13: sql
if ($oldMemberID != $memberID) {
sql("update membership_userrecords set memberID='{$memberID}' where lcase(memberID)='{$oldMemberID}'");
}
// is member was approved, notify him
if ($isApproved && !$oldIsApproved) {
notifyMemberApproval($memberID);
}
}
// redirect to member editing page
redirect("pageEditMember.php?memberID={$memberID}");
} elseif ($_GET['memberID'] != '') {
// we have an edit request for a member
$memberID = makeSafe(strtolower($_GET['memberID']));
} elseif ($_GET['groupID'] != '') {
$groupID = intval($_GET['groupID']);
$addend = " to '" . sqlValue("select name from membership_groups where groupID='{$groupID}'") . "'";
}
include "{$d}/incHeader.php";
if ($memberID != '') {
// fetch group data to fill in the form below
$res = sql("select * from membership_users where lcase(memberID)='{$memberID}'");
if ($row = mysql_fetch_assoc($res)) {
// get member data
$email = $row['email'];
$groupID = $row['groupID'];
$isApproved = $row['isApproved'];
$isBanned = $row['isBanned'];
$custom1 = htmlspecialchars($row['custom1']);
$custom2 = htmlspecialchars($row['custom2']);
$custom3 = htmlspecialchars($row['custom3']);
$custom4 = htmlspecialchars($row['custom4']);
示例14: patients_dv
/**
* Called when a user requests to view the detail view (before displaying the detail view).
*
* @param $selectedID
* The primary key value of the record selected. False if no record is selected (i.e. the detail view will be
* displayed to enter a new record).
*
* @param $memberInfo
* An array containing logged member's info.
* @see http://bigprof.com/appgini/help/working-with-generated-web-database-application/hooks/memberInfo
*
* @param $html
* (passed by reference) the HTML code of the form ready to be displayed. This could be useful for manipulating
* the code before displaying it using regular expressions, … etc.
*
* @param $args
* An empty array that is passed by reference. It's currently not used but is reserved for future uses.
*
* @return
* None.
*/
function patients_dv($selectedID, $memberInfo, &$html, &$args)
{
// re-calculate age
if ($selectedID) {
$dobTS = strtotime(sqlValue("select birth_date from patients where id='" . intval($selectedID) . "'"));
if ($dobTS) {
// calculate age in years from timestamps (seconds)
$age = floor((time() - $dobTS) / (365 * 86400));
// update age in database
sql("update patients set age={$age} where id='" . intval($selectedID) . "'");
// update age in page
$html .= "\n\n<script>document.observe('dom:loaded', function() { \$('age').value='{$age}'; });</script>";
}
}
}
示例15: sqlValue
$user_id = $usr['userid'];
$latitude = sqlValue("SELECT `latitude` FROM user WHERE user_id='" . sql_escape($usr['userid']) . "'", 0);
$longitude = sqlValue("SELECT `longitude` FROM user WHERE user_id='" . sql_escape($usr['userid']) . "'", 0);
tpl_set_var('userid', $user_id);
if ($longitude == NULL && $latitude == NULL || $longitude == 0 && $latitude == 0) {
tpl_set_var('info', '<br><div class="notice" style="line-height: 1.4em;font-size: 120%;"><b>' . tr("myn_info") . '</b></div><br>');
} else {
tpl_set_var('info', '');
}
if ($latitude == NULL || $latitude == 0) {
$latitude = 52.24522;
}
if ($longitude == NULL || $longitude == 0) {
$longitude = 21.00442;
}
$distance = sqlValue("SELECT `notify_radius` FROM user WHERE user_id='" . sql_escape($usr['userid']) . "'", 0);
if ($distance == 0) {
$distance = 35;
}
$distance_unit = 'km';
$radius = $distance;
//get the users home coords
$lat = $latitude;
$lon = $longitude;
$lon_rad = $lon * 3.14159 / 180;
$lat_rad = $lat * 3.14159 / 180;
//all target caches are between lat - max_lat_diff and lat + max_lat_diff
$max_lat_diff = $distance / 111.12;
//all target caches are between lon - max_lon_diff and lon + max_lon_diff
//TODO: check!!!
$max_lon_diff = $distance * 180 / (abs(sin((90 - $lat) * 3.14159 / 180)) * 6378 * 3.14159);