|
Home
Ed's Space
Betsy's Space
Our Space
Friends
Movies
Web Cam
Gallery
FAQ
Credits
|
|
|
// Here goes our script.
require "variables.php3";
/* ************************************
* The actual code. First the functions
* ************************************ */
function showentries($from_number) {
global $script, $imgfile, $numofentries, $from, $action, $num_in_each_row, $thumbdir;
// Open image data file
if(($file = file($imgfile)) == 0) {
error_msg("List of images not found.");
return;
}
echo " Welcome to my space. Click on the little pictures to see the big ones... ";
echo " ";
$insertrow = 0;
$start = $from_number;
$end = $start + $numofentries -1;
$entries = 0;
$img = $file[0];
$img = substr($img, 0, strlen($img)-1);
do {
$entries++;
if($entries >= $start) {
// the two lines below make sure that $num_in_each_row items are added in each row
if($insertrow >= $num_in_each_row) $insertrow = 0;
if($insertrow == 0) echo "\n";
echo "\n";
echo "";
echo " \n";
echo " | ";
$insertrow++;
if($entries == $end) {
$end += 1;
echo " ";
if($start == 1) {
echo "Next page";
}
else {
$start -= $numofentries;
if($start < 0) $start = 1; // This should never occur
echo "Previous page";
if($file[$end-1])
echo " - Next page";
}
return;
}
}
$img = next($file);
$img = substr($img, 0, strlen($img)-1);
} while($img);
echo " | \n";
$start -= $numofentries;
if($start > 0)
echo "Previous page ";
return;
}
function showimage($given_img) {
global $script, $imgfile, $textfile, $numofentries, $action, $picdir;
if(($file = file($imgfile)) == 0) {
error_msg("List of images not found.");
return;
}
$exists = 0;
$tempvar = 0;
$img = $file[0];
do {
$img = substr($img, 0, strlen($img)-1);
if(!strcmp($img, $given_img)) {
$exists = 1;
$arrayfield = $tempvar;
break;
}
$tempvar = $tempvar + 1;
$img = next($file);
} while ($img);
if(!$exists) {
error_msg("The requested file doesn't belong in the Image database of this gallery.");
return;
}
// else
if(($file2 = file($textfile)) == 0) {
error_msg("Text data file not found.");
return;
}
echo "\n";
echo "";
echo " | ";
echo "";
echo "$file2[$arrayfield]";
// Define in which gallery to return to.
$div = 1;
while( $div <= ($arrayfield+1)) $div += $numofentries;
$div-=$numofentries;
if($div <= 0) $div = 1;
print " | < < <. . . back to the little pictures";
echo "
| ";
return;
}
function error_msg($text) {
global $webmaster;
echo "ERROR: $text\n";
echo " Please, contact our webmaster and notify her of the problem";
echo ", so that it is fixed as soon as possible. Thank you.";
return;
}
/* ************************************
* The main code
* ************************************ */
// Let's check parameters
if(!$action || ($action == "start"))
showentries(1);
else if($action == "thumbs")
showentries($from);
else if($action == "showimage")
showimage($image);
?>
|