diff --git a/Repositories/Maps/coordinates.php b/Repositories/Maps/coordinates.php new file mode 100755 index 0000000..25d62bb --- /dev/null +++ b/Repositories/Maps/coordinates.php @@ -0,0 +1,90 @@ + 0 ? " LIMIT $num_IPs" : ''); +$result = mysql_query($query,$connect); + +if (mysql_num_rows($result) > 0) +{ + if ($num_IPs < 1) $num_IPs = mysql_num_rows($result); + + while ($row = mysql_fetch_assoc($result)) + { + $ip = $row["ip"]; + $count = $row["count"]; + + $location = GeoIP_record_by_addr($gi, $ip); + + if (isset($location->latitude)) + { + $lat = $location->latitude; + $long = $location->longitude; + $city = $location->city; + + if ($city == '') $city = 'Unknown'; + + $cities[$city]['lat'] = $lat; + $cities[$city]['long'] = $long; + if (!isset($cities[$city])) $cities[$city]['count'] = 0; + $cities[$city]['count'] += $count; + $num_hits += $count; + + list($x, $y) = explode("\t", exec("echo '$long\t$lat'" . $proj_pipe)); + $cities[$city]['x'] = round(($x + $x_offset) / $max_x * 900, 0); + $cities[$city]['y'] = round(($y_offset - $y) / $max_y * 457, 0); + } + } + + $mapimage = imagecreatefrompng('map.png'); + if ($mapimage) /* See if it failed */ + { + foreach ($cities as $city => $loc) + { + $col_ellipse = imagecolorallocate($mapimage, 255, 0, 0); + imagefilledrectangle($mapimage, $loc['x'] - 1, $loc['y'] - 1, $loc['x'] + 1, $loc['y'] + 1, $col_ellipse); + } + } + else + { + $mapimage� = imagecreatetruecolor(150, 30); /* Create a blank image */ + $bgc = imagecolorallocate($mapimage, 255, 255, 255); + $tc� = imagecolorallocate($mapimage, 0, 0, 0); + imagefilledrectangle($mapimage, 0, 0, 150, 30, $bgc); + /* Output an errmsg */ + imagestring($mapimage, 1, 5, 5, "Error loading $imgname", $tc); + } + + $tc� = imagecolorallocate($mapimage, 0, 0, 0); + imagestring($mapimage, 1, 3, 3, "$num_hits downloads from " . (count($cities)) . ' cities', $tc); + imagestring($mapimage, 1, 3, 15, "($num_IPs IP addresses)", $tc); + imagestring($mapimage, 1, 3, 447, 'Elapsed time ' . (time() - $start_time) . ' seconds', $tc); + + header("Content-type: image/jpeg"); + + imagejpeg($mapimage); +} + +?>