I took a php code from internet webpage and modified it suitably for my web but it doesn,t work.
Tutorial for the code said:
/****************************************************************************/
// Easy PHP Photo Gallery by Joe Dolson //
// Free for non-commercial use with attribution. //
// Version 1.1, July 2007 //
//--------------------------------------------------------------------------//
/****************************************************************************/
Installation of this script should be quite easy. This script assumes you're
using a standard Linux server setup with PHP.
1) index.php is the destination file for your photo gallery. When you've installed
the gallery, this file is the address visitors will go to in order to view your images.
Index.php is essentially a shell containing a small amount of php: configuration data
and the call to the gallery script. You can copy and paste the section of index.php
between <?php and ?> and place it into any PHP file on your website to run the script.
2) gallery.php is the script which actually creates the photo gallery. You shouldn't need
edit this document, although you can if you want. No warranties, though!
3) title.php (NEW!) is the script which supplies the <title> element for each page of the gallery.
3) titles.txt is the file which lists the images in the gallery. The format of the
file is as follows: filename.jpg|description of image|alt text.
-You only need to include the name of the full sized version of the image
-Each image should be on one line
-Thumbnails should be named filename_tn.jpg. The script will find these automatically.
-The titles.txt file should be in the same directory as all images for the script.
4) The directory for images can be any directory you choose on your server. You'll
need to input the path to this directory in the configuration data. For example, if you're
locating your gallery at http://www.yourdomain.com/pics/me/2007/ and your images are in
http://www.yourdomain.com/galleries/me/2007/, the path will need to be ../galleries/me/2007.
5) basic_styles.css. This is JUST some basic styling to give you an idea how it works.
There's no need to make any use of them at all. They haven't been tested in anything other then Firefox version 2, so don't have any great expectations. Design as you please.
Any questions? Good. You can contact me at http://www.joedolson.com/contact.php.
That's what I did in my opinion but as You can see here http://cancaseiro.homelinux.com/kool/galerii/, it doesn't work.
So my index.php looks like that:
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<link rel="stylesheet" type="text/css" title="styles" href="basic_styles.css">
<?php
//THE SCRIPT//
/*************************************/
// Configuration //
/*************************************/
// Labels for Image Gallery Titles:
$sitename = "Pildigalerii";
$sep = " - "; // title element separator
// relative path to image folder
$path = "/var/www/kool/galerii/images";
// title of this gallery
$gallery_title = "Pildigalerii PHP-ga";
// text description of this gallery
$description = "Suvalised pildid"; //optional
// Pick which field will supply unique title element text.
// "TRUE" field is the source for the title element.
$description_title = FALSE;
$alt_title = TRUE;
// heading level of gallery header [e.g. <h1>, <h2>] (string, 1-6);
$header = "2";
// path + name of image index file (you can name the index
// file whatever you want, just put that name here!)
$piclist = "images/titles.txt";
// Leave this set to TRUE if you want to include the description
// text for the image in a paragraph underneath the image.
$caption_text_under = TRUE;
// Ditto, except that the caption would be above the image.
$caption_text_over = FALSE;
// Do you want to include an alternative text attribute on the
// full size images? If you've left the description/caption turned on,
// it may be preferable to disable the alternative text on these images.
$alt_text = FALSE;
// Do you want to give me your public thanks? Hey! That's cool! Not required, though.
$attribution = TRUE;
/***********************************/
// End Configuration //
/***********************************/
include("includes/title.php");
?>
</head>
<body>
<div id="wrap">
<!-- This would be the nice HTML editable section. Text above the gallery, your header include, whatever... -->
<?php
include("includes/gallery.php");
// END THE GALLERY SCRIPT//
?>
</div>
</div>
</body>
</html>
Code: Select all
<?php
// PHP Gallery Navigation Script: Configuration set in index.php
echo "
<div id='gallery'>";
//starting variable
$y = 0;
// open file and set into array of thumbnails
// append _tn to end of file name to access thumbnails
// thumbnails must be have:
// identical file names to full size images
// no periods
// same file type as full size images
$fp = fopen($piclist, 'r');
while ($buffer= fgets($fp,4096)) {
$image[$y] = explode("|", $buffer);
$photo[$y] = str_replace(".", "_tn.", $image[$y][0]);
$y++;
}
// calculate total number of images
$result = count($photo);
// numeric value of final image where initial image = 0
$suma = ($result-1);
// calculate image values based on currently viewed image
if (isset($_GET['a'])) {
if (is_numeric($_GET['a'])) {
$newa=$_GET['a'];
} else {
$newa=1;
}
$prev = ($newa-1);
$next = ($newa+1);
switch ($newa) {
case 0:
$prev = $suma;
$next = 1;
break;
case $suma:
$prev = ($suma - 1);
$next = 0;
break;
}
// display navigation links for image gallery
// if "a" is set in the $_GET array:
echo "
<div id='gallery_nav'><p><a href='?a=$prev'>Previous</a> | <a href='?a=$next'>Next</a></p></div>";
} else {
// if "a" is NOT set:
echo "
<div id='gallery_nav'><p><a href='?a=$suma'>Previous</a> | <a href='?a=1'>Next</a></p></div>";
}
echo "<h$header>$gallery_title</h$header>
<div class=\"gallery_description\">
<p>$description</p>
<p><small><a href=\"#thumbs\">Skip to Thumbnails</a></small></p>
</div>";
// display current full sized image if get value is set
if (isset($_GET['a'])) {
if (is_numeric($_GET['a'])) {
$a = $_GET['a'];
} else {
$a = 1;
}
$display = $image[$a][0];
$description = $image[$a][1];
$alt = $image[$a][2];
echo "
<div id='full_image'>";
if ($caption_text_over == TRUE) { echo "<p>$description</p>"; }
echo "<p><img src='$path/$display' alt='";if($alt_text==TRUE){echo $alt;}echo"' /></p>";
if ($caption_text_under == TRUE) { echo "<p>$description</p>"; }
echo "</div>";
} else {
// display first image if no get value is set
$display = $image[0][0];
$description = $image[0][1];
$alt = $image[0][2];
echo "
<div id='full_image'>";
if ($caption_text_over == TRUE) { echo "<p>$description</p>"; }
echo "<p><img src='$path/$display' alt='";if($alt_text==TRUE){echo$alt;}echo"' /></p>";
if ($caption_text_under == TRUE) { echo "<p>$description</p>"; }
echo "</div>";
}
// display thumbnails in unordered list format
echo "
<div id='thumbs'><h";
echo $header+1;
echo ">Thumbnails</h";
echo $header+1;
echo "><ul>";
for ($i = 0; $i <= $result; $i++){
if(is_file($path.'/'.$photo[$i])) {
$alt = $image[$i][2];
echo "
<li><a href='?a=$i'><img src='$path/$photo[$i]' alt='$alt' /></a></li>
";
}
}
echo "
</ul></div>";
if ($attribution == TRUE) {
echo "<p><small>Easy PHP Photo Gallery by <a href='http://www.joedolson.com'>Joseph C Dolson</a>.</small></p>";
} else {
echo "<!--<p><small>Easy PHP Photo Gallery by <a href='http://www.joedolson.com'>Joseph C Dolson</a>.</small></p>-->";
}
?>
Code: Select all
<?php
$y = 0;
// open file and set into array of thumbnails
// append _tn to end of file name to access thumbnails
// thumbnails must be have:
// identical file names to full size images
// no periods
// same file type as full size images
$fp = fopen($piclist, 'r');
while ($buffer= fgets($fp,4096)) {
$image[$y] = explode("|", $buffer);
$photo[$y] = str_replace(".", "_tn.", $image[$y][0]);
$y++;
}
if (isset($_GET['a'])) {
if (is_numeric($_GET['a'])) {
$a = $_GET['a'];
} else {
$a = 1;
}
if ($description_title == TRUE) {
$img_title = $image[$a][1];
} else if ($alt_title == TRUE) {
$img_title = $image[$a][2];
}
} else {
// display first image if no get value is set
if ($description_title == TRUE) {
$img_title = $image[0][1];
} else if ($alt_title == TRUE) {
$img_title = $image[0][2];
}
}
$title_element = $gallery_title . $sep . $img_title . $sep . $sitename;
echo "<title>$title_element</title>";
?>