issue44, renamed error-logging function
[phpfspot.git] / phpfspot.class.php
index 825f92d098d55a8e602ee8c16bd5cf027ac89b31..6a85ccda447a7bfca76307038e6612be97423ac2 100644 (file)
@@ -105,6 +105,7 @@ 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']);
+      $this->tmpl->assign('template_path', 'themes/'. $this->cfg->theme_name);
 
       $_SESSION['start_action'] = $_GET['mode'];
 
@@ -150,7 +151,6 @@ class PHPFSPOT {
       $this->tmpl->assign('to_date', $this->get_calendar('to'));
       $this->tmpl->assign('sort_field', $this->get_sort_field());
       $this->tmpl->assign('content_page', 'welcome.tpl');
-      $this->tmpl->assign('template_path', 'themes/'. $this->cfg->theme_name);
       $this->tmpl->show("index.tpl");
 
 
@@ -293,11 +293,11 @@ class PHPFSPOT {
       $thumb_path = $this->cfg->base_path ."/thumbs/". $this->cfg->photo_width ."_". $this->getMD5($photo);
 
       if(!file_exists($orig_path)) {
-         $this->_warning("Photo ". $orig_path ." does not exist!<br />\n");
+         $this->_error("Photo ". $orig_path ." does not exist!<br />\n");
       }
 
       if(!is_readable($orig_path)) {
-         $this->_warning("Photo ". $orig_path ." is not readable for user ". $this->getuid() ."<br />\n");
+         $this->_error("Photo ". $orig_path ." is not readable for user ". $this->getuid() ."<br />\n");
       }
 
       /* If the thumbnail doesn't exist yet, try to create it */
@@ -353,7 +353,7 @@ class PHPFSPOT {
          $this->tmpl->assign('current', $current);
       }
       else {
-         $this->_warning("Can't open file ". $thumb_path ."\n");
+         $this->_error("Can't open file ". $thumb_path ."\n");
          return;
       }
 
@@ -1112,12 +1112,12 @@ class PHPFSPOT {
       $full_path = $this->translate_path($details['directory_path'])  ."/". $details['name'];
 
       if(!file_exists($full_path)) {
-         $this->_warning("File ". $full_path ." does not exist\n");
+         $this->_error("File ". $full_path ." does not exist\n");
          return;
       }
 
       if(!is_readable($full_path)) {
-         $this->_warning("File ". $full_path ." is not readable for ". $this->getuid() ."\n");
+         $this->_error("File ". $full_path ." is not readable for ". $this->getuid() ."\n");
          return;
       }
 
@@ -1411,12 +1411,22 @@ class PHPFSPOT {
 
    } // checkifImageSupported()
 
-   public function _warning($text)
+   public function _error($text)
    {
-      print "<img src=\"resources/green_info.png\" alt=\"warning\" />\n";
-      print $text;
+      switch($this->cfg->logging) {
+         case 'display':
+            print "<img src=\"resources/green_info.png\" alt=\"warning\" />\n";
+            print $text;
+            break;
+         case 'errorlog':  
+            error_log($text);
+            break;
+         case 'logfile':
+            error_log($text, 3, $his->cfg->log_file);
+            break;
+      }
 
-   } // _warning()
+   } // _error()
 
    /**
     * output calendard input fields
@@ -1551,8 +1561,13 @@ class PHPFSPOT {
                break;
                
             case 'MoinMoin':
-               // [%pictureurl% %thumbnailurl%]
-               print htmlspecialchars(" * [".$orig_url." ".$thumb_url."&fake=1.jpg]") ."<br />\n";
+               // "[%pictureurl% %thumbnailurl%]"
+               print htmlspecialchars("[".$orig_url." ".$thumb_url."&fake=1.jpg]") ."<br />\n";
+               break;
+
+            case 'MoinMoinList':
+               // " * [%pictureurl% %thumbnailurl%]"
+               print "&nbsp;" . htmlspecialchars("* [".$orig_url." ".$thumb_url."&fake=1.jpg]") ."<br />\n";
                break;
          }
 
@@ -1666,6 +1681,12 @@ class PHPFSPOT {
 
    } // get_sort_order()
 
+   /***
+     * return the next to be shown slide show image
+     *
+     * this function returns the URL of the next image
+     * in the slideshow sequence.
+     */
    public function getNextSlideShowImage()
    {
       $all_photos = $this->getPhotoSelection();
@@ -1683,6 +1704,29 @@ class PHPFSPOT {
 
    } // getNextSlideShowImage()
 
+   /***
+     * return the previous to be shown slide show image
+     *
+     * this function returns the URL of the previous image
+     * in the slideshow sequence.
+     */
+   public function getPrevSlideShowImage()
+   {
+      $all_photos = $this->getPhotoSelection();
+
+      if(!isset($_SESSION['slideshow_img']) || $_SESSION['slideshow_img'] == 0)
+         $_SESSION['slideshow_img'] = 0;
+      else
+         $_SESSION['slideshow_img']--;
+
+      $server_name = $_SERVER['SERVER_NAME'];
+      if(!isset($_SERVER['HTTPS'])) $protocol = "http";
+      else $protocol = "https";
+
+      return $protocol ."://". $server_name . $this->cfg->web_path ."phpfspot_img.php?idx=". $all_photos[$_SESSION['slideshow_img']] ."&width=". $this->cfg->photo_width;
+
+   } // getPrevSlideShowImage()
+
    public function resetSlideShow()
    {
       if(isset($_SESSION['slideshow_img']))
@@ -1709,10 +1753,10 @@ class PHPFSPOT {
       ");
       
       while($row = $this->db->db_fetch_object($result)) {
-         array_push($all, $row[0]);
+         array_push($all, $row['id']);
       }
 
-      return array_rand($all);
+      return $all[array_rand($all)];
 
    } // get_random_photo()