SAFE MODE og gallerier
Jeg er ikke specielt god til PHP, men det er lykkedes mig at få banket nogen gallerier sammen (med en hel del hjælp). Uheldigvis virker det ikke.Systemet består af:
1 PHP-side (default.php)
og en .inc-fil (functions.inc)
+en masse billeder i .jpg format, og jeg laver dem ikke om!
Alle filer ligger i mappen: ../Billeder/Bad-taste/
----------------------------------------------------------
indhold af default.php:
<?
include("functions.inc");
?>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<?
getImages($firstImage);
?>
<p> </p>
<p> </p>
<p> </p>
</body>
</html>
-------------------------------------------------------------------------------
Indhold af functions.inc:
<?
//---- Settings Start ---\\
// Image Information
$imageWidth=100;
$imageHeight=100;
// Table Layout
$rows=4;
$cols=5;
//Image path
$libery="../Billeder/Bad-taste/"; // remember to finish with /
// Settings Stop----------//
$viewNum=$cols*$rows;
if(!$firstImage){ // so it works if you just enter default.php and show the pictures without having to define the variables in the path
$firstImage=1;
}
function getImages($firstImage){
global $viewNum, $imageWidth, $imageHeight,$cols,$libery; //insures that the function gets the variables
$handle=opendir('../Billeder/Bad-taste/'); //opens directory
while($file=readdir($handle)){ // reads the directory
$extension=substr($file,-4); // gets the extension of the files
if(($extension == ".jpg") || ($extension == ".gif") || ($extension == ".png")){ // checks for image files
$all[]=$file; //adds positive results to the archive
}
}
$colscounter=0; // variable that controls the tablebuilding system below
$firstImage--; // variable that insures that the first image is being showed. Case: It looks best if the links begins with 1 but the array begins with 0
if(isset($all)){ // if array is set build the table
print "<table>";
for($i=$firstImage; $i < $firstImage+$viewNum; $i++){
if($all[$i]){ // checks for rinning dry of imges
if($i==$firstImage + $colscounter*$cols){ // if true: new row
$colscounter++;
print "<tr>";
} // add the image
print "<td><a href='".$libery."".$all[$i]."'><img src='".$libery."".$all[$i]."' border='0' width='$imageWidth' height='$imageHeight' alt='Click to Enlarge'></a></td>";
}
else{ // stop if no more images
break;
}
}
print "</table><br>";
$num=count($all); //number of pictures in actual libery
makeList($num); // function to make the links list
}
else{
print "Der var desværre ingen billeder i dette bibliotek<br><a href='java script:history.back()'>Go Back</a>";
}
}
function makeList($num){
global $libery, $firstImage, $viewNum; //insures that the function gets the variables
$numLinks = $num / $viewNum; // finds the number og links to be maked
for($a=0; $a < $numLinks;$a++){
$start=$a*$viewNum+1; //adds 1 because then the links begins with ex. number 1-10 and 11-20 instead of 0-10 and 10-20
$finish=$a*$viewNum+$viewNum;
if($finish>$num){ // insures that the final link returns the right amount of pictures instead of to much
$finish=$num;
}
if(($firstImage >= $start) && ($firstImage < $a * $viewNum+$viewNum)){ // if true: makes no link because you already are on the page
print "$start - $finish</a> ";
}
else{ // makes the link
print "<a href='default.php?libery=$libery&firstImage=$start'>$start - $finish</a> ";
}
}
}
?>
----------------------------------------------------------------
Hvorfor dur det ikke (jeg har opfattet at det har noget at gøre med at serveren kører i SAFE MODE at gøre)?
Og vigtigere, hvordan får jeg det til at virke?
