issue3, first requirement checks
[phpfspot.git] / phpfspot.class.php
index 191e06627f9e8dfc9f13e27877eb2387763d7bbe..907b6dc9592231da1cbf975e9e224eb506adffdc 100644 (file)
@@ -16,6 +16,11 @@ class PHPFSPOT {
 
    public function __construct()
    {
+      /* Check necessary requirements */
+      if(!$this->checkRequirements()) {
+         exit(1);
+      }
+
       $this->cfg = new PHPFSPOT_CFG;
 
       $this->db = new PHPFSPOT_DB(&$this, $this->cfg->fspot_db);
@@ -798,7 +803,7 @@ class PHPFSPOT {
 
    } // get_photo_tags()
 
-   function showTextImage($txt, $color=000000, $space=4, $font=4, $w=300)
+   public function showTextImage($txt, $color=000000, $space=4, $font=4, $w=300)
    {
       if (strlen($color) != 6) 
          $color = 000000;
@@ -824,6 +829,40 @@ class PHPFSPOT {
 
    } // showTextImage()
 
+   private function checkRequirements()
+   {
+      if(!function_exists("imagecreatefromjpeg")) {
+         print "PHP GD library extension is missing<br />\n";
+         $missing = true;
+      }
+
+      if(!function_exists("mysql_connect")) {
+         print "PHP MySQL library extension is missing<br />\n";
+         $missing = true;
+      }
+
+      if(!function_exists("sqlite3_open")) {
+         print "PHP SQLite3 library extension is missing<br />\n";
+         $missing = true;
+      }
+
+      /* Check for HTML_AJAX PEAR package, lent from Horde project */
+      ini_set('track_errors', 1);
+      @include 'HTML/AJAX/Server.php';
+      if(isset($php_errormsg)) {
+         print "PEAR HTML_AJAX package is missing<br />\n";
+         $missing = true;
+      }
+      ini_restore('track_errors');
+
+      if(isset($missing))
+         return false;
+
+      return true;
+
+   } // checkRequirements()
+         
+
 }
 
 ?>