Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Chris

Pages: 1 [2] 3 4 5
16
Quote
When I, as an admin, delete an image, its ID remains in lightbox table, so it still counts for the user who had it in his lightbox. I've tried a search but nothing, is there a way to solve this? I show in user_logininfo the total number of images the user has in his lightbox, but after deleting one of them it is still counted...

Here is the fix:

in admin/images.php find:

Code: [Select]
  $sql = "SELECT image_id, cat_id, user_id, image_name, image_media_file, image_thumb_file
          FROM ".IMAGES_TABLE."
          WHERE image_id IN ($image_ids)";
  $image_result = $site_db->query($sql);
  while ($image_row = $site_db->fetch_array($image_result)) {

replace it with:
Code: [Select]
  $sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_media_file, i.image_thumb_file, l.lightbox_image_ids
          FROM ".IMAGES_TABLE." i
          LEFT JOIN ".LIGHTBOXES_TABLE." l ON (l.user_id = i.user_id)
          WHERE i.image_id IN ($image_ids)";
  $image_result = $site_db->query($sql);
  while ($image_row = $site_db->fetch_array($image_result)) {
    if ($image_row['user_id'] != GUEST)
    {
      $lightbox_array = explode(" ",$image_row['lightbox_image_ids']);
      foreach ($lightbox_array as $key => $val) {
        if ($val == $image_row['image_id']) {
          unset($lightbox_array[$key]);
        }
      }
      $lightbox_image_ids = trim(implode(" ", $lightbox_array));
      $sql = "UPDATE ".LIGHTBOXES_TABLE."
              SET lightbox_image_ids = '".$lightbox_image_ids."'
              WHERE user_id = ".$image_row['user_id'];
      $site_db->query($sql);
    }

This should work as with original admin/images.php as with the v2.x and v3.x from the MODs forum. But it will not work for GUESTs ("Lighbox for guests" MOD)

17
This fix will let u use IP and FTP addresses in download URL and remote image path.

Open /includes/functions.php

Find:
Code: [Select]
  return (preg_match('#^https?\\:\\/\\/[a-z0-9\-]+\.([a-z0-9\-]+\.)?[a-z]+#i', $file_name)) ? 1 : 0;
Replace with:
Code: [Select]
  return (preg_match("/^(http|https|ftp):\/\/(([A-Z0-9][A-Z0-9_-]*)(:[A-Z0-9][A-Z0-9_-]*)?@)?(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?(\/)?/i", $file_name)) ? 1 : 0;

Find:
Code: [Select]
  return (preg_match("#^(https?:\/\/[a-z0-9\-]+?\.([a-z0-9\-]+\.)*[a-z]+(:[0-9]+)*\/.*?\.([a-z]{1,4})$)#is", $file_name)) ? 1 : 0;
Replace with:
Code: [Select]
  return (preg_match("/^(http|https|ftp):\/\/(([A-Z0-9][A-Z0-9_-]*)(:[A-Z0-9][A-Z0-9_-]*)?@)?(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?\/.*\.([a-z]{1,4})$/i", $file_name)) ? 1 : 0;

Find:
Code: [Select]
  return (preg_match("#^(https?:\/\/[a-z0-9\-]+?\.([a-z0-9\-]+\.)*[a-z]+(:[0-9]+)*\/.*?\.(".$config['allowed_mediatypes_match'].")$)#is", $remote_media_file)) ? 1 : 0;
Replace with:
Code: [Select]
  return (preg_match("/^(http|https|ftp):\/\/(([A-Z0-9][A-Z0-9_-]*)(:[A-Z0-9][A-Z0-9_-]*)?@)?(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?\/.*\.(".$config['allowed_mediatypes_match'].")$/i", $remote_media_file)) ? 1 : 0;

Find:
Code: [Select]
  return (preg_match("#^(https?:\/\/[a-z0-9\-]+?\.([a-z0-9\-]+\.)*[a-z]+(:[0-9]+)*\/.*?\.(gif|jpg|jpeg|png)$)#is", $remote_thumb_file)) ? 1 : 0;
Replace with:
Code: [Select]
  return (preg_match("/^(http|https|ftp):\/\/(([A-Z0-9][A-Z0-9_-]*)(:[A-Z0-9][A-Z0-9_-]*)?@)?(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?\/.*\.(gif|jpg|jpeg|png)$/i", $remote_thumb_file)) ? 1 : 0;

Find:
Code: [Select]
  if (!preg_match("/^https?\\:\\/\\/[a-z0-9\-]+\.([a-z0-9\-]+\.)?[a-z]+/i", $url)) {
Replace with:
Code: [Select]
  if (!preg_match("/^(http|https|ftp):\/\/(([A-Z0-9][A-Z0-9_-]*)(:[A-Z0-9][A-Z0-9_-]*)?@)?(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?(\/)?/i", $url)) {

I've tested it with this url types:
http://example.com/image.jpg
http://user@example.com/image.jpg
http://user:pass@example.com/image.jpg
http://123.123.123.123/image.jpg
http://user@123.123.123.123/image.jpg
http://user:pass@123.123.123.123/image.jpg
ftp://, https:// and port numbers also working

Please let me know if u find anything not working after these changes.

P.S. there is a bug in member.php that let u upload not existing images by using remote url.

18
ACP = Admin Control Panel

Just discovered a bug that acure when u are trying find an image from the ACP that was uploaded by a not existing user (user was deleted).

To test it u can do the following:
1) create a user
2) upload an image (image must be validated)
3) delete the user
4) in ACP go to "Edit images" and try to find the image.

To fix that, find in /admin/images.php
Code: [Select]
  $sql = "SELECT COUNT(*) AS images
          FROM ".IMAGES_TABLE." i, ".USERS_TABLE." u
          WHERE $condition AND ".get_user_table_field("u.", "user_id")." = i.user_id";

replace it with:
Code: [Select]
  $sql = "SELECT COUNT(*) AS images
          FROM ".IMAGES_TABLE." i
          LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = i.user_id)
          WHERE ".$condition;

then find:
Code: [Select]
    $sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_media_file, i.image_date".get_user_table_field(", u.", "user_name")."
            FROM ".IMAGES_TABLE." i, ".USERS_TABLE." u
            WHERE $condition AND ".get_user_table_field("u.", "user_id")." = i.user_id

replace with:
Code: [Select]
    $sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_media_file, i.image_date".get_user_table_field(", u.", "user_name")."
            FROM ".IMAGES_TABLE." i
            LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = i.user_id)
            WHERE $condition

19
Bug Fixes & Patches / [1.7.1] {if blah} {endif blah} left in templates
« on: March 16, 2005, 04:20:34 AM »
Since 4images v1.7.1 was released some conditional tags in the templates are not working properly, the tags are being showed.
I'm not quite sure if this was intentionally or it was forgotten from v1.7.1 beta, but function clean_template() is missing cleaning the conditional tags.

To fix that find in include/templates.php:

Code: [Select]
    $template = preg_replace(
      "/".preg_quote($this->start)."[^".preg_quote($this->end)."\s]+".preg_quote($this->end)."/",
      '',
      $template
    );

add after:
Code: [Select]
    $search_array = array(
      "/".preg_quote($this->start).'if\s+([A-Z0-9_]+)'.preg_quote($this->end)."/i",
      "/".preg_quote($this->start).'endif\s+([A-Z0-9_]+)'.preg_quote($this->end)."/i"
    );
    $replace_array = array(
      "",
      ""
    );
    $template = preg_replace($search_array, $replace_array, $template);

20
From the postcard_preview.html template, 4images versions 1.7 and 1.7.1 both tie the {lang_edit_postcard}, "Modify eCard" / "eCard bearbeiten", form button to the browser history back function. This sends the visitor back to the postcard_create.html templated page. But whether the values previously entered into the form fields appear or the form is reset to its defaults depends on the browser being used. Under Internet Explorer 6, the browser doesn't even navigate back!

The code posted here fixes the "Modify eCard" / "eCard bearbeiten" button so that the user is always sent back to the postcard_create.html templated page and the values they entered previously are reused when the page loads.

Open postcards.php

Locate:
Code: [Select]
$main_template = ($action == "createcard") ? "postcard_create" : (($action == "previewcard") ? "postcard_create" : "postcard_send");
Change to:
Code: [Select]
$main_template = ($action == "createcard" || $action == "modifycard") ? "postcard_create" : (($action == "previewcard") ? "postcard_create" : "postcard_send");

Locate:
Code: [Select]
if ($action == "createcard") {
Change to:
Code: [Select]
if ($action == "createcard" || $action == "modifycard") {

Locate:
Code: [Select]
  if (!$sendprocess) {
    $bg_color = "";
    $border_color = "";
    $font_color = "";
    $font_face = "";
    $sender_name = ($user_info['user_level'] != GUEST) ? $user_info['user_name'] : "";
    $sender_email = ($user_info['user_level'] != GUEST) ? $user_info['user_email'] : "";
    $recipient_name = "";
    $recipient_email = "";
    $headline = "";
    $message = "";
  }

Add immediately after on a new line:
Code: [Select]
  if ($action == "modifycard") {
    $bg_color = un_htmlspecialchars(trim($HTTP_POST_VARS['bg_color']));
    $border_color = un_htmlspecialchars(trim($HTTP_POST_VARS['border_color']));
    $font_color = un_htmlspecialchars(trim($HTTP_POST_VARS['font_color']));
    $font_face = un_htmlspecialchars(trim($HTTP_POST_VARS['font_face']));

    $sender_name = un_htmlspecialchars(trim($HTTP_POST_VARS['sender_name']));
    $sender_email = un_htmlspecialchars(trim($HTTP_POST_VARS['sender_email']));
    $recipient_name = un_htmlspecialchars(trim($HTTP_POST_VARS['recipient_name']));
    $recipient_email = un_htmlspecialchars(trim($HTTP_POST_VARS['recipient_email']));

    $headline = un_htmlspecialchars(trim($HTTP_POST_VARS['headline']));
    $message = un_htmlspecialchars(trim($HTTP_POST_VARS['message']));
  }


Three lines down locate:
Code: [Select]
  $site_template->register_vars(array(
    "image" => $image,
    "thumbnail" => $thumbnail,
    "image_name" => $image_row['image_name'],
    "lang_bg_color" => $lang['bg_color'],
    "lang_border_color" => $lang['border_color'],
    "lang_font_color" => $lang['font_color'],
    "lang_font_face" => $lang['font_face'],
    "lang_sender" => $lang['sender'],
    "lang_recipient" => $lang['recipient'],
    "lang_email" => $lang['email'],
    "lang_name" => $lang['name'],
    "lang_headline" => $lang['headline'],
    "lang_message" => $lang['message'],
    "lang_preview_postcard" => $lang['preview_postcard'],
    "url_postcard" => $site_sess->url(ROOT_PATH."postcards.php?".URL_IMAGE_ID."=".$image_id),
    "sender_name" => stripslashes($sender_name),
    "sender_email" => stripslashes($sender_email),
    "recipient_name" => stripslashes($recipient_name),
    "recipient_email" => stripslashes($recipient_email),
    "headline" => stripslashes($headline),
    "message" => stripslashes($message),
    "lang_send_postcard" => $lang['send_postcard'],
    "back_url" => stripslashes($url)
  ));

Change to:
Code: [Select]
  $site_template->register_vars(array(
    "image" => $image,
    "thumbnail" => $thumbnail,
    "image_name" => $image_row['image_name'],
    "lang_bg_color" => $lang['bg_color'],
    "bg_color" => $bg_color,
    "lang_border_color" => $lang['border_color'],
    "border_color" => $border_color,
    "lang_font_color" => $lang['font_color'],
    "font_color" => $font_color,
    "lang_font_face" => $lang['font_face'],
    "font_face" => $font_face,
    "lang_sender" => $lang['sender'],
    "lang_recipient" => $lang['recipient'],
    "lang_email" => $lang['email'],
    "lang_name" => $lang['name'],
    "lang_headline" => $lang['headline'],
    "lang_message" => $lang['message'],
    "lang_preview_postcard" => $lang['preview_postcard'],
    "url_postcard" => $site_sess->url(ROOT_PATH."postcards.php?".URL_IMAGE_ID."=".$image_id),
    "sender_name" => stripslashes($sender_name),
    "sender_email" => stripslashes($sender_email),
    "recipient_name" => stripslashes($recipient_name),
    "recipient_email" => stripslashes($recipient_email),
    "headline" => stripslashes($headline),
    "message" => stripslashes($message),
    "lang_send_postcard" => $lang['send_postcard'],
    "back_url" => stripslashes($url)
  ));


Open postcard_create.html

Locate:
Code: [Select]
                  <form method="post" action="{url_postcard}">
Change to:
Code: [Select]
                  <form method="post" action="{url_postcard}" name="createCard">

Locate:
Code: [Select]
                  </form>
Change to:
Code: [Select]
                  </form>
<script language="javascript" type="text/javascript">
var bg_color = "{bg_color}";
var border_color = "{border_color}";
var font_color = "{font_color}";
var font_face = "{font_face}";
   
function RestoreUserValues()
{
  var x = document.forms.createCard;
  for (i=0;i<x.bg_color.length;i++) {
    if (x.bg_color[i].value == bg_color) {
      x.bg_color[i].checked = true;
      break;
    }
  }
  for (i=0;i<x.border_color.length;i++) {
    if (x.border_color[i].value == border_color) {
      x.border_color[i].checked = true;
      break;
    }
  }
  for (i=0;i<x.font_color.length;i++) {
    if (x.font_color[i].value == font_color) {
      x.font_color[i].checked = true;
      break;
    }
  }
  for (i=0;i<x.font_face.length;i++) {
    if (x.font_face[i].value == font_face) {
      x.font_face[i].checked = true;
      break;
    }
  }
}
if( bg_color != "" )
  RestoreUserValues();
</script>


Open postcard_preview.html

Locate:
Code: [Select]
<form action="{url_postcard}" method="post">
Change to:
Code: [Select]
<form action="{url_postcard}" method="post" name="previewCard">

Locate:
Code: [Select]
    <input type="button" value="{lang_edit_postcard}" onclick="history.go(-1)" class="button" />
Change to:
Code: [Select]
    <input type="button" value="{lang_edit_postcard}" onclick="document.forms.previewCard.elements['action'].value = 'modifycard';document.forms.previewCard.submit();" class="button" />

NOTES:
This FIX is compatible with the [Mod] Keep text formatting of eCard message

21
FAQ, Tips / [Tutorial] Making additional fields searchable
« on: March 15, 2005, 01:57:19 AM »
I have added a field to the database for my images.  How can I make it searchable just like keywords, and description fields?

http://www.4homepages.de/forum/index.php?topic=1313.msg5562#msg5562

22
I am reposting this template pack since I had backup copies of the files.  I did NOT create this template and I will not support it.  Thank you and enjoy.

The white border around the screen shot is not part of the template itself.  I left it there so the edges were clear.

23
Code: [Select]
Warning: ob_start(): output handler 'ob_gzhandler' cannot be used after 'URL-Rewriter'
From the admin control panel, under "Settings", set "Use GZip compression" to "No".

This message appears because Apache is already compressing the output due to your server's php.ini settings. Use one or the other, not both.

24
Quote
There is some speculation as to whether or not a search engine will crawl pages that have a URL with a query string:
Code: [Select]
categories.php?cat_id=12&page=2The webmaster documentation for some search engines suggests their crawlers will not crawl pages with these types of URLs as they may represent and INFINITE URL space.  Frankly, Google has ALWAYS crawled all of my web pages with these URLs with no problems.  My opinion is that it is the session id in a query string that may influence the crawler.

The following was recovered from search engine cache and restored by me. I did not write this mod

This mod will convert your 4images URLs into shorter URLs and remove the query string.  This mod requires an Apache compatible web server.

Step 1
Open /includes/sessions.php
Find:
Code: [Select]
  function url($url, $amp = "&amp;") {
    global $l;
    $dummy_array = explode("#", $url);
    $url = $dummy_array[0];

    if ($this->mode == "get" && !preg_match("/".SESSION_NAME."=/i", $url)) {
      $url .= preg_match("/\?/", $url) ? "$amp" : "?";
      $url .= SESSION_NAME."=".$this->session_id;
    }

    if (!empty($l)) {
      $url .= preg_match("/\?/", $url) ? "$amp" : "?";
      $url .= "l=".$l;
    }

    $url .= (isset($dummy_array[1])) ? "#".$dummy_array[1] : "";
    return $url;
  }
Replace with:
Code: [Select]
/* ORIGINAL CODE
  function url($url, $amp = "&amp;") {
    global $l;
    $dummy_array = explode("#", $url);
    $url = $dummy_array[0];

    if ($this->mode == "get" && !preg_match("/".SESSION_NAME."=/i", $url)) {
      $url .= preg_match("/\?/", $url) ? "$amp" : "?";
      $url .= SESSION_NAME."=".$this->session_id;
    }

    if (!empty($l)) {
      $url .= preg_match("/\?/", $url) ? "$amp" : "?";
      $url .= "l=".$l;
    }

    $url .= (isset($dummy_array[1])) ? "#".$dummy_array[1] : "";
    return $url;
  }
*/
  function url($url, $amp = "&amp;") {
    global $l, $user_info;
    $dummy_array = explode("#", $url);
    $url = $dummy_array[0];
    $url = str_replace('&amp;', '&', $url);
    if (!defined('IN_CP')) {
      if (strstr($url, 'index.php')) {
        $url = str_replace('index.php', './', $url);
      }
      elseif (strstr($url, 'search.php')) {
        if (strstr($url, 'page=')) {
          preg_match('#page=([0-9]+)&?#', $url, $matches);
          if (isset($matches[1])) {
            $split = explode('?', $url);
            $url = $split[0];
            $query = @$split[1];
            $url   = str_replace('search.php', 'search.'.$matches[1].'.htm', $url);
            $query = str_replace('page='.$matches[1].'&', '', $query);
            $query = str_replace('&page='.$matches[1], '', $query);
            $query = str_replace('page='.$matches[1], '', $query);
            if (!empty($query)) {
              $url .= '?' . $query;
            }
          }
        }
        else {
          $url = str_replace('search.php', 'search.htm', $url);
        }
      }
      elseif (strstr($url, 'lightbox.php')) {
        if (strstr($url, 'page=')) {
          preg_match('#page=([0-9]+)&?#', $url, $matches);
          if (isset($matches[1])) {
            $split = explode('?', $url);
            $url = $split[0];
            $query = @$split[1];
            $url   = str_replace('lightbox.php', 'lightbox.'.$matches[1].'.htm', $url);
            $query = str_replace('page='.$matches[1].'&', '', $query);
            $query = str_replace('&page='.$matches[1], '', $query);
            $query = str_replace('page='.$matches[1], '', $query);
            if (!empty($query)) {
                $url .= '?' . $query;
            }
          }
        }
        else {
          $url = str_replace('lightbox.php', 'lightbox.htm', $url);
        }
      }
      elseif (strstr($url, 'categories.php')) {
        if (strstr($url, 'cat_id=') && strstr($url, 'page=')) {
          preg_match('#cat_id=([0-9]+)&?#', $url, $matches1);
          preg_match('#page=([0-9]+)&?#', $url, $matches2);
          if (isset($matches1[1]) && isset($matches2[1])) {
            $split = explode('?', $url);
            $url = $split[0];
            $query = @$split[1];
            $url   = str_replace('categories.php', 'cat'.$matches1[1].'.'.$matches2[1].'.htm', $url);
            $query = str_replace('cat_id='.$matches1[1].'&', '', $query);
            $query = str_replace('&cat_id='.$matches1[1], '', $query);
            $query = str_replace('cat_id='.$matches1[1], '', $query);
            $query = str_replace('page='.$matches2[1].'&', '', $query);
            $query = str_replace('&page='.$matches2[1], '', $query);
            $query = str_replace('page='.$matches2[1], '', $query);
            if (!empty($query)) {
              $url .= '?' . $query;
            }
          }
        }
        elseif (strstr($url, 'cat_id=')) {
          preg_match('#cat_id=([0-9]+)&?#', $url, $matches);
          if (isset($matches[1])) {
            $split = explode('?', $url);
            $url = $split[0];
            $query = @$split[1];
            $url   = str_replace('categories.php', 'cat'.$matches[1].'.htm', $url);
            $query = str_replace('cat_id='.$matches[1].'&', '', $query);
            $query = str_replace('&cat_id='.$matches[1], '', $query);
            $query = str_replace('cat_id='.$matches[1], '', $query);
            if (!empty($query)) {
              $url .= '?' . $query;
            }
          }
        }
        else {
          $url = str_replace('categories.php', 'cat.htm', $url);
        }
      }
      elseif (strstr($url, 'details.php?image_id=')) {
        if (strstr($url, 'image_id=') && strstr($url, 'mode=')) {
          preg_match('#image_id=([0-9]+)&?#', $url, $matches1);
          preg_match('#mode=([a-zA-Z0-9]+)&?#', $url, $matches2);
          if (isset($matches1[1]) && isset($matches2[1])) {
            $split = explode('?', $url);
            $url = $split[0];
            $query = @$split[1];
            $url   = str_replace('details.php', 'img'.$matches1[1].'.'.$matches2[1].'.htm', $url);
            $query = str_replace('image_id='.$matches1[1].'&', '', $query);
            $query = str_replace('&image_id='.$matches1[1], '', $query);
            $query = str_replace('image_id='.$matches1[1], '', $query);
            $query = str_replace('mode='.$matches2[1].'&', '', $query);
            $query = str_replace('&mode='.$matches2[1], '', $query);
            $query = str_replace('mode='.$matches2[1], '', $query);
            if (!empty($query)) {
              $url .= '?' . $query;
            }
          }
        }
        else {
          preg_match('#image_id=([0-9]+)&?#', $url, $matches);
          if (isset($matches[1])) {
            $split = explode('?', $url);
            $url = $split[0];
            $query = @$split[1];
            $url   = str_replace('details.php', 'img'.$matches[1].'.htm', $url);
            $query = str_replace('image_id='.$matches[1].'&', '', $query);
            $query = str_replace('&image_id='.$matches[1], '', $query);
            $query = str_replace('image_id='.$matches[1], '', $query);
            if (!empty($query)) {
              $url .= '?' . $query;
            }
          }
        }
      }
      elseif (strstr($url, 'postcards.php?image_id=')) {
        preg_match('#image_id=([0-9]+)&?#', $url, $matches);
        if (isset($matches[1])) {
          $split = explode('?', $url);
          $url = $split[0];
          $query = @$split[1];
          $url   = str_replace('postcards.php', 'postcard.img'.$matches[1].'.htm', $url);
          $query = str_replace('image_id='.$matches[1].'&', '', $query);
          $query = str_replace('&image_id='.$matches[1], '', $query);
          $query = str_replace('image_id='.$matches[1], '', $query);
          if (!empty($query)) {
            $url .= '?' . $query;
          }
        }
      }
    }
    if ($this->mode == "get" && strstr($url, $this->session_id)) {
      $url .= strpos($url, '?') !== false ? '&' : '?';
      $url .= SESSION_NAME."=".$this->session_id;
    }
    if (!empty($l)) {
      $url .= strpos($url, '?') ? '&' : '?';
      $url .= "l=".$l;
    }
    $url = str_replace('&', $amp, $url);
    $url .= isset($dummy_array[1]) ? "#".$dummy_array[1] : "";
    return $url;
  }

Step 2
Create a new file named .htaccess (note the leading period that starts the file name) or edit your existing .htaccess file in the root level of your 4images installation.  Place the following lines inside that file:
Code: [Select]
# Begin search engine friendly links code
RewriteEngine On
#RewriteBase /
RewriteRule ^lightbox\.htm$ lightbox.php?%{QUERY_STRING}
RewriteRule ^lightbox\.([0-9]+)\.htm$ lightbox.php?page=$1&%{QUERY_STRING}

RewriteRule ^search\.htm$ search.php?%{QUERY_STRING}
RewriteRule ^search\.([0-9]+)\.htm$ search.php?page=$1&%{QUERY_STRING}

RewriteRule ^cat\.htm$ categories.php?%{QUERY_STRING}
RewriteRule ^cat([0-9]+)\.([0-9]+)\.htm$ categories.php?cat_id=$1&page=$2&%{QUERY_STRING}
RewriteRule ^cat([0-9]+)\.htm$ categories.php?cat_id=$1&%{QUERY_STRING}

RewriteRule ^img([0-9]+)\.htm$ details.php?image_id=$1&%{QUERY_STRING}
RewriteRule ^img([0-9]+)\.([a-zA-Z0-9]+)\.htm$ details.php?image_id=$1&mode=$2&%{QUERY_STRING}

RewriteRule ^postcard([a-zA-Z0-9]+)\.htm$ postcards.php?postcard_id=$1&%{QUERY_STRING}
RewriteRule ^postcard\.img([0-9]+)\.htm$ postcards.php?image_id=$1&%{QUERY_STRING}

# End search engine friendly links code

If for some reason it doesnt work for u, make sure that mod_rewrite is installed on your server and that the vdomain/dir of yours has permissions to use it (contact your hoster if u are not sure).
If it still doesnt work, try to uncomment:
Code: [Select]
#RewriteBase /
and replace / with the path to 4image root dir in your address bar.
(for example if your gallery address is: www.example.com/pix/
then u should add:
Code: [Select]
RewriteBase /pix/
Revision History:
  • Restored sessions.php mod code from search engine cached page

25
FAQ, Tips / Why is a directory listing shown instead of index.php?
« on: March 12, 2005, 10:42:23 PM »
Quote
I downloaded the 4images package and the appropriate language pack. I also uploaded the files to my server and followed the directions found in docs/Installation.txt. Per the last instruction, I pointed my browser to the URL where I uploaded 4images, however I do not get the configuration/setup menu that I should. Instead I only see a directory listing with my files. What do I need to do to be able to get the setup menu to put in my database user/password/host/name?


Your web server doesn't know that it should look for a file named index.php. And since it can't find any file named index.htm or index.html, it displays the directory listing instead.

If you're using Apache, create a file named .htaccess (note the leading period character) in the top-level of your 4images directory, or web root, and place inside it the following line:
Code: [Select]
DirectoryIndex index.php index.htm index.html
This tells the Apache web server to first look for a file named index.php, then index.htm and finally index.html when a URL is entered in a browser without a file name. If you want to disable the directory listing for directories with no index.php or index.htm* files, add this line:
Code: [Select]
# Disable directory listings in the web browser
Options -Indexes

26
By default, the category_bit.html template displays a folder icon next to categories. It is possible to also display a thumbnail of an image selected at random from that category.

In the category_bit.html template that ships with the downloaded distribution of 4images, there is the following:
Code: [Select]
<table border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td valign="top">
      <img src="{template_url}/images/folder.gif" width="20" height="13" alt="" />

      <!-- {if random_cat_image_file}<a href="{cat_url}"><img src="{random_cat_image_file}" border="1"></a>{endif random_cat_image_file}  -->

    </td>
    <td> <a href="{cat_url}" class="maincat">{cat_name}</a>&nbsp;({num_images})
      {if cat_is_new}<sup class="new">{lang_new}</sup>{endif cat_is_new} </td>
  </tr>
</table>


As you can see above, there is already HTML that can display a random category image thumbnail. It is simply commented out. To activate the thumbnail, uncomment the HTML. In this example the folder icon HTML is deleted in favor of the image thumbnail.
Code: [Select]
<table border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td valign="top">

      {if random_cat_image_file}<a href="{cat_url}"><img src="{random_cat_image_file}" border="1"></a>{endif random_cat_image_file}

    </td>
    <td> <a href="{cat_url}" class="maincat">{cat_name}</a>&nbsp;({num_images})
      {if cat_is_new}<sup class="new">{lang_new}</sup>{endif cat_is_new} </td>
  </tr>
</table>


Lastly, this feature is enabled by default, but if you previously edited includes/constants.php, check to ensure that the following line is present in that file:
Code: [Select]
define('SHOW_RANDOM_CAT_IMAGE', 1);

27
If u download images from lightbox, the download counter for each image does not getting updated.

Step 1.
Open /download.php
Find:
Code: [Select]
  $sql = "SELECT cat_id, image_media_file, image_download_urlreplace with:
Code: [Select]
  $image_ids = array();
  $sql = "SELECT cat_id, image_media_file, image_download_url, image_id


Step 1.2.
Find next:
Code: [Select]
        unset($file_data);Add after:
Code: [Select]
        $image_ids[] = $image_row['image_id'];

Step 1.3.
Find next:
Code: [Select]
    if ($file_added) {Add after:
Code: [Select]
      if ($user_info['user_level'] != ADMIN) {
        $sql = "UPDATE ".IMAGES_TABLE."
                SET image_downloads = image_downloads + 1
                WHERE image_id IN (".trim(implode(", ", $image_ids)).")";
        $site_db->query($sql);
      }



NOTE: Because there are atleast two simular parts in the file that will match with strings that u need to find, u'll need only the fist matching lines that are in between line
Code: [Select]
if ($action == "lightbox") {and
Code: [Select]
elseif ($image_id) {

28
This mod outputs a dynamic (ever changing) page title for your web pages. Essentially this adds the clickstream to your page title but without the added HTML markup.

If your site name is defined as "Smith Family Pictures" and you were viewing a details.php page for an image named "Old Bridge" in a subcategory named "Road Trip" which was a subcategory of a top-level "2005 Events" category and your admin control panel setting for "Category delimiter (in category paths)" was defined as "/", your page title would look like this: Smith Family Pictures /2005 Events/Road Trip/Old Bridge

As with any mod, ALWAYS save backup copies of any file you might edit so you can go back to a clean, working version if you encounter any problems.

Open includes/functions.php, locate:
Code: [Select]
function get_category_path($cat_id = 0, $detail_path = 0) {
  global $site_sess, $config, $cat_cache, $url;
  $parent_id = 1;
  while ($parent_id) {
    if (!isset($cat_cache[$cat_id]['cat_parent_id'])) {
      return false;
    }
    $parent_id = $cat_cache[$cat_id]['cat_parent_id'];

    if (empty($path)) {
      if ($detail_path) {
        $cat_url = ROOT_PATH."categories.php?".URL_CAT_ID."=".$cat_id;
        if (preg_match("/".URL_PAGE."=([0-9]+)/", $url, $regs)) {
          if (!empty($regs[1]) && $regs[1] != 1) {
            $cat_url .= "&amp;".URL_PAGE."=".$regs[1];
          }
        }
        $path = "<a href=\"".$site_sess->url($cat_url)."\" class=\"clickstream\">".$cat_cache[$cat_id]['cat_name']."</a>";
      }
      else  {
        $path = $cat_cache[$cat_id]['cat_name'];
      }
    }
    else {
      $path = "<a href=\"".$site_sess->url(ROOT_PATH."categories.php?".URL_CAT_ID."=".$cat_id)."\" class=\"clickstream\">".$cat_cache[$cat_id]['cat_name']."</a>".$config['category_separator'].$path;
    }
    $cat_id = $parent_id;
  } // end while
  return $path;
}

Add after:
Code: [Select]

function get_category_path_nohtml($cat_id = 0) {  // MOD: Dynamic page title
  global $config, $cat_cache;
  $parent_id = 1;
  while ($parent_id) {
    if (!isset($cat_cache[$cat_id]['cat_parent_id'])) {
      return false;
    }
    $parent_id = $cat_cache[$cat_id]['cat_parent_id'];

    if (empty($path)) {
      $path = $cat_cache[$cat_id]['cat_name'];
    }
    else {
      $path = $cat_cache[$cat_id]['cat_name'].$config['category_separator'].$path;
    }
    $cat_id = $parent_id;
  } // end while
  return $path;
}



Open categories.php, locate:
Code: [Select]
$clickstream = "<span class=\"clickstream\"><a href=\"".$site_sess->url(ROOT_PATH."index.php")."\" class=\"clickstream\">".$lang['home']."</a>".$config['category_separator'].get_category_path($cat_id)."</span>";
Add after:
Code: [Select]
$page_title = $config['category_separator'].get_category_path_nohtml($cat_id); // MOD: Dynamic page title
Locate:
Code: [Select]
$site_template->register_vars(array(
  "msg" => $msg,
  "clickstream" => $clickstream
));

Change to:
Code: [Select]
$site_template->register_vars(array(
  "msg" => $msg,
  "clickstream" => $clickstream,
  "page_title" => $page_title // MOD: Dynamic page title
));



Open details.php, locate:
Code: [Select]
$clickstream = "<span class=\"clickstream\"><a href=\"".$site_sess->url(ROOT_PATH."index.php")."\" class=\"clickstream\">".$lang['home']."</a>".$config['category_separator'];
Add after:
Code: [Select]
$page_title = $config['category_separator'].$lang['home'].$config['category_separator']; // MOD: Dynamic page title
Locate:
Code: [Select]
  $clickstream .= "<a href=\"".$site_sess->url(ROOT_PATH."lightbox.php".$page_url)."\" class=\"clickstream\">".$lang['lightbox']."</a>".$config['category_separator'];
Add after:
Code: [Select]
  $page_title = $config['category_separator'].$lang['lightbox'].$config['category_separator']; // MOD: Dynamic page title
Locate:
Code: [Select]
  $clickstream .= "<a href=\"".$site_sess->url(ROOT_PATH."search.php?show_result=1".$page_url)."\" class=\"clickstream\">".$lang['search']."</a>".$config['category_separator'];
Add after:
Code: [Select]
  $page_title = $config['category_separator'].$lang['search'].$config['category_separator']; // MOD: Dynamic page title
Locate:
Code: [Select]
  $clickstream .= get_category_path($cat_id, 1).$config['category_separator'];
Add after:
Code: [Select]
  $page_title = $config['category_separator'].get_category_path_nohtml($cat_id).$config['category_separator']; // MOD: Dynamic page title
Locate:
Code: [Select]
$clickstream .= $image_name."</span>";
Add after:
Code: [Select]
$page_title .= $image_name; // MOD: Dynamic page title
Locate:
Code: [Select]
$site_template->register_vars(array(
  "msg" => $msg,
  "clickstream" => $clickstream,

CHANGE to:
Code: [Select]
$site_template->register_vars(array(
  "msg" => $msg,
  "clickstream" => $clickstream,
  "page_title" => $page_title, // MOD: Dynamic page title



Open index.php, locate:
Code: [Select]
if (!empty($template)) {
  $clickstream = "<a href=\"".$site_sess->url(ROOT_PATH."index.php")."\">".$lang['home']."</a>".$config['category_separator'].str_replace("_", " ", ucfirst($template));

Add after:
Code: [Select]
  $page_title = $config['category_separator'].str_replace("_", " ", ucfirst($template)); // MOD: Dynamic page title
Locate:
Code: [Select]
  $site_template->register_vars("clickstream", $clickstream);
CHANGE to:
Code: [Select]
  $site_template->register_vars(array(
    "clickstream" => $clickstream,
    "page_title" => $page_title // MOD: Dynamic page title
  ));

On the next line down, locate:
Code: [Select]
  $site_template->print_template($site_template->parse_template($main_template));
  include(ROOT_PATH.'includes/page_footer.php');
}

CHANGE this to:
Code: [Select]
  $site_template->print_template($site_template->parse_template($main_template));
  include(ROOT_PATH.'includes/page_footer.php');
} else { // MOD: Dynamic page title
  $page_title = $config['category_separator'].$lang['home'];
  $site_template->register_vars("page_title", $page_title);
}

Locate:
Code: [Select]
//-----------------------------------------------------
//--- Print Out ---------------------------------------
//-----------------------------------------------------
$site_template->register_vars(array(
  "msg" => $msg,
  "clickstream" => $clickstream
));

CHANGE this to:
Code: [Select]
//-----------------------------------------------------
//--- Print Out ---------------------------------------
//-----------------------------------------------------
$site_template->register_vars(array(
  "msg" => $msg,
  "clickstream" => $clickstream,
  "page_title" => $page_title // MOD: Dynamic page title
));



Open lightbox.php, locate:
Code: [Select]
//-----------------------------------------------------
//--- Clickstream -------------------------------------
//-----------------------------------------------------
$clickstream = "<span class=\"clickstream\"><a href=\"".$site_sess->url(ROOT_PATH."index.php")."\" class=\"clickstream\">".$lang['home']."</a>".$config['category_separator'].$lang['lightbox']."</span>";

Add after:
Code: [Select]
$page_title = $config['category_separator'].$lang['lightbox']; // MOD: Dynamic page title
Locate:
Code: [Select]
$site_template->register_vars(array(
  "msg" => $msg,
  "clickstream" => $clickstream,

CHANGE this to:
Code: [Select]
$site_template->register_vars(array(
  "msg" => $msg,
  "clickstream" => $clickstream,
  "page_title" => $page_title, // MOD: Dynamic page title



Open member.php, locate:
Code: [Select]
//-----------------------------------------------------
//--- Clickstream -------------------------------------
//-----------------------------------------------------
$clickstream = "<span class=\"clickstream\"><a href=\"".$site_sess->url(ROOT_PATH."index.php")."\" class=\"clickstream\">".$lang['home']."</a>".$config['category_separator'].$txt_clickstream."</span>";

Add after:
Code: [Select]
$page_title = $config['category_separator'].$txt_clickstream; // MOD: Dynamic page title
Locate:
Code: [Select]
$site_template->register_vars(array(
  "content" => $content,
  "msg" => $msg,
  "clickstream" => $clickstream,

CHANGE this to:
Code: [Select]
$site_template->register_vars(array(
  "content" => $content,
  "msg" => $msg,
  "clickstream" => $clickstream,
  "page_title" => $page_title, // MOD: Dynamic page title



Open register.php, locate:
Code: [Select]
//-----------------------------------------------------
//--- Clickstream -------------------------------------
//-----------------------------------------------------
$clickstream = "<span class=\"clickstream\"><a href=\"".$site_sess->url(ROOT_PATH."index.php")."\" class=\"clickstream\">".$lang['home']."</a>".$config['category_separator'].$lang['register']."</span>";

Add after:
Code: [Select]
$page_title = $config['category_separator'].$lang['register']; // MOD: Dynamic page title
Locate:
Code: [Select]
$site_template->register_vars(array(
  "content" => $content,
  "msg" => $msg,
  "clickstream" => $clickstream,

CHANGE this to:
Code: [Select]
$site_template->register_vars(array(
  "content" => $content,
  "msg" => $msg,
  "clickstream" => $clickstream,
  "page_title" => $page_title, // MOD: Dynamic page title



Open search.php, locate:
Code: [Select]
//-----------------------------------------------------
//--- Clickstream -------------------------------------
//-----------------------------------------------------
$clickstream = "<span class=\"clickstream\"><a href=\"".$site_sess->url(ROOT_PATH."index.php")."\" class=\"clickstream\">".$lang['home']."</a>".$config['category_separator'].$lang['search']."</span>";

CHANGE this to:
Code: [Select]
//-----------------------------------------------------
//--- Clickstream -------------------------------------
//-----------------------------------------------------
// $clickstream = "<span class=\"clickstream\"><a href=\"".$site_sess->url(ROOT_PATH."index.php")."\" class=\"clickstream\">".$lang['home']."</a>".$config['category_separator'].$lang['search']."</span>"; // Original code
// MOD: Dynamic page title BLOCK BEGIN
if (!empty($search_id['search_new_images'])) {
  if( $search_id['search_new_images'] == 1 )
    $txt_clickstream = $lang['new_images'];
  else
    $txt_clickstream = $lang['new_images_since'];
}
else {
  $txt_clickstream = $lang['search'];
}
$clickstream = "<span class=\"clickstream\"><a title=\"".$lang['home']."\" href=\"".$site_sess->url(ROOT_PATH."index.php")."\" class=\"clickstream\">".$lang['home']."</a>".$config['category_separator'].(($search_keywords) ? "<a href=\"".$site_sess->url(ROOT_PATH."search.php")."\" class=\"clickstream\">".$lang['search']."</a>".$config['category_separator'].$search_keywords : $txt_clickstream)."</span>";  // Show search keywords
$page_title = $config['category_separator'].$txt_clickstream;
// MOD: Dynamic page title BLOCK END

Locate:
Code: [Select]
$site_template->register_vars(array(
  "content" => $content,
  "msg" => $msg,
  "clickstream" => $clickstream,

CHANGE this to:
Code: [Select]
$site_template->register_vars(array(
  "content" => $content,
  "msg" => $msg,
  "clickstream" => $clickstream,
  "page_title" => $page_title, // MOD: Dynamic page title



Open top.php, locate:
Code: [Select]
//-----------------------------------------------------
//--- Clickstream -------------------------------------
//-----------------------------------------------------
$clickstream = "<span class=\"clickstream\"><a href=\"".$site_sess->url(ROOT_PATH."index.php")."\" class=\"clickstream\">".$lang['home']."</a>".$config['category_separator'];
if ($cat_id && isset($cat_cache[$cat_id])) {
  $clickstream .= get_category_path($cat_id, 1).$config['category_separator'];
}
$clickstream .= $lang['top_images']."</span>";

CHANGE this to:
Code: [Select]
//-----------------------------------------------------
//--- Clickstream -------------------------------------
//-----------------------------------------------------
$clickstream = "<span class=\"clickstream\"><a title=\"".$lang['home']."\" href=\"".$site_sess->url(ROOT_PATH."index.php")."\" class=\"clickstream\">".$lang['home']."</a>".$config['category_separator'];
$page_title = $config['category_separator']; // MOD: Dynamic page title
if ($cat_id && isset($cat_cache[$cat_id])) {
  $clickstream .= get_category_path($cat_id, 1).$config['category_separator'];
  $page_title .= get_category_path_nohtml($cat_id).$config['category_separator']; // MOD: Dynamic page title
}
$clickstream .= $lang['top_images']."</span>";
$page_title .= $lang['top_images']; // MOD: Dynamic page title

Locate:
Code: [Select]
$site_template->register_vars(array(
  "msg" => $msg,
  "clickstream" => $clickstream,

CHANGE this to:
Code: [Select]
$site_template->register_vars(array(
  "msg" => $msg,
  "clickstream" => $clickstream,
  "page_title" => $page_title, // MOD: Dynamic page title



Open templates/default/header.html, locate:
Code: [Select]
<title>{site_name}</title>
CHANGE this to:
Code: [Select]
<title>{site_name} {page_title}</title>


IF you are using version 1.7, you are finished STOP HERE




IF you are using version 1.7.1 which has a new template processing engine, you will also need to do the following steps:


Open includes/functions.php, locate:
Code: [Select]
function show_error_page($error_msg, $clickstream = "") {
  global $site_template, $site_sess, $lang, $config;
  if (empty($clickstream)) {
    $clickstream = "<a href=\"".$site_sess->url(ROOT_PATH."index.php")."\">".$lang['home']."</a>".$config['category_separator'].$lang['error'];
  }
  $site_template->register_vars(array(
    "error_msg" => $error_msg,
    "lang_error" => $lang['error'],
    "clickstream" => $clickstream,
    "random_image" => ""
  ));
  $site_template->print_template($site_template->parse_template("error"));
  exit;
}

Change this to:
Code: [Select]
function show_error_page($error_msg, $clickstream = "") {
  global $site_template, $site_sess, $lang, $config;
  if (empty($clickstream)) {
    $clickstream = "<a href=\"".$site_sess->url(ROOT_PATH."index.php")."\">".$lang['home']."</a>".$config['category_separator'].$lang['error'];
  }
  $site_template->register_vars(array(
    "error_msg" => $error_msg,
    "lang_error" => $lang['error'],
    "clickstream" => $clickstream,
    "random_image" => ""
  ));
  // MOD: Dynamic page title BLOCK BEGIN
  $header = $site_template->parse_template("header");
  $footer = $site_template->parse_template("footer");
  $site_template->register_vars(array(
    "header" => $header,
    "footer" => $footer
  ));
  unset($header);
  unset($footer);
  // MOD: Dynamic page title BLOCK END
  $site_template->print_template($site_template->parse_template("error"));
  exit;
}

Open includes/page_header.php, locate:
Code: [Select]
//-----------------------------------------------------
//--- Parse Header & Footer ---------------------------
//-----------------------------------------------------
if (isset($main_template) && $main_template) {
  $header = $site_template->parse_template("header");
  $footer = $site_template->parse_template("footer");
  $site_template->register_vars(array(
    "header" => $header,
    "footer" => $footer
  ));
  unset($header);
  unset($footer);
}

We need to move this logic to each of the top-level php files, so comment out this code by replacing it with:
Code: [Select]
/********** ORIGINAL
//-----------------------------------------------------
//--- Parse Header & Footer ---------------------------
//-----------------------------------------------------
if (isset($main_template) && $main_template) {
  $header = $site_template->parse_template("header");
  $footer = $site_template->parse_template("footer");
  $site_template->register_vars(array(
    "header" => $header,
    "footer" => $footer
  ));
  unset($header);
  unset($footer);
}
**********/

Open categories.php, details.php, index.php, lightbox.php, member.php, postcards.php, register.php, search.php, top.php and locate this line:
Code: [Select]
$site_template->print_template($site_template->parse_template($main_template));
On a new line ABOVE that line, paste this
Code: [Select]
// MOD: Dynamic page title BLOCK BEGIN
//-----------------------------------------------------
//--- Parse Header & Footer ---------------------------
//-----------------------------------------------------
if (isset($main_template) && $main_template) {
  $header = $site_template->parse_template("header");
  $footer = $site_template->parse_template("footer");
  $site_template->register_vars(array(
    "header" => $header,
    "footer" => $footer
  ));
  unset($header);
  unset($footer);
}
// MOD: Dynamic page title BLOCK END

NOTE: There are TWO places inside index.php this needs to be done. All the other PHP files listed above have only ONE.

Revision History:
* Bug fix in includes/functions.php show_error_page() for version 1.7.1
* Added support for version 1.7.1. I do not like the solution as it is a hack but it works.
* Corrected a typo in the edit needed for categories.php

29
FAQ, Tips / Pages load very slowly
« on: June 17, 2003, 04:41:48 PM »
This was really just copied from a post made by Jan and edited slightly for clarity.  :wink:
--------------------------------------------------------------------------------------

If you have a lot of images in your database, the random category image and random image are very expensive database queries because of "RAND()" in the ORDER BY clause.

Open includes/constants.php and try changing
Code: [Select]
define('SHOW_RANDOM_CAT_IMAGE', 1);
to
Code: [Select]
define('SHOW_RANDOM_CAT_IMAGE', 0);
This disables the category related random image.


If this does not help, change
Code: [Select]
define('SHOW_RANDOM_IMAGE', 1);
to
Code: [Select]
define('SHOW_RANDOM_IMAGE', 0);
This will disable the random image completely.

30
This mod replaces the text links used in the details.html template with buttons.  There are two ways to do it.

Quick And Dirty Method
1.  Put the <img> tag in your language pack's main.php in place of the "next" image text.  Be sure to put a backslash character in front of embedded double quote characters like this:
Code: [Select]
$lang['next_image'] = "<img src=\"{template_url}/images/next_image.gif\" border=\"0\">";
The drawback here is that if there is no next (or previous) image link, there will be no output and this could throw off your HTML tables.  It also doesn't work with 4images installations using multi-language support.


Clean And Elegant Method
2.  Put an HTML img tag and the next/previous links in your template details.html.

2.1 Create 4 buttons:  image_prev.gif, image_prev_off.gif, image_next_off.gif, image_next.gif  

2.1.1 Place these in your template's "images" directory if you're only supporting one language.
EXAMPLE:
Code: [Select]
templates/default/images/next_off.gif

2.1.2 For multi-language support, create different language specific versions of the 4 buttons and place them in the appropriate templates/<your template set name/images_<language> directory.

EXAMPLE:  If your 4images installation supports both English and Deutsch:
Code: [Select]
templates/default/images_deutsch/next_off.gif
templates/default/images_english/next_off.gif



2.2 Open details.php, find
Code: [Select]
// Get next and previous image
if (!empty($next_prev_cache[$next_image_id])) {
  $next_image_name = htmlspecialchars($next_prev_cache[$next_image_id]['image_name']);
  $next_image_url = $site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$next_image_id.((!empty($mode)) ? "&amp;mode=".$mode : ""));
  if (!get_file_path($next_prev_cache[$next_image_id]['image_media_file'], "media", $next_prev_cache[$next_image_id]['cat_id'], 0, 0)) {
    $next_image_file = ICON_PATH."/404.gif";
  }
  else {
    $next_image_file = get_file_path($next_prev_cache[$next_image_id]['image_media_file'], "media", $next_prev_cache[$next_image_id]['cat_id'], 0, 1);
  }
  if (!get_file_path($next_prev_cache[$next_image_id]['image_thumb_file'], "thumb", $next_prev_cache[$next_image_id]['cat_id'], 0, 0)) {
    $next_thumb_file = ICON_PATH."/".get_file_extension($next_prev_cache[$next_image_id]['image_media_file']).".gif";
  }
  else {
    $next_thumb_file = get_file_path($next_prev_cache[$next_image_id]['image_thumb_file'], "thumb", $next_prev_cache[$next_image_id]['cat_id'], 0, 1);
  }
}
else {
  $next_image_name = REPLACE_EMPTY;
  $next_image_url = REPLACE_EMPTY;
  $next_image_file = REPLACE_EMPTY;
  $next_thumb_file = REPLACE_EMPTY;
}

if (!empty($next_prev_cache[$prev_image_id])) {
  $prev_image_name = htmlspecialchars($next_prev_cache[$prev_image_id]['image_name']);
  $prev_image_url = $site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$prev_image_id.((!empty($mode)) ? "&amp;mode=".$mode : ""));
  if (!get_file_path($next_prev_cache[$prev_image_id]['image_media_file'], "media", $next_prev_cache[$prev_image_id]['cat_id'], 0, 0)) {
    $prev_image_file = ICON_PATH."/404.gif";
  }
  else {
    $prev_image_file = get_file_path($next_prev_cache[$prev_image_id]['image_media_file'], "media", $next_prev_cache[$prev_image_id]['cat_id'], 0, 1);
  }
  if (!get_file_path($next_prev_cache[$prev_image_id]['image_thumb_file'], "thumb", $next_prev_cache[$prev_image_id]['cat_id'], 0, 0)) {
    $prev_thumb_file = ICON_PATH."/".get_file_extension($next_prev_cache[$prev_image_id]['image_media_file']).".gif";
  }
  else {
    $prev_thumb_file = get_file_path($next_prev_cache[$prev_image_id]['image_thumb_file'], "thumb", $next_prev_cache[$prev_image_id]['cat_id'], 0, 1);
  }
}
else {
  $prev_image_name = REPLACE_EMPTY;
  $prev_image_url = REPLACE_EMPTY;
  $prev_image_file = REPLACE_EMPTY;
  $prev_thumb_file = REPLACE_EMPTY;
}

$site_template->register_vars(array(
  "next_image_id" => $next_image_id,
  "next_image_name" => $next_image_name,
  "next_image_url" => $next_image_url,
  "next_image_file" => $next_image_file,
  "next_thumb_file" => $next_thumb_file,
  "prev_image_id" => $prev_image_id,
  "prev_image_name" => $prev_image_name,
  "prev_image_url" => $prev_image_url,
  "prev_image_file" => $prev_image_file,
  "prev_thumb_file" => $prev_thumb_file
));
unset($next_prev_cache);


Replace with:
Code: [Select]
// Get next and previous image
if (!empty($next_prev_cache[$next_image_id])) {
  $next_image_name = htmlspecialchars($next_prev_cache[$next_image_id]['image_name']);
  $next_image_url = $site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$next_image_id.((!empty($mode)) ? "&amp;mode=".$mode : ""));
  if (!get_file_path($next_prev_cache[$next_image_id]['image_media_file'], "media", $next_prev_cache[$next_image_id]['cat_id'], 0, 0)) {
    $next_image_file = ICON_PATH."/404.gif";
  }
  else {
    $next_image_file = get_file_path($next_prev_cache[$next_image_id]['image_media_file'], "media", $next_prev_cache[$next_image_id]['cat_id'], 0, 1);
  }
  if (!get_file_path($next_prev_cache[$next_image_id]['image_thumb_file'], "thumb", $next_prev_cache[$next_image_id]['cat_id'], 0, 0)) {
    $next_thumb_file = ICON_PATH."/".get_file_extension($next_prev_cache[$next_image_id]['image_media_file']).".gif";
  }
  else {
    $next_thumb_file = get_file_path($next_prev_cache[$next_image_id]['image_thumb_file'], "thumb", $next_prev_cache[$next_image_id]['cat_id'], 0, 1);
  }
  $next_button_file = get_gallery_image("image_next.gif"); // MOD: Next-Previous Buttons
}
else {
  $next_image_name = REPLACE_EMPTY;
  $next_image_url = REPLACE_EMPTY;
  $next_image_file = REPLACE_EMPTY;
  $next_thumb_file = REPLACE_EMPTY;
  $next_button_file = get_gallery_image("image_next_off.gif"); // MOD: Next-Previous Buttons
}

if (!empty($next_prev_cache[$prev_image_id])) {
  $prev_image_name = htmlspecialchars($next_prev_cache[$prev_image_id]['image_name']);
  $prev_image_url = $site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$prev_image_id.((!empty($mode)) ? "&amp;mode=".$mode : ""));
  if (!get_file_path($next_prev_cache[$prev_image_id]['image_media_file'], "media", $next_prev_cache[$prev_image_id]['cat_id'], 0, 0)) {
    $prev_image_file = ICON_PATH."/404.gif";
  }
  else {
    $prev_image_file = get_file_path($next_prev_cache[$prev_image_id]['image_media_file'], "media", $next_prev_cache[$prev_image_id]['cat_id'], 0, 1);
  }
  if (!get_file_path($next_prev_cache[$prev_image_id]['image_thumb_file'], "thumb", $next_prev_cache[$prev_image_id]['cat_id'], 0, 0)) {
    $prev_thumb_file = ICON_PATH."/".get_file_extension($next_prev_cache[$prev_image_id]['image_media_file']).".gif";
  }
  else {
    $prev_thumb_file = get_file_path($next_prev_cache[$prev_image_id]['image_thumb_file'], "thumb", $next_prev_cache[$prev_image_id]['cat_id'], 0, 1);
  }
  $prev_button_file = get_gallery_image("image_prev.gif"); // MOD: Next-Previous Buttons
}
else {
  $prev_image_name = REPLACE_EMPTY;
  $prev_image_url = REPLACE_EMPTY;
  $prev_image_file = REPLACE_EMPTY;
  $prev_thumb_file = REPLACE_EMPTY;
  $prev_button_file = get_gallery_image("image_prev_off.gif"); // MOD: Next-Previous Buttons
}

$site_template->register_vars(array(
  "next_image_id" => $next_image_id,
  "next_image_name" => $next_image_name,
  "next_image_url" => $next_image_url,
  "next_image_file" => $next_image_file,
  "next_thumb_file" => $next_thumb_file,
  "prev_image_id" => $prev_image_id,
  "prev_image_name" => $prev_image_name,
  "prev_image_url" => $prev_image_url,
  "prev_image_file" => $prev_image_file,
  "prev_thumb_file" => $prev_thumb_file,  // MOD: Next-Previous Buttons
  "next_button" => $next_button_file,  // MOD: Next-Previous Buttons
  "prev_button" => $prev_button_file  // MOD: Next-Previous Buttons
));
unset($next_prev_cache);


2.3 Open details.html, find this:
Code: [Select]
{if next_image_name}
{lang_next_image}<br />
<b><a href="{next_image_url}">{next_image_name}</a></b>
{endif next_image_name}


Replace with:
Code: [Select]
{if next_image_url}<a href="{next_image_url}">{endif next_image_url}
<img src="{next_button}" border="0" alt="{next_image_name}">
{if next_image_url}</a>{endif next_image_url}

2.4 Do the same for the previous image link.

The php code will output either an "off" button if there is no next image or an "on" button if there is.  The button will only be clickable if it is the "on" button.

Revisions:
* Added multi-language support by calling get_gallery_image()

Pages: 1 [2] 3 4 5