Example #1
0
error_reporting(E_ALL);
ini_set('display_errors', '1');
// Hack for forcing immediate output (padstr and final <br/>)
$padstr = str_pad("", 1024, " ");
echo $padstr;
// Map Init
echo "<html><title>Wiki Users</title>\n    <script type=\"text/javascript\"\n    src=\"http://api.maps.yahoo.com/ajaxymap?v=3.8&appid=k0Ynt5bV34HdGAMTOjBPAk9pMo8FeVdlxiSVgRVV2Gk3TiT8p3B4QD62c6ENIPbiJbdDnIfMIzRS\">\n</script>\n<style type=\"text/css\">\n#map{\n  height: 85%;\n  width: 100%;\n}\n</style>\n<body>\n<div id=\"map\"></div>\n<script type=\"text/javascript\">\n\tvar map = new YMap(document.getElementById('map'));\n\tmap.addTypeControl();\n\tmap.addZoomLong();\n\tmap.addPanControl();\n\n\t// Set map type to either of: YAHOO_MAP_SAT, YAHOO_MAP_HYB, YAHOO_MAP_REG\n\tmap.setMapType(YAHOO_MAP_SAT);\n\tmap.drawZoomAndCenter(new YGeoPoint(0,0),16);\n\tmap.addMarker(new YGeoPoint(0,0));\n\t</script><br/>";
flush();
$final_url = "";
$url = $_POST['uri'];
if ($parsed_url = parse_url($url)) {
    $final_url = str_replace("wiki/", "w/index.php?title=", $url);
    $final_url = $final_url . "&limit=500&action=history";
} else {
    echo "Error";
    echo "</body></html>";
    exit;
}
$doc = new DOMDocument();
$doc->loadHTMLFile($final_url);
$xpath = new DOMXpath($doc);
$node = $xpath->query('//ul[@id="pagehistory"]');
$edit = $xpath->query('//li', $node->item(0));
$users = $xpath->query('//span[@class="history-user"]', $edit->item(0));
foreach ($users as $user) {
    list($id, $extra) = explode(' ', $user->nodeValue);
    if (preg_match("^([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3}^", $id)) {
        display_location($id);
    }
}
echo "</body></html>";
$sel = FALSE;
// Define the base SQL
$sql = "SELECT * FROM " . LOCATIONS_TABLE . " WHERE ";
if (isset($_GET['type'])) {
    // If this ia drop-down request, set the flag and process the parent type
    $parent = TRUE;
    $parent_type = addslashes(htmlspecialchars($_GET['type']));
    if (isset($_GET['sel'])) {
        $sel = addslashes(htmlspecialchars($_GET['sel']));
    }
    // Append to the SQL, and start the XHTML output
    $sql .= "loc_type < {$parent_type} AND loc_type != 4";
} else {
    $sql .= "location_id != 0";
}
// Execute query and loop through all returned locations
$sql .= " ORDER BY loc_order_hash ASC, loc_name ASC";
$all_locs = $db->GetArray($sql);
if ($parent) {
    echo display_form($all_locs, "parent", $sel, FALSE);
} else {
    foreach ($all_locs as $loc) {
        $location = display_location($loc);
        // If we are doing an AJAX call, just echo to the output stream
        if ($ajax) {
            echo $location;
        } else {
            $template['locations'] .= $location;
        }
    }
}