X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=phpfspot.git;a=blobdiff_plain;f=phpfspot.class.php;h=6c150fa6c70ca9c97862ffb9c6d0a49ef55b1b23;hp=f88ddf815b9cd1a66fa3045ca8ba3bc2c561eeb2;hb=3e95994d0452a1f24f03c75774b94fbec71aebdd;hpb=360821514a97c946ab0ae66a2677380ad72bd794
diff --git a/phpfspot.class.php b/phpfspot.class.php
index f88ddf8..6c150fa 100644
--- a/phpfspot.class.php
+++ b/phpfspot.class.php
@@ -23,7 +23,6 @@
require_once "phpfspot_cfg.php";
require_once "phpfspot_db.php";
-require_once "phpfspot_tmpl.php";
class PHPFSPOT {
@@ -43,13 +42,17 @@ class PHPFSPOT {
*/
public function __construct()
{
+ $this->cfg = new PHPFSPOT_CFG;
+
+ /* set application name and version information */
+ $this->cfg->product = "phpfspot";
+ $this->cfg->version = "1.1";
+
/* Check necessary requirements */
if(!$this->checkRequirements()) {
exit(1);
}
- $this->cfg = new PHPFSPOT_CFG;
-
$this->db = new PHPFSPOT_DB($this, $this->cfg->fspot_db);
if(!is_writeable(dirname($this->cfg->phpfspot_db))) {
@@ -64,7 +67,13 @@ 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";
$this->tmpl = new PHPFSPOT_TMPL($this);
$this->get_tags();
@@ -1161,7 +1170,7 @@ class PHPFSPOT {
foreach($resolutions as $resolution) {
$thumb_sub_path = substr($file_md5, 0, 2);
- $thumb_path = $this->cfg->base_path ."/thumbs/". $thumb_sub_path ."/". $resolution ."_". $file_md5;
+ $thumb_path = $this->cfg->thumb_path ."/". $thumb_sub_path ."/". $resolution ."_". $file_md5;
if(!file_exists(dirname($thumb_path))) {
mkdir(dirname($thumb_path), 0755);
@@ -1669,7 +1678,7 @@ class PHPFSPOT {
-
+
getMD5($photo), 0, 2);
- return $this->cfg->base_path
- . "/thumbs/"
+ return $this->cfg->thumb_path
+ . "/"
. $sub_path
. "/"
. $width
@@ -1942,6 +1951,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()
}