issue77, check Smarty.class.php exists and is readable
[phpfspot.git] / phpfspot.class.php
index ca8542b6df1174a871a9f091c17e42edc271f15f..50ab45e139423f31c34f08d6c414af13062ac91c 100644 (file)
@@ -64,6 +64,9 @@ class PHPFSPOT {
       $this->check_config_table();
 
       /* include Smarty template engine */
       $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";
       require $this->cfg->smarty_path .'/libs/Smarty.class.php';
       /* overload Smarty class if our own template handler */
       require_once "phpfspot_tmpl.php";
@@ -1944,6 +1947,31 @@ class PHPFSPOT {
    {
       return $this->get_web_protocol() ."://". $this->get_server_name() . $this->cfg->web_path;
    } // get_phpfspot_url()
    {
       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()
 
 }
 
 
 }