diff options
Diffstat (limited to 'phpfspot.class.php')
-rw-r--r-- | phpfspot.class.php | 49 |
1 files changed, 47 insertions, 2 deletions
diff --git a/phpfspot.class.php b/phpfspot.class.php index 525b5c1..6800da2 100644 --- a/phpfspot.class.php +++ b/phpfspot.class.php @@ -121,6 +121,14 @@ class PHPFSPOT { $orig_path = $this->translate_path($details['directory_path']) ."/". $details['name']; $thumb_path = $this->cfg->base_path ."/thumbs/". $this->cfg->photo_width ."_". $this->getMD5($photo); + if(!file_exists($orig_path)) { + print "Photo ". $orig_path ." does not exist!<br />\n"; + } + + if(!is_readable($orig_path)) { + print "Photo ". $orig_path ." is not readable for user ". get_current_user() ."<br />\n"; + } + /* If the thumbnail doesn't exist yet, try to create it */ if(!file_exists($thumb_path)) { $this->gen_thumb($photo, 0, 1); @@ -431,13 +439,24 @@ class PHPFSPOT { $direction = "bubbleimg_down"; $details = $this->get_photo_details($photo); + $orig_path = $this->translate_path($details['directory_path']) ."/". $details['name']; $image_url = "phpfspot_img.php?idx=". $photo ."&width=". $this->cfg->bubble_width; - $filesize = filesize($this->translate_path($details['directory_path']) ."/". $details['name']); + $filesize = filesize($orig_path); $filesize = rand($filesize/1024, 2); - $img = getimagesize($this->translate_path($details['directory_path']) ."/". $details['name']); + if(!file_exists($orig_path)) { + print "Photo ". $orig_path ." does not exist!<br />\n"; + return; + } + + if(!is_readable($orig_path)) { + print "Photo ". $orig_path ." is not readable for user ". get_current_user() ."<br />\n"; + return; + } + + $img = getimagesize($orig_path); $this->tmpl->assign('file_size', $filesize); $this->tmpl->assign('width', $img[0]); @@ -755,6 +774,32 @@ class PHPFSPOT { } // get_photo_tags() + 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() + } ?> |