xpath('//download[@name="'.$file.'"]'); if (count($res) > 0) { $node = $res[0]; $node["count"] = intval($node["count"]) + 1; } else { $obj = $xml-> addChild("download"); $obj -> addAttribute("name", $file); $obj -> addAttribute("count", "1"); } $xml->asXML("download_stat.xml"); //fclose($xml); } catch(Exception $e) { } } if(!isset($_GET['file']) ) { header('HTTP/1.0 404 Not Found'); die(1); } $file = $_GET['file']; // not used now if(!isset($_SERVER['HTTP_RANGE']) ) { // old version // update_count_of_downloads($file) ; if (!isset($_GET['event'])) { $eventno = 1; } else { $eventno = $_GET['event']; } if (isset($_GET['osmandver'])) { $app = $_GET['osmandver']; } else { $app = 'Download '.$_SERVER['HTTP_USER_AGENT']; } $tracker = new GoogleAnalytics\Tracker('UA-28342846-1', 'download.osmand.net'); $visitor = new GoogleAnalytics\Visitor(); $visitor->setIpAddress($_SERVER['REMOTE_ADDR']); $visitor->setUserAgent($_SERVER['HTTP_USER_AGENT']); $visitor->setScreenResolution('1024x768'); // Assemble Session information // (could also get unserialized from PHP session) $session = new GoogleAnalytics\Session(); // Assemble Page information $page = new GoogleAnalytics\Page('/download.php?'.$file); $page->setTitle('Download file '.$file); // Track page view $tracker->trackPageview($page, $session, $visitor); $event = new GoogleAnalytics\Event($app, 'App', $file, $eventno); $tracker->trackEvent($event, $session, $visitor); } set_time_limit(0); $xml = simplexml_load_file("indexes.xml"); $res = $xml->xpath('//region[@name="'.$file.'"]'); if(isset($_GET['road'])){ downloadFile('road-indexes/'.$file); } else if (count($res) > 0) { $node = $res[0]; if($node["local"]) { downloadFile('indexes/'.$file); } else { header('HTTP/1.1 302 Found'); header('Location: http://osmand.googlecode.com/files/'.$file); } } else { header('HTTP/1.1 302 Found'); header('Location: http://osmand.googlecode.com/files/'.$file); } ?>