Automatic installer.php lang files by installer_builder (20070726)
[moodle-linuxchix.git] / iplookup / ipatlas / plot.php
blob838469b509a4656744fcc4c85a41bfa1aaf41513
1 <?php
3 include("plotconf.inc");
4 include("plot.inc");
6 if (isset($user)) {
7 $user = get_record("user", "id", $user);
8 $fullname = fullname($user, true);
9 $username = "<b>$fullname</b> [$user->city, $user->country] : ";
10 } else {
11 $username = "";
14 // cleanup
15 if (isset($HTTP_GET_VARS["lastquery"])) {
16 $HTTP_GET_VARS["lastquery"] = clean_param($HTTP_GET_VARS["lastquery"], PARAM_HOST);
19 // check if it is the user's ip, or another host
21 if(!isset($HTTP_GET_VARS["address"]) || ($HTTP_GET_VARS["address"] == "")) {
22 $address = $HTTP_SERVER_VARS['REMOTE_ADDR'];
23 $local = 1;
24 } else {
25 $HTTP_GET_VARS["address"] = clean_param($HTTP_GET_VARS["address"], PARAM_HOST);
26 $address = $HTTP_GET_VARS["address"];
27 $local = 0;
30 // this is the most important function, gets lat/lon and description of location
31 $values = getstuff($address, $local) or die("Error in plot.inc");
33 if(isset($logging) && is_writable("plotlog.txt")) {
34 $log = @fopen("plotlog.txt", "a") or print "";
35 @fputs($log, $HTTP_SERVER_VARS["REMOTE_ADDR"] ."\t". date("F j, Y, g:i a") . "\t$address\t$values[address]\t$values[lat]\t$values[lon]\n") or print "";
36 @fclose($log);
39 if(isset($HTTP_COOKIE_VARS["atlasprefs"]) && validcookie($HTTP_COOKIE_VARS["atlasprefs"])) {
40 list( , , , $imagething) = split(":", $HTTP_COOKIE_VARS["atlasprefs"]);
41 $imagething = clean_param($imagething, PARAM_FILE);
42 $earthimage = isvalidimage($imagething, $earthimages, $defaultimage);
43 } else {
44 $earthimage = $earthimages[$defaultimage];
47 if(strstr($earthimage, ":")) {
48 list($earthimage, , , ) = split(":", $earthimage);
51 // check if we need to run it in css mode
52 if(!shouldrun($HTTP_SERVER_VARS['HTTP_USER_AGENT'])) {
54 list($width, $height) = getimagecoords($earthimages, $earthimage);
56 // make sure some coords were found
57 if($values["lat"] == "" || $values["lon"] == "") {
59 $display = "&nbsp;";
60 $extracss = "";
62 } else {
64 list($x, $y) = getlocationcoords($values["lat"], $values["lon"], $width, $height);
66 if(isset($HTTP_COOKIE_VARS["atlasprefs"])) {
67 list( , , , , $dotname) = split(":", $HTTP_COOKIE_VARS["atlasprefs"]);
68 $dotname = clean_param($dotname, PARAM_FILE);
69 list($thedot, $dotwidth, $dotheight) = finddot($dotname, $cssdots, $defaultdot);
70 } else {
71 $dotname = $cssdots[$defaultdot];
72 list($dotname, , , ) = split(":", $dotname);
73 $dotname = clean_param($dotname, PARAM_FILE);
74 list($thedot, $dotwidth, $dotheight) = finddot($dotname, $cssdots, $defaultdot);
77 // magical formula for placing the css dot
78 $x = ($x - floor($dotwidth / 2));
79 $y = ($y - floor($dotheight / 2));
81 $extracss = "<style>
82 #dotDiv { padding-left:$x; padding-top:$y; }
83 </style>";
84 $display = "<div id=\"dotDiv\"><img width=\"$dotwidth\" height=\"$dotheight\" src=\"$thedot\">";
88 } else {
90 // gd mode
92 list($width, $height) = getimagecoords($earthimages, $earthimage) or die("Unable to find width/height for image $earthimage in config file");
93 $extracss = "";
94 $display = "<img src=\"plotimage.php?lat=$values[lat]&amp;lon=$values[lon]\" width=\"$width\" height=\"$height\" alt=\"\" />";
98 # START HTML
100 print '
102 <html><head><title>'.t("Plotting").' '.$values["address"].'</title>
103 '.$extracss.'
105 <!-- your head tags here -->
106 <link rel="Stylesheet" href="ip-atlas.css">
107 </head><body bgcolor="#FFFFFF">
110 <a name="map"></a>
112 <table valign="top" cellpadding=0 cellspacing=0 border=0 background="'.$earthimage.'" width="'.$width.'" height="'.$height.'"><tr><td valign="top">'.$display.'</td></tr></table>
115 <br />
118 if(isset($address)) {
119 print "$username $values[desc]";
122 $PHP_SELF = 'plot.php';
124 print '
125 <br /><br />
126 <form method="GET" action="'.$PHP_SELF.'#map">
127 <table width="100%"><tr><td nowrap align="left">
128 '.t("IP/Hostname:").' <input value="'.$values["address"].'" type="text" size="30" name="address" /><input type="Submit" value="'.t("Submit").'" /></td><td align="right" width="100%">
129 [ <a href="ip-atlas_prefs.php?lastquery='?><?php if(isset($HTTP_GET_VARS["address"])) { echo $HTTP_GET_VARS["address"]; } ?><?php echo '">'.t("preferences").'</a> ]
130 [ <a href="'."$PHP_SELF".'">'.t("locate me").'</a> ]
131 </td></tr></table>
132 </form>
135 include("footer.inc");
137 print "</body></html>";