}
//include template handling
require_once $rootpath . 'lib/common.inc.php';
require_once $rootpath . 'lib/cache_icon.inc.php';
//$red2 = imagecolorallocate ($im2, 255,0,0);
$rs = sql(" SELECT latitude, longitude, date_created FROM caches ORDER BY `date_created`");
$im = imagecreatefromjpeg("mapa.jpg");
$blue = imagecolorallocate($im, 0, 0, 255);
$green = imagecolorallocate($im, 0, 255, 0);
$l = 0;
$no_users = mysql_num_rows($rs);
for ($i = 0; $i < $no_users; $i++) {
    $record = sql_fetch_array($rs);
    $long = $record['longitude'];
    $lat = $record['latitude'];
    $pt = latlon_to_pix($lat, $long);
    imagefilledellipse($im, $pt["x"], $pt["y"], 2, 2, $blue);
    // Now mark the point on the map using a red 4 pixel rectangle
    if ($i % 5 == 0) {
        // Write the string at the top left
        imagefilledrectangle($im, 0, 0, 90, 14, $green);
        imagestring($im, 5, 0, 0, substr($record['date_created'], 0, 10), $blue);
        imagejpeg($im, "pics/mapa-new-" . $l . ".jpg", 80);
        $l++;
    }
}
imagedestroy($im);
function latlon_to_pix($lat, $lon)
{
    $lat = abs($lat);
    $lon = abs($lon);
    $h_ignored = "LEFT JOIN cache_ignore ON (cache_ignore.user_id='{$user_id}' AND cache_ignore.cache_id=foreign_caches.cache_id)";
} else {
    $h_sel_ignored = "";
    $h_ignored = "";
}
if ($_GET['h_nogeokret'] == "true") {
    $filter_by_type_string .= " AND foreign_caches.cache_id IN (SELECT cache_id FROM foreign_caches WHERE wp_oc IN (SELECT wp FROM gk_item_waypoint WHERE id IN (SELECT id FROM gk_item WHERE stateid<>1 AND stateid<>4 AND typeid<>2)) OR (wp_gc IN (SELECT wp FROM gk_item_waypoint WHERE id IN (SELECT id FROM gk_item WHERE stateid<>1 AND stateid<> 4 AND typeid<>2)) AND wp_gc <> '') OR (wp_nc IN (SELECT wp FROM gk_item_waypoint WHERE id IN (SELECT id FROM gk_item WHERE stateid<>1 AND stateid<>4 AND typeid<>2)) AND wp_nc <> '')) ";
} else {
    $filter_by_type_string = "";
}
$sql = "SELECT {$h_sel_ignored} foreign_caches.cache_id, foreign_caches.name, foreign_caches.wp_oc as wp, foreign_caches.latitude, foreign_caches.longitude, foreign_caches.type, foreign_caches.status as status, datediff(now(), foreign_caches.date_hidden) as old, foreign_caches.user_id, IF(foreign_caches.cache_id IN (SELECT cache_id FROM cache_logs WHERE deleted=0 AND user_id='" . sql_escape($user_id) . "' AND (type=1 OR type=8)), 1, 0) as found\n    FROM foreign_caches\n    {$h_ignored}\n    WHERE ( foreign_caches.latitude BETWEEN " . ($rect->y - $rect->height * $bound) . " AND " . ($rect->y + $rect->height + $rect->height * $bound) . " ) AND ( foreign_caches.longitude BETWEEN " . ($rect->x - $rect->width * $bound) . " AND " . ($rect->x + $rect->width + $rect->width * $bound) . " )" . $filter_by_type_string;
$query = mysql_query($sql);
while ($cache = mysql_fetch_array($query)) {
    if (!($_GET['h_u'] == "true" && $cache['type'] == 1) && !($_GET['h_t'] == "true" && $cache['type'] == 2) && !($_GET['h_m'] == "true" && $cache['type'] == 3) && !($_GET['h_v'] == "true" && $cache['type'] == 4) && !($_GET['h_w'] == "true" && $cache['type'] == 5) && !($_GET['h_e'] == "true" && $cache['type'] == 6) && !($_GET['h_q'] == "true" && $cache['type'] == 7) && !($_GET['h_o'] == "true" && $cache['type'] == 8) && !($_GET['h_ignored'] == "true" && $cache['ignored']) && !($_GET['h_own'] == "true" && $cache['username'] == $user_id) && !($_GET['h_found'] == "true" && $cache['found']) && !($_GET['be_ftf'] == "true" && ($cache['found'] == 1 || $cache['status'] != 1 || $cache['username'] == $username)) && !($_GET['h_avail'] == "true" && $cache['status'] == 1) && !($_GET['h_temp_unavail'] == "true" && $cache['status'] == 2) && !($_GET['h_arch'] == "true" && $cache['status'] == 3) && !($_GET['h_noattempt'] == "true" && !$cache['found']) && $cache['status'] <= 3 && $_GET['h_de'] == "true") {
        // caches, user haven't been searching for
        $pt = latlon_to_pix($cache['latitude'], $cache['longitude'], $rect);
        if ($cache['user_id'] == $user_id) {
            $typeColor = "own";
        } else {
            if ($cache['found']) {
                $typeColor = "found";
            } else {
                if ($cache['old'] <= 10) {
                    $typeColor = "new";
                } else {
                    $typeColor = "r";
                }
            }
        }
        if ($zoom > 13) {
            $pointer = 1.5 * $zoom;
Beispiel #3
0
    }
    // found caches
    // end markers
}
$sql = "SELECT longitude, latitude, notify_radius FROM user WHERE user_id = " . sql_escape(intval($user_id));
$query = mysql_query($sql);
$userdata = mysql_fetch_array($query);
$watch = latlon_to_pix($userdata['latitude'], $userdata['longitude'], $rect);
//if( $_GET['watch_circle'] == "true" )
//  {
//echo "u=".$userdata['notify_radius']."aa".$user_id.$black;
//die();
$north = calcLatLong($userdata['longitude'], $userdata['latitude'], $userdata['notify_radius'] * 1000, 0);
$east = calcLatLong($userdata['longitude'], $userdata['latitude'], $userdata['notify_radius'] * 1000, 90);
$north_pt = latlon_to_pix($north['latitude'], $north['longitude'], $rect);
$east_pt = latlon_to_pix($east['latitude'], $east['longitude'], $rect);
//print_r($north_pt);
//print_r($east_pt);
//print_r($watch);
//die();
imageellipse($im, $watch["x"], $watch["y"], $watch["x"] - $east_pt["x"], $watch["y"] - $north_pt["y"], $alpha);
//}
unset($icons);
header("Content-Type: image/gif");
imagegif($im, '', 9);
imagedestroy($im);
// utility class to hold the rectangle position and size.
class Rectangle
{
    var $x, $y;
    var $width, $height;