本文整理汇总了PHP中Utils\Database\XDb类的典型用法代码示例。如果您正苦于以下问题:PHP XDb类的具体用法?PHP XDb怎么用?PHP XDb使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了XDb类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: landkreisFromLocid
function landkreisFromLocid($locid)
{
if (!is_numeric($locid)) {
return '';
}
return XDb::xMultiVariableQueryValue("SELECT `rb`.`text_val` `regierungsbezirk`\n FROM `geodb_textdata` `ct`, `geodb_textdata` `rb`, `geodb_hierarchies` `hr`\n WHERE `ct`.`loc_id`=`hr`.`loc_id`\n AND `hr`.`id_lvl5`=`rb`.`loc_id`\n AND `ct`.`text_type`=500100000\n AND `rb`.`text_type`=500100000\n AND `ct`.`loc_id`= :1\n AND `hr`.`id_lvl5`!=0", 0, $locid);
}
示例2: isGeokretInCache
function isGeokretInCache($cacheid)
{
$res = XDb::xSql("SELECT wp_oc, wp_gc, wp_nc, wp_ge, wp_tc\n FROM caches WHERE cache_id = ? LIMIT 1", $cacheid);
$cache_record = XDb::xFetchArray($res);
// get cache waypoint
$cache_wp = '';
if ($cache_record['wp_oc'] != '') {
$cache_wp = $cache_record['wp_oc'];
} else {
if ($cache_record['wp_gc'] != '') {
$cache_wp = $cache_record['wp_gc'];
} else {
if ($cache_record['wp_nc'] != '') {
$cache_wp = $cache_record['wp_nc'];
} else {
if ($cache_record['wp_ge'] != '') {
$cache_wp = $cache_record['wp_ge'];
} else {
if ($cache_record['wp_tc'] != '') {
$cache_wp = $cache_record['wp_tc'];
}
}
}
}
}
$gkNum = XDb::xMultiVariableQueryValue("SELECT COUNT(*) FROM gk_item\n WHERE id IN (\n SELECT id FROM gk_item_waypoint\n WHERE wp = :1\n )\n AND stateid<>1 AND stateid<>4\n AND stateid <>5 AND typeid<>2", 0, $cache_wp);
if ($gkNum == 0) {
return 0;
} else {
return 1;
}
}
示例3: get_cache_size_from_database
function get_cache_size_from_database()
{
$cache_size = array();
$resp = XDb::xSql("SELECT * FROM cache_size ORDER BY id ASC");
while ($row = XDb::xFetchArray($resp)) {
$cache_size[] = $row;
}
return $cache_size;
}
示例4: run
function run()
{
$sql = "delete from CACHE_ACCESS_LOGS where date_sub(now(), INTERVAL 5 DAY) > event_date";
set_time_limit(360);
$s = XDb::xSql($sql);
$total_deleted = XDb::xNumRows($s);
set_time_limit(60);
unset($db);
echo "total_deleted={$total_deleted}\n";
}
示例5: online_user
function online_user()
{
// add check users id who want to by username hidden
$rs = XDb::xSql("SELECT `user_id` FROM `sys_sessions`\n WHERE user_id!=1 AND `sys_sessions`.last_login >(NOW()-INTERVAL 10 MINUTE)\n GROUP BY `user_id`");
$online_users = array();
while ($r = XDb::xFetchArray($rs)) {
$online_users[] = $r['user_id'];
}
return $online_users;
}
示例6: find_news
function find_news($start, $end)
{
global $tpl;
global $lang;
global $znalezione;
$wp = XDb::xEscape($_GET['wp']);
$query = "select id,type,user_id,date,text,deleted from cache_logs where cache_id = (select cache_id from caches where wp_oc = '" . $wp . "') order by date desc limit " . $start . "," . $end;
$wynik = XDb::xSql($query);
$query = "select name,cache_id from caches where cache_id = (select cache_id from caches where wp_oc = '" . $wp . "');";
$wynik2 = XDb::xSql($query);
$caches = XDb::xFetchArray($wynik2);
$tpl->assign("name", $caches['name']);
// detailed cache access logging
global $enable_cache_access_logs;
if (@$enable_cache_access_logs) {
$dbc = OcDb::instance();
$cache_id = $caches['cache_id'];
$user_id = @$_SESSION['user_id'] > 0 ? $_SESSION['user_id'] : null;
$access_log = @$_SESSION['CACHE_ACCESS_LOG_VL_' . $user_id];
if ($access_log === null) {
$_SESSION['CACHE_ACCESS_LOG_VL_' . $user_id] = array();
$access_log = $_SESSION['CACHE_ACCESS_LOG_VL_' . $user_id];
}
if (@$access_log[$cache_id] !== true) {
$dbc->multiVariableQuery('INSERT INTO CACHE_ACCESS_LOGS
(event_date, cache_id, user_id, source, event, ip_addr, user_agent, forwarded_for)
VALUES
(NOW(), :1, :2, \'M\', \'view_logs\', :3, :4, :5)', $cache_id, $user_id, $_SERVER['REMOTE_ADDR'], $_SERVER['HTTP_USER_AGENT'], $_SERVER['HTTP_X_FORWARDED_FOR']);
$access_log[$cache_id] = true;
$_SESSION['CACHE_ACCESS_LOG_VL_' . $user_id] = $access_log;
}
}
$znalezione = array();
while ($logs = XDb::xFetchArray($wynik)) {
if ($logs['deleted'] == 0) {
$query = "select username from user where user_id = '" . $logs['user_id'] . "';";
$wynik3 = XDb::xSql($query);
$user = XDb::xFetchArray($wynik3);
$logs2['id'] = $logs['id'];
$logs2['user_id'] = $logs['user_id'];
$logs2['newtype'] = $logs['type'];
$logs2['newdate'] = date('j.m.Y', strtotime($logs['date']));
$logs2['username'] = $user[0];
$logs2['newtext'] = html2log($logs['text']);
$znalezione[] = $logs2;
}
}
$tpl->assign("wp_oc", $wp);
$tpl->assign("logs", $znalezione);
}
示例7: find_news
function find_news($start, $end)
{
global $tpl;
$query = "SELECT id,date_posted,content FROM `news` order by id desc limit " . $start . "," . $end;
$wynik = XDb::xSql($query);
$ile = XDb::xNumRows($wynik);
$znalezione = array();
while ($odp2 = XDb::xFetchArray($wynik)) {
$odp['date_posted'] = $odp2['date_posted'];
//$odp['content']=strip_tags($odp2['content'],'<b></b><p></p><a></a><br><br/>');
$odp['content'] = html2desc($odp2['content']);
$znalezione[] = $odp;
}
$tpl->assign('news', $znalezione);
return $ile;
}
示例8: array
function find_news($start, $end)
{
global $lang;
global $ile;
global $url;
global $znalezione;
$query = "select cache_id from cache_watches where user_id=" . $_SESSION['user_id'] . " limit " . $start . "," . $end;
$wynik = XDb::xSql($query);
$ile2 = XDb::xNumRows($wynik);
if ($ile2 > 0) {
$znalezione = array();
while ($rek = XDb::xFetchArray($wynik)) {
$query = "select status,cache_id,name, score, latitude, longitude, wp_oc, user_id, type from caches where cache_id=" . $rek['cache_id'] . " order by name";
$wynik2 = XDb::xSql($query);
while ($rekord = XDb::xFetchArray($wynik2)) {
if (isset($_SESSION['user_id'])) {
$query2 = "select 1 from cache_logs where user_id = '" . $_SESSION['user_id'] . "' and type = '1' and deleted='0' and cache_id ='" . $rekord['cache_id'] . "';";
$wynik2 = XDb::xSql($query2);
$if_found = XDb::xFetchArray($wynik2);
if ($if_found[0] != '1') {
$query2 = "select 2 from cache_logs where user_id = '" . $_SESSION['user_id'] . "' and type = '2' and deleted='0' and cache_id ='" . $rekord['cache_id'] . "';";
$wynik2 = XDb::xSql($query2);
$if_found = XDb::xFetchArray($wynik2);
}
$if_found = $if_found[0];
}
$query = "select username from user where user_id = " . $rekord['user_id'] . ";";
$wynik2 = XDb::xSql($query);
$wiersz = XDb::xFetchArray($wynik2);
$query = "select " . $lang . " from cache_type where id = " . $rekord['type'] . ";";
$wynik2 = XDb::xSql($query);
$wiersz2 = XDb::xFetchArray($wynik2);
$rekord['if_found'] = $if_found;
$rekord['username'] = $wiersz['username'];
$rekord['N'] = cords($rekord['latitude']);
$rekord['E'] = cords($rekord['longitude']);
$rekord['typetext'] = $wiersz2[0];
$znalezione[] = $rekord;
}
}
}
}
示例9: genStatPieUrl
function genStatPieUrl()
{
$startDate = mktime(0, 0, 0, 1, 1, 2006);
global $lang;
if (checkField('cache_type', $lang)) {
$lang_db = XDb::xEscape($lang);
} else {
$lang_db = "en";
}
// Get data
$rsTypes = XDb::xSql("SELECT COUNT(`caches`.`type`) `count`, `cache_type`.`{$lang_db}` AS `type`, `cache_type`.`color`\n FROM `caches` INNER JOIN `cache_type` ON (`caches`.`type`=`cache_type`.`id`)\n WHERE `status`=1\n GROUP BY `caches`.`type`\n ORDER BY `count` DESC");
$yData = array();
$xData = array();
$colors = array();
$url = "http://chart.apis.google.com/chart?chs=550x200&chd=t:";
$sum = 0;
while ($rTypes = XDb::xFetchArray($rsTypes)) {
$yData[] = ' (' . $rTypes['count'] . ') ' . $rTypes['type'];
$xData[] = $rTypes['count'];
$colors[] = substr($rTypes['color'], 1);
$sum += $rTypes['count'];
}
XDb::xFreeResults($rsTypes);
foreach ($xData as $count) {
$url .= normTo100($count, $sum) . ",";
}
$url = substr($url, 0, -1);
$url .= "&cht=p3&chl=";
foreach ($yData as $label) {
$url .= urlencode($label) . "|";
}
$url = substr($url, 0, -1);
$url .= "&chco=";
foreach ($colors as $color) {
$url .= urlencode($color) . ",";
}
return $url = substr($url, 0, -1);
}
示例10: getDBFilter
/**
* Reads user map settings from the DB
* @param int $user_id - user identifier
*/
function getDBFilter($user_id)
{
global $MIN_SCORE, $MAX_SCORE, $powerTrailModuleSwitchOn;
// defined in settings.inc/php
$filter = array("h_u" => 1, "h_t" => 1, "h_m" => 1, "h_v" => 1, "h_w" => 1, "h_e" => 1, "h_q" => 1, "h_o" => 1, "h_owncache" => 1, "h_ignored" => 0, "h_own" => 1, "h_found" => 1, "h_noattempt" => 1, "h_nogeokret" => 1, "h_avail" => 0, "h_temp_unavail" => 1, "map_type" => 1, "h_arch" => 0, "be_ftf" => 0, "powertrail_only" => 0, "min_score" => $MIN_SCORE, "max_score" => $MAX_SCORE, "h_noscore" => 1);
// default filter
$query = XDb::xSql("SELECT * FROM map_settings WHERE `user_id`= ? LIMIT 1", $user_id);
while ($row = XDb::xFetchArray($query)) {
$filter["h_u"] = $row['unknown'];
$filter["h_t"] = $row['traditional'];
$filter["h_m"] = $row['multicache'];
$filter["h_v"] = $row['virtual'];
$filter["h_w"] = $row['webcam'];
$filter["h_e"] = $row['event'];
$filter["h_q"] = $row['quiz'];
$filter["h_o"] = $row['mobile'];
$filter["h_owncache"] = $row['owncache'];
$filter["h_ignored"] = $row['ignored'];
$filter["h_own"] = $row['own'];
$filter["h_found"] = $row['found'];
$filter["h_noattempt"] = $row['notyetfound'];
$filter["h_nogeokret"] = $row['geokret'];
$filter["h_avail"] = $row['active'];
$filter["h_temp_unavail"] = $row['notactive'];
$filter["map_type"] = $row['maptype'];
$filter["h_arch"] = $row['archived'];
$filter["be_ftf"] = $row['be_ftf'];
if ($powerTrailModuleSwitchOn) {
$filter["powertrail_only"] = $row['powertrail_only'];
}
$filter["min_score"] = $row['min_score'];
$filter["max_score"] = $row['max_score'];
$filter["h_noscore"] = $row['noscore'];
}
return $filter;
}
示例11: event_notify_new_cache
function event_notify_new_cache($cache_id)
{
global $rootpath;
//prepare the templates and include all neccessary
require_once $rootpath . 'lib/search.inc.php';
$rs = XDb::xSql('SELECT `caches`.`latitude`, `caches`.`longitude`
FROM `caches`
WHERE `caches`.`cache_id`= ? ', $cache_id);
$r = XDb::xFetchArray($rs);
$latFrom = $r['latitude'];
$lonFrom = $r['longitude'];
XDb::xFreeResults($rs);
$distanceMultiplier = 1;
// TODO: Seeking pre-select `user`. `latitude` like with max_lon / min_lon / max_lat / min_lat
XDb::xSql('INSERT INTO `notify_waiting` (`id`, `cache_id`, `user_id`, `type`)
SELECT NULL, ' . XDb::xEscape($cache_id) . ', `user`.`user_id`, ' . NOTIFY_NEW_CACHES . '
FROM `user`
WHERE NOT ISNULL(`user`.`latitude`)
AND NOT ISNULL(`user`.`longitude`)
AND `user`.`notify_radius` > 0
AND (acos(cos((90- ? ) * 3.14159 / 180) * cos((90-`user`.`latitude`) * 3.14159 / 180) +
sin((90-?) * 3.14159 / 180) * sin((90-`user`.`latitude`) * 3.14159 / 180) * cos(( ? -`user`.`longitude`) *
3.14159 / 180)) * 6370 * ?) <= `user`.`notify_radius`', $latFrom, $latFrom, $lonFrom, $distanceMultiplier);
}
示例12: COUNT
) AS `t`', 0);
$rsfCR = XDb::xSql("SELECT COUNT(*) `count`, `cache_location`.`adm3` region, `cache_location`.`code3` code_region\n FROM `cache_location`\n INNER JOIN cache_logs ON cache_location.cache_id=cache_logs.cache_id\n WHERE `cache_location`.`code1`='PL'\n AND (cache_logs.type='1' OR cache_logs.type='2')\n AND cache_logs.deleted='0'\n GROUP BY `cache_location`.`code3`\n ORDER BY count DESC");
echo '<table width="97%"><tr><td align="center"><center><b> ' . tr('Stats_t7_01') . '</b> <br /><br /> ' . tr('Stats_t7_02') . ':<b> ';
echo $fCt["count"];
echo ' </b><br />' . tr('Stats_t7_03') . ':<b> ';
echo $r['users'];
echo '</b><br /><br />(' . tr('Stats_t7_04') . ')</center></td></tr></table><br><table border="1" bgcolor="white" width="97%">' . "\n";
echo '
<tr class="bgcolor2">
<td width="20%">
<center><b>' . tr('Stats_t7_05') . '</b></center>
</td>
<td align="right">
<b>' . tr('Stats_t7_06') . '</b>
</td>
</tr><tr><td height="2"></td></tr>';
while ($line = XDb::xFetchArray($rsfCR)) {
echo '<tr class="bgcolor2">
<td align="right">
<b>' . $line["count"] . '</b>
</td>
<td align="right">
<b><a class=links href=articles.php?page=s10®ion=' . $line['code_region'] . '>' . $line['region'] . '</a></b>
</td>';
}
echo '</table>' . "\n";
XDb::xFreeResults($rsfCR);
$result = ob_get_clean();
apc_store($cache_key, $result, 86400);
}
print $result;
示例13: tr
if (!isset($rootpath)) {
$rootpath = './';
}
//include template handling
require_once $rootpath . 'lib/common.inc.php';
setlocale(LC_TIME, 'pl_PL.UTF-8');
echo '<table width="97%"><tr><td align="center"><center><b>' . tr('Stats_t5_01') . '</b><br /><br />' . tr('Stats_t5_02') . ': (z% - <b><font color="green">X</font>/<font color="blue">Y</font></b>) X- ' . tr('Stats_t5_03') . ', Y - ' . tr('Stats_t5_04') . ', <br /> z - ' . tr('Stats_t5_05') . ' % ' . tr('Stats_t5_06') . ' (X/Y)*100<br /><br /></center></td></tr> </table>';
echo '<table border="1" bgcolor="white" width="97%" style="font-size:11px; line-height:1.6em;">' . "\n";
$linie = XDb::xSql("SELECT count(*) count, user.username username, user.user_id user_id\n FROM caches, cache_rating, user\n WHERE `cache_rating`.`cache_id`=caches.cache_id\n AND caches.user_id=user.user_id\n AND caches.type <> 6\n GROUP BY `user`.`user_id`\n ORDER BY `count` DESC, `user`.`username` ASC");
echo '<tr><td class="bgcolor2" align="right"><b>' . tr('Stats_t5_07') . '</b> </td><td class="bgcolor2" align="center"><img src="images/rating-star.png" border="0" alt="Recommendations" /> <b>' . tr('Stats_t5_08') . '</b> </td><td class="bgcolor2" align="center"><b>' . tr('Stats_t5_09') . '</b> </td></tr><tr><td>';
$l2 = "";
$licznik = 0;
while ($linia = XDb::xFetchArray($linie)) {
$l1 = $linia['count'];
$x = XDb::xMultiVariableQueryValue("SELECT COUNT(*) FROM caches\n WHERE `caches`.`topratings` >= 1\n AND caches.type <> 6\n AND caches.user_id= :1 ", 0, $linia['user_id']);
$y = XDb::xMultiVariableQueryValue("SELECT COUNT(*) FROM caches\n WHERE user_id= :1\n AND status <> 4 AND status <> 5\n AND status <> 6 AND type <> 6", 0, $linia['user_id']);
if ($y != 0) {
$xy = sprintf("%.u", $x / $y * 100);
} else {
$xy = 0;
}
if ($l2 != $l1) {
$licznik++;
echo "</td></tr><tr><td class=\"bgcolor2\" align=\"right\"> <b>{$licznik}</b> </td><td class=\"bgcolor2\" align=\"right\"> <b>{$l1}</b> </td>";
echo "<td class=\"bgcolor2\"><a class=\"links\" href=\"viewprofile.php?userid=" . $linia['user_id'] . "\">" . htmlspecialchars($linia['username']) . " (<font color=\"firebrick\">{$xy}% - </font><font color=\"green\">{$x}</font>/<font color=\"blue\">{$y}</font>)</a>";
$l2 = $l1;
} else {
echo ", <a class=\"links\" href=\"viewprofile.php?userid=" . $linia['user_id'] . "\">" . htmlspecialchars($linia['username']) . " (<font color=\"firebrick\">{$xy}% - </font><font color=\"green\">{$x}</font>/<font color=\"blue\">{$y}</font>)</a>";
}
}
echo '</td></tr></table>' . "\n";
示例14: intval
}
}
if ($total_pages >= $startat + $PAGES_LISTED) {
$pages .= '<a href="my_logs.php?userid=' . $user_id . '&start=' . ($i - 1) * $LOGS_PER_PAGE . '">{last_img}</a> ';
} else {
$pages .= '{last_img_inactive}';
}
$rs = XDb::xSql("SELECT `cache_logs`.`id`\n FROM `cache_logs`, `caches`\n WHERE `cache_logs`.`cache_id`=`caches`.`cache_id`\n AND `cache_logs`.`deleted`=0\n AND `caches`.`status` != 4\n AND `caches`.`status` != 5\n AND `caches`.`status` != 6\n AND `cache_logs`.`user_id`= ?\n ORDER BY `cache_logs`.`date_created` DESC\n LIMIT " . intval($start) . ", " . intval($LOGS_PER_PAGE), $user_id);
$log_ids = array();
while ($record = XDb::xFetchArray($rs)) {
$log_ids[] = $record['id'];
}
XDb::xFreeResults($rs);
$rs = XDb::xSql("SELECT cache_logs.id, cache_logs.cache_id AS cache_id, cache_logs.type AS log_type, cache_logs.date AS log_date,\n cache_logs.text AS log_text, `cache_logs`.`encrypt` AS `encrypt`, caches.user_id AS cache_owner,\n caches.name AS cache_name, user.username AS user_name, cache_logs.user_id AS luser_id,\n caches.wp_oc AS wp_name, caches.type AS cache_type, cache_type.icon_small AS cache_icon_small,\n log_types.icon_small AS icon_small,\n IF(ISNULL(`cache_rating`.`cache_id`), 0, 1) AS `recommended`,COUNT(gk_item.id) AS geokret_in\n FROM ((cache_logs INNER JOIN caches ON (caches.cache_id = cache_logs.cache_id)))\n INNER JOIN user ON (cache_logs.user_id = user.user_id)\n INNER JOIN log_types ON (cache_logs.type = log_types.id)\n INNER JOIN cache_type ON (caches.type = cache_type.id)\n LEFT JOIN `cache_rating` ON `cache_logs`.`cache_id`=`cache_rating`.`cache_id`\n AND `cache_logs`.`user_id`=`cache_rating`.`user_id`\n LEFT JOIN gk_item_waypoint ON gk_item_waypoint.wp = caches.wp_oc\n LEFT JOIN gk_item ON gk_item.id = gk_item_waypoint.id\n AND gk_item.stateid<>1 AND gk_item.stateid<>4 AND gk_item.typeid<>2 AND gk_item.stateid !=5\n WHERE cache_logs.deleted=0 AND cache_logs.id IN ( " . implode(',', $log_ids) . " ) AND `cache_logs`.`user_id`= ?\n GROUP BY cache_logs.id ORDER BY cache_logs.date_created DESC", $user_id);
$file_content = '';
while ($log_record = XDb::xFetchArray($rs)) {
if (!($log_record['log_type'] == 12 && !$usr['admin'])) {
//ten warunek ukryje logi typu "komentarz COG" przed zwykłymi userami, natomiast adminom wyświetli wszystkie logi
$file_content .= '<tr>';
$file_content .= '<td style="width: 70px;">' . htmlspecialchars(date($dateFormat, strtotime($log_record['log_date'])), ENT_COMPAT, 'UTF-8') . '</td>';
if ($log_record['geokret_in'] != '0') {
$file_content .= '<td width="26"> <img src="images/gk.png" border="0" alt="" title="GeoKret" /></td>';
} else {
$file_content .= '<td width="26"> </td>';
}
//$rating_picture
if ($log_record['recommended'] == 1 && $log_record['log_type'] == 1) {
$file_content .= '<td width="22"><img src="images/rating-star.png" border="0" alt=""/></td>';
} else {
$file_content .= '<td width="22"> </td>';
}
示例15: intval
}
if (isset($_GET['h_avail'])) {
$columns[] = 'active = ' . ($_GET['h_avail'] == 'true' ? 1 : 0);
}
if (isset($_GET['h_temp_unavail'])) {
$columns[] = 'notactive = ' . ($_GET['h_temp_unavail'] == 'true' ? 1 : 0);
}
if (isset($_GET['h_arch'])) {
$columns[] = 'archived = ' . ($_GET['h_arch'] == 'true' ? 0 : 1);
}
if (isset($_GET['be_ftf'])) {
$columns[] = 'be_ftf = ' . ($_GET['be_ftf'] == 'true' ? 1 : 0);
}
global $powerTrailModuleSwitchOn;
if (isset($_GET['powertrail_only']) && $powerTrailModuleSwitchOn === true) {
//powertrail_only param update only if powertrails are enabled
$columns[] = 'powertrail_only = ' . ($_GET['powertrail_only'] == 'true' ? 1 : 0);
}
if (isset($_GET['min_score']) && is_numeric($_GET['min_score'])) {
$columns[] = 'min_score = ' . intval($_GET['min_score']);
}
if (isset($_GET['max_score']) && is_numeric($_GET['max_score'])) {
$columns[] = 'max_score = ' . intval($_GET['max_score']);
}
if (isset($_GET['h_noscore'])) {
$columns[] = 'noscore = ' . ($_GET['h_noscore'] == 'true' ? 1 : 0);
}
$q = 'REPLACE map_settings SET ' . implode(',', $columns);
XDb::xQuery($q);
}
}