4images PHP Cross Reference Image Galleries

Source: /index.php - 182 lines - 7391 bytes - Summary - Text - Print

   1  <?php
   2  /**************************************************************************
   3   *                                                                        *
   4   *    4images - A Web Based Image Gallery Management System               *
   5   *    ----------------------------------------------------------------    *
   6   *                                                                        *
   7   *             File: index.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 = 'home,category_bit,whos_online,thumbnail_bit';
  26  $main_template = 'home';
  27  
  28  define('GET_CACHES', 1);
  29  define('ROOT_PATH', './');
  30  define('MAIN_SCRIPT', __FILE__);
  31  define('GET_USER_ONLINE', 1);
  32  include (ROOT_PATH.'global.php');
  33  require (ROOT_PATH.'includes/sessions.php');
  34  $user_access = get_permission();
  35  
  36  if (isset($HTTP_GET_VARS['template']) || isset($HTTP_POST_VARS['template'])) {
  37    $template = (isset($HTTP_GET_VARS['template'])) ? get_basefile(stripslashes($HTTP_GET_VARS['template'])) : get_basefile(stripslashes($HTTP_POST_VARS['template']));
  38    if (!file_exists(TEMPLATE_PATH."/".$template.".".$site_template->template_extension)) {
  39      $template = "";
  40    }
  41    else {
  42      $main_template = $template;
  43    }
  44  }
  45  else {
  46    $template = "";
  47  }
  48  include (ROOT_PATH.'includes/page_header.php');
  49  
  50  if (!empty($template)) {
  51    $clickstream = "<a href=\"".$site_sess->url(ROOT_PATH."index.php")."\">".$lang['home']."</a>".$config['category_separator'].str_replace("_", " ", ucfirst($template));
  52    $site_template->register_vars("clickstream", $clickstream);
  53    $site_template->print_template($site_template->parse_template($main_template));
  54    include (ROOT_PATH.'includes/page_footer.php');
  55  }
  56  
  57  $cache_id = create_cache_id(
  58    'page.index',
  59    array(
  60      $user_info[$user_table_fields['user_id']],
  61      isset($user_info['lightbox_image_ids']) ? substr(md5($user_info['lightbox_image_ids']), 0, 8) : 0,
  62      $config['template_dir'],
  63      $config['language_dir']
  64    )
  65  );
  66  
  67  if (!$cache_page_index || !$content = get_cache_file($cache_id)) {
  68  // Always append session id if cache is enabled
  69  if ($cache_page_index) {
  70    $old_session_mode = $site_sess->mode;
  71    $site_sess->mode = 'get';
  72  }
  73  
  74  ob_start();
  75  
  76  //-----------------------------------------------------
  77  //--- Show Categories ---------------------------------
  78  //-----------------------------------------------------
  79  $categories = get_categories(0);
  80  if (!$categories)  {
  81    $categories = $lang['no_categories'];
  82  }
  83  $site_template->register_vars("categories", $categories);
  84  unset($categories);
  85  
  86  //-----------------------------------------------------
  87  //--- Show New Images ---------------------------------
  88  //-----------------------------------------------------
  89  $site_template->register_vars(array(
  90    "has_rss"   => true,
  91    "rss_title" => "RSS Feed: ".format_text($config['site_name'], 2)." (".str_replace(':', '', $lang['new_images']).")",
  92    "rss_url"   => $script_url."/rss.php?action=images"
  93  ));
  94  
  95  $imgtable_width = ceil(intval($config['image_table_width']) / $config['image_cells']);
  96  if ((substr($config['image_table_width'], -1)) == "%") {
  97    $imgtable_width .= "%";
  98  }
  99  
 100  $additional_sql = "";
 101  if (!empty($additional_image_fields)) {
 102    foreach ($additional_image_fields as $key => $val) {
 103      $additional_sql .= ", i.".$key;
 104    }
 105  }
 106  
 107  $num_new_images = $config['image_cells'];
 108  $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")."
 109          FROM (".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c)
 110          LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = i.user_id)
 111          WHERE i.image_active = 1 AND c.cat_id = i.cat_id AND i.cat_id NOT IN (".get_auth_cat_sql("auth_viewcat", "NOTIN").")
 112          ORDER BY i.image_date DESC
 113          LIMIT $num_new_images";
 114  $result = $site_db->query($sql);
 115  $num_rows = $site_db->get_numrows($result);
 116  
 117  if (!$num_rows)  {
 118    $new_images = "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\"><tr class=\"imagerow1\"><td>";
 119    $new_images .= $lang['no_new_images'];
 120    $new_images .= "</td></tr></table>";
 121  }
 122  else  {
 123    $new_images = "<table width=\"".$config['image_table_width']."\" border=\"0\" cellpadding=\"".$config['image_table_cellpadding']."\" cellspacing=\"".$config['image_table_cellspacing']."\">";
 124    $count = 0;
 125    $bgcounter = 0;
 126    while ($image_row = $site_db->fetch_array($result)){
 127      if ($count == 0) {
 128        $row_bg_number = ($bgcounter++ % 2 == 0) ? 1 : 2;
 129        $new_images .= "<tr class=\"imagerow".$row_bg_number."\">\n";
 130      }
 131      $new_images .= "<td width=\"".$imgtable_width."\" valign=\"top\">\n";
 132  
 133      show_image($image_row);
 134      $new_images .= $site_template->parse_template("thumbnail_bit");
 135      $new_images .= "\n</td>\n";
 136      $count++;
 137      if ($count == $config['image_cells']) {
 138        $new_images .= "</tr>\n";
 139        $count = 0;
 140      }
 141    } // end while
 142  
 143    if ($count > 0)  {
 144      $leftover = ($config['image_cells'] - $count);
 145      if ($leftover >= 1) {
 146        for ($f = 0; $f < $leftover; $f++) {
 147          $new_images .= "<td width=\"".$imgtable_width."\">\n&nbsp;\n</td>\n";
 148        }
 149        $new_images .= "</tr>\n";
 150      }
 151    }
 152    $new_images .= "</table>\n";
 153  } // end else
 154  
 155  $site_template->register_vars("new_images", $new_images);
 156  unset($new_images);
 157  
 158  //-----------------------------------------------------
 159  //--- Print Out ---------------------------------------
 160  //-----------------------------------------------------
 161  $site_template->register_vars(array(
 162    "msg" => $msg,
 163    "clickstream" => $clickstream
 164  ));
 165  $site_template->print_template($site_template->parse_template($main_template));
 166  
 167  $content = ob_get_contents();
 168  ob_end_clean();
 169  
 170  if ($cache_page_index) {
 171    // Reset session mode
 172    $site_sess->mode = $old_session_mode;
 173  
 174    save_cache_file($cache_id, $content);
 175  }
 176  
 177  } // end if get_cache_file()
 178  
 179  echo $content;
 180  
 181  include (ROOT_PATH.'includes/page_footer.php');
 182  ?>

title

Description

title

Description

title

Description

title

title

Body