Fisherman.php (part1):
<?php
if ($_SERVER['PHP_SELF'] == "/poss/gallery/fisherman.php") {
echo "<center><font size='4' face='Verdana, Arial, Helvetica, sans-serif' color='#FF0000'>ERROR: Sorry, You cannot access this file directly...<br />\n</font></center>";
exit;
}
$path = $_SERVER['DOCUMENT_ROOT'];
$path2 = $_SERVER['DOC_ROOT'];
// sort and counting files in directory
$dir = $path . $imgageFolder;
$openDir = opendir($dir);
while (false !== ($fileNames = readdir($openDir))) {
$allfiles[] = $fileNames;
}
sort($allfiles);
for($o = 0; $o < count($allfiles); $o++) {
list($front, $ext) = explode(".", $allfiles[$o]);
if($front == "" || $ext == "") {
continue;
} else {
$files[] = $allfiles[$o];
}
}
for($i = 0; $i < count($files); $i++) {
// check files and get image informatons
$file = $imgageFolder . "/" . $files[$i];
$imgYes = getimagesize($path . $file);
// check image type for displaying and kick out all non-image files
if($imageType == 0) {
$allow = $imgYes[2] == 1 || $imgYes[2] == 2 || $imgYes[2] == 3; // all types
} elseif($imageType == 1) {
$allow = $imgYes[2] == 1; // only GIF
} elseif($imageType == 2) {
$allow = $imgYes[2] == 2; // only JPG
} elseif($imageType == 3) {
$allow = $imgYes[2] == 3; // only PNG
} elseif($imageType == 4) {
$allow = $imgYes[2] == 1 || $imgYes[2] == 2; // GIF and JPG
} elseif($imageType == 5) {
$allow = $imgYes[2] == 1 || $imgYes[2] == 3; // GIF and PNG
} elseif($imageType == 6) {
$allow = $imgYes[2] == 2 || $imgYes[2] == 3; // JPG and PNG
} else {
$allow = $imgYes[2] == 1 || $imgYes[2] == 2 || $imgYes[2] == 3; // all types
}
if($allow) {
$image[] = $files[$i];
} else {
continue;
}
}
asort($image, SORT_NUMERIC);
// prev, next and slide show navigation
$destination = $_POST['PHP_SELF'];
$sec = $_GET['second'];
$allImages = count($image);
if(empty($_GET['num']) || $_GET['num'] == 0) {
$num = 0;
$plus = $num+1;
if(empty($_GET['second'])) {
$first = "<a href= $destination?num=0><img src='nav_img/first.gif' width='16' height='14' border='0' alt='first'></a>";
$l = $allImages-1;
$last = "<a href= $destination?num=$l><img src='nav_img/last.gif' width='16' height='14' border='0' alt='last'></a>";
$next = "<a href = $destination?num=$plus><img src='nav_img/next.gif' width='16' height='14' border='0' alt='next'></a>";
$prev = "<img src='nav_img/in_prev.gif' width='16' height='14' border='0'>";
$slideShow = "<a href = $destination?num=$num&second=$secTime><img src='nav_img/slide.gif' width='16' height='14' border='0' alt='Slide Show'></a>";
} else {
$slideShow = "<a href = $destination?num=$num><img src='nav_img/stop.gif' width='16' height='14' border='0' alt='Stop Show'> </a>";
$nextSlide = $destination . "?num=$plus&second=$sec";
}
} elseif($_GET['num'] == $allImages-1) {
$num = $allImages - 1;
$minus = $num-1;
if(empty($_GET['second'])) {
$first = "<a href= $destination?num=0><img src='nav_img/first.gif' width='16' height='14' border='0' alt='first'></a>";
$l = $allImages-1;
$last = "<a href= $destination?num=$l><img src='nav_img/last.gif' width='16' height='14' border='0' alt='last'></a>";
$next = "<img src='nav_img/in_next.gif' width='16' height='14' border='0'>";
$prev = "<a href = $destination?num=$minus><img src='nav_img/prev.gif' width='16' height='14' border='0' alt='previous'></a>";
$slideShow = "<img src='nav_img/in_slide.gif' width='16' height='14' border='0'>";
} else {
$slideShow = "<a href = $destination?num=$num><img src='nav_img/stop.gif' width='16' height='14' border='0' alt='Stop Show'> </a>";
$nextSlide = $destination . "?num=0";
}
} else {
$num = $_GET['num'];
$plus = $num+1;
$minus = $num-1;
if(empty($_GET['second'])) {
$first = "<a href= $destination?num=0><img src='nav_img/first.gif' width='16' height='14' border='0' alt='first'></a>";
$l = $allImages-1;
$last = "<a href= $destination?num=$l><img src='nav_img/last.gif' width='16' height='14' border='0' alt='last'></a>";
$next = "<a href = $destination?num=$plus><img src='nav_img/next.gif' width='16' height='14' border='0' alt='next'></a>";
$prev = "<a href = $destination?num=$minus><img src='nav_img/prev.gif' width='16' height='14' border='0' alt='previous'></a>";
$slideShow = "<a href = $destination?num=$num&second=$secTime><img src='nav_img/slide.gif' width='16' height='14' border='0' alt='Slide Show'></a>";
} else {
$slideShow = "<a href = $destination?num=$num><img src='nav_img/stop.gif' width='16' height='14' border='0' alt='Stop Show'></a>";
$nextSlide = $destination . "?num=$plus&second=$sec";
}
}
// read image array
foreach($image as $key => $value) {
// grab an image from array
if($key == $num){
$display = $path . $imgageFolder . "/" . $image[$key];
$display2 = $path2 . $imgageFolder . "/" . $image[$key];
$sizes = getimagesize($display);
// resize images
if ($sizes[0] >= $sizes[1] && $sizes[0] > $maxWidth_Height) {
$resize = $sizes[0]/$maxWidth_Height;
$width = round($sizes[0]/$resize);
$height = round($sizes[1]/$resize);
} elseif($sizes[0] < $sizes[1] && $sizes[1] > $maxWidth_Height) {
$resize = $sizes[1]/$maxWidth_Height;
$width = round($sizes[0]/$resize);
$height = round($sizes[1]/$resize);
} else {
$width = $sizes[0];
$height = $sizes[1];
}
}
}
// check if is set image description or urls
if($descriptionYesOrNo == 1 || $urls == 1) {
// open image description
$fileName = $path . $descriptionFolder . "$description";
$fileDes = file($fileName);
foreach ($fileDes as $line) {
list($var, $targ, $desc) = explode('|', $line);
if ($var == $image[$num]) {
$description = $desc;
$URL = $targ;
break;
} else {
$description = "";
}
}
}
// again check if is set image description and print description table
if($descriptionYesOrNo == 1) {
// check if is set original name and dimension
if($name == 1) {
$name = $image[$num] . "<br />\n";
} elseif($name == 2) {
$string = explode(".", $image[$num]);
if(strpos($string[0], "-") > 0) {
$string1 = explode("-", $string[0]);
$new1 = $string1[1];
} else {
$new1 = $string[0];
}
if(strpos($new1, "_") > 0) {
$string2 = explode("_", $new1);
$new2 = implode(" ", $string2);
} else {
$new2 = $new1;
}
$name = $new2 . "<br />\n";
} else {
$name ="";
}
if($dimension == 1) {
$dimension = $sizes[3] . "<br />\n";
} else {
$dimension ="";
}
// descriptions table
$allDescriptions = "<table width='$descriptionWidth' border='0' cellpadding='0' cellspacing='0'>
<tr>
<td width='10' valign='top'> </td>
<td valign='top'><span class='descriptionFont'><br>
$name $dimension <br>
$description</span></td>
<td width='5' valign='top'> </td>
</tr>
</table>";
} else {
if($name == 1) {
$names = $image[$num] . "<br />\n";
} elseif($name == 2) {
$string = explode(".", $image[$num]);
if(strpos($string[0], "-") > 0) {
$string1 = explode("-", $string[0]);
$new1 = $string1[1];
} else {
$new1 = trim($string[0]);
}
if(strpos($new1, "_") > 0) {
$string2 = explode("_", $new1);
$new2 = implode(" ", $string2);
} else {
$new2 = $new1;
}
$names = $new2;
} else {
$names ="";
}
}