[GRASS-SVN] r29893 - grass-web/trunk

svn_grass at osgeo.org svn_grass at osgeo.org
Tue Jan 29 16:40:00 EST 2008


Author: neteler
Date: 2008-01-29 16:40:00 -0500 (Tue, 29 Jan 2008)
New Revision: 29893

Modified:
   grass-web/trunk/index.php
Log:
test first if CURL is installed on mirror

Modified: grass-web/trunk/index.php
===================================================================
--- grass-web/trunk/index.php	2008-01-29 21:05:29 UTC (rev 29892)
+++ grass-web/trunk/index.php	2008-01-29 21:40:00 UTC (rev 29893)
@@ -34,30 +34,34 @@
                 <center><br>
                   <h1>Welcome to GRASS GIS</h1>
 <?php
-$ch = curl_init();
-$MYIP = $_SERVER['SERVER_ADDR'];
-$timeout = 5; // set to zero for no timeout
-curl_setopt ($ch, CURLOPT_URL, "http://api.hostip.info/get_html.php?ip=$MYIP");
-curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
-curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
-$file_contents = curl_exec($ch);
-curl_close($ch);
 
-if (!$file_contents) {
-    echo "[unknown mirror country]\n";
-    exit;
-}
-// e.g.: "Country: UNITED STATES (US) City: San Diego, CA"
-$MYSTATETMP = explode(":", $file_contents);
-$MYSTATETMP2 = explode(")", $MYSTATETMP[1]);
-$MYSTATE = $MYSTATETMP2[0] . ")";
-if ($MYIP == "198.202.74.219")
-  echo "<font size=\"-1\"><i>You are at the official GRASS site in $MYSTATE
+if (function_exists('curl_init')) {
+  $ch = curl_init();
+  $MYIP = $_SERVER['SERVER_ADDR'];
+  $timeout = 5; // set to zero for no timeout
+  curl_setopt ($ch, CURLOPT_URL, "http://api.hostip.info/get_html.php?ip=$MYIP");
+  curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
+  curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
+  $file_contents = curl_exec($ch);
+  curl_close($ch);
+  if (!$file_contents) {
+     echo "[unknown mirror country]\n";
+     exit;
+  }
+  // e.g.: "Country: UNITED STATES (US) City: San Diego, CA"
+  $MYSTATETMP = explode(":", $file_contents);
+  $MYSTATETMP2 = explode(")", $MYSTATETMP[1]);
+  $MYSTATE = $MYSTATETMP2[0] . ")";
+  if ($MYIP == "198.202.74.219")
+     echo "<font size=\"-1\"><i>You are at the official GRASS site in $MYSTATE
                    (<a href=\"mirrors.php\">mirror sites</a>)<br>";
-else
-  echo "<font size=\"-1\"><i>You are at a GRASS mirror site in $MYSTATE (other
+  else
+     echo "<font size=\"-1\"><i>You are at a GRASS mirror site in $MYSTATE (other
                    <a href=\"mirrors.php\">mirror sites</a>)<br>";
-
+} else {
+     echo "<font size=\"-1\"><i>You are at a GRASS mirror site
+                   (other <a href=\"mirrors.php\">mirror sites</a>)<br>";
+}
 ?>
                    This site is updated daily: LASTUPDATED</i> <!-- processed by cron/sed -->
                    </font>



More information about the grass-commit mailing list