issue62, fix time information for item pubDate in rss feed
[phpfspot.git] / phpfspot.class.php
index ca8542b6df1174a871a9f091c17e42edc271f15f..4b033f612147cdcf573ede99d81f416d2ff3179c 100644 (file)
@@ -64,6 +64,9 @@ class PHPFSPOT {
       $this->check_config_table();
 
       /* include Smarty template engine */
+      if(!$this->check_readable($this->cfg->smarty_path .'/libs/Smarty.class.php')) {
+         exit(1);
+      }
       require $this->cfg->smarty_path .'/libs/Smarty.class.php';
       /* overload Smarty class if our own template handler */
       require_once "phpfspot_tmpl.php";
@@ -1163,7 +1166,7 @@ class PHPFSPOT {
       foreach($resolutions as $resolution) {
 
          $thumb_sub_path = substr($file_md5, 0, 2);
-         $thumb_path = $this->cfg->base_path ."/thumbs/". $thumb_sub_path ."/". $resolution ."_". $file_md5;
+         $thumb_path = $this->cfg->thumb_path ."/". $thumb_sub_path ."/". $resolution ."_". $file_md5;
 
          if(!file_exists(dirname($thumb_path))) {
             mkdir(dirname($thumb_path), 0755);
@@ -1671,7 +1674,7 @@ class PHPFSPOT {
    <description>
     <?php print $thumb_html; ?> 
    </description>
-   <pubDate><?php print strftime("%a, %d %b %Y %T %z"); ?></pubDate>
+   <pubDate><?php print strftime("%a, %d %b %Y %T %z", $meta_date); ?></pubDate>
   </item>
 <?php
 
@@ -1907,8 +1910,8 @@ class PHPFSPOT {
    public function get_thumb_path($width, $photo)
    {
       $sub_path = substr($this->getMD5($photo), 0, 2);
-      return $this->cfg->base_path
-         . "/thumbs/"
+      return $this->cfg->thumb_path
+         . "/"
          . $sub_path
          . "/"
          . $width
@@ -1944,6 +1947,31 @@ class PHPFSPOT {
    {
       return $this->get_web_protocol() ."://". $this->get_server_name() . $this->cfg->web_path;
    } // get_phpfspot_url()
+   
+   /**
+    * check file exists and is readable
+    *
+    * returns true, if everything is ok, otherwise false
+    * if $silent is not set, this function will output and
+    * error message
+    */
+   private function check_readable($file, $silent = null)
+   {
+      if(!file_exists($file)) {
+         if(!isset($silent))
+            print "File \"". $file ."\" does not exist.\n";
+         return false;
+      }
+
+      if(!is_readable($file)) {
+         if(!isset($silent))
+            print "File \"". $file ."\" is not reachable for user ". $this->getuid() ."\n";
+         return false;
+      }
+
+      return true;
+
+   } // check_readable()
 
 }