/*************************************************************************************
* Script: PicPick *
* Firm: NFec *
* Author: Nicolas Fischer (nf@nfec.de) *
* Date of creation: 2003-08-22 *
* Description: This file(index.php4) is the complete galleryscript, it includes *
* everything! It's complete based on functions. *
* You need simply fillin some informations into the variables the *
* config-part of this script below the changes-section, like this: *
* $pagetitle = "fillin the pagetitle here"; *
* *
* What what is this script good for? *
* Very simple to explain. It will build a dynamic gallery with *
* thumbnails-support. Every image of the types JPEG and PNG which is in*
* the same directory like this index.php4 will be shown as a thumb in *
* the gallery. If you click on it it will be resized to a specail size *
* and gets displayed in a popup window. *
* *
* Is it possibel to rename the index.php4? *
* Yes! Will operate in every PHP supportet filename. *
**************************************************************************************
* Changes:
Author | Date | Version
Nicolas Fischer 2003-08-22 0.1
Nicolas Fischer 2003-08-23 0.2
Nicolas Fischer 2003-09-17 0.3
Nicolas Fischer 2003-09-18 0.4
**************************************************************************************/
//CONFIGURATION
/*
Some infos about this site(gallery):
*/
$site["pagetitle"] = "Party.San OpenAir 2005"; //[string] The title which shoud be shown in the top of the webbrowser
$site["decription"] = ""; //[string] Sitedecription
$site["author"] = "Photos TheNewNoize; //[string] the name of the author of this site
$site["keywords"] = ""; //[string] which keywords decribe this gallery/site
/*
Sitedesign:
You need some knowledge about CSS or a bit more luck to setup right || Germans can take a look to: http://selfhtml.teamone.de/navigation/css.htm
*/
$site["style"] = "
table {
white-space: normal;
}
tr {
white-space: normal;
}
td {
white-space: normal;
}
table.thumbs {
border: 0px solid #000000;
border-right-width: 30px;
border-top-width:5px;
padding: 0px;
margin:0px;
white-space: normal;
}
td.info {
font-weight: bold;
padding: 0px;
margin:0px;
}
td.nav {
border-top: 2px solid #000000;
letter-spacing: 2px;
}
img.thumb {
border: 1px solid #000000;
}
.header {
font-family: arial;
font-size: x-large;
font-decoration: underline;
letter-spacing: 2px;
}
";
/*
Gallery spezific informations:
*/
$ppp = "12"; //[interger] The number how mutch [p]ictures [p]er [p]age should be shown
/*
You have to fillin a least one value for $thumb and $image. If you want a fixed width
and dynamic heigth, you need only to put a value in $thumb[width] = ""; for example.
If you need a absolut fixed width and heigth put a value in each variable. Hope you know
that is's very possible that the images and thumbs won't be proportional in width an height!
*/
$thumb["width"] = ""; //[integer]
$thumb["height"] = "150"; //[integer]
$image["width"] = ""; //[integer]
$image["height"] = "800"; //[integer]
/*
Upload:
If you want to use these feature. Else you have to manage everything but FTP or WebDAV.
Don't forget to set the mode to 777 for the directory where PicPick is placed!
*/
$upload["enable"] = "false"; //[true/false] Do you want to enable the uploadfunction
$upload["show"] = "false"; //[true/false]Do you want to show the link to uploadsection? Else you have to go directly to the URL: index.php4?mode=upload
$upload["pwd"] = ""; //[string]Set here the password to secure the uploadfunction
//-----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*
*/
//Securecheck
if(!$thumb["width"] AND !$thumb["height"]){DIE("You forgot to setup some resolution for the thumbnails in the config-part of PicPick!");}
if(!$image["width"] AND !$thumb["height"]){DIE("You forgot to setup some resolution for the images in the config-part of PicPick!");}
if(!$ppp){DIE("You forgot to setup a value for PicturePerPage!");}
class image_proc
{
var $type;
function open($file)
{
global $type;
if(function_exists(exif_imagetype) == true)
{
$type = exif_imagetype($file); //get the imagetype with exif-support
}
else
{
if(strrchr(strtolower($file),".") == ".jpg")
{$type = 1;}
elseif(strrchr(strtolower($file),".") == ".jpeg")
{$type = 1;}
elseif(strrchr(strtolower($file),".") == ".png")
{$type = 2;}
else
{$type = "not supportet";}
}
switch($type)
{
case 1:
$im = @ImageCreateFromJPEG ($file); //open the file to editmode
if(!$im){DIE("It went into hell!");}
break;
case 2:
$im = @ImageCreateFromJPEG ($file); //open the file to editmode
if(!$im){DIE("It went into hell!");}
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)
{
$im = $this->open($file);
//get some infos about the original
$origwidth = imagesx($im);
$origheight = imagesy($im);
//calculation for the new data
if($tnx == "dynamic")
{$tnx = $origwidth/($origheight/$tny);}
if($tny == "dynamic")
{$tny = $origheight/($origwidth/$tnx);}
//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);
}
}
//need this function to build the general xhtmloutput
function page_start($site, $count_pics, $last, $i, $prev, $next, $ppp, $popup_w, $popup_h)
{
include('http://www.party-san.de/openair/overall_header.php');
echo "
\n
$site[pagetitle] |
";
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
echo " |
$site[author] |
Images: ".($last+1)."...".($i)."/".$count_pics." | Page No. ".($last/$ppp+1)." |
$prev | $next |
|
";
}
//need this function to build the general xhtmloutput
function page_end($count_pics, $ppp, $prev, $next, $upload)
{
$pagecount =ceil($count_pics / $ppp);
for($i=1;$i<=$pagecount;$i++)
{
$lastpic = ($ppp*($i-1));
$pages .= "$i|";
}
if($upload["show"]=="true")
{$upload_show = "upload";}
else{$upload_show = " ";}
echo "
|
$upload_show | Jump to page: $pages | $prev | $next |
|
";
include('http://www.party-san.de/openair/overall_footer.php');
}
//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);
}
}
return $images;
}
//some setups for the popup
$popup_w = $image["width"];
$popup_h = $image["height"];
//Calculation for the right resolution
if(!$thumb["width"]){$thumb["width"] = "dynamic";}
if(!$thumb["height"]){$thumb["height"] = "dynamic";}
if(!$image["width"]){$image["width"] = "dynamic"; $popup_w = $image["height"];}
if(!$image["height"]){$image["height"] = "dynamic"; $popup_h = $image["width"];}
//OPERATEMODES
switch($_GET[mode])
{
case thumb:
$image_cl = new image_proc;
$image_cl->resize(urldecode($_GET[selected]), $thumb["width"], $thumb["height"]);
break;
case image:
$image_cl = new image_proc;
$image_cl->resize(urldecode($_GET[selected]), $image["width"], $image["height"]);
break;
case upload:
if($upload["enable"]=="true")
{
switch($_GET[step])
{
//Building the uploadform
case 1:
if($_POST[upld_pwd] == $upload["pwd"])
{
print page_start($site, $count_pics, $last, $i, $prev, $next, $ppp, $popup_w, $popup_h);
echo "
\n";
print page_end($count_pics, $ppp, $prev, $next, $upload);
}
else{DIE("Bad password! Go back!");}
break;
//Upload!
case 2:
if($_POST[upld_pwd] == $upload["pwd"])
{
print page_start($site, $count_pics, $last, $i, $prev, $next, $ppp, $popup_w, $popup_h);
echo "\n";
for($i=1;$i<=$_POST[count_upld];$i++)
{
if(!empty($HTTP_POST_FILES["image".$i][name]) AND (($HTTP_POST_FILES["image".$i][type] == "image/png") OR ($HTTP_POST_FILES["image".$i][type] == "image/jpeg")))
{
$dir = ".";
if(@copy($HTTP_POST_FILES["image".$i][tmp_name],"$dir/".$HTTP_POST_FILES["image".$i][name]))
{
echo "Picture: ".$HTTP_POST_FILES["image".$i][name];
echo "
";
echo "Filesize: ".$HTTP_POST_FILES["image".$i][size]." Byte
";
}
else
{ echo "I got an error with ".$HTTP_POST_FILES["image".$i][name]."
";}
}
}
echo "
Back to the gallery | Upload more\n";
print page_end($count_pics, $ppp, $prev, $next, $upload);
}
else{DIE("Bad password! Go back!");}
break;
//Asking how many images should be uploaded and for the password
default:
print page_start($site, $count_pics, $last, $i, $prev, $next, $ppp, $popup_w, $popup_h);
echo "
\n";
print page_end($count_pics, $ppp, $prev, $next, $upload);
}
break;
}
break;
default:
if(!$_GET[last]){$i=0;}
else
{
$i=$_GET[last];
$last = $_GET[last];
}
$images = read_dir();
$count_pics = count($images);
while(($i
\n";
$i++;
}
//previous, next page...
if(($last-$ppp) < 0){$last_prev = 0;}
else{$last_prev = $last-$ppp;}
if($last == count($images)){$last_next = $last;}
else{$last_next= $last+$ppp;}
if($last >= $ppp)
{$prev = "Prev";}
if(count($images) > $last_next)
{$next = "Next\n";}
//Build the page
print page_start($site, $count_pics, $last, $i, $prev, $next, $ppp, $popup_w, $popup_h);
print $xhtml_thumbs;
print page_end($count_pics, $ppp, $prev, $next, $upload);
break;
}
?>