Topic: [Beta] Gallery

This will display all the images uploaded to your image hosting site ..
Features
*Pagination
*Shuffle Images
Ps : This is in beta and open for suggestions and corrections.


Code

<?
require('engine.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "[url]http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd[/url]">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?=LANG;?>" lang="<?=LANG;?>">
<head>
<meta name="generator" content="Chevereto <?=SC_VERSION;?>" /><!-- Dejar para estadisticas por favor! -->
<title><? echo $titulo.' '.APP_NAME;?> - <?=TAG_LINE;?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="content-language" content="<?=LANG;?>" />
<link href="<?=URL_SCRIPT;?>estilo.css" rel="stylesheet" type="text/css" />
<link rel="shortcut icon" href="<?=PATH_SCRIPT;?>favicon.ico" type="image/x-icon" />
</head>
<body>
<div id="top">
    <div id="logo">
      <a href="<?=URL_SCRIPT;?>"><img src="<?=PATH_SCRIPT;?>site-img/logo.png" alt="<?=APP_NAME;?>" /></a>
    </div>
    <div id="tagline"><?=TAG_LINE;?></div><div id="limite">JPG PNG BMP GIF <span>Max.<?=$max_mb;?>Mb</span></div>
</div>
<div id="contenido">
<div id="selector_up">
</div> 
<div align="center">
      <?php
      // credits to kkeith29
     // by desiboy aka 3lite
      $thispage = 'gallery.php';
      $imageDir = 'thumbs/';
      $perPage = 50; //total images to display per page
      $perRow = 5; //total images per row
      if ( isset( $_GET['reset'] ) ) {
      unset( $_SESSION['chunks'] );
      }
      if ( !isset( $_SESSION['chunks'] ) ) {
      if ( is_dir( $imageDir ) ) {
      if ( $dir = opendir( $imageDir ) ) {
      while ( ( $file = readdir( $dir ) ) !== false ) {
      if ( $file !== '.' && $file !== '..' ) {
      $images[] = $file;
      }
      }
      closedir( $dir );
      }
      else {
      die("Unable to read directory - {$imageDir}");
      }
      }
      shuffle( $images );
      $_SESSION['chunks'] = array_chunk( $images,$perPage );
      }
      $page = 1;
      if ( isset( $_GET['page'] ) && $_GET['page'] > 0 ) {
      $page = (int) $_GET['page'];
      }
       $images[] = $file;
      $chunk =& $_SESSION['chunks'];
      $total = count( $chunk );
      $images[] = $file;
      if ( isset( $chunk[$page-1] ) ) {
      $images = $chunk[$page-1];
      $html = "<table cellspacing=\"0\" cellpadding=\"3\">\n\t<tr>\n";
      $i = 0;
      foreach( $images as $image ) {
      if ( $i == $perRow ) {
      $html .= "\t</tr>\n\t<tr>\n";
      $i = 0;
      }
      $html .= "\t\t<td><a href=\"/?v={$image}\"><img src=\"{$imageDir}{$image}\" /></a></td>\n";
      $i++;
      }
      $html .= "\t<tr>\n";
      if ( $total > 1 ) {
      $nav = '';
      if ( $page > 1 ) {
      $nav .= "<a href=\"{$thispage}?page=1\">[FIRST]</a><a href=\"{$thispage}?page=" . ( $page - 1 ) . "\">[PREV]</a>";
      }
      $i = 1;
      while( $i < $total + 1 ) {
      $nav .= "<a href=\"{$thispage}?page={$i}\">[{$i}]</a>";
      $i++;
      }
      if ( $page < $total ) {
      $nav .= "<a href=\"{$thispage}?page=" . ( $page + 1 ) . "\">[NEXT]</a><a href=\"{$thispage}?page={$total}\">[LAST]</a>";
      }
      $html .= "\t<tr>\n\t\t<td colspan=\"{$perRow}\">{$nav}</td>\n\t</tr>\n";
      }
      $html .= "</table><br /><br /><a href=\"{$thispage}?reset=true\">Shuffle Images</a>";
      echo $html;
      }
      ?></div>
    
</div>

<div id="foot"><div class="foot-d2"><?=APP_NAME;?> - <a href="gallery.php">Gallery</a> - Powered by <a href="http://chevereto.com/" target="_blank">Chevereto</a></div></div>

</body>
</html>

Note : as chevereto script doesn't have any css related to CSS links, it may look badly..
but you can edit  estilo.css
and include

A:link {text-decoration: none}
A:visited {text-decoration: none}
A:active {text-decoration: none}
A:hover {text-decoration: underline; color: red;}

Use the details that you want

and to include this in the index page
in footer or where ever you want
include

<a href="gallery.php">Gallery</a>

Thanks
desiboy aka 3lit3

Last edited by 3lit3 (2009-10-28 13:52:58)

Thumbs up

Re: [Beta] Gallery

Reserved big_smile

Please Reply if you are using yikes

Last edited by 3lit3 (2009-10-23 18:31:32)

Thumbs up

Re: [Beta] Gallery

any demo

Thumbs up

Re: [Beta] Gallery

aww..can give my site as demo , but its adult image hosting

Thumbs up

Re: [Beta] Gallery

okok i tryed it

it's everything ok big_smile Thanks big_smile

Thumbs up

Re: [Beta] Gallery

art0on wrote:

okok i tryed it

it's everything ok big_smile Thanks big_smile


Nice that it worked without any problems..any suggestion for next edition that I may release ?

Thumbs up

Re: [Beta] Gallery

Works absolutly propper! Nice!
http://saved.im/mtuxntyzmznp_vs/demo.jpg

Thumbs up

Re: [Beta] Gallery

Dustin wrote:

Works absolutly propper! Nice!
http://saved.im/mtuxntyzmznp_vs/demo.jpg

Thanks for the screen shot smile

Thumbs up

Re: [Beta] Gallery

Great mod, much needed feature.

The only thing missing now is a public/private option for uploading images. People may not want their images to be displayed in the gallery - I know this requires a database.

Thumbs up

Re: [Beta] Gallery

figment wrote:

Great mod, much needed feature.

The only thing missing now is a public/private option for uploading images. People may not want their images to be displayed in the gallery - I know this requires a database.


ya..I am thinking of a other way to get it worked without a db..

Thumbs up

Re: [Beta] Gallery

3lit3 wrote:
figment wrote:

Great mod, much needed feature.

The only thing missing now is a public/private option for uploading images. People may not want their images to be displayed in the gallery - I know this requires a database.


ya..I am thinking of a other way to get it worked without a db..

use flatfiles

Thumbs up

Re: [Beta] Gallery

This looks awesome so far, if there was a way to have an option like mentioned above I would gladly pay someone for this!

Thumbs up

Re: [Beta] Gallery

Also just out of curiosity, or it may be a bug... Why have pagination if its random?

Thumbs up

Re: [Beta] Gallery

Great code; thanks for sharing. Now if I can work in a timestamp for the date it was uploaded and a delete function, I'll be all set!

Thumbs up

Re: [Beta] Gallery

Thanks for the code.

How to set by latest not random?

Thumbs up