Initial add of defaria.com
[clearscm.git] / defaria.com / php / getImage.php
1 <?php
2   // Obtain an image only if we are here on this server....
3
4 $img_name = isset ($_GET ["img"]) ? $_GET ["img"] : "";
5 $img_path = "/web/Pictures";
6 $server   = $_SERVER ["SERVER_NAME"];
7
8 function GetImage ($img_name) {
9   global $server;
10   global $img_path;
11
12   if (isset ($img_name)) {
13     $fp = @fopen ("$img_path/$img_name", "r");
14
15     if ($fp) {
16       header ("Content-Type: image/jpeg\nContent-Transfer-Encoding: binary");
17       fpassthru ($fp);
18     } else {
19       header ("Content-Type: text/html\n");
20       print "<font color=\"red\"<b>Error:</b></font> Unable to find image $img_name<br>";
21     } // if
22   } // if
23 } // GetImage
24
25 if (isset ($_POST ["magic"])) {
26   print "It's magic!" . $_POST ["magic"];
27   return;
28 }
29
30 if ($server == "defaria.com") {
31   GetImage ($img_name);
32 } else {
33   header ("Content-Type: text/html\n");
34   print "<font color=\"red\"<b>Error:</b></font> You don't have authorization to link to this image";
35 } // if
36 ?>