本文整理汇总了PHP中sql_slave函数的典型用法代码示例。如果您正苦于以下问题:PHP sql_slave函数的具体用法?PHP sql_slave怎么用?PHP sql_slave使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sql_slave函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: search_output
function search_output()
{
global $sqldebug;
/*
cacheid
name
latitude
longitude
type
size
difficulty
terrain
username
waypoint
*/
$sql = '
SELECT
&searchtmp.`cache_id` `cacheid`,
&searchtmp.`longitude`,
&searchtmp.`latitude`,
`caches`.`name`,
`caches`.`wp_oc`,
`caches`.`terrain`,
`caches`.`difficulty`,
`cache_type`.`short` `typedesc`,
`cache_size`.`name` `sizedesc`,
`user`.`username`
FROM
&searchtmp,
`caches`,
`cache_type`,
`cache_size`,
`user`
WHERE
&searchtmp.`cache_id`=`caches`.`cache_id` AND
&searchtmp.`type`=`cache_type`.`id` AND
&searchtmp.`size`=`cache_size`.`id` AND
&searchtmp.`user_id`=`user`.`user_id`';
$rs = sql_slave($sql, $sqldebug);
while ($r = sql_fetch_array($rs)) {
$lat = sprintf('%07d', $r['latitude'] * 100000);
$lon = sprintf('%07d', $r['longitude'] * 100000);
$name = convert_string($r['name']);
$username = convert_string($r['username']);
$type = convert_string($r['typedesc']);
$size = convert_string($r['sizedesc']);
$difficulty = sprintf('%01.1f', $r['difficulty'] / 2);
$terrain = sprintf('%01.1f', $r['terrain'] / 2);
$cacheid = convert_string($r['wp_oc']);
$line = "{$name} by {$username}, {$type}, {$size}, {$cacheid}";
$record = pack("CLllA*x", 2, 1 + 4 + 4 + 4 + strlen($line) + 1, (int) $lon, (int) $lat, $line);
append_output($record);
}
mysql_free_result($rs);
}
示例2: search_output
function search_output()
{
$ovlLine = "[Symbol {symbolnr1}]\r\nTyp=6\r\nGroup=1\r\nWidth=20\r\nHeight=20\r\nDir=100\r\nArt=1\r\nCol=3\r\nZoom=1\r\nSize=103\r\nArea=2\r\nXKoord={lon}\r\nYKoord={lat}\r\n[Symbol {symbolnr2}]\r\nTyp=2\r\nGroup=1\r\nCol=3\r\nArea=1\r\nZoom=1\r\nSize=130\r\nFont=1\r\nDir=100\r\nXKoord={lonname}\r\nYKoord={latname}\r\nText={cachename}\r\n";
$ovlFoot = "[Overlay]\r\nSymbols={symbolscount}\r\n";
/*
{symbolnr1}
{lon}
{lat}
{symbolnr2}
{lonname}
{latname}
{cachename}
{symbolscount}
*/
$nr = 1;
$rs = sql_slave('
SELECT SQL_BUFFER_RESULT
&searchtmp.`cache_id` `cacheid`,
&searchtmp.`longitude`,
&searchtmp.`latitude`,
`caches`.`name`
FROM
&searchtmp,
`caches`
WHERE
&searchtmp.`cache_id`=`caches`.`cache_id`');
while ($r = sql_fetch_array($rs)) {
$thisline = $ovlLine;
$lat = sprintf('%01.5f', $r['latitude']);
$thisline = mb_ereg_replace('{lat}', $lat, $thisline);
$thisline = mb_ereg_replace('{latname}', $lat, $thisline);
$lon = sprintf('%01.5f', $r['longitude']);
$thisline = mb_ereg_replace('{lon}', $lon, $thisline);
$thisline = mb_ereg_replace('{lonname}', $lon, $thisline);
$thisline = mb_ereg_replace('{cachename}', utf8ToIso88591($r['name']), $thisline);
$thisline = mb_ereg_replace('{symbolnr1}', $nr, $thisline);
$thisline = mb_ereg_replace('{symbolnr2}', $nr + 1, $thisline);
append_output($thisline);
$nr += 2;
}
mysql_free_result($rs);
$ovlFoot = mb_ereg_replace('{symbolscount}', $nr - 1, $ovlFoot);
append_output($ovlFoot);
}
示例3: mb_ereg_replace
// clear if not oconly
if ($caches_record['oconly'] != 1) {
$tmp_caches_oconlystring = '';
}
// clear if oconly attribute is hidden
if ($oconlyhidden == 1) {
$tmp_caches_oconlystring = '';
}
$tmpline = mb_ereg_replace('{oconly}', $tmp_caches_oconlystring, $tmpline);
// das letzte found suchen
$sql = 'SELECT `cache_logs`.`id` `id`, `cache_logs`.`type` `type`, `cache_logs`.`date` `date`, `log_types`.`icon_small` `icon_small`
FROM `cache_logs`, `log_types`
WHERE `cache_logs`.`cache_id`=\'' . sql_escape($caches_record['cache_id']) . '\'
AND `log_types`.`id`=`cache_logs`.`type`
ORDER BY `cache_logs`.`date` DESC LIMIT 6';
$result = sql_slave($sql);
if ($row = sql_fetch_array($result)) {
$tmpline = mb_ereg_replace('{logimage1}', icon_log_type($row['icon_small'], "") . '<a href=\'viewlogs.php?cacheid=' . htmlspecialchars($caches_record['cache_id'], ENT_COMPAT, 'UTF-8') . '#' . htmlspecialchars($row['id'], ENT_COMPAT, 'UTF-8') . '\'>{gray_s}' . date($logdateformat, strtotime($row['date'])) . '{gray_e}</a>', $tmpline);
$tmpline = mb_ereg_replace('{logdate1}', "", $tmpline);
} else {
$tmpline = mb_ereg_replace('{logimage1}', "<img src='images/trans.gif' border='0' width='16' height='16' />", $tmpline);
$tmpline = mb_ereg_replace('{logdate1}', "--.--.----", $tmpline);
}
$lastlogs = "";
while ($row = sql_fetch_array($result)) {
$lastlogs .= '<a href=\'viewlogs.php?cacheid=' . urlencode($caches_record['cache_id']) . '#' . htmlspecialchars($row['id'], ENT_COMPAT, 'UTF-8') . '\'>' . icon_log_type($row['icon_small'], '') . '</a> ';
}
$tmpline = mb_ereg_replace('{lastlogs}', $lastlogs, $tmpline);
// und jetzt noch die Richtung ...
if ($caches_record['distance'] > 0) {
$tmpline = mb_ereg_replace('{direction}', Bearing2Text(calcBearing($lat_rad / 3.14159 * 180, $lon_rad / 3.14159 * 180, $caches_record['latitude'], $caches_record['longitude']), 1), $tmpline);
示例4: sql_value_slave
function sql_value_slave($sql, $default)
{
$rs = sql_slave($sql);
if ($r = sql_fetch_row($rs)) {
if ($r[0] == null) {
return $default;
} else {
return $r[0];
}
} else {
return $default;
}
}
示例5: search_output
function search_output()
{
global $opt;
global $state_temporarily_na, $state_archived, $state_locked;
$server_domain = $opt['page']['domain'];
$server_address = $opt['page']['default_absolute_url'];
$locHead = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?><loc version="1.0" src="' . $server_domain . '">' . "\n";
$locLine = '
<waypoint>
<name id="{waypoint}"><![CDATA[{archivedflag}{name} by {username}]]></name>
<coord lat="{lat}" lon="{lon}"/>
<type>Geocache</type>
<link text="Beschreibung">' . $server_address . 'viewcache.php?cacheid={cacheid}</link>
</waypoint>
';
$locFoot = '</loc>';
append_output($locHead);
/*
{waypoint}
status -> {archivedflag}
{name}
{username}
{lon}
{lat}
{cacheid}
*/
$rs = sql_slave('
SELECT SQL_BUFFER_RESULT
&searchtmp.`cache_id` `cacheid`,
&searchtmp.`longitude`,
&searchtmp.`latitude`,
`caches`.`name`,
`caches`.`status`,
`caches`.`wp_oc` `waypoint`,
`user`.`username` `username`
FROM
&searchtmp,
`caches`,
`user`
WHERE
&searchtmp.`cache_id`=`caches`.`cache_id` AND
&searchtmp.`user_id`=`user`.`user_id`');
while ($r = sql_fetch_array($rs)) {
$thisline = $locLine;
$lat = sprintf('%01.5f', $r['latitude']);
$thisline = mb_ereg_replace('{lat}', $lat, $thisline);
$lon = sprintf('%01.5f', $r['longitude']);
$thisline = mb_ereg_replace('{lon}', $lon, $thisline);
$thisline = mb_ereg_replace('{waypoint}', $r['waypoint'], $thisline);
$thisline = mb_ereg_replace('{name}', $r['name'], $thisline);
if ($r['status'] == 2 || $r['status'] == 3 || $r['status'] == 6) {
if ($r['status'] == 2) {
$thisline = mb_ereg_replace('{archivedflag}', $state_temporarily_na . '!, ', $thisline);
} elseif ($r['status'] == 3) {
$thisline = mb_ereg_replace('{archivedflag}', $state_archived . '!, ', $thisline);
} else {
$thisline = mb_ereg_replace('{archivedflag}', $state_locked . '!, ', $thisline);
}
} else {
$thisline = mb_ereg_replace('{archivedflag}', '', $thisline);
}
$thisline = mb_ereg_replace('{username}', $r['username'], $thisline);
$thisline = mb_ereg_replace('{cacheid}', $r['cacheid'], $thisline);
append_output($thisline);
}
mysql_free_result($rs);
append_output($locFoot);
}
示例6: sql
if ($rMapCache = sql_fetch_assoc($rsMapCache)) {
$resultId = $rMapCache['result_id'];
sql("UPDATE `map2_result` SET `shared_counter`=`shared_counter`+1 WHERE `result_id`='" . ($resultId + 0) . "'");
} else {
// ensure that query is performed without errors before reserving the result_id
sql_temp_table_slave('tmpmapresult');
sql_slave("CREATE TEMPORARY TABLE &tmpmapresult (`cache_id` INT UNSIGNED NOT NULL, PRIMARY KEY (`cache_id`)) ENGINE=MEMORY");
sql_slave("INSERT INTO &tmpmapresult (`cache_id`) " . $sqlFilter);
sql("INSERT INTO `map2_result` (`slave_id`, `sqlchecksum`, `sqlquery`, `date_created`, `date_lastqueried`) VALUES ('&1', '&2', '&3', NOW(), NOW())", $db['slave_id'], $sqlchecksum, $cachesFilter . "\n" . $sqlFilter);
$resultId = sql_insert_id();
sql_slave("INSERT IGNORE INTO `map2_data` (`result_id`, `cache_id`) SELECT '&1', `cache_id` FROM &tmpmapresult", $resultId);
sql_drop_temp_table_slave('tmpmapresult');
}
sql_free_result($rsMapCache);
if ($map2_bounds) {
$rs = sql_slave("SELECT MIN(`latitude`) AS `lat_min`,\n\t\t MAX(`latitude`) AS `lat_max`,\n\t\t MIN(`longitude`) AS `lon_min`,\n\t\t MAX(`longitude`) AS `lon_max`\n FROM `map2_data`, `caches`\n\t WHERE `result_id`='&1'\n\t AND `caches`.`cache_id`=`map2_data`.`cache_id`", $resultId);
if (($rBounds = sql_fetch_assoc($rs)) && $rBounds['lat_min'] !== null) {
if ($rBounds['lat_min'] == $rBounds['lat_max'] && $rBounds['lon_min'] == $rBounds['lon_max']) {
$halfwin = 0.02;
$rBounds['lat_min'] -= $halfwin;
$rBounds['lat_max'] += $halfwin;
$rBounds['lon_min'] -= $halfwin;
$rBounds['lon_max'] += $halfwin;
}
$bounds_param = "&lat_min=" . round($rBounds['lat_min'], 5) . "&lat_max=" . round($rBounds['lat_max'], 5) . '&lon_min=' . round($rBounds['lon_min'], 5) . '&lon_max=' . round($rBounds['lon_max'], 5);
}
sql_free_result($rs);
$tpl->redirect('map2.php?queryid=' . $options['queryid'] . '&resultid=' . $resultId . $bounds_param);
} else {
echo $resultId;
}
示例7: search_output
function search_output()
{
global $opt, $translate, $txt_record;
global $converted_from_html;
global $phpzip, $bUseZip;
$txtLine = $txt_record;
$txtLogs = "<===================>\n{username} / {date} / {type}\n\n{text}\n";
$rs = sql_slave("SELECT SQL_BUFFER_RESULT\n &searchtmp.`cache_id` `cacheid`,\n &searchtmp.`longitude` `longitude`,\n &searchtmp.`latitude` `latitude`,\n `caches`.`wp_oc` `waypoint`,\n `caches`.`date_hidden` `date_hidden`,\n `caches`.`name` `name`,\n `caches`.`terrain` `terrain`,\n `caches`.`difficulty` `difficulty`,\n `caches`.`desc_languages` `desc_languages`,\n `caches`.`needs_maintenance`,\n `caches`.`listing_outdated`,\n IFNULL(`stt_country`.`text`,`countries`.`en`) AS `country`,\n IFNULL(`stt_size`.`text`,`cache_size`.`name`) `size`,\n IFNULL(`stt_type`.`text`,`cache_type`.`en`) `type`,\n IFNULL(`stt_status`.`text`,`cache_status`.`name`) `status`,\n `user`.`username` `username`,\n `cache_desc`.`desc` `desc`,\n `cache_desc`.`short_desc` `short_desc`,\n `cache_desc`.`language` `desc_language`,\n `cache_desc`.`hint` `hint`,\n `cache_desc`.`desc_html` `html`,\n `user`.`user_id`,\n `user`.`username`,\n `user`.`data_license`\n FROM\n &searchtmp\n INNER JOIN `caches` ON &searchtmp.`cache_id`=`caches`.`cache_id`\n INNER JOIN `cache_desc`\n ON `cache_desc`.`cache_id`=`caches`.`cache_id`\n AND `caches`.`default_desclang`=`cache_desc`.`language`\n INNER JOIN `cache_type` ON `cache_type`.`id`=`caches`.`type`\n INNER JOIN `cache_size` ON `cache_size`.`id`=`caches`.`size`\n INNER JOIN `cache_status` ON `cache_status`.`id`=`caches`.`status`\n INNER JOIN `user` ON `user`.`user_id`=`caches`.`user_id`\n LEFT JOIN `countries` ON `countries`.`short`=`caches`.`country`\n LEFT JOIN `sys_trans_text` `stt_type` ON `stt_type`.`trans_id`=`cache_type`.`trans_id` AND `stt_type`.`lang`='&1'\n LEFT JOIN `sys_trans_text` `stt_size` ON `stt_size`.`trans_id`=`cache_size`.`trans_id` AND `stt_size`.`lang`='&1'\n LEFT JOIN `sys_trans_text` `stt_status` ON `stt_status`.`trans_id`=`cache_status`.`trans_id` AND `stt_status`.`lang`='&1'\n LEFT JOIN `sys_trans_text` `stt_country` ON `stt_country`.`trans_id`=`countries`.`trans_id` AND `stt_country`.`lang`='&1'", $opt['template']['locale']);
while ($r = sql_fetch_array($rs)) {
if (strlen($r['desc_languages']) > 2) {
$r = get_locale_desc($r);
}
$thisline = $txtLine;
$lat = sprintf('%01.5f', $r['latitude']);
$thisline = mb_ereg_replace('{lat}', help_latToDegreeStr($lat), $thisline);
$lon = sprintf('%01.5f', $r['longitude']);
$thisline = mb_ereg_replace('{lon}', help_lonToDegreeStr($lon), $thisline);
$time = date('d.m.Y', strtotime($r['date_hidden']));
$thisline = mb_ereg_replace('{time}', $time, $thisline);
$thisline = mb_ereg_replace('{waypoint}', $r['waypoint'], $thisline);
$thisline = mb_ereg_replace('{cacheid}', $r['cacheid'], $thisline);
$thisline = mb_ereg_replace('{cachename}', $r['name'], $thisline);
$thisline = mb_ereg_replace('{country}', $r['country'], $thisline);
if ($r['hint'] == '') {
$thisline = mb_ereg_replace('{hints}', '', $thisline);
} else {
$thisline = mb_ereg_replace('{hints}', str_rot13_gc(decodeEntities(strip_tags($r['hint']))), $thisline);
}
$thisline = mb_ereg_replace('{shortdesc}', $r['short_desc'], $thisline);
$license = getLicenseDisclaimer($r['user_id'], $r['username'], $r['data_license'], $r['cacheid'], $opt['template']['locale'], true, false, true);
if ($license != "") {
$license = "\r\n\r\n{$license}";
}
if ($r['html'] == 0) {
$thisline = mb_ereg_replace('{htmlwarn}', '', $thisline);
$thisline = mb_ereg_replace('{desc}', decodeEntities(strip_tags($r['desc'])) . $license, $thisline);
} else {
$thisline = mb_ereg_replace('{htmlwarn}', " ({$converted_from_html})", $thisline);
$thisline = mb_ereg_replace('{desc}', html2txt($r['desc']) . $license, $thisline);
}
$thisline = mb_ereg_replace('{type}', $r['type'], $thisline);
$thisline = mb_ereg_replace('{container}', $r['size'], $thisline);
$thisline = mb_ereg_replace('{status}', $r['status'], $thisline);
$difficulty = sprintf('%01.1f', $r['difficulty'] / 2);
$thisline = mb_ereg_replace('{difficulty}', $difficulty, $thisline);
$terrain = sprintf('%01.1f', $r['terrain'] / 2);
$thisline = mb_ereg_replace('{terrain}', $terrain, $thisline);
$thisline = mb_ereg_replace('{siteurl}', $opt['page']['default_absolute_url'], $thisline);
$thisline = mb_ereg_replace('{owner}', $r['username'], $thisline);
$flags = array();
if ($r['needs_maintenance'] > 0 || $r['listing_outdated']) {
if ($r['needs_maintenance'] > 0) {
$flags[] = 'geocache needs maintenance';
}
if ($r['listing_outdated'] > 0) {
$flags[] = 'description is outdated';
}
} else {
$flags[] = 'ok';
}
foreach ($flags as &$flag) {
$flag = $translate->t($flag, '', basename(__FILE__), __LINE__);
}
$thisline = mb_ereg_replace('{condition}', implode(', ', $flags), $thisline);
// logs ermitteln
$logentries = '';
$rsLogs = sql_slave("SELECT\n `cache_logs`.`id`,\n `cache_logs`.`text_html`,\n IFNULL(`stt`.`text`, `log_types`.`en`) `type`,\n `cache_logs`.`date`,\n `cache_logs`.`text`,\n `user`.`username`\n FROM `cache_logs`\n JOIN `user` ON `cache_logs`.`user_id`=`user`.`user_id`\n JOIN `log_types` ON `cache_logs`.`type`=`log_types`.`id`\n LEFT JOIN `sys_trans_text` `stt` ON `stt`.`trans_id`=`log_types`.`trans_id` AND `stt`.`lang`='&2'\n WHERE `cache_logs`.`cache_id`=&1\n ORDER BY\n `cache_logs`.`order_date` DESC,\n `cache_logs`.`date_created` DESC,\n `cache_logs`.`id` DESC\n LIMIT 20", $r['cacheid'], $opt['template']['locale']);
while ($rLog = sql_fetch_array($rsLogs)) {
$thislog = $txtLogs;
$thislog = mb_ereg_replace('{id}', $rLog['id'], $thislog);
$dateformat = "d.m.Y H:i";
if (substr($rLog['date'], 11) == "00:00:00") {
$dateformat = "d.m.Y";
}
$thislog = mb_ereg_replace('{date}', date($dateformat, strtotime($rLog['date'])), $thislog);
$thislog = mb_ereg_replace('{username}', $rLog['username'], $thislog);
$logtype = $rLog['type'];
$thislog = mb_ereg_replace('{type}', $logtype, $thislog);
if ($rLog['text_html'] == 0) {
$thislog = mb_ereg_replace('{text}', decodeEntities(strip_tags($rLog['text'])), $thislog);
} else {
$thislog = mb_ereg_replace('{text}', html2txt($rLog['text']), $thislog);
}
$logentries .= $thislog . "\n";
}
$thisline = mb_ereg_replace('{logs}', $logentries, $thisline);
$thisline = lf2crlf($thisline);
if (!$bUseZip) {
echo $thisline;
} else {
$phpzip->add_data($r['waypoint'] . '.txt', $thisline);
}
}
mysql_free_result($rs);
}
示例8: outputLocidSelectionForm
function outputLocidSelectionForm($locSql, $options)
{
global $tpl;
global $locline, $bgcolor1, $bgcolor2;
require_once "lib2/logic/geodb.inc.php";
$urlparamString = prepareLocSelectionForm($options) . '&locid={locid}';
sql_temp_table_slave('locids');
sql_slave('CREATE TEMPORARY TABLE &locids ENGINE=MEMORY ' . $locSql);
sql_slave('ALTER TABLE &locids ADD PRIMARY KEY (`loc_id`)');
$rs = sql_slave('SELECT `geodb_textdata`.`loc_id` `loc_id`, `geodb_textdata`.`text_val` `text_val` FROM `geodb_textdata`, &locids WHERE &locids.`loc_id`=`geodb_textdata`.`loc_id` AND `geodb_textdata`.`text_type`=500100000 ORDER BY `text_val`');
$nr = 1;
$locations = '';
while ($r = sql_fetch_array($rs)) {
$thislocation = $locline;
// locationsdings zusammenbauen
$locString = '';
$land = geodb_landFromLocid($r['loc_id']);
if ($land != '') {
$locString .= htmlspecialchars($land, ENT_COMPAT, 'UTF-8');
}
$rb = geodb_regierungsbezirkFromLocid($r['loc_id']);
if ($rb != '') {
$locString .= ' > ' . htmlspecialchars($rb, ENT_COMPAT, 'UTF-8');
}
$lk = geodb_landkreisFromLocid($r['loc_id']);
if ($lk != '') {
$locString .= ' > ' . htmlspecialchars($lk, ENT_COMPAT, 'UTF-8');
}
$thislocation = mb_ereg_replace('{parentlocations}', $locString, $thislocation);
// koordinaten ermitteln
$r['loc_id'] = $r['loc_id'] + 0;
$rsCoords = sql_slave('SELECT `lon`, `lat` FROM `geodb_coordinates` WHERE loc_id=' . $r['loc_id'] . ' LIMIT 1');
if ($rCoords = sql_fetch_array($rsCoords)) {
$coordString = help_latToDegreeStr($rCoords['lat']) . ' ' . help_lonToDegreeStr($rCoords['lon']);
} else {
$coordString = '[' . $no_location_coords . ']';
}
$thislocation = mb_ereg_replace('{coords}', htmlspecialchars($coordString, ENT_COMPAT, 'UTF-8'), $thislocation);
$thislocation = mb_ereg_replace('{locationname}', htmlspecialchars($r['text_val'], ENT_COMPAT, 'UTF-8'), $thislocation);
$thislocation = mb_ereg_replace('{urlparams}', $urlparamString, $thislocation);
$thislocation = mb_ereg_replace('{locid}', urlencode($r['loc_id']), $thislocation);
$thislocation = mb_ereg_replace('{nr}', $nr, $thislocation);
$thislocation = mb_ereg_replace('{secondlocationname}', '', $thislocation);
if ($nr % 2) {
$thislocation = mb_ereg_replace('{bgcolor}', $bgcolor1, $thislocation);
} else {
$thislocation = mb_ereg_replace('{bgcolor}', $bgcolor2, $thislocation);
}
$nr++;
$locations .= $thislocation . "\n";
}
$tpl->assign('locations', $locations);
$tpl->assign('resultscount', sql_num_rows($rs));
$tpl->assign('pages', '');
sql_free_result($rs);
sql_drop_temp_table_slave('locids');
$tpl->display();
exit;
}
示例9: sql_slave
// ok, ausgabe ...
/*
cacheid
name
lon
lat
archivedflag
type
size
difficulty
terrain
username
*/
$sql = 'SELECT `ov2content`.`cache_id` `cacheid`, `ov2content`.`longitude` `longitude`, `ov2content`.`latitude` `latitude`, `caches`.`date_hidden` `date_hidden`, `caches`.`name` `name`, `caches`.`wp_oc` `wp_oc`, `cache_type`.`short` `typedesc`, `cache_size`.`de` `sizedesc`, `caches`.`terrain` `terrain`, `caches`.`difficulty` `difficulty`, `user`.`username` `username` FROM `ov2content`, `caches`, `cache_type`, `cache_size`, `user` WHERE `ov2content`.`cache_id`=`caches`.`cache_id` AND `ov2content`.`type`=`cache_type`.`id` AND `ov2content`.`size`=`cache_size`.`id` AND `ov2content`.`user_id`=`user`.`user_id`';
$rs = sql_slave($sql, $sqldebug);
while ($r = sql_fetch_array($rs)) {
$lat = sprintf('%07d', $r['latitude'] * 100000);
$lon = sprintf('%07d', $r['longitude'] * 100000);
$name = convert_string($r['name']);
$username = convert_string($r['username']);
$type = convert_string($r['typedesc']);
$size = convert_string($r['sizedesc']);
$difficulty = sprintf('%01.1f', $r['difficulty'] / 2);
$terrain = sprintf('%01.1f', $r['terrain'] / 2);
$cacheid = convert_string($r['wp_oc']);
$line = "{$name} by {$username}, {$type}, {$size}, {$cacheid}";
$record = pack("CLllA*x", 2, 1 + 4 + 4 + 4 + strlen($line) + 1, (int) $lon, (int) $lat, $line);
append_output($record);
}
mysql_free_result($rs);
示例10: output_searchresult
function output_searchresult($nResultId, $compact, $nLon1, $nLon2, $nLat1, $nLat2, $cachenames, $smallmap, $showlockedcaches)
{
global $login, $opt, $useragent_msie;
// check if data is available and connect the right slave server
$nSlaveId = sql_value("SELECT `slave_id` FROM `map2_result` WHERE `result_id`='&1' AND DATE_ADD(`date_created`, INTERVAL '&2' SECOND)>NOW()", -2, $nResultId, $opt['map']['maxcacheage']);
if ($nSlaveId == -2) {
echo '<searchresult count="0" available="0">';
echo '</searchresult>';
exit;
}
sql_connect_slave($nSlaveId);
sql("UPDATE `map2_result` SET `request_counter`=`request_counter`+1, `date_lastqueried`=NOW() WHERE `result_id`='&1'", $nResultId);
// execute query and return search result
$nRecordCount = sql_value_slave("SELECT COUNT(*) FROM `map2_data` INNER JOIN `caches` ON `map2_data`.`cache_id`=`caches`.`cache_id` WHERE `map2_data`.`result_id`='&1' AND `caches`.`longitude`>'&2' AND `caches`.`longitude`<'&3' AND `caches`.`latitude`>'&4' AND `caches`.`latitude`<'&5'", 0, $nResultId, $nLon1, $nLon2, $nLat1, $nLat2);
// TODO: SQL_CALC_FOUND_ROWS + $nRecordCount = sql_value_slave("SELECT FOUND_ROWS()", 0);
// determine max. number of records to send
$maxrecords = $opt['map']['maxrecords'] + 0;
if ($login->userid > 0) {
$user_maxrecords = sql_value("SELECT option_value FROM user_options WHERE user_id='&1' AND option_id=8", $opt['map']['maxrecords'] + 0, $login->userid);
if ($user_maxrecords > 0 && (!$useragent_msie || $user_maxrecords < $maxrecords)) {
$maxrecords = min(max($user_maxrecords, $opt['map']['min_maxrecords']), $opt['map']['max_maxrecords']);
}
} else {
$user_maxrecords = 0;
}
if ($smallmap && $user_maxrecords == 0 && $maxrecords > 1000) {
$maxrecords = floor($maxrecords * 0.65);
}
$bMaxRecordReached = $nRecordCount > $maxrecords;
// output data
echo '<searchresult count="' . xmlentities($nRecordCount) . '" available="1"' . ' maxrecordreached="' . ($bMaxRecordReached ? '1' : '0') . '">' . "\n";
if (!$bMaxRecordReached) {
$namequery = $cachenames ? ", `caches`.`name` AS `cachename`" : "";
$rs = sql_slave("SELECT SQL_BUFFER_RESULT \n distinct `caches`.`wp_oc`,\n `caches`.`longitude`, `caches`.`latitude`,\n `caches`.`type`, \n `caches`.`status`>1 AS `inactive`,\n `caches`.`type`=6 AND `caches`.`date_hidden`+INTERVAL 1 DAY < NOW() AS `oldevent`,\n `user`.`user_id`='&6' AS `owned`,\n IF(`found_logs`.`id` IS NULL, 0, 1) AS `found`,\n IF(`found_logs`.`id` IS NULL AND `notfound_logs`.`id` IS NOT NULL, 1, 0) AS `notfound`,\n IF(`caches_attributes`.`attrib_id` IS NULL, 0, 1) AS `oconly`" . $namequery . "\n FROM `map2_data`\n INNER JOIN `caches` ON `map2_data`.`cache_id`=`caches`.`cache_id`\n INNER JOIN `user` ON `user`.`user_id`=`caches`.`user_id`\n LEFT JOIN `cache_logs` `found_logs` ON `found_logs`.`cache_id`=`caches`.`cache_id` AND `found_logs`.`user_id`='&6' AND `found_logs`.`type` IN (1,7)\n LEFT JOIN `cache_logs` `notfound_logs` ON `notfound_logs`.`cache_id`=`caches`.`cache_id` AND `notfound_logs`.`user_id`='&6' AND `notfound_logs`.`type`=2\n LEFT JOIN `caches_attributes` ON `caches_attributes`.`cache_id`=`caches`.`cache_id` AND `caches_attributes`.`attrib_id`=6\n WHERE `map2_data`.`result_id`='&1' AND `caches`.`longitude`>'&2' AND `caches`.`longitude`<'&3' AND `caches`.`latitude`>'&4' AND `caches`.`latitude`<'&5'\n\t AND (`caches`.`status`<>5 OR `caches`.`user_id`='&6') /* hide unpublished caches */\n\t AND `caches`.`status`<>'&7' /* ... and vandalized listings, locked duplicates etc. */\n\t AND `caches`.`status`<>7 /* ... and locked/invisible caches */\n\t\t\t\t\t\t\t\t\t ORDER BY `caches`.`status` DESC, `oconly` AND NOT (`found` OR `notfound`), NOT (`found` OR `notfound`), `caches`.`type`<>4, MD5(`caches`.`name`)\n\t\t\t\t\t\t\t\t\t LIMIT &8", $nResultId, $nLon1, $nLon2, $nLat1, $nLat2, $login->userid, $showlockedcaches ? 0 : 6, $maxrecords);
while ($r = sql_fetch_assoc($rs)) {
$flags = 0;
if ($r['owned']) {
$flags |= 1;
}
if ($r['found']) {
$flags |= 2;
}
if ($r['notfound']) {
$flags |= 4;
}
if ($r['inactive'] || $r['oldevent']) {
$flags |= 8;
}
if ($r['oconly']) {
$flags |= 16;
}
if ($compact) {
echo '<c d="' . xmlentities($r['wp_oc'] . '/' . round($r['longitude'], 5) . '/' . round($r['latitude'], 5) . '/' . $r['type'] . '/' . $flags) . '"' . (isset($r['cachename']) ? ' n="' . xmlentities($r['cachename']) . '"' : '') . ' />';
} else {
echo '<cache wp="' . xmlentities($r['wp_oc']) . '"' . ' lon="' . xmlentities(round($r['longitude'], 5)) . '"' . ' lat="' . xmlentities(round($r['latitude'], 5)) . '"' . ' type="' . xmlentities($r['type']) . '"' . (isset($r['cachename']) ? ' n="' . xmlentities($r['cachename']) . '"' : '') . ' f="' . xmlentities($flags) . '" />' . "\n";
}
}
sql_free_result($rs);
}
echo '</searchresult>';
exit;
}
示例11: cleanup_mapresult
function cleanup_mapresult($slaveId)
{
// table mapresult
sql_slave("DELETE FROM `mapresult` WHERE `date_created`<DATE_SUB(NOW(), INTERVAL 5 MINUTE)");
sql_slave("DELETE `mapresult_data` FROM `mapresult_data` LEFT JOIN `mapresult` ON `mapresult_data`.`query_id`=`mapresult`.`query_id` WHERE ISNULL(`mapresult`.`query_id`)");
}
示例12: sql_escape
$tpl->cache_id = $startat . "-" . $country . "-" . $cachetype;
if ($startat > 10 * $perpage) {
$tpl->cache_lifetime = 3600;
} else {
$tpl->cache_lifetime = 300;
}
if (!$tpl->is_cached()) {
require $opt['rootpath'] . 'lib2/logic/cacheIcon.inc.php';
$cachetype_condition = $cachetype ? " AND `caches`.`type` = " . sql_escape($cachetype) : "";
if ($bEvents) {
$cachetype_condition .= " AND `date_hidden` >= curdate()";
}
$date_field = $bEvents ? 'date_hidden' : 'date_created';
$sort_order = $bEvents ? 'ASC' : 'DESC';
$newCaches = array();
$rsNewCaches = sql_slave("SELECT `caches`.`cache_id` `cacheid`, `caches`.`wp_oc` `wpoc`,\n\t\t\t\t\t `caches`.`name` `cachename`, `caches`.`type`, `caches`.`country` `country`,\n\t\t\t\t\t `caches`.`{$date_field}` `date_created`,\n\t\t\t\t\t IFNULL(`sys_trans_text`.`text`,`countries`.`en`) AS `country_name`,\n\t\t\t\t\t `user`.`user_id` `userid`, `user`.`username` `username`,\n\t\t\t\t\t `ca`.`attrib_id` IS NOT NULL AS `oconly`\n\t\t\t\t\t FROM `caches`\n\t\t\tINNER JOIN `user` ON `caches`.`user_id`=`user`.`user_id`\n\t\t\t LEFT JOIN `countries` ON `countries`.`short` = `caches`.`country`\n\t\t\t LEFT JOIN `sys_trans_text` ON `sys_trans_text`.`trans_id` = `countries`.`trans_id`\n\t\t\t AND `sys_trans_text`.`lang` = '" . sql_escape($opt['template']['locale']) . "'\n\t\t\t LEFT JOIN `caches_attributes` `ca` ON `ca`.`cache_id`=`caches`.`cache_id` AND `ca`.`attrib_id`=6\n\t\t\t WHERE `caches`.`status` = 1" . ($country ? " AND `caches`.`country`='" . sql_escape($country) . "'" : "") . $cachetype_condition . "\n\t\t\t ORDER BY `caches`.`{$date_field}` {$sort_order}\n\t\t\t\t LIMIT " . ($startat + 0) . ', ' . ($perpage + 0));
// see also write_newcaches_urls() in sitemap.class.php
while ($rNewCache = sql_fetch_assoc($rsNewCaches)) {
$newCaches[] = $rNewCache;
}
sql_free_result($rsNewCaches);
$tpl->assign('newCaches', $newCaches);
$startat = isset($_REQUEST['startat']) ? $_REQUEST['startat'] + 0 : 0;
$cacheype_par = $cachetype ? "&cachetype={$cachetype}" : "";
if ($country == '') {
$count = sql_value_slave("SELECT COUNT(*) FROM `caches` WHERE `caches`.`status`=1" . $cachetype_condition, 0);
$pager = new pager("newcaches.php?startat={offset}" . $cacheype_par);
} else {
$count = sql_value_slave("SELECT COUNT(*) FROM `caches` WHERE `caches`.`status`=1 AND `caches`.`country`='&1'" . $cachetype_condition, 0, $country);
$pager = new pager("newcaches.php?country=" . $country . "&startat={offset}" . $cacheype_par);
}
示例13: array
<?php
/***************************************************************************
* You can find the license in the docs directory
*
* Unicode Reminder メモ
***************************************************************************/
require './lib2/web.inc.php';
$tpl->name = 'newcaches_withoutown';
$tpl->menuitem = MNU_START_NEWCACHES_WITHOUTOWN;
$tpl->caching = true;
$tpl->cache_lifetime = 3600;
if (!$tpl->is_cached()) {
require $opt['rootpath'] . 'lib2/logic/cacheIcon.inc.php';
$newCaches = array();
sql_temp_table_slave('cachelist');
sql_slave("CREATE TEMPORARY TABLE &cachelist (`cache_id` INT(11) PRIMARY KEY) SELECT `cache_id` FROM `caches` INNER JOIN `cache_status` ON `caches`.`status`=`cache_status`.`id` WHERE `cache_status`.`allow_user_view`=1 AND `country`!='DE' ORDER BY `date_created` DESC LIMIT 200");
$rsNewCaches = sql_slave("SELECT IFNULL(`sys_trans_text`.`text`, `countries`.`name`) `country_name`, `caches`.`cache_id` `cacheid`, `caches`.`wp_oc` `wpoc`, `user`.`user_id` `userid`, `caches`.`country` `country`, `caches`.`name` `cachename`, `user`.`username` `username`, `caches`.`date_created` `date_created`, `cache_type`.`icon_large` `icon_large` \r\n\t\t FROM `caches`\r\n\t\t INNER JOIN `user` ON `caches`.`user_id`=`user`.`user_id`\r\n\t\t INNER JOIN `cache_type` ON `caches`.`type`=`cache_type`.`id`\r\n\t\t INNER JOIN &cachelist ON &cachelist.`cache_id`=`caches`.`cache_id`\r\n\t\t INNER JOIN `countries` ON `countries`.`short`=`caches`.`country`\r\n\t\t LEFT JOIN `sys_trans` ON `countries`.`trans_id`=`sys_trans`.`id`\r\n\t\t LEFT JOIN `sys_trans_text` ON `sys_trans`.`id`=`sys_trans_text`.`trans_id` AND `sys_trans_text`.`lang`='&1'\r\n\t\t ORDER BY `country_name`, `caches`.`date_created` DESC LIMIT 200", $opt['template']['locale']);
while ($rNewCache = sql_fetch_assoc($rsNewCaches)) {
$rNewCache['icon_large'] = getSmallCacheIcon($rNewCache['icon_large']);
$newCaches[] = $rNewCache;
}
sql_free_result($rsNewCaches);
sql_drop_temp_table_slave('cachelist');
$tpl->assign('newCaches', $newCaches);
}
$tpl->display();
示例14: ss_zip
$phpzip = new ss_zip('', 6);
}
// ok, ausgabe starten
if ($sqldebug == false) {
if ($bUseZip == true) {
header("content-type: application/zip");
header('Content-Disposition: attachment; filename=' . $sFilebasename . '.zip');
} else {
header("Content-type: application/gpx");
header("Content-Disposition: attachment; filename=" . $sFilebasename . ".gpx");
}
}
$gpxHead = mb_ereg_replace('{time}', date($gpxTimeFormat, time()), $gpxHead);
append_output($gpxHead);
// ok, ausgabe ...
$rs = sql_slave('SELECT SQL_BUFFER_RESULT `gpxcontent`.`cache_id` `cacheid`, `gpxcontent`.`longitude` `longitude`, `gpxcontent`.`latitude` `latitude`, `gpxcontent`.`state` `state`, `caches`.`wp_oc` `waypoint`, `caches`.`date_hidden` `date_hidden`, `caches`.`name` `name`, `caches`.`country` `country`, `caches`.`terrain` `terrain`, `caches`.`difficulty` `difficulty`, `caches`.`desc_languages` `desc_languages`, `caches`.`size` `size`, `caches`.`type` `type`, `caches`.`status` `status`, `user`.`username` `username`, `caches`.`user_id` `userid`, `cache_desc`.`desc` `desc`, `cache_desc`.`short_desc` `short_desc`, `cache_desc`.`hint` `hint` FROM `gpxcontent`, `caches`, `user`, `cache_desc` WHERE `gpxcontent`.`cache_id`=`caches`.`cache_id` AND `caches`.`cache_id`=`cache_desc`.`cache_id` AND `caches`.`default_desclang`=`cache_desc`.`language` AND `gpxcontent`.`user_id`=`user`.`user_id`');
while ($r = sql_fetch_array($rs)) {
$thisline = $gpxLine;
$lat = sprintf('%01.5f', $r['latitude']);
$thisline = mb_ereg_replace('{lat}', $lat, $thisline);
$lon = sprintf('%01.5f', $r['longitude']);
$thisline = mb_ereg_replace('{lon}', $lon, $thisline);
$time = date($gpxTimeFormat, strtotime($r['date_hidden']));
$thisline = mb_ereg_replace('{time}', $time, $thisline);
$thisline = mb_ereg_replace('{waypoint}', $r['waypoint'], $thisline);
$thisline = mb_ereg_replace('{cacheid}', $r['cacheid'], $thisline);
$thisline = mb_ereg_replace('{cachename}', xmlentities($r['name']), $thisline);
$thisline = mb_ereg_replace('{country}', $r['country'], $thisline);
$thisline = mb_ereg_replace('{state}', xmlentities($r['state']), $thisline);
if ($r['hint'] == '') {
$thisline = mb_ereg_replace('{hints}', '', $thisline);
示例15: array
<?php
/***************************************************************************
* You can find the license in the docs directory
*
* Unicode Reminder メモ
***************************************************************************/
require './lib2/web.inc.php';
$tpl->name = 'newlogs';
$tpl->menuitem = MNU_START_NEWLOGS;
$tpl->caching = true;
$tpl->cache_lifetime = 300;
if (!$tpl->is_cached()) {
$newLogs = array();
sql_temp_table_slave('loglist');
sql_slave("CREATE TEMPORARY TABLE &loglist (`id` INT(11) PRIMARY KEY) SELECT `cache_logs`.`id` FROM `cache_logs` INNER JOIN `caches` ON `cache_logs`.`cache_id`=`caches`.`cache_id` INNER JOIN `cache_status` ON `caches`.`status`=`cache_status`.`id` WHERE `cache_status`.`allow_user_view`=1 ORDER BY `cache_logs`.`date_created` DESC LIMIT 200");
if ($opt['logic']['new_logs_per_country']) {
$sqlOrderBy = '`countries`.`de` ASC, ';
} else {
$sqlOrderBy = '';
}
$rsLogs = sql_slave("SELECT `countries`.`de` AS `country_name`, `cache_logs`.`id`, `cache_logs`.`date_created`, `caches`.`name` AS `cachename`, `caches`.`wp_oc`, `cache_logs`.`type`, `cacheloguser`.`user_id`, `cacheloguser`.`username` FROM &loglist INNER JOIN `cache_logs` ON &loglist.`id`=`cache_logs`.`id` INNER JOIN `caches` ON `cache_logs`.`cache_id`=`caches`.`cache_id` INNER JOIN `user` AS `cacheloguser` ON `cache_logs`.`user_id`=`cacheloguser`.`user_id` INNER JOIN `countries` ON `caches`.`country`=`countries`.`short` ORDER BY " . $sqlOrderBy . "`cache_logs`.`date_created` DESC");
while ($rLog = sql_fetch_assoc($rsLogs)) {
$newLogs[] = $rLog;
}
sql_free_result($rsLogs);
sql_drop_temp_table_slave('loglist');
$tpl->assign('newLogs', $newLogs);
$tpl->assign('newLogsPerCountry', $opt['logic']['new_logs_per_country']);
}
$tpl->display();