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 2 [3] 4 5 6 7 ... 14
31
Thank you ch€ri{Bi}² for discovering and reporting this bug.

If something went wrong while deleting an image in ACP (Admin Control Panel) it will show a "success" message instead of "error".

To fix that find in admin/images.php (note, this is only a part of the line):
Code: [Select]
$error_log[] = "<b>".$lang['image_delete_success']
Replace it with:
Code: [Select]
$error_log[] = "<b>".$lang['image_delete_error']

P.S.
This bug only affects default, unmodified admin/images.php

32

----------------- [ Index ] -----------------


----------------- [ Introduction ] -----------------

This mod replaces user selection drop down menu with text input field in ACP (Admin Control Panel). It will suggest user names while you type. If entered user name is not correct, administrator's will be used instead.
There is a side effect in this mod: if you type incorrect/non-existing user name and submit the forum, it will use your name instead without any warnings.

For the sake of experiment, I've tested this mod with over 2M members on my local computer. The result was: no performance lose, pages open instantly (except for "Send email" menu) and suggestions showed up with no lag.

But, unless you have lots of members, you probably don't need this mod.

P.S.
This mod uses Yahoo! UI Library: AutoComplete javascript.



----------------- [ Screenshots ] -----------------

Inline completing



Using wildcard *




----------------- [ Changed files ] -----------------

admin/admin_functions.php


----------------- [ New files ] -----------------

admin/userfind.php
admin/userfind.css



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

Step_1Download attached package. Extract files and upload them to your 4images folder, preserving this tree structure:
admin/userfind.php
admin/userfind.css


Step_2Open admin/admin_functions.php
Find:
Code: [Select]
  </head>

Insert ABOVE:
Code: [Select]
<!-- Combo-handled YUI CSS files: -->
<link rel="stylesheet" type="text/css" href="<?php echo ROOT_PATH?>admin/userfind.css">
<!-- Combo-handled YUI JS files: -->
<script type="text/javascript" src="http://yui.yahooapis.com/combo?2.6.0/build/yahoo/yahoo-min.js&2.6.0/build/event/event-min.js&2.6.0/build/connection/connection-min.js&2.6.0/build/dom/dom-min.js&2.6.0/build/datasource/datasource-min.js&2.6.0/build/autocomplete/autocomplete-min.js"></script> 


Step_2.1Find:function show_user_select_row($title$user_id$i 0) {


Replace it with:/*
MOD ajax user select
start replace

function show_user_select_row($title, $user_id, $i = 0) {
*/
$user_id_name_input "user_id";
if (isset(
$HTTP_POST_VARS['user_id_name_input']))
{
  
$user_id_name_input $HTTP_POST_VARS['user_id_name_input'];
}
if (isset(
$HTTP_POST_VARS['user_id_name_i']))
{
  
$n intval($HTTP_POST_VARS['user_id_name_i']);
  for (
$i 0$i <= $n$i++)
  {
    if (isset(
$HTTP_POST_VARS['user_id_name_'.$i]))
    {
      if (isset(
$HTTP_POST_VARS['user_id_name_array']) && $HTTP_POST_VARS['user_id_name_array'])
      {
        
$HTTP_POST_VARS[$user_id_name_input][$i] = get_user_id_by_name($HTTP_POST_VARS['user_id_name_'.$i]);
      }
      else
      {
        
$HTTP_POST_VARS[$user_id_name_input.'_'.$i] = get_user_id_by_name($HTTP_POST_VARS['user_id_name_'.$i]);
      }
    }
  }
}
elseif (isset(
$HTTP_POST_VARS['user_id_name']))
{
  
$HTTP_POST_VARS[$user_id_name_input] = get_user_id_by_name($HTTP_POST_VARS['user_id_name']);
}
function 
get_user_id_by_name($user_name)
{
  global 
$site_db$user_table_fields;
  
$sql "SELECT ".get_user_table_field("""user_id")."
          FROM "
.USERS_TABLE."
          WHERE "
.get_user_table_field("""user_name")." = '".$user_name."'";
  
$result $site_db->query_firstrow($sql);
  return @
$result['user_id'];
}

function 
show_user_select_row($title$user_id$i ""$size 0$input "user_id"$array 0$orig 0$full 1)
{
  global 
$error$lang$HTTP_POST_VARS$site_db$user_table_fields$user_select_row_cache$site_sess$textinput_size;
  
  if (
$orig)
  {
    return 
_show_user_select_row($title$user_id$i);
  }
  
$user_id_name "";
  if (isset(
$error[$input.'_'.$i]) || isset($error[$input]))
  {
    
$title sprintf("<span class=\"marktext\">%s *</span>"$title);
  }
  if (!
$size)
  {
    
$size $textinput_size;
  }
  if (!
$user_id)
  {
    
$user_id 0;
  }
  
$user_id_array = array($user_id);
  if (isset(
$HTTP_POST_VARS[$input.'_'.$i]))
  {
    
$user_id_array[] = $HTTP_POST_VARS[$input.'_'.$i];
  }
  elseif (
$array && isset($HTTP_POST_VARS[$input][$i]))
  {
    
$user_id_array[] = $HTTP_POST_VARS[$input][$i];
  }
  elseif (isset(
$HTTP_POST_VARS[$input]) && !is_array($HTTP_POST_VARS[$input]))
  {
    
$user_id_array[] = $HTTP_POST_VARS[$input];
  }
  if (isset(
$HTTP_POST_VARS['user_id_name_'.$i]))
  {
    
$user_id_name stripslashes($HTTP_POST_VARS['user_id_name_'.$i]);
  }
  elseif (isset(
$HTTP_POST_VARS['user_id_name']))
  {
    
$user_id_name stripslashes($HTTP_POST_VARS['user_id_name']);
  }
  
$sql "SELECT ".get_user_table_field("""user_name")."
          FROM "
.USERS_TABLE."
          WHERE "
.get_user_table_field("""user_id")." IN (".implode(","$user_id_array).")";
  if (
$result $site_db->query_firstrow($sql))
  {
    
$user_id_name $result['user_name'];
  }
  if (
$full)
  {
    echo 
"<tr class=\"".get_row_bg()."\">\n<td><p class=\"rowtitle\">".$title."</p></td>\n";
    echo 
"<td>\n";
  }
  if (
$input != "user_id")
  {
    echo 
"<input type=\"hidden\" name=\"user_id_name_input\" value=\"".$input."\">\n";
  }
  echo 
"<input type=\"hidden\" name=\"user_id_name_array\" value=\"".$array."\">\n";
  if (
$i !== "")
  {
    echo 
"<input type=\"hidden\" name=\"user_id_name_i\" value=\"".$i."\">\n";
    
$i "_".$i;
  }
  echo 
'<div class="yui-ac" style="width:'.($size/2).'em; padding-bottom:2em;">';
  echo 
"<input type=\"text\" name=\"user_id_name".$i."\" id=\"user_id_name".$i."\" value=\"".format_text($user_id_name2)."\" size=\"".$size."\" style=\"width:".($size/2)."em;\" class=\"yui-ac-input\">\n";
  echo 
'
	
<div id="usernameauto'
.$i.'" class="yui-ac-container" style="width:'.($size/2).'em;"></div>
</div>
<script type="text/javascript" language="javascript">
YAHOO.example.BasicRemote = function() {
    // Use an XHRDataSource
    var oDS = new YAHOO.util.XHRDataSource("'
.ROOT_PATH.'admin/userfind.php");
    // Set the responseType
    oDS.responseType = YAHOO.util.XHRDataSource.TYPE_TEXT;
    // Define the schema of the delimited results
    oDS.responseSchema = {
        recordDelim: "\n",
        fieldDelim: "\t" 
    };
    // Enable caching
    oDS.maxCacheEntries = 10;
    // Instantiate the AutoComplete
    var oAC = new YAHOO.widget.AutoComplete("user_id_name'
.$i.'", "usernameauto'.$i.'", oDS);
// Enable type ahead
    oAC.typeAhead = false;
// Enable a drop-shadow under the container element 
    oAC.useShadow = true;  
// Display up to 30 results in the container 
    oAC.maxResultsDisplayed = 30;
    return {
        oDS: oDS,
        oAC: oAC
    };
}();
</script>'
;
  if (
$full)
  {
    echo 
"</td>\n</tr>\n";
  }
}

function 
_show_user_select_row($title$user_id$i 0) {
/*
MOD ajax user select
end replace
*/




----------------- [ Tweaks ] -----------------

1. If you want inline auto complete (automatically selects and enters first name from the list) then set to true in admin/admin_functions.php:
Code: [Select]
// Enable type ahead
    oAC.typeAhead = false;


2. By default first 30 names will be showed. You can change that number in admin/admin_functions.php:
Code: [Select]
// Display up to 30 results in the container
    oAC.maxResultsDisplayed = 30;
And in admin/userfind.php:
Code: [Select]
          LIMIT 30";


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

v1.1 (2008-11-21)
- Added support for non-standard use of the function. Needed for [MOD] Batch Copy/Move/Edit Images. Redo Step 2.1

v1.0 (2008-11-21)
- First release



33
FAQ, Tips / [How to] remove image validation on upload
« on: November 04, 2008, 10:52:15 PM »
To disable image validation on upload (aka automatic validation) go to ACP -> Edit Categories -> select your category and click Edit -> set "Direct Upload" permission to the appropriate group.

34

----------------- [ Index ] -----------------


----------------- [ Introduction ] -----------------

With this mod you'll be able hide categories and/or set a password.

Hidden categories will not be visible anywhere on the site and can be accessed only by a direct link to it. By default once such category opened, it will become visible for the visitor, meaning it will not be hidden anymore for that particular visitor. This behavior can be changed.

If a category password protected, only it's name will be visible to the visitors (assuming visitor has "view category" permissions). Once visitor open it or open an image from such category, a prompt to enter the password will be showed instead. When the submitted password accepted, the category become fully accessible to the visitor, based on it's permissions. The submitted passwords are stored in the database for each member or in sessions for guests.

All subcategories inherit "hidden" and "password" settings from it's parent category.

If you have a request or suggestion, make sure you visit Tweaks section, it might be already there ;)


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

Once this mod is installed, you should see two new options when edit or create new category.


----------------- [ Demo ] -----------------

You can see how it works here. You can click on "reset cat password" link on left to reset entered password and visited hidden categories.


----------------- [ Changed files ] -----------------

global.php
details.php
categories.php
includes/auth.php
includes/page_header.php
includes/sessions.php
admin/categories.php
lang/<your language>/main.php

----------------- [ New files ] -----------------

install_catpashid.php
includes/catpass.php
templates/<your template>/catpass.html


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

Step 1
Download attached package. Extract files and upload them to your 4images folder, preserving this tree structure:
install_catpashid.php
includes/catpass.php
templates/<your template>/catpass.html


Step 2
Execute install_catpashid.php by typing in your browser's address bar:
http://yourdomain/4images/install_catpashid.php


Step 3
Open global.php
Find:  $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:  $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_password, cat_hide

(or simply add , cat_password, cat_hide at the end of that line)

Step 4
Open details.php
Find:$cat_id = (isset($image_row['cat_id'])) ? $image_row['cat_id'] : 0;

Insert BELOW:
cat_unhide($cat_id);



Step 4.1 
Find:if (!check_permission("auth_viewcat"$cat_id) || !check_permission("auth_viewimage"$cat_id) || !$image_row) {
  
redirect($url);
}

Insert BELOW:
$txt_clickstream get_category_path($cat_id,1).$config['category_separator'].format_text($image_row['image_name'], 2).$config['category_separator'];
include(
ROOT_PATH."includes/catpass.php");



Step 5
Open categories.php
Find:$user_access get_permission();

Insert BELOW:
cat_unhide($cat_id);



Step 5.1 
Find:if (!$cat_id || !isset($cat_cache[$cat_id]) || !check_permission("auth_viewcat"$cat_id)) {
  
redirect("index.php");
}

Insert BELOW:
include(ROOT_PATH."includes/catpass.php");



Step 6
Open includes/auth.php
Find:function check_permission($type$cat_id 0) {

Replace it with:function cat_unhide($cat_id$save 1)
{
  global 
$cat_cache$site_sess$user_info$site_db$cat_parent_cache;
  if (!isset(
$cat_cache[$cat_id]))
    return;

  if (isset(
$cat_cache[$cat_id]['auth_viewcat_backup']))
    
$cat_cache[$cat_id]['auth_viewcat'] = $cat_cache[$cat_id]['auth_viewcat_backup'];

  
$cat_subcat_ids get_auth_subcat_ids($cat_id$cat_id$cat_parent_cache);
  if (isset(
$cat_subcat_ids[$cat_id]))
  {
    foreach (
$cat_subcat_ids[$cat_id] as $key2 => $val2)
    {
      if (
$cat_cache[$val2]['auth_viewcat'] < $cat_cache[$cat_id]['auth_viewcat']
            && (!
$cat_cache[$val2]['cat_hide']
                  || (
$cat_cache[$val2]['cat_hide'] && isset($user_info['cat_hide'][$val2]))))
      {
        
$cat_cache[$val2]['auth_viewcat'] = $cat_cache[$cat_id]['auth_viewcat'];
      }
    }
  }
  if (
$cat_cache[$cat_id]['cat_hide'])
  {
    if (isset(
$user_info['cat_hide'][$cat_id]))
      return;

    
$user_info['cat_hide'][$cat_id] = "";
    if (!
$save)
      return;

    if (
$user_info['cat_hide_db'])
    {
      
$sql "UPDATE ".USERS_TABLE." SET cat_hide = '".implode("|"array_keys($user_info['cat_hide']))."' WHERE ".get_user_table_field("""user_id")." = ".$user_info['user_id'];
      
$site_db->query($sql);
    }
    else
    {
      
$site_sess->set_session_var("cathide"implode("|"array_keys($user_info['cat_hide'])));
    }
  }
  else
  {
    if (
$cat_cache[$cat_id]['cat_parent_id'] != 0)
    {
//uncomment next line if you want unhide parent category when opened child category.
//      cat_unhide($cat_cache[$cat_id]['cat_parent_id'], $save);
    
}
  }
  
}

function 
cat_pass_check($cat_id)
{
  global 
$user_info$site_sess$cat_cache;
  if (
$user_info['user_level'] == ADMIN)
    return 
true;

  if (isset(
$cat_cache[$cat_id]['cat_password_id']))
    
$cat_id $cat_cache[$cat_id]['cat_password_id'];

  if (!isset(
$cat_cache[$cat_id]['cat_password']) || !$cat_cache[$cat_id]['cat_password'])
    return 
true;

  return (isset(
$user_info['cat_password'][$cat_id]) && $cat_cache[$cat_id]['cat_password'] == $user_info['cat_password'][$cat_id]) ? true false;
}

function 
check_permission($type$cat_id 0) {
  global 
$user_info$cat_cache;
  if (!
_check_permission($type$cat_id) && $cat_cache[$cat_id][$type] != 999)
  {
    return 
false;
  }
  if (
$type != "auth_viewcat")
  {
    return 
true;
  }
  if (
$user_info['user_level'] != ADMIN && $cat_cache[$cat_id][$type] == 999)
  {
    return 
false;
  }
  return 
true;
}

function 
_check_permission($type$cat_id 0) {



Step 6.1 
Find:    if ($val['auth_viewcat'] != AUTH_ALL) {

Replace it with:    if ($val['cat_hide'] && !isset($user_info['cat_hide'][$key]))
    {
      
$cat_cache[$key]['auth_viewcat_backup'] = $val['auth_viewcat'];
      
$cat_cache[$key]['auth_viewcat'] = $val['auth_viewcat'] = 999;
    }
    if (
$val['auth_viewcat'] != AUTH_ALL || $val['cat_password']) {



Step 6.2 
Find:        foreach ($cat_subcat_ids[$key] as $key2 => $val2) {

Insert BELOW:
          if (!$cat_cache[$val2]['cat_password'] && $cat_cache[$key]['cat_password']) //all subcategories also should obbey cat password from parent
          
{
            
$cat_cache[$val2]['cat_password'] = $cat_cache[$key]['cat_password'];
            
$cat_cache[$val2]['cat_password_id'] = (isset($cat_cache[$key]['cat_password_id'])) ? $cat_cache[$key]['cat_password_id'] : $key;
          }
          if (
$val['auth_viewcat'] == 999)
          {
            if (
$cat_cache[$val2]['cat_hide'] && isset($user_info['cat_hide'][$val2]) && $cat_cache[$val2]['auth_viewcat'] < $cat_cache[$key]['auth_viewcat'])
            {
              
$cat_cache[$val2]['auth_viewcat'] = $cat_cache[$key]['auth_viewcat_backup'];
              continue;
            }
            
$cat_cache[$val2]['auth_viewcat_backup'] = $cat_cache[$key]['auth_viewcat_backup'];
          }



Step 6.3 
Find:    if (!check_permission($type$key)) {

Replace it with:    if (!check_permission($type$key) || !cat_pass_check($key)) {



Step 7
Open includes/page_header.php
Find:      if (check_permission("auth_viewcat"$key)) {

Replace it with:      if (check_permission("auth_viewcat"$key) && cat_pass_check($key)) {



Step 8   
Open includes/sessions.php
Find:$user_info $site_sess->return_user_info();

Insert BELOW:
$user_info['cat_password_db'] = true//set to false to use only sessions to store passwords
$user_info['cat_hide_db'] = true//set to false to use only sessions to store visited hidden categories
if ($user_info['user_level'] == GUEST || !isset($user_info['cat_password']) || ($user_info['user_level'] != GUEST && !$user_info['cat_password_db']))
{
  
$cat_pass trim($site_sess->get_session_var("catpass"));
  
$user_info['cat_password_db'] = false;
}
else
{
  
$cat_pass $user_info['cat_password'];
  
$user_info['cat_password_db'] = true;
}
$user_info['cat_password'] = array();
$cat_pass explode("|"$cat_pass);
foreach(
$cat_pass as $key)
{
  
$val explode(","$key);
  if (
count($val) > && $val[0] = (int)$val[0])
    
$user_info['cat_password'][$val[0]] = $val[1];
}

if (
$user_info['user_level'] == GUEST || !isset($user_info['cat_hide']) || ($user_info['user_level'] != GUEST && !$user_info['cat_hide_db']))
{
  
$cat_hide trim($site_sess->get_session_var("cathide"));
  
$user_info['cat_hide_db'] = false;
}
else
{
  
$cat_hide $user_info['cat_hide'];
  
$user_info['cat_hide_db'] = true;
}
$user_info['cat_hide'] = array();
$cat_hide explode("|"$cat_hide);
foreach(
$cat_hide as $key)
{
  if (
$key = (int)$key)
    
$user_info['cat_hide'][$key] = "";
}



Step 9
Open admin/categories.php
Find two (2) times:
  $auth_postcomment $HTTP_POST_VARS['auth_postcomment'];

Insert BELOW each:
  $cat_password un_htmlspecialchars(trim($HTTP_POST_VARS['cat_password']));
  
$cat_hide intval($HTTP_POST_VARS['cat_hide']);



Step 9.1 
Find:    $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 it with:    $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_password, cat_hide)
            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_password', $cat_hide)";



Step 9.2 
Find:  show_table_separator($permission_headline2);

Insert ABOVE:
  show_radio_row($lang['cat_hide'], "cat_hide"0);
  
show_input_row($lang['cat_password'], "cat_password"""$textinput_size);



Step 9.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 it 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_password = '$cat_password', cat_hide = $cat_hide


Step 9.4 
Find:  $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 it with:  $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_password, cat_hide



Step 9.5 
Find:  show_input_row($lang['field_hits'], "cat_hits"$cat_row['cat_hits'], 5);

Insert BELOW:
  show_radio_row($lang['cat_hide'], "cat_hide"$cat_row['cat_hide']);
  
show_input_row($lang['cat_password'], "cat_password"$cat_row['cat_password'], $textinput_size);


Step 9.6 
Find:    show_text_link($lang['add_subcategory'], "categories.php?action=addcat&cat_parent_id=".$cats['cat_id']);
Insert below:
    if ($cats['cat_hide'] || $cats['cat_password'])
    {
      echo 
"&nbsp;&nbsp;&nbsp;&nbsp;<b>(";
      if (
$cats['cat_hide'])
      {
        echo 
$lang['cat_hidden'];
      }

      if (
$cats['cat_password'])
      {
        echo ((
$cats['cat_hide']) ? ", " "").$lang['cat_password2'];
      }

      echo 
")</b>";
    }


Step 9.7 
Find two times:$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 both with:
$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_hide, cat_password


Step 10   
Open lang/<your language>/main.php
At the end, ABOVE closing ?> insert:
$lang['cat_hide'] = "Hidden";
$lang['cat_password'] = "Category password";
$lang['cat_password_msg'] = "This category is password protected.<br />Please enter the password";
$lang['cat_password_error'] = "You have entered incorrect password";
$lang['cat_hidden'] = "hidden";
$lang['cat_password2'] = "password";





Tweaks and version history in the next reply.

35
If a website uses non-standard port (i.e. http://example.com:12345/4images) redirects (i.e. after login or logout) won't work on some browsers (Internet Explorer, Google Chrome).

The problem is in $_SERVER['HTTP_HOST'] which might contain the port number.

To fix this find in global.php:
  $script_url .= (!empty($HTTP_SERVER_VARS['HTTP_HOST'])) ? $HTTP_SERVER_VARS['HTTP_HOST'] : getenv("SERVER_NAME");


Insert BELOW:
  if ($port$script_url str_replace($port""$script_url);

36
If you see error message similar to:
Quote
Parse error: syntax error, unexpected $end in includes/template.php(101) : eval()'d code on line 160
This means one or more template files have not matching number of {if ..} and {endif ..} or {ifno ..} and {endifno ..} template tags ( ".." is the name of a tag, i.e. {if blahexample} and {endif blahexample})
Such error didn't show on 4images v1.7, so if your template worked on v1.7 and after 4images upgrade it shows this error, it means your template is not compatible with new 4images, read next how you can make your template compatible.

What you'll need to do is search in all .html template files for all {if ..} and {ifno ..} tags and make sure they have matching {endif ..} and {endifno ..} tags.
Also, the number of {if ..} and {ifno ..} must be equal to number of {endif ..} and {endifno ..} tags in each template file.

For example this is wrong, because it has only one {if ..} and two {endif ..} tags:
Code: [Select]
{if blahexample}
....some html stuff....
{endif blahexample}
...some more html stuff...
{endif blahexample}

Or change template.

37
After login 4images redirects to index.php instead of the same page the visitor logged in at.

In global.php find:
  $url get_basefile(getenv("HTTP_REFERER"));


Replace it with:
  $url get_basename(getenv("HTTP_REFERER"));

38
Chit Chat / "Deutsch" = "English" according to google...
« on: October 07, 2008, 04:00:22 PM »
Quote
gibt es hier eine Anleitung in "Deutsch"?

Google translation:
Quote
There is an instruction to "English"?

http://translate.google.com/translate_t?hl=en#de|en|gibt%20es%20hier%20eine%20Anleitung%20in%20%22Deutsch%22%3F

Weird... :lol:

39
Templates & Styles (Releases & Support) / [MOD] reCAPTCHA
« on: October 03, 2008, 03:57:30 AM »
This mod will replace 4images default captcha graphic with more advanced reCAPTCHA

Step 1
Register at http://recaptcha.net
Once registered, go to "My account" -> "My sites" and add each domain where you want use reCAPTCHA.
Then go to "My account" -> "My sites" and click on each domain you've added, it will show you Public Key and Private Key, write them down, you'll need them in next step.

Download PHP plugin, extract it and upload recaptchalib.php into 4images includes/ folder




Step 2
Open global.php
Find:
$captcha_filter_bg           1;


Insert BELOW:
$captcha_recaptcha           1//0 = disable; 1 = enable with auto domain select; "yourdomain" = for one specific domain only, this domain must be specified in $recaptcha_domains below
//$captcha_recaptcha           = "yourdomain2"; //use only reCAPTCHA keys for yourdomain2

$recaptcha_domains['yourdomain1'] = array("public key for yourdomain1""private key for yourdomain1");
/*//to add more then one domain:
$recaptcha_domains['example.com']   = array("public key for example.com", "private key for example.com");
$recaptcha_domains['4homepages.de'] = array("asdfasdfasdf", "a98sd7as9df7as");
$recaptcha_domains['google.com']    = array("23kj423h42k", "8fas9d8a9sdf9a");
*/
if ($captcha_enable && $captcha_recaptcha
    
&& (isset($recaptcha_domains[$captcha_recaptcha])
          || isset(
$recaptcha_domains[strtolower($_SERVER["HTTP_HOST"])])))
{
  
$captcha_recaptcha = (isset($recaptcha_domains[$captcha_recaptcha]))
                          ? 
$recaptcha_domains[$captcha_recaptcha]
                          : 
$recaptcha_domains[strtolower($_SERVER["HTTP_HOST"])];
}
else
{
  
$captcha_recaptcha 0;
}


In the code you just inserted update $recaptcha_domains['yourdomain1'] = array("public key for yourdomain1""private key for yourdomain1"); with the correct data, yourdomain1 replace with the domain name of your website.  public key for yourdomain1 and private key for yourdomain1 with the public and private keys from Step 1.
You can add as many domains as you wish.




Step 3
Open includes/captcha_utils.php
Find:
$captcha_enable $captcha_enable && function_exists("imagecreatetruecolor") && function_exists("imagecopyresampled");


Replace it with:function recaptcha_image()
{
  global 
$captcha_recaptcha;
  if (
$captcha_recaptcha)
  {
    require_once(
ROOT_PATH 'includes/recaptchalib.php');
    return 
recaptcha_get_html($captcha_recaptcha[0]);
  }
}
if (!
$captcha_recaptcha)
{
  
$captcha_enable $captcha_enable && function_exists("imagecreatetruecolor") && function_exists("imagecopyresampled");
}




Step 3.1
Find:
  $sess_code trim($site_sess->get_session_var('captcha'));


Insert ABOVE:
  global $captcha_recaptcha$HTTP_POST_VARS;
  if (
$captcha_recaptcha)
  {
    require_once(
ROOT_PATH 'includes/recaptchalib.php');
    
$resp recaptcha_check_answer ($captcha_recaptcha[1],
                                    
$_SERVER["REMOTE_ADDR"],
                                    
$HTTP_POST_VARS["recaptcha_challenge_field"],
                                    
$HTTP_POST_VARS["recaptcha_response_field"]);
    
    if (
$resp->is_valid)
      return 
true;
  }





Step 4
Open includes/page_header.php
Find:
  "url_captcha_image" => $site_sess->url(ROOT_PATH."captcha.php"),


Insert BELOW::
  "recaptcha" => ($captcha_recaptcha) ? recaptcha_image() : "",
  
"recaptcha_public" => @$captcha_recaptcha[0],
  
"recaptcha_private" => @$captcha_recaptcha[1],





Step 5
In templates comment_form.html, member_uploadform.html, postcard_preview.html, register_form.html and in any others where you were using captcha, use this tag:
{recaptcha}
If you wish to customize reCAPTCHA view to match your site theme or whatever, you probably will need do it via javascript (don't ask me how, I don't know), in that case you might need public or private key, for that you can use these tags:
{recaptcha_public}
{recaptcha_private}


P.S.
You can use both 4images built-in captcha and reCAPTCHA at the same time if you wish.

40
Chit Chat / Forum software updated to v1.1.6
« on: September 28, 2008, 10:21:44 AM »
This forum software has been updated.
Because of some custom modifications the update could possible break something. If you see errors or something strange, please report it here.

Thank you.

41
This bug doesn't affect 4images itself, only possibly some MODs.

$additinal_user_fields array not being used for guests, and $user_info array will contain only default 4images fields, which might through out warning messages in some MODs.

The fix is simple:
in includes/sessions.php find:

    return $user_info;


Insert ABOVE:
    global $additional_user_fields;
    foreach (
$additional_user_fields as $key => $val)
    {
      if (!isset(
$user_info[$key]))
      {
        
$user_info[$key] = "";
      }
    }

42
Error Messages / Fehlermeldungen / Unknown column 'i.user_id' in 'on clause'
« on: September 07, 2008, 01:39:52 PM »
This error occur when used 4images v1.7 / 1.7.1 (and/or some old mods) and MySQL v5.x
It caused by the changes in MySQL v5 handling multiple tables on one query.
If your 4images is newer then v1.7.1 and you still get these errors, then you must have installed a mod that is not MySQL v5 compatible.

There are three ways fix the problem:
1) Downgrade MySQL to v3 or v4
2) Upgrade your 4images
3) In .php files replace all
FROM table1 ref, table2 ref

with:
FROM (table1 ref, table2 ref)


There are quiet a few places needs to be fixed, so I'd recommend use a text editor which allows use unix regular expressions to search and modify files.

This REGEX string I've used in UltraEdit:
Code: [Select]
(FROM\s+)("\.[A-Z_]+\."\s+[a-z]+,\s*"\.[A-Z_]+\."\s+[a-z]+)and in replacing string used:
Code: [Select]
\1(\2)
it worked quiet well. That editor allows search and replace string in files without opening them in the editor, which would be the fastest way, however I'd strongly recommend do a complete backup of all .php files before you attempt doing it.

I corrected this problem by running a perl command from the shell in the 4images root dir, the \admin dir and the \includes dir:

Code: [Select]
perl -pi '-es/(FROM\s+)("\.[A-Z_]+\."\s+[a-z]+,\s*"\.[A-Z_]+\."\s+[a-z]+)/$1($2)/g' *.php
This might be useful for people without access to Ultraedit.
Remember to BACK UP everything before you try this!


If you don't have such editor or for any other reasons can't use that REGEX, prepare yourself for a long journey modifying almost all 4images files manually.
The list below is only for non-modified 4images v1.7 / 1.7.1 That means if after fixing all these files you still getting errors there are only two reasons:
1) you missed a modification
2) you've installed a mod that also not MySQL v5 compatible.

In any case you'll need find and fix the problem yourself.

Hopefully after looking at the list below you'll understand what has to be changed.

Good luck.

Find in categories.php:
Code: [Select]
FROM ".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." cReplace with:
Code: [Select]
FROM (".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c)

Find in details.php:
Code: [Select]
FROM ".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." cReplace with:
Code: [Select]
FROM (".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c)

Find in index.php:
Code: [Select]
FROM ".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." cReplace with:
Code: [Select]
FROM (".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c)

Find in lightbox.php:
Code: [Select]
FROM ".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." cReplace with:
Code: [Select]
FROM (".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c)


Find in member.php (4 times):
Code: [Select]
FROM ".COMMENTS_TABLE." c, ".IMAGES_TABLE." iReplace with:
Code: [Select]
FROM (".COMMENTS_TABLE." c, ".IMAGES_TABLE." i)

Find in postcards.php:
Code: [Select]
FROM ".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." cReplace with:
Code: [Select]
FROM (".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c)


Find in postcards.php:
Code: [Select]
FROM ".POSTCARDS_TABLE." p, ".IMAGES_TABLE." iReplace with:
Code: [Select]
FROM (".POSTCARDS_TABLE." p, ".IMAGES_TABLE." i)


Find in search.php:
Code: [Select]
FROM ".WORDLIST_TABLE." w, ".WORDMATCH_TABLE." mReplace with:
Code: [Select]
FROM (".WORDLIST_TABLE." w, ".WORDMATCH_TABLE." m)

Find in search.php:
Code: [Select]
FROM ".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." cReplace with:
Code: [Select]
FROM (".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c)

Find in top.php (4 times):
Code: [Select]
FROM ".IMAGES_TABLE." i, ".CATEGORIES_TABLE." cReplace with:
Code: [Select]
FROM (".IMAGES_TABLE." i, ".CATEGORIES_TABLE." c)

Find in admin\comments.php:
Code: [Select]
FROM ".COMMENTS_TABLE." c, ".IMAGES_TABLE." iReplace with:
Code: [Select]
FROM (".COMMENTS_TABLE." c, ".IMAGES_TABLE." i)


Find in admin\home.php:
Code: [Select]
FROM ".USERS_TABLE." u, ".SESSIONS_TABLE." sReplace with:
Code: [Select]
FROM (".USERS_TABLE." u, ".SESSIONS_TABLE." s)

Find in admin\usergroups.php:
Code: [Select]
FROM ".GROUPS_TABLE." g, ".GROUP_MATCH_TABLE." gmReplace with:
Code: [Select]
FROM (".GROUPS_TABLE." g, ".GROUP_MATCH_TABLE." gm)

Find in includes\auth.php:
Code: [Select]
FROM ".GROUP_ACCESS_TABLE." a, ".GROUP_MATCH_TABLE." mReplace with:
Code: [Select]
FROM (".GROUP_ACCESS_TABLE." a, ".GROUP_MATCH_TABLE." m)


Find in includes\functions.php (2 times):
Code: [Select]
FROM ".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." cReplace with:
Code: [Select]
FROM (".IMAGES_TABLE." i,  ".CATEGORIES_TABLE." c)

Find in includes\sessions.php:
Code: [Select]
FROM ".USERS_TABLE." u, ".LIGHTBOXES_TABLE." lReplace with:
Code: [Select]
FROM (".USERS_TABLE." u, ".LIGHTBOXES_TABLE." l)

43
When a user deleted with their comments, the comments count in each image not being updated.

In admin/users.php find:

    if ($delcomments) {


Insert BELOW:

      $sql "SELECT i.image_id, COUNT(c.comment_id) AS count
              FROM " 
IMAGES_TABLE " i
              LEFT JOIN " 
COMMENTS_TABLE " c ON c.image_id = i.image_id
              WHERE c.user_id = " 
$user_id "
              GROUP BY i.image_id"
;
      
$result $site_db->query($sql);
      while(
$row $site_db->fetch_array($result))
      {
        
$sql "UPDATE " IMAGES_TABLE "
                SET image_comments = image_comments - " 
$row['count'] ."
                WHERE image_id = " 
$row['image_id'];
        
$site_db->query($sql);
      }



If your comments count not messed up you don't need do anything else, but for these who's comments count different from actual count you can run this MySQL query in phpmyadmin:
Code: (MySQL) [Select]
UPDATE 4images_images i
SET i.image_comments = (SELECT COUNT(comment_id) FROM 4images_comments WHERE image_id = i.image_id)

If the query above didn't work for you, download attached file, extract update_comments_count.php from the package and upload it to your 4images root directory then run it by typing in your browser: http://yoursiteaddress/4images/update_comments_count.php
After that delete the file.

44
FAQ, Tips / CAPTCHA (verification code) related
« on: September 19, 2006, 02:09:25 PM »
This is a very basic FAQ about CAPTCHA. For more info please read docs/CAPTCHA.txt from 4images package.

Q: What is CAPTCHA?
A: A CAPTCHA (an acronym for "Completely Automated Public Turing test to tell Computers and Humans Apart") is a type of challenge-response test used in computing to determine whether or not the user is human. (you can find more info about it here)

Q: Where CAPTCHA being used in 4images?
A: By default the following forms can be protected by CAPTCHA:
  • Registration
  • E-Cards
  • Comments
  • Image-Upload

Q: How do I enable/disable CAPTCHA or how do I control it?
A: You can control the CAPTCHA system in your config.php by inserting the following configuration variables above closing
  • $captcha_enable = 1;
    A value of 1 enables the CAPTCHA system, 0 disables it.
    Default value is 1.

  • $captcha_enable_comments = 1;
    A value of 1 enables the CAPTCHA system for the comments
    form, 0 disables it.
    Default value is 1.

  • $captcha_enable_upload = 1;
    A value of 1 enables the CAPTCHA system for the upload
    form, 0 disables it.
    Default value is 1.

  • $captcha_enable_registration = 1;
    A value of 1 enables the CAPTCHA system for the
    registration form, 0 disables it.
    Default value is 1.

  • $captcha_enable_postcards = 1;
    A value of 1 enables the CAPTCHA system for the e-cards
    form, 0 disables it.
    Default value is 1.

  • $captcha_path = './captcha';
    Path to the folder which contains the CAPTCHA files
    (backgrounds, fonts).

  • $captcha_chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
    A list of letters which will be used for the
    randomly generated CAPTCHA strings
    Default value is "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".

  • $captcha_length = 5;
    Number of letters of the CAPTCHA strings
    Default value is 5.

  • $captcha_wordfile = 0;
    If this option is set to 1, a word from
    "captcha/wordlist.txt" is used.
    Default value is 0.

  • $captcha_width = 200;
    Width of the CAPTCHA image in pixel.
    Default value is 200.

  • $captcha_height = 70;
    Height of the CAPTCHA image in pixel.
    Default value is 70.

  • $captcha_text_color = "#000000";
    Color (Hex) of the CAPTCHA text.
    Default value is "#000000" (black).

  • $captcha_text_size = 25;
    Size of the CAPTCHA text.
    Default value is 25.

  • $captcha_text_transparency = 60;
    Transparency of the CAPTCHA text.
    Default value is 60.

  • $captcha_filter_text = 1;
    If this option is set to 1, the CAPTCHA text will
    be filtered ("obscured").
    Default value is 1.

  • $captcha_filter_bg = 1;
    If this option is set to 1, the CAPTCHA background
    image will be filtered ("obscured").
    Default value is 1.

Q: Why I cannot see CAPTCHA image?
A: There are several possible reasons:
  • CAPTCHA is disabled. Look previous question for more info.
  • You are using an old/custom template that does not support CAPTCHA. You can find detailed template changes here
  • Your server does not support GD library. If you look in phpinfo() and can't find anything about GD, then most probably its not installed/enabled on your server. In that case contact your host's administrator. Until they enable/install GD you won't have other choice but disable CAPTCHA feature (see above)
  • Some FTP programms gernerate a log file after uploading files to a server. Make sure that in the directory /captacha/backgrounds/ on your server are ONLY the background images for the CAPTCHA and not any other files like wsftp.log, thumbs.db, etc.
  • You are logged in as admin. Administrators don't have to enter verifications codes

Q: How can I change the look of the captcha images?
A: [TUT] Change of the CAPTCHA-Design
or
[MOD] reCAPTCHA

45
Bug Fixes & Patches / [1.7] Blank upload image page
« on: September 18, 2006, 08:31:07 AM »
This only happend on servers with PHP v5.
You'll need apply the following fix:
[1.7] PHP5 compatible

Pages: 1 2 [3] 4 5 6 7 ... 14