require __DIR__ . '/lib2/web.inc.php'; $tpl->name = 'coordinates'; $tpl->popup = true; $lat_float = 0; if (isset($_REQUEST['lat'])) { $lat_float += $_REQUEST['lat']; } $lon_float = 0; if (isset($_REQUEST['lon'])) { $lon_float += $_REQUEST['lon']; } $cache_country = isset($_REQUEST['country']) ? $_REQUEST['country'] : false; $cache_desclang = isset($_REQUEST['desclang']) ? $_REQUEST['desclang'] : false; $coord = new coordinate($lat_float, $lon_float); $tpl->assign('coordDeg', $coord->getDecimal()); $tpl->assign('coordDegMin', $coord->getDecimalMinutes()); $tpl->assign('coordDegMinSec', $coord->getDecimalMinutesSeconds()); $tpl->assign('coordUTM', $coord->getUTM()); $tpl->assign('coordGK', $coord->getGK()); $tpl->assign('coordRD', $coord->getRD()); $tpl->assign('showRD', $coord->nLat >= 45 && $coord->nLat <= 57 && $coord->nLon >= 0 && $coord->nLon <= 15); $tpl->assign('coordQTH', $coord->getQTH()); $tpl->assign('coordSwissGrid', $coord->getSwissGrid()); // build priority list of W3W languages to display // 1. current page locale $w3w_langs = array(); if ($opt['locale'][$opt['template']['locale']]['what3words']) { $w3w_langs[] = $opt['template']['locale']; } // 2. language of the cache description if ($cache_desclang && !in_array($cache_desclang, $w3w_langs)) {
/** * @group unit-tests * @covers \coordinate::getDecimalMinutes * @dataProvider formatProvider * * @return void */ public function testFormatConversions($lat, $lon, $expectedMin, $expectedMinSec) { $coord = new \coordinate($lat, $lon); self::assertEquals($expectedMin, $coord->getDecimalMinutes()); self::assertEquals($expectedMinSec, $coord->getDecimalMinutesSeconds()); }
$desclanguageCountry = $opt['locale'][$desclanguage]['country']; } } $rCache['desclanguageCountries'][$desclanguage] = $desclanguageCountry; } $rCache['sizeName'] = labels::getLabelValue('cache_size', $rCache['size']); $rCache['statusName'] = labels::getLabelValue('cache_status', $rCache['status']); $rCache['typeName'] = labels::getLabelValue('cache_type', $rCache['type']); $rCache['userhasfound'] = false; if ($login->userid != 0) { $rCache['userhasfound'] = sql_value("SELECT COUNT(*) FROM `cache_logs` WHERE `cache_id`='&1' AND `user_id`='&2' AND `type` IN (1,7)", 0, $cacheid, $login->userid) > 0; } $tpl->assign('cache', $rCache); $tpl->title = $rCache['wpoc'] . ' ' . $rCache['name']; $coord = new coordinate($rCache['latitude'], $rCache['longitude']); $tpl->assign('coordinates', $coord->getDecimalMinutes()); // podcasts $rs = sql("SELECT `uuid`, `title`, `url` FROM `mp3` WHERE `object_id`='&1' ORDER BY date_created", $cacheid); $tpl->assign_rs('podcasts', $rs); sql_free_result($rs); // pictures $rs = sql("SELECT `id`, `uuid`, `url`, `title`, `thumb_url`, `spoiler`, `display` FROM `pictures` WHERE `object_type`=2 AND `object_id`='&1' AND `display`!=0 ORDER BY `date_created`", $cacheid); $tpl->assign_rs('pictures', $rs); sql_free_result($rs); $tpl->assign('childWaypoints', getChildWaypoints($cacheid)); if ($login->userid != 0) { $cacheNotePresenter = new CacheNote_Presenter(new Http_Request(), new Language_Translator()); $cacheNotePresenter->init(new CacheNote_Handler(), $login->userid, $cacheid); if (isset($_POST['submit_cache_note']) && $cacheNotePresenter->validate()) { $cacheNotePresenter->doSubmit(); }
function setTplHistoryData($exclude_report_id) { global $opt, $tpl; // (other) reports for this cache $rs = sql("SELECT `cr`.`id`, `cr`.`date_created`, `cr`.`lastmodified`,\n\t\t `cr`.`userid`, `cr`.`adminid`,\n\t\t\t\t `users`.`username` AS `usernick`,\n\t\t\t\t `admins`.`username` AS `adminnick`,\n\t\t\t\t\t\t\t\t\t\t\tIFNULL(`tt`.`text`, `crs`.`name`) AS `status`,\n\t\t\t\t IFNULL(`tt2`.`text`, `crr`.`name`) AS `reason`\n\t\t\t\t FROM `cache_reports` AS `cr`\n\t\t\t\t LEFT JOIN `cache_report_reasons` AS `crr` ON `cr`.`reason`=`crr`.`id`\n\t\t\t LEFT JOIN `user` AS `users` ON `users`.`user_id`=`cr`.`userid`\n\t\t\t LEFT JOIN `user` AS `admins` ON `admins`.`user_id`=`cr`.`adminid`\n\t\t\t LEFT JOIN `cache_report_status` AS `crs` ON `cr`.`status`=`crs`.`id`\n\t\t\t LEFT JOIN `sys_trans_text` AS `tt` ON `crs`.`trans_id`=`tt`.`trans_id` AND `tt`.`lang`='&2'\n\t\t\t LEFT JOIN `sys_trans_text` AS `tt2` ON `crr`.`trans_id`=`tt2`.`trans_id` AND `tt2`.`lang`='&2'\n\t\t\t WHERE `cr`.`cacheid`='&1' AND `cr`.`id`<>'&3'\n\t\t\t ORDER BY `cr`.`status`,`cr`.`id` DESC", $this->getCacheId(), $opt['template']['locale'], $exclude_report_id); $tpl->assign_rs('reports', $rs); sql_free_result($rs); // user; deleted logs $rs = sql("SELECT * FROM `caches` WHERE `cache_id`='&1'", $this->getCacheId()); $rCache = sql_fetch_array($rs); $tpl->assign('cache', $rCache); sql_free_result($rs); $tpl->assign('ownername', sql_value("SELECT `username` FROM `user` WHERE `user_id`='&1'", "", $rCache['user_id'])); $tpl->assign('deleted_logs', $this->getLogsArray($this->getCacheId(), 0, 1000, true)); // status changes $rs = sql("SELECT `csm`.`date_modified`,\n\t\t `csm`.`old_state` AS `old_status_id`,\n\t\t `csm`.`new_state` AS `new_status_id`,\n\t\t `user`.`username`,\n\t\t\t\t `user`.`user_id`,\n\t\t IFNULL(`stt_old`.`text`,`cs_old`.`name`) AS `old_status`,\n\t\t IFNULL(`stt_new`.`text`,`cs_new`.`name`) AS `new_status`\n\t\t FROM `cache_status_modified` `csm`\n\t LEFT JOIN `cache_status` `cs_old` ON `cs_old`.`id`=`csm`.`old_state`\n\t\t\t\t\t\tLEFT JOIN `sys_trans_text` `stt_old` ON `stt_old`.`trans_id`=`cs_old`.`trans_id` AND `stt_old`.`lang`='&2'\n\t LEFT JOIN `cache_status` `cs_new` ON `cs_new`.`id`=`csm`.`new_state`\n\t\t\t\t\t\tLEFT JOIN `sys_trans_text` `stt_new` ON `stt_new`.`trans_id`=`cs_new`.`trans_id` AND `stt_new`.`lang`='&2'\n\t\t\t\t\t\tLEFT JOIN `user` ON `user`.`user_id`=`csm`.`user_id`\n\t\t WHERE `cache_id`='&1'\n\t\t ORDER BY `date_modified` DESC", $this->getCacheId(), $opt['template']['locale']); $tpl->assign_rs('status_changes', $rs); sql_free_result($rs); // coordinate changes $rs = sql("SELECT `cc`.`date_created`, `cc`.`longitude`, `cc`.`latitude`,\n\t\t IFNULL(`admin`.`user_id`, `owner`.`user_id`) AS `user_id`,\n\t\t IFNULL(`admin`.`username`, `owner`.`username`) AS `username`\n\t\t FROM `cache_coordinates` `cc`\n\t\t LEFT JOIN `caches` ON `caches`.`cache_id`=`cc`.`cache_id`\n\t\t LEFT JOIN `user` `owner` ON `owner`.`user_id`=`caches`.`user_id`\n\t\t LEFT JOIN `user` `admin` ON `admin`.`user_id`=`cc`.`restored_by`\n\t\t WHERE `cc`.`cache_id`='&1'\n\t\t ORDER BY `cc`.`date_created` DESC", $this->getCacheId()); $coords = array(); while ($rCoord = sql_fetch_assoc($rs)) { $coord = new coordinate($rCoord['latitude'], $rCoord['longitude']); $coords[] = array('date' => $rCoord['date_created'], 'coord' => $coord->getDecimalMinutes(), 'user_id' => $rCoord['user_id'], 'username' => $rCoord['username']); } sql_free_result($rs); $tpl->assign('coordinates', $coords); // Adoptions $rs = sql("SELECT `cache_adoptions`.`date`,\n\t\t `cache_adoptions`.`from_user_id`,\n\t\t `cache_adoptions`.`to_user_id`,\n\t\t `from_user`.`username` AS `from_username`,\n\t\t `to_user`.`username` AS `to_username`\n\t\t FROM `cache_adoptions`\n\t\t LEFT JOIN `user` `from_user` ON `from_user`.`user_id`=`from_user_id`\n\t\t LEFT JOIN `user` `to_user` ON `to_user`.`user_id`=`to_user_id`\n\t\t WHERE `cache_id`='&1'\n\t\t ORDER BY `cache_adoptions`.`date`, `cache_adoptions`.`id`", $this->getCacheId()); $tpl->assign_rs('adoptions', $rs); sql_free_result($rs); }
$tpl->assign('username', $_REQUEST['username']); $rs = sql("SELECT `user_id`, `username`, `is_active_flag` FROM `user` WHERE `username`='&1'", $_REQUEST['username']); $r = sql_fetch_assoc($rs); sql_free_result($rs); if ($r == false) { $tpl->assign('error', 'userunknown'); $tpl->display(); } $tpl->assign('username', $r['username']); // get cache set for this user $user_id = $r['user_id']; $rs = sql("SELECT\n `cache_id`,\n `wp_oc`,\n `name`,\n `latitude`,\n `longitude`,\n `status`,\n LEFT(`listing_last_modified`,10) AS `last_modified`,\n (SELECT COUNT(*) FROM `cache_logs` WHERE `cache_logs`.`cache_id`=`caches`.`cache_id`) AS `logs`\n FROM `caches`\n WHERE `user_id`='&1'\n AND `status`!=5", $user_id); $caches = array(); while ($rCache = sql_fetch_assoc($rs)) { $coord = new coordinate($rCache['latitude'], $rCache['longitude']); $rCache['coordinates'] = $coord->getDecimalMinutes(); $rCache['data'] = get_archive_data(array($rCache['cache_id'])); if (count($rCache['data'])) { $keys = array_keys($rCache['data']); $rCache['date'] = $keys[0]; } $caches[] = $rCache; } sql_free_result($rs); if (count($caches) == 0) { $tpl->assign('error', 'nocaches'); } else { // STEP 3: select caches to restore $tpl->assign('step', 3); $tpl->assign('aCaches', $caches); $tpl->assign('disabled', $r['is_active_flag'] == 0);
public function testFormatConversions() { $coord = new coordinate(51.52775, -120.8972); $decimalMin = $coord->getDecimalMinutes(); $this->assertEquals("N 51° 31.665'", $decimalMin['lat']); $this->assertEquals("W 120° 53.832'", $decimalMin['lon']); $decimalMinSec = $coord->getDecimalMinutesSeconds(); $this->assertEquals("N 51° 31' 39''", $decimalMinSec['lat']); $this->assertEquals("W 120° 53' 49''", $decimalMinSec['lon']); $coord = new coordinate(-8.81687, 13.24057); $decimalMin = $coord->getDecimalMinutes(); $this->assertEquals("S 08° 49.012'", $decimalMin['lat']); $this->assertEquals("E 013° 14.434'", $decimalMin['lon']); $decimalMinSec = $coord->getDecimalMinutesSeconds(); $this->assertEquals("S 08° 49' 00''", $decimalMinSec['lat']); $this->assertEquals("E 013° 14' 26''", $decimalMinSec['lon']); $coord = new coordinate(52.67578, 6.773); $decimalMin = $coord->getDecimalMinutes(); $this->assertEquals("N 52° 40.547'", $decimalMin['lat']); $this->assertEquals("E 006° 46.380'", $decimalMin['lon']); $decimalMinSec = $coord->getDecimalMinutesSeconds(); $this->assertEquals("N 52° 40' 32''", $decimalMinSec['lat']); $this->assertEquals("E 006° 46' 22''", $decimalMinSec['lon']); $coord = new coordinate(60.63367, 4.81313); $decimalMin = $coord->getDecimalMinutes(); $this->assertEquals("N 60° 38.020'", $decimalMin['lat']); $this->assertEquals("E 004° 48.788'", $decimalMin['lon']); $decimalMinSec = $coord->getDecimalMinutesSeconds(); $this->assertEquals("N 60° 38' 01''", $decimalMinSec['lat']); $this->assertEquals("E 004° 48' 47''", $decimalMinSec['lon']); }
function assignFromUser($user) { global $tpl; $tpl->assign('username', $user->getUsername()); $tpl->assign('email', $user->getEMail()); $tpl->assign('firstName', $user->getFirstName()); $tpl->assign('lastName', $user->getLastName()); $tpl->assign('country', $user->getCountry()); $tpl->assign('countryCode', $user->getCountryCode()); $coords = new coordinate($user->getLatitude(), $user->getLongitude()); $tpl->assign('coords', $coords->getDecimalMinutes()); $tpl->assign('coordsDecimal', $coords->getFloat()); $tpl->assign('notifyRadius', $user->getNotifyRadius()); $tpl->assign('registeredSince', $user->getDateRegistered()); $tpl->assign('usePMR', $user->getUsePMR()); $tpl->assign('permanentLogin', $user->getPermanentLogin()); $tpl->assign('noHTMLEditor', $user->getNoHTMLEditor()); }
function assignFromUser($user) { global $tpl; $tpl->assign('username', $user->getUsername()); $tpl->assign('email', $user->getEMail()); $tpl->assign('firstName', $user->getFirstName()); $tpl->assign('lastName', $user->getLastName()); $tpl->assign('country', $user->getCountry()); $tpl->assign('countryCode', $user->getCountryCode()); $coords = new coordinate($user->getLatitude(), $user->getLongitude()); $tpl->assign('coords', $coords->getDecimalMinutes()); $tpl->assign('coordsDecimal', $coords->getFloat()); $tpl->assign('notifyRadius', $user->getNotifyRadius()); $tpl->assign('notifyOconly', $user->getNotifyOconly()); $oconly_helplink = helppagelink('oconly'); $tpl->assign('oconly_helpstart', $oconly_helplink); $tpl->assign('oconly_helpend', $oconly_helplink != '' ? '</a>' : ''); $tpl->assign('registeredSince', $user->getDateRegistered()); $tpl->assign('accMailing', $user->getAccMailing()); $tpl->assign('usePMR', $user->getUsePMR()); $tpl->assign('permanentLogin', $user->getPermanentLogin()); $tpl->assign('noHTMLEditor', $user->getNoHTMLEditor()); $tpl->assign('sendUsermailAddress', $user->getUsermailSendAddress()); }