MDL-11075 Now saving to temp file, then outputting using filelib's readfile_chunked...
[moodle-pu.git] / iplookup / ipatlas / plotimage.php
blob3ceecb019399a03d7b60ff6f3f639f0aea006e16
1 <?php
3 include("plotconf.inc");
4 include("plot.inc");
6 $form_vars = ${"HTTP_".$HTTP_SERVER_VARS["REQUEST_METHOD"]."_VARS"};
7 $lat = $form_vars['lat'];
8 $lon = $form_vars['lon'];
10 if(isset($HTTP_COOKIE_VARS["atlasprefs"]) && validcookie($HTTP_COOKIE_VARS["atlasprefs"])) {
11 list($setshape, $setcolor, $setsize, $earthimage, , ) = split(":", $HTTP_COOKIE_VARS["atlasprefs"]);
12 } else {
13 $setshape = "Diamond";
14 $setcolor = "red";
15 $setsize = "3";
16 $earthimage = $earthimages[$defaultimage];
17 list($earthimage, , , ) = split(":", $earthimage);
20 $earthimage = isvalidimage($earthimage, $earthimages, $defaultimage);
22 if(strstr($earthimage, ":")) {
23 list($earthimage, , , ) = split(":", $earthimage);
26 list($width, $height) = getimagecoords($earthimages, $earthimage);
28 if($setsize > 8 || $setsize < 2) {
29 $setsize = 2;
32 $im = @ImageCreate ($width, $height)
33 or die ("Cannot Initialize new GD image stream");
34 $background_color = ImageColorAllocate ($im, 255, 255, 255);
37 // color table
38 if($setcolor == "red") { $r = "255"; $g = "0"; $b = "0"; }
39 elseif($setcolor == "white") { $r = "255"; $g = "255"; $b = "254"; }
40 elseif($setcolor == "yellow") { $r = "255"; $g = "255"; $b = "0"; }
41 elseif($setcolor == "magenta") { $r = "255"; $g = "0"; $b = "255"; }
42 elseif($setcolor == "cyan") { $r = "0"; $g = "255"; $b = "255"; }
43 elseif($setcolor == "green") { $r = "0"; $g = "225"; $b = "0"; }
44 elseif($setcolor == "violet") { $r = "191"; $g = "0"; $b = "255"; }
45 else { $r = "255"; $g = "0"; $b = "0"; }
47 $loc_color = ImageColorAllocate ($im, $r, $g, $b);
49 if($lat == "" && $lon == "") { } else {
51 list($x, $y) = getlocationcoords($lat, $lon, $width, $height);
53 if($setshape == "Diamond") {
54 ImageLine($im, ($x - $setsize), $y, $x, ($y + $setsize), $loc_color);
55 ImageLine($im, ($x - $setsize), $y, $x, ($y - $setsize), $loc_color);
56 ImageLine($im, ($x + $setsize), $y, $x, ($y + $setsize), $loc_color);
57 ImageLine($im, ($x + $setsize), $y, $x, ($y - $setsize), $loc_color);
58 ImageFill($im, $x, $y, $loc_color);
59 } elseif($setshape == "Diamond Outline") {
60 ImageLine($im, ($x - $setsize), $y, $x, ($y + $setsize), $loc_color);
61 ImageLine($im, ($x - $setsize), $y, $x, ($y - $setsize), $loc_color);
62 ImageLine($im, ($x + $setsize), $y, $x, ($y + $setsize), $loc_color);
63 ImageLine($im, ($x + $setsize), $y, $x, ($y - $setsize), $loc_color);
64 } elseif($setshape == "Square") {
65 ImageFilledRectangle($im, ($x - $setsize), ($y - $setsize), ($x + $setsize), ($y + $setsize), $loc_color);
66 } elseif($setshape == "Square Outline") {
67 ImageRectangle($im, ($x - $setsize), ($y - $setsize), ($x + $setsize), ($y + $setsize), $loc_color);
68 } elseif($setshape == "Cross") {
69 ImageLine($im, ($x - $setsize), $y, ($x + $setsize), $y, $loc_color);
70 ImageLine($im, $x, ($y - $setsize), $x, ($y + $setsize), $loc_color);
71 } else {
72 // draw a diamond if error
73 ImageLine($im, ($x - $setsize), $y, $x, ($y + $setsize), $loc_color);
74 ImageLine($im, ($x - $setsize), $y, $x, ($y - $setsize), $loc_color);
75 ImageLine($im, ($x + $setsize), $y, $x, ($y + $setsize), $loc_color);
76 ImageLine($im, ($x + $setsize), $y, $x, ($y - $setsize), $loc_color);
77 ImageFill($im, $x, $y, $loc_color);
83 ImageColorTransparent ($im, $background_color);
84 Header("Pragma: no-cache");
85 Header("Expires: Thu, 26-Oct-1972 12:00:00");
86 Header("Content-type: image/png");
87 ImagePng ($im);
88 ImageDestroy($im);