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 ... 3 4 5 6 [7] 8 9 10 11 ... 14
91
On some non-IE based browsers such as Mozilla or Firefox the backup database may fail, resulting not usible database backup archive.

To fix that, open admin/backup.php
Find:
Code: [Select]
    $table_select .= "<option value\"".$row[0]."\"";Replace with:
Code: [Select]
    $table_select .= "<option value=\"".$row[0]."\"";

92
--------- [ Introduction ] ------------
This mod will show "Terms and Conditions" message instead of image on the image details page untill the visitor accept them.

- Administrator can set terms per category and per individual image. Per image settings have higher priority then per category, meaning if both category and image set terms, only image terms will be used, and accepting image terms will not affect category terms.
- Administrator can set who must accept terms: only guests or everyone
- Cookies are supported

U can see it in action:
here terms are set for the image only
and here terms are set for category (members only)



--------- [ Installation ] ------------

NOTE:
This mod require [MOD] Dropdown options for custom database fields mod to be installed.


Changed files:

global.php
details.php
categories.php
includes/functions.php
includes/constants.php
includes/db_field_definitions.php
lang/<yourlanguage>/main.php
admin/categories.php
templates/<yourtemplate>/details.html
templates/<yourtemplate>/categories.html


New template:

templates/<yourtemplate>/terms.html



Step 1
Open global.php
For 4images v1.7
Find:
Code: [Select]
$sql = "SELECT c.cat_id, c.cat_name, c.cat_description, c.cat_parent_id, c.cat_hits, c.cat_order, c.auth_viewcat, c.auth_viewimage, c.auth_download, c.auth_upload, c.auth_directupload, c.auth_vote, c.auth_sendpostcard, c.auth_readcomment, c.auth_postcomment, COUNT(i.image_id) AS new_images
replace with:
Code: [Select]
$sql = "SELECT c.cat_id, c.cat_name, c.cat_description, c.cat_parent_id, c.cat_hits, c.cat_order, c.auth_viewcat, c.auth_viewimage, c.auth_download, c.auth_upload, c.auth_directupload, c.auth_vote, c.auth_sendpostcard, c.auth_readcomment, c.auth_postcomment, COUNT(i.image_id) AS new_images, c.terms, c.terms_msg(there only added , c.terms, c.terms_msg at the end of that line)

For 4images v1.7.1
Find:
Code: [Select]
 $sql = "SELECT cat_id, cat_name, cat_description, cat_parent_id, cat_hits, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcommentReplace with:
Code: [Select]
 $sql = "SELECT cat_id, cat_name, cat_description, cat_parent_id, cat_hits, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment, terms, terms_msg(there only added , terms, terms_msg at the end of that line)



Step 2
Open details.php
Find:
Code: [Select]
show_image($image_row, $mode, 0, 1);
Insert above:
Code: [Select]
//-----------------------------------------------------
//--- Image Terms -------------------------------------
//-----------------------------------------------------
if ($action == "terms") {
  terms_add($cat_id, (($image_row['terms']) ? $image_id : ""));
}
$terms = 0;
if (!terms_check($cat_id, (($image_row['terms']) ? $image_row : "")) && $action != "terms")
{
  if ($image_row['terms'])
  {
    $terms_agreement = ($lang['terms_agreement'][$image_row['terms_msg']]) ? $lang['terms_agreement'][$image_row['terms_msg']] : $lang['terms_agreement'][0];
  }
  else
  {
    $terms_agreement = ($lang['terms_agreement'][$cat_cache[$cat_id]['terms_msg']]) ? $lang['terms_agreement'][$cat_cache[$cat_id]['terms_msg']] : $lang['terms_agreement'][0];
  }
  $site_template->register_vars(array(
    "url_home" => $site_sess->url(ROOT_PATH."index.php"),
    "lang_terms" => $lang['terms'],
    "mode" => $mode,
    "lang_terms_agreement" => $terms_agreement,
    "lang_agree" => $lang['agree'],
    "lang_agree_not" => $lang['agree_not']
  ));
  $terms = $site_template->parse_template("terms");
}
$site_template->register_vars(array(
    "show_terms" => $terms,
    "no_terms" => ($terms) ? 0 : 1
));
//--- End Image Terms -------------------------------------




Step 3
Open includes/functions.php
At the end, above closing ?> insert:
Code: [Select]
//-----------------------------------------------------
//--- Image Terms -------------------------------------
//-----------------------------------------------------
function terms_check($id, $image = array())
{
  global $HTTP_COOKIE_VARS, $site_sess, $user_info, $cat_cache;
  if ($user_info['user_level'] == ADMIN || (!empty($image) && (($image['terms'] == 1 && $user_info['user_level'] > GUEST) || ($image['terms'] == 2 && $user_info['user_level'] > USER))) || (empty($image) && empty($cat_cache[$id]['terms']) || ($cat_cache[$id]['terms'] && (($cat_cache[$id]['terms'] == 1 && $user_info['user_level'] > GUEST) || ($cat_cache[$id]['terms'] == 2 && $user_info['user_level'] > USER)))))
  {
    return true;
  }
  $name = "terms";
  if (!empty($image))
  {
    $id = $image['image_id'];
    $name .= "img";
  }
  if (TERMS_COOKIES)
  {
    $cookie_name = (defined("COOKIE_NAME")) ? COOKIE_NAME : "4images_";
    $cookie_name .= $name.$user_info['user_id'];
    $split_list = isset($HTTP_COOKIE_VARS[$cookie_name]) ? unserialize(stripslashes($HTTP_COOKIE_VARS[$cookie_name])) : array();
    $terms = in_array($id, $split_list);
  }
  if (!isset($site_sess->session_info[$name]))
  {
    $site_sess->session_info[$name] = $site_sess->get_session_var($name);
  }
  $split_list = array();
  if (!empty($site_sess->session_info[$name]))
  {
    $split_list = explode(" ", $site_sess->session_info[$name]);
  }
  return ((TERMS_COOKIES && $terms) || in_array($id, $split_list));
}
    
function terms_add($id, $image = "")
{
  global $HTTP_COOKIE_VARS, $site_sess, $user_info, $cat_cache;
  $name = "terms";
  if ($image)
  {
    $id = $image;
    $name .= "img";
  }
  if (TERMS_COOKIES)
  {
    $cookie_name = (defined("COOKIE_NAME")) ? COOKIE_NAME : "4images_";
    $cookie_name .= $name.$user_info['user_id'];
    $split_list = isset($HTTP_COOKIE_VARS[$cookie_name]) ? unserialize(stripslashes($HTTP_COOKIE_VARS[$cookie_name])) : array();
    if (!in_array($id, $split_list)) {
      $cookie_termsid[] = $id;
      setcookie($cookie_name, serialize($cookie_termsid), time() + TERMS_COOKIES_EXPIRE, COOKIE_PATH, COOKIE_DOMAIN, COOKIE_SECURE);
    }
  }
  if (!isset($site_sess->session_info[$name]))
  {
    $site_sess->session_info[$name] = $site_sess->get_session_var($name);
  }
  $split_list = array();
  if (!empty($site_sess->session_info[$name]))
  {
    $split_list = explode(" ", $site_sess->session_info[$name]);
  }
  if (!in_array($id, $split_list))
  {
    $site_sess->session_info[$name] .= " ".$id;
    $site_sess->session_info[$name] = trim($site_sess->session_info[$name]);
    $site_sess->set_session_var($name, $site_sess->session_info[$name]);
  }
}
//--- End Image Terms -------------------------------------




Step 4
Open includes/constants.php
At the end, above closing ?> insert:
Code: [Select]
// Terms and conditions
define('TERMS_COOKIES', 0); //use cookies? if not only session will be used (every time browser is closed a new session will be started)
define('TERMS_COOKIES_EXPIRE', 60*60*24*1); //60 seconds * 60 minutes * 24 hours * 1 day (read the comments )




Step 5
Open includes/db_field_definitions.php
At the end, above ?> insert:
Code: [Select]
$additional_image_fields['terms'] = array($lang['terms'], "dropdown", 0, $lang['terms_array'], 1);
$additional_image_fields['terms_msg'] = array($lang['terms_msg'], "dropdown", 0, $lang['terms_agreement'], 1);




Step 6
Open lang/<yourlanguage>/main.php
At the end, above closing ?> insert:
Code: [Select]
//-----------------------------------------------------
//--- Image Terms -------------------------------------
//-----------------------------------------------------
$lang['terms'] = "Terms and Conditions";
$lang['terms_msg'] = "Terms and Conditions message";
$lang['terms_agreement'] = array(
      "Terms and conditions blah blah<b>testa</b><br>asdfasdf",
      "Another terms and conditions blah blah blah"
);
$lang['terms_array'] = array("Disable", "Guests", "Everyone");




Step 7
Open admin/categories.php
Find:
Code: [Select]
function show_access_select($title = "", $type, $status) {
Insert above:
Code: [Select]
function show_terms_select($title = "", $type, $status, $array) {
  global $HTTP_POST_VARS;
  if (isset($HTTP_POST_VARS[$type])) {
    $status = $HTTP_POST_VARS[$type];
  }
  echo "<tr class=\"".get_row_bg()."\" valign=\"top\">\n<td><p class=\"rowtitle\">".$title."</p></td>\n";
  echo "<td>\n<select name=\"".$type."\">\n";
  foreach ($array as $key => $val) {
    echo "<option value=\"".$key."\"";
    if ($status == $key) {
      echo " selected=\"selected\"";
    }
    echo ">".$val."</option>\n";
  }
  echo "</select>\n</td>\n</tr>\n";
}



Step 7.1
Find two times:
Code: [Select]
 $auth_postcomment = $HTTP_POST_VARS['auth_postcomment'];
Insert below each:
Code: [Select]
 $terms = $HTTP_POST_VARS['terms'];
  $terms_msg = $HTTP_POST_VARS['terms_msg'];



Step 7.2
Find:
Code: [Select]
           (cat_name, cat_description, cat_parent_id, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment)
Replace it with:
Code: [Select]
           (cat_name, cat_description, cat_parent_id, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment, terms, terms_msg)
(please note, that there only added , terms, terms_msg at the end of the line. If u have different line, just add those two words manualy)


Step 7.3
Two line below, find:
Code: [Select]
           ('$cat_name', '$cat_description', $cat_parent_id, $cat_order, $auth_viewcat, $auth_viewimage, $auth_download, $auth_upload, $auth_directupload, $auth_vote, $auth_sendpostcard, $auth_readcomment, $auth_postcomment)";
Replace it with:
Code: [Select]
           ('$cat_name', '$cat_description', $cat_parent_id, $cat_order, $auth_viewcat, $auth_viewimage, $auth_download, $auth_upload, $auth_directupload, $auth_vote, $auth_sendpostcard, $auth_readcomment, $auth_postcomment, '$terms', '$terms_msg')";
(same deal here, only , $terms, $terms_msg was added to the end of the line)


Step 7.4
Find:
Code: [Select]
 show_form_footer($lang['add'], $lang['reset'], 2);
Insert above:
Code: [Select]
 show_table_separator($lang['terms'], 2);
  show_terms_select($lang['terms'], 'terms', $row['terms'], $lang['terms_array']);
  show_terms_select($lang['terms_msg'], 'terms_msg', $row['terms_msg'], $lang['terms_agreement']);



Step 7.5
Find:
Code: [Select]
           SET cat_name = '$cat_name', cat_description = '$cat_description', cat_parent_id = $cat_parent_id, cat_hits = $cat_hits, auth_viewcat = $auth_viewcat, auth_viewimage = $auth_viewimage, auth_download = $auth_download, auth_upload = $auth_upload, auth_directupload = $auth_directupload, auth_vote = $auth_vote, auth_sendpostcard = $auth_sendpostcard, auth_readcomment = $auth_readcomment, auth_postcomment = $auth_postcomment
Replace it with:
Code: [Select]
           SET cat_name = '$cat_name', cat_description = '$cat_description', cat_parent_id = $cat_parent_id, cat_hits = $cat_hits, auth_viewcat = $auth_viewcat, auth_viewimage = $auth_viewimage, auth_download = $auth_download, auth_upload = $auth_upload, auth_directupload = $auth_directupload, auth_vote = $auth_vote, auth_sendpostcard = $auth_sendpostcard, auth_readcomment = $auth_readcomment, auth_postcomment = $auth_postcomment, terms = '$terms', terms_msg = '$terms_msg'
(And again , terms = '$terms', terms_msg = '$terms_msg' was added to the end of the line)


Step 7.6
Find:
Code: [Select]
 $sql = "SELECT cat_name, cat_description, cat_parent_id, cat_hits, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment
Replace it with:
Code: [Select]
 $sql = "SELECT cat_name, cat_description, cat_parent_id, cat_hits, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment, terms, terms_msg
(, terms, terms_msg was added to the end of the line)


Step 7. 7
Find:
Code: [Select]
 show_form_footer($lang['save_changes'], $lang['reset'], 2, $lang['back']);
Insert above:

(4images v1.7 - 1.7.1)
Code: [Select]
 show_table_separator($lang['terms'], 2);
  show_terms_select($lang['terms'], 'terms', $result['terms'], $lang['terms_array']);
  show_terms_select($lang['terms_msg'], 'terms_msg', $result['terms_msg'], $lang['terms_agreement']);

(4images v1.7.2+)
Code: [Select]
 show_table_separator($lang['terms'], 2);
  show_terms_select($lang['terms'], 'terms', $cat_row['terms'], $lang['terms_array']);
  show_terms_select($lang['terms_msg'], 'terms_msg', $cat_row['terms_msg'], $lang['terms_agreement']);



Step 7.8
Find:
Code: [Select]
 $sql = "SELECT cat_id, cat_name, cat_description, cat_parent_id, cat_hits, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment
Replace it with:
Code: [Select]
 $sql = "SELECT cat_id, cat_name, cat_description, cat_parent_id, cat_hits, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment, terms, terms_msg
(, terms, terms_msg was added to the end of the line)



Step 8
Open templates/<yourtemplate>/details.html
Find {image} tag.
Replace it with:
Code: [Select]
                 {if show_terms}<b>{show_terms}<br /></b>{endif show_terms}
                      {if no_terms}
                      {image}
                      {endif no_terms}

Let me explain what it does. The {show_terms} tag will show the "Terms and Condition" message, u should add it in between {if show_terms} and {endif show_terms} tags, if u want u can add between those tags whatever u want to display along with the terms.
Put whatever u dont want to show when terms are present, between {if no_terms} and {endif no_terms} tags, make sure that {show_terms} tag is outside of no_terms tags.



Step 9
Create a new template: templates/<yourtemplate>/terms.html With this code:
Code: [Select]
<table border="0" cellpadding="0" cellspacing="0"  width="400" class="bordercolor" align="center">
  <tr>
    <td>
      <table width="100%" border="0" cellpadding="3" cellspacing="1">
        <tr>
          <td valign="top" class="head1">{lang_terms}</td>
        </tr>
        <tr>
          <td class="row2">{lang_terms_agreement}</td>
        </tr>
      </table>
    </td>
  </tr>
</table>
<table border="0" cellspacing="1" cellpadding="1" width="400" align="center">
   <tr>
      <form method="post" action="{self}">
         <td align="right" width="50%">
            <input type="hidden" name="action" value="terms" />
{if mode}
            <input type="hidden" name="mode" value="{mode}" />
{endif mode}
            <input type="submit" value="{lang_agree}" class="button" />
         </td>
      </form>
      <form method="post" action="{url_home}">
         <td align="left" width="50%">
            <input type="submit" value="{lang_agree_not}" class="button" />
         </td>
      </form>
   </tr>
</table>




Step 10
In your favorite MySQL manager (phpmyadmin or such) execute this query:
Code: [Select]
ALTER TABLE `4images_images` ADD `terms` TINYINT( 1 ) NOT NULL, ADD `terms_msg` SMALLINT( 6 ) NOT NULL;

ALTER TABLE `4images_images_temp` ADD `terms` TINYINT( 1 ) NOT NULL, ADD `terms_msg` SMALLINT( 6 ) NOT NULL;

ALTER TABLE `4images_categories` ADD `terms` TINYINT( 1 ) NOT NULL, ADD `terms_msg` SMALLINT( 6 ) NOT NULL;

In few words:
in phpmyadmin select your database (if its not selected already), click on "SQL" icon on top and paste the query above to the text box, click "Go" button.

The alternative is to download this installer.



Step 11
If u haven't install [MOD] Dropdown options for custom database fields, then do so, its required.



Step 12 (added 30-03-2005)
Open categories.php
Find:
Code: [Select]
//-----------------------------------------------------
//--- Clickstream -------------------------------------
//-----------------------------------------------------

Insert above:
Code: [Select]
//-----------------------------------------------------
//--- Image Terms -------------------------------------
//-----------------------------------------------------
if ($action == "terms") {
  terms_add($cat_id);
}
$terms = 0;
if (!terms_check($cat_id) && $action != "terms")
{
  $terms_agreement = ($lang['terms_agreement'][$cat_cache[$cat_id]['terms_msg']]) ? $lang['terms_agreement'][$cat_cache[$cat_id]['terms_msg']] : $lang['terms_agreement'][0];
  $site_template->register_vars(array(
    "url_home" => $site_sess->url(ROOT_PATH."index.php"),
    "mode" => $mode,
    "lang_terms" => $lang['terms'],
    "lang_terms_agreement" => $terms_agreement,
    "lang_agree" => $lang['agree'],
    "lang_agree_not" => $lang['agree_not']
  ));
  $terms = $site_template->parse_template("terms");
}
$site_template->register_vars(array(
    "show_terms" => $terms,
    "no_terms" => ($terms) ? 0 : 1
));
//--- End Image Terms -------------------------------------



Step 13
Open templates/<yourtemplate>/categories.html
Find {thumbnails} tag
Replace it with:
Code: [Select]
{if show_terms}
            {show_terms}
{endif show_terms}
{if no_terms}
            {thumbnails}
{endif no_terms}
Adjust it to your layout ;)



Now in ACP (Admin Control Panel) under "Edit images" and "Edit categories" u should see new options.



------- [ Version history ] ----------

1.2.1 (18-04-05) (more info here)
  - Fixed a bug in Step 2

1.2 (30-03-05) (more info here)
  - Added terms to the category page

1.1 (26-08-04)
  - Fixed "decline" button. (details.php)

1.0 (25-08-04)
  - First release

93
This mod will add new feature to use dropdown options for custom database fields, that could be specifyed in /includes/db_field_definitions.php

-------- [ Installation ] ---------

4images v1.7.6 and newer

Step 1

:flag-en: Open members.php
:flag-de: Öffne members.php

:flag-en: search:
:flag-de: suche:  
Code: [Select]
else {
        $value = (isset($HTTP_POST_VARS[$key])) ? format_text(stripslashes(trim($HTTP_POST_VARS[$key]))) : $image_row[$key];
      }

:flag-en: Insert above  
:flag-de: füge darüber ein:

Code: [Select]
elseif ($val[1] == "dropdown") {
        $value = (isset($HTTP_POST_VARS[$key])) ? format_text(stripslashes(trim($HTTP_POST_VARS[$key]))) : $image_row[$key];
        $additional_field_array[$key.'_dropdown'] = get_db_fields_dropdown($key, $val, $value);
      }

Step 1.1

:flag-en: search:
:flag-de: suche:

Code: [Select]
else {
        $value = (isset($HTTP_POST_VARS[$key])) ? format_text(trim($HTTP_POST_VARS[$key]), 2) : $user_info[$key];
      }

:flag-en: Insert above:
:flag-de: füge darüber ein:

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);
      }


Step 2
:flag-en: Open register.php
:flag-de: Öffne register.php

:flag-en: search:
:flag-de: suche:

Code: [Select]
else {
            $additional_field_array[$key.'_yes'] = "";
            $additional_field_array[$key.'_no'] = " checked=\"checked\"";
          }
        }

:flag-en: Replace with:
:flag-de: ersetze mit:

Code: [Select]
else {
            $additional_field_array[$key.'_yes'] = "";
            $additional_field_array[$key.'_no'] = " checked=\"checked\"";
          }
        }
        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);
        }


Step 3
:flag-en: Open includes/functions.php
At the end, above closing ?> insert:

:flag-de: Öffne includes/funktions.php
füge am ende vor ?> folgendes ein

Code: [Select]
function get_dropdown_options($name, $options = array(), $value = "", $multi_dim = 1, $number = 0, $auto = 0, $keypress = 0, $extra = "", $class = "", $i_start = 0, $i_step = 1, $i_stop = 1) {
  $keypress = ($keypress) ? " onkeypress=\"if(window.event.keyCode==13)this.form.submit();\"" : "";
  $auto = ($auto) ? " onchange=\"this.form.submit();\"" : "";
    $dropdown = "<SELECT name=\"".$name."\"".$auto.$keypress." class=\"".(($class) ? $class : "select")."\"".$extra.">\n";
   $i = $i_start;
  if (count($options)) {
    foreach ($options as $key => $val) {
       $what = (($number) ? $i : (($multi_dim) ? $key : $val));
        $dropdown .= "<option value=\"".$what."\"".(($value == $what) ? " selected" : "").">".preg_replace (array("/{key}/siU", "/{val}/siU", "/{what}/siU", "/{value}/siU"), array($key, $val, $what, $value), $val)."</option>\n";
        $i = $i + $i_step;
     }
  }else{
    for ($i = $i_start; $i <= $i_stop; $i += $i_step) {
        $dropdown .= "<option value=\"".$i."\"".(($value == $i) ? " selected" : "").">".$i."</option>\n";
    }
  }
   $dropdown .= "</select>\n";
  return $dropdown;
}
function get_db_fields_dropdown($key, $val, $value) {
  return get_dropdown_options($key, $val[3], $value, $val[4], $val[5], $val[7], 1, "", "select", $val[6]);
}


Step 4
:flag-en: Open admin/admin_functions.php
:flag-de: Öffne admin/admin_functions.php

:flag-en: search:
:flag-de: suche:

Code: [Select]
case "radio":
        show_radio_row($val[0], $field_name, ($value == "") ? 1 : $value);
        break;

:flag-en: Insert below:
:flag-de: füge darunter ein:

Code: [Select]
case "dropdown":
        show_user_dropdown_row($field_name, $val, $value);
        break;

Step 4.1

:flag-en: At the end, above closing ?> insert:

:flag-de: füge am ende vor ?> folgendes ein

Code: [Select]
function show_user_dropdown_row($name, $val, $value = 0){
  echo "<tr class=\"".get_row_bg()."\" valign='top'>\n<td><p class=\"rowtitle\">".$val[0]."</p></td>\n";
  echo "<td><p>\n";
  echo get_dropdown_options($name, $val[3], $value, $val[4], $val[5], $val[7], 1, "", "select", $val[6]);
  echo "</p></td>\n</tr>\n";
}







4images v1.7 - v1.7.5

Step 1 (updated 05-22-2004)
Open members.php

Find two times:
Code: [Select]
     else {
        $value = (isset($HTTP_POST_VARS[$key])) ? htmlspecialchars(stripslashes(trim($HTTP_POST_VARS[$key]))) : "";
      }

Replace both of them with:
Code: [Select]
     elseif ($val[1] == "dropdown") {
        $value = (isset($HTTP_POST_VARS[$key])) ? $HTTP_POST_VARS[$key] : $image_row[$key];
         $additional_field_array[$key.'_dropdown'] = get_db_fields_dropdown($key, $val, $value);
      }
      else {
        $value = (isset($HTTP_POST_VARS[$key])) ? htmlspecialchars(stripslashes(trim($HTTP_POST_VARS[$key]))) : ((isset($image_row[$key])) ? $image_row[$key] : "");
      }


4images v1.7.3

Find two times:
Code: [Select]
     else {
        $value = (isset($HTTP_POST_VARS[$key])) ? format_text(stripslashes(trim($HTTP_POST_VARS[$key]))) : $image_row[$key];
      }

Insert above both of them:
Code: [Select]
     elseif ($val[1] == "dropdown") {
        $value = (isset($HTTP_POST_VARS[$key])) ? format_text(stripslashes(trim($HTTP_POST_VARS[$key]))) : $image_row[$key];
        $additional_field_array[$key.'_dropdown'] = get_db_fields_dropdown($key, $val, $value);
      }



Step 1.1

4images v1.7

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];
      }



4images v1.7.3

Find:
Code: [Select]
     else {
        $value = (isset($HTTP_POST_VARS[$key])) ? format_text(trim($HTTP_POST_VARS[$key]), 2) : $user_info[$key];
      }

Insert above:
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);
      }




Step 2
Open register.php
Find:
Code: [Select]
         else {
            $additional_field_array[$key.'_yes'] = "";
            $additional_field_array[$key.'_no'] = " checked=\"checked\"";
          }
        }

Replace with:
Code: [Select]
         else {
            $additional_field_array[$key.'_yes'] = "";
            $additional_field_array[$key.'_no'] = " checked=\"checked\"";
          }
        }
        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);
        }




Step 3 (updated 2005-12-01)
Open includes/functions.php
At the end, above closing ?> insert:
Code: [Select]
function get_dropdown_options($name, $options = array(), $value = "", $multi_dim = 1, $number = 0, $auto = 0, $keypress = 0, $extra = "", $class = "", $i_start = 0, $i_step = 1, $i_stop = 1) {
  $keypress = ($keypress) ? " onkeypress=\"if(window.event.keyCode==13)this.form.submit();\"" : "";
  $auto = ($auto) ? " onchange=\"this.form.submit();\"" : "";
    $dropdown = "<SELECT name=\"".$name."\"".$auto.$keypress." class=\"".(($class) ? $class : "select")."\"".$extra.">\n";
   $i = $i_start;
  if (count($options)) {
    foreach ($options as $key => $val) {
       $what = (($number) ? $i : (($multi_dim) ? $key : $val));
        $dropdown .= "<option value=\"".$what."\"".(($value == $what) ? " selected" : "").">".preg_replace (array("/{key}/siU", "/{val}/siU", "/{what}/siU", "/{value}/siU"), array($key, $val, $what, $value), $val)."</option>\n";
        $i = $i + $i_step;
     }
  }else{
    for ($i = $i_start; $i <= $i_stop; $i += $i_step) {
        $dropdown .= "<option value=\"".$i."\"".(($value == $i) ? " selected" : "").">".$i."</option>\n";
    }
  }
   $dropdown .= "</select>\n";
  return $dropdown;
}
function get_db_fields_dropdown($key, $val, $value) {
  return get_dropdown_options($key, $val[3], $value, $val[4], $val[5], $val[7], 1, "", "select", $val[6]);
}




Step 4
Open admin/admin_functions.php
Find:
Code: [Select]
     case "radio":
        show_radio_row($val[0], $field_name, ($value == "") ? 1 : $value);
        break;

Insert below:
Code: [Select]
     case "dropdown":
        show_user_dropdown_row($field_name, $val, $value);
        break;



Step 4.2
At the end, above closing ?> insert:
Code: [Select]
function show_user_dropdown_row($name, $val, $value = 0){
  echo "<tr class=\"".get_row_bg()."\" valign='top'>\n<td><p class=\"rowtitle\">".$val[0]."</p></td>\n";
  echo "<td><p>\n";
  echo get_dropdown_options($name, $val[3], $value, $val[4], $val[5], $val[7], 1, "", "select", $val[6]);
  echo "</p></td>\n</tr>\n";
}




---------- [ How to use ] -----------

the format that u need to enter in includes/db_field_definitions.php must be like this:
Quote
$additional_user_fields['%column_name%'] = array("%field_description%", "%admin_field_type%", %is_required%, %dropdown_array% [, %is_multidimention%, %is_number%, %start_number%, %is_auto%]);


----------
%column_name% string

- Replace %column_name% with name of the table column.
You can use the tag {%column_name%_dropdown} in the templates to display the dropdown.

----------
%field_description% string

Replace %field_description% with a custom name. This name will be displayed in the Control Panel.
The value can be displayed in the templates with the tag {lang_%column_name%}.
It is also recommended to add this tag to the language files (main.php) and to replace "%field_description%"
with $lang['%column_name%']. (example: $lang['example'] = "Some description"; )

----------
%admin_field_type% string

- Replace %admin_field_type% with the type of input field you would like to use in your

----------
%is_required% bool

- Sets up the field as required when adding data through the Control Panel or the user upload form.

----------
%dropdown_array% array

- Array with a list of items for dropdown options.

----------
%is_multidimention% bool (optional. default 0)

- If %dropdown_array% is multidimetion array, set it to 1 otherwise 0

----------
%is_number% bool (optional. default 1)

- If %dropdown_array% is not multidimention array and you want use number in the value, set it to 1 otherwise 0

----------
%start_number% number (optional. default 0)

- Start number that will be used as value for first item in %dropdown_array%, when %is_number% is set to 1.

----------
%is_auto% bool (optional. default 0)

- Makes dropdown auto select (no need "submit" button)



--------- [ Examples ] ----------
 
Quote
$additional_user_fields['user_gender'] = array($lang['user_gender'], "dropdown", 0, array("---", "male", "female"), 0, 1, 5, 0);

it will produse template tag {user_gender_dropdown} with this code:

Code: [Select]
 <select name="user_gender" onkeypress="if(window.event.keyCode==13)this.form.submit();" />
    <option value="5">---</option>
    <option value="6">male</option>
    <option value="7">female</option>
  </select>



Quote
$additional_user_fields['user_gender'] = array($lang['user_gender'], "dropdown", 0, array("---", "male", "female"), 0, 0, 0, 1);

it will produse template tag {user_gender_dropdown} with this code:
 
Code: [Select]
 <select name="user_gender" onkeypress="if(window.event.keyCode==13)this.form.submit();" onchange="this.form.submit();" />
    <option value="---">---</option>
    <option value="male">male</option>
    <option value="female">female</option>
  </select>



Quote
$additional_user_fields['user_gender'] = array($lang['user_gender'], "dropdown", 0, array("n" => "---", "m" => "Male", "f" => "Female"), 1, 0, 0, 0);

it will produse template tag {user_gender_dropdown} with this code:

Code: [Select]
 <select name="user_gender" onkeypress="if(window.event.keyCode==13)this.form.submit();" />
    <option value="n">---</option>
    <option value="m">Male</option>
    <option value="f">Female</option>
  </select>


94
PPhlogger is a very powerful statistics tool
With this integration u'll be able see your visitors usernames in the PPhlogger's statistics and also you'll be able search by user id or user name in the statistics too.




------------- [ Installation ] -------------

Step 1
Backup these files:
From PPlogger dir:

    pphlogger.php
    dspLogs.php
    config.inc.php
    include/pphlogger.js
    include/loglist.inc.php
    libraries/search_func.lib.php
    mysql/pphl_xxxxx_logs.sql

    [/list]


    From 4images dir:

      includes/page_header.php
      pphlogger.js
      (this file might be located in different place, depence how u call your pphlogger script to log visitors)
      templates/<yourtemplate>/header.html or another template where u add call your pphloogger script
      [/list]

      Step 2
      Download package for your PPhlogger version: v2.2.4 or v2.2.5


      Step 3
      Unzip it and upload all files into pphlogger dir, overwrite the old files.


      Step 4
      Edit config.inc.php There are 2 new settings for 4images.


      Step 5
      If u have not yet install pphlogger, then just install it, all needed db changes will be included in the installation.
      If u have installed it, then add two fields into pphlogger database (execute those commands in your mysql manager):
      NOTE Replace xxxxx with your user ID (not user name, u can find it from ADMIN panel, or from pphlogger database)
      Code: [Select]
      ALTER TABLE `pphl_xxxxx_logs` ADD `user_id` MEDIUMINT( 8 ) NOT NULL;
      ALTER TABLE `pphl_xxxxx_logs` ADD `user_name` VARCHAR( 255 ) NOT NULL;


      Step 6
      Login into to your pphlogger with your username (not admin panel), go to "settings" and redownload pphlogger.js file, replace your old one.


      Step 7
      Open includes/page_header.php
      Find:
      Code: [Select]
        "site_name" => $config['site_name'],

      Insert below:
      Code: [Select]
        "current_user_id" => $user_info['user_id'],
        "current_user_name" => ($user_info['user_level'] == GUEST) ? $lang['userlevel_guest'] : addslashes($user_info['user_name']),


      Step 8
      Open templates/<yourtemplate>/header.html or footer.html, the one where u add pphloger loggin script.
      replace your loggin script with this one:
      Code: [Select]
      <script language="JavaScript">var user_id='{current_user_id}';var user_name='{current_user_name}';</script>
      <script language="JavaScript" type="text/javascript" src="pphlogger.js"></script>
      <noscript><img alt="" src="../log/pphlogger.php?id=81312&st=img&user_id={current_user_id}&user_name={current_user_name}"></noscript>


      Adopt it to your settings

      P.S.
      - when user is online (online time u can set from settings) the username is shows in green color.
      - when user logged out, and continue browse the site, hes username wont be replaced with "Guest" in the logs.
      - when user logged out and then login with different username, the log will show current username.

      95
      Mods & Plugins (Releases & Support) / [MOD] Ban v1.7
      « on: March 28, 2005, 05:32:31 AM »
      Working with v1.7 and v1.7.1 (possible with v1.7.2 too)

      With this mod administrators can control who should not visit their 4images site and for how long.

      here are a few screenshots of the control panel:

      The list of bans:



      The list of current visitors with ability ban them from there:



      A clean form for a new ban:



      Logs of banned visitors:




      --------- [ Features ] -----------

      • ban by IP, hostname, email, username and user ID
      • use wildcard for partial matching (*.aol.com) (one exeption is user ID)
      • use IP range (192.168.0.1-9 this will ban IPs from 192.168.0.1 to 192.168.0.9
      • in the list of already added bans u can filter what type of ban u would like to see and which to hide
      • multi-sorting options
      • temporary or perm bans
      • add info about a current visitor from "who's online" menu directly to the "add new ban" form (dont need type manualy)



      ---------- [ Changed/new files ] -----------

      New files:
      admin/plugins/ban.php
      templates/<your template>/ban.html


      Changed files:
      admin/settings.php
      includes/constants.php
      includes/functions.php
      includes/sessions.php
      lang/<your language>/admin.php
      lang/<your language>/main.php
      member.php




      ---------- [ Installation ] ----------

      Step 1
      Open admin/settings.php
      Find:
      Code: [Select]
        show_form_footer($lang['save_changes'], "", 2);Add above:
      Code: [Select]
      /*
        MOD BAN
        START INSERT
      */
        show_table_separator($setting_group[XX], 2, "#setting_group_XX");
        show_setting_row("look_hostname", "radio");
      /*
        MOD BAN
        END INSERT
      */
      Now is the tricky part. Scroll little bit up and find the last
      show_table_separator($setting_group[XX], 2, "#setting_group_XX");
      where XX is a number of the last section. Now add 1 to that number and memorize that number, u'll need it in Step 5
      Also, replace XX in the code u've just added to admin/settings.php with that number.
      For example if the last section looks like show_table_separator($setting_group[7], 2, "#setting_group_7");
      Then the number u should "memorize" is 8 (7+1=8)



      Step 2
      Open includes/constants.php
      At the very end, above closing ?> insert:
      Code: [Select]
      /*
        MOD BAN
        START INSERT
      */
      define("BAN_TABLE", $table_prefix."ban");
      define("BAN_LOGS_TABLE", $table_prefix."ban_logs");
      define("BAN_IP", 1);
      define("BAN_HOSTNAME", 2);
      define("BAN_USERID", 3);
      define("BAN_NAME", 4);
      define("BAN_EMAIL", 5);
      /*
        MOD BAN
        END INSERT
      */



      Step 3
      Open includes/functions.php
      At the very end, above closing ?> insert:
      Code: [Select]
      /*
        MOD BAN
        START INSERT
      */

      function check_ban()
      {
        global $user_info, $site_sess, $config, $lang, $site_db, $HTTP_GET_VARS;
        $types = array("ip", "hostname", "name", "user_id", "email");
        if (!$config['ban_update'])
        {
          return false;
        }
        if ($user_info['user_level'] == ADMIN)
        {
          if (!isset($HTTP_GET_VARS['bantest'])) return false;
          $return = true;
          foreach ($types as $key)
          {
            if (isset($HTTP_GET_VARS[$key]) && $$key = $HTTP_GET_VARS[$key]) $return = false;
            else $$key = "";
          }
          if ($return) return false;
          $force = true;
        }
        else
        {
          $ip = $site_sess->session_info['session_ip'];
          $email = $user_info['user_email'];
          $user_id = $user_info['user_id'];
          $name = $user_info['user_name'];
          $hostname = "";
          $force = false;
        }
       
        $ban = false;
        $ban_checked = $site_sess->get_session_var("ban_checked");
        $ban_userid = $site_sess->get_session_var("ban_userid");
        $ban_banned = $site_sess->get_session_var("ban_banned");
        if (get_magic_quotes_gpc() != 0)
        {
          $ban_banned = stripslashes($ban_banned);
        }
      //  $ban_banned = stripslashes($ban_banned); //uncomment this line if magic_quotes_gpc is turned on on your server
        $ban_banned = ($ban_banned) ? unserialize($ban_banned) : "";
       
        if ($force || (!$ban_checked || !$ban_userid || ($ban_userid && $ban_userid != $user_info['user_id']) || ($ban_checked && $ban_checked < $config['ban_update']) || ($ban_banned && $ban_banned['expire'] < time())))
        {
          $query = array();

          if (preg_match('/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/', $ip, $ip_chop) == 1)
          {
            $query[] = "(type = ".BAN_IP." AND ($ip_chop[1] BETWEEN ip1_start AND ip1_end) AND ($ip_chop[2] BETWEEN ip2_start AND ip2_end) AND ($ip_chop[3] BETWEEN ip3_start AND ip3_end) AND ($ip_chop[4] BETWEEN ip4_start AND ip4_end))";

            if ($config['look_hostname'] && !$hostname)
            {
              $hostname = @gethostbyaddr($ip);
            }
          }
          if ($hostname)
          {
            $query[] = "(type = ".BAN_HOSTNAME." AND ('$hostname' LIKE hostname))";
          }
          if ($email)
          {
            $query[] = "(type = ".BAN_EMAIL." AND ('".addslashes($email)."' LIKE email))";
          }

          if ($user_id && $user_id > GUEST)
          {
            $query[] = "(type = ".BAN_USERID." AND user_id = ".$user_id.")";
          }

          if ($name)
          {
            $query[] = "(type = ".BAN_NAME." AND ('".addslashes($name)."' LIKE name))";
          }

          if (!empty($query))
          {
            $sql = "SELECT id, type, message, date, expire
                    FROM ".BAN_TABLE."
                    WHERE (".implode(' OR ', $query).")";
            if ($result = $site_db->query($sql))
            {
              while ($row = $site_db->fetch_array($result))
              {
                $site_sess->set_session_var("ban_banned", addslashes(serialize($row)));
       
                if ($row['date'] <= time() && (!$row['expire'] || $row['expire'] > time()))
                {
                  $ban = $row;
                  break;
                }
              }
            }
            else
            {
              $site_sess->set_session_var("ban_banned", "");
            }
           
          }
          $site_sess->set_session_var("ban_checked", time());
          $site_sess->set_session_var("ban_userid", $user_info['user_id']);
        }
        elseif ($ban_banned && $ban_banned['date'] <= time() && (!$ban_banned['expire'] ||  $ban_banned['expire'] > time()))
        {
          $ban = $ban_banned;
        }

        return $ban;
      }
      /*
        MOD BAN
        END INSERT
      */



      Step 4
      Open includes/sessions.php
      Find:
      Code: [Select]
      $user_info = $site_sess->return_user_info();
      Insert below:
      Code: [Select]
      /*
        MOD BAN
        START INSERT
      */
      if ($ban = check_ban())
      {
        $sql = "INSERT INTO ".BAN_LOGS_TABLE."
                (date, ip, uri, ban_id, user_id)
                VALUES
                (".time().", '".$site_sess->session_info['session_ip']."', 'http".(($_SERVER['SERVER_PORT'] != 80) ? "s" : "")."//".$_SERVER['SERVER_NAME'].addslashes($_SERVER['REQUEST_URI'])."', ".$ban['id'].", '".$user_info['user_id']."')";
        $site_db->query($sql);
        $main_template = "ban";
        $config['badword_list'] = "";
        include(ROOT_PATH.'includes/page_header.php');
        $site_template->register_vars(array(
          "lang_ban" => $lang['ban_banned'],
          "message" => format_text($ban['message'], 1, 0, 1, 1, 1, 1)
        ));
        $site_template->print_template($site_template->parse_template($main_template));
        include(ROOT_PATH.'includes/page_footer.php');
        exit;
      }
      /*
        MOD BAN
        END INSERT
      */



      Step 5
      Open lang/<your language>/admin.php
      At the very end, above closing ?> insert:
      Code: [Select]
      /*
        MOD BAN
        START INSERT
      */
      /*-- Setting-Group XX --*/
      $setting_group[XX]="Ban";
      $setting['look_hostname'] = "Lookup hostnames<span class=\"smalltext\"><br />might affect the perfomance";

      $lang['ban'] = "Ban";
      $lang['ban_ip'] = "IP";
      $lang['ban_ip_expl'] = "<span class=\"smalltext\">ex: 123.123.123.123 or 123.123.123.* or 123.123.123.0-255</span>";
      $lang['ban_user_id'] = "User id";
      $lang['ban_email'] = "Email";
      $lang['ban_email_expl'] = "<span class=\"smalltext\">ex: example*@example.com</span>";
      $lang['ban_name'] = "Name";
      $lang['ban_name_expl'] = "<span class=\"smalltext\">ex: example*</span>";
      $lang['ban_hostname'] = "Hostname";
      $lang['ban_hostname_expl'] = "<span class=\"smalltext\">ex: *.aol.com</span>";
      $lang['ban_add'] = "Add new ban";
      $lang['ban_edit'] = "Edit ban";
      $lang['ban_date'] = "Start date";
      $lang['ban_date_expl'] = "<span class=\"smalltext\">yyyy-mm-dd hh:mm:ss</span>";
      $lang['ban_expire'] = "End date";
      $lang['ban_expire_expl'] = "(leave blank for permanent ban)<br /><span class=\"smalltext\">yyyy-mm-dd hh:mm:ss</span>";
      $lang['ban_message'] = "Message";
      $lang['ban_message_expl'] = "<span class=\"smalltext\">Will be displayed to the banned visitor</span>";
      $lang['ban_reason'] = "Reason";
      $lang['ban_reason_expl'] = "<span class=\"smalltext\">Remind yourself</span>";
      $lang['ban_required'] = array(
          BAN_IP => "Please enter IP",
          BAN_HOSTNAME => "Please enter a hostname",
          BAN_USERID => "Please enter a user ID",
          BAN_NAME => "Please enter a username",
          BAN_EMAIL => "Please enter an email"
      );
      $lang['ban_bad_entry'] = array(
          BAN_IP => "IP is incorrect",
          BAN_HOSTNAME => "Hostname is incorrect",
          BAN_USERID => "User ID is incorrect",
          BAN_NAME => "Username is incorrect",
          BAN_EMAIL => "Email is incorrect"
      );
      $lang['ban_dublicate'] = array(
          BAN_IP => "This IP is already present in the database",
          BAN_HOSTNAME => "This hostname is already present in the database",
          BAN_USERID => "This user ID is already present in the database",
          BAN_NAME => "This username is already present in the database",
          BAN_EMAIL => "This email is already present in the database"
      );
      $lang['ban_type_array'] = array(
          BAN_IP => "IP",
          BAN_HOSTNAME => "Hostname",
          BAN_USERID => "User ID",
          BAN_NAME => "Username",
          BAN_EMAIL => "Email"
      );
      $lang['ban_list'] = "List";
      $lang['ban_type'] = "Type";
      $lang['ban_value'] = "Value";
      $lang['ban_add_success'] = "Entry added successfuly";
      $lang['ban_add_error'] = "Error adding new entry";
      $lang['ban_update_success'] = "Entry updated successfuly";
      $lang['ban_update'] = "Update";
      $lang['ban_update_error'] = "Error updating entry";
      $lang['ban_edit_error'] = "Error edit entry";
      $lang['ban_edit_success'] = "Entry edited successfuly";
      $lang['ban_delete_error'] = "Error delete entry";
      $lang['ban_delete_success'] = "Entry deleted successfuly";
      $lang['ban_filter'] = "Filter";
      $lang['ban_menu'] = "Content menu";
      $lang['ban_whois'] = "Whos online";
      $lang['ban_action'] = "Action";
      $lang['ban_perm'] = "Never";
      $lang['ban_perpage'] = "Show per page";
      $lang['ban_logs'] = "Logs";
      $lang['ban_uri'] = "Accessed URL";
      $lang['ban_user_name'] = "User name";
      $lang['ban_date_access'] = "Access date";
      $lang['ban_logs_del_success'] = "Log(s) deleted successfuly";
      $lang['ban_logs_del_error'] = "Error deleting log(s)";
      $lang['ban_active'] = "Active";
      $lang['ban_expired'] = "Expired";
      $lang['ban_notactive'] = "Not active";
      $lang['bad_invalid_date'] = "End date must be bigger then start date";
      $lang['ban_copy'] = "Copy";
      $lang['ban_test'] = "Test";
      /*
        MOD BAN
        END INSERT
      */
      Replace XX with the number u were supposed to memorize from Step 1
      Quote
      /*-- Setting-Group XX --*/
      $setting_group[XX]="Ban";



      Step 6
      Open lang/<your language>/main.php
      At the very end, above closing ?> insert:
      Code: [Select]
      /*
        MOD BAN
        START INSERT
      */
      $lang['ban_banned'] = "You've been banned";

      /*
        MOD BAN
        END INSERT
      */



      Step 7
      Download this package.
      Unzip it and upload acording the following directory tree:
      ban_install.php
      admin/plugins/ban.php
      templates/<your template>/ban.html

      (If u dont have admin/plugins/ folder, then simply create it)

      Step 7.1
      Login with your administrator account and run the installer (ban_install.php)
      by typing in your browser: http://<yoursiteaddress>/<path_to_4images>/ban_install.php
      Once the database update is finished, delete ban_install.php



      Step 8 (added 2006-05-20)
      Open member.php
      Find:
      Code: [Select]
        if ($user_row = get_user_info($user_id)) {
      Replace with:
      Code: [Select]
        if (($user_info['user_level'] == ADMIN || !$site_db->query_firstrow("SELECT id FROM ".BAN_TABLE." WHERE type = ".BAN_USERID." AND user_id = ".$user_id." AND (NOT expire OR expire > ".time().") LIMIT 1")) && $user_row = get_user_info($user_id)) {



      In the settings u should see now a new section "Ban" were u can turn on/off hostname lookup. If u turn it off, u wont be able ban by hostname, but it might increase server perfomance. U should only turn it off if your site loose its perfomance.



      ---------- [ F.A.Q. ] --------------

      Q: Why when I ban someone, they see the ban message only first time they open the page, after refresh the ban doesnt work anymore?
      A: This is a recent discover and its probably because your server has magic_quotes_gpc is turned on (check in phpinfo()).
      To fix that, uncomment this line from includes/functions.php:
      //  $ban_banned = stripslashes($ban_banned); //uncomment this line if magic_quotes_gpc is turned on on your server
      Since v1.6.1 added auto check if magic_quotes_gpc is enabled

      Q: Why when I enter an user id, name or an email address for a new ban it says id/name/email is not valid?
      A: The plugin checks if a member exists with such id/name/email, you can not ban non-existing members.

      Q: How can I ban entire subnet?
      A: If you want ban a subnet 192.168.0.X u have two ways to do so either use wildcard (*): 192.168.0.* or use IP range: 192.168.0.0-255
      You can specify range of each of 4 IP parts. 0-255.0-255.0-255.0-255
      In green is start number of the range and red is the end of the range. (be carefull, dont ban your own IP, otherwise ones you logout, the only way to get back is manualy edit database)

      Q: I just tryed ban myself, but I still was able access my site. Why?
      A: For security reason ban does not apply for administrators. Ones you log out, the only way unban yourself is edit manualy MySQL database.

      Q: When click on "whos online" link, it takes a while before it opens the page. Why?
      A: Most probably the "Hostname lookup" is turned on in the settings. You can disable it there, or edit ban.php and read comments for $look_hostname variable on top of the file.

      Q: How can I properly test the mod working?
      A: Well, the best sollution is add ban for your own IP/hostname and logout. BUT before you do that, make sure that you set expiration date for just a few minutes, you will have enough time to test the ban before it get expired and you'll be able login. To test ban by username/userid/email - set a ban for your test account and then try to login with that account.
      Also, since v1.5 you can test the ban by clicking "test" link next to it from the bans list page.



      ---------- [ Version history ] -------------

      1.7 (2006-05-20)
        - added an optional Step 8 which will allow view profiles of banned by user id members only to admins, other visitors will get "user not found" message.

      1.6.3 (2006-05-20)
        - fixed issue with not able see member's profile by admin when member banned by user id. (replace ban.php and redo step 3)

      1.6.2 (2005-07-09)
        - fixed issue when ban wouldnt work for name, user id or email, when visitor visited the site as a guest and then login.

      1.6.1 (2005-06-03)
        - added auto check if  magic_quotes_gpc is enabled on the server. it should fix issue covered in FAQ about ban doesnt work after page referesh. (just 3 lines added into includes/functions.php above the line mentioned in the FAQ)

      1.6 (2005-04-01) (more info here)
        - added support for [MOD] Country flags (based on IP) in whos online in ACP
        - added "reason" field in the logs page
        - fixed test by hostname
        - improved test feature

      1.5 (2005-03-29) (more info here)
        - added two new features: copy existing bans data into new ban form and test feature for admins

      1.4.3 (2005-03-29)
        - not a bug, and not a new feature, it just didnt show correct page when editing an entry. (replace ban.php)

      1.4.2 (2005-03-28)
        - very minor bug fixed where input form named "Add new ban" instead of "Update ban" after update failure (replace ban.php)

      1.4.1 (2005-03-28) (more info here)
        - found a bug that would only check the first found entry in the database and if the first entry is expired or not active and second entry is valid, the visitor will not get banned..

      1.4 (2005-03-28) (more info here)
        - added sorting by "value", its not perfect, but its close enough :)

      1.3 (2005-03-28) (more info here)
        - added another filter "not active" which will show/hide bans that are not active yet (the start date is still in the future)
        - added check for end date, that must be bigger then the start date.

      1.2 (2005-03-28) (more info here)
        - very minor change, now it coloring bans which are not active or expired
        - and now it parses bbcode, smiles (if installed) in the ban list

      1.1.1 (2005-03-28) (more info here)
        - fixed a very minor warning message

      1.1 (2005-03-28) (more info here)
        - added two new filters for the ban list

      1.0 (2005-03-28)
        - first release

      96
      Plugins / [Plugin] Rebuild Thumbnails v1.2 (2012-02-05)
      « on: March 27, 2005, 07:35:30 PM »
      This plugin will let u rebuild already existing thumbnails. Its usefull in case u want make your thumbnails bigger.

      ---------- [ Installation ] ------------

      1) create new folder admin/plugins/
      2) download attached package
      3) unzip it and upload rebuild_thumbnails.php into admin/plugins/ directory


      ---------- [ How to use ] -----------

      Go to ACP (Admin Control Panel) on left menu panel u should see new section "PlugIns" where u should find "Rebuild Thumbnails"


      ----------- [ Version history ] ------------

      1.2 (2012-02-05)
      - Added: include subcategories
      - Added: form settings are stored in session
      - Added: all text is now uses $lang array (can be translated)
      - Added: show thumbnails
      - Added: auto redirect coundown
      - Fixed: [MOD] Media Sites support

      1.1.1 (2010-07-10)
      - Fixed: javascript redirect to next page

      1.1 (2009-06-21)
      - Added: support for [MOD] Media sites

      1.0.3 (2005-03-29)
      - Fixed: problem with files with extension contains capital letters

      97
      If u set max width bigger then max height in the settings and tryed to resize an image witch width is smaller then height, after resize it height will be equal to max width, but bigger then max height.
      This is because 4images uses max width as max dimentions when resizing images.

      To correct this and resize images acording your max widht AND max height, do this:

      Step 1
      Open includes/image_utils.php
      Find:
      Code: [Select]

      function get_width_height($dimension, $width, $height, $resize_type = 1) {
        if ($resize_type == 2) {
          $new_width = $dimension;
          $new_height = floor(($dimension/$width) * $height);
        }
        elseif ($resize_type == 3) {
          $new_width = floor(($dimension/$height) * $width);
          $new_height = $dimension;
        }
        else {
          $ratio = $width / $height;
          if ($ratio > 1) {
            $new_width = $dimension;
            $new_height = floor(($dimension/$width) * $height);
          }
          else {
            $new_width = floor(($dimension/$height) * $width);
            $new_height = $dimension;
          }
        }
        return array("width" => $new_width, "height" => $new_height);
      }


      Replace it with:
      Code: [Select]
      function get_width_height($dimension, $width, $height, $resize_type = 1, $max_height = false) {
        $max_width = $dimension;
        $max_height = ($max_height === false) ? $max_width : $max_height;
        if ($resize_type == 2)
        {
          $new_width = $max_width;
          $new_height = floor(($max_width/$width) * $height);
        }
        elseif ($resize_type == 3)
        {
          $new_width = floor(($max_height/$height) * $width);
          $new_height = $max_height;
        }
        else
        {
          $new_width = $width;
          $new_height = $height;
          if ($width > $max_width || $height > $max_height)
          {
            $scale = min($max_width/$width, $max_height/$height);
            $new_width = floor($scale*$width);
            $new_height = floor($scale*$height);
          }
        }
        return array("width" => $new_width, "height" => $new_height);
      }




      Step 1.2
      Find:
      Code: [Select]
      function resize_image($file, $quality, $dimension, $resize_type = 1) {

      Replace it with:
      Code: [Select]
      function resize_image($file, $quality, $dimension, $resize_type = 1, $height = false) {



      Step 1.3
      Find:
      Code: [Select]
       $width_height = get_width_height($dimension, $image_info[0], $image_info[1], $resize_type);

      Replace it with:
      Code: [Select]
       $width_height = get_width_height($dimension, $image_info[0], $image_info[1], $resize_type, $height);




      Step 2
      Open admin/resizer.php
      Find:
      Code: [Select]
       $dimension = (isset($HTTP_POST_VARS['dimension'])) ? intval($HTTP_POST_VARS['dimension']) : 200;
        $resize_type = (isset($HTTP_POST_VARS['resize_type'])) ? intval($HTTP_POST_VARS['resize_type']) : 1;


      Replace it with:
      Code: [Select]
       $dimension = (isset($HTTP_POST_VARS['dimension'])) ? intval($HTTP_POST_VARS['dimension']) : $config['max_image_width'];
        $height = (isset($HTTP_POST_VARS['height'])) ? intval($HTTP_POST_VARS['height']) : $config['max_image_height'];
        $resize_type = (isset($HTTP_POST_VARS['resize_type'])) ? intval($HTTP_POST_VARS['resize_type']) : $config['auto_thumbnail_resize_type'];




      Step 2.2
      Find:
      Code: [Select]
       $dimension = (isset($HTTP_POST_VARS['dimension'])) ? intval($HTTP_POST_VARS['dimension']) : 200;
        $resize_type = (isset($HTTP_POST_VARS['resize_type'])) ? intval($HTTP_POST_VARS['resize_type']) : 1;


      Replace it with:
      Code: [Select]
       $dimension = (isset($HTTP_POST_VARS['dimension'])) ? intval($HTTP_POST_VARS['dimension']) : $config['max_image_width'];
        $height = (isset($HTTP_POST_VARS['height'])) ? intval($HTTP_POST_VARS['height']) : $config['max_image_height'];
        $resize_type = (isset($HTTP_POST_VARS['resize_type'])) ? intval($HTTP_POST_VARS['resize_type']) : $config['auto_thumbnail_resize_type'];




      Step 2.3
      Find:
      Code: [Select]
       show_input_row($lang['resize_dimension_desc'], "dimension", $dimension);

      Replace it with:
      Code: [Select]
       show_input_row($lang['max_imagewidth'], "dimension", $dimension);
        show_input_row($lang['max_imageheight'], "height", $height);




      Step 2.4
      Find:
      Code: [Select]
       $dimension = (isset($HTTP_POST_VARS['dimension'])) ? intval($HTTP_POST_VARS['dimension']) : 200;

      Replace it with:
      Code: [Select]
       $dimension = (isset($HTTP_POST_VARS['dimension'])) ? intval($HTTP_POST_VARS['dimension']) : $config['max_image_height'];
        $height = (isset($HTTP_POST_VARS['height'])) ? intval($HTTP_POST_VARS['height']) : $config['max_image_height'];



      Step 2.5
      Find:
      Code: [Select]
               if ($resize_type == 1 && ($image_info[0] > $dimension || $image_info[1] > $dimension)) {

      Replace it with:
      Code: [Select]
               if ($resize_type == 1 && ($image_info[0] > $dimension || $image_info[1] > $height)) {



      Step 2.6
      Find:
      Code: [Select]
               elseif ($resize_type == 3 && $image_info[1] > $dimension) {

      Replace it with:
      Code: [Select]
               elseif ($resize_type == 3 && $image_info[1] > $height) {



      Step 2.7
      Find:
      Code: [Select]
                 $width_height = get_width_height($dimension, $image_info[0], $image_info[1], $resize_type);

      Replace it with:
      Code: [Select]
                 $width_height = get_width_height($dimension, $image_info[0], $image_info[1], $resize_type, $height);



      Step 2.8
      Find:
      Code: [Select]
         show_hidden_input("dimension", $dimension);

      Add above:
      Code: [Select]
         show_hidden_input("height", $height);

      98
      So you want to be able to autothumbnail gif images?
      Are you having trouble with netpbm?
      I answered yes to both of those questions at one time.

      If you are tired of searching the forums, please read this. it should help you fix your problems.

      1. Download netpbm from this location:
      http://sniptools.com/av/netpbm.zip

      **LOCATION WAS UPDATED***

      2. Unzip the files to your harddrive into a folder called netpbm.

      The folder structure should look something like this.
       

      3. Create a php file with the following contents, and name it path.php

      Code: [Select]
      <?php 

      if (empty($PATH_TRANSLATED)) { 
      $pathinfo $SCRIPT_FILENAME
      }else{ 
      $pathinfo $PATH_TRANSLATED


      $lastseparator strrpos($pathinfo,"/"); 

      if (!
      $lastseparator) { 
      $lastseparator strrpos($pathinfo,"\\"); 


      $pathname substr($pathinfo,0,$lastseparator+1); 

      print 
      "Maybe this file is in <br> $pathname"
      ?>

       


      This code came from the following thread, and was posted by lutz:

      http://www.4homepages.de/forum/index.php?topic=7551&highlight=netpbm+path

      Make sure you save path.php INSIDE the netpbm directory

      4. Now, open up an ftp client and ftp that directory (in its entirety) to your website, under the 4images folder (or whatever you called it).

      The path should be: www.yourwebsite.com/4images/netbpm

      5. Now, chmod the netbpm folder and ALL files in it to 777

      6. In your browser, open up www.yourwebsite.com/4images/netbpm/path.php

      It will output the probable path for netbmp.

      Write that down, or copy and paste it somewhere, WITHOUT THE LAST /

      7. Open up www.yourwebsite.com/4images/admin in your web browser.

      8. Scroll down to Conversion tool for thumbnail.

      Choose NetPBM from the dropdown box.

      9. Right under that it will say: If you have selected "ImageMagick" or "NetPBM", enter path and program name


      10. Enter in the path that was given to you when you opened up path.php

      REMEMBER TO LEAVE OFF THE LAST /

      11. Scroll further down the admin page until you see Auto-create thumbnail
      . Choose yes.

      12. Please note, you need to store the images in the /4images/data/media/[number of the album] directory.

      Go to www.yourwebpage.com/4images/admin and choose Auto-thumbnailer. Then check the database for missing files.

      13. Now, time to test it! Open up www.yourwebsite.com/4images in your web browser and upload a photo. Upload a gif or jpg if you like. After you upload it, click on the category to make sure that the thumbnail was created. If you get an image of a grey eye with the file type, then you have done something wrong or this tutorial is totally off 

      Anyway, happy going to everyone. Questions or comments, please reply to this.

      Moderators, if you wanna put this in the FAQ section or modify it, feel free to, just please give me credit 

      Good luck all.

      Thanks pierro for the update

      99
      FAQ, Tips / Two sessionid in URLs
      « on: March 24, 2005, 06:06:30 AM »
      On some systems sessionid= being added twice to URLs.
      To fix that add in .htaccess file this line:
      Code: [Select]
      php_flag session.use_trans_sid off

      Another options are to change it directly in your php.ini (if you have access) or you can try to set it with the following code in config.php:
      Code: [Select]
      ini_set("session.use_trans_sid", "0");

      100
      Feedback & Suggestions / Pic Security
      « on: March 24, 2005, 03:38:18 AM »
      In this topic we'll discuss some trick to secure images,media files, etc
      Before the hack we had over 10 pages of this topic 8O

      I'll try reproduce some usefull tips'n tricks.  In case u would like to, I've attached 8 pages from the old forum.

      101
      Mods & Plugins (Releases & Support) / [MOD] Auto-Image Resizer v2.1
      « on: March 22, 2005, 11:54:42 PM »
      This is an enhanced version of default admin/resizer.php (which was lost long before the hack 8O)



      ---------- [ New features ] ---------
      • Category select
      • Thumbnails preview
      • Shows image name and image filename


      ---------- [ Installation ] ---------
      1) Backup admin/resizer.php
      2) Download attached package
      3) Unzip it and upload new resizer.php into admin/ folder


      ---------- [ Version history ] -----------

      v2.1
          Dont know what was changed :)

      v2
          First release

      102
      Chit Chat / Beware of some sites!
      « on: March 22, 2005, 12:08:21 AM »
      I woke up this morning, looked on condition of my server and my lower jaw hit the table - server was loaded on 100% for last 4 hours straight!
      in "Whos online" in ACP it showed me 200+ simulation connections and most of the "visitors" where on one sertain page (an image details), from different IPs, different countries, different clients (web browsers) and they were not bots for sure.
      Well, ok, I thought probably someone sent out a postcard or a link to that image to their friends, I'm fine with that.
      But, after few more hours the load didnt go down...I got suspicious, looked in my server access logs (man I had to go through 500mb of logs!) and found that most of those visitors came from one site:
      http://fusker.onedawg.com/ (please dont click unless u are 18 or over!)
      and there it is, a few links pointed to my site.
      I guess I wouldnt mind if they would cache the pages, but no, they show preview of the images hotlinked to the original site - that was the problem!

      So, my sollution was:
      1) contact my member who posted the links there (still waiting their responce)
      2) prevent any visitors whos referrer site is onedawg.com
      3) hopefuly the site has report links, so I reported links to my site as illegal and they removed them in a few minutes.

      Here is some code from my .htaccess to send visitors from this site back to the site they came from:
      Code: [Select]
      RewriteEngine on
      RewriteCond %{HTTP_REFERER} ^http://.*onedawg\.com.* [NC]
      RewriteRule .* %{HTTP_REFERER} [R,L]
      Note that your server must have mod_rewrite installed for this to work.

      If u, guys, know any other sites that do the same, we should add them to the list as well...

      103
      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 going to do your own changes in 4images code, then probably dont bother reading "How To Use" section )

      -------- [ Installation ] --------
      1. Backup original includes/paging.php
      2. Download this package.
      3. Unpack and replace includes/paging.php with the new one.

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

      If u want show input form where visitor can manualy enter the page number they want to see, change these lines in the file:
      Code: [Select]
           $this->form = $form; //(true, false or $form) - show the form where visitor can manualy enter the page they want to enter.
            $this->formjs = $formjs; //(true, false or $formjs) - include JS input validation, to ensure that the entered page is valid.



      --------- [ How To Use ] ----------

      I'll try explain it 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="paginginput" and class="pagingbutton"
      You can either replace in style.css:
      Code: (style.css) [Select]
      .button {with:
      Code: (style.css) [Select]
      .button, .pagingbutton {
      and
      Code: (style.css) [Select]
      .logininput {with
      Code: (style.css) [Select]
      .logininput, .paginginput {

      or add in style.css something like this:
      Code: (style.css) [Select]
      .paginginput {
        background-color: #ffffff;
        font-family: Tahoma,Verdana,Arial,Helvetica,sans-serif;
        color: #0f5475;
        font-size: 11px;
      }

      .pagingbutton {
        font-family:  Tahoma,Verdana,Arial, Helvetica, sans-serif;
        background-color: #003366;
        color: #fcdc43;
        font-size: 11px;
        font-weight: bold;
      }



      -------- [ Version history ] --------
      1.1.2 (2010-12-08)
          - applied bug fix: [1.7 - 1.7.9] Security fix for path disclosure in paging.php
      1.1.1 (2010-09-06)
          - it's now PHP5 compatible
      1.1
          - Added optional "manual input form" feature
      1.0
          - First release

      104
      This mod was written by CannabisCow before the hack and I'm just restoring it.

      ###############################################################
      ##
      ## Dieser Hack erlaubt euch, die Kategorien beliebig zu ordnen.
      ##
      ##############################################################


      ===============================================================
      == ./global.php
      ===============================================================
      ///////////////////////////////////////////
      // search
      ///////////////////////////////////////////

      Code: [Select]
        $sql = "SELECT c.cat_id, c.cat_name, c.cat_description, c.cat_parent_id, c.cat_hits, c.cat_order, c.auth_viewcat, c.auth_viewimage, c.auth_download, c.auth_upload, c.auth_directupload, c.auth_vote, c.auth_sendpostcard, c.auth_readcomment, c.auth_postcomment, COUNT(i.image_id) AS new_images
                FROM ".CATEGORIES_TABLE." c
                LEFT JOIN ".IMAGES_TABLE." i ON (i.cat_id = c.cat_id AND i.image_date >= $new_cutoff AND i.image_active = 1)
                GROUP BY c.cat_id
                ORDER BY c.cat_order, c.cat_name ASC";

       


      //////////////////////////////
      // replace with
      //////////////////////////////

      Code: [Select]
        $sql = "SELECT c.cat_id, c.cat_name, c.cat_description, c.cat_parent_id, c.cat_hits, c.cat_order, c.auth_viewcat, c.auth_viewimage, c.auth_download, c.auth_upload, c.auth_directupload, c.auth_vote, c.auth_sendpostcard, c.auth_readcomment, c.auth_postcomment, COUNT(i.image_id) AS new_images
                FROM ".CATEGORIES_TABLE." c
                LEFT JOIN ".IMAGES_TABLE." i ON (i.cat_id = c.cat_id AND i.image_date >= $new_cutoff AND i.image_active = 1)
                GROUP BY c.cat_id
                ORDER BY ".$config['cat_order']."";

       



      ===============================================================
      == ./lang/{lang}/admin.php
      ===============================================================
      ///////////////////////////////////////////
      // search
      ///////////////////////////////////////////

      Code: [Select]
      /*-- Setting-Group 3 --*/



      ///////////////////////////////////////////
      // add before
      ///////////////////////////////////////////
       
      Code: [Select]
      $setting['cat_order'] = "Nach welchem Prinzip, sollen die Kategorien bzw. Subkategorien geordnet werden";
      $cat_order_array = array(
      'c.cat_order' => 'Manuell',
      'c.cat_name ASC' => 'Name Aufsteigend',
      'c.cat_name DESC' => 'Name Absteigend'
      );

       


      ===============================================================
      == ./admin/settings.php
      ===============================================================
      ///////////////////////////////////////////
      // search
      ///////////////////////////////////////////
       
      Code: [Select]
      show_setting_row("num_subcats");
       


      ///////////////////////////////////////////
      // add after
      ///////////////////////////////////////////

      Code: [Select]
      show_setting_row("cat_order", "show_cat_order");


      ///////////////////////////////////////////
      // search
      ///////////////////////////////////////////

      Code: [Select]
      function show_image_order_select($setting_name, $setting_value) {
        global $image_order_optionlist;
        echo "<select name=\"setting_item[".$setting_name."]\">";
        foreach ($image_order_optionlist as $key => $val) {
          echo "<option value=\"$key\"";
          if ($setting_value == $key) {
            echo " selected=\"selected\"";
          }
          echo ">".$val."</option>";
        }
        echo "</select>";
      }

       

      ///////////////////////////////////////////
      // add after
      ///////////////////////////////////////////

      Code: [Select]
      function show_cat_order($setting_name, $setting_value) {
      global $cat_order_array;

        echo "<select name=\"setting_item[".$setting_name."]\">";
        foreach ($cat_order_array as $key => $val) {
          echo "<option value=\"$key\"";
          if ($setting_value == $key) {
            echo " selected=\"selected\"";
          }
          echo ">".$val."</option>";
        }
        echo "</select>";
      }



      ===============================================================
      == SQL (add this with phpmyadmin or run this installer --> installer (thx V@no for this installer)
      ===============================================================


      Code: [Select]
      INSERT INTO `4images_settings` ( `setting_name` , `setting_value` )
      VALUES (
      'cat_order', 'c.cat_name ASC'
      );

       


      PS: Viel Spass, hoffe hab nix vergessen ;)

      105
      Mods & Plugins (Releases & Support) / [MOD] Category Image v1.0.2
      « on: March 20, 2005, 09:14:38 PM »
      This mod will let admin set an image to be showed as a category image instead of folder icon in the categories list.


      --------- [ Changed Files ] --------
      global.php
      admin/categories.php
      admin/images.php
      (optional)
      includes/functions.php
      templates/<your template>/category_bit.html



      ---------- [ New files ] -----------
      catimage_install.php


      ---------- [ Installation ] -----------

      Before you do each step, scroll down and make sure that there is no exclusive for you 4images version changes. If there no version specifyed, then it means its for any 4images version.
      If you see "For 4images v1.7" then it means only for v1.7, scroll down and look for the changes needed for your version. In some cases there are two separate changes for v1.7 and v1.7.1 for instance, but your version is v1.7.3, then you should do the changes for the closest to your version (in this example it would be v1.7.1)

      Step 1
      Open global.php
      For 4images v1.7
      Find:
      Code: [Select]
        $sql = "SELECT c.cat_id, c.cat_name, c.cat_description, c.cat_parent_id, c.cat_hits, c.cat_order, c.auth_viewcat, c.auth_viewimage, c.auth_download, c.auth_upload, c.auth_directupload, c.auth_vote, c.auth_sendpostcard, c.auth_readcomment, c.auth_postcomment, COUNT(i.image_id) AS new_images
      At the end of that line (!) add:
      Quote
      , c.cat_image

      after u've changed it, the line should looks something like this:
      Quote
      $sql = "SELECT c.cat_id, c.cat_name, c.cat_description, c.cat_parent_id, c.cat_hits, c.cat_order, c.auth_viewcat, c.auth_viewimage, c.auth_download, c.auth_upload, c.auth_directupload, c.auth_vote, c.auth_sendpostcard, c.auth_readcomment, c.auth_postcomment, COUNT(i.image_id) AS new_images, c.cat_image


      For 4images v1.7.1
      Find:
      Code: [Select]
        $sql = "SELECT cat_id, cat_name, cat_description, cat_parent_id, cat_hits, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment

      At the end of that line (!) add:
      Quote
      , cat_image

      after u changed it, the line should looks something like this:
      Quote
      $sql = "SELECT cat_id, cat_name, cat_description, cat_parent_id, cat_hits, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment, cat_image




      Step 2
      Open admin/categories.php
      Find two (2) times:
      Code: [Select]
        $auth_postcomment = $HTTP_POST_VARS['auth_postcomment'];
      Insert below each line:
      Code: [Select]
      //Category Image
        $cat_image = (isset($HTTP_POST_VARS['cat_image']) && intval($HTTP_POST_VARS['cat_image'])) ? intval($HTTP_POST_VARS['cat_image']) : 0;
      //End Category Image



      Step 2.1
      Find:
      Code: [Select]
          $sql = "INSERT INTO ".CATEGORIES_TABLE."
                  (cat_name, cat_description, cat_parent_id, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment)
                  VALUES
                  ('$cat_name', '$cat_description', $cat_parent_id, $cat_order, $auth_viewcat, $auth_viewimage, $auth_download, $auth_upload, $auth_directupload, $auth_vote, $auth_sendpostcard, $auth_readcomment, $auth_postcomment)";

      Replace with:
      Code: [Select]
          $sql = "INSERT INTO ".CATEGORIES_TABLE."
                  (cat_name, cat_description, cat_parent_id, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment, cat_image)
                  VALUES
                  ('$cat_name', '$cat_description', $cat_parent_id, $cat_order, $auth_viewcat, $auth_viewimage, $auth_download, $auth_upload, $auth_directupload, $auth_vote, $auth_sendpostcard, $auth_readcomment, $auth_postcomment, $cat_image)";



      Step 2.2
      4images v1.7-1.7.2
      Find:
      Code: [Select]
                  SET cat_name = '$cat_name', cat_description = '$cat_description', cat_parent_id = $cat_parent_id, cat_hits = $cat_hits, auth_viewcat = $auth_viewcat, auth_viewimage = $auth_viewimage, auth_download = $auth_download, auth_upload = $auth_upload, auth_directupload = $auth_directupload, auth_vote = $auth_vote, auth_sendpostcard = $auth_sendpostcard, auth_readcomment = $auth_readcomment, auth_postcomment = $auth_postcomment

      Replace with:
      Code: [Select]
                  SET cat_name = '$cat_name', cat_description = '$cat_description', cat_parent_id = $cat_parent_id, cat_hits = $cat_hits, auth_viewcat = $auth_viewcat, auth_viewimage = $auth_viewimage, auth_download = $auth_download, auth_upload = $auth_upload, auth_directupload = $auth_directupload, auth_vote = $auth_vote, auth_sendpostcard = $auth_sendpostcard, auth_readcomment = $auth_readcomment, auth_postcomment = $auth_postcomment, cat_image = $cat_image

      4images v1.7.3
      Find:
      Code: [Select]
                  SET cat_name = '$cat_name', cat_description = '$cat_description', cat_parent_id = $cat_parent_id, cat_order = $cat_order, cat_hits = $cat_hits, auth_viewcat = $auth_viewcat, auth_viewimage = $auth_viewimage, auth_download = $auth_download, auth_upload = $auth_upload, auth_directupload = $auth_directupload, auth_vote = $auth_vote, auth_sendpostcard = $auth_sendpostcard, auth_readcomment = $auth_readcomment, auth_postcomment = $auth_postcomment
      Replace with:
      Code: [Select]
                  SET cat_name = '$cat_name', cat_description = '$cat_description', cat_parent_id = $cat_parent_id, cat_order = $cat_order, cat_hits = $cat_hits, auth_viewcat = $auth_viewcat, auth_viewimage = $auth_viewimage, auth_download = $auth_download, auth_upload = $auth_upload, auth_directupload = $auth_directupload, auth_vote = $auth_vote, auth_sendpostcard = $auth_sendpostcard, auth_readcomment = $auth_readcomment, auth_postcomment = $auth_postcomment, cat_image = $cat_image


      Step 2.3
      Find:
      Code: [Select]
        $sql = "SELECT cat_name, cat_description, cat_parent_id, cat_hits, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment
      Replace with:
      Code: [Select]
        $sql = "SELECT cat_name, cat_description, cat_parent_id, cat_hits, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment, cat_image

      4images v1.7.3
      Find:
      Code: [Select]
        $sql = "SELECT cat_name, cat_description, cat_parent_id, cat_hits, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment
      Replace with:
      Code: [Select]
        $sql = "SELECT cat_name, cat_description, cat_parent_id, cat_hits, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment, cat_image


      Step 2.4
      Find:
      Code: [Select]
        show_form_footer($lang['save_changes'], $lang['reset'], 2, $lang['back']);
      Insert above:
      Code: [Select]
      // Category image 
        $cat_image = "";
        if ($result['cat_image'])
        {
          $sql = "SELECT image_id, image_media_file, image_thumb_file, image_name, cat_id
                  FROM ".IMAGES_TABLE."
                  WHERE image_id = ".$result['cat_image'];
          if ($image_row = $site_db->query_firstrow($sql))
          {
            if (!get_file_path($image_row['image_thumb_file'], "thumb", $image_row['cat_id'], 0, 0))
            {
              $cat_image = ICON_PATH."/".get_file_extension($image_row['image_media_file']).".gif";
            }
            else
            {
              $cat_image = get_file_path($image_row['image_thumb_file'], "thumb", $image_row['cat_id'], 0, 1);
            }
            $file_info = @getimagesize($cat_image);
            $dim = 50;
            $width = $file_info[0];
            $height = $file_info[1];
            if ($width && $height) {
              if ($width > $dim || $height > $dim) {
                @$ratio = $width / $height;
                if ($ratio > 1) {
                  $new_width = $dim;
                  $new_height = round(($dim/$width) * $height);
                }else {
                  $new_width = round(($dim/$height) * $width);
                  $new_height = $dim;
                }
              }else{
                $new_width = $width;
                $new_height = $height;
              }
            }else{
              $new_width = $dim;
              $new_height = $dim;
            }
            $cat_image = "<a href=\"".$site_sess->url(ROOT_PATH."details.php?image_id=".$result['cat_image'])."\" target=\"_blank\"><img src=\"".$cat_image."\" width=\"".$new_width."\" height=\"".$new_height."\"></a>&nbsp;<a href=\"".$site_sess->url(ROOT_PATH."details.php?image_id=".$result['cat_image'])."\" target=\"_blank\">".$image_row['image_name']."</a>";
          }
         
        }
        $value = $result['cat_image'];
        if (isset($HTTP_POST_VARS['cat_image'])/* && $value == ""*/) {
          $value = stripslashes($HTTP_POST_VARS['cat_image']);
        }
        echo "<tr class=\"".get_row_bg()."\">\n<td><p class=\"rowtitle\">Category image</p></td>\n<td><p><input type=\"text\" size=\"5\" name=\"cat_image\" value=\"".$value."\">&nbsp;$cat_image</p></td>\n</tr>\n";
      //End Category image


      Step 2.5
      Find (in 4images v1.7.2 and above there are two instances of this line, find and replace both!):
      Code: [Select]
        $sql = "SELECT cat_id, cat_name, cat_description, cat_parent_id, cat_hits, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment Replace with:
      Code: [Select]
        $sql = "SELECT cat_id, cat_name, cat_description, cat_parent_id, cat_hits, cat_order, auth_viewcat, auth_viewimage, auth_download, auth_upload, auth_directupload, auth_vote, auth_sendpostcard, auth_readcomment, auth_postcomment, cat_image


      Step 2.6 (added 2006-03-13)
      This step only needed for 4images v1.7.2 (or maybe newer)! (thanks to roger13 for this find)
      Find:
      Code: [Select]
        $cat_image = "";Insert below:
      Code: [Select]
        $result = $cat_row;


      Step 3
      Open includes/functions.php
      Find:
      Code: [Select]
          if (defined("SHOW_RANDOM_IMAGE") && SHOW_RANDOM_IMAGE == 0 || defined("SHOW_RANDOM_CAT_IMAGE") && SHOW_RANDOM_CAT_IMAGE == 0) {
      Insert above:
      Code: [Select]
          $cat_image = "";
          if ($cat_cache[$category_id]['cat_image'])
          {
            $sql = "SELECT image_id, image_media_file, image_thumb_file, cat_id
                    FROM ".IMAGES_TABLE."
                    WHERE image_id = ".$cat_cache[$category_id]['cat_image'];
            if ($image_row = $site_db->query_firstrow($sql))
            {
              if (!get_file_path($image_row['image_thumb_file'], "thumb", $image_row['cat_id'], 0, 0))
              {
                $cat_image = ICON_PATH."/".get_file_extension($image_row['image_media_file']).".gif";
              }
              else
              {
                $cat_image = get_file_path($image_row['image_thumb_file'], "thumb", $image_row['cat_id'], 0, 1);
              }
            }
          }
          $site_template->register_vars("cat_image", $cat_image);




      Step 4
      Open templates/<your template>/category_bit.html
      Insert where u want the image to be displayed:
      Code: [Select]
      {if cat_image}<img src="{cat_image}">{endif cat_image}

      Note that it will not display anything if no category image was set.



      Step 5
      Download database update script
      Unpack it and upload the catimage_install.php file into your 4images root dir. Then start the updater by typing in your browser: http://<your site address>/<path to 4images>/catimage_install.php



      Step 6 (optional)
      For a better experience I'd suggest u install this mod as well (v3.5 or newer).



      ------- [ How to use it ] -------

      First method:

      Go to ACP (Admin Control Panel) -> Edit categories -> edit a cegory.
      There u should see a new field where u can manualy enter image ID which u want to use as "Category Image". If any image previously was selected, its ID and thumb with image name should be present there.

      Second method:

      Do Step 6
      Then got to ACP -> Edit images -> find an image -> edit.
      In the single image edit screen (not the group image edit!) at the bottom, u sould see a new option "Category Image (yes/no)" simply select "yes" to set that image as "Category Image".
      Also if any image was previousle set as "Category Image" u should see its thumbnail and image name.


      ------- [ Extra ] ---------
      If u wish to show something else if no "Category Image" was set, then u'll need this (for 4images v1.7) or this (for 4images v1.7.1) mod. Then in category_bit.html template u can use {ifno cat_image} and {endifno cat_image} in Step 4


      Edit :
      - 17.12.2007 : editing of the formating of this post by mawenzi

      Pages: 1 ... 3 4 5 6 [7] 8 9 10 11 ... 14