Beispiel #1
0
<?php

include 'update_indexes.php';
updateIndexes();
if (isset($_GET['gzip'])) {
    header("Content-type: gzip");
    header('Content-Disposition: attachment; filename="indexes.xml.gz"');
    echo gzencode(file_get_contents('indexes.xml'));
} else {
    header('Content-type: application/xml');
    header('Content-Disposition: attachment; filename="indexes.xml"');
    readfile('indexes.xml');
}
{
    $local_file = basename($_SERVER['PHP_SELF']) == basename(__FILE__);
    if ($local_file) {
        $update = true;
    }
    $localFileName = 'indexes.xml';
    // check each 30 minutes
    if (!$update && file_exists($localFileName) && time() - filemtime($localFileName) < 60 * 30) {
        return;
    }
    if ($local_file) {
        echo '<h1>File update : </h1> <br>';
    }
    $dom = new DomDocument();
    $output = new DOMDocument();
    $output->formatOutput = true;
    $outputIndexes = $output->createElement("osmand_regions");
    $outputIndexes->setAttribute('mapversion', '1');
    $output->appendChild($outputIndexes);
    /// 2. append local indexes
    // Open a known directory, and proceed to read its contents
    loadIndexesFromDir($output, $outputIndexes, 'indexes/', 'region', 'map');
    loadIndexesFromDir($output, $outputIndexes, 'wiki/', 'wiki', 'wikimap');
    loadIndexesFromDir($output, $outputIndexes, 'road-indexes/', 'road_region', 'road_map');
    loadIndexesFromDir($output, $outputIndexes, 'srtm-countries/', 'srtmcountry', 'srtm_map');
    loadIndexesFromDir($output, $outputIndexes, 'hillshade/', 'hillshade', 'hillshade');
    loadIndexesFromDir($output, $outputIndexes, 'tours/', 'tour', 'tour');
    $output->save($localFileName);
}
updateIndexes(false);
Beispiel #3
0
<html>
<head><title>OsmAnd Indexes</title></head>
<?php 
$update = $_GET['update'];
include 'update_indexes.php';
updateIndexes($update);
$dom = new DomDocument();
$dom->load('indexes.xml');
$xpath = new DOMXpath($dom);
function printNode($node)
{
    if ($node->getAttribute('parts')) {
        echo "<tr><td>" . $node->getAttribute('name') . "</td><td>" . $node->getAttribute('date') . "</td><td>" . $node->getAttribute('size') . "</td><td>" . $node->getAttribute('size') . "</td><td>" . $node->getAttribute('parts') . "</td><td>" . $node->getAttribute('description') . "</td></tr>";
    } else {
        echo "<tr><td>" . $node->getAttribute('name') . "</td><td>" . $node->getAttribute('date') . "</td><td>" . $node->getAttribute('size') . "</td><td>" . $node->getAttribute('targetsize') . "</td><td>" . $node->getAttribute('description') . "</td></tr>";
    }
}
?>
<body>
<h1><?php 
echo "Table of indexes hosted on osmand.net";
?>
</h1>
<table border="1">
<?php 
$res = $xpath->query('//region');
if ($res && $res->length > 0) {
    foreach ($res as $node) {
        if (file_exists('indexes/' . $node->getAttribute('name'))) {
            printNode($node);
        }