PDA

View Full Version : PHPalbum


PHPalbum
08-16-2005, 10:33 AM
Hello

Recently i aquired the domain name PHPalbum.com

I wish to furthermore develop this site. I intend to offer a free basic PHP album.

I want the gallery to read the images in a directory and basically display on a page one image at a time.

I wish for there to be numbers underneath were users Navigate through the images.

To get a bigger picture, heres the design i intend to use:

http://www.6zm.com/imagehost//t.php?img=42976765f1.gif

As you see it displays one image and the rest of the images in the directory are given a number.

I wish the numbers to be automatically created according to the amount of images in a directory.

I was wondering how much you would quote me for as i have had offers on other forums for $20-30

If you don't get what i am quite looking for please post and i will try explain in more detail.

Thank you.
PHPalbum

PHPalbum
08-16-2005, 10:36 AM
Okay i found a really good example of what i am looking for:

http://www.*******************/?item=PHP+Image+Gallery

Exept instead of Next I wish for there to be numbers linking to the images.

Note: the coding has to be Unique as i am redistributing it under GPL.

Thanks
PHPalbum

delinear
08-16-2005, 01:07 PM
This will do essentially what you want, it just needs prettying up a little.
<?php

// this part creates an array of your images
$directory = '.'; // this points to the current directory, change it to point to your images - do not use a trailing slash
$allowed_images = array('jpg', 'gif', 'png'); // put the allowed image extensions in here
if ($handle = opendir($directory)) {
while (false !== ($file = readdir($handle))) {
if (!is_dir($file) && $file != "." && $file != "..") {
if(in_array(end(explode('.', $file)), $allowed_images)) {
$images_array[] = $file;
}
}
}
closedir($handle);
}
if(isset($images_array)) {
// this part shows the current image within your page
$_GET['img'] = (!isset($_GET['img']) ? '0' : $_GET['img']);
?>
<img src="<?php echo $directory . '/' . $images_array[$_GET['img']]; ?>" />
<br /><br />
<?php

// this part creates the pagination links
$images_num = count($images_array);
for($i=0; $i < $images_num; $i++) {
if($images_array[$i] == $_GET['img']) {
echo ' &nbsp;|&nbsp; <b>' . $$i . '</b> &nbsp;|&nbsp; ';
} else {
echo ' &nbsp;|&nbsp; <a href="' . basename($_SERVER['PHP_SELF']) . '?img=' . $i . '">' . $i . '</a> &nbsp;|&nbsp; ';
}
}
}
?>

PHPalbum
08-17-2005, 04:22 PM
Thank you ever so kindly.

I am extremly gratefull for this effort and will look for a way in the future to repay you :)

You've made a man very happy today.

Is this code unique for me so i can redistribute under GPL?

I think you may have missed that part out?

delinear
08-18-2005, 02:42 PM
Sure, feel free to do as you will with the code :)