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 - V@no

Pages: 1 ... 5 6 7 8 [9] 10 11 12 13 14
121
This mod will let admin logout from ACP without needed go to the main page to do so.

Step 1.
Open admin/index.php
Find:
Code: [Select]
        <td align="right"><b><a href="<?php echo $site_sess->url(ROOT_PATH); ?>" target="_blank"><?php echo $lang['goto_homepage']; ?></a>&nbsp;&nbsp;</b></TD>Insert below:
Code: [Select]
<!-- MOD ACP LOGOUT INSERT //-->
        <td align="right"><b><a href="<?php echo $site_sess->url("index.php?action=logout"); ?>" target="_parent"><?php echo $lang['logout']; ?></a>&nbsp;&nbsp;</b></TD>
<!-- MOD ACP LOGOUT END INSERT //-->


Step 2.
Open admin/admin_globals.php
Find:
Code: [Select]
require(ROOT_PATH.'lang/'.$config['language_dir'].'/admin.php');

Insert above:
Code: [Select]
/*
  MOD ACP LOGOUT
  START INSERT
*/
if ($action == "logout") {
  $site_sess->logout($user_info['user_id']);
  if (defined('ADMIN_SAFE_LOGIN') && ADMIN_SAFE_LOGIN == 1) {
    setcookie("adminon", "", 0, '/');
    unset($HTTP_COOKIE_VARS['adminon']);
  }
  Header("Location: ".$site_sess->url("index.php"));
  exit;
}
/*
  MOD ACP LOGOUT
  END INSERT
*/


If everything done correctly u should see logout link on top-right corner in ACP

122
Bug Fixes & Patches / [1.7] Cant display \\# (i.e \\2 or \\4 or \\9)
« on: June 15, 2003, 04:15:25 AM »
By default 4images replaces all \\xx (where xx is number 0-9)  with \\1
For testing purpose, try add anywhere (in any template or any variable that will be printed in a template) this: \\7 u'll see that it will be replaced by \\1
to fix that, in /includes/template.php remove marked:
Quote
 function clean_template($template) {
    $search_array = array(
      "/".$this->start."[^ \t\r\n".$this->end."]+".$this->end."/",
      "/".$this->start."if[ \t\r\n]+[^ \t\r\n".$this->end."]+".$this->end."/",
      "/".$this->start."endif[ \t\r\n]+[^ \t\r\n".$this->end."]+".$this->end."/",
      "/&#36;([0-9])/",
      "/&#92;([0-9])/"

    );
    $replace_array = array(
      "",
      "",
      "",
      '$\1',
      '\\\1'

    );

NOTE: dont forget delete comas!

123
Chit Chat / Strange behavor of this forum lately?
« on: June 13, 2003, 06:30:47 AM »
Have anyone experienced lately, that when u go through all unreaded messages and in about 5 min after refresh index page of this forum it shows u that in some forums has new messages, and when u open that forum there are no threads with new messages...or a thread shows that it has new message, but that thread u already readed...?
I was gonna say that thats might be because of many different browsers installed on my machine, but I just had same experience from another comp, that has only IE6 installed...
Strange... :?

124
Mods & Plugins (Releases & Support) / [MOD] Members Templates Select
« on: June 12, 2003, 06:27:34 AM »
This is experemental MOD, that will let members select templates from list of avalable.
The reason it's "experemental" because some code from global.php has to move into /includes/sessions.php. With some tests I had on my site I didnt see any side effects though.

Another maybe usefull feature this mod will add into 4images is "dropdown" option in db_field_definitions.php


----- Changes in files --------

/global.php
/includes/sessions.php
/includes/functions.php
/includes/db_field_definitions.php
/member.php
/lang/<yourlanguage>/main.php
/admin/admin_functions.php
/templates/<yourtemplate>/member_editprofile.html


----- Installation ---------

Step 1.
Open /global.php
Find and delete (or comment):
Code: [Select]
define('TEMPLATE_PATH', ROOT_PATH.TEMPLATE_DIR."/".$config['template_dir']);
define('ICON_PATH', ROOT_PATH.TEMPLATE_DIR."/".$config['template_dir']."/icons");

Step 1.2
Find:
Code: [Select]
//-----------------------------------------------------
//--- Templates ---------------------------------------
//-----------------------------------------------------
include(ROOT_PATH.'includes/template.php');
$site_template = new Template(TEMPLATE_PATH);
Replace with:
Code: [Select]
//-----------------------------------------------------
//--- Templates ---------------------------------------
//-----------------------------------------------------
$dir = opendir(ROOT_PATH.TEMPLATE_DIR);
$templates_cache = array();
while($dir_cache = readdir($dir))
{
  if (@is_dir(ROOT_PATH.TEMPLATE_DIR."/".$dir_cache) && $dir_cache != "." && $dir_cache != "..")
  {
    $templates_cache[] = $dir_cache;
  }
}
closedir($dir);

Step 2.
Open /includes/sessions.php
Find:
Code: [Select]
if (defined("GET_USER_ONLINE") && ($config['display_whosonline'] == 1 || $user_info['user_level'] == ADMIN)) {Add before:
Code: [Select]
//-----------------------------------------------------
//--- Templates ---------------------------------------
//-----------------------------------------------------
$user_info['user_template'] = (isset($HTTP_GET_VARS['user_template'])) ? $HTTP_GET_VARS['user_template'] : ((isset($HTTP_POST_VARS['user_template'])) ? $HTTP_POST_VARS['user_template'] : $user_info['user_template']);
$user_template = ($user_info['user_template']) ? ((in_array($user_info['user_template'], $templates_cache)) ? $user_info['user_template'] : $config['template_dir']) : $config['template_dir'];
define('TEMPLATE_PATH', ROOT_PATH.TEMPLATE_DIR."/".$user_template);
define('ICON_PATH', ROOT_PATH.TEMPLATE_DIR."/".$user_template."/icons");
include(ROOT_PATH.'includes/template.php');
$site_template = new Template(TEMPLATE_PATH);
//--- End Templates -----------------------------------


Step 3.
Open /includes/functions.php
Add at the end, just before closing ?>
Code: [Select]
//--- DB Field Dropdown ---
function get_db_fields_dropdown($key, $val, $value) {
  $dropdown = "<SELECT name=\"".$key."\" onkeypress=\"if(window.event.keyCode==13)this.form.submit();\" class=\"select\">";
$i = 0;
foreach ($val[3] as $item) {
  $what = ($val[4]) ? $item : $i;
$dropdown .= "<option value=\"".$what."\"".(($value == $what) ? " selected" : "").">".$item."</option>\n";
$i++;
}
$dropdown .= "</select>\n";
  return $dropdown;
}
//--- End DB Field Dropdown ---


Step 4.
Open /includes/db_field_definitions.php
Add at the end, just before closing ?>
Code: [Select]
$additional_user_fields['user_template'] = array($lang['user_template'], "dropdown", 0, $templates_cache, 1);

Step 5.
Open /members.php
v1.7 / v1.7.1[/color]
Find:
Code: [Select]
      else{
        $value = (isset($HTTP_POST_VARS[$key])) ? htmlspecialchars(trim($HTTP_POST_VARS[$key])) : $user_info[$key];
Replace with:
Code: [Select]
      elseif ($val[1] == "dropdown") {
        $value = (isset($HTTP_POST_VARS[$key])) ? $HTTP_POST_VARS[$key] : $user_info[$key];
      $additional_field_array[$key.'_dropdown'] = get_db_fields_dropdown($key, $val, $value);
      }else{
        $value = (isset($HTTP_POST_VARS[$key])) ? htmlspecialchars(trim($HTTP_POST_VARS[$key])) : $user_info[$key];

v1.7.2
Find:
Code: [Select]
      else {
        $value = (isset($HTTP_POST_VARS[$key])) ? format_text(trim($HTTP_POST_VARS[$key]), 2) : $user_info[$key];
Replace with:
Code: [Select]
      elseif ($val[1] == "dropdown") {
        $value = (isset($HTTP_POST_VARS[$key])) ? format_text(trim($HTTP_POST_VARS[$key]), 2) : $user_info[$key];
      $additional_field_array[$key.'_dropdown'] = get_db_fields_dropdown($key, $val, $value);
      }else{
        $value = (isset($HTTP_POST_VARS[$key])) ? format_text(trim($HTTP_POST_VARS[$key]), 2) : $user_info[$key];


Step 6.
Open /lang/<yourlanguage>/main.php
Add at the end, just before closing ?>
Code: [Select]
//--- User templates --------
$lang['user_template'] = "Select style";
//--- End User templates ----


Step 7.
Open /admin/admin_functions.php
Find:
Code: [Select]
      case "text":Add before:
Code: [Select]
  case "dropdown":
show_dropdown_row($val[0], $field_name, $value, $val[3], $val[4]);
break;

Step 7.2.
Add at the end, just before closing ?>
Code: [Select]
function show_dropdown_row($title, $name, $value = 0, $array = array(), $value_show = 0){
$i = 0;
echo "<tr width=\"50%\"class=\"".get_row_bg()."\" valign='top'>\n<td><p class=\"rowtitle\">".$title."</p></td>\n";
echo "<td width=\"50%\" valign=\"middle\">\n<SELECT name=\"".$name."\" onkeypress=\"if(window.event.keyCode==13){this.form.submit();}\"\">";
foreach ($array as $key) {
  $what = ($value_show) ? $key : $i;
echo "<option value=\"".$what."\"".(($value == $what) ? " selected" : "").">".$key."</option>\n";
$i++;
}
echo "</select>\n</td>\n</tr>\n";
}


Step 8.
Open /templates/<yourtemplate>/member_editprofile.html
Add this:
Code: [Select]
          <tr>
            <td class="row1"><b>{lang_user_template}:</b></td>
            <td class="row1">
              {user_template_dropdown}
            </td>
</tr>
*Repeat Step 8. for each template, or your members wont be able change templates if chose the one without that change.


Step 9.
Download this installer.
Unpack it and upload user_template_install.php file into 4images root dir.
Install it http://yoursite.com/4images/user_template_install.php


If u did everything correctly, in control panel (not ACP) u should see new dropdown.
The script automaticaly scans /templates/ folder and if it finds any folders, it add them as selection, so be carefull, make sure that each of your template sets has all needed templates.

125
Reqested several times mod, that will let visitors search between date they select. (uses dropdown options for day, month, year)


-------- Files to edit ------------
/search.php
/templates/<yourtemplate>/search_form.html
/lang/<yourlanguage>/main.php



-------- Installation -------------

Step 1.
Open /search.php
Find:
Code: [Select]
include(ROOT_PATH.'includes/search_utils.php');Add after:
Code: [Select]
$year_default = 2000;
$year_now = date("Y", time());
$year_start = (isset($HTTP_POST_VARS['year_start']) ) ? intval($HTTP_POST_VARS['year_start']) : ((isset($HTTP_GET_VARS['year_start'])) ? intval($HTTP_GET_VARS['year_start']) : $year_default);
$year_end = (isset($HTTP_POST_VARS['year_end']) ) ? intval($HTTP_POST_VARS['year_end']) : ((isset($HTTP_GET_VARS['year_end'])) ? intval($HTTP_GET_VARS['year_end']) : $year_now);
$month_start = (isset($HTTP_POST_VARS['month_start']) ) ? intval($HTTP_POST_VARS['month_start']) : ((isset($HTTP_GET_VARS['month_start'])) ? intval($HTTP_GET_VARS['month_start']) : 1);
$month_end = (isset($HTTP_POST_VARS['month_end']) ) ? intval($HTTP_POST_VARS['month_end']) : ((isset($HTTP_GET_VARS['month_end'])) ? intval($HTTP_GET_VARS['month_end']) : date("n", time()));
$day_start = (isset($HTTP_POST_VARS['day_start']) ) ? intval($HTTP_POST_VARS['day_start']) : ((isset($HTTP_GET_VARS['day_start'])) ? intval($HTTP_GET_VARS['day_start']) : 1);
$day_end = (isset($HTTP_POST_VARS['day_end']) ) ? intval($HTTP_POST_VARS['day_end']) : ((isset($HTTP_GET_VARS['day_end'])) ? intval($HTTP_GET_VARS['day_end']) : date("j", time()));
$date_start = mktime(0,0,0,$month_start,$day_start,$year_start);
$date_end = mktime(23,59,59,$month_end,$day_end,$year_end);

Step 1.2.
Find:
Code: [Select]
     $sql = "SELECT m.image_id
              FROM ".WORDLIST_TABLE." w, ".WORDMATCH_TABLE." m
              WHERE w.word_text LIKE '".addslashes(str_replace("*", "%", $split_words[$i]))."'
              AND m.word_id = w.word_id
              $match_field_sql";
Replace with:
Code: [Select]
     $sql = "SELECT m.image_id, i.image_date
              FROM ".WORDLIST_TABLE." w, ".WORDMATCH_TABLE." m
              LEFT JOIN ".IMAGES_TABLE." i ON (m.image_id = i.image_id)
              WHERE w.word_text LIKE '".addslashes(str_replace("*", "%", $split_words[$i]))."'
              AND m.word_id = w.word_id AND i.image_date >= ".$date_start." AND i.image_date <= ".$date_end."
              $match_field_sql";

Step 1.3.
Find:
Code: [Select]
 $site_template->register_vars(array(
    "search_keywords" => htmlspecialchars(stripslashes($org_search_keywords)),
Replace with:
Code: [Select]
 function date_select($start, $end, $now, $text_array = ""){
    $options = "";
    $start = ($start) ? $start : $start + 1;
    for ($i = $start; $i <= $end; $i++){
      $select = ($i == $now) ? " selected" : "";
      $options .= "<option value=\"".$i."\"".$select.">".(($text_array) ? $text_array[$i - 1] : $i)."</option>";
    }
    return $options;
  }

  $site_template->register_vars(array(
    "search_keywords" => stripslashes($org_search_keywords),
    "year_start" => date_select($year_default, $year_now, $year_start),
    "year_end" => date_select($year_default, $year_now, $year_end),
    "month_start" => date_select(1, 12, $month_start, $lang['month_array']),
    "month_end" => date_select(1, 12, $month_end, $lang['month_array']),
    "day_start" => date_select(1, 31, $day_start),
    "day_end" => date_select(1, 31, $day_end),
    "lang_search_date" => $lang['search_date'],
    "lang_search_date_start" => $lang['search_start'],
    "lang_search_date_end" => $lang['search_end'],


Step 2.
Open /templates/<yourtemplate>/search_form.html
Add this:
Code: [Select]
<tr class="row2">
<td><b>{lang_search_date}:</b></td>
<td>
{lang_search_date_start}<br />
<select name="day_start" class="select">{day_start}</select>
<select name="month_start" class="select">{month_start}</select>
<select name="year_start" class="select">{year_start}</select><br /><br />
{lang_search_date_end}<br />
<select name="day_end" class="select">{day_end}</select>
<select name="month_end" class="select">{month_end}</select>
<select name="year_end" class="select">{year_end}</select>
</td>
</tr>


Step 3.
Open /lang/<yourlanguage>/main.php
Add at the end, just before closing ?>
Code: [Select]
$lang['month_array'] = array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
$lang['search_date'] = "Search between";
$lang['search_start'] = "Start";
$lang['search_end'] = "End";


NOTE:
- If u dont want display name for each month instead of number (1 to 12), then just comment $lang['month_array'] in Step 3.
- U can change minimum year in dropdown: $year_default = 2000; from Step 1.

P.S. I know, design and text - sux, and would really appretiate it if somebody help me with that ;) :D

126
Mods & Plugins (Releases & Support) / [MOD] Votes saved in DB
« on: June 08, 2003, 06:19:12 PM »
This mod will save each members vote in the database. That means, that members now can only vote ONCE for the same image, even if they clear cookies.
I made two versions of this mod:

A - will uses new table in the database "4images_voted", that will stores new entry for each vote for each image and user. That would allow with some extra code display how many members voted for an image, who and what was the vote. And backwards: how many images the user voted, witch images and what was the vote. The disadvantage of this version is that database will grew as fast as many votes members do. :(

B - will uses existing users table "4images_users" with new field and store image ids and vote rating as simple text. Disadvantage of this version - statistics other then which images a member voted for would not be avalable (almost not possible).
------------------------------


Version A

Just 3 files to edit:
/includes/page_header.php
/includes/functions.php
/includes/constants.php


------ Installation ------

Step 1
Open /includes/page_header.php
Find:
Code: [Select]
  $rating = intval($HTTP_POST_VARS['rating']);Add after:
Code: [Select]
  if ($user_info['user_level'] != GUEST) {
    $sql = "SELECT user_id, image_id, vote
            FROM ".VOTED_TABLE."
            WHERE image_id = ".$id." AND user_id = ".$user_info['user_id'];
    $rated = $site_db->query_firstrow($sql);
    $rating = ($rated['vote']) ? $rated['vote'] : $rating;
  }else{
    $rated = FALSE;
  }

Step 1.2
Find:
Code: [Select]
if (!in_array($id, $split_list) && !in_array($id, $cookie_rated)) {Replace with:
Code: [Select]
if (!in_array($id, $split_list) && !in_array($id, $cookie_rated) && !$rated) {

Step 2
Open /includes/functions.php
Find:
Code: [Select]
function update_image_rating($image_id, $rating) {
  global $site_db;
Replace with:
Code: [Select]
function update_image_rating($image_id, $rating) {
  global $site_db, $user_info;

Step 2.2
Find next:
Code: [Select]
$sql = "UPDATE ".IMAGES_TABLE."
            SET image_votes = ($old_votes + 1), image_rating = '$new_rating'
Add before:
Code: [Select]
   if ($user_info['user_id'] != GUEST) {
        $sql = "INSERT INTO ".VOTED_TABLE."
                (user_id, image_id, vote)
                VALUES
                (".$user_info['user_id'].", ".$image_id.", ".$rating.")";
        $site_db->query($sql);
    }


Step 3
Open /includes/constants.php
Add just before closing ?>
Code: [Select]
define('VOTED_TABLE', $table_prefix.'voted');

Step 4
Download this installer.
Unpack it and upload to your 4images root.
Start it http://yoursite/4images/voted_b_install.php



Version B

Just 3 files to edit:
/includes/page_header.php
/includes/functions.php
/includes/db_field_definitions.php


------ Installation ------

Step 1
Open /includes/page_header.php
Find:
Code: [Select]
  $rating = intval($HTTP_POST_VARS['rating']);Add after:
Code: [Select]
  if ($user_info['user_level'] != GUEST) {
    $voted_array = array();
    if (!empty($user_info['user_voted'])) {
      $voted_array = explode(" ", $user_info['user_voted']);
    }
    $list_rated = array();
    foreach ($voted_array as $key) {
      $split = explode(",", $key);
      $list_rated[] = $split[0];
      if ($id == $split[0]) {
        $rating = $split[1];
      }
    }
    $rated = in_array($id, $list_rated);
  }else{
    $rated = FALSE;
  }

Step 1.2
Find:
Code: [Select]
if (!in_array($id, $split_list) && !in_array($id, $cookie_rated)) {Replace with:
Code: [Select]
if (!in_array($id, $split_list) && !in_array($id, $cookie_rated) && !$rated) {

Step 2
Open /includes/functions.php
Find:
Code: [Select]
function update_image_rating($image_id, $rating) {
  global $site_db;
Replace with:
Code: [Select]
function update_image_rating($image_id, $rating) {
  global $site_db, $user_info;

Step 2.2
Find next:
Code: [Select]
    $sql = "UPDATE ".IMAGES_TABLE."
            SET image_votes = ($old_votes + 1), image_rating = '$new_rating'
Add before:
Code: [Select]
   if ($user_info['user_id'] != GUEST) {
        $user_info['user_voted'] = $user_info['user_voted']." ".$image_id.",".$rating;
        $sql = "UPDATE ".USERS_TABLE."
                SET user_voted = '".trim($user_info['user_voted'])."'
                WHERE user_id = ".$user_info['user_id'];
        $site_db->query($sql);
    }

Step 3
Open /includes/db_field_definitions.php
Add just before closing ?>
Code: [Select]
$additional_user_fields['user_voted'] = array("User votes", "text", 0);
Step 4
Download this installer.
Unpack it and upload to your 4images root.
Start it http://yoursite/4images/voted_b_install.php



Version history

1.0- Original release

127
This little addon will make category link in the clickstream (on details.php page) pointing on the page where the image is.
Lets try explain one more time with an example ;)
Lets say u click on an image from "random image", then, u can see in the clickstream path of that image ( Home / cat name / subcat name / image name )
then, u click on category name in the clickstream ( subcat name ). It will open categories.php page on first page, but to find where was that image u might need go next page, then maybe next and next and next... I found this little bit anoying, so this mod will help with that "problem" - it will open categories.php page on page where the image is ( categories.php?cat_id=xx&page=xx )


Step 1.
Open /details.php
Find:
Code: [Select]
unset($image_id_cache);Add before:
Code: [Select]
$cur_page = ceil((array_search($image_id, $image_id_cache) + 1) / $perpage);
Step 1.2.
Find:
Code: [Select]
$clickstream .= get_category_path($cat_id, 1).$config['category_separator'];Replace with:
Code: [Select]
$clickstream .= get_category_path($cat_id, 1, $cur_page).$config['category_separator'];
Step 2.
Open /includes/functions.php
Find:
Code: [Select]
function get_category_path($cat_id = 0, $detail_path = 0) {Replace with:
Code: [Select]
function get_category_path($cat_id = 0, $detail_path = 0, $page = 0) {
Step 2.2a original
I leave this "version" of Step 2.2a so u have a chose ;)
Personaly I'd suggest use Step 2.2b by effemmess

Find:
Code: [Select]
       if (preg_match("/".URL_PAGE."=([0-9]+)/", $url, $regs)) {
         if (!empty($regs[1]) && $regs[1] != 1) {
           $cat_url .= "&amp;".URL_PAGE."=".$regs[1];
         }
       }
Replace with:
Code: [Select]
      if ($page > 1) {
         $cat_url .= "&amp;".URL_PAGE."=".$page;
       }else{
       if (preg_match("/".URL_PAGE."=([0-9]+)/", $url, $regs)) {
         if (!empty($regs[1]) && $regs[1] != 1) {
           $cat_url .= "&amp;".URL_PAGE."=".$regs[1];
         }
       }
     }

Step 2.2b by effemmess
Find:
Code: [Select]
 return $path;Add before:
Code: [Select]
 if ($page > 1){
    $path = $path.$config['category_separator']."<a href=\"".$site_sess->url($cat_url."&amp;".URL_PAGE."=".$page)."\" class=\"clickstream\">page ".$page."</a>";
  }

Demo:
http://gallery.vano.org/5686
(click at category name in top-left corner)

128
This little extra feature will let u use those kind of tags in templates:
{ifno tagname1}
 {tagname2}
 or page content
{endifno tagname1}

What does it mean?
It will display whatever is registered in {tagname2} if {tagname1} is empty or set as 0
the format is the same as {if tagname}{tagname} or whatever else{endif tagname} but works opposite

For 4images v1.7

Open /includes/template.php
Find:
Code: [Select]
 function replace_if($template) {
    foreach ($this->key_cache as $key => $val) {
      if (empty($this->val_cache[$key]) || $this->val_cache[$key] == REPLACE_EMPTY) {
        $reg = "/".$this->start."if[ \t\r\n]+".$key.$this->end."(.*)".$this->start."endif[ \t\r\n]+".$key.$this->end."/siU";
        $template = preg_replace($reg, "", $template);
      }
    }
    return $template;
  }
Add after:
Code: [Select]
 function replace_ifno($template) {
    foreach ($this->key_cache as $key => $val) {
      if (!empty($this->val_cache[$key]) && $this->val_cache[$key] != REPLACE_EMPTY) {
        $reg = "/".$this->start."ifno[ \t\r\n]+".$key.$this->end."(.*)".$this->start."endifno[ \t\r\n]+".$key.$this->end."/siU";
        $template = preg_replace($reg, "", $template);
      }
    }
    return $template;
  }


Find:
Code: [Select]
   $template = $this->replace_if ($template);Add after:
Code: [Select]
   $template = $this->replace_ifno ($template);
Find:
Code: [Select]
     "/".$this->start."endif[ \t\r\n]+[^ \t\r\n".$this->end."]+".$this->end."/",Add after:
Code: [Select]
     "/".$this->start."ifno[ \t\r\n]+[^ \t\r\n".$this->end."]+".$this->end."/",
      "/".$this->start."endifno[ \t\r\n]+[^ \t\r\n".$this->end."]+".$this->end."/",

Find:
Code: [Select]
   $replace_array = array(Add after, those two lines:
Code: [Select]
     "",
      "",


For 4images v1.7.1
Please apply [1.7.1] Conditional tags inside other conditional tags + {ifno ...}{endifno ...} bug fix, which includes {ifno..} feature:

129
Mods & Plugins (Releases & Support) / [MOD] Search Statistics v1.2
« on: June 04, 2003, 08:49:17 AM »
This MOD was originaly created by www.girls-on-bikes.com ( http://4homepages.de/forum/viewforum.php?f=11 )
I just adopted it as a "public" MOD
[MOD] Search Statistics v1.5 | Works with 1.7.2 - 1.7.4 thanks to ivan

------ Overview -----------
This MOD will log all searched words and phrases and count each unique word/phrase. When searched with just one word, it will be logged/count as "word" and when searched with two or more words it will be logged and count as a "phrase" and will not log/count each separate word from that phrase.

------ News ----------------
v1.2.
- Added count of who was searching word/phrase (guest, user or admin) (edit search_stats.php and set $show_more to 1 or 0)
- Date display now can be anabled/disabled (edit search_stats.php and set $show_date to 1 or 0)
v1.1.
- Added log last search date of word/phrase


All neccessery files and instruction u can find in this file:
http://gallery.vano.org/file30dl (see attachment below)

demo:
http://gallery.vano.org/search
(there is a link "Search Statistics" at the left-bottom)

130
Chit Chat / Just a spider or...?
« on: May 30, 2003, 12:30:10 PM »
Yesterday I noticed that one "guest" was always shows as "online", "active" whenever I logged in into ACP. But the "guest" wasnt just sittiong on one page, when ever I refresh ACP screen he was on different location...that was goin on for atleast 20 hours now...
And there is another interesting part is...my Phplogger doesnt log it! and I cant find the IP in Apache access log...
so, I'm wondering is that some kind of a "web spider" or something like that?
I put him in my BAN list, he dissapier, but as soon as I removed his IP, he showed up almost immediatly...
I have traced the IP, could find some info of the location, domain and blah - blah, but now what? Maybe somebody knows anything about such a thing?
here is the IP:
65.214.36.154

131
When u go to http://yoursite.com/4images/member.php?action=uploadform it will show u list of categories avalable for upload.
Even if u select a category, it wont let u upload and show u error message "Please select a category".
To fix that, open /templates/<yourtemplate>/member_uploadform.html
Find:
Code: [Select]
<input type="hidden" name="cat_id" value="{cat_id}" />Replace with:
Code: [Select]
{if cat_id}<input type="hidden" name="cat_id" value="{cat_id}" />{endif cat_id}

132
Discussion & Troubleshooting / little bug
« on: May 26, 2003, 06:30:03 AM »
Just discovered a little bug:
when u open details.php with mode=search and then vote for the image, it will open details.php without mode=search, so u will lose the images u found, unless u hit "back" browsers button.
to fix this, find in /includes/page_header.php:
Code: [Select]
 "self" => $site_sess->url($self_url),add after:
Code: [Select]
 "self_mode" => $site_sess->url($self_url.((!empty($mode)) ? (preg_match("/\?/", $self_url) ? "&" : "?")."mode=".$mode : "")),

then in /templates/<yourtemplate>/rate_form.html replace {self} with {self_mode}

133
Many people asked me post the code that will disable "rate form" after visitor voted. (no more error message "Sorry, u have voted ones recently") u can try it youself here
what it does:
1. could be anable/disable to show what was your vote for each picture. (it will show your vote number in the dropdown, but it will be disabled and u wont be able vote again for that image)
2. could be anabled/disabled ability vote for one image by different members who share one computer. (right now, if u and your brother use the same computer, and u visit 4images sites with different login names, after vote either of u, cookies set that nobody else can vote for the same image from same computer)
3. rate form generates automaticaly based on MAX_RATING set in /includes/constants.php

Open /includes/page_header.php
Find:
Code: [Select]
//-----------------------------------------------------
//--- Save Rating -------------------------------------
//-----------------------------------------------------
if ($action == "rateimage" && $id) {
  $rating = intval($HTTP_POST_VARS['rating']);
  $cookie_name = (defined("COOKIE_NAME")) ? COOKIE_NAME : "4images_";
  $cookie_rated = isset($HTTP_COOKIE_VARS[$cookie_name.'rated']) ? unserialize(stripslashes($HTTP_COOKIE_VARS[$cookie_name.'rated'])) : array();
  if ($rating && $rating <= MAX_RATING && $id) {
    if (!isset($session_info['rated_imgs'])) {
      $session_info['rated_imgs'] = $site_sess->get_session_var("rated_imgs");
    }   
    $split_list = array();
    if (!empty($session_info['rated_imgs'])) {
      $split_list = explode(" ", $session_info['rated_imgs']);
    }
    if (!in_array($id, $split_list) && !in_array($id, $cookie_rated)) {
      $session_info['rated_imgs'] .= " ".$id;
      $session_info['rated_imgs'] = trim($session_info['rated_imgs']);
      $site_sess->set_session_var("rated_imgs", $session_info['rated_imgs']);
      $cookie_rated[] = $id;
      $cookie_expire = time() + 60 * 60 * 24 * 4;
      setcookie($cookie_name.'rated', serialize($cookie_rated), $cookie_expire, COOKIE_PATH, COOKIE_DOMAIN, COOKIE_SECURE);
      update_image_rating($id, $rating);
      $msg = $lang['voting_success'];
    }
    else {
      $msg = $lang['already_voted'];
    }
  }
  else {
    $msg = $lang['voting_error'];
  }
}

//-----------------------------------------------------
//--- Parse Header & Footer ---------------------------
//-----------------------------------------------------
Replace with:
Code: [Select]
//-----------------------------------------------------
//--- Save Rating -------------------------------------
//-----------------------------------------------------

//----- Settings ------------

//change to $rate_suffix = ""; if u dont want remmber votes for different users on same computer
$rate_suffix = "_".$user_info['user_id'];

//--- End Settings ----------

if ($action == "rateimage" && $id) {
  $rating = intval($HTTP_POST_VARS['rating']);
  $cookie_name = (defined("COOKIE_NAME")) ? COOKIE_NAME : "4images_";
  $cookie_rated_array = isset($HTTP_COOKIE_VARS[$cookie_name.'rated'.$rate_suffix]) ? unserialize(stripslashes($HTTP_COOKIE_VARS[$cookie_name.'rated'.$rate_suffix])) : array();
  if ($rating && $rating <= MAX_RATING && $id) {
    if (!isset($session_info['rated_imgs'.$rate_suffix])) {
      $session_info['rated_imgs'.$rate_suffix] = $site_sess->get_session_var("rated_imgs".$rate_suffix);
    }
    $split_list_array = array();
    if (!empty($session_info['rated_imgs'.$rate_suffix])) {
      $split_list_array = explode(" ", $session_info['rated_imgs'.$rate_suffix]);
    }
    $split_list = array();
    foreach ($split_list_array as $key) {
      $key = explode(",", $key);
      $split_list[] = $key[0];
    }
    $cookie_rated = array();
    foreach ($cookie_rated_array as $key) {
      $key = explode(",", $key);
      $cookie_rated[] = $key[0];
    }
    if (!in_array($id, $split_list) && !in_array($id, $cookie_rated)) {
      $session_info['rated_imgs'.$rate_suffix] .= " ".$id.",".$rating;
      $session_info['rated_imgs'.$rate_suffix] = trim($session_info['rated_imgs'.$rate_suffix]);
      $site_sess->set_session_var("rated_imgs".$rate_suffix, $session_info['rated_imgs'.$rate_suffix]);
      $cookie_rated_array[] = $id.",".$rating;
      $cookie_expire = time() + 60 * 60 * 24 * 4;
      setcookie($cookie_name.'rated'.$rate_suffix, serialize($cookie_rated_array), $cookie_expire, COOKIE_PATH, COOKIE_DOMAIN, COOKIE_SECURE);
      update_image_rating($id, $rating);
      $msg = $lang['voting_success'];
    }
    else {
      $msg = $lang['already_voted'];
    }
  }
  else {
    $msg = $lang['voting_error'];
  }
}

//-----------------------------------------------------
//--- Parse Header & Footer ---------------------------
//-----------------------------------------------------


Open /includes/functions.php
Find:
Code: [Select]
    $site_template->register_vars("rate", $lang['rate']);
    $rate_form = $site_template->parse_template("rate_form");
  }
  $site_template->register_vars("rate_form", $rate_form);
  return true;
}
Replace with:
Code: [Select]
    $rate_form = rate_form($image_row['image_id'], $rate_suffix, $rating);
  }
  $site_template->register_vars("rate_form", $rate_form);

  return true;
}

function rate_form($id, $rate_suffix = "", $rating = ""){
 global $site_template, $session_info, $lang, $site_sess, $HTTP_COOKIE_VARS, $rate_suffix;

  //----- Settings ------------

  //change to $rate_show = 0; if u dont want to show what was your vote for an image
  $rate_show = 1;

  //--- End Settings ----------

  $cookie_name = (defined("COOKIE_NAME")) ? COOKIE_NAME : "4images_";
  $cookie_rated_array = isset($HTTP_COOKIE_VARS[$cookie_name.'rated'.$rate_suffix]) ? unserialize(stripslashes($HTTP_COOKIE_VARS[$cookie_name.'rated'.$rate_suffix])) : array();
  $split_list_array = array();
  if (!empty($session_info['rated_imgs'.$rate_suffix])) {
    $split_list_array = explode(" ", $session_info['rated_imgs'.$rate_suffix]);
  }
  $cookie_rated = array();
  foreach ($cookie_rated_array as $key) {
    $split = explode(",", $key);
    $cookie_rated[] = $split[0];
    if ($id == $split[0]) {
      $rating = $split[1];
    }
  }
  $split_list = array();
  foreach ($split_list_array as $key) {
    $split = explode(",", $key);
    $split_list[] = $split[0];
    if ($id == $split[0]) {
      $rating = $split[1];
    }
  }
  $no_rateform = (in_array($id, $split_list) || in_array($id, $cookie_rated)) ? "disabled" : 0;
  $rate_options = "<option value=\"\">--</option>\n";
  for ($i = MAX_RATING; $i; $i--){
    $rate_options .= "<option value=\"".$i."\"".(($i == $rating && $rate_show) ? "selected" : "").">".$i."</option>\n";
  }
  $site_template->register_vars(array(
          "rate" => ($no_rateform && !(check_permission("auth_vote", $image_row['cat_id']) && $no_rateform)) ?  "rated" : $lang['rate'],
          "rate_options" => $rate_options,
          "rate_button" => ($no_rateform) ? $no_rateform : ""

    ));
  $rate_form = $site_template->parse_template("rate_form");
  return $rate_form;
}

*In each changed parts u'll find //----- Settings ---------


Open /templates/<yourtemplate>/rate_form.html
replace the code with this:
Code: [Select]
<table border="0" cellspacing="0" cellpadding="1">
  <form method="post" action="{self}">
    <tr>
      <td class="head1">
        <table border="0" cellspacing="0" cellpadding="3" class="row1">
          <tr>
            <td valign="bottom">
              <select name="rating" class="select" {rate_button}>
                {rate_options}
              </select>
            </td>
            <td>
              <input type="hidden" name="action" value="rateimage" />
              <input type="hidden" name="id" value="{image_id}" />
              <input type="submit" value="{rate}" class="button" name="submit" {rate_button} />
            </td>
          </tr>
        </table>
      </td>
    </tr>
  </form>
</table>

134
Mods & Plugins (Releases & Support) / [MOD] Paging for comments
« on: May 23, 2003, 03:07:58 PM »
This MOD will add Paging to comments, that means it will display only XX number of comments per page, just like in categories.php ( u probably have seen this already: http://gallery.vano.org/7570 )
Also, this MOD fix some problem, when u have extra fields in USERS_TABLE in the database (for example if u added new fields for Yahoo ID, signature) and want display it in comments too (by default u can not show value of those fields in comments. Reference).


------------ Changes in following files: -------------
/details.php
/lang/<yourlanguage>/main.php
/templates/<yourtemplate>/details.html


------------ New template: --------------
/template/<yourtemplate>/commentsperpage_dropdown_form.html


-----------| Installation |-------------

Step 1.
Open /details.php
Find:
Code: [Select]
if ($image_allow_comments == 1) {
Insert below:
Code: [Select]
  if (isset($HTTP_POST_VARS['commentsetperpage']) || isset($HTTP_GET_VARS['commentsetperpage'])) {
    $commentsetperpage = (intval($HTTP_POST_VARS['commentsetperpage']) ) ? intval($HTTP_POST_VARS['commentsetperpage']) : intval($HTTP_GET_VARS['commentsetperpage']);
    if ($commentsetperpage) {
      $site_sess->set_session_var("commentperpage", $commentsetperpage);
      $session_info['commentperpage'] = $commentsetperpage;
    }
  }

  if (isset($session_info['commentperpage'])) {
    $commentperpage = $session_info['commentperpage'];
  }
  else {
    $commentperpage = 5;
  }
  $commentsperpage_dropdown = "\n<select name=\"commentsetperpage\" onchange=\"if (this.options[this.selectedIndex].value != 0){ forms['commentsperpage'].submit() }\" class=\"select\">\n";
  for($i = 1; $i <= 15; $i++) {
    $setvalue = 1 * $i;
    $commentsperpage_dropdown .= "<option value=\"".$setvalue."\"";
      if ($setvalue == $commentperpage) {
      $commentsperpage_dropdown .= " selected=\"selected\"";
    }
    $commentsperpage_dropdown .= ">";
    $commentsperpage_dropdown .= $setvalue;
    $commentsperpage_dropdown .= "</option>\n";
  }
  $commentsperpage_dropdown .= "</select>\n";

  $site_template->register_vars("commentsperpage_dropdown", $commentsperpage_dropdown);
  $commentsperpage_dropdown_form = $site_template->parse_template("commentsperpage_dropdown_form");
  $site_template->register_vars("commentsperpage_dropdown_form", $commentsperpage_dropdown_form);

  $sql = "SELECT COUNT(image_id) AS comments
          FROM ".COMMENTS_TABLE."
          WHERE image_id = $image_id";
  $result = $site_db->query_firstrow($sql);
  $site_db->free_result();
  $num_comments = $result['comments'];
  if ($action == "postcomment") {
    $page = ceil($num_comments / $commentperpage);
  }
  $num_rows_all = (isset($num_comments)) ? $num_comments : 0;
  $link_arg = $site_sess->url(ROOT_PATH."details.php?image_id=$image_id");
  include(ROOT_PATH.'includes/paging.php');
  $getpaging = new Paging($page, $commentperpage, $num_rows_all, $link_arg, $lang['comment_stats'], "comments");
  $offset = $getpaging->get_offset();
  $site_template->register_vars(array(
    "paging" => $getpaging->get_paging(),
    "paging_stats" => ($num_comments) ? $getpaging->get_paging_stats() : ""
  ));
  $additional_sql = "";
  if (!empty($additional_user_fields)) {
    $table_fields = $site_db->get_table_fields(USERS_TABLE);
    foreach ($additional_user_fields as $key => $val) {
      if (isset($table_fields[$key])) {
        $additional_sql .= ", u.$key";
      }
    }
  }

Step 1.1. added 5-27-03
Find:
Code: [Select]
       "comment_id" => $comment_row[$i]['comment_id'],Add after:
Code: [Select]
"lang_comments_per_page" => $lang['comments_per_page'],
Step 1.2 added 2009-08-12
Find:
Code: [Select]
          ORDER BY c.comment_date ASCReplace it with:
Code: [Select]
          ORDER BY c.comment_date ASC
          LIMIT $offset, $commentperpage";


Step 2.
Open /lang/<yourlanguage>/main.php
Add just before closing ?>
Code: [Select]
$lang['comment_stats'] = "Found: {total_cat_images} comment(s) on {total_pages} page(s). Displayed: comment {first_page} to {last_page}.";
$lang['comments_per_page'] = "Comments per page:";


Step 3.
Open /templates/<yourtemplate>/details.html
Find:
Code: [Select]
{if allow_comments}Add after:
Code: [Select]
<a name="comments"></a>
{if paging_stats}
<table width="100%" border="0" cellspacing="1" cellpadding="0" class="bordercolor">
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="3">
<tr>
<td class="row1" valign="middle">
{paging_stats}
</td>
<td class="row1" valign="top" align="right">
{commentsperpage_dropdown_form}
</td>
</tr>
</table>
</td>
</tr>
</table>
<br />
{endif paging_stats}
{if paging}
<table width="100%" border="0" cellspacing="1" cellpadding="0" class="bordercolor">
<tr>
<td>
<table width="100%" border="0" cellspacing="0" cellpadding="3">
<tr>
<td class="row1" valign="top">{paging}</td>
</tr>
</table>
</td>
</tr>
</table>
<br />
{endif paging}


Step 4.
Create new template /templates/<yourtemplate>/commentsperpage_dropdown_form.html with this code:
Code: [Select]
<table border="0" cellspacing="0" cellpadding="0">
<form method="post" action="{self}#comments" name="commentsperpage">
<tr>
<td>{lang_comments_per_page}&nbsp;</td>
<td>{commentsperpage_dropdown}</td>
</tr>
</form>
</table>


Step 5.
Make sure that u have new Universal Paging Class.
This MOD will work with default paging.php, but will display
Quote
Found 5 Imag(s) on 1 page(s). Dispalayed Image 1 to 5

Step 6
For 4images v1.7.1 Apply this patch:
http://www.4homepages.de/forum/index.php?topic=7493.0

135
Mods & Plugins (Requests & Discussions) / Universal Paging Class
« on: May 19, 2003, 07:37:17 PM »
Topic has moved here

Please dont use the code below!
It wasn't deleted just for your references.
Quote
This is replacement for the default /includes/paging.php that works exactly the same but could be used for anything, not only for images. (If u are not gonna do your own changes in 4images code, then probably dont bother reading "How To Use" section ;))


1. Backup original /includes/paging.php
2. Create new /includes/paging.php file with this code (replace the original)
Code: [Select]
<?php
/**************************************************************************
 *                                                                        *
 *    4images - A Web Based Image Gallery Management System               *
 *    ----------------------------------------------------------------    *
 *                                                                        *
 *             File: paging.php                                           *
 *        Copyright: (C) 2002 Jan Sorgalla                                *
 *            Email: jan@4homepages.de                                    *
 *              Web: http://www.4homepages.de                             *
 *    Scriptversion: 1.7                                                  *
 *                                                                        *
 *    Never released without support from: Nicky (http://www.nicky.net)   *
 *                                                                        *
 **************************************************************************
 *                                                                        *
 *    Dieses Script ist KEINE Freeware. Bitte lesen Sie die Lizenz-       *
 *    bedingungen (Lizenz.txt) f&#8319;r weitere Informationen.                 *
 *    ---------------------------------------------------------------     *
 *    This script is NOT freeware! Please read the Copyright Notice       *
 *    (Licence.txt) for further information.                              *
 *                                                                        *
 *************************************************************************/
if (!defined('ROOT_PATH')) {
  die("Security violation");
}
if (
class_exists(Paging)) return;

class 
Paging {
  var $page,$offset,$perpage,$num_rows_all,$link_args;
  var $first,$last,$total_pages,$config,$desc,$next,$back,$extra;

  function Paging($page 1$perpage 0$num_rows_all 0$link_args ""$text ""$extra ""$page_text ""$style "") {
    global $lang$config;

//-------- Config ------------
//Change $this->alt to 1 if u want display number of pages not more then u set in the settings, no metter on witch page u are.
//by default if u have 20 pages, for example, and in the settings set to show only 10, it will actualy show u 20 pages when u go to 10th page.
$this->alt 1;
//------- End Config ---------

    $this->style = ($style) ? $style "paging";
    $this->extra = ($extra) ? "#".$extra "";
    $this->page_text = ($page_text) ? $page_text "page";
    $this->desc = ($text) ? $text $lang['paging_stats'];

    $this->page $page;
    $this->perpage $perpage;
    $this->num_rows_all $num_rows_all;

    if (!isset($this->page) || !intval($this->page)) {
      $this->page 1;
    }
    if (!$this->num_rows_all) {
      $this->total_pages 0;
    }
    elseif ($this->num_rows_all <= $this->perpage) {
      $this->total_pages 1;
    }
    elseif ($this->num_rows_all $this->perpage == 0) {
      $this->total_pages $this->num_rows_all $this->perpage;
    }
    else {
      $this->total_pages ceil($this->num_rows_all $this->perpage);
    }
    if ($this->page $this->total_pages) {
      $this->page 1;
    }
    if (!$this->num_rows_all) {
      $this->first 0;
    }
    else {
      $this->first $this->perpage $this->page $this->perpage 1;
    }
    if (!$this->num_rows_all) {
      $this->last 0;
    }
    elseif ($this->page == $this->total_pages) {
      $this->last $this->num_rows_all;
    }
    else {
      $this->last $this->perpage $this->page;
    }

    $this->offset $this->perpage $this->page $this->perpage;

    $link_args ereg_replace("&".$this->page_text."=[0-9]*"""$link_args);
    $link_args ereg_replace($this->page_text."=[0-9]*&"""$link_args);
    $this->link_args basename($link_args);
    $this->link_args .= preg_match("/\?/",$this->link_args) ? "&amp;" "?";

    $this->paging_next $lang['paging_next'];
    $this->paging_back $lang['paging_previous'];
    $this->paging_lastpage $lang['paging_lastpage'];
    $this->paging_firstpage $lang['paging_firstpage'];
    $this->range $config['paging_range'];
  }

  function get_paging() {
    $html "";
    if ($this->total_pages 1) {
      $page_back $this->page 1;
      $page_next $this->page 1;

if ($this->alt) {
      if ($page_back 0) {
        $html .= "<a href=\"".$this->link_args.$this->page_text."=1".$this->extra."\" class=\"".$this->style."\">".$this->paging_firstpage."</a>&nbsp;&nbsp;";
        $html .= "<a href=\"".$this->link_args.$this->page_text."=".$page_back.$this->extra."\" class=\"".$this->style."\">".$this->paging_back."</a>&nbsp;&nbsp;";
      }
      $page_num2 ceil($this->range 2);
      $page_num3 $this->range;
      $page_left 1;
      if (($this->page $page_num2) > 0) {
       $html .= "<a href=\"".$this->link_args.$this->page_text."=".(($this->page $this->range $page_num2) ? $page_num2 : (($this->page <= ($this->total_pages $page_num2)) ? $this->page $this->range $this->total_pages $this->range $page_num2 1)).$this->extra."\" class=\"".$this->style."\">...</a>&nbsp;&nbsp;";
}
      for ($page_num 1$page_num <= $this->total_pages$page_num++){
       if ($page_num3) {
       if ($page_left) {
       if (($page_num >= $this->page - ($this->range $page_num2)) || ($page_num $this->total_pages $this->range && $this->page $this->total_pages $this->range )) {
          if ($this->page == $page_num) {
           $page_left--;
           $page_num2--;
           $page_num3--;
            $html .= "[<b class=\"".$this->style."on\">".$page_num."</b>]&nbsp;&nbsp;";
          }
          else {
           $page_num2--;
           $page_num3--;
            $html .= "<a href=\"".$this->link_args.$this->page_text."=".$page_num.$this->extra."\" class=\"".$this->style."\">".$page_num."</a>&nbsp;&nbsp;";
          }
        }
      }else{
      if ($page_num <= $this->page + ($this->range $page_num2)) {

          if ($this->page == $page_num) {
            $html .= "[<b class=\"".$this->style."on\">".$page_num."</b>]&nbsp;&nbsp;";
          }
          else {
           $page_num2--;
           $page_num3--;
            $html .= "<a href=\"".$this->link_args.$this->page_text."=".$page_num.$this->extra."\" class=\"".$this->style."\">".$page_num."</a>&nbsp;&nbsp;";
          }
        }
}
}
}
$page_num2 ceil($this->range 2);
      if (($this->page $page_num2) <= $this->total_pages) {
       $html .= "<a href=\"".$this->link_args.$this->page_text."=".(($this->page $page_num2 <= $this->total_pages $this->range) ? (($this->page $page_num2) ? $this->range $page_num2 $this->page $this->range) : $this->total_pages $page_num2 1).$this->extra."\" class=\"".$this->style."\">...</a>&nbsp;&nbsp;";
}
      if ($page_next <= $this->total_pages) {
        $html .= "<a href=\"".$this->link_args.$this->page_text."=".$page_next.$this->extra."\" class=\"".$this->style."\">".$this->paging_next."</a>&nbsp;&nbsp;";
        $html .= "<a href=\"".$this->link_args.$this->page_text."=".$this->total_pages.$this->extra."\" class=\"".$this->style."\">".$this->paging_lastpage."</a>";
      }
}else{
      if ($page_back 0) {
        $html .= "<a href=\"".$this->link_args.$this->page_text."=1".$this->extra."\" class=\"".$this->style."\">".$this->paging_firstpage."</a>&nbsp;&nbsp;";
        $html .= "<a href=\"".$this->link_args.$this->page_text."=".$page_back.$this->extra."\" class=\"".$this->style."\">".$this->paging_back."</a>&nbsp;&nbsp;";
      }
  for ($page_num 1$page_num <= $this->total_pages$page_num++) {
        if ($page_num >= ($this->page $this->range) && $page_num <= ($this->page $this->range)) {
          if ($this->page == $page_num) {
            $html .= "<b class=\"".$this->style."on\">".$page_num."</b>&nbsp;&nbsp;";
          }else{
            $html .= "<a href=\"".$this->link_args.$this->page_text."=".$page_num.$this->extra."\" class=\"".$this->style."\">".$page_num."</a>&nbsp;&nbsp;";
          }
        }
      }
      if ($page_next <= $this->total_pages) {
        $html .= "<a href=\"".$this->link_args.$this->page_text."=".$page_next.$this->extra."\" class=\"".$this->style."\">".$this->paging_next."</a>&nbsp;&nbsp;";
        $html .= "<a href=\"".$this->link_args.$this->page_text."=".$this->total_pages.$this->extra."\" class=\"".$this->style."\">".$this->paging_lastpage."</a>";
      }
      }



    }
    return $html;
  }

  function get_offset() {
    return $this->offset;
  }

  function get_paging_stats() {
    global $site_template;
    $search_array = array(
      "/".$site_template->start."total_cat_images".$site_template->end."/iU",
      "/".$site_template->start."total_pages".$site_template->end."/iU",
      "/".$site_template->start."first_page".$site_template->end."/iU",
      "/".$site_template->start."last_page".$site_template->end."/iU"
    );
    $replace_array = array(
      $this->num_rows_all,
      $this->total_pages,
      $this->first,
      $this->last
    
);
    $this->desc preg_replace($search_array$replace_array$this->desc);
    return $this->desc;
  }
//end of class
?>

I added alternative way to show number of pictures (reference)
for that u'll need just change $this->alt = 1; inside the file.


How To Use:
I'll try explain by an example ;):
Code: [Select]
  $cat_num_all = 10;
  $cat_perpage = 4;
  $cat_page = 2;
  $link_arg = $site_sess->url(ROOT_PATH."categories.php");
  $text = "Found {total_cat_images} categories(s) on {total_pages} page(s) .Displayed: category {first_page} to {last_page}.";
  $page_text = "cat_page";
  $extra = "categories";
  include(ROOT_PATH.'includes/paging.php');
  $getpaging = new Paging($cat_page, $cat_perpage, $cat_num_all, $link_arg, $text, $page_text, $extra);
  $offset = $getpaging->get_offset();
  $site_template->register_vars(array(
    "cat_paging" => $getpaging->get_paging(),
    "cat_paging_stats" => $getpaging->get_paging_stats()
  ));
this is not working example, so dont bother trying it ;)

if u are familuar a little bit with 4images code, then u might see, that all this is almost the same as the default, exept three new variables that being send to Paging class:
$getpaging = new Paging($cat_page, $cat_perpage, $cat_num_all, $link_arg, $text, $page_text, $extra, $style);
if u leave those variables empty (or just wont add them to the code), paging will use the default settings.

In $text variable u can specify text that u'd like to show in the templates by {cat_paging_stats}
U can use the same {..} tags as in $lang['paging_stats'] in your /lang/<yourlanguage>/main.php

In $page_text u can specify name of "page" for the link address. In this example it will change current page when in the address add cat_page=XX . If u leave it empty it will generate links to the pages by using page=XX. This is neccery if u want use more then one paging at the same page, for example if u want add paging for list of categories and still have paging for images.

$extra needs only if u want after open "next" page it "jumps" to the part of page, name of witch matching with $extra. $extra will be added into "pages" link as #$extra.
in this example the link would be:
categories.php?cat_page=XX#categories

$style set style of paging displayed. If not set, will use class="paging"

Pages: 1 ... 5 6 7 8 [9] 10 11 12 13 14