this software does not have any MySQL requirements
[phpfspot.git] / phpfspot.class.php
index 0a59d96c6eb804fc29fce69bc27a486815b00ddb..33f3b5b8938acafc30041874265c70d5e71ff398 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);
@@ -47,8 +52,19 @@ class PHPFSPOT {
       $this->tmpl->assign('searchfor', $_SESSION['searchfor']);
       $this->tmpl->assign('page_title', $this->cfg->page_title);
       $this->tmpl->assign('current_condition', $_SESSION['tag_condition']);
+
+      switch($_GET['mode']) {
+         case 'showpi':
+            if(isset($_GET['tags'])) {
+               $_SESSION['selected_tags'] = split(',', $_GET['tags']);
+            }
+            break;
+      }
+
+      $this->tmpl->assign('content_page', 'welcome.tpl');
       $this->tmpl->show("index.tpl");
 
+
    } // show()
 
    private function get_tags()
@@ -418,7 +434,14 @@ class PHPFSPOT {
          if($end_with < $count)
             $this->tmpl->assign("next_url", "javascript:showPhotoIndex(". $next_start .");"); 
       }
-   
+
+      $current_tags = "";
+      foreach($_SESSION['selected_tags'] as $tag)
+         $current_tags.= $tag .",";
+      $current_tags = substr($current_tags, 0, strlen($current_tags)-1);
+      $extern_link = "http://". $_SERVER['SERVER_NAME'] ."/index.php?mode=showpi&tags=". $current_tags;
+
+      $this->tmpl->assign('extern_link', $extern_link);
       $this->tmpl->assign('count', $count);
       $this->tmpl->assign('width', $this->cfg->thumb_width);
       $this->tmpl->assign('images', $images);
@@ -780,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;
@@ -806,6 +829,35 @@ class PHPFSPOT {
 
    } // showTextImage()
 
+   private function checkRequirements()
+   {
+      if(!function_exists("imagecreatefromjpeg")) {
+         print "PHP GD 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()
+         
+
 }
 
 ?>