summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Unterkircher <unki@netshadow.at>2008-01-12 11:53:28 +0100
committerAndreas Unterkircher <unki@netshadow.at>2008-01-12 11:53:28 +0100
commit42d1600991af9c3243761c56cf01197dd71fabd7 (patch)
tree31f815ca2dcc1f3b929bda8e83b21ebc819820f1
parent811a18a58c30241e895f02e43ec5db502e252c3f (diff)
issue96, move config check to phpfspot main class
Signed-off-by: Andreas Unterkircher <unki@netshadow.at>
-rw-r--r--phpfspot.class.php92
-rw-r--r--phpfspot_cfg.php.dist79
2 files changed, 92 insertions, 79 deletions
diff --git a/phpfspot.class.php b/phpfspot.class.php
index 329371f..9cffc58 100644
--- a/phpfspot.class.php
+++ b/phpfspot.class.php
@@ -32,6 +32,8 @@ class PHPFSPOT {
var $tmpl;
var $tags;
var $avail_tags;
+
+ private $runtime_error = false;
private $dbver;
/**
@@ -45,6 +47,11 @@ class PHPFSPOT {
{
$this->cfg = new PHPFSPOT_CFG;
+ /* verify config settings */
+ if($this->check_config_options()) {
+ exit(1);
+ }
+
/* set application name and version information */
$this->cfg->product = "phpfspot";
$this->cfg->version = "1.3";
@@ -1684,9 +1691,10 @@ class PHPFSPOT {
public function _error($text)
{
switch($this->cfg->logging) {
+ default:
case 'display':
print "<img src=\"resources/green_info.png\" alt=\"warning\" />\n";
- print $text;
+ print $text ."<br />\n";
break;
case 'errorlog':
error_log($text);
@@ -1696,6 +1704,8 @@ class PHPFSPOT {
break;
}
+ $this->runtime_error = true;
+
} // _error()
/**
@@ -2280,6 +2290,86 @@ class PHPFSPOT {
} // parse_uri()
+ /**
+ * validate config options
+ *
+ * this function checks if all necessary configuration options are
+ * specified and set.
+ */
+ private function check_config_options()
+ {
+ if(!isset($this->cfg->page_title) || $this->cfg->page_title == "")
+ $this->_error("Please set \$page_title in phpfspot_cfg");
+
+ if(!isset($this->cfg->base_path) || $this->cfg->base_path == "")
+ $this->_error("Please set \$base_path in phpfspot_cfg");
+
+ if(!isset($this->cfg->web_path) || $this->cfg->web_path == "")
+ $this->_error("Please set \$web_path in phpfspot_cfg");
+
+ if(!isset($this->cfg->thumb_path) || $this->cfg->thumb_path == "")
+ $this->_error("Please set \$thumb_path in phpfspot_cfg");
+
+ if(!isset($this->cfg->smarty_path) || $this->cfg->smarty_path == "")
+ $this->_error("Please set \$smarty_path in phpfspot_cfg");
+
+ if(!isset($this->cfg->fspot_db) || $this->cfg->fspot_db == "")
+ $this->_error("Please set \$fspot_db in phpfspot_cfg");
+
+ if(!isset($this->cfg->db_access) || $this->cfg->db_access == "")
+ $this->_error("Please set \$db_access in phpfspot_cfg");
+
+ if(!isset($this->cfg->phpfspot_db) || $this->cfg->phpfspot_db == "")
+ $this->_error("Please set \$phpfspot_db in phpfspot_cfg");
+
+ if(!isset($this->cfg->thumb_width) || $this->cfg->thumb_width == "")
+ $this->_error("Please set \$thumb_width in phpfspot_cfg");
+
+ if(!isset($this->cfg->thumb_height) || $this->cfg->thumb_height == "")
+ $this->_error("Please set \$thumb_height in phpfspot_cfg");
+
+ if(!isset($this->cfg->photo_width) || $this->cfg->photo_width == "")
+ $this->_error("Please set \$photo_width in phpfspot_cfg");
+
+ if(!isset($this->cfg->mini_width) || $this->cfg->mini_width == "")
+ $this->_error("Please set \$mini_width in phpfspot_cfg");
+
+ if(!isset($this->cfg->thumbs_per_page))
+ $this->_error("Please set \$thumbs_per_page in phpfspot_cfg");
+
+ if(!isset($this->cfg->path_replace_from) || $this->cfg->path_replace_from == "")
+ $this->_error("Please set \$path_replace_from in phpfspot_cfg");
+
+ if(!isset($this->cfg->path_replace_to) || $this->cfg->path_replace_to == "")
+ $this->_error("Please set \$path_replace_to in phpfspot_cfg");
+
+ if(!isset($this->cfg->hide_tags))
+ $this->_error("Please set \$hide_tags in phpfspot_cfg");
+
+ if(!isset($this->cfg->theme_name))
+ $this->_error("Please set \$theme_name in phpfspot_cfg");
+
+ if(!isset($this->cfg->logging))
+ $this->_error("Please set \$logging in phpfspot_cfg");
+
+ if(isset($this->cfg->logging) && $this->cfg->logging == 'logfile') {
+
+ if(!isset($this->cfg->log_file))
+ $this->_error("Please set \$log_file because you set logging = log_file in phpfspot_cfg");
+
+ if(!is_writeable($this->cfg->log_file))
+ $this->_error("The specified \$log_file ". $log_file ." is not writeable!");
+
+ }
+
+ /* check for pending slash on web_path */
+ if(!preg_match("/\/$/", $this->web_path))
+ $this->web_path.= "/";
+
+ return $this->runtime_error;
+
+ } // check_config_options()
+
} // class PHPFSPOT
?>
diff --git a/phpfspot_cfg.php.dist b/phpfspot_cfg.php.dist
index b08c123..93aaff4 100644
--- a/phpfspot_cfg.php.dist
+++ b/phpfspot_cfg.php.dist
@@ -95,86 +95,9 @@ class PHPFSPOT_CFG {
public function __construct()
{
- if(!isset($this->page_title) || $this->page_title == "")
- $this->showError("Please set \$page_title in phpfspot_cfg");
-
- if(!isset($this->base_path) || $this->base_path == "")
- $this->showError("Please set \$base_path in phpfspot_cfg");
-
- if(!isset($this->web_path) || $this->web_path == "")
- $this->showError("Please set \$web_path in phpfspot_cfg");
-
- if(!isset($this->thumb_path) || $this->thumb_path == "")
- $this->showError("Please set \$thumb_path in phpfspot_cfg");
-
- if(!isset($this->smarty_path) || $this->smarty_path == "")
- $this->showError("Please set \$smarty_path in phpfspot_cfg");
-
- if(!isset($this->fspot_db) || $this->fspot_db == "")
- $this->showError("Please set \$fspot_db in phpfspot_cfg");
-
- if(!isset($this->db_access) || $this->db_access == "")
- $this->showError("Please set \$db_access in phpfspot_cfg");
-
- if(!isset($this->phpfspot_db) || $this->phpfspot_db == "")
- $this->showError("Please set \$phpfspot_db in phpfspot_cfg");
-
- if(!isset($this->thumb_width) || $this->thumb_width == "")
- $this->showError("Please set \$thumb_width in phpfspot_cfg");
-
- if(!isset($this->thumb_height) || $this->thumb_height == "")
- $this->showError("Please set \$thumb_height in phpfspot_cfg");
-
- if(!isset($this->photo_width) || $this->photo_width == "")
- $this->showError("Please set \$photo_width in phpfspot_cfg");
-
- if(!isset($this->mini_width) || $this->mini_width == "")
- $this->showError("Please set \$mini_width in phpfspot_cfg");
-
- if(!isset($this->thumbs_per_page))
- $this->showError("Please set \$thumbs_per_page in phpfspot_cfg");
-
- if(!isset($this->path_replace_from) || $this->path_replace_from == "")
- $this->showError("Please set \$path_replace_from in phpfspot_cfg");
-
- if(!isset($this->path_replace_to) || $this->path_replace_to == "")
- $this->showError("Please set \$path_replace_to in phpfspot_cfg");
-
- if(!isset($this->hide_tags))
- $this->showError("Please set \$hide_tags in phpfspot_cfg");
-
- if(!isset($this->theme_name))
- $this->showError("Please set \$theme_name in phpfspot_cfg");
-
- if(!isset($this->logging))
- $this->showError("Please set \$logging in phpfspot_cfg");
-
- if(isset($this->logging) && $this->logging == 'logfile') {
-
- if(!isset($this->log_file))
- $this->showError("Please set \$log_file because you set logging = log_file in phpfspot_cfg");
-
- if(!is_writeable($this->log_file))
- $this->showError("The specified \$log_file ". $log_file ." is not writeable!");
-
- }
-
- if(isset($this->error_found) && $this->error_found)
- exit(1);
-
- /* check for pending slash on web_path */
- if(!preg_match("/\/$/", $this->web_path))
- $this->web_path.= "/";
} // __construct()
- private function showError($text)
- {
- print $text ."<br />\n";
- $this->error_found = 1;
-
- } // showError()
-
-}
+} // class PHPFSPOT_CFG
?>