4images PHP Cross Reference Image Galleries

Source: /lightbox.php - 179 lines - 8078 bytes - Summary - Text - Print

   1  <?php
   2  /**************************************************************************
   3   *                                                                        *
   4   *    4images - A Web Based Image Gallery Management System               *
   5   *    ----------------------------------------------------------------    *
   6   *                                                                        *
   7   *             File: lightbox.php                                         *
   8   *        Copyright: (C) 2002-2012 Jan Sorgalla                           *
   9   *            Email: jan@4homepages.de                                    *
  10   *              Web: http://www.4homepages.de                             *
  11   *    Scriptversion: 1.7.11                                               *
  12   *                                                                        *
  13   *    Never released without support from: Nicky (http://www.nicky.net)   *
  14   *                                                                        *
  15   **************************************************************************
  16   *                                                                        *
  17   *    Dieses Script ist KEINE Freeware. Bitte lesen Sie die Lizenz-       *
  18   *    bedingungen (Lizenz.txt) für weitere Informationen.                 *
  19   *    ---------------------------------------------------------------     *
  20   *    This script is NOT freeware! Please read the Copyright Notice       *
  21   *    (Licence.txt) for further information.                              *
  22   *                                                                        *
  23   *************************************************************************/
  24  
  25  $templates_used = 'lightbox,thumbnail_bit';
  26  $main_template = 'lightbox';
  27  
  28  define('GET_CACHES', 1);
  29  define('ROOT_PATH', './');
  30  define('MAIN_SCRIPT', __FILE__);
  31  include (ROOT_PATH.'global.php');
  32  require (ROOT_PATH.'includes/sessions.php');
  33  $user_access = get_permission();
  34  include (ROOT_PATH.'includes/page_header.php');
  35  
  36  if ($user_info['user_level'] == GUEST || $user_info['user_level'] == USER_AWAITING) {
  37    show_error_page($lang['lightbox_register']);
  38  }
  39  
  40  //-----------------------------------------------------
  41  //--- Show Images -------------------------------------
  42  //-----------------------------------------------------
  43  $imgtable_width = ceil((intval($config['image_table_width'])) / $config['image_cells']);
  44  if ((substr($config['image_table_width'], -1)) == "%") {
  45    $imgtable_width .= "%";
  46  }
  47  
  48  $download_allowed = false;
  49  
  50  $num_rows_all = 0;
  51  $num_rows = 0;
  52  
  53  if (!empty($user_info['lightbox_image_ids']))  {
  54    $image_id_sql = str_replace(" ", ", ", trim($user_info['lightbox_image_ids']));
  55    $sql = "SELECT COUNT(image_id) AS images
  56            FROM ".IMAGES_TABLE."
  57            WHERE image_active = 1 AND image_id IN ($image_id_sql) AND cat_id NOT IN (".get_auth_cat_sql("auth_viewcat", "NOTIN").")";
  58    $result = $site_db->query_firstrow($sql);
  59    $num_rows_all = $result['images'];
  60  }
  61  
  62  $link_arg = $site_sess->url(ROOT_PATH."lightbox.php");
  63  include (ROOT_PATH.'includes/paging.php');
  64  $getpaging = new Paging($page, $perpage, $num_rows_all, $link_arg);
  65  $offset = $getpaging->get_offset();
  66  $site_template->register_vars(array(
  67    "paging" => $getpaging->get_paging(),
  68    "paging_stats" => $getpaging->get_paging_stats()
  69  ));
  70  
  71  if ($num_rows_all) {
  72    $sql = "SELECT COUNT(image_id) AS images
  73            FROM ".IMAGES_TABLE."
  74            WHERE image_active = 1 AND image_id IN ($image_id_sql) AND cat_id NOT IN (".get_auth_cat_sql("auth_download", "NOTIN").")";
  75    $result = $site_db->query_firstrow($sql);
  76    $download_allowed = intval($result['images']) > 0;
  77  
  78    $additional_sql = "";
  79    if (!empty($additional_image_fields)) {
  80      foreach ($additional_image_fields as $key => $val) {
  81        $additional_sql .= ", i.".$key;
  82      }
  83    }
  84    $sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits".$additional_sql.", c.cat_name".get_user_table_field(", u.", "user_name")."
  85            FROM (".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c)
  86            LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = i.user_id)
  87            WHERE i.image_active = 1 AND i.image_id IN ($image_id_sql) AND c.cat_id = i.cat_id AND i.cat_id NOT IN (".get_auth_cat_sql("auth_viewcat", "NOTIN").")
  88            ORDER BY i.".$config['image_order']." ".$config['image_sort'].", i.image_id ".$config['image_sort']."
  89            LIMIT $offset, $perpage";
  90    $result = $site_db->query($sql);
  91    $num_rows = $site_db->get_numrows($result);
  92  }
  93  
  94  if (!$num_rows)  {
  95    $thumbnails = "";
  96    $msg .= ($msg != "") ? "<p>".$lang['lightbox_no_images'] : $lang['lightbox_no_images'];
  97  }
  98  else {
  99    set_download_token($user_info['lightbox_image_ids']);
 100  
 101    $thumbnails = "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\">\n";
 102    $count = 0;
 103    $bgcounter = 0;
 104    while ($image_row = $site_db->fetch_array($result)) {
 105      if (!$download_allowed && check_permission("auth_download", $image_row['cat_id'])) {
 106        $download_allowed = true;
 107      }
 108  
 109      if ($count == 0) {
 110        $row_bg_number = ($bgcounter++ % 2 == 0) ? 1 : 2;
 111        $thumbnails .= "<tr class=\"imagerow".$row_bg_number."\">\n";
 112      }
 113      $thumbnails .= "<td width=\"".$imgtable_width."\" valign=\"top\">\n";
 114  
 115      show_image($image_row, "lightbox");
 116      $thumbnails .= $site_template->parse_template("thumbnail_bit");
 117      $thumbnails .= "\n</td>\n";
 118  
 119      $count++;
 120      if ($count == $config['image_cells']) {
 121        $thumbnails .= "</tr>\n";
 122        $count = 0;
 123      }
 124    } // end while
 125    if ($count > 0)  {
 126      $leftover = ($config['image_cells'] - $count);
 127      if ($leftover >= 1) {
 128        for ($i = 0; $i < $leftover; $i++){
 129          $thumbnails .= "<td width=\"".$imgtable_width."\">\n&nbsp;\n</td>\n";
 130        }
 131        $thumbnails .= "</tr>\n";
 132      }
 133    }
 134    $thumbnails .= "</table>\n";
 135  } // end else
 136  
 137  $lightbox_lastaction = format_date($config['date_format']." ".$config['time_format'], $user_info['lightbox_lastaction']);
 138  if (empty($user_info['lightbox_lastaction'])) {
 139    $lightbox_lastaction = "n/a";
 140  }
 141  
 142  $site_template->register_vars(array(
 143    "thumbnails" => $thumbnails,
 144    "lightbox_lastaction" => $lightbox_lastaction
 145  ));
 146  unset($thumbnails);
 147  
 148  //-----------------------------------------------------
 149  //--- Clickstream -------------------------------------
 150  //-----------------------------------------------------
 151  $clickstream = "<span class=\"clickstream\"><a href=\"".$site_sess->url(ROOT_PATH."index.php")."\" class=\"clickstream\">".$lang['home']."</a>".$config['category_separator'].$lang['lightbox']."</span>";
 152  
 153  //-----------------------------------------------------
 154  //--- Print Out ---------------------------------------
 155  //-----------------------------------------------------
 156  $download_button = "";
 157  if (function_exists("gzcompress") && function_exists("crc32")) {
 158    if ($download_allowed && !empty($user_info['lightbox_image_ids'])) {
 159      $download_button = "<a href=\"".$site_sess->url(ROOT_PATH."download.php?action=lightbox")."\"><img src=\"".get_gallery_image("download_zip.gif")."\" border=\"0\" alt=\"\" /></a>";
 160    }
 161    else {
 162      $download_button = "<img src=\"".get_gallery_image("download_zip_off.gif")."\" border=\"0\" alt=\"\" />";
 163    }
 164  }
 165  
 166  $site_template->register_vars(array(
 167    "msg" => $msg,
 168    "clickstream" => $clickstream,
 169    "lang_lightbox" => $lang['lightbox'],
 170    "lang_delete_lightbox" => $lang['delete_lightbox'],
 171    "url_delete_lightbox" => $site_sess->url(ROOT_PATH."lightbox.php?action=clearlightbox"),
 172    "lang_delete_lightbox_confirm" => $lang['delete_lightbox_confirm'],
 173    "lang_lightbox_lastaction" => $lang['lighbox_lastaction'],
 174    "download_button" => $download_button
 175  ));
 176  
 177  $site_template->print_template($site_template->parse_template($main_template));
 178  include (ROOT_PATH.'includes/page_footer.php');
 179  ?>

title

Description

title

Description

title

Description

title

title

Body