Nogen der kan hjælpe mig med at finde den sætning der sætter en sort border på album ikonerne på denne side
http://anakin.dk/fotoalbum/?album=MHV/Uddannelse/22-29%20april%202006/ud fra denne kode:
<?php
/**
* Versioning
*/
$progname = "<a href=\\"http://www.ruwebit.net/article/110/\\" target=\\"_blank\\">SilverMine</a>™";
$version = "2.24";
$copyright = "© 2001-2005 <a href=\\"http://www.ruwebit.net/\\" target=\\"_blank\\">RuweBit</a>";
/**********************************************************************
* Input parameters
**********************************************************************/
/**
* Request Variables
*/
$action = $_REQUEST['action'];
$album = $_REQUEST['album'];
$picture = $_REQUEST['picture'];
/**
* Validation 1: Filter the parameters from unwanted html tags
*/
$action = strip_tags($action);
$album = strip_tags($album);
$picture = strip_tags($picture);
/**
* Validation 2: Set default values
*/
// Default action is showing thumbnails
if ((trim($action) == "") or (!IsSet($action)))
{
$action = "thumbnails";
}
// Replace \\ slashes with / slashes
$album = str_replace("\\\\", "/", $album);
// Top level album is indicated with empty string
if ((trim($album) == "/") or (!IsSet($album)))
{
$album = "";
}
// Add ending slash for albums if not done so
// This is not done for the toplevel album
if ($album != "")
{
if (substr($album, strlen($album) - 1, 1) != "/")
{
$album .= "/";
}
}
/**
* Validation 3: Using regular expressions to allow only strict
* formatting
*/
validatePath($album);
validateAction($action);
validateFile($picture);
/**********************************************************************
* Configuration
**********************************************************************/
function setDefault(&$var, $DefaultValue)
{
if (!IsSet($var))
{
$var = $DefaultValue;
}
}
// Set default configuration if not set in configuration file
setDefault($thumbnails_columns, 4);
setDefault($thumb_prefix, "thumb_");
setDefault($normal_prefix, "normal_");
setDefault($generate_thumbnail_images, 1);
setDefault($thumbnail_image_resolution, "160x120");
setDefault($thumbnail_image_jpeg_quality, 80);
setDefault($max_thumbnail_images_to_generate, 10);
setDefault($generate_normal_images, 1);
setDefault($normal_image_resolution, "800x600");
setDefault($normal_image_jpeg_quality, 80);
setDefault($allowed_pictures, array("jpg", "jpeg", "gif"));
setDefault($allowed_movies, array("avi", "mov", "mpg", "mpeg"));
setDefault($allowed_documents, array("doc", "htm", "html", "pdf"));
setDefault($language, "english");
// Normal image resolution
$normalImgResArray = explode("x",strToLower($normal_image_resolution));
$iNormalImageWidth = $normalImgResArray[0];
$iNormalImageHeight = $normalImgResArray[1];
// Thumbnail image resolution
$thumbImgResArray = explode("x",strToLower($thumbnail_image_resolution));
$iThumbnailImageWidth = $thumbImgResArray[0];
$iThumbnailImageHeight = $thumbImgResArray[1];
// Nr of thumbnail images that are created on this page request
$iNrOfThumbnailImagesCreated = 0;
/**********************************************************************
* Validation functions
**********************************************************************/
/**
* Validate the pathname
*/
function validatePath($strPathName)
{
// Allowed characters are between [ and ]
// Paths should always start with / and end with /
$bIsValid = ereg("^(/|([A-Za-z0-9 @()%_=-]+/))*$", $strPathName);
// Check if there are no /./ and no /../ paths
//
$SpecialPathsPresent = ereg("(/[.]+/)|([.]+/)|(/[.]+)]*", $strPathName);
if (!(($bIsValid) and (!$bSpecialPathsPresent)))
{
tamperingDetected("validatePath", $strPathName);
}
}
function validateFile($strFileName)
{
// Allowed characters are between [ and ]
$bIsValid = ereg("^([A-Za-z0-9_.,-~@()=#% ]+)*$", $strFileName);
if (!$bIsValid)
{
tamperingDetected("validateFile", $strFileName);
}
}
function validateAction($strAction)
{
$bIsValid = ereg("[A-Za-z]+", $strAction);
if (!$bIsValid)
{
tamperingDetected("validateAction", $strAction);
}
}
/**
* Filters parameters from unwanted strings for security purpose
*/
function filterParameter($strParameter)
{
$strReturnValue = strip_tags($strParameter);
$strReturnValue = str_replace("`", "", $strReturnValue);
$strReturnValue = str_replace("*", "", $strReturnValue);
$strReturnValue = str_replace("?", "", $strReturnValue);
return $strReturnValue;
}
/**
* Tampering detected
*/
function tamperingDetected($strContext1, $strContext2)
{
global $webmaster;
global $action;
global $progname;
global $version;
global $silvermine_dir;
global $topdir;
global $topurl;
global $thumb_prefix;
global $normal_prefix;
global $allowed_pictures;
global $allowed_movies;
global $allowed_documents;
$strRemoteIP = $_SERVER['REMOTE_ADDR'];
$strRequestURI = $_SERVER['REQUEST_URI'];
$strUserAgent = $_SERVER['HTTP_USER_AGENT'];
$strHostname = gethostbyaddr($strRemoteIP);
echo "<font class=warning>";
echo "<b>Tampering detected</b><p>";
echo "Input parameter validation failed, your IP has been logged ";
echo "and the webmaster has been notified.<p>";
echo "If you don't do anything with the parametes or don't even know what ";
echo "parameters are: then don't worry.<p>";
echo "If you did tamper with the parameters: stop it or eat shit and die!<p>";
echo "If this problem persists, please notify the <a href=\\"mailto:".$webmaster."\\"><font class=warning><u>webmaster</u></font></a><p>";
echo "For the webmaster: it is possible that the validation is too strict: ";
echo "check the validate functions silvermine_inc.php ";
echo "file, edit them to your needs and notify the author of SilverMine.<p>";
echo "<table class=warning border=0><tr><td valign=top align=left>Remote IP</td><td valign=top align=left>: ".$strRemoteIP."</td></tr><tr><td>";
echo "Hostname</td><td valign=top align=left>: ".$strHostname."</td></tr><tr><td valign=top align=left>";
echo "Context</td><td valign=top align=left>: ".$strContext1."(".$strContext2.")</td></tr><tr><td valign=top align=left>";
echo "URI</td><td valign=top align=left>: ".$strRequestURI."</td></tr><tr><td valign=top align=left>";
echo "UserAgent</td><td valign=top align=left>: ".$strUserAgent."</td></tr></table>";
// Send mail
$strBodyText = "This is an automatically sent mail from the SilverMine Photoalbum script ";
$strBodyText .= "because a suspected tampering attempt has been detected\\n\\n";
$strBodyText .= "Relevant data:\\n";
$strBodyText .= " Remote IP: ".$strRemoteIP."\\n";
$strBodyText .= " Hostname: ".$strHostname."\\n";
$strBodyText .= " Context: ".$strContext1."(".$strContext2.")\\n";
$strBodyText .= " URI: ".$strRequestURI."\\n";
$strBodyText .= " UserAgent: ".$strUserAgent."\\n";
$strBodyText .= " Program: ".$progname." version ".$version."\\n";
$strBodyText .= "\\nRelevant configuration parameters:\\n";
$strBodyText .= " SilvermineDir=".$silvermine_dir."\\n";
$strBodyText .= " TopDir=".$topdir."\\n";
$strBodyText .= " TopURL=".$topurl."\\n";
$strBodyText .= " Thumb_Prefix=".$thumb_prefix."\\n";
$strBodyText .= " Normal_Prefix=".$normal_prefix."\\n";
$strBodyText .= " Allowed_Pictures=".implode(",",$allowed_pictures)."\\n";
$strBodyText .= " Allowed_Movies=".implode(",",$allowed_movies)."\\n";
$strBodyText .= " Allowed_Documents=".implode(",",$allowed_documents)."\\n";
$strBodyText .= "\\nBy the way, don't blame the user too much, it could be that the validation on albumname and picturename is too strict.\\n";
$strBodyText .="\\nThe SilverMine Team";
if (sendMail($strBodyText))
{
echo "<p>Mail sent...";
}
echo "</font><p>";
$action = "die";
}
/**
* Send mailfrom SilverMine
*/
function sendMail($strBodyText)
{
global $webmaster;
$strHeaders = "From: SilverMine Photoalbum <".$webmaster.">\\r\\n";
$strHeaders .= "Reply-to: ".$webmaster."\\r\\n";
$strHeaders .= "X-Mailer: : ".$progname." version ".$version;
return (mail($webmaster, "Tampering detected", $strBodyText,
$strHeaders));
}
/**********************************************************************
* (String) processing functions
**********************************************************************/
/**
* Strip last directory from directory (previous)
*/
function stripDir($strDir)
{
$i = strlen($strDir)-2;
$returnValue = "";
while ($i>0)
{
if (substr($strDir, $i, 1) == "/")
{
$returnValue = substr($strDir,0,$i+1);
$i = 0;
}
$i--;
}
return $returnValue;
}
/**
* Returns the extension of the file without dot (.)
*/
function GetFileExtension($strFileName)
{
$FilenameArray = explode(".",$strFileName);
return strToLower($FilenameArray[count($FilenameArray)-1]);
}
/**
* Capitalize first character of a string
*/
function strToUpperFirst($strString)
{
return strToUpper(substr($strString,0,1)).strToLower(substr($strString,1,strlen($strString)-1));
}
function warnings_off()
{
error_reporting (E_ERROR | E_PARSE);
}
function warnings_on()
{
error_reporting (E_ERROR | E_WARNING | E_PARSE);
}
function errors_off()
{
error_reporting (E_PARSE);
}
function errors_on()
{
error_reporting (E_ERROR | E_WARNING | E_PARSE);
}
/**********************************************************************
* Display and layout functions
**********************************************************************/
function showNavigation()
{
global $album;
global $topurl;
global $picture;
global $PicturesArray;
global $imageurl;
global $stringArray;
//
// Previous
//
echo "<center><table border=0 cellspacing=0 cellpadding=0 align=center><tr>";
if ($picture > 0)
{
echo "<td class=navigation valign=bottom><a class=navigation href=\\"".$PHP_SELF."?action=view&album=".$album."&picture=".($picture-1)."\\"></a></td>";
echo "<td class=navigation valign=bottom><a class=navigation href=\\"".$PHP_SELF."?action=view&album=".$album."&picture=".($picture-1)."\\">".strToUpperFirst($stringArray["_previous"])."</a></td>";
}
else
{
echo "<td class=navigation valign=bottom>".strToUpperFirst($stringArray["_previous"])."</td>";
}
echo "<td class=navigation valign=bottom><a class=navigation href=\\"".$PHP_SELF."?album=".$album."\\">".$stringArray["_overview"]."</a></td>";
//
// Next
//
if (($picture+1) < count($PicturesArray))
{
echo "<td class=navigation valign=bottom><a class=navigation href=\\"".$PHP_SELF."?action=view&album=".$album."&picture=".($picture+1)."\\">".$stringArray["_next"]."</a></td>";
echo "<td class=navigation valign=bottom><a class=navigation href=\\"".$PHP_SELF."?action=view&album=".$album."&picture=".($picture+1)."\\"></a></td>";
}
else
{
echo "<td class=navigation valign=bottom>[".$stringArray["_next"]."]</td>";
// echo "<td class=navigation valign=bottom><img src=\\"".$imageurl."disabled_nextpicture.gif\\"></td>";
}
echo "</tr></table></center>";
}
/**
* Display the directories in a clickable form like / blabla/ blabla/ etc/
*/
function showAlbumsNavigation($strFullDirectoryName)
{
global $stringArray;
if ((!IsSet($strFullDirectoryName)) OR ($strFullDirectoryName == ""))
{
$strFullDirectoryName = "/";
}
$DirectoryArray = explode("/",$strFullDirectoryName);
echo "</center><font class=albumtitle> › ".strToUpperFirst($stringArray["_album"])."<a class=albumtitle href=\\"".$PHP_SELF."?album=/\\">".$stringArray["_root"]."</a></font>";
$iCount = 0;
$strAlbum = "";
while ($iCount < count($DirectoryArray))
{
if (trim($DirectoryArray[$iCount]) != "")
{
$strAlbum .= $DirectoryArray[$iCount]."/";
echo "<font class=albumtitle> › <a href=\\"".$PHP_SELF."?album=".$strAlbum."\\">".$DirectoryArray[$iCount]."</a> </font>";
}
$iCount++;
}
echo "<center>";
}
/**
* Create smaller images (thumbnails / normal sized etc)
*/
function CreateSmallerImage($strSourceImage, $strTargetImage, $width, $height, $quality)
{
Global $topdir;
Global $album;
//
// Generate the thumbnail or normal sized image
//
$bGenerationSucceeded = false;
// Warnings off
warnings_off();
// Check if directory is writeable
// otherwise don't even try to create the new image
if (is_writable($topdir.$album))
{
//
// Process different image types
//
$unknown = 0; $jpg = 1; $gif = 2; $png = 3;
$image_type = $unknown;
$strExt = strToLower(GetFileExtension($strSourceImage));
if (($strExt == "jpg") || ($strExt == "jpeg"))
{
$image_type = $jpg;
}
//else if ($strExt == "gif")
//{
// $image_type = $gif;
//}
//else if ($strExt == "png")
//{
// $image_type = $png;
//}
if ($image_type != $unknown)
{
// Source image
if ($image_type == $jpg)
{
$hSource_image = imagecreatefromjpeg($strSourceImage);
}
else if ($image_type == $gif)
{
$hSource_image = imagecreatefromgif($strSourceImage);
}
list($width_orig, $height_orig) = getimagesize($strSourceImage);
// Keep aspect ratio
if ($width && ($width_orig < $height_orig))
{
$width = ($height / $height_orig) * $width_orig;
}
else
{
$height = ($width / $width_orig) * $height_orig;
}
// Do not increase image size
if (($width > $width_orig) || ($height > $height_orig))
{
$width = $width_orig;
$height = $height_orig;
}
// Target image
$hTarget_image = imagecreatetruecolor($width, $height);
// Resample
$bSucceeded = false;
$bSucceeded = imagecopyresampled($hTarget_image, $hSource_image, 0, 0, 0, 0,
$width, $height, /* new size */
$width_orig, $height_orig /* old size */);
/*
// Add text
if ($bSucceeded)
{
warnings_on();
$white = imagecolorallocate($hTarget_image, 255, 255, 255);
$black = imagecolorallocate($hTarget_image, 0, 0, 0);
$x = 10; $y = 12;
$font = "/mnt/removable/www/html/global/packages/silvermine/arial.ttf";
$text = "SilverMine";
imagettftext($hTarget_image, 10, 0, $x-1, $y-1, $black, $font, $text);
imagettftext($hTarget_image, 10, 0, $x+1, $y+1, $black, $font, $text);
imagettftext($hTarget_image, 10, 0, $x, $y, $white, $font, $text);
warnings_off();
}
*/
// Create smaller image
if ($bSucceeded)
{
if ($image_type == $jpg)
{
$bSucceeded = imagejpeg($hTarget_image, $strTargetImage, $quality);
}
else if ($image_type == $gif)
{
$bSucceeded = imagegif($hTarget_image, $strTargetImage); // not supported ??
}
}
// Smaller image created!
if ($bSucceeded)
{
$bGenerationSucceeded = true;
}
imagedestroy($hSource_image);
imagedestroy($hTarget_image);
}
} // not writeable
// Warnings on again
warnings_on();
return $bGenerationSucceeded;
}
/**
* Show the thumbnails page
*/
function showThumbnails()
{
global $album;
global $topdir;
global $topurl;
global $imagedir;
global $imageurl;
global $thumbnails_columns;
global $thumb_prefix;
global $normal_prefix;
global $AlbumsArray;
global $PicturesArray;
global $OtherFilesArray;
global $AllFilesArray;
global $stringArray;
global $generate_thumbnail_images;
global $iThumbnailImageWidth;
global $iThumbnailImageHeight;
global $iNrOfThumbnailImagesCreated;
global $max_thumbnail_images_to_generate;
global $thumbnail_image_jpeg_quality;
//
// Show thumbnails
//
$iMaxCols = $thumbnails_columns;
$iColCount = 0;
//
// Top of page
//
echo "<center>";
echo "<table border=0 cellpadding=0 cellspacing=0>\\n";
//
// Albums
//
$i = 0;
while ($i < count($AlbumsArray))
{
if ($iColCount == 0)
{
echo "<tr>";
}
echo "<td class=thumbnails_main valign=center align=center height=100%>";
//
// Previous album
//
if ($AlbumsArray[$i] == "..")
{
echo "<table height=100% width=100% border=0 cellpadding=0 cellspacing=0>";
echo "<tr><td class=album_thumbnail valign=middle align=middle>";
echo "<img src=\\"".$imageurl."previousalbum_thumb.gif\\" border=0 alt=\\"".$stringArray["_clickpreviousalbum"]."\\">";
echo "</td></tr><td class=album_thumbnail valign=bottom align=middle>";
echo "<a href=\\"".$PHP_SELF."?album=".stripDir($album)."\\"><font class=album_thumbnailtext>".strToUpperFirst($stringArray["_previousalbum"])."</font></a>";
echo "</td></tr></table>";
}
//
// Any other albums
//
else
{
echo "<table height=100% width=100% border=0 cellpadding=0 cellspacing=0>";
echo "<tr><td class=album_thumbnail valign=middle align=middle>";
// Get extra info
$strInfo = getDirectoryInfo($topdir.$album.$AlbumsArray[$i]."/");
// 1. Show album art (jpg or gif)
if (file_exists($topdir.$album.$AlbumsArray[$i]."/".$thumb_prefix."album.jpg"))
{
$strFilename = $topurl.$album.$AlbumsArray[$i]."/".$thumb_prefix."album.jpg";
}
else if (file_exists($topdir.$album.$AlbumsArray[$i]."/".$thumb_prefix."album.gif"))
{
$strFilename = $topurl.$album.$AlbumsArray[$i]."/".$thumb_prefix."album.gif";
}
// 2. Get thumbnail from directory
else
{
$strFilename = getFirstThumbnail($topdir.$album.$AlbumsArray[$i]);
// 3. Default icon
if (($strFilename == "") or (!file_exists($topdir.$album.$AlbumsArray[$i]."/".$strFilename)))
{
$strFilename = $imageurl."album_thumb.gif";
}
else
{
$strFilename = $topurl.$album.$AlbumsArray[$i]."/".$strFilename;
}
}
echo "<img src=\\"".$strFilename."\\" alt=\\"".$strInfo."\\" border=0>";
echo "</td></tr><td class=album_thumbnail valign=bottom align=middle>";
echo "<a href=\\"".$PHP_SELF."?album=".$album.$AlbumsArray[$i]."/\\"><font class=album_thumbnailtext>".strToUpperFirst($stringArray[""])."".$AlbumsArray[$i]."</font></a>";
echo "</td></tr></table>";
}
echo "</td>";
$i++;
$iColCount++;
if ($iColCount == $iMaxCols)
{
echo "</tr>\\n";
$iColCount = 0;
}
}
//
// Pictures
//
$i = 0;
while ($i < count($AllFilesArray))
{
if ($iColCount == 0)
{
echo "<tr>";
}
echo "<td class=thumbnails_main valign=center align=center height=100%>";
//
// Picture
//
if (IsPicture($AllFilesArray[$i]))
{
$strThumbFile = $topdir.$album.$thumb_prefix.$AllFilesArray[$i];
$strThumbUrl = $topurl.$album.$thumb_prefix.$AllFilesArray[$i];
$strFileNameArray = explode(".",$AllFilesArray[$i]);
if (!file_exists($strThumbFile))
{
//
// Generate the thumbnail image
//
$bGenerationSucceeded = false;
if ($generate_thumbnail_images == 1)
{
// Get normal_ or original picture as source image
$strFilename = $AllFilesArray[$i];
if (file_exists($topdir.$album.$normal_prefix.$strFilename))
{
$strSourceImage = $topdir.$album.$normal_prefix.$strFilename;
}
else
{
$strSourceImage = $topdir.$album.$strFilename;
}
if (($iNrOfThumbnailImagesCreated <= $max_thumbnail_images_to_generate) || (0 == $max_thumbnail_images_to_generate))
{
$bGenerationSucceeded = CreateSmallerImage(
$strSourceImage, $strThumbFile,
$iThumbnailImageWidth, $iThumbnailImageHeight,
$thumbnail_image_jpeg_quality);
$iNrOfThumbnailImagesCreated++;
}
}
//
// Or show an icon
//
if (!$bGenerationSucceeded)
{
$strThumbFile = $imagedir."picture_thumb.gif";
$strThumbUrl = $imageurl."picture_thumb.gif";
}
}
$ThumbImageSizeArray = GetImageSize ($strThumbFile);
$strInfo = getFileInfo($AllFilesArray[$i]);
echo "<table height=100% width=100% border=0 cellpadding=0 cellspacing=0>";
echo "<tr><td class=picture_thumbnail valign=top align=middle>";
// echo "<img src=\\"".$strThumbUrl."\\" border=1 ".$ThumbImageSizeArray[3]." alt=\\"".$strInfo."\\"></a>";
echo "<img src=\\"".$strThumbUrl."\\" border=1 ".$ThumbImageSizeArray[3]." alt=\\"".$strInfo."\\">";
echo "</td></tr><tr><td class=picture_thumbnail valign=top align=middle>";
echo "<a href=\\"".$PHP_SELF."?action=view&album=".$album."&picture=".getPictureIndex($AllFilesArray[$i])."\\">";
echo "<font class=picture_thumbnailtext>".$strFileNameArray[0].".".$strFileNameArray[1];
// $$$ Hier is plek voor meer info
echo "</font></a><br>";
echo "</td></tr></table>";
}
//
// Movies
//
else if (IsMovie($AllFilesArray[$i]))
{
$strInfo = getFileInfo($AllFilesArray[$i]);
echo "<table height=100% width=100% border=0 cellpadding=0 cellspacing=0>";
echo "<tr><td class=movie_thumbnail valign=middle align=middle>";
echo "<img src=\\"".$imageurl."movie_thumb.gif\\" alt=\\"".$strInfo."\\" border=0>";
echo "</td></tr><tr><td class=movie_thumbnail valign=bottom align=middle>";
echo "<a class=movie_thumbnailtext href=\\"".$topurl.$album.$AllFilesArray[$i]."\\"><font class=movie_thumbnailtext>".$AllFilesArray[$i]."</font></a>";
echo "</td></tr></table>";
}
//
// Document
//
else if (IsDocument($AllFilesArray[$i]))
{
$strInfo = getFileInfo($AllFilesArray[$i]);
echo "<table height=100% width=100% border=0 cellpadding=0 cellspacing=0>";
echo "<tr><td class=document_thumbnail valign=middle align=middle>";
echo "<img src=\\"".$imageurl."document_thumb.gif\\" border=0>";
echo "</td></tr><tr><td class=document_thumbnail valign=bottom align=middle>";
echo "<a class=document_thumbnailtext href=\\"".$topurl.$album.$AllFilesArray[$i]."\\"><font class=document_thumbnailtext>".$AllFilesArray[$i]."</font></a>";
echo "</td></tr></table>";
}
echo "</td>";
$i++;
$iColCount++;
if ($iColCount == $iMaxCols)
{
echo "</tr>\\n";
$iColCount = 0;
}
}
echo "</table>\\n";
echo "</center>\\n";
}
/**
* Show page with specified picture
*
* $bOriginalPicture=true shows original picture if exists
* $bOriginalPicture=false shows normal_ picture if exists
*/
function showPicture($bOriginalPicture)
{
global $topdir;
global $topurl;
global $album;
global $PicturesArray;
global $AllFilesArray;
global $normal_prefix;
global $picture;
global $stringArray;
global $generate_normal_images;
global $iNormalImageWidth;
global $iNormalImageHeight;
global $normal_image_jpeg_quality;
//
// Show normal sized picture if exists
//
$strFilename = "";
//
// Small (normal sized) picture is requested
//
$bSmallerPictureUsed = false;
if (!$bOriginalPicture)
{
//
// Smaller (normal sized) picture exists
//
if (file_exists($topdir.$album.$normal_prefix.$PicturesArray[$picture]))
{
$strPictureURL = $topurl.$album.$normal_prefix.$PicturesArray[$picture];
$strPictureFile = $topdir.$album.$normal_prefix.$PicturesArray[$picture];
$bSmallerPictureUsed = true;
}
//
// Smaller (normal sized) picture does not exist
//
else
{
// Try to generate it
$bGenerationSucceeded = false;
if ($generate_normal_images)
{
$bGenerationSucceeded = CreateSmallerImage(
$topdir.$album.$PicturesArray[$picture],
$topdir.$album.$normal_prefix.$PicturesArray[$picture],
$iNormalImageWidth, $iNormalImageHeight,
$normal_image_jpeg_quality);
$strPictureURL = $topurl.$album.$normal_prefix.$PicturesArray[$picture];
$strPictureFile = $topdir.$album.$normal_prefix.$PicturesArray[$picture];
}
if (!$bGenerationSucceeded)
{
$strPictureURL = $topurl.$album.$PicturesArray[$picture];
$strPictureFile = $topdir.$album.$PicturesArray[$picture];
}
else
{
$bSmallerPictureUsed = true;
}
}
}
//
// Original picture
//
else
{
$strPictureURL = $topurl.$album.$PicturesArray[$picture];
$strPictureFile = $topdir.$album.$PicturesArray[$picture];
}
//
// Get file info
//
warnings_off();
$ImageSizeArray = GetImageSize ($strPictureFile);
warnings_on();
// Stop if picture doesn't exist or is incorrect
if (0 == $ImageSizeArray)
{
global $stringArray;
echo "<p><font class=albumtitle>".$stringArray["_picturenotfound"]."</font></p>";
return;
}
// Show navigation etc.
echo "<strong><font class=picturetitle>".$PicturesArray[$picture];
if ($bOriginalPicture)
{
echo " - ".$stringArray["_original"]."<p>";
}
echo "</font></strong>";
if (!$bOriginalPicture)
{
echo "<br>(<font class=subtitle>".$stringArray["_picture"]." ".($picture + 1)." ".$stringArray["_of"]." ".count($PicturesArray).")</font><br>";
showNavigation();
echo "<p>";
}
$strInfo = getFileInfo($PicturesArray[$picture]);
// Link to original picture
if ((file_exists($topdir.$album.$PicturesArray[$picture])) && ($bSmallerPictureUsed))
{
// echo "<a href=\\"".$PHP_SELF."?action=vieworiginal&album=".$album."&picture=".$picture."\\" target=vieworiginal><img src=\\"".$strPictureURL."\\" border=1 ".$ImageSizeArray[3]." alt=\\"".$strInfo."\\"></a>";
echo "<img src=\\"".$strPictureURL."\\" border=1 ".$ImageSizeArray[3]." alt=\\"".$strInfo."\\">";
}
// Show normal sized picture
else
{
echo "<img src=\\"".$strPictureURL."\\" border=1 ".$ImageSizeArray[3]." alt=\\"".$strInfo."\\">";
}
echo "<p>";
echo "<a name=\\"navigation\\"> </a>";
//
// Read textfile if exists
//
$strFilename = $PicturesArray[$picture];
$strExt = GetFileExtension($strFilename);
$strTextFilename = substr($strFilename, 0, strlen($strFilename) - strlen($strExt));
$strTextFilename .= "txt";
$strText = readText($strTextFilename, true /* covnert to html */);
if ($strText != "")
{
echo $strText."<p>";
}
// Only for JPG
if (isJPEG($PicturesArray[$picture]))
{
echo "<a class=navigation href=\\"".$PHP_SELF."?action=exif&album=".$album."&picture=".$picture."\\" target=vieworiginal></a>";
echo "<p>";
}
}
function ShowExifInformation()
{
global $stringArray;
global $topdir;
global $album;
global $PicturesArray;
global $normal_prefix;
global $picture;
// echo "<font class=albumtitle>".$stringArray["_exifinfo"].$PicturesArray[$picture]."</font><br><br>";
// Load original or normal_ file
$strFilename = $topdir.$album.$PicturesArray[$picture];
if (!file_exists($strFilename))
{
$strFilename = $topdir.$album.$normal_prefix.$PicturesArray[$picture];
}
$exif = exif_read_data($strFilename, 0, true);
echo "<center><table border=0 cellpadding=0 cellspacing=0 bordercolor=black>";
foreach ($exif as $key => $section) {
foreach ($section as $name => $val) {
echo "<tr><td valign=top align=left>$key.$name</td><td valign=top align=left>: </td><td valign=top align=left>$val</td></tr>\\n";
}
}
echo "</table></center>";
echo "<p>";
echo "<input type=button value=\\"".$stringArray["_closewindow"]."\\" onClick=\\"javascript:window.close();\\">";
echo "</p>";
}
function ShowTree()
{
}
/**********************************************************************
* Data retrieval and mutation
**********************************************************************/
function getPictureIndex($strName)
{
global $PicturesArray;
$iCount = 0;
while ($strName != $PicturesArray[$iCount])
{
$iCount++;
}
if ($strName != $PicturesArray[$iCount])
{
return -1;
}
else
{
return $iCount;
}
}
function readText($strFilename, $bConvertToHTML)
{
global $topdir;
global $album;
$strFilename = $topdir.$album.$strFilename;
$strContents = "";
if (file_exists($strFilename))
{
$handle = fopen ($strFilename, "r");
$strContents = fread ($handle, filesize ($strFilename));
fclose ($handle);
}
if ($bConvertToHTML)
{
$strContents = nl2br($strContents);
}
return $strContents;
}
function IsPicture($strFileName)
{
global $allowed_pictures;
$strExt = GetFileExtension($strFileName);
return (in_array($strExt, $allowed_pictures));
}
function IsJPEG($strFileName)
{
global $allowed_pictures;
$strExt = GetFileExtension($strFileName);
return (($strExt == "jpeg" || $strExt == "jpg"));
}
function IsMovie($strFileName)
{
global $allowed_movies;
$strExt = GetFileExtension($strFileName);
return (in_array($strExt, $allowed_movies));
}
function IsDocument($strFileName)
{
global $allowed_documents;
$strExt = GetFileExtension($strFileName);
return (in_array($strExt, $allowed_documents));
}
// Converts xxxxxxx bytes to x,xxx KB
function Bytes2KBytes($bytes)
{
$KB = round($bytes / 1024);
return $KB;
}
function getFirstThumbnail($strDirectory)
{
global $thumb_prefix;
warnings_off();
$d = dir($strDirectory);
warnings_on();
if (0 == $d)
{
return 0;
}
while ($entry = $d->read())
{
if (!is_dir($strDirectory.$entry))
{
if (IsPicture($entry))
{
if (strToLower(substr($entry,0,strlen($thumb_prefix)) == $thumb_prefix))
{
return $entry;
break;
}
}
}
}
}
function getDirectoryInfo($strDirectory)
{
global $normal_prefix;
global $thumb_prefix;
global $stringArray;
$iDirectories = 0;
$iThumbnails = 0;
$iPictures = 0;
$iMovies = 0;
$iDocuments = 0;
warnings_off();
$d = dir($strDirectory);
warnings_on();
// Check validity of directory
if (0 == $d)
{
return $stringArray["_errorreaddir"];
}
while ($entry = $d->read())
{
if (!is_dir($strDirectory.$entry))
{
if (IsPicture($entry))
{
// Count thumbnails
if (strToLower(substr($entry,0,strlen($thumb_prefix)) == $thumb_prefix))
{
$iThumbnails++;
}
else
{
//
// remove normal_ prefix if present
//
if (strToLower(substr($entry,0,strlen($normal_prefix)) == $normal_prefix))
{
$entry = substr($entry, strlen($normal_prefix), strlen($entry) - strlen($normal_prefix));
}
//
// Only add if not already added
//
if (!is_array($TempArray))
{
$TempArray[$iPictures] = $entry;
$iPictures++;
}
else if (!in_array($entry, $TempArray))
{
$TempArray[$iPictures] = $entry;
$iPictures++;
}
}
}
elseif (IsMovie($entry))
{
$iMovies++;
}
elseif (IsDocument($entry))
{
$iDocuments++;
}
}
else
{
$iDirectories++;
}
}
if ($iDirectories >= 2)
{
$iDirectories = $iDirectories - 2;
}
$strInfo = $stringArray["_albumcontains"]." ";
$strInfo .= $iPictures." ".$stringArray["_pictures"].", ";
$strInfo .= $iMovies." ".$stringArray["_movies"].", \\n";
$strInfo .= $iDocuments." ".$stringArray["_documents"].", ";
$strInfo .= $stringArray["_and"]." ".$iDirectories." ".$stringArray["_otheralbums"]."\\n";
return $strInfo;
}
function getFileInfo($strFilename)
{
global $topdir;
global $album;
global $normal_prefix;
global $stringArray;
// Full path to picture
$strFullFilename = $topdir.$album.$strFilename;
// Filename
$strInfo = $strFilename."\\n";
// Get image resolution
if (IsPicture($strFilename))
{
// Check if picture exists, otherwise use normal_
if (!file_exists($strFullFilename))
{
$strFullFilename = $topdir.$album.$normal_prefix.$strFilename;
}
$ImageSizeArray = GetImageSize ($strFullFilename);
$strInfo .= $ImageSizeArray[0]."x".$ImageSizeArray[1]."\\n";
}
// Get filesize
$iFileSize = Bytes2KBytes(filesize($strFullFilename));
$strInfo .= $iFileSize." KB\\n";
//
// Filetype
//
if (IsMovie($strFilename))
{
$strInfo .= $stringArray["_filetype"].": ".$stringArray["_movie"]."\\n";
}
else if (IsDocument($strFilename))
{
$strInfo .= $stringArray["_filetype"].": ".$stringArray["_document"]."\\n";
}
else if (IsPicture($strFilename))
{
$strInfo .= $stringArray["_filetype"].": ".$stringArray["_picture"]."\\n";
}
//
// Read textfile if exists
//
$strExt = GetFileExtension($strFilename);
if ((strToLower($strExt) != "txt"))
{
$strTextFilename = substr($strFilename, 0, strlen($strFilename) - strlen($strExt));
$strTextFilename .= "txt";
$strDescription = readText($strTextFilename, false /* do not convert to html */);
if ($strDescription != "")
{
$strInfo .= "\\n".$strDescription."\\n";;
}
}
return $strInfo;
}
//
// Read files in directory
//
function readAlbum()
{
global $topdir;
global $album;
global $thumb_prefix;
global $normal_prefix;
global $AlbumsArray;
global $PicturesArray;
global $OtherFilesArray;
global $AllFilesArray;
$iAlbumsRead = 0;
$iPicturesRead = 0;
$iOtherFilesRead= 0;
warnings_off();
$d = dir($topdir.$album);
warnings_on();
// Album not found
if (0 == $d)
{
return false;
}
while ($entry = $d->read())
{
//
// Exclude thumb_ pictures
// Read both normal_ and original pictures, but only add one of them
//
if (strToLower(substr($entry,0,strlen($thumb_prefix)) != $thumb_prefix))
{
//
// Files
//
if (is_readable($topdir.$album.$entry))
{
if (!is_dir($topdir.$album.$entry))
{
if (IsPicture($entry))
{
//
// remove normal_ prefix if present
//
if (strToLower(substr($entry,0,strlen($normal_prefix)) == $normal_prefix))
{
$entry = substr($entry, strlen($normal_prefix), strlen($entry) - strlen($normal_prefix));
}
//
// Only add if not already added
//
if (!is_array($PicturesArray))
{
$PicturesArray[$iPicturesRead] = $entry;
$iPicturesRead++;
}
else if (!in_array($entry, $PicturesArray))
{
$PicturesArray[$iPicturesRead] = $entry;
$iPicturesRead++;
}
}
else if (IsDocument($entry))
{
$OtherFilesArray[$iOtherFilesRead] = $entry;
$iOtherFilesRead++;
}
else if (IsMovie($entry))
{
$OtherFilesArray[$iOtherFilesRead] = $entry;
$iOtherFilesRead++;
}
}
//
// Directories (albums)
//
else
{
if ($entry != ".")
{
// Do not show previous dir when on toplevel
if (!(($album == "") and ($entry == "..")))
{
$AlbumsArray[$iAlbumsRead] = $entry;
$iAlbumsRead++;
}
}
} // is_dir
} // is_readable
}
}
//
// Sort the pictures
//
if (count($PicturesArray) > 0)
{
//usort($PicturesArray,"filenamecmp");
sort($PicturesArray);
}
//
// Sort the other files
//
if (count($OtherFilesArray) > 0)
{
usort($OtherFilesArray,"filenamecmp");
}
//
// Sort the albums
//
if (count($AlbumsArray) > 0)
{
sort($AlbumsArray);
}
//
// Merge the two arrays of pictures and other files
//
$AllFilesArray = array_merge($PicturesArray, $OtherFilesArray);
if (count($AllFilesArray) > 0)
{
//usort($AllFilesArray,"filenamecmp");
sort($AllFilesArray);
}
return true;
}
/**********************************************************************
* Main
**********************************************************************/
//
// Header
//
echo "<center>";
// Read files
if ($action != "die")
{
if (!readAlbum())
{
global $stringArray;
showAlbumsNavigation($album);
echo "<p><font class=albumtitle>".$stringArray["_albumnotfound"]."</font></p>";
$action = "die";
}
}
//
// View
//
if ($action == "view")
{
showAlbumsNavigation($album);
echo "<br>";
showPicture(false);
}
else if ($action == "vieworiginal")
{
showPicture(true);
echo "<p>";
echo "<input type=button value=\\"".$stringArray["_closewindow"]."\\" onClick=\\"javascript:window.close();\\">";
echo "</p>";
}
//
// ZIP and download the album
//
else if ($action == "download")
{
echo "Please be patient while the album is being zipped";
echo system("zip -r /tmp/silvermine_album.zip ".$topdir.$album."/* 2>&1");
}
//
// Exif info
//
else if ($action == "exif")
{
showExifInformation();
}
else if ($action == "tree")
{
ShowTree();
}
else if ($action == "die")
{
// do nothing
}
//
// Thumbnails
//
else
{
showAlbumsNavigation($album);
echo "";
$strText = readText("album.txt", true /* convert to html */);
if ($strText != "")
{
echo $strText."";
}
showThumbnails();
echo "";
echo getDirectoryInfo($topdir.$album);
echo "";
}
// Footer
echo "<hr>";
echo $progname." ".$version." - ".$copyright;
echo "</center>";
?>
Jeg har været over den flere gange, men synes ikke at kunne finde den rette linie. Når den findes og ændres, må den ikke sætte en kant rundt om "tilbage" ikonet.
Hvordan løser jeg det?