X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=phpfspot.git;a=blobdiff_plain;f=phpfspot.class.php;h=85d276e104d29a09a792cae3b5f59d004f83017c;hp=bfe415534e1aab68de5b786f1db3f4deed4498e9;hb=b8e94789af7969321cd895d1cef5d175074afcbb;hpb=cd94f8e46b565a4528dda5ddb602918f0bf13896
diff --git a/phpfspot.class.php b/phpfspot.class.php
index bfe4155..85d276e 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,9 +47,23 @@ 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.2";
+ $this->cfg->version = "1.3";
+
+ $this->sort_orders= array(
+ 'date_asc' => 'Date ↑',
+ 'date_desc' => 'Date ↓',
+ 'name_asc' => 'Name ↑',
+ 'name_desc' => 'Name ↓',
+ 'tags_asc' => 'Tags ↑',
+ 'tags_desc' => 'Tags ↓',
+ );
/* Check necessary requirements */
if(!$this->checkRequirements()) {
@@ -63,15 +79,21 @@ class PHPFSPOT {
$this->dbver = $this->getFspotDBVersion();
if(!is_writeable(dirname($this->cfg->phpfspot_db))) {
- print dirname($this->cfg->phpfspot_db) .": directory is not writeable!";
+ print dirname($this->cfg->phpfspot_db) .": directory is not writeable for user ". $this->getuid() ."\n";
exit(1);
}
-
+
+ if(!is_writeable($this->cfg->base_path ."/templates_c")) {
+ print $this->cfg->base_path ."/templates_c: directory is not writeable for user ". $this->getuid() ."\n";
+ exit(1);
+ }
+
$this->cfg_db = new PHPFSPOT_DB($this, $this->cfg->phpfspot_db);
if(!is_writeable($this->cfg->phpfspot_db)) {
print $this->cfg->phpfspot_db ." is not writeable for user ". $this->getuid() ."\n";
exit(1);
}
+
$this->check_config_table();
/* include Smarty template engine */
@@ -86,19 +108,21 @@ class PHPFSPOT {
/* check if all necessary indices exist */
$this->checkDbIndices();
- session_start();
+ /* if session is not yet started, do it now */
+ if(session_id() == "")
+ session_start();
if(!isset($_SESSION['tag_condition']))
$_SESSION['tag_condition'] = 'or';
if(!isset($_SESSION['sort_order']))
- $_SESSION['sort_order'] = 'date_asc';
+ $_SESSION['sort_order'] = 'date_desc';
- if(!isset($_SESSION['searchfor']))
- $_SESSION['searchfor'] = '';
+ if(!isset($_SESSION['searchfor_tag']))
+ $_SESSION['searchfor_tag'] = '';
- // if begin_with is still set but rows_per_page is now 0, unset it
- if(isset($_SESSION['begin_with']) && $this->cfg->rows_per_page == 0)
+ // if begin_with is still set but thumbs_per_page is now 0, unset it
+ if(isset($_SESSION['begin_with']) && $this->cfg->thumbs_per_page == 0)
unset($_SESSION['begin_with']);
} // __construct()
@@ -119,7 +143,7 @@ class PHPFSPOT {
*/
public function show()
{
- $this->tmpl->assign('searchfor', $_SESSION['searchfor']);
+ $this->tmpl->assign('searchfor_tag', $_SESSION['searchfor_tag']);
$this->tmpl->assign('page_title', $this->cfg->page_title);
$this->tmpl->assign('current_condition', $_SESSION['tag_condition']);
$this->tmpl->assign('template_path', 'themes/'. $this->cfg->theme_name);
@@ -150,10 +174,10 @@ class PHPFSPOT {
$_SESSION['start_action'] = 'showp';
}
if(isset($_GET['from_date']) && $this->isValidDate($_GET['from_date'])) {
- $_SESSION['from_date'] = strtotime($_GET['from_date']);
+ $_SESSION['from_date'] = strtotime($_GET['from_date'] ." 00:00:00");
}
if(isset($_GET['to_date']) && $this->isValidDate($_GET['to_date'])) {
- $_SESSION['to_date'] = strtotime($_GET['to_date']);
+ $_SESSION['to_date'] = strtotime($_GET['to_date'] ." 23:59:59");
}
break;
case 'export':
@@ -183,9 +207,9 @@ class PHPFSPOT {
if(isset($_SESSION['from_date']) && isset($_SESSION['to_date']))
$this->tmpl->assign('date_search_enabled', true);
+ $this->tmpl->register_function("sort_select_list", array(&$this, "smarty_sort_select_list"), false);
$this->tmpl->assign('from_date', $this->get_calendar('from'));
$this->tmpl->assign('to_date', $this->get_calendar('to'));
- $this->tmpl->assign('sort_field', $this->get_sort_field());
$this->tmpl->assign('content_page', 'welcome.tpl');
$this->tmpl->show("index.tpl");
@@ -417,10 +441,12 @@ class PHPFSPOT {
if(!file_exists($orig_path)) {
$this->_error("Photo ". $orig_path ." does not exist!
\n");
+ return;
}
if(!is_readable($orig_path)) {
$this->_error("Photo ". $orig_path ." is not readable for user ". $this->getuid() ."
\n");
+ return;
}
/* If the thumbnail doesn't exist yet, try to create it */
@@ -455,30 +481,29 @@ class PHPFSPOT {
$this->tmpl->assign('extern_link', $extern_link);
- if(file_exists($thumb_path)) {
+ if(!file_exists($thumb_path)) {
+ $this->_error("Can't open file ". $thumb_path ."\n");
+ return;
+ }
- $info = getimagesize($thumb_path);
+ $info = getimagesize($thumb_path);
- $this->tmpl->assign('description', $details['description']);
- $this->tmpl->assign('image_name', $this->parse_uri($details['uri'], 'filename'));
+ $this->tmpl->assign('description', $details['description']);
+ $this->tmpl->assign('image_name', $this->parse_uri($details['uri'], 'filename'));
- $this->tmpl->assign('width', $info[0]);
- $this->tmpl->assign('height', $info[1]);
- $this->tmpl->assign('ExifMadeOn', $meta_date);
- $this->tmpl->assign('ExifMadeWith', $meta_make);
- $this->tmpl->assign('ExifOrigResolution', $meta_res);
- $this->tmpl->assign('ExifFileSize', $meta_size);
-
- $this->tmpl->assign('image_url', 'phpfspot_img.php?idx='. $photo ."&width=". $this->cfg->photo_width);
- $this->tmpl->assign('image_url_full', 'phpfspot_img.php?idx='. $photo);
+ $this->tmpl->assign('width', $info[0]);
+ $this->tmpl->assign('height', $info[1]);
+ $this->tmpl->assign('ExifMadeOn', $meta_date);
+ $this->tmpl->assign('ExifMadeWith', $meta_make);
+ $this->tmpl->assign('ExifOrigResolution', $meta_res);
+ $this->tmpl->assign('ExifFileSize', $meta_size);
+
+ $this->tmpl->assign('image_url', 'phpfspot_img.php?idx='. $photo ."&width=". $this->cfg->photo_width);
+ $this->tmpl->assign('image_url_full', 'phpfspot_img.php?idx='. $photo);
+ $this->tmpl->assign('image_filename', $this->parse_uri($details['uri'], 'filename'));
- $this->tmpl->assign('tags', $this->get_photo_tags($photo));
- $this->tmpl->assign('current', $current);
- }
- else {
- $this->_error("Can't open file ". $thumb_path ."\n");
- return;
- }
+ $this->tmpl->assign('tags', $this->get_photo_tags($photo));
+ $this->tmpl->assign('current', $current);
if($previous_img) {
$this->tmpl->assign('previous_url', "javascript:showImage(". $previous_img .");");
@@ -495,6 +520,8 @@ class PHPFSPOT {
$this->tmpl->show("single_photo.tpl");
+ print "\n";
+
} // showPhoto()
/**
@@ -506,6 +533,7 @@ class PHPFSPOT {
*/
public function getAvailable