function cs2cs_core2($lat, $lon, $to) { $descriptorspec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "w")); if (mb_eregi('^[a-z0-9_ ,.\\+\\-=]*$', $to) == 0) { die("invalid arguments in command: " . $to . "\n"); } $command = CS2CS . " +proj=latlong +ellps=WGS84 +to " . $to; $process = proc_open($command, $descriptorspec, $pipes); if (is_resource($process)) { fwrite($pipes[0], $lon . " " . $lat); fclose($pipes[0]); $stdout = stream_get_contents($pipes[1]); fclose($pipes[1]); $stderr = stream_get_contents($pipes[2]); fclose($pipes[2]); // // $procstat = proc_get_status($process); // // neither proc_close nor proc_get_status return reasonable results with PHP5 and linux 2.6.11, // see http://bugs.php.net/bug.php?id=32533 // // as temporary (?) workaround, check stderr output. // (Vinnie, 2006-02-09) if ($stderr) { die("proc_open() failed:<br />command='{$command}'<br />stderr='" . $stderr . "'"); } proc_close($process); return explode_multi(mb_trim($stdout), "\t\n "); } else { die("proc_open() failed, command={$command}\n"); } }
function parseOutputLine($str) { $nLon = 0; $nLat = 0; $parts = explode_multi(mb_trim($str), "\t\n "); if (count($parts) == 3) { if (strpos($parts[0], '\'') === false) { preg_match('/^(\\d+)dE$/', $parts[0], $aLon); $nLon = $aLon[1]; } else { if (strpos($parts[0], '"') === false) { preg_match('/^(\\d+)d(\\d+)\'E$/', $parts[0], $aLon); $nLon = $aLon[1] + $aLon[2] / 60; } else { preg_match('/^(\\d+)d(\\d+)\'([\\d\\.]+)"E$/', $parts[0], $aLon); $nLon = $aLon[1] + $aLon[2] / 60 + $aLon[3] / 3600; } } if (strpos($parts[1], '\'') === false) { preg_match('/^(\\d+)dN$/', $parts[1], $aLat); $nLat = $aLat[1]; } else { if (strpos($parts[1], '"') === false) { preg_match('/^(\\d+)d(\\d+)\'N$/', $parts[1], $aLat); $nLat = $aLat[1] + $aLat[2] / 60; } else { preg_match('/^(\\d+)d(\\d+)\'([\\d+\\.]+)"N$/', $parts[1], $aLat); $nLat = $aLat[1] + $aLat[2] / 60 + $aLat[3] / 3600; } } } $coord = array('lon' => $nLon, 'lat' => $nLat); return $coord; }
sql_slave($cachesFilter); sql_slave('ALTER TABLE &result_caches ADD PRIMARY KEY ( `cache_id` )'); $sql_select[] = '&result_caches.`cache_id`'; $sql_from = '&result_caches'; $sql_innerjoin[] = '`caches` ON `caches`.`cache_id`=&result_caches.`cache_id`'; } else { $options['error_locidnocoords'] = true; outputSearchForm($options); exit; } } else { if ($options['searchtype'] == 'byort') { if ($locid == 0) { $ort = $options['ort']; $simpletexts = search_text2sort($ort, true); $simpletextsarray = explode_multi($simpletexts, ' -/,'); $sqlhashes = ''; $wordscount = 0; foreach ($simpletextsarray as $text) { if ($text != '') { $searchstring = search_text2simple($text); if ($sqlhashes != '') { $sqlhashes .= ' OR '; } $sqlhashes .= '`gns_search`.`simplehash`=' . sprintf("%u", crc32($searchstring)); $wordscount++; } } if ($sqlhashes == '') { $options['error_noort'] = true; outputSearchForm($options);
static function getCoreCommand($x, $y, $command) { global $opt; $descriptorspec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "w")); if (mb_eregi('^[a-z0-9_ ,\\+\\-=\\.]*$', $command) == 0) { die("invalid arguments in command: " . $command . "\n"); } $command = $opt['bin']['cs2cs'] . " " . $command; $process = proc_open($command, $descriptorspec, $pipes); if (is_resource($process)) { fwrite($pipes[0], $x . " " . $y); fclose($pipes[0]); $stdout = stream_get_contents($pipes[1]); fclose($pipes[1]); $stderr = stream_get_contents($pipes[2]); fclose($pipes[2]); // // $procstat = proc_get_status($process); // // neither proc_close nor proc_get_status return reasonable results with PHP5 and linux 2.6.11, // see http://bugs.php.net/bug.php?id=32533 // // as temporary (?) workaround, check stderr output. // (Vinnie, 2006-02-09) if ($stderr) { die("proc_open() failed:<br>command='{$command}'<br>stderr='" . $stderr . "'"); } proc_close($process); return explode_multi(mb_trim($stdout), "\t\n "); } else { die("proc_open() failed, command={$command}\n"); } }