summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--phpfspot.class.php28
1 files changed, 28 insertions, 0 deletions
diff --git a/phpfspot.class.php b/phpfspot.class.php
index ca8542b..50ab45e 100644
--- a/phpfspot.class.php
+++ b/phpfspot.class.php
@@ -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";
@@ -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()
}