X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=phpfspot.git;a=blobdiff_plain;f=phpfspot.class.php;h=50ab45e139423f31c34f08d6c414af13062ac91c;hp=ca8542b6df1174a871a9f091c17e42edc271f15f;hb=7f4f4e748a2b168d3242650431877c223d1174d5;hpb=ede1b530a05e7ea1ed264d137d433a0175292196 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() }