Gallery

open($file); // get some infos about the original $origwidth = imagesx($im); $origheight = imagesy($im); // calculation for the new data if($tny == "") { $tny = $origheight/($origwidth/$tnx); } if($tnx == "") { $tnx = $origwidth/($origheight/$tny); } // lets make a thumb and resize $im_new = imageCreateTrueColor($tnx, $tny); if ($img_quality == "resample") imageCopyResampled($im_new,$im,"0","0","0","0",$tnx,$tny,$origwidth,$origheight); else imageCopyResized($im_new,$im,"0","0","0","0",$tnx,$tny,$origwidth,$origheight); header("Content-type: image/jpg"); Imagejpeg($im_new); } function output($file, $tnx="", $tny="") { $im = $this->open($file); // get some infos about the original $origwidth = imagesx($im); $origheight = imagesy($im); // calculation for the new data if($tny == "") { $tny = $origheight/($origwidth/$tnx); } if($tnx == "") { $tnx = $origwidth/($origheight/$tny); } // lets make a thumb and resize $im_new = imageCreateTrueColor($tnx, $tny); imagecopyresized($im_new,$im,"0","0","0","0",$tnx,$tny,$origwidth,$origheight); // header("Content-type: image/jpg"); Imagejpeg($im_new); } function getHeight($file,$image_width,$image_height) { if($image_width > 0 && $image_height > 0) { $new['height'] = $image_height; $new['width'] = $image_width; return $new; } $im = $this->open($file); $oheight = imagesy($im); $owidth = imagesx($im); if ($image_width > $owidth) { $image_width = $owidth; } if ($image_height > $oheight) { $image_height = $oheight; } if($image_width > 0) { $new['width'] = $image_width; $new['height'] = ceil($oheight/($owidth/$image_width)); return $new; } if($image_height > 0) { $new['width'] = $owidth/($oheight/$image_height); $new['height'] = $image_height; return $new; } return $new; } } // collect all images in this directory function read_dir() { $path = $_SERVER['DOCUMENT_ROOT'] . GALLERY_DIR; $cdir = dir($path); //while($entry = $cdir->read()) while (false !== ($entry = $cdir->read())) { if((!is_dir($entry)) AND ((strrchr(strtolower($entry),".") == ".jpg") OR (strrchr(strtolower($entry),".") == ".jpeg") OR (strrchr(strtolower($entry),".") == ".png") OR (strrchr(strtolower($entry),".") == ".gif"))) { $images[] = urlencode($entry); } } sort($images); ksort($images); return $images; } function get_caption ($filename) { $cap = file($_SERVER['DOCUMENT_ROOT'] . GALLERY_DIR . 'captions.txt'); foreach($cap as $val) { if (strstr($val,$filename)) { $capLen = strlen($val); $filLen = strlen($filename) + 1; $tehCap = substr($val, $filLen, $capLen); return $tehCap; } } return NULL; } if($text_display == "caption") { $captions = file($_SERVER['DOCUMENT_ROOT'] . GALLERY_DIR . 'captions.txt'); foreach($captions as $captiona) { list($key,$val) = explode("|",$captiona); $caption[$key] = $val; } } else { $caption = NULL; } //OPERATEMODES switch($_GET[mode]) { case download: $filename = $_GET['selected']; header ("Content-type: octet/stream"); if (strstr($_SERVER["HTTP_USER_AGENT"], "MSIE")) header("Content-Disposition: filename=" . $filename); // For IE else header("Content-Disposition: attachment; filename=" . $filename); // For Other browsers readfile($filename); break; case thumb: $image_cl = new image_proc; $image_cl->resize(urldecode($_GET[selected]), $thumb['width'], $thumb['height'],$img_quality); break; default: $page = isset($_GET['page']) ? $_GET['page'] : 1; @$i = ($page - 1) * $ppp; $images = read_dir(); $current_image = $images[$i]; $image_c2 = new image_proc(); $num_images = count($images); $num_pages = ceil($num_images / $ppp); $col_width = 100/$cols . "%"; $zcol = 0; $xhtml_thumbs = "\n\n"; while(($i < $num_images) && $i < ($page * $ppp)) { // $images[$i] = urlencode($images[$i]); if($text_display == "filename") { $caption[$images[$i]] = $images[$i]; } $galName = str_replace("/", "", dirname(DIR_WS_TEMPLATES . DIR_TEMPLATE . 'tpl_gallery_default.php')); $image['width'] = "500"; //[integer] Image width $image['height'] = ""; //[integer] Image height $dimensions = $image_c2->getHeight($images[$i],$image['width'],$image['height']); $orig_width = $dimensions['width']; $orig_height = $dimensions['height']; $xhtml_thumbs .= "\n"; $i++; $zcol++; if(($zcol >= $cols) && ($i < ($page * $ppp))) { $xhtml_thumbs .= "\n\n"; $zcol = 0; } } $xhtml_thumbs .= "\n
\n"; $wert=explode('.', $caption[$images[$i]]); $xhtml_thumbs .= "\n"; if($caption_thumb == 1) { $xhtml_thumbs .= "
" . $wert[0] . "
\n"; } $xhtml_thumbs .= "
\n"; // Pagination $next = $page + 1; $prev = $page - 1; $nav_string = "\n\n\n
"; // Page $page of $num_pages :: "; if($num_pages > 1) { $current_url='index.php?main_page=gallery'; if (strpos($current_url, '?')){$cong='&';} else {$cong='?';} if($page == 1) $nav_string .= " | "; else $nav_string .= " | "; for($pnav = 1; $pnav <= $num_pages; $pnav++) { if($pnav == 1 && $pnav == $page) $nav_string .= $pnav; elseif ($pnav == 1 && $pnav != $page) $nav_string .= " $pnav "; elseif ($pnav == $num_pages && $pnav == $page) $nav_string .= $pnav; elseif ($pnav == $num_pages && $pnav != $page) $nav_string .= " $pnav "; elseif($pnav == $page) { if ($nav_disp == "dots") $nav_string .= " . "; else $nav_string .= " $pnav "; } else { if ($nav_disp == "dots") $nav_string .= " . "; else /*$nav_string .= "