+ public function startTagSearch($searchfor)
+ {
+ $_SESSION['searchfor'] = $searchfor;
+ $_SESSION['selected_tags'] = Array();
+
+ foreach($this->avail_tags as $tag) {
+ if(preg_match('/'. $searchfor .'/i', $this->tags[$tag]))
+ array_push($_SESSION['selected_tags'], $tag);
+ }
+
+ } // startTagSearch()
+
+ private function rotateImage($img, $degrees)
+ {
+ if(function_exists("imagerotate"))
+ $img = imagerotate($img, $degrees, 0);
+ else
+ {
+ function imagerotate($src_img, $angle)
+ {
+ $src_x = imagesx($src_img);
+ $src_y = imagesy($src_img);
+ if ($angle == 180) {
+ $dest_x = $src_x;
+ $dest_y = $src_y;
+ }
+ elseif ($src_x <= $src_y) {
+ $dest_x = $src_y;
+ $dest_y = $src_x;
+ }
+ elseif ($src_x >= $src_y) {
+ $dest_x = $src_y;
+ $dest_y = $src_x;
+ }
+
+ $rotate=imagecreatetruecolor($dest_x,$dest_y);
+ imagealphablending($rotate, false);
+
+ switch ($angle) {
+
+ case 90:
+ for ($y = 0; $y < ($src_y); $y++) {
+ for ($x = 0; $x < ($src_x); $x++) {
+ $color = imagecolorat($src_img, $x, $y);
+ imagesetpixel($rotate, $dest_x - $y - 1, $x, $color);
+ }
+ }
+ break;
+
+ case 270:
+ for ($y = 0; $y < ($src_y); $y++) {
+ for ($x = 0; $x < ($src_x); $x++) {
+ $color = imagecolorat($src_img, $x, $y);
+ imagesetpixel($rotate, $y, $dest_y - $x - 1, $color);
+ }
+ }
+ break;
+
+ case 180:
+ for ($y = 0; $y < ($src_y); $y++) {
+ for ($x = 0; $x < ($src_x); $x++) {
+ $color = imagecolorat($src_img, $x, $y);
+ imagesetpixel($rotate, $dest_x - $x - 1, $dest_y - $y - 1, $color);
+ }
+ }
+ break;
+
+ default: $rotate = $src_img;
+ };
+
+ return $rotate;
+
+ }
+
+ $img = imagerotate($img, $degrees);
+
+ }
+
+ return $img;
+
+ } // rotateImage()
+
+ private function get_photo_tags($idx)
+ {
+ $result = $this->db->db_query("
+ SELECT t.id, t.name
+ FROM tags t
+ INNER JOIN photo_tags pt
+ ON t.id=pt.tag_id
+ WHERE pt.photo_id='". $idx ."'
+ ");
+
+ $tags = Array();
+
+ while($row = $this->db->db_fetch_object($result))
+ $tags[$row['id']] = $row['name'];
+
+ return $tags;
+
+ } // get_photo_tags()
+
+ public function showTextImage($txt, $color=000000, $space=4, $font=4, $w=300)
+ {
+ if (strlen($color) != 6)
+ $color = 000000;
+
+ $int = hexdec($color);
+ $h = imagefontheight($font);
+ $fw = imagefontwidth($font);
+ $txt = explode("\n", wordwrap($txt, ($w / $fw), "\n"));
+ $lines = count($txt);
+ $im = imagecreate($w, (($h * $lines) + ($lines * $space)));
+ $bg = imagecolorallocate($im, 255, 255, 255);
+ $color = imagecolorallocate($im, 0xFF & ($int >> 0x10), 0xFF & ($int >> 0x8), 0xFF & $int);
+ $y = 0;
+
+ foreach ($txt as $text) {
+ $x = (($w - ($fw * strlen($text))) / 2);
+ imagestring($im, $font, $x, $y, $text, $color);
+ $y += ($h + $space);
+ }
+
+ Header("Content-type: image/png");
+ ImagePng($im);
+
+ } // showTextImage()
+
+ private function checkRequirements()
+ {
+ if(!function_exists("imagecreatefromjpeg")) {
+ print "PHP GD library extension is missing<br />\n";
+ $missing = true;
+ }
+
+ if(!function_exists("sqlite3_open")) {
+ print "PHP SQLite3 library extension is missing<br />\n";
+ $missing = true;
+ }
+
+ /* Check for HTML_AJAX PEAR package, lent from Horde project */
+ ini_set('track_errors', 1);
+ @include_once 'HTML/AJAX/Server.php';
+ if(isset($php_errormsg)) {
+ print "PEAR HTML_AJAX package is missing<br />\n";
+ $missing = true;
+ }
+ ini_restore('track_errors');
+
+ if(isset($missing))
+ return false;
+
+ return true;
+
+ } // checkRequirements()
+
+ private function _debug($text)
+ {
+ if($this->fromcmd) {
+ print $text;
+ }
+
+ } // _debug()
+
+ public function checkifImageSupported($mime)
+ {
+ if(in_array($mime, Array("image/jpeg")))
+ return true;
+
+ return false;
+
+ } // checkifImageSupported()
+