+ /**
+ * validates provided date
+ *
+ * this function validates if the provided date
+ * contains a valid date and will return true
+ * if it is.
+ */
+ public function isValidDate($date_str)
+ {
+ $timestamp = strtotime($date_str);
+
+ if(is_numeric($timestamp))
+ return true;
+
+ return false;
+
+ } // isValidDate()
+
+ /**
+ * timestamp to string conversion
+ */
+ private function ts2str($timestamp)
+ {
+ return strftime("%Y-%m-%d", $timestamp);
+ } // ts2str()
+
+ private function extractTags($tags_str)
+ {
+ $not_validated = split(',', $_GET['tags']);
+ $validated = array();
+
+ foreach($not_validated as $tag) {
+ if(is_numeric($tag))
+ array_push($validated, $tag);
+ }
+
+ return $validated;
+
+ } // extractTags()
+
+ /**
+ * returns the full path to a thumbnail
+ */
+ public function get_thumb_path($width, $photo)
+ {
+ $md5 = $this->getMD5($photo);
+ $sub_path = substr($md5, 0, 2);
+ return $this->cfg->thumb_path
+ . "/"
+ . $sub_path
+ . "/"
+ . $width
+ . "_"
+ . $md5;
+
+ } // get_thumb_path()
+
+ /**
+ * returns server's virtual host name
+ */
+ private function get_server_name()
+ {
+ return $_SERVER['SERVER_NAME'];
+ } // get_server_name()
+
+ /**
+ * returns type of webprotocol which is
+ * currently used
+ */
+ private function get_web_protocol()
+ {
+ if(!isset($_SERVER['HTTPS']))
+ return "http";
+ else
+ return "https";
+ } // get_web_protocol()
+
+ /**
+ * return url to this phpfspot installation
+ */
+ private function get_phpfspot_url()
+ {
+ 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()
+
+ /**
+ * check if all needed indices are present
+ *
+ * this function checks, if some needed indices are already
+ * present, or if not, create them on the fly. they are
+ * necessary to speed up some queries like that one look for
+ * all tags, when show_tags is specified in the configuration.
+ */
+ private function checkDbIndices()
+ {
+ $result = $this->db->db_exec("
+ CREATE INDEX IF NOT EXISTS
+ phototag
+ ON
+ photo_tags
+ (photo_id, tag_id)
+ ");
+
+ } // checkDbIndices()
+
+ /**
+ * retrive F-Spot database version
+ *
+ * this function will return the F-Spot database version number
+ * It is stored within the sqlite3 database in the table meta
+ */
+ public function getFspotDBVersion()
+ {
+ if($result = $this->db->db_fetchSingleRow("
+ SELECT data as version
+ FROM meta
+ WHERE
+ name LIKE 'F-Spot Database Version'
+ "))
+ return $result['version'];
+
+ return null;
+
+ } // getFspotDBVersion()
+
+ /**
+ * parse the provided URI and will returned the
+ * requested chunk
+ */
+ public function parse_uri($uri, $mode)
+ {
+ if(($components = parse_url($uri)) !== false) {
+
+ switch($mode) {
+ case 'filename':
+ return basename($components['path']);
+ break;
+ case 'dirname':
+ return dirname($components['path']);
+ break;
+ case 'fullpath':
+ return $components['path'];
+ break;
+ }
+ }
+
+ return $uri;
+
+ } // parse_uri()
+
+} // class PHPFSPOT