<?
ini_set('display_errors', 0);
$extensions = array('gif','jpg','jpeg','png','bmp','wbm');
$thumbMaxSize = 150;
$tBorder = TRUE;
$imagesHorizonally = -1;
function CreateThumbnail ( $filename, $border = TRUE, $maxSize = 150, $quality = 90 )
{
$imagePath = WorkingDir(0) . $filename;
if ( $image = @imagecreatefromjpeg ( $imagePath ) )
{
$iWidth = imagesX ( $image );
$iHeight = imagesY ( $image );
$nHeight;
$nWidth;
if ( $iWidth > $iHeight )
{
$nWidth = $maxSize;
$nHeight = floor ( $iHeight * ( $maxSize / $iWidth ) );
}
else
{
$nHeight = $maxSize;
$nWidth = floor ( $iWidth * ( $maxSize / $iHeight ) );
}
rMkDir ( WorkingDir(1) );
$thumbImage = ImageCreateTrueColor ( $nWidth, $nHeight );
$thumbPath = WorkingDir(1) . $filename;
imagecopyresampled($thumbImage, $image, 0, 0, 0, 0, $nWidth, $nHeight, $iWidth, $iHeight);
if ( $Border )
{
$black = imagecolorallocate($tImg, 0, 0, 0);
$white = imagecolorallocate($tImg, 255, 255, 255);
imagerectangle($tImg, 0, 0, $tWidth - 1, $tHeight - 1, $black);
imagerectangle($tImg, 1, 1, $tWidth - 2, $tHeight - 2, $white);
imagerectangle($tImg, 2, 2, $tWidth - 3, $tHeight - 3, $white);
}
ImageJPEG($thumbImage,$thumbPath,$quality);
chmod($thumbPath, 0644);
imagedestroy($thumbImage);
imagedestroy($image);
return TRUE;
}
else
{
return FALSE;
}
}
function ScanDirectory( $folderPath )
{
if ( is_dir ( $folderPath ) )
{
$results;
if ( $dh = opendir ( $folderPath ) )
{
$i = 0;
while ( ($file = readdir ( $dh ) ) !== false )
{
if ( $file != "." && $file != ".." )
{
$results[$i] = $file;
$i++;
}
}
closedir($dh);
}
return $results;
}
else
{
return array();
}
}
function FolderDelete ( $folderPath )
{
if ( is_dir ( $folderPath ) )
{
foreach ( ScanDirectory ( $folderPath ) as $value )
{
if ( $value != "." && $value != ".." )
{
$value = $folderPath . DIRECTORY_SEPARATOR . $value;
if ( is_dir ( $value ) )
{
FolderDelete ( $value );
}
elseif ( is_file ( $value ) )
{
@unlink ( $value );
}
}
}
rmdir ( $folderPath );
return TRUE;
}
else
{
return FALSE;
}
}
function rMkDir ( $path )
{
if ( !is_dir ( $path ) )
{
if ( version_compare ( PHP_VERSION, '5.0.0' ) < 0 )
{
$exp = explode ( DIRECTORY_SEPARATOR, $path );
$way = '';
foreach ( $exp as $n )
{
$way .= $n . DIRECTORY_SEPARATOR;
if ( !file_exists ( $way ) )
{
mkdir ( $way, 0777 );
}
}
}
else
{
mkdir ( $path, 0777, TRUE );
}
}
}
function BBCode ( $iFilename, $thumbnail = FALSE )
{
$imagePath = ImageLink ( $iFilename );
if ( ThumbnailExists ( $iFilename ) && $thumbnail )
{
$thumbnailPath = ThumbLink ( $iFilename );
return "[url=" . $imagePath . "][img]" . $thumbnailPath . "[/img][/url]";
}
else
{
return "[img]" . $imagePath . "[/img]";
}
}
function ImageLink ( $iFilename )
{
return "http://" . $_SERVER['HTTP_HOST'] . str_replace ( "index.php", "", $_SERVER['PHP_SELF'] ) . "albums" . str_replace ( "//", "/", str_replace ( "\\", "/", str_replace ( " ", "%20", $_GET['dir'] ) ) ) . "/" . $iFilename;
}
function ThumbLink ( $iFilename )
{
return "http://" . $_SERVER['HTTP_HOST'] . str_replace ( "index.php", "", $_SERVER['PHP_SELF'] ) . "thumbs" . str_replace ( "//", "/", str_replace ( "\\", "/", str_replace ( " ", "%20", $_GET['dir'] ) ) ) . "/" . $iFilename;
}
function WorkingDir ( $type = 0 )
{
$cDir;
if ( DIRECTORY_SEPARATOR == "/" )
{
$cDir = str_replace ( "//", "/", str_replace ( "\\", "/", $_GET['dir'] ) );
}
else
{
$cDir = str_replace ( "\\\\", "\\", $_GET['dir'] );
}
switch ( $type )
{
Case 0:
return getcwd() . DIRECTORY_SEPARATOR . "albums" . $cDir . DIRECTORY_SEPARATOR;
break;
Case 1:
return getcwd() . DIRECTORY_SEPARATOR . "thumbs" . $cDir . DIRECTORY_SEPARATOR;
break;
}
}
function ThumbnailExists ( $iFilename )
{
if ( file_exists ( WorkingDir(1) . $iFilename ) )
{
return TRUE;
}
else
{
return FALSE;
}
}
function ActionBoxHTML ( $title, $body )
{
$tabs = "\t\t\t";
return $tabs . "<div id=\"action\">" . "\n" . "\t\t\t\t\t" . "<h2>" . $title . ":</h2>" . "\n" .
$tabs . "\t" . $body . "\n" .
$tabs . "\t" . "<p class=\"right\"><a href=\"?dir=" . stripslashes ( $_GET['dir'] ) . "\" title=\"Close BB Code box\">Close</a></p>" . "\n" .
$tabs . "</div>";
}
$actionHTML;
$feedback;
if ( !is_dir ( WorkingDir() ) )
{
$_GET['dir'] = "";
}
if ( $_POST['folderAction'] )
{
if ( $_GET['dir'] != "" )
{
if ( FolderDelete ( WorkingDir() ) )
{
FolderDelete ( WorkingDir(1) );
$feedback = "<p id=\"fb2\"><b>Feedback:</b> The folder was successfully deleted.</p>";
$_GET['dir'] = "";
}
else
{
$feedback = "<p id=\"fb1\"><b>Error:</b> The operation could not be completed.</p>";
}
}
else
{
$feedback = "<p id=\"fb1\"><b>Error:</b> You cannot delete the root folder!</p>";
}
}
if ( $_POST['imageAction'] )
{
if ( $_POST['image'] )
{
$imageArray;
$i = 0;
while ( list ( $key, $val ) = @each ( $_POST['image'] ) )
{
$imageArray[$i] = $val;
$i++;
}
switch ( $_POST['imageAction'] )
{
Case "Recreate Thumbnails":
$success = 0;
$failed = 0;
$nothumb = 0;
foreach( $imageArray as $value )
{
if ( CreateThumbnail ( $value, $tBorder ) )
{
$success++;
}
else
{
$failed++;
}
}
$fbType = "2";
if ( ( $nothumb > $success ) && ( $nothumb > $failed ) )
{
$fbType = "3";
}
else
{
if ( $failed > $success )
{
$fbType = "1";
}
}
$fbMessage = "";
if ( $success > 0 )
{
$fbMessage .= " " . $success . " image thumbnail(s) were successfully created.";
}
if ( $failed > 0 )
{
$fbMessage .= " " . $failed . " image or thumbnail(s) could <u>not</u> be created.";
}
if ( $nothumb > 0 )
{
$fbMessage .= " " . $nothumb . " image(s) <u>do not</u> need thumbnails.";
}
$feedback = "<p id=\"fb" . $fbType . "\"><b>Feedback:</b>" . $fbMessage . "</p>";
break;
Case "Generate BB Code":
$bbCode;
$i = 0;
foreach( $imageArray as $value )
{
$bbCode .= BBCode ( $value, TRUE );
$i++;
if ( $i == $imagesHorizonally )
{
$bbCode .= "\r\n";
$i = 0;
}
else
{
$bbCode .= " ";
}
}
$actionHTML = ActionBoxHTML ( "BB Code", "<textarea rows=\"7\" cols=\"70\" onfocus=\"this.select()\">" . $bbCode . "</textarea>" );
break;
Case "Delete":
$success = 0;
$failed = 0;
$nonexistant = 0;
foreach( $imageArray as $value )
{
if ( is_file ( WorkingDir() . $value ) )
{
if ( @unlink ( WorkingDir() . $value ) )
{
if ( ThumbnailExists ( WorkingDir(1) . $value ) )
{
if ( @unlink ( WorkingDir(1) . $value ) )
{
$success++;
}
else
{
$failed++;
}
}
else
{
$success++;
}
}
else
{
$failed++;
}
}
else
{
$nonexistant++;
}
}
$fbType = "2";
if ( ( $failed + $nonexistant ) > $success )
{
$fbType = "1";
}
$fbMessage = "";
if ( $success > 0 )
{
$fbMessage .= " " . $success . " image(s) and thumbnail(s) were successfully deleted.";
}
if ( $failed > 0 )
{
$fbMessage .= " " . $failed . " image(s) or thumbnail(s) could <u>not</u> be deleted.";
}
if ( $nonexistant > 0 )
{
$fbMessage .= " " . $nonexistant . " image(s) did not exist on the server.";
}
$feedback = "<p id=\"fb" . $fbType . "\"><b>Feedback:</b>" . $fbMessage . "</p>";
break;
}
}
else
{
$feedback = "<p id=\"fb1\"><b>Error:</b> No images were selected.</p>";
}
}
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>eGallery</title>
<link rel="stylesheet" type="text/css" href="style.css" media="all" />
<script type="text/javascript">
var formblock;
var forminputs;
function prepare() {
formblock= document.getElementById('selected_images');
forminputs = formblock.getElementsByTagName('input');
}
function select_all(name, value) {
for (i = 0; i < forminputs.length; i++) {
var regex = new RegExp(name, "i");
if (regex.test(forminputs[i].getAttribute('name'))) {
if (value == '1') {
forminputs[i].checked = true;
} else {
forminputs[i].checked = false;
}
}
}
}
if (window.addEventListener) {
window.addEventListener("load", prepare, false);
} else if (window.attachEvent) {
window.attachEvent("onload", prepare)
} else if (document.getElementById) {
window.onload = prepare;
}
</script>
</head>
<body>
<div id="cont">
<h1>e<span class="blue">Gallery</span></h1>
<div id="main">
<ul>
<li><img src="images/folder.png" alt="Current Directory:" /><a href="?" title="Navigate to: Root Folder">Root Folder</a></li>
<li>//</li>
<?
$tabs = "\t\t\t\t";
$dirBuild = "";
foreach( explode ( "\\", $_GET['dir'] ) as $value )
{
if ( $value != "" )
{
$dirBuild .= "\\" . $value;
echo $tabs . "<li><a href=\"?dir=" . $dirBuild . "\" title=\"Navigate to: " . $value . "\">" . $value . "</a></li>" . "\n" .
$tabs . "<li>//</li>" . "\n";
}
}
?>
</ul>
<?
if ( $actionHTML != "" )
{
echo $actionHTML . "\n";
}
?>
<form id="selected_images" method="post" action="">
<ul id="user">
<li style="float:left"><input type="button" onClick="select_all('image', '1');" value="Select All" /></li>
<li style="float:left"><input type="button" onClick="select_all('image', '0');" value="Deselect All" /></li>
<li><input name="folderAction" type="submit" class="del" onclick="return confirm('Are you sure you wish to delete the current directory?\r\nAny files or folders in the directory will be deleted too!');" value="Delete Folder" /></li>
<li><input name="imageAction" type="submit" class="del" onclick="return confirm('Are you sure you wish to delete the selected images?');" value="Delete" /></li>
<li><input name="imageAction" type="submit" value="Generate BB Code" /></li>
<li><input name="imageAction" type="submit" value="Recreate Thumbnails" /></li>
</ul>
<ul>
<li><h2>Folders in Current Directory:</h2></li>
<?
$tabs = "\t\t\t\t\t";
$i = 0;
foreach ( ScanDirectory( WorkingDir() ) as $value )
{
if ( is_dir ( WorkingDir() . $value ) )
{
echo $tabs . "<li>-</li>" . "\n" .
$tabs . "<li><img src=\"images/folder.png\" alt=\"Folder\" /><a href=\"?dir=" . $_GET['dir'] . "\\" . $value . "\" title=\"Navigate to: $value\">$value</a></li>" . "\n";
$i++;
}
}
if ( $i == 0 )
{
echo $tabs . "<li>No folders in this directory</li>" . "\n";
}
?>
</ul>
<?
$tabs = "\t\t\t\t";
if ( $feedback != "" )
{
echo $tabs . $feedback . "\n";
}
$i = 0;
foreach( ScanDirectory( WorkingDir() ) as $value )
{
if ( is_file ( WorkingDir() . $value ) )
{
if ( in_array( strtolower ( end ( explode ( ".", $value ) ) ), $extensions) )
{
$thumbBox;
$thumbnailSRC = "images/image.png";
if ( ThumbnailExists ( $value ) )
{
$thumbBox = $tabs . "\t\t" . "<h2>Thumb BB Code:</h2>" . "\n" . $tabs . "\t\t" . "<input class=\"i_code\" onfocus=\"this.select()\" value=\"" . BBCode ( $value, TRUE ) . "\" />" . "\n";
$thumbnailSRC = ThumbLink ( $value );
}
echo $tabs . "<div class=\"thumb\">" . "\n" .
$tabs . "\t" . "<a href=\"" . ImageLink ( $value ) . "\" target=\"_blank\" title=\"Open image: " . $value . "\"><img src=\"" . $thumbnailSRC . "\" alt=\"" . $value . " thumbnail\" /></a>" . "\n" .
$tabs . "\t" . "<p class=\"code\">" . "\n" .
$thumbBox .
$tabs . "\t\t" . "<h2>Direct BB Code:</h2>" . "\n" .
$tabs . "\t\t" . "<input class=\"i_code\" onfocus=\"this.select()\" value=\"" . BBCode ( $value ) . "\" /><br />" . "\n" .
$tabs . "\t\t" . "<input class=\"check\" type=\"checkbox\" name=\"image[]\" value=\"" . $value . "\" />Select Image" . "\n" .
$tabs . "\t" . "</p>" . "\n" .
$tabs . "\t" . "<p class=\"clear\"></p>" . "\n" .
$tabs . "</div>" . "\n";
$thumbBox = "";
$i++;
}
}
}
if ( $i == 0 )
{
echo $tabs . "<div class=\"thumb\">" . "\n" .
$tabs . "\t" . "<p class=\"center\"><b>There are no images in this folder!</b></p>" . "\n" .
$tabs . "</div>" . "\n";
}
?>
</form>
</div>
<p id="copy">Copyright e<span class="blue">Gallery</span> // All rights reserved.</p>
</div>
</body>
</html>
What do you mean by this?
HOW DARE YOU!!!£"!£
lol...i joke!.....i'm not bothered don't worry.
Anychance you could post marc's script so i can see how it works and hopefully improve mine.
Thanks.
$ convert -strip 200x200 foo.jpg foo.thumb.jpg &
Use ImageMagick to resize images, sorted.
I was under the impression that ImageMagick isn't enabled on most servers, so i thought GD would be best?
Would i be wrong in assuming that?
<?
ini_set('display_errors', 0);
set_time_limit(0);
$extensions = array('gif','jpg','jpeg','png','bmp','wbm');
$thumbMaxSize = 150;
$tBorder = TRUE;
$imagesHorizonally = 2;
function CreateThumbnail ( $filename, $border = TRUE, $maxSize = 150, $quality = 90 )
{
$imagePath = WorkingDir() . $filename;
if ( $image = @imagecreatefromjpeg ( $imagePath ) )
{
$iWidth = imagesX ( $image );
$iHeight = imagesY ( $image );
$nHeight;
$nWidth;
if ( $iWidth > $iHeight )
{
$nWidth = $maxSize;
$nHeight = floor ( $iHeight * ( $maxSize / $iWidth ) );
}
else
{
$nHeight = $maxSize;
$nWidth = floor ( $iWidth * ( $maxSize / $iHeight ) );
}
$thumbImage = ImageCreateTrueColor ( $nWidth, $nHeight );
$thumbPath = WorkingDir(1) . $filename;
imagecopyresampled($thumbImage, $image, 0, 0, 0, 0, $nWidth, $nHeight, $iWidth, $iHeight);
if ( $border )
{
$black = imagecolorallocate($thumbImage, 0, 0, 0);
$white = imagecolorallocate($thumbImage, 255, 255, 255);
imagerectangle($thumbImage, 0, 0, $nWidth - 1, $nHeight - 1, $black);
imagerectangle($thumbImage, 1, 1, $nWidth - 2, $nHeight - 2, $white);
imagerectangle($thumbImage, 2, 2, $nWidth - 3, $nHeight - 3, $white);
}
ImageJPEG($thumbImage,$thumbPath,$quality);
chmod($thumbPath, 0644);
imagedestroy($thumbImage);
imagedestroy($image);
return TRUE;
}
else
{
return FALSE;
}
}
function ScanDirectory( $folderPath )
{
if ( is_dir ( $folderPath ) )
{
$results;
if ( $dh = opendir ( $folderPath ) )
{
$i = 0;
while ( ($file = readdir ( $dh ) ) !== false )
{
if ( $file != "." && $file != ".." )
{
$results[$i] = $file;
$i++;
}
}
closedir($dh);
}
return $results;
}
else
{
return array();
}
}
function FolderDelete ( $folderPath )
{
if ( is_dir ( $folderPath ) )
{
foreach ( ScanDirectory ( $folderPath ) as $value )
{
if ( $value != "." && $value != ".." )
{
$value = $folderPath . DIRECTORY_SEPARATOR . $value;
if ( is_dir ( $value ) )
{
FolderDelete ( $value );
}
elseif ( is_file ( $value ) )
{
@unlink ( $value );
}
}
}
rmdir ( $folderPath );
return TRUE;
}
else
{
return FALSE;
}
}
function rMkDir ( $path )
{
if ( !is_dir ( $path ) )
{
if ( version_compare ( PHP_VERSION, '5.0.0' ) < 0 )
{
$exp = explode ( DIRECTORY_SEPARATOR, $path );
$way = '';
foreach ( $exp as $n )
{
$way .= $n . DIRECTORY_SEPARATOR;
if ( !file_exists ( $way ) )
{
mkdir ( $way, 0777 );
}
}
}
else
{
mkdir ( $path, 0777, TRUE );
}
}
}
function BBCode ( $iFilename, $thumbnail = FALSE )
{
$imagePath = ImageLink ( $iFilename );
if ( ThumbnailExists ( $iFilename ) && $thumbnail )
{
$thumbnailPath = ThumbLink ( $iFilename );
return "[url=" . $imagePath . "][img]" . $thumbnailPath . "[/img][/url]";
}
else
{
return "[img]" . $imagePath . "[/img]";
}
}
function ImageLink ( $iFilename )
{
return "http://" . $_SERVER['HTTP_HOST'] . str_replace ( "index.php", "", $_SERVER['PHP_SELF'] ) . "albums" . str_replace ( "//", "/", str_replace ( "\\", "/", str_replace ( " ", "%20", $_GET['dir'] ) ) ) . "/" . $iFilename;
}
function ThumbLink ( $iFilename )
{
return "http://" . $_SERVER['HTTP_HOST'] . str_replace ( "index.php", "", $_SERVER['PHP_SELF'] ) . "thumbs" . str_replace ( "//", "/", str_replace ( "\\", "/", str_replace ( " ", "%20", $_GET['dir'] ) ) ) . "/" . $iFilename;
}
function WorkingDir ( $type = 0 )
{
$cDir;
if ( DIRECTORY_SEPARATOR == "/" )
{
$cDir = str_replace ( "//", "/", str_replace ( "\\", "/", $_GET['dir'] ) );
}
else
{
$cDir = str_replace ( "\\\\", "\\", $_GET['dir'] );
}
switch ( $type )
{
Case 0:
return getcwd() . DIRECTORY_SEPARATOR . "albums" . $cDir . DIRECTORY_SEPARATOR;
break;
Case 1:
return getcwd() . DIRECTORY_SEPARATOR . "thumbs" . $cDir . DIRECTORY_SEPARATOR;
break;
}
}
function ThumbnailExists ( $iFilename )
{
if ( file_exists ( WorkingDir(1) . $iFilename ) )
{
return TRUE;
}
else
{
return FALSE;
}
}
function ActionBoxHTML ( $title, $body )
{
$tabs = "\t\t\t";
return $tabs . "<div id=\"action\">" . "\n" . "\t\t\t\t\t" . "<h2>" . $title . ":</h2>" . "\n" .
$tabs . "\t" . $body . "\n" .
$tabs . "\t" . "<p class=\"right\"><a href=\"?dir=" . stripslashes ( $_GET['dir'] ) . "\" title=\"Close BB Code box\">Close</a></p>" . "\n" .
$tabs . "</div>";
}
$actionHTML;
$feedback;
if ( !is_dir ( WorkingDir() ) )
{
$_GET['dir'] = "";
}
if ( $_POST['folderAction'] )
{
if ( $_GET['dir'] != "" )
{
if ( FolderDelete ( WorkingDir() ) )
{
FolderDelete ( WorkingDir(1) );
$feedback = "<p id=\"fb2\"><b>Feedback:</b> The folder was successfully deleted.</p>";
$_GET['dir'] = "";
}
else
{
$feedback = "<p id=\"fb1\"><b>Error:</b> The operation could not be completed.</p>";
}
}
else
{
$feedback = "<p id=\"fb1\"><b>Error:</b> You cannot delete the root folder!</p>";
}
}
if ( $_POST['imageAction'] )
{
if ( $_POST['image'] )
{
$imageArray;
$i = 0;
while ( list ( $key, $val ) = @each ( $_POST['image'] ) )
{
$imageArray[$i] = $val;
$i++;
}
switch ( $_POST['imageAction'] )
{
Case "Recreate Thumbnails":
$success = 0;
$failed = 0;
$nothumb = 0;
rMkDir ( WorkingDir(1) );
$startTime = time();
foreach( $imageArray as $value )
{
if ( CreateThumbnail ( $value ) )
{
$success++;
}
else
{
$failed++;
}
}
echo time() - $startTime;
die();
$fbType = "2";
if ( ( $nothumb > $success ) && ( $nothumb > $failed ) )
{
$fbType = "3";
}
else
{
if ( $failed > $success )
{
$fbType = "1";
}
}
$fbMessage = "";
if ( $success > 0 )
{
$fbMessage .= " " . $success . " image thumbnail(s) were successfully created.";
}
if ( $failed > 0 )
{
$fbMessage .= " " . $failed . " image or thumbnail(s) could <u>not</u> be created.";
}
if ( $nothumb > 0 )
{
$fbMessage .= " " . $nothumb . " image(s) <u>do not</u> need thumbnails.";
}
$feedback = "<p id=\"fb" . $fbType . "\"><b>Feedback:</b>" . $fbMessage . "</p>";
break;
Case "Generate BB Code":
$bbCode;
$i = 0;
foreach( $imageArray as $value )
{
$bbCode .= BBCode ( $value, TRUE );
$i++;
if ( $i == $imagesHorizonally )
{
$bbCode .= "\r\n";
$i = 0;
}
else
{
$bbCode .= " ";
}
}
$actionHTML = ActionBoxHTML ( "BB Code", "<textarea rows=\"7\" cols=\"70\" onfocus=\"this.select()\">" . $bbCode . "</textarea>" );
break;
Case "Delete":
$success = 0;
$failed = 0;
$nonexistant = 0;
foreach( $imageArray as $value )
{
if ( is_file ( WorkingDir() . $value ) )
{
if ( @unlink ( WorkingDir() . $value ) )
{
if ( ThumbnailExists ( WorkingDir(1) . $value ) )
{
if ( @unlink ( WorkingDir(1) . $value ) )
{
$success++;
}
else
{
$failed++;
}
}
else
{
$success++;
}
}
else
{
$failed++;
}
}
else
{
$nonexistant++;
}
}
$fbType = "2";
if ( ( $failed + $nonexistant ) > $success )
{
$fbType = "1";
}
$fbMessage = "";
if ( $success > 0 )
{
$fbMessage .= " " . $success . " image(s) and thumbnail(s) were successfully deleted.";
}
if ( $failed > 0 )
{
$fbMessage .= " " . $failed . " image(s) or thumbnail(s) could <u>not</u> be deleted.";
}
if ( $nonexistant > 0 )
{
$fbMessage .= " " . $nonexistant . " image(s) did not exist on the server.";
}
$feedback = "<p id=\"fb" . $fbType . "\"><b>Feedback:</b>" . $fbMessage . "</p>";
break;
}
}
else
{
$feedback = "<p id=\"fb1\"><b>Error:</b> No images were selected.</p>";
}
}
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>eGallery</title>
<link rel="stylesheet" type="text/css" href="style.css" media="all" />
<script type="text/javascript">
var formblock;
var forminputs;
function prepare() {
formblock= document.getElementById('selected_images');
forminputs = formblock.getElementsByTagName('input');
}
function select_all(name, value) {
for (i = 0; i < forminputs.length; i++) {
var regex = new RegExp(name, "i");
if (regex.test(forminputs[i].getAttribute('name'))) {
if (value == '1') {
forminputs[i].checked = true;
} else {
forminputs[i].checked = false;
}
}
}
}
if (window.addEventListener) {
window.addEventListener("load", prepare, false);
} else if (window.attachEvent) {
window.attachEvent("onload", prepare)
} else if (document.getElementById) {
window.onload = prepare;
}
</script>
</head>
<body>
<div id="cont">
<h1>e<span class="blue">Gallery</span></h1>
<div id="main">
<ul>
<li><img src="images/folder.png" alt="Current Directory:" /><a href="?" title="Navigate to: Root Folder">Root Folder</a></li>
<li>//</li>
<?
$tabs = "\t\t\t\t";
$dirBuild = "";
foreach( explode ( "\\", $_GET['dir'] ) as $value )
{
if ( $value != "" )
{
$dirBuild .= "\\" . $value;
echo $tabs . "<li><a href=\"?dir=" . $dirBuild . "\" title=\"Navigate to: " . $value . "\">" . $value . "</a></li>" . "\n" .
$tabs . "<li>//</li>" . "\n";
}
}
?>
</ul>
<?
if ( $actionHTML != "" )
{
echo $actionHTML . "\n";
}
?>
<form id="selected_images" method="post" action="">
<ul id="user">
<li style="float:left"><input type="button" onClick="select_all('image', '1');" value="Select All" /></li>
<li style="float:left"><input type="button" onClick="select_all('image', '0');" value="Deselect All" /></li>
<li><input name="folderAction" type="submit" class="del" onclick="return confirm('Are you sure you wish to delete the current directory?\r\nAny files or folders in the directory will be deleted too!');" value="Delete Folder" /></li>
<li><input name="imageAction" type="submit" class="del" onclick="return confirm('Are you sure you wish to delete the selected images?');" value="Delete" /></li>
<li><input name="imageAction" type="submit" value="Generate BB Code" /></li>
<li><input name="imageAction" type="submit" value="Recreate Thumbnails" /></li>
</ul>
<ul>
<li><h2>Folders in Current Directory:</h2></li>
<?
$tabs = "\t\t\t\t\t";
$i = 0;
foreach ( ScanDirectory( WorkingDir() ) as $value )
{
if ( is_dir ( WorkingDir() . $value ) )
{
echo $tabs . "<li>-</li>" . "\n" .
$tabs . "<li><img src=\"images/folder.png\" alt=\"Folder\" /><a href=\"?dir=" . $_GET['dir'] . "\\" . $value . "\" title=\"Navigate to: $value\">$value</a></li>" . "\n";
$i++;
}
}
if ( $i == 0 )
{
echo $tabs . "<li>No folders in this directory</li>" . "\n";
}
?>
</ul>
<?
$tabs = "\t\t\t\t";
if ( $feedback != "" )
{
echo $tabs . $feedback . "\n";
}
$i = 0;
foreach( ScanDirectory( WorkingDir() ) as $value )
{
if ( is_file ( WorkingDir() . $value ) )
{
if ( in_array( strtolower ( end ( explode ( ".", $value ) ) ), $extensions) )
{
$thumbBox;
$thumbnailSRC = "images/image.png";
if ( ThumbnailExists ( $value ) )
{
$thumbBox = $tabs . "\t\t" . "<h2>Thumb BB Code:</h2>" . "\n" . $tabs . "\t\t" . "<input class=\"i_code\" onfocus=\"this.select()\" value=\"" . BBCode ( $value, TRUE ) . "\" />" . "\n";
$thumbnailSRC = ThumbLink ( $value );
}
echo $tabs . "<div class=\"thumb\">" . "\n" .
$tabs . "\t" . "<a href=\"" . ImageLink ( $value ) . "\" target=\"_blank\" title=\"Open image: " . $value . "\"><img src=\"" . $thumbnailSRC . "\" alt=\"" . $value . " thumbnail\" /></a>" . "\n" .
$tabs . "\t" . "<p class=\"code\">" . "\n" .
$thumbBox .
$tabs . "\t\t" . "<h2>Direct BB Code:</h2>" . "\n" .
$tabs . "\t\t" . "<input class=\"i_code\" onfocus=\"this.select()\" value=\"" . BBCode ( $value ) . "\" /><br />" . "\n" .
$tabs . "\t\t" . "<input class=\"check\" type=\"checkbox\" name=\"image[]\" value=\"" . $value . "\" />Select Image" . "\n" .
$tabs . "\t" . "</p>" . "\n" .
$tabs . "\t" . "<p class=\"clear\"></p>" . "\n" .
$tabs . "</div>" . "\n";
$thumbBox = "";
$i++;
}
}
}
if ( $i == 0 )
{
echo $tabs . "<div class=\"thumb\">" . "\n" .
$tabs . "\t" . "<p class=\"center\"><b>There are no images in this folder!</b></p>" . "\n" .
$tabs . "</div>" . "\n";
}
?>
</form>
</div>
<p id="copy">Copyright e<span class="blue">Gallery</span> // All rights reserved.</p>
</div>
</body>
</html>
(Please note: the upload function does not work yet)
I was under the impression that ImageMagick isn't enabled on most servers, so i thought GD would be best?
Would i be wrong in assuming that?
marc2003 said:i'm assuming as this isn't a public gallery and the OP is wanting to resize hundreds of files at a time, rob is suggesting that he should process the files on his pc before he uploads them?
<?php
exec("convert -strip 200x200 foo.jpg foo.thumb.jpg");
?>
i like it
uploaded 306 images, no time out
but the images doesnt display horizontally for forums
thanks
$imagesHorizonally = 2
$imagesHorizonally = -1
<?php
if ( exec ( "convert -strip 200x200 foo.jpg foothumb.jpg" ) )
{
echo "done"; //has imagemagick
}
else
{
echo "doesn't have imagemagick"; //use gd instead
}
?>