4images PHP Cross Reference Image Galleries

Source: /top.php - 254 lines - 14075 bytes - Summary - Text - Print

   1  <?php
   2  /**************************************************************************
   3   *                                                                        *
   4   *    4images - A Web Based Image Gallery Management System               *
   5   *    ----------------------------------------------------------------    *
   6   *                                                                        *
   7   *             File: top.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  $main_template = 'top';
  26  
  27  define('GET_CACHES', 1);
  28  define('ROOT_PATH', './');
  29  define('MAIN_SCRIPT', __FILE__);
  30  include (ROOT_PATH.'global.php');
  31  require (ROOT_PATH.'includes/sessions.php');
  32  $user_access = get_permission();
  33  include (ROOT_PATH.'includes/page_header.php');
  34  
  35  $cache_id = create_cache_id(
  36    'page.top',
  37    array(
  38      $user_info[$user_table_fields['user_id']],
  39      $cat_id,
  40      $config['template_dir'],
  41      $config['language_dir']
  42    )
  43  );
  44  
  45  if (!$cache_page_top || !$content = get_cache_file($cache_id)) {
  46  if ($cache_page_top) {
  47    // Always append session id if cache is enabled
  48    $old_session_mode = $site_sess->mode;
  49    $site_sess->mode = 'get';
  50  }
  51  
  52  ob_start();
  53  
  54  $cat_match_sql = ($cat_id && check_permission("auth_viewcat", $cat_id)) ? "AND i.cat_id = '$cat_id' " : "";
  55  $register_array = array();
  56  
  57  $cat_id_sql = get_auth_cat_sql("auth_viewcat", "NOTIN");
  58  
  59  // Rating
  60  $sql = "SELECT i.image_id, i.user_id, i.cat_id, i.image_name, i.image_rating, i.image_votes, c.cat_name".get_user_table_field(", u.", "user_name")."
  61          FROM (".IMAGES_TABLE." i, ".CATEGORIES_TABLE." c)
  62          LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = i.user_id)
  63          WHERE i.image_active = 1 AND i.cat_id NOT IN ($cat_id_sql) AND i.cat_id = c.cat_id
  64          $cat_match_sql
  65          ORDER BY i.image_rating DESC, i.image_name ASC
  66          LIMIT 10";
  67  $result = $site_db->query($sql);
  68  $top_list = array();
  69  $i = 1;
  70  while ($row = $site_db->fetch_array($result)) {
  71    $top_list[$i] = $row;
  72    $i++;
  73  }
  74  $site_db->free_result();
  75  
  76  for ($i = 1; $i <= 10; $i++) {
  77    if (isset($top_list[$i])) {
  78      $register_array['image_rating_'.$i] = (check_permission("auth_viewimage", $top_list[$i]['cat_id'])) ? "<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$top_list[$i]['image_id'])."\">".format_text($top_list[$i]['image_name'], 2)."</a>" : format_text($top_list[$i]['image_name'], 2);
  79      $register_array['image_rating_openwindow_'.$i] = (check_permission("auth_viewimage", $top_list[$i]['cat_id'])) ? "<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$top_list[$i]['image_id'])."\" onclick=\"opendetailwindow()\" target=\"detailwindow\">".format_text($top_list[$i]['image_name'])."</a>" : format_text($top_list[$i]['image_name']);
  80      if (isset($top_list[$i][$user_table_fields['user_name']]) && $top_list[$i]['user_id'] != GUEST) {
  81        $user_profile_link = (!empty($url_show_profile)) ? preg_replace("/{user_id}/", $top_list[$i]['user_id'], $url_show_profile) : ROOT_PATH."member.php?action=showprofile&amp;".URL_USER_ID."=".$top_list[$i]['user_id'];
  82        $register_array['image_rating_user_'.$i] = "<a href=\"".$site_sess->url($user_profile_link)."\">".format_text($top_list[$i][$user_table_fields['user_name']])."</a>";
  83      }
  84      else {
  85        $register_array['image_rating_user_'.$i] = $lang['userlevel_guest'];
  86      }
  87      $register_array['image_rating_cat_'.$i] = "<a href=\"".$site_sess->url(ROOT_PATH."categories.php?".URL_CAT_ID."=".$top_list[$i]['cat_id'])."\">".format_text($top_list[$i]['cat_name'])."</a>";
  88      $register_array['image_rating_number_'.$i] = "<b>".$top_list[$i]['image_rating']."</b> (".$top_list[$i]['image_votes']." ".$lang['votes'].")";
  89    }
  90    else {
  91      $register_array['image_rating_'.$i] = "--";
  92      $register_array['image_rating_user_'.$i] = "--";
  93      $register_array['image_rating_cat_'.$i] = "--";
  94      $register_array['image_rating_number_'.$i] = "--";
  95    }
  96  }
  97  
  98  // Votes
  99  $sql = "SELECT i.image_id, i.user_id, i.cat_id, i.image_name, i.image_rating, i.image_votes, c.cat_name".get_user_table_field(", u.", "user_name")."
 100          FROM (".IMAGES_TABLE." i, ".CATEGORIES_TABLE." c)
 101          LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = i.user_id)
 102          WHERE i.image_active = 1 AND i.cat_id NOT IN ($cat_id_sql) AND i.cat_id = c.cat_id
 103          $cat_match_sql
 104          ORDER BY i.image_votes DESC, i.image_name ASC
 105          LIMIT 10";
 106  $result = $site_db->query($sql);
 107  $top_list = array();
 108  $i = 1;
 109  while ($row = $site_db->fetch_array($result)) {
 110    $top_list[$i] = $row;
 111    $i++;
 112  }
 113  $site_db->free_result();
 114  
 115  for ($i = 1; $i <= 10; $i++) {
 116    if (isset($top_list[$i])) {
 117      $register_array['image_votes_'.$i] = (check_permission("auth_viewimage", $top_list[$i]['cat_id'])) ? "<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$top_list[$i]['image_id'])."\">".format_text($top_list[$i]['image_name'])."</a>" : format_text($top_list[$i]['image_name']);
 118      $register_array['image_votes_openwindow_'.$i] = (check_permission("auth_viewimage", $top_list[$i]['cat_id'])) ? "<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$top_list[$i]['image_id'])."\" onclick=\"opendetailwindow()\" target=\"detailwindow\">".format_text($top_list[$i]['image_name'])."</a>" : format_text($top_list[$i]['image_name']);
 119      if (isset($top_list[$i][$user_table_fields['user_name']]) && $top_list[$i]['user_id'] != GUEST) {
 120        $user_profile_link = (!empty($url_show_profile)) ? preg_replace("/{user_id}/", $top_list[$i]['user_id'], $url_show_profile) : ROOT_PATH."member.php?action=showprofile&amp;".URL_USER_ID."=".$top_list[$i]['user_id'];
 121        $register_array['image_votes_user_'.$i] = "<a href=\"".$site_sess->url($user_profile_link)."\">".format_text($top_list[$i][$user_table_fields['user_name']])."</a>";
 122      }
 123      else {
 124        $register_array['image_votes_user_'.$i] = $lang['userlevel_guest'];
 125      }
 126      $register_array['image_votes_cat_'.$i] = "<a href=\"".$site_sess->url(ROOT_PATH."categories.php?".URL_CAT_ID."=".$top_list[$i]['cat_id'])."\">".format_text($top_list[$i]['cat_name'])."</a>";
 127      $register_array['image_votes_number_'.$i] = "<b>".$top_list[$i]['image_rating']."</b> (".$top_list[$i]['image_votes']." ".$lang['votes'].")";
 128    }
 129    else {
 130      $register_array['image_votes_'.$i] = "--";
 131      $register_array['image_votes_user_'.$i] = "--";
 132      $register_array['image_votes_cat_'.$i] = "--";
 133      $register_array['image_votes_number_'.$i] = "--";
 134    }
 135  }
 136  
 137  // Hits
 138  $sql = "SELECT i.image_id, i.user_id, i.cat_id, i.image_name, i.image_hits, c.cat_name".get_user_table_field(", u.", "user_name")."
 139          FROM (".IMAGES_TABLE." i, ".CATEGORIES_TABLE." c)
 140          LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = i.user_id)
 141          WHERE i.image_active = 1 AND i.cat_id NOT IN ($cat_id_sql) AND i.cat_id = c.cat_id
 142          $cat_match_sql
 143          ORDER BY i.image_hits DESC, i.image_name ASC
 144          LIMIT 10";
 145  $result = $site_db->query($sql);
 146  $top_list = array();
 147  $i = 1;
 148  while ($row = $site_db->fetch_array($result)) {
 149    $top_list[$i] = $row;
 150    $i++;
 151  }
 152  $site_db->free_result();
 153  
 154  for ($i = 1; $i <= 10; $i++) {
 155    if (isset($top_list[$i])) {
 156      $register_array['image_hits_'.$i] = (check_permission("auth_viewimage", $top_list[$i]['cat_id'])) ? "<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$top_list[$i]['image_id'])."\">".format_text($top_list[$i]['image_name'])."</a>" : format_text($top_list[$i]['image_name']);
 157      $register_array['image_hits_openwindow_'.$i] = (check_permission("auth_viewimage", $top_list[$i]['cat_id'])) ? "<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$top_list[$i]['image_id'])."\" onclick=\"opendetailwindow()\" target=\"detailwindow\">".format_text($top_list[$i]['image_name'])."</a>" : format_text($top_list[$i]['image_name']);
 158      if (isset($top_list[$i][$user_table_fields['user_name']]) && $top_list[$i]['user_id'] != GUEST) {
 159        $user_profile_link = (!empty($url_show_profile)) ? preg_replace("/{user_id}/", $top_list[$i]['user_id'], $url_show_profile) : ROOT_PATH."member.php?action=showprofile&amp;".URL_USER_ID."=".$top_list[$i]['user_id'];
 160        $register_array['image_hits_user_'.$i] = "<a href=\"".$site_sess->url($user_profile_link)."\">".format_text($top_list[$i][$user_table_fields['user_name']])."</a>";
 161      }
 162      else {
 163        $register_array['image_hits_user_'.$i] = $lang['userlevel_guest'];
 164      }
 165      $register_array['image_hits_cat_'.$i] = "<a href=\"".$site_sess->url(ROOT_PATH."categories.php?".URL_CAT_ID."=".$top_list[$i]['cat_id'])."\">".format_text($top_list[$i]['cat_name'])."</a>";
 166      $register_array['image_hits_number_'.$i] = "<b>".$top_list[$i]['image_hits']."</b>";
 167    }
 168    else {
 169      $register_array['image_hits_'.$i] = "--";
 170      $register_array['image_hits_user_'.$i] = "--";
 171      $register_array['image_hits_cat_'.$i] = "--";
 172      $register_array['image_hits_number_'.$i] = "--";
 173    }
 174  }
 175  
 176  // Downloads
 177  $sql = "SELECT i.image_id, i.user_id, i.cat_id, i.image_name, i.image_downloads, c.cat_name".get_user_table_field(", u.", "user_name")."
 178          FROM (".IMAGES_TABLE." i, ".CATEGORIES_TABLE." c)
 179          LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = i.user_id)
 180          WHERE i.image_active = 1 AND i.cat_id NOT IN ($cat_id_sql) AND i.cat_id = c.cat_id
 181          $cat_match_sql
 182          ORDER BY i.image_downloads DESC, i.image_name ASC
 183          LIMIT 10";
 184  $result = $site_db->query($sql);
 185  $top_list = array();
 186  $i = 1;
 187  while ($row = $site_db->fetch_array($result)) {
 188    $top_list[$i] = $row;
 189    $i++;
 190  }
 191  $site_db->free_result();
 192  
 193  for ($i = 1; $i <= 10; $i++) {
 194    if (isset($top_list[$i])) {
 195      $register_array['image_downloads_'.$i] = (check_permission("auth_viewimage", $top_list[$i]['cat_id'])) ? "<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$top_list[$i]['image_id'])."\">".format_text($top_list[$i]['image_name'])."</a>" : format_text($top_list[$i]['image_name']);
 196      $register_array['image_downloads_openwindow_'.$i] = (check_permission("auth_viewimage", $top_list[$i]['cat_id'])) ? "<a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$top_list[$i]['image_id'])."\" onclick=\"opendetailwindow()\" target=\"detailwindow\">".format_text($top_list[$i]['image_name'])."</a>" : format_text($top_list[$i]['image_name']);
 197      if (isset($top_list[$i][$user_table_fields['user_name']]) && $top_list[$i]['user_id'] != GUEST) {
 198        $user_profile_link = (!empty($url_show_profile)) ? preg_replace("/{user_id}/", $top_list[$i]['user_id'], $url_show_profile) : ROOT_PATH."member.php?action=showprofile&amp;".URL_USER_ID."=".$top_list[$i]['user_id'];
 199        $register_array['image_downloads_user_'.$i] = "<a href=\"".$site_sess->url($user_profile_link)."\">".format_text($top_list[$i][$user_table_fields['user_name']])."</a>";
 200      }
 201      else {
 202        $register_array['image_downloads_user_'.$i] = $lang['userlevel_guest'];
 203      }
 204      $register_array['image_downloads_cat_'.$i] = "<a href=\"".$site_sess->url(ROOT_PATH."categories.php?".URL_CAT_ID."=".$top_list[$i]['cat_id'])."\">".format_text($top_list[$i]['cat_name'])."</a>";
 205      $register_array['image_downloads_number_'.$i] = "<b>".$top_list[$i]['image_downloads']."</b>";
 206    }
 207    else {
 208      $register_array['image_downloads_'.$i] = "--";
 209      $register_array['image_downloads_user_'.$i] = "--";
 210      $register_array['image_downloads_cat_'.$i] = "--";
 211      $register_array['image_downloads_number_'.$i] = "--";
 212    }
 213  }
 214  
 215  $site_template->register_vars($register_array);
 216  
 217  //-----------------------------------------------------
 218  //--- Clickstream -------------------------------------
 219  //-----------------------------------------------------
 220  $clickstream = "<span class=\"clickstream\"><a href=\"".$site_sess->url(ROOT_PATH."index.php")."\" class=\"clickstream\">".$lang['home']."</a>".$config['category_separator'];
 221  if ($cat_id && isset($cat_cache[$cat_id])) {
 222    $clickstream .= get_category_path($cat_id, 1).$config['category_separator'];
 223  }
 224  $clickstream .= $lang['top_images']."</span>";
 225  
 226  //-----------------------------------------------------
 227  //--- Print Out ---------------------------------------
 228  //-----------------------------------------------------
 229  $site_template->register_vars(array(
 230    "msg" => $msg,
 231    "clickstream" => $clickstream,
 232    "lang_top_image_hits" => $lang['top_image_hits'],
 233    "lang_top_image_downloads" => $lang['top_image_downloads'],
 234    "lang_top_image_rating" => $lang['top_image_rating'],
 235    "lang_top_image_votes" => $lang['top_image_votes']
 236  ));
 237  $site_template->print_template($site_template->parse_template($main_template));
 238  
 239  $content = ob_get_contents();
 240  ob_end_clean();
 241  
 242  if ($cache_page_top) {
 243    // Reset session mode
 244    $site_sess->mode = $old_session_mode;
 245  
 246    save_cache_file($cache_id, $content);
 247  }
 248  
 249  } // end if get_cache_file()
 250  
 251  echo $content;
 252  
 253  include (ROOT_PATH.'includes/page_footer.php');
 254  ?>

title

Description

title

Description

title

Description

title

title

Body