photo album

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
xexexexe
Forum Newbie
Posts: 3
Joined: Mon Jul 15, 2002 6:47 am

photo album

Post by xexexexe »

hi,

i fount a photo album script at http://www.evilwalrus.com/viewcode.php?codeEx=324:

Code: Select all

<?
if( ! isset( $filename ) )&#123;
define( "SIZE" , 120 ) ;
define( "COLNUM" , 6 ) ;
$dir = ($dir)?$dir:"." ;
?>
<html>
<head>
<title>Browse <?= $dir ?></title>
<style type="text/css">
<!--
table&#123; width:100%; &#125;
td&#123; text-align:center; &#125;
img&#123; border:none; &#125;
-->
</style>
</head>
<body>
<table>
<?
$dd = opendir($dir) ;
for( $i = 0 ; $filename = readdir($dd) ; )&#123;
if( is_file("$dir/$filename") )&#123;
if( $imgSize = getImageSize("$dir/$filename") )&#123;
$w0 = $imgSize&#1111;0] ;
$h0 = $imgSize&#1111;1] ;
$imgType = $imgSize&#1111;2] ;
$ratio = $w0 / $h0 ;
if( $ratio > 1 )&#123;
$w1 = SIZE ;
$h1 = ( SIZE * $h0 ) / $w0 ;
&#125;
else&#123;
$w1 = ( SIZE * $w0 ) / $h0 ;
$h1 = SIZE ;
&#125;
$params = sprintf( "filename=$dir/$filename&w0=$w0&h0=$h0&imgType=$imgType&h1=%d&w1=%d" , $h1 , $w1 ) ;
if( ! ( $i % COLNUM ) )&#123;
echo "\n<tr>\n" ;
&#125;
?>
	<td>
	<a href="<?= "$dir/$filename" ?>">
	<img src="<?= $PHP_SELF ?>?<?= $params ?>" style="width:<?= $w1 ?>;height:<?= $h1 ?>;"></a><br>
	<?= "$filename : $w0 x $h0" ?>
<?
					$i++ ;
				&#125;
			&#125;
		&#125;
?>
</table>
</body>
</html>
<?
		closedir($dd) ;
	&#125;
	else&#123;
		switch($imgType)&#123;
			case 1:
				$imgType = "gif" ;
			break;

			case 2:
				$imgType = "JPEG" ;
			break;

			case 3:
				$imgType = "png" ;
			break;

			default:
			break;
		&#125;
		header("Content-type: image/$imgType") ;

		$tImg = imageCreate( $w1 , $h1 ) ;

		$imgOpenFunc = "imageCreateFrom".$imgType ;
		$imgSendFunc = "image".$imgType ;

		$img = $imgOpenFunc("$filename") ;

		imageCopyResized( $tImg , $img , 0 , 0 , 0 , 0 , $w1 , $h1 , $w0 , $h0 ) ;

		imageDestroy($img) ;

		$imgSendFunc($tImg) ;
	&#125;
	?>
This script works perfect, but i need to add 2 things:

1st. I need that images would be dispalyed 25 images per page.
2nd. I need to dispaly how much there is images in total.

Please add this things and post code on this forum ;]

Thanks!
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Sorry not a script writing service, if you would like to hire someone to make these changes for you please hop over to the Job Hunt forum and post there.

Also, if you attempt to make the changes and have difficulty we will be happy to help.

Mac
Post Reply