//CONFIGURATION
// DON'T USE THIS ANY MORE
//$full_path = "http://www.xavier-llongueras.com/";
// DON'T USE THIS ANY MORE
$show_nav = "none";
//Options are "above", "below", "both", or "none" to determine if the page navigation appears above the
//thumbnails, below them, or both.
$show_download_button = "0";
$show_gal_title = "0";
$show_image_name = "0";
$show_image_caption = "0";
$image_caption_pos = "bottom"; // Options are "top" or "bottom";
$right_click_disable = "1";
// 1 for "On", 0 for "Off"
$nav_disp = "numbers";
// Options are "dots" or "numbers" for page identification
$image_alignment = "left";
// Options are "left", "center", and "right"
$thumb_location = "left";
$thumb_alignment = "left";
//Options are "top", "bottom", "left", and "right" to detemine where the thumbnail images are in
//relation to the iFrame containing the full-size images
$img_quality = "resample"; // Options are "resize" or "resample". Resampling looks better but is slower.
$rows = "9";
//[integer] How many rows of thumbnails
$cols = "2";
//[integer] How many columns in each row
$display = "rollover";
//Options are "rollover", "click", and "popup" to determine whether the images display in the iFrame on
//rollover of the thumbnail, in the iFrame on click of the thumbnail, or in a popup window on click of
//the thumbnail.
$text_display = "none";
/*
Options are "filename", "caption", and "none" to determine what text displays underneath the
thumbnail image. If set to "caption," the text will be taken from the file "captions.txt" in
the image directory. That file should have one caption per line, with each line formatted
as filename|caption, as follows:
image01.jpg|This is the text of the caption
image02.jpg|This is the caption for the image named image02.jpg
db345uhsor.jpg|This caption is for the image named db345uhsor.jpg
*/
$site['font_color'] = "#ffffff"; //[color-code] Color for all text on the page.
$site['background_color'] = "#ffffff"; //[color-code] Color for all text on the page.
$site['background_image'] = ""; //[color-code] Color for all text on the page.
$thumb_table['border_width'] = "0"; //[integer] Border width on table surrounding thumbnails. "0" for no border.
$thumb_table['border_color'] = "#ffffff"; //[color-code] Border color on table surrounding thumbnails.
$nav['border_width'] = "0"; //[integer] Border width on table surrounding page navigation. "0" for no border.
$nav['border_color'] = "#000000"; //[color-code] Border color on table surrounding page navigation.
$nav['font-family'] = "Arial";
$nav['font_color'] = "#FFFFFF";
$nav['font-size'] = "small";
$nav['link_decoration'] = "underline";
$thumb['border_width'] = "1"; //[integer] Border width on thumbnail images themselves. "0" for no border.
$thumb['border_color'] = "#5a9063"; //[color-code] Border color on thumbnail images.
$image['border_width'] = "1"; //[integer] Border width on large images. "0" for no border.
$image['border_color'] = "#5a9063"; //[color-code] Border color on large images.
//You must enter either a width or height (or both) for the thumbnails, and at least a width
//for the images.
$thumb['width'] = "50"; //[integer] Thumbnail width
$thumb['height'] = "50"; //[integer] Thumbnail height
$image['width'] = "400"; //[integer] Image width
$image['height'] = ""; //[integer] Image height
$iframe_width = "";
$iframe_height = "";
$image['textheight'] = "15"; // This may need to be set higher if the font sizes below are set higher than "medium"
$image_disp['filename_color'] = "#000000"; //[color-code] font color for image filename display
$image_disp['galname_color'] = "#000000"; //[color-code] font color for gallery name display
$image_disp['filename_fontsize'] = "small"; // Options are "xx-small", "x-small", "small"
$image_disp['galname_fontsize'] = "small"; // "medium", "large", "x-large", "xx-large"
$image_disp['filename_fontweight'] = "normal"; // Options are
$image_disp['galname_fontweight'] = "bold"; // "bold" and "normal"
//CSS Configuration: Don't mess with this if you don't know CSS.
$site['style'] = "
";
$site['javascript'] = "
";
//-----DO NOT EDIT AFTER THIS LINE --------------------------------------------------------------
/*
If you edit some thing something after this line, I hope you know what you are doing, because
sometimes I'm not sure what I did in this scripts too *g* ;) - That's all folks - Don't panik *g*
*/
$ppp = $rows * $cols;
//Securecheck
if(!$thumb['width'] && !$thumb['height'])
{
die("You must set the thumbnail width in the configuration");
}
if(!$image['width'] && !$image['height'])
{
die("You must set the image width in the configuration");
}
if(!$rows || !$cols)
{
die("You must set the rows and columns in the configuration");
}
class image_proc
{
var $type;
function open($file)
{
global $type;
$file = str_replace("+"," ",$file);
if(function_exists(exif_imagetype) == true && exif_imagetype($file) != false)
{
$type = exif_imagetype($file); //get the imagetype with exif-support
}
else
{
if(strrchr(strtolower($file),".") == ".jpg")
$type = 2;
elseif(strrchr(strtolower($file),".") == ".jpeg")
$type = 2;
elseif(strrchr(strtolower($file),".") == ".png")
$type = 3;
elseif(strrchr(strtolower($file),".") == ".gif")
$type = 1;
else
$type = "not supported";
}
// echo "TYPE: \"".$type."\"";
switch($type)
{
case 1:
$im = @ImageCreateFromGIF ($file); //open the file to editmode
if(!$im){DIE("Image creation failed!");}
break;
case 2:
$im = @ImageCreateFromJPEG ($file); //open the file to editmode
if(!$im){DIE("Image creation failed!");}
break;
case 3:
$im = @ImageCreateFromPNG ($file);
if(!$im){DIE("Image creation failed!");}
break;
default:
$im = ImageCreate (150, 30);
$bgc = ImageColorAllocate ($im, 255, 255, 255);
$tc = ImageColorAllocate ($im, 0, 0, 0);
ImageFilledRectangle ($im, 0, 0, 150, 30, $bgc);
ImageString($im, 1, 5, 5, "Can't open image: $file", $tc);
break;
}
return $im;
}
function resize($file, $tnx="", $tny="", $img_qual="resample")
{
global $img_quality;
$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);
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 = dirname(_PATH_TRANSLATED);
$cdir = dir($path);
while($entry = $cdir->read())
{
if((!is_dir($entry)) AND ((strrchr(strtolower($entry),".") == ".jpg") OR (strrchr(strtolower($entry),".") == ".jpeg") OR (strrchr(strtolower($entry),".") == ".png")))
{
$images[] = urlencode($entry);
}
}
sort($images);
return $images;
}
function get_caption ($filename)
{
$cap = file('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('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;
case image:
if(isset($_GET['selected']))
{
if(!isset($_GET['inframe']))
{
$image_cl = new image_proc;
$dimensions = $image_cl->getHeight($_GET['selected'],$image['width'],$image['height']);
$image_cl->resize(urldecode($_GET[selected]), $dimensions['width'], $dimensions['height'], $img_quality);
}
else
{
list($w,$h) = explode("x",$_GET["windowDim"]);
echo "\n";
echo "
\n";
echo $site['style'];
echo $site['javascript'];
echo "\n \n";
echo " \n";
echo " \n";
if ($show_gal_title == "1") {
echo " ".ucfirst($_GET['galname'])." |
\n";
}
if ($show_image_name == "1" || $show_download_button == "1") {
echo " ";
if ($show_image_name == "1")
echo ucfirst($_GET['selected']);
if ($show_download_button == "1")
echo " [ Download ]";
echo " |
\n";
}
if ($show_image_caption == "1" && $image_caption_pos == "top")
{
if (get_caption($_GET['selected']) != NULL)
{
echo "";
echo get_caption($_GET['selected']);
echo " |
\n";
}
}
echo " |
\n";
if ($show_image_caption == "1" && $image_caption_pos == "bottom")
{
if (get_caption($_GET['selected']) != NULL)
{
echo "";
echo get_caption($_GET['selected']);
echo " |
\n";
}
}
echo "
\n";
echo " \n";
echo "\n";
}
}
break;
default:
$page = isset($_GET['page']) ? $_GET['page'] : 1;
@$i = ($page - 1) * $ppp;
if ($iframe_width > 0) {
$frame_width = $iframe_width;
}
else {
$frame_width = $image['width'] + 40;
}
if ($iframe_height > 0) {
$frame_height = $iframe_height;
}
else {
if ($image['height'] > 0)
$frame_height = $image['height'];
else
$frame_height = $frame_width;
}
$popup_width = $image['width'] + 20;
$popup_height = $popup_width;
$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($_SERVER["PHP_SELF"]));
$dimensions = $image_c2->getHeight($images[$i],$image['width'],$image['height']);
$orig_width = $dimensions['width'];
$orig_height = $dimensions['height'];
$popup_width = ceil($orig_width + 20);
$popup_height = ceil($orig_height + 45);
if ($iframe_height == 0)
{
$frame_height = $orig_height;
$new_width = ceil($orig_width + 40);
if($new_width > $frame_width)
{
$frame_width = $new_width;
}
if($new_height > $frame_height)
{
$frame_height = $new_height;
}
$new_width = ceil($orig_width + 40);
$new_height = ceil($orig_height + 40);
if($new_height > $frame_height)
{
$frame_height = $new_height;
}
}
if ($show_gal_title == "1")
{
$popup_height += $image['textheight'];
}
if ($show_image_name == "1")
{
$popup_height += $image['textheight'];
}
$xhtml_thumbs .= "\n";
if($display == "popup")
{
$xhtml_thumbs .= "\n";
if(is_array($caption))
{
$xhtml_thumbs .= " " . $caption[$images[$i]] . " \n";
}
$xhtml_thumbs .= " | \n";
$i++;
$zcol++;
if(($zcol >= $cols) && ($i < ($page * $ppp)))
{
$xhtml_thumbs .= "
\n\n";
$zcol = 0;
}
}
$xhtml_thumbs .= "
\n
\n";
// Pagination
$next = $page + 1;
$prev = $page - 1;
$nav_string = "\n\n\n";
// Page $page of $num_pages :: ";
if($page == 1)
$nav_string .= "<<Previous | ";
else
$nav_string .= "<<Previous | ";
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 .= " $pnav ";
}
}
if($page == $num_pages)
$nav_string .= " | Next>>";
else
$nav_string .= " | Next>>";
$nav_string .= " | \n
\n
\n";
// Build the page
$thumbs_cell = "$xhtml_thumbs | \n";
if($display == "popup")
$iframe_cell = "";
else
$iframe_cell = " | \n";
$body_table = "\n\n";
switch($thumb_location)
{
case "top":
$body_table .= $thumbs_cell . "
\n\n" . $iframe_cell;
break;
case "bottom":
$body_table .= $iframe_cell . "
\n\n" . $thumbs_cell;
break;
case "left":
$body_table .= $thumbs_cell . $iframe_cell;
break;
case "right":
$body_table .= $iframe_cell . $thumbs_cell;
break;
}
$body_table .= "
\n
\n";
echo $site['style'];
echo "".$site['javascript'];
if($show_nav == "above" || $show_nav == "both")
echo $nav_string;
echo $body_table;
if($show_nav == "below" || $show_nav == "both")
echo $nav_string;
break;
}
?>