Jump to content
xisto Community
killingjoke

How Do I Make PHP Based Image Gallery Like This? Help Needed

Recommended Posts

is it possible to make a page in php, with a url like this:

httq://http://forums.xisto.com/no_longer_exists/ (This is a sample link, read below)

 

so that in what i change the last part the gallery will change with it?

so that i just have to make one php-page and this page just shows all the imaes in the map thats in the url after the questionmark??

 

thanks,

Edited by vujsa (see edit history)

Share this post


Link to post
Share on other sites

maybe that was just an example ? if i got it right he wants to have a php script, a gallery script which would show all the images from some kind of a site gathering them from <img> tags or similar ???to answer his question, everything is possible, but knowledge and time is needed, you would need a lot of regular expressions in my opinion, but I might have got it wrong.. :S

Share this post


Link to post
Share on other sites

please edit this post, i would like to add and remove this line..Oh, or maybe he justs wants to gather all the pictures from a directory viewer?dir=galleries/01 something like this.. yes it is possible.. and quite easy, but for a gallery I would recommend that you put all the filenames to a database like mysql and count a lot of stuff, hits, views add comments, ratings and stuff.

Share this post


Link to post
Share on other sites

Ahaa I misinterpreted his post..

 

Anyway - what you seek is quite easy to do - but the format of the link you've stated is quite unnecessary... a better approach would be something like:

http://forums.xisto.com/no_longer_exists/ - and you simply keep changing the last number to switch galleries.

Share this post


Link to post
Share on other sites

well, if you do not want to write one yourself, because I think you can't and not many here would want to write it for you in my opinion, go and download one and install, there are really a lot of different php gallery's, search google or hotscripts.. and if you will get an account here, you will have access to fantastico and from there you could install some galleries like: 4Images Gallery, Coppermine Photo Gallery and Gallery.. that is how they are called.

Gallery homepage: http://galleryproject.org/
Coppermine Photo Gallery homepage: http://coppermine-gallery.net/
4Images Gallery homepage: https://www.4homepages.de/

these are the more powerfull available on the "market" :D I remember I wrote a gallery script for myself with rating and comments and stuff, but never finished the control panel, was adding the pictures by editing some script source, I mean manually, but I dropped everything later. :D

Share this post


Link to post
Share on other sites

hello, thanks for the replies, but i'm looking for just one php page with simething init that reads whats in the url, like in my first post;http://forums.xisto.com/no_longer_exists/ the actual page shows only the images all below each other, i ca ndo it in html, but its a lot of work, cause i have very much galeries to put online, so i would like to make it more dynamic through php, but i dont know anythin of php,Can someone make such a page for me? it's just one page?i would be very gracefull,thanks,Michiel

Share this post


Link to post
Share on other sites

hello,
thanks vujsa, with your tut i came a lot further,
and now i have this;

<?php   # Do we have a path? if not, it's the current directory   $path = $_GET["path"];   if( !isset( $path ) || $path == "" )  {     $path = ".";   }   # Initialise list arrays, directories and files separately and array counters for them   $d_arr = array(); $d = 0;   $f_arr = array(); $f = 0;   # Open possibly available directory   if( is_dir( $path ) ) {     if( $handle = opendir( $path ) ) {         while( false !== ( $file = readdir( $handle ) ) ) {           # Make sure we don't push parental directories or dotfiles (unix) into the arrays           if( $file != "." && $file != ".." && $file[0] != "." ) {               if( is_dir( $path . "/" . $file ) )                 # Create array for directories                 $d_arr[$d++] = $file;               else                 # Create array for files                 $f_arr[$f++] = $file;           }         }     }   }   # Wrap things up if we're in a directory   if( is_dir( $handle ) ) closedir( $handle );  # Sort and reset the arrays   sort( $d_arr ); reset( $d_arr );   sort( $f_arr ); reset( $f_arr );   # Print file list   for( $i=0; $i < count( $f_arr ); $i++ ) {     # Only print path and filename     print "<a href=\"" . $path . "/" . $f_arr[$i] . "\"><img src=\"" . $path . "/" . $f_arr[$i] . "\"></a><br><br>\n";        }?>

So, you have the images all sorted under each other, with a link to the image, but i want that the image that is shown is if width is bigger then 500px it shows it with the 500px with so you have to click the iamge to the HQ pic,
so how do i do that? In html its just width="500", but here that doesn't work,

i found this script on the internet, maybe someone can put it together, if you need a script like this orso;

<?PHP$image = "/map/plaatje.gif"; $size = getimagesize("$image");$width = $size[0];$height = $size[1];if ($width > 294){    $width = 294;    $percent = ($size[0] / $width);    $height = ($size[1] / $percent);}?>

Thanks

Share this post


Link to post
Share on other sites

oh, and how i can make the borders disappear around my iamges, plz?

 

Thank you!

1064335501[/snapback]


Well,
border="0"
should do it.

 

Just change:

  # Print file list  for( $i=0; $i < count( $f_arr ); $i++ ) {    # Only print path and filename    print "<a href=\"" . $path . "/" . $f_arr[$i] . "\"><img src=\"" . $path . "/" . $f_arr[$i] . "\"></a><br><br>\n";     }

to:
  # Print file list  for( $i=0; $i < count( $f_arr ); $i++ ) {    # Only print path and filename    print "<a href=\"" . $path . "/" . $f_arr[$i] . "\"><img src=\"" . $path . "/" . $f_arr[$i] . "border=\"0\" \"></a><br><br>\n";     }

You can also control this with CSS by adding a class to the thumbnails and specifying that it should not have a boreder in the CS file.

 

You'll have to play with the CSS a little to get everything right.

 

Hope this helps.

 

vujsa

Share this post


Link to post
Share on other sites

hello,
everything works like i want it to work now, but when i put it online, at the bottom it shows a square like the other pictures, but its the file 'thumbs.db' wich is invisible for me on my pc and server, so there is a blanc image at the bottom, now, my question is, can you let the php-code let only show the .jpg and .JPG files? How?

Here's my code;

<?php   $path = $_GET["path"];   if( !isset( $path ) || $path == "" )  {     $path = ".";   }   $d_arr = array(); $d = 0;   $f_arr = array(); $f = 0;   if( is_dir( $path ) ) {     if( $handle = opendir( $path ) ) {         while( false !== ( $file = readdir( $handle ) ) ) {            if( $file != "." && $file != ".." && $file[0] != "." ) {               if( is_dir( $path . "/" . $file ) )                                  $d_arr[$d++] = $file;               else                 $f_arr[$f++] = $file;           }         }     }   }   if( is_dir( $handle ) ) closedir( $handle );   sort( $d_arr ); reset( $d_arr );   sort( $f_arr ); reset( $f_arr );   for( $i=0; $i < count( $f_arr ); $i++ ) {     print "<center><a href=\"" . $path . "/" . $f_arr[$i] . "\" target=\"_blanc\"><img src=\"" . $path . "/" . $f_arr[$i] . "\" width=\"550\" border=\"0\"></a><br><br>\n</center>";        }?>

Thanks

Share this post


Link to post
Share on other sites

thumbs.db

 

The quickest and easiest way if it is only the thumbs.bd file is to change the following:

   for( $i=0; $i < count( $f_arr ); $i++ ) {     print "<center><a href=\"" . $path . "/" . $f_arr[$i] . "\" target=\"_blanc\"><img src=\"" . $path . "/" . $f_arr[$i] . "\" width=\"550\" border=\"0\"></a><br><br>\n</center>";        }?>

to:

   for( $i=0; $i < count( $f_arr ); $i++ ) {    if ($f_arr[$i] != 'thumbs.db') {     print "<center><a href=\"" . $path . "/" . $f_arr[$i] . "\" target=\"_blanc\"><img src=\"" . $path . "/" . $f_arr[$i] . "\" width=\"550\" border=\"0\"></a><br><br>\n</center>";    }   }?>

Basically, only print the HTML if the filename is NOT thumbs.db.

 

Yo can also write a more complex function to only allow know image types. This would be more difficult but I'm sure we can help out if you want us to.

 

Yet another way to deal specifically with the thumbs.db is to add an .htaccess rule to disallow that file to be shown or used by HTML or PHP.

 

Hope This Helps. :D

 

vujsa

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.