From: <wis...@us...> - 2017-10-06 22:54:50
|
Revision: 13300 http://sourceforge.net/p/xoops/svn/13300 Author: wishcraft Date: 2017-10-06 22:54:47 +0000 (Fri, 06 Oct 2017) Log Message: ----------- GeoSpatial Places API Service ~ Version 2.3.2! Modified Paths: -------------- *.xoops.org (Subdomain APIs & Sites)/places.xoops.org/class/cache/file.php *.xoops.org (Subdomain APIs & Sites)/places.xoops.org/class/logger/apilogger.php *.xoops.org (Subdomain APIs & Sites)/places.xoops.org/functions.php *.xoops.org (Subdomain APIs & Sites)/places.xoops.org/help.php *.xoops.org (Subdomain APIs & Sites)/places.xoops.org/include/version.php *.xoops.org (Subdomain APIs & Sites)/places.xoops.org/index.php Added Paths: ----------- *.xoops.org (Subdomain APIs & Sites)/places.xoops.org/assets/media/Life BT Bold Italic/Life BT Bold Italic.ufo/glyphs/F_.glif Added: *.xoops.org (Subdomain APIs & Sites)/places.xoops.org/assets/media/Life BT Bold Italic/Life BT Bold Italic.ufo/glyphs/F_.glif =================================================================== --- *.xoops.org (Subdomain APIs & Sites)/places.xoops.org/assets/media/Life BT Bold Italic/Life BT Bold Italic.ufo/glyphs/F_.glif (rev 0) +++ *.xoops.org (Subdomain APIs & Sites)/places.xoops.org/assets/media/Life BT Bold Italic/Life BT Bold Italic.ufo/glyphs/F_.glif 2017-10-06 22:54:47 UTC (rev 13300) @@ -0,0 +1,80 @@ +<?xml version="1.0" encoding="UTF-8"?> +<glyph name="F" format="1"> + <advance width="1237"/> + <unicode hex="0046"/> + <outline> + <contour> + <point x="240" y="1468" type="line"/> + <point x="291" y="1466"/> + <point x="360" y="1465" type="qcurve" smooth="yes"/> + <point x="405" y="1464"/> + <point x="586" y="1464" type="qcurve"/> + <point x="1286" y="1468" type="line"/> + <point x="1263" y="1337"/> + <point x="1255" y="1282" type="qcurve" smooth="yes"/> + <point x="1236" y="1149"/> + <point x="1229" y="1098" type="qcurve"/> + <point x="1163" y="1098" type="line"/> + <point x="1163" y="1244"/> + <point x="1112" y="1303" type="qcurve"/> + <point x="1059" y="1362"/> + <point x="930" y="1362" type="qcurve" smooth="yes"/> + <point x="791" y="1362" type="line" smooth="yes"/> + <point x="755" y="1362"/> + <point x="744" y="1352" type="qcurve"/> + <point x="732" y="1344"/> + <point x="721" y="1300" type="qcurve"/> + <point x="614" y="815" type="line"/> + <point x="741" y="815" type="line" smooth="yes"/> + <point x="856" y="815"/> + <point x="906" y="851" type="qcurve" smooth="yes"/> + <point x="956" y="887"/> + <point x="981" y="981" type="qcurve"/> + <point x="1047" y="981" type="line"/> + <point x="1011" y="852"/> + <point x="987" y="738" type="qcurve" smooth="yes"/> + <point x="962" y="623"/> + <point x="942" y="508" type="qcurve"/> + <point x="877" y="508" type="line"/> + <point x="883" y="545"/> + <point x="886" y="569" type="qcurve" smooth="yes"/> + <point x="889" y="594"/> + <point x="889" y="610" type="qcurve" smooth="yes"/> + <point x="889" y="668"/> + <point x="858" y="690" type="qcurve" smooth="yes"/> + <point x="826" y="713"/> + <point x="737" y="713" type="qcurve" smooth="yes"/> + <point x="592" y="713" type="line"/> + <point x="483" y="229" type="line" smooth="yes"/> + <point x="479" y="215"/> + <point x="472" y="176" type="qcurve"/> + <point x="469" y="150"/> + <point x="469" y="135" type="qcurve" smooth="yes"/> + <point x="469" y="93"/> + <point x="500" y="77" type="qcurve"/> + <point x="530" y="60"/> + <point x="627" y="59" type="qcurve"/> + <point x="627" y="-6" type="line"/> + <point x="507" y="0"/> + <point x="418" y="3" type="qcurve" smooth="yes"/> + <point x="328" y="6"/> + <point x="266" y="6" type="qcurve" smooth="yes"/> + <point x="171" y="6"/> + <point x="-58" y="-5" type="qcurve"/> + <point x="-76" y="-6" type="line"/> + <point x="-76" y="59" type="line"/> + <point x="30" y="59"/> + <point x="76" y="90" type="qcurve"/> + <point x="120" y="125"/> + <point x="145" y="242" type="qcurve" smooth="yes"/> + <point x="365" y="1235" type="line"/> + <point x="365" y="1237" type="line"/> + <point x="379" y="1305"/> + <point x="379" y="1327" type="qcurve" smooth="yes"/> + <point x="379" y="1368"/> + <point x="352" y="1385" type="qcurve" smooth="yes"/> + <point x="327" y="1400"/> + <point x="240" y="1405" type="qcurve"/> + </contour> + </outline> +</glyph> Modified: *.xoops.org (Subdomain APIs & Sites)/places.xoops.org/class/cache/file.php =================================================================== --- *.xoops.org (Subdomain APIs & Sites)/places.xoops.org/class/cache/file.php 2017-10-06 19:57:52 UTC (rev 13299) +++ *.xoops.org (Subdomain APIs & Sites)/places.xoops.org/class/cache/file.php 2017-10-06 22:54:47 UTC (rev 13300) @@ -110,7 +110,7 @@ 'extension' => '.php', 'prefix' => 'api_', 'lock' => false, - 'serialize' => false, + 'serialize' => true, 'duration' => 31556926); $this->settings = array_merge($defaults, $this->settings); if (!isset($this->file)) { @@ -221,7 +221,11 @@ $data = APIUtility::recursive('stripslashes', $data); } } elseif ($data && empty($this->settings['serialize'])) { - $data = eval($data); + try { + $data = eval($data); + } catch (Exception $e) { + $data = false; + } } $this->file->close(); Modified: *.xoops.org (Subdomain APIs & Sites)/places.xoops.org/class/logger/apilogger.php =================================================================== --- *.xoops.org (Subdomain APIs & Sites)/places.xoops.org/class/logger/apilogger.php 2017-10-06 19:57:52 UTC (rev 13299) +++ *.xoops.org (Subdomain APIs & Sites)/places.xoops.org/class/logger/apilogger.php 2017-10-06 22:54:47 UTC (rev 13300) @@ -49,7 +49,7 @@ */ public $usePopup = false; - public $activated = true; + public $activated = false; /** * *@access protected @@ -224,7 +224,7 @@ $trace = false; $errstr = substr($errstr, 8); } - echo sprintf(_API_FATAL_MESSAGE, $errstr); + echo sprintf('Fatal: %s ~ (%s:%s)', $errstr, basename($errfile), $errline); if ($trace && function_exists('debug_backtrace')) { echo "<div style='color:#f0f0f0;background-color:#f0f0f0;'>" . _API_FATAL_BACKTRACE . ':<br>'; $trace = debug_backtrace(); Modified: *.xoops.org (Subdomain APIs & Sites)/places.xoops.org/functions.php =================================================================== --- *.xoops.org (Subdomain APIs & Sites)/places.xoops.org/functions.php 2017-10-06 19:57:52 UTC (rev 13299) +++ *.xoops.org (Subdomain APIs & Sites)/places.xoops.org/functions.php 2017-10-06 22:54:47 UTC (rev 13300) @@ -120,7 +120,7 @@ if (list($key) = $GLOBALS['APIDB']->fetchRow($result)) return $key; } - $ret = array(); + return array(); } } } @@ -167,7 +167,7 @@ if ($place = $GLOBALS['APIDB']->fetchArray($result)) return array('latitude'=>$place['Latitude_Float'], 'longitude' => $place['Longitude_Float']); } - $ret = array('latitude'=> 0, 'longitude' => 0); + return array('latitude'=> 0, 'longitude' => 0); } } } Modified: *.xoops.org (Subdomain APIs & Sites)/places.xoops.org/help.php =================================================================== --- *.xoops.org (Subdomain APIs & Sites)/places.xoops.org/help.php 2017-10-06 19:57:52 UTC (rev 13299) +++ *.xoops.org (Subdomain APIs & Sites)/places.xoops.org/help.php 2017-10-06 22:54:47 UTC (rev 13300) @@ -33,11 +33,11 @@ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> -<meta property="og:title" content="Geographical API API Services"/> -<meta property="og:type" content="api"/> +<meta property="og:title" content="<?php echo API_VERSION; ?>"/> +<meta property="og:type" content="api<?php echo API_TYPE; ?>"/> <meta property="og:image" content="<?php echo API_URL; ?>/assets/images/logo_500x500.png"/> <meta property="og:url" content="<?php echo (isset($_SERVER["HTTPS"])?"https://":"http://").$_SERVER["HTTP_HOST"].$_SERVER["REQUEST_URI"]; ?>" /> -<meta property="og:site_name" content="<?php echo API_LICENSE_COMPANY; ?>"/> +<meta property="og:site_name" content="<?php echo API_VERSION; ?> - <?php echo API_LICENSE_COMPANY; ?>"/> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="rating" content="general" /> <meta http-equiv="<?php echo $place['iso2']; ?>thor" content="wis...@us..." /> @@ -94,7 +94,7 @@ <body> <div class="main"> <img style="float: right; margin: 11px; width: auto; height: auto; clear: none;" src="<?php echo API_URL; ?>/assets/images/logo_350x350.png" /> - <h1>Geographical API API Services -- <?php echo API_LICENSE_COMPANY; ?></h1> + <h1><?php echo API_VERSION; ?> -- <?php echo API_LICENSE_COMPANY; ?></h1> <p>This is an API Service for conducting a locational search for a place. It provides the longitude, latitude and altitude of place being searched for and provides responses when access the API inclusing JSON, XML, Serialisation, HTML and RAW outputs.</p> <p>You can access the API currently without a key or system it is an open api and was written in response to the many API Services that charge ridiculous amounts for querying such a simple base. The following instructions are how to access the api I hope you enjoy this api as I have writting it!.</p> <h2>Examples of Calls (Using JSON)</h2> Modified: *.xoops.org (Subdomain APIs & Sites)/places.xoops.org/include/version.php =================================================================== --- *.xoops.org (Subdomain APIs & Sites)/places.xoops.org/include/version.php 2017-10-06 19:57:52 UTC (rev 13299) +++ *.xoops.org (Subdomain APIs & Sites)/places.xoops.org/include/version.php 2017-10-06 22:54:47 UTC (rev 13300) @@ -29,5 +29,5 @@ /** * Define API version */ -define('API_VERSION', 'GeoSpatial API API 2.3.1'); +define('API_VERSION', 'GeoSpatial Places API 2.3.2'); define('API_TYPE', 'places'); Modified: *.xoops.org (Subdomain APIs & Sites)/places.xoops.org/index.php =================================================================== --- *.xoops.org (Subdomain APIs & Sites)/places.xoops.org/index.php 2017-10-06 19:57:52 UTC (rev 13299) +++ *.xoops.org (Subdomain APIs & Sites)/places.xoops.org/index.php 2017-10-06 22:54:47 UTC (rev 13300) @@ -21,290 +21,297 @@ * @see https://github.com/Chronolabs-Cooperative/API-API-PHP */ - define('_API_FATAL_MESSAGE', 'Fatal: %s!'); - - include_once __DIR__ . DIRECTORY_SEPARATOR . 'mainfile.ph'; - error_reporting(E_ERROR); - ini_set('display_errors', true); - ini_set('log_errors', true); - ini_set('error_log', __DIR__ . DIRECTORY_SEPARATOR . date('Y-m') .'--error-log.txt'); - - $parts = explode(".", microtime(true)); - mt_srand(mt_rand(-time(), time())/$parts[1]); - mt_srand(mt_rand(-time(), time())/$parts[1]); - mt_srand(mt_rand(-time(), time())/$parts[1]); - mt_srand(mt_rand(-time(), time())/$parts[1]); - $salter = ((float)(mt_rand(0,1)==1?'':'-').$parts[1].'.'.$parts[0]) / sqrt((float)$parts[1].'.'.intval(cosh($parts[0])))*tanh($parts[1]) * mt_rand(1, intval($parts[0] / $parts[1])); - header('Blowfish-salt: '. $salter); - - global $domain, $protocol, $business, $entity, $contact, $referee, $peerings, $source; - require_once __DIR__ . DIRECTORY_SEPARATOR . 'apiconfig.php'; - require_once __DIR__ . DIRECTORY_SEPARATOR . 'verify.php'; - - /** - * URI Path Finding of API URL Source Locality - * @var unknown_type - */ - $odds = $inner = array(); - foreach($_GET as $key => $values) { - if (!isset($inner[$key])) { - $inner[$key] = $values; - } elseif (!in_array(!is_array($values) ? $values : md5(json_encode($values, true)), array_keys($odds[$key]))) { - if (is_array($values)) { - $odds[$key][md5(json_encode($inner[$key] = $values, true))] = $values; - } else { - $odds[$key][$inner[$key] = $values] = "$values--$key"; - } +define('_API_FATAL_MESSAGE', 'Fatal: %s!'); + +$parts = explode(".", microtime(true)); +mt_srand(mt_rand(-time(), time())/$parts[1]); +mt_srand(mt_rand(-time(), time())/$parts[1]); +mt_srand(mt_rand(-time(), time())/$parts[1]); +mt_srand(mt_rand(-time(), time())/$parts[1]); +$salter = ((float)(mt_rand(0,1)==1?'':'-').$parts[1].'.'.$parts[0]) / sqrt((float)$parts[1].'.'.intval(cosh($parts[0])))*tanh($parts[1]) * mt_rand(1, intval($parts[0] / $parts[1])); +header('Blowfish-salt: '. $salter); + +global $source; +require_once __DIR__ . DIRECTORY_SEPARATOR . 'apiconfig.php'; +require_once __DIR__ . DIRECTORY_SEPARATOR . 'verify.php'; +$GLOBALS['APILogger']->activated = false; + +/** + * URI Path Finding of API URL Source Locality + * @var unknown_type + */ +$odds = $inner = array(); +foreach($_GET as $key => $values) { + if (!isset($inner[$key])) { + $inner[$key] = $values; + } elseif (!in_array(!is_array($values) ? $values : md5(json_encode($values, true)), array_keys($odds[$key]))) { + if (is_array($values)) { + $odds[$key][md5(json_encode($inner[$key] = $values, true))] = $values; + } else { + $odds[$key][$inner[$key] = $values] = "$values--$key"; } - } - - foreach($_POST as $key => $values) { - if (!isset($inner[$key])) { - $inner[$key] = $values; - } elseif (!in_array(!is_array($values) ? $values : md5(json_encode($values, true)), array_keys($odds[$key]))) { - if (is_array($values)) { - $odds[$key][md5(json_encode($inner[$key] = $values, true))] = $values; - } else { - $odds[$key][$inner[$key] = $values] = "$values--$key"; - } - } - } - - foreach(parse_url('http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].(strpos($_SERVER['REQUEST_URI'], '?')?'&':'?').$_SERVER['QUERY_STRING'], PHP_URL_QUERY) as $key => $values) { - if (!isset($inner[$key])) { - $inner[$key] = $values; - } elseif (!in_array(!is_array($values) ? $values : md5(json_encode($values, true)), array_keys($odds[$key]))) { - if (is_array($values)) { - $odds[$key][md5(json_encode($inner[$key] = $values, true))] = $values; - } else { - $odds[$key][$inner[$key] = $values] = "$values--$key"; - } - } - } - - $help=false; - if ((!isset($inner['country']) || empty($inner['country'])) && (!isset($inner['place']) || empty($inner['place'])) && (!isset($inner['address']) || empty($inner['address']))) { - $help=true; - } elseif (isset($inner['output']) || !empty($inner['output'])) { - if (isset($inner['country']) && $inner['country'] == 'list') { - $output = trim($inner['output']); - switch ($inner['place']) - { - default: - $mode = 'countries'; - break; - case 'continents': - $mode = 'continents'; - break; - case 'types': - $mode = 'types'; - break; - } - } elseif (isset($inner['country']) && $inner['country'] == 'key') { - $key = trim($inner['place']); - $radius = isset($inner['radius'])?(float)$inner['radius']:API_RADIUS_DEFAULT; - if ($radius<0) - $radius = 0; - elseif ($radius>245) - $radius = 145; - $output = trim($inner['output']); - $mode = 'key'; - } elseif (isset($inner['country']) && $inner['country'] == 'nearby') { - $latitude = (float)$inner['latitude']; - $longitude = (float)$inner['longitude']; - $radius = isset($inner['radius'])?(float)$inner['radius']:API_RADIUS_DEFAULT; - if ($radius<0) - $radius = 0; - elseif ($radius>245) - $radius = 145; - $output = trim($inner['output']); - $mode = 'nearby'; - } elseif (isset($inner['country']) && $inner['country'] == 'exactly') { - $latitude = (float)$inner['latitude']; - $longitude = (float)$inner['longitude']; - $radius = isset($inner['radius'])?(float)$inner['radius']:API_RADIUS_DEFAULT; - if ($radius<0) - $radius = 0; - elseif ($radius>245) - $radius = 145; - $output = trim($inner['output']); - $mode = 'exactly'; - } elseif (isset($inner['country']) && $inner['country'] == 'venues') { - $key = (string)$inner['place']; - $radius = isset($inner['radius'])?(float)$inner['radius']:API_RADIUS_DEFAULT; - if ($radius<0) - $radius = 0; - elseif ($radius>245) - $radius = 145; - $output = trim($inner['output']); - $type = trim($inner['type']); - $mode = 'venues'; - } elseif (isset($inner['country']) && $inner['country'] == 'maps') { - $key = (string)$inner['place']; - $output = trim($inner['output']); - $radius = isset($inner['radius'])?(float)$inner['radius']:API_RADIUS_DEFAULT; - $mode = 'maps'; - } elseif (isset($inner['country']) && $inner['country'] == 'details') { - $key = (string)$inner['place']; - $output = trim($inner['output']); - $mode = 'details'; - } elseif (isset($inner['country']) && $inner['country'] == 'address') { - $address = (string)(!isset($inner['place'])?$inner['address']:$inner['place']); - $radius = isset($inner['radius'])?(float)$inner['radius']:API_RADIUS_DEFAULT; - $output = trim($inner['output']); - $type = trim($inner['type']); - $mode = 'address'; - } else { - $mode = 'place'; - $country = trim($inner['country']); - $place = trim($inner['place']); - $output = trim($inner['output']); - $number = isset($inner['radius'])?(float)$inner['radius']:API_RADIUS_DEFAULT; - } + } +} + +foreach($_POST as $key => $values) { + if (!isset($inner[$key])) { + $inner[$key] = $values; + } elseif (!in_array(!is_array($values) ? $values : md5(json_encode($values, true)), array_keys($odds[$key]))) { + if (is_array($values)) { + $odds[$key][md5(json_encode($inner[$key] = $values, true))] = $values; + } else { + $odds[$key][$inner[$key] = $values] = "$values--$key"; + } + } +} + +foreach(parse_url('http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'].(strpos($_SERVER['REQUEST_URI'], '?')?'&':'?').$_SERVER['QUERY_STRING'], PHP_URL_QUERY) as $key => $values) { + if (!isset($inner[$key])) { + $inner[$key] = $values; + } elseif (!in_array(!is_array($values) ? $values : md5(json_encode($values, true)), array_keys($odds[$key]))) { + if (is_array($values)) { + $odds[$key][md5(json_encode($inner[$key] = $values, true))] = $values; + } else { + $odds[$key][$inner[$key] = $values] = "$values--$key"; + } + } +} + +error_reporting(0); +$help=false; +if ((!isset($inner['country']) || empty($inner['country'])) && (!isset($inner['place']) || empty($inner['place'])) && (!isset($inner['address']) || empty($inner['address']))) { + $help=true; +} elseif (isset($inner['output']) || !empty($inner['output'])) { + if (isset($inner['country']) && $inner['country'] == 'list') { + $output = trim($inner['output']); + switch ($inner['place']) + { + default: + $mode = 'countries'; + break; + case 'continents': + $mode = 'continents'; + break; + case 'types': + $mode = 'types'; + break; + } + } elseif (isset($inner['country']) && $inner['country'] == 'key') { + $key = trim($inner['place']); + $radius = isset($inner['radius'])?(float)$inner['radius']:API_RADIUS_DEFAULT; + if ($radius<0) + $radius = 0; + elseif ($radius>245) + $radius = 145; + $output = trim($inner['output']); + $mode = 'key'; + } elseif (isset($inner['country']) && $inner['country'] == 'nearby') { + $latitude = (float)$inner['latitude']; + $longitude = (float)$inner['longitude']; + $radius = isset($inner['radius'])?(float)$inner['radius']:API_RADIUS_DEFAULT; + if ($radius<0) + $radius = 0; + elseif ($radius>245) + $radius = 145; + $output = trim($inner['output']); + $mode = 'nearby'; + } elseif (isset($inner['country']) && $inner['country'] == 'exactly') { + $latitude = (float)$inner['latitude']; + $longitude = (float)$inner['longitude']; + $radius = isset($inner['radius'])?(float)$inner['radius']:API_RADIUS_DEFAULT; + if ($radius<0) + $radius = 0; + elseif ($radius>245) + $radius = 145; + $output = trim($inner['output']); + $mode = 'exactly'; + } elseif (isset($inner['country']) && $inner['country'] == 'venues') { + $key = (string)$inner['place']; + $radius = isset($inner['radius'])?(float)$inner['radius']:API_RADIUS_DEFAULT; + if ($radius<0) + $radius = 0; + elseif ($radius>245) + $radius = 145; + $output = trim($inner['output']); + $type = trim($inner['type']); + $mode = 'venues'; + } elseif (isset($inner['country']) && $inner['country'] == 'maps') { + $key = (string)$inner['place']; + $output = trim($inner['output']); + $radius = isset($inner['radius'])?(float)$inner['radius']:API_RADIUS_DEFAULT; + $mode = 'maps'; + } elseif (isset($inner['country']) && $inner['country'] == 'details') { + $key = (string)$inner['place']; + $output = trim($inner['output']); + $mode = 'details'; + } elseif (isset($inner['country']) && $inner['country'] == 'address') { + $address = (string)(!isset($inner['place'])?$inner['address']:$inner['place']); + $radius = isset($inner['radius'])?(float)$inner['radius']:API_RADIUS_DEFAULT; + $output = trim($inner['output']); + $type = trim($inner['type']); + $mode = 'address'; } else { - $help=true; + $mode = 'place'; + $country = trim($inner['country']); + $place = trim($inner['place']); + $output = trim($inner['output']); + $number = isset($inner['radius'])?(float)$inner['radius']:API_RADIUS_DEFAULT; } - - if ($help==true) { - http_response_code(400); - include dirname(__FILE__).'/help.php'; - if ($sessions = APICache::read('sessions-'.md5($_SERVER['HTTP_HOST']))) +} else { + $help=true; +} + +error_reporting(0); +if ($help==true) { + http_response_code(400); + include dirname(__FILE__).'/help.php'; + if ($sessions = @APICache::read('sessions-'.md5($_SERVER['HTTP_HOST']))) + { + foreach($sessions as $key => $seconds) + if ($seconds<time()) { - foreach($sessions as $key => $seconds) - if ($seconds<time()) - { - APICache::delete($key); - unset ($sessions[$key]); - } - APICache::write('sessions-'.md5($_SERVER['HTTP_HOST']), $sessions, API_CACHE_SECONDS * API_CACHE_SECONDS * API_CACHE_SECONDS); + @APICache::delete($key); + unset ($sessions[$key]); } - exit; + @APICache::write('sessions-'.md5($_SERVER['HTTP_HOST']), $sessions, API_CACHE_SECONDS * API_CACHE_SECONDS * API_CACHE_SECONDS); } - http_response_code(200); - if ($country == 'random' || $place == 'random') - $keyname = md5(whitelistGetIP(true) . '___' . $_SERVER['HTTP_HOST'] . '___' . $_SERVER['REQUEST_URI']); - else - $keyname = md5($_SERVER['REQUEST_URI']); - if (!$data = APICache::read($keyname)) - { - $retries = 0; - $data = array(); - while (empty($data) || $retries<11) - { - $retries++; - switch ($mode) { - case 'countries': - $sql = "SELECT *, md5(concat(`CountryID`, `Country`, max(`CountryID`) - `CountryID` + 1)) as `key` FROM `$mode` GROUP BY `CountryID` ORDER BY `Country`"; - $result = $GLOBALS['DebauchDB']->queryF($sql); - while($row = $GLOBALS['DebauchDB']->fetchArray($result)) - { - $table = $row['Table']; - unset($row['Table']); - unset($row['CountryID']); - if ($output!='xml') - $data[$row['key']] = strippedArray($row, explode("|", API_COUNTRY_FIELDS)); - else - $data[$table] = strippedArray($row, explode("|", API_COUNTRY_FIELDS)); - } - break; - case 'continents': - $sql = "SELECT *, md5(concat(`ContinentID`, `Continent`, max(`ContinentID`) - `ContinentID` + 1)) as `key` FROM `$mode` GROUP BY `ContinentID` ORDER BY `Continent`"; - $result = $GLOBALS['DebauchDB']->queryF($sql); - while($row = $GLOBALS['DebauchDB']->fetchArray($result)) - { - $continent = str_replace(array(" ", "'". "`", "-"), "", ucwords(strtolower($row['Continent']))); - unset($row['ContinentID']); - if ($output!='xml') - $data[$row['key']] = strippedArray($row, explode("|", API_CONTINENT_FIELDS)); - else - $data[$continent] = strippedArray($row, explode("|", API_CONTINENT_FIELDS)); - } - break; - case 'types': - $sql = "SELECT *, md5(concat(`CountryID`, `Country`, max(`CountryID`) - `CountryID` + 1)) as `key` FROM `$mode` GROUP BY `CountryID` ORDER BY `Country`"; - $result = $GLOBALS['DebauchDB']->queryF($sql); - while($row = $GLOBALS['DebauchDB']->fetchArray($result)) - { - $table = $row['Table']; - unset($row['Table']); - unset($row['CountryID']); - if ($output!='xml') - $data[$row['key']] = strippedArray($row, explode("|", API_COUNTRY_FIELDS)); - else - $data[$table] = strippedArray($row, explode("|", API_COUNTRY_FIELDS)); - } - break; - case 'place': - $data = findPlace($country, $place, $output, $number); - break; - case 'nearby': - $data = findNearby($latitude, $longitude, $radius, $output); - break; - case 'exactly': - $data = findExactly($latitude, $longitude, $radius, $output); - break; - case 'key': - $data = findKey($key, $radius, $output); - break; - case 'maps': - $data = findKeyMaps($key, $radius, $output); - break; - case 'details': - $data = findKeyDetails($key, $output); - break; - case 'venues': - $data = findKeyVenues($key, $type, $radius, $output); - break; - case 'address': - $data = findAddressVenues($address, $type, $radius, $output); - break; - } + exit; +} - } - if (!empty($data)) - { - APICache::write($keyname, $data, API_CACHE_SECONDS); - if (!$sessions = APICache::read('sessions-'.md5($_SERVER['HTTP_HOST']))) - $sessions = array(); - $sessions[$keyname] = time() + API_CACHE_SECONDS; - APICache::write('sessions-'.md5($_SERVER['HTTP_HOST']), $sessions, API_CACHE_SECONDS * API_CACHE_SECONDS * API_CACHE_SECONDS); - } - } - - switch ($output) { - default: - echo '<h1>' . $country . ' - ' . $place . ' (API data)</h1>'; - echo '<pre style="font-family: \'Courier New\', Courier, Terminal; font-size: 0.77em;">'; - echo print_r($data, true); - echo '</pre>'; +error_reporting(0); +http_response_code(200); +if ($country == 'random' || $place == 'random') + $keyname = md5(whitelistGetIP(true) . '___' . $_SERVER['HTTP_HOST'] . '___' . $_SERVER['REQUEST_URI']); +else + $keyname = md5($_SERVER['REQUEST_URI']); +if (!$data = APICache::read($keyname)) +{ + $retries = 0; + $data = array(); + while (empty($data) || $retries<11) + { + $retries++; + switch ($mode) { + case 'countries': + $sql = "SELECT *, md5(concat(`CountryID`, `Country`, max(`CountryID`) - `CountryID` + 1)) as `key` FROM `$mode` GROUP BY `CountryID` ORDER BY `Country`"; + $result = $GLOBALS['DebauchDB']->queryF($sql); + while($row = $GLOBALS['DebauchDB']->fetchArray($result)) + { + $table = $row['Table']; + unset($row['Table']); + unset($row['CountryID']); + if ($output!='xml') + $data[$row['key']] = @strippedArray($row, explode("|", API_COUNTRY_FIELDS)); + else + $data[$table] = @strippedArray($row, explode("|", API_COUNTRY_FIELDS)); + } break; - case 'raw': - echo "<?php\n\nreturn " . var_export($data, true) . ";\n\n?>"; + case 'continents': + $sql = "SELECT *, md5(concat(`ContinentID`, `Continent`, max(`ContinentID`) - `ContinentID` + 1)) as `key` FROM `$mode` GROUP BY `ContinentID` ORDER BY `Continent`"; + $result = $GLOBALS['DebauchDB']->queryF($sql); + while($row = $GLOBALS['DebauchDB']->fetchArray($result)) + { + $continent = str_replace(array(" ", "'". "`", "-"), "", ucwords(strtolower($row['Continent']))); + unset($row['ContinentID']); + if ($output!='xml') + $data[$row['key']] = @strippedArray($row, explode("|", API_CONTINENT_FIELDS)); + else + $data[$continent] = @strippedArray($row, explode("|", API_CONTINENT_FIELDS)); + } break; - case 'json': - header('Content-type: application/json'); - echo json_encode($data); + case 'types': + $sql = "SELECT *, md5(concat(`CountryID`, `Country`, max(`CountryID`) - `CountryID` + 1)) as `key` FROM `$mode` GROUP BY `CountryID` ORDER BY `Country`"; + $result = $GLOBALS['DebauchDB']->queryF($sql); + while($row = $GLOBALS['DebauchDB']->fetchArray($result)) + { + $table = $row['Table']; + unset($row['Table']); + unset($row['CountryID']); + if ($output!='xml') + $data[$row['key']] = @strippedArray($row, explode("|", API_COUNTRY_FIELDS)); + else + $data[$table] = @strippedArray($row, explode("|", API_COUNTRY_FIELDS)); + } break; - case 'serial': - header('Content-type: text/html'); - echo serialize($data); + case 'place': + $data = @findPlace($country, $place, $output, $number); break; - case 'xml': - header('Content-type: application/xml'); - $dom = new XmlDomConstruct('1.0', 'utf-8'); - $dom->fromMixed(array($mode=>$data)); - echo $dom->saveXML(); + case 'nearby': + $data = @findNearby($latitude, $longitude, $radius, $output); break; - } - - if ($sessions = APICache::read('sessions-'.md5($_SERVER['HTTP_HOST']))) - { - foreach($sessions as $key => $seconds) - if ($seconds<time()) - { - APICache::delete($key); - unset ($sessions[$key]); - } - APICache::write('sessions-'.md5($_SERVER['HTTP_HOST']), $sessions, API_CACHE_SECONDS * API_CACHE_SECONDS * API_CACHE_SECONDS); - } -?> \ No newline at end of file + case 'exactly': + $data = @findExactly($latitude, $longitude, $radius, $output); + break; + case 'key': + $data = @findKey($key, $radius, $output); + break; + case 'maps': + $data = @findKeyMaps($key, $radius, $output); + break; + case 'details': + $data = @findKeyDetails($key, $output); + break; + case 'venues': + $data = @findKeyVenues($key, $type, $radius, $output); + break; + case 'address': + $data = @findAddressVenues($address, $type, $radius, $output); + break; + } + + } +} + +error_reporting(0); +if (!empty($data)) +{ + @APICache::write($keyname, $data, API_CACHE_SECONDS); + if (!$sessions = APICache::read('sessions-'.md5($_SERVER['HTTP_HOST']))) + $sessions = array(); + $sessions[$keyname] = time() + API_CACHE_SECONDS; + @APICache::write('sessions-'.md5($_SERVER['HTTP_HOST']), $sessions, API_CACHE_SECONDS * API_CACHE_SECONDS * API_CACHE_SECONDS); +} + +if (function_exists('mb_http_output')) { + mb_http_output('pass'); +} + +error_reporting(0); +switch ($output) { + default: + echo '<h1>' . $country . ' - ' . $place . ' (API data)</h1>'; + echo '<pre style="font-family: \'Courier New\', Courier, Terminal; font-size: 0.77em;">'; + echo print_r($data, true); + echo '</pre>'; + break; + case 'raw': + echo ('<?php'."\n\n".'return ' . var_export($data, true) . ";\n\n?>"); + break; + case 'json': + header('Content-type: application/json'); + echo (json_encode($data)); + break; + case 'serial': + header('Content-type: text/html'); + echo (serialize($data)); + break; + case 'xml': + header('Content-type: application/xml'); + $dom = new XmlDomConstruct('1.0', 'utf-8'); + $dom->fromMixed(array($mode=>$data)); + echo ($dom->saveXML()); + break; +} + + +error_reporting(0); +if ($sessions = @APICache::read('sessions-'.md5($_SERVER['HTTP_HOST']))) +{ + foreach($sessions as $key => $seconds) + if ($seconds<time()) + { + @APICache::delete($key); + unset ($sessions[$key]); + } + @APICache::write('sessions-'.md5($_SERVER['HTTP_HOST']), $sessions, API_CACHE_SECONDS * API_CACHE_SECONDS * API_CACHE_SECONDS); +} |