summaryrefslogtreecommitdiffstats
path: root/phpfspot.class.php
diff options
context:
space:
mode:
authorAndreas Unterkircher <unki@netshadow.at>2007-11-03 12:47:27 +0000
committerAndreas Unterkircher <unki@netshadow.at>2007-11-03 12:47:27 +0000
commit7f4f4e748a2b168d3242650431877c223d1174d5 (patch)
treed8b7058cf2799af4b71806bff2027213f48e37bb /phpfspot.class.php
parentede1b530a05e7ea1ed264d137d433a0175292196 (diff)
issue77, check Smarty.class.php exists and is readable
git-svn-id: file:///var/lib/svn/phpfspot/trunk@291 fa6a889d-dae6-447d-9e79-4ba9a3039384
Diffstat (limited to 'phpfspot.class.php')
-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()
}