only check if phpfspot SQLite database is writeable, if the file really exists
[phpfspot.git] / phpfspot.class.php
index 5d3521093bb9ad1fc77a58fb87fe533b802cb277..edfed95e1cae4294c6305f3f460a4f162f5eff37 100644 (file)
@@ -122,7 +122,7 @@ class PHPFSPOT {
 
       /* set application name and version information */
       $this->cfg->product = "phpfspot";
-      $this->cfg->version = "1.6";
+      $this->cfg->version = "1.7";
       $this->cfg->db_version = 2;
 
       $this->sort_orders= array(
@@ -141,6 +141,12 @@ class PHPFSPOT {
 
       /******* Opening F-Spot's sqlite database *********/
 
+      /* Check if database file exists and is readable */
+      if(!file_exists($this->cfg->fspot_db) || !is_readable($this->cfg->fspot_db)) {
+         print "Error: ". $this->cfg->fspot_db ." does not exist or is not readable for user ". $this->getuid() .".\n";
+         exit(1);
+      }
+
       /* Check if database file is writeable */
       if(!is_writeable($this->cfg->fspot_db)) {
          print "Error: ". $this->cfg->fspot_db ." is not writeable for user ". $this->getuid() .".\n";
@@ -183,7 +189,7 @@ class PHPFSPOT {
       }
 
       /* Check if database file is writeable */
-      if(!is_writeable($this->cfg->phpfspot_db)) {
+      if(file_exists($this->cfg->phpfspot_db) && !is_writeable($this->cfg->phpfspot_db)) {
          print "Error: ". $this->cfg->phpfspot_db ." is not writeable for user ". $this->getuid() .".\n";
          print "Please fix permissions so phpfspot can create its own sqlite database to store some settings.\n";
          exit(1);
@@ -3780,6 +3786,22 @@ class PHPFSPOT {
 
    } // get_photo_version_name()
 
+   /**
+    */
+   public function is_valid_width($image_width)
+   {
+      if(in_array($image_width,
+         Array($this->cfg->thumb_width,
+               $this->cfg->photo_width,
+               $this->cfg->mini_width,
+               30)))
+
+         return true;
+
+      return false;
+
+   } // is_valid_width()
+
 } // class PHPFSPOT
 
 ?>