LogicOpinion
04-23-2008, 09:28 AM
hello, i am using code belove.. to make php to read DIR and create thumbnails in thumbs folder after what php reads thumbs folder and shows gallery on the page. when u click small image bigger one is displayed in a new window.
but now i want to add some more function to php, what?
so, when all is done... 1. directory read. 2. thumbnails are created and showen on the page i want to empty the content of THUMBS folder. remove content of it.
someone has any sugestations how to do it?
Thank you in adavnce!
<?php
$lang_id = &$_REQUEST['lang_id'];
if (isset($lang_id) && $lang_id == "geo") { $imgpath="images/gallery_ge_pgtitle.jpg"; }
elseif (isset($lang_id) && $lang_id == "eng") { $imgpath="images/gallery_en_pgtitle.jpg"; }
elseif (isset($lang_id) && $lang_id == "rus") { $imgpath="images/gallery_ru_pgtitle.jpg"; }
print "<BR>";
print "<table align='center' border='0' cellpadding='0' cellspacing='0' width='530' height='50'>";
print "<TR><TD height='50'><img src='$imgpath'></TD></TR>";
print "</table>";
?>
<?php
function createThumbs( $pathToImages, $pathToThumbs, $thumbWidth )
{
$dir = opendir( $pathToImages );
while (false !== ($fname = readdir( $dir ))) {
$info = pathinfo($pathToImages . $fname);
if ( strtolower($info['extension']) == 'jpg' )
{
$img = imagecreatefromjpeg( "{$pathToImages}{$fname}" );
$width = imagesx( $img );
$height = imagesy( $img );
$new_width = $thumbWidth;
$new_height = floor( $height * ( $thumbWidth / $width ) );
$tmp_img = imagecreatetruecolor( $new_width, $new_height );
imagecopyresized( $tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height );
imagejpeg( $tmp_img, "{$pathToThumbs}{$fname}" );
}
}
closedir( $dir );
}
createThumbs("images/upload/","images/upload/thumbs/",140);
function createGallery( $pathToImages, $pathToThumbs )
{
$output .= "<table bgcolor='#f0f0f0' border=\"0\" cellspacing=\"5\" align=\"center\" cellpadding=\"12\" width=\"500\">";
$output .= "<tr>";
$dir = opendir( $pathToThumbs );
$counter = 0;
$output.=" <SCRIPT LANGUAGE=\"JavaScript\">
function openindex(imgname)
{
OpenWindow=window.open(\"\", \"newwin\", \"height=700, width=760,toolbar=no,scrollbars=\"+scroll+\", menubar=no, top=100, left=50\");
OpenWindow.document.write(\"<HTML>\")
OpenWindow.document.write(\"<HEAD>\")
OpenWindow.document.write(\"<TITLE>Gallery</TITLE>\")
OpenWindow.document.write(\"</HEAD>\")
OpenWindow.document.write(\"<STYLE>\")
OpenWindow.document.write(\".asdad {font-size:14px; font-family: Tahoma; color: #C30000; Font-weight:Bold; text-decoration:none;} p { font-family:Tahoma; font-weight:bold; font-size:10px; color:#000000;\")
OpenWindow.document.write(\"</STYLE>\")
OpenWindow.document.write(\"<BODY BGCOLOR='#FFFFFF' topmargin='0' leftmargin='0' rightmargin='0' bottommargin='0'>\")
OpenWindow.document.write(\"<div align=right style='padding-top:15px; padding-right:15px;'><a class='asdad' href='JavaScript:self.close();'>x</a></div>\")
OpenWindow.document.write(\"<div align=right style='padding-right:15px;'><P>HOTEL BATUMI</p></div>\")
OpenWindow.document.write(\"<table border='0' cellspacing='0' cellpadding='0' width='100%' align='center' width='750' height='700'>\")
OpenWindow.document.write(\"<tr>\")
OpenWindow.document.write(\"<td align='center' valign='top'>\")
OpenWindow.document.write(\"<img src=\"+imgname+\">\")
OpenWindow.document.write(\"</td>\")
OpenWindow.document.write(\"</tr>\")
OpenWindow.document.write(\"</table>\")
OpenWindow.document.write(\"</BODY>\")
OpenWindow.document.write(\"</HTML>\")
OpenWindow.document.close()
self.name=\"main\"
}
</SCRIPT>";
while (false !== ($fname = readdir($dir)))
{
if ($fname != '.' && $fname != '..')
{
$output .= "
<td onmouseover=\"this.style.backgroundColor='#DADADA';\" onmouseout=\"this.style.backgroundColor='#f0f0f0';\" valign=\"middle\" align=\"center\">
<a href=\"javascript:void(0)\" onclick=\"openindex('{$pathToImages}{$fname}')\" Return false;>";
$output .= "<img src=\"{$pathToThumbs}{$fname}\" border=\"0\" />";
$output .= "</a></td>";
$counter += 1;
if ( $counter % 3 == 0 ) { $output .= "</tr><tr>"; }
}
}
closedir( $dir );
$output .= "</tr>";
$output .= "</table>";
print "$output";
}
createGallery("images/upload/","images/upload/thumbs/");
?>
but now i want to add some more function to php, what?
so, when all is done... 1. directory read. 2. thumbnails are created and showen on the page i want to empty the content of THUMBS folder. remove content of it.
someone has any sugestations how to do it?
Thank you in adavnce!
<?php
$lang_id = &$_REQUEST['lang_id'];
if (isset($lang_id) && $lang_id == "geo") { $imgpath="images/gallery_ge_pgtitle.jpg"; }
elseif (isset($lang_id) && $lang_id == "eng") { $imgpath="images/gallery_en_pgtitle.jpg"; }
elseif (isset($lang_id) && $lang_id == "rus") { $imgpath="images/gallery_ru_pgtitle.jpg"; }
print "<BR>";
print "<table align='center' border='0' cellpadding='0' cellspacing='0' width='530' height='50'>";
print "<TR><TD height='50'><img src='$imgpath'></TD></TR>";
print "</table>";
?>
<?php
function createThumbs( $pathToImages, $pathToThumbs, $thumbWidth )
{
$dir = opendir( $pathToImages );
while (false !== ($fname = readdir( $dir ))) {
$info = pathinfo($pathToImages . $fname);
if ( strtolower($info['extension']) == 'jpg' )
{
$img = imagecreatefromjpeg( "{$pathToImages}{$fname}" );
$width = imagesx( $img );
$height = imagesy( $img );
$new_width = $thumbWidth;
$new_height = floor( $height * ( $thumbWidth / $width ) );
$tmp_img = imagecreatetruecolor( $new_width, $new_height );
imagecopyresized( $tmp_img, $img, 0, 0, 0, 0, $new_width, $new_height, $width, $height );
imagejpeg( $tmp_img, "{$pathToThumbs}{$fname}" );
}
}
closedir( $dir );
}
createThumbs("images/upload/","images/upload/thumbs/",140);
function createGallery( $pathToImages, $pathToThumbs )
{
$output .= "<table bgcolor='#f0f0f0' border=\"0\" cellspacing=\"5\" align=\"center\" cellpadding=\"12\" width=\"500\">";
$output .= "<tr>";
$dir = opendir( $pathToThumbs );
$counter = 0;
$output.=" <SCRIPT LANGUAGE=\"JavaScript\">
function openindex(imgname)
{
OpenWindow=window.open(\"\", \"newwin\", \"height=700, width=760,toolbar=no,scrollbars=\"+scroll+\", menubar=no, top=100, left=50\");
OpenWindow.document.write(\"<HTML>\")
OpenWindow.document.write(\"<HEAD>\")
OpenWindow.document.write(\"<TITLE>Gallery</TITLE>\")
OpenWindow.document.write(\"</HEAD>\")
OpenWindow.document.write(\"<STYLE>\")
OpenWindow.document.write(\".asdad {font-size:14px; font-family: Tahoma; color: #C30000; Font-weight:Bold; text-decoration:none;} p { font-family:Tahoma; font-weight:bold; font-size:10px; color:#000000;\")
OpenWindow.document.write(\"</STYLE>\")
OpenWindow.document.write(\"<BODY BGCOLOR='#FFFFFF' topmargin='0' leftmargin='0' rightmargin='0' bottommargin='0'>\")
OpenWindow.document.write(\"<div align=right style='padding-top:15px; padding-right:15px;'><a class='asdad' href='JavaScript:self.close();'>x</a></div>\")
OpenWindow.document.write(\"<div align=right style='padding-right:15px;'><P>HOTEL BATUMI</p></div>\")
OpenWindow.document.write(\"<table border='0' cellspacing='0' cellpadding='0' width='100%' align='center' width='750' height='700'>\")
OpenWindow.document.write(\"<tr>\")
OpenWindow.document.write(\"<td align='center' valign='top'>\")
OpenWindow.document.write(\"<img src=\"+imgname+\">\")
OpenWindow.document.write(\"</td>\")
OpenWindow.document.write(\"</tr>\")
OpenWindow.document.write(\"</table>\")
OpenWindow.document.write(\"</BODY>\")
OpenWindow.document.write(\"</HTML>\")
OpenWindow.document.close()
self.name=\"main\"
}
</SCRIPT>";
while (false !== ($fname = readdir($dir)))
{
if ($fname != '.' && $fname != '..')
{
$output .= "
<td onmouseover=\"this.style.backgroundColor='#DADADA';\" onmouseout=\"this.style.backgroundColor='#f0f0f0';\" valign=\"middle\" align=\"center\">
<a href=\"javascript:void(0)\" onclick=\"openindex('{$pathToImages}{$fname}')\" Return false;>";
$output .= "<img src=\"{$pathToThumbs}{$fname}\" border=\"0\" />";
$output .= "</a></td>";
$counter += 1;
if ( $counter % 3 == 0 ) { $output .= "</tr><tr>"; }
}
}
closedir( $dir );
$output .= "</tr>";
$output .= "</table>";
print "$output";
}
createGallery("images/upload/","images/upload/thumbs/");
?>