"; // this is the footer of your album view pages $footer="
Powered by pictelo
"; // this is the header and footer of your single-image view // use _name_ to show the name of the photo $singleViewHeader="

_name_...

"; $singleViewFooter="

Powered by pictelo
"; // don't edit anything below this line :) set_time_limit(0); if($adminpassword=="")die("You need to edit this script and change the admin password from default!"); $colWidth=100/$numCols; if($_POST['password']==$adminpassword) $admin=1; function loadImage($filename, $extension) { $file=$filename; switch ($extension) { case "gif": $source = imagecreatefromgif($file); break; case "jpg": $source = imagecreatefromjpeg($file); break; case "jpeg": $source = imagecreatefromjpeg($file); break; case "png": $source = imagecreatefrompng($file); break; } return $source; } function makeThumbs() { global $totalImages,$thumbnail, $fullsize, $thumbWidth, $thumbHeight, $curImage; $numImages=0; $totalImages=0; $filecounter=0; if ($dir = opendir('.')) { while(false !== ($file = readdir($dir))) { $temp=split("\.", $file); $filename=""; for($count=0;$count0 && $curImage>$filecounter) || $curImage<$startImage) { $filecounter++; continue; } $numImages++; $thumbFilename="./pictelo/".$filename."_thumb.$extension"; $thumbnail[$numImages-1]=$thumbFilename; $fullsize[$numImages-1]=$file; if(!file_exists($thumbFilename) || filemtime($thumbFilename)< filemtime($file)) { list($width, $height) = getimagesize($file); if($width>$thumbWidth) { $ratio=$width/$thumbWidth; if(($height/($ratio))<$thumbHeight) { $newWidth=$width/$ratio; $newHeight=$height/$ratio; } else { $ratio=$height/$thumbHeight; $newWidth=$width/$ratio; $newHeight=$height/$ratio; } } $thumb = imagecreatetruecolor($newWidth, $newHeight); $source = loadImage($file, $extension); imagecopyresampled($thumb, $source, 0, 0, 0, 0, $newWidth, $newHeight, $width, $height); imagejpeg($thumb, $thumbFilename, 75); makeSTF($file); } } } closedir($dir); } return($numImages); } function setStartImage() { global $curImage, $startImage; if(!isset($_GET['start']) || !is_int((int)$_GET['start'])) $curImage=$startImage=0; else $curImage=$startImage=(int)$_GET['start']; } function updateCounter($filename) { $statfile="pictelo/".$filename.".stf"; $fp=fopen($statfile, "rb"); $fdata=split("\|", fread($fp, filesize($statfile))); fclose($fp); $fp=fopen($statfile, "w+b"); $put=((int)$fdata[0]+1)."|{$fdata[1]}|{$fdata[2]}"; fwrite($fp, $put); fclose($fp); } function makeSTF($filename) { $statfile="pictelo/".$filename.".stf"; $newFile=0; if(!file_exists($statfile) || filesize($statfile)==0) $newFile=1; if($newFile) $fp=fopen($statfile, "a+b"); else $fp=fopen($statfile, "r+b"); if($fp) { if($newFile) { $put="0|$filename| "; rewind($fp); fwrite($fp, $put); fclose($fp); } } } function getDetails($filename) { $statfile="pictelo/".$filename.".stf"; if(file_exists($statfile)) { $fp=fopen($statfile, "rb"); $data=fread($fp,filesize($statfile)); return($data); fclose($fp); } return(false); } function showBigPicture($filename) { global $singleViewHeader, $singleViewFooter, $thumbWidth, $thumbHeight, $basic, $imageBorderSize; $statfile="pictelo/".$filename.".stf"; $prevfilename=""; $curfilename=""; $nextfilename=""; $tfn=""; if ($dir2 = opendir('.')) { rewinddir($dir2); while(false !== ($file = readdir($dir2))) { $extension=eregi_replace(".*\.(.*)","\\1", $file); if($extension=="gif" || $extension=="jpg" || $extension=="jpeg" || $extension=="png" && substr(0,1,$file)!=".") { if($file==$filename) { $prevfilename=$tfn; $curfilename=$file; } if($curfilename!="" && $file!=$curfilename) { $nextfilename=$file; break; } $tfn=$file; } } } list($width, $height) = getimagesize($filename); $fp=fopen($statfile, "rb"); $data=fread($fp, filesize($statfile)); $splitdata=split("\|", $data,3); $name=$splitdata[1]; $singleViewHeader=str_replace("_name_", stripslashes($name), $singleViewHeader); $singleViewFooter=str_replace("_name_", stripslashes($name), $singleViewFooter); updateCounter($filename); echo "$singleViewHeader"; echo " "; if($basic!=true) { if($prevfilename!="") { echo "\n"; } else { echo "\n"; } } echo "\n"; if($basic!=true) { if($nextfilename!="") { echo "\n"; } else { echo "\n"; } } echo ""; echo "
"; if($prevfilename!="") { $prevthumb="./pictelo/".eregi_replace("(.*)\..*","\\1", $prevfilename)."_thumb.".eregi_replace(".*\.(.*)","\\1",$prevfilename); if($basic==true) echo "previous"; } echo " "; if($nextfilename!="") { $nextthumb="./pictelo/".eregi_replace("(.*)\..*","\\1", $nextfilename)."_thumb.".eregi_replace(".*\.(.*)","\\1",$nextfilename); if($basic==true) echo "next"; } echo "
       
album index
\n"; echo "$singleViewFooter"; } //showBigPicture("swbl3.gif"); function showAlbum() { global $imageBorderSize,$startImage,$colWidth,$curImage, $admin, $numRows, $numCols, $numImages, $thumbnail, $fullsize,$header,$footer,$albumName,$afterThought; $numImages=makeThumbs(); if($admin==1) echo "
"; echo "\n"; for($row=0;$row<$numRows;$row++) { for($col=0;$col<$numCols;$col++) { $curImage=(($row*$numCols)+($col+1)); if($curImage>$numImages) continue; else { echo " \n"; } } echo "\n\n"; for($col=0;$col<$numCols;$col++) { $details=""; $curImage=((($row)*$numCols)+($col+1)); $details=getDetails($fullsize[$curImage-1]); if($details) { $details=split("\|",$details); if($admin==1) echo "
{$details[0]} views

\n"; else echo "".stripslashes($details[1])."
{$details[0]} views

\n"; } else { if($admin==1 && (($curImage-1) < count($fullsize))) echo "
0 views


\n"; else echo " \n"; } } echo "\n"; if($row!=($numRows-1)) echo "\n"; } if($admin==1) echo ""; } if($_GET['admin']==true)$numCols=2; foreach($_POST as $key => $val) { $file=eregi_replace("(.*)_(.*)","\\1.\\2", $key); if($file!="password" && file_exists($file)) { $statfile="pictelo/".$file.".stf"; $fp=fopen($statfile, "rb"); $fdata=split("\|", fread($fp, filesize($statfile))); fclose($fp); $fp=fopen($statfile, "wb"); $put=((int)$fdata[0])."|{$val}|{$fdata[2]}"; fwrite($fp, $put); fclose($fp); } } if(isset($_GET['filename']) && $_GET['action']=="showfull") { showBigPicture($_GET['filename']); } else { echo "$header "; setStartImage(); if($_GET['admin']==true) { echo ""; echo ""; echo "

$albumName

You are trying to log in as an administrator, to view the album as a user, click here

Password
"; echo ""; } else { echo ""; showAlbum(); $lastImage=$curImage+$startImage; $tcs=$numCols-1; $prevPage=$lastImage-(2*($numCols*($numRows))); echo ""; if($start>0) echo "backward  "; else echo "                  "; if($lastImage<$totalImages) echo "  forward"; else echo "                "; echo "
"; echo "edit"; if($prevPage<=0) $prevPage=0; } echo $footer; } ?>