Picture Viewer
';
print'';
//check directory $thumb_dir exists!
$search_dir='.';
$dp = opendir ($search_dir);
while($item=readdir($dp) AND $a!=1){
if((is_dir($item)) AND (substr($item,0,1)!='.')){
if($item == $thumb_dir){$a=1;}
}
}
if(!$a==1){mkdir($thumb_dir);
}
//show thumbnails
if(!isset($_GET['start'])){$start=0;
}else{$start=$_GET['start'];
}
$search_dir='.';
$dp=opendir($search_dir);
rewinddir($dp);
$a=0; //images/page counter
while($item=readdir($dp)){
if((is_file($item))AND(substr($item,0,1)!=';')){
if(eregi('()(.jpg|.png|.gif)$',$item)){ //show files. .jpg/.png/.gif
//create the thumbnail picture pad/name
$thumb="$thumb_dir/$item";
//check if the thumbnail already exist, if not, create one!
if(!file_exists($thumb)){resize($item, $thumb, $size_x, $size_y);
}
$pc=$pc+1; //general picture counter
if($pc > 0+$start AND $pc <= $x*$y+$start){
$a=$a+1;
print'
|
';
if($a==$x){
$a=0;
$row=$row+1;
print'';}
}
}
}
}
print'
';
print'
';
closedir($dp);
//counting for next pages
if(!isset($_GET['start'])){$start=$x*$y;
}else{$start=$_GET['start']+$x*$y;
}
$pg=0;
echo'';
while($pc > $pg*$x*$y){
$start=$pg*$x*$y;
$view=$pg+1;
if($start==$_GET['start']){print''.$view.' | ';
}else{
print''.$view.' | ';
}
$pg=$pg+1;
}
//page end
echo'';
echo'