/** * singleton function to return * the instance of the class * * @return NoCache */ public static function singleton() { if (!self::$instance) { self::$instance = new NoCache(); } return self::$instance; }
/** * singleton function to return * the instance of the class * * @return Memcache or NoCache */ public static function singleton() { if (!Cache::$enabled) { return NoCache::singleton(); } if (!self::$instance) { self::$instance = new MemcacheCache(); } return self::$instance; }
$tllon = $_REQUEST["tllon"]; $tllat = $_REQUEST["tllat"]; $brlon = $_REQUEST["brlon"]; $brlat = $_REQUEST["brlat"]; $zoom = $_REQUEST["zoom"]; // Validate the input parameters if (is_numeric($tllon) && -180.0 <= $tllon && $tllon < 180.0 && is_numeric($tllat) && -90.0 <= $tllat && $tllat <= 90.0 && is_numeric($brlon) && -180.0 <= $brlon && $brlon < 180.0 && is_numeric($brlat) && -90.0 <= $brlat && $brlat <= 90.0 && is_numeric($zoom) && $zoom >= 0 && $zoom < 20) { $min_lat = $tllat < $brlat ? $tllat : $brlat; $max_lat = $tllat > $brlat ? $tllat : $brlat; $min_lon = $tllon < $brlon ? $tllon : $brlon; $max_lon = $tllon > $brlon ? $tllon : $brlon; $key = "poi_" . $min_lat . "_" . $max_lat . "_" . $min_lon . "_" . $max_lon . "_" . $zoom; if (strcmp($cache_type, "FileCache") == 0) { $cache = new FileCache(); } else { $cache = new NoCache(); } $xml = $cache->get($key); if ($xml == FALSE) { $db = new MySQLDatabase($hostname, $database, $username, $password); $db->connect(); $poi = new POIManager($db); $gpx = $poi->getWpts($min_lat, $max_lat, $min_lon, $max_lon, $zoom); $xml = $gpx->toXml(); $db->disconnect(); $cache->put($key, $xml); } header("Content-type: text/xml; charset=utf-8"); print $xml; } else { header("Content-type: text/plain; charset=utf-8");