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 ... 14
16
Chit Chat / Google page translation doesn't work anymore?
« on: July 24, 2009, 05:57:08 PM »
I just noticed when a topic has two different languages, google page translation doesn't translate the second language...
example:
http://www.4homepages.de/forum/index.php?topic=25386.0
and translation:
http://translate.google.com/translate?prev=hp&hl=en&js=y&u=http%3A%2F%2Fwww.4homepages.de%2Fforum%2Findex.php%3Ftopic%3D25386.0&sl=es&tl=en&history_state0=&num=50

is it just me, or google screwed something up?

17
FAQ, Tips / UNICODE / UTF8 / UTF16 related
« on: July 09, 2009, 05:15:00 PM »
Technically UNICODE, UTF8 and UTF16 are little different from each other, but all of them are multi-byte encodings. For the end user (You) such technical details are not important, so in this topic to save time and typing I will refer to all these encodings as one type: UNICODE


There are few aspects needs to be remember when you work with UNICODE and 4images / PHP:

1) your editor must have ability save files without BOM. Windows' "Notepad" and "Wordpad" don't have such option, so do not use them. There are plenty of free text/php editors that you can use (a few to mention: notepad++, notepad2)
If you save files with BOM, you might get bunch of errors, example:
Quote

Warning: Cannot modify header information - headers already sent by (output started at /4images/yourfile.php:1) in /4images/admin/admin_functions.php on line 168

Some editors (UltraEdit) might have problem saving UNICODE files without BOM if original file was saved with BOM. The work around is create a new file, copy text from the original file and then save the new file without BOM.


2) 4images does NOT support .html templates saved in UNICODE. Template files must be saved in ASCII (single byte) encoding.




P.S.
This topic will be updated as more information become available.

18
This little bug affects all 3 templates that came with 4images.

In
templates/default/postcard_preview.html
templates/default_960px/postcard_preview.html
templates/default_full/postcard_preview.html

Find:
Code: [Select]
                    <font face="{font_face}" color="{font_color}" size="2">{message_hidden}</font> <br />
Replace with:
Code: [Select]
                    <font face="{font_face}" color="{font_color}" size="2">{message}</font> <br />

19
Bug Fixes & Patches / [1.7 - 1.7.6] Security fix in global.php
« on: April 02, 2009, 03:27:36 PM »
In global.php find:

4images version 1.7

if (isset($HTTP_GET_VARS['l']) || isset($HTTP_POST_VARS['l'])) {
  
$l = (isset($HTTP_GET_VARS['l'])) ? trim($HTTP_GET_VARS['l']) : trim($HTTP_POST_VARS['l']);
  if (
file_exists(ROOT_PATH.'lang/'.$l.'/main.php')) {
    
$config['language_dir'] = $l;
  }
}


Replace it with:

$l null;
if (isset(
$HTTP_GET_VARS['l']) || isset($HTTP_POST_VARS['l'])) {
  
$requested_l = (isset($HTTP_GET_VARS['l'])) ? trim($HTTP_GET_VARS['l']) : trim($HTTP_POST_VARS['l']);
  if (!
preg_match('#\.\.[\\\/]#'$requested_l) && $requested_l != $config['language_dir'] && file_exists(ROOT_PATH.'lang/'.$requested_l.'/main.php')) {
    
$l $requested_l;
    
$config['language_dir'] = $l;
  }
}





4images version 1.7.1 - 1.7.6

  if ($requested_l != $config['language_dir'] && file_exists(ROOT_PATH.'lang/'.$requested_l.'/main.php')) {

Replace it with:

  if (!preg_match('#\.\.[\\\/]#'$requested_l) && $requested_l != $config['language_dir'] && file_exists(ROOT_PATH.'lang/'.$requested_l.'/main.php')) {





For these who installed [MOD] Language select with cookies support and can't find anything mentioned above, then you'll need find in global.php:

if (isset($HTTP_GET_VARS['l']) || isset($HTTP_POST_VARS['l'])) {
  
$l = (isset($HTTP_GET_VARS['l'])) ? trim($HTTP_GET_VARS['l']) : trim($HTTP_POST_VARS['l']);
  if (
file_exists(ROOT_PATH.'lang/'.$l.'/main.php')) {
    
$config['language_dir'] = $l;
    
setcookie('4images_lang'$l, (time()+ 60 60 24 365), "/"""0);
  }
}
else
{
  if (isset(
$HTTP_COOKIE_VARS['4images_lang']) && file_exists(ROOT_PATH.'lang/'.$HTTP_COOKIE_VARS['4images_lang'].'/main.php'))
  {
    
$l $config['language_dir'] = $HTTP_COOKIE_VARS['4images_lang'];
  }
}


And replace it with:

if (isset($HTTP_GET_VARS['l']) || isset($HTTP_POST_VARS['l'])) {
  
$requested_l = (isset($HTTP_GET_VARS['l'])) ? trim($HTTP_GET_VARS['l']) : trim($HTTP_POST_VARS['l']);
  if (!
preg_match('#\.\.[\\\/]#'$requested_l) && file_exists(ROOT_PATH.'lang/'.$requested_l.'/main.php')) {
    
$l $requested_l;
    
$config['language_dir'] = $l;
    
setcookie('4images_lang'$l, (time()+ 60 60 24 365), "/"""0);
  }
}
else
{
  if (isset(
$HTTP_COOKIE_VARS['4images_lang']) && !preg_match('#\.\.[\\\/]#'$HTTP_COOKIE_VARS['4images_lang']) && file_exists(ROOT_PATH.'lang/'.$HTTP_COOKIE_VARS['4images_lang'].'/main.php'))
  {
    
$l $config['language_dir'] = $HTTP_COOKIE_VARS['4images_lang'];
  }
}

(I've already updated the code in the mentioned mod with this fix)




P.S.
thanks to 4dabdura for reporting this bug and Jan for providing us with the fix.

20
This bug allows members set blank passwords at "change password" form (credit goes to komsho24 and Nicky for reporting this bug)

In members.php find:
  $user_password md5(trim($HTTP_POST_VARS['user_password']));
  
$user_password2 md5(trim($HTTP_POST_VARS['user_password2']));


Replace it with:
  $user_password trim($HTTP_POST_VARS['user_password']);
  
$user_password2 trim($HTTP_POST_VARS['user_password2']);


Then find a few lines below:
            SET ".get_user_table_field("", "user_password")." '$user_password'

Replace it with:
            SET ".get_user_table_field("", "user_password")." '".md5($user_password)."' 

21
nuzecast discovered a bug in search engine, that does not ignore "common" words during search (words such as "the", "are", "by", etc). The bug seems only affect english language pack that comes with 4images.
The bug is actually not in the code, but in misspelling the file with stop terms list.
The fix is simple - rename:
lang/english/stop_searchterms.txt
to this:
lang/english/search_stopterms.txt

22
This is not a bug per-se, but more like a missing feature. The additional image fields not being showed at random image / random cat image

The fix is:

in includes/functions.php find:
  $random_image_cache = array();

Insert below:
  global $additional_image_fields;
  
$additional_sql "";
  if (!empty(
$additional_image_fields)) {
    foreach (
$additional_image_fields as $key => $val) {
      
$additional_sql .= ", i.".$key;
    }
  }


Then find:
Code: (PHP/MySQL) [Select]
    $sql = "SELECT DISTINCT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits, c.cat_name".get_user_table_field(", u.", "user_name")."
Replace with:
Code: (PHP/MySQL) [Select]
    $sql = "SELECT DISTINCT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits, c.cat_name".get_user_table_field(", u.", "user_name").$additional_sql."

Next find:
Code: (PHP/MySQL) [Select]
    $sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits, c.cat_name".get_user_table_field(", u.", "user_name")."
Replace with:
Code: (PHP/MySQL) [Select]
    $sql = "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_description, i.image_keywords, i.image_date, i.image_active, i.image_media_file, i.image_thumb_file, i.image_download_url, i.image_allow_comments, i.image_comments, i.image_downloads, i.image_votes, i.image_rating, i.image_hits, c.cat_name".get_user_table_field(", u.", "user_name").$additional_sql."

23
This error indicates that there is not enough memory allowed per script.
Usually this occur when processing images (resizing, creating thumbnails)

Your only solutions are:

1) create thumbnails manually and upload them with the image (or add them later) (same applied to image resizing)
2) try use ImageMagic or NetPBM instead of GD (for information about executable paths contact your host's administrator)
3) ask your server's administrator increase memory limit (good luck on this one)
4) find another host.

24
This error shows when something went wrong in database querying.

Normally such error shows for non-admin members and guests, so if that is the case, try login as admin and see if any details about the error revealed.

If login is not possible or no error shows for admin, you can do the following:

in includes/db_mysql.php find:

        echo "<br /><font color='#FF0000'><b>An unexpected error occured. Please try again later.</b></font><br />";

Replace it with:
        echo "<br /><span onclick=\"if(event.altKey)this.getElementsByTagName('SPAN')[0].style.display='block';\"><font color='#FF0000'><b>An unexpected error occured. Please try again later.</b></font><span style=\"display:none;\"><pre style=\"border:1px solid black;padding:3px;\">".$errmsg."</pre></span></span><br />";


Now when such error shows, press and hold ALT key and click on the red message, it should show you more detailed message.
Or you can highlight the error message, copy it into clipboard and then paste into a text editor.

Once the problem was solved I would recommend you remove these changes, because the detailed error message could possible be used to hack your site.

[EDIT]
If you receive that error during 4images installation process, then find:
      if (isset($user_info['user_level']) && $user_info['user_level'] == ADMIN){

Replace it with:
      if (!defined("4IMAGES_ACTIVE") || (isset($user_info['user_level']) && $user_info['user_level'] == ADMIN)){

25
Chit Chat / Useful Firefox extensions
« on: February 09, 2009, 05:33:25 AM »
This list is just a few of many I use personally (69 to be exact :)). I don't want to post any everybody-already-know extensions, such as ABP or Tab Mix Plus, but a few that are not very common:

  • Copy Link Text (CoLT) I've been searching for such extension for a long time, and even attempted to make something similar myself, until yesterday I gave one more time a search. This is a very handy extension for forums, it copy a link with it's description to clipboard in a user specified format, i.e. in bbcode format: [url=http://example.com/blah]link description[/url] (p.s. this extension is actually the reason I started this topic :twisted:)
  • FoxLingo useful extension if you visit many multilanguage sites and need quick translation
  • Dictionary Switcher this extension is useful for these who type in different languages and would like to switch spell check to needed language (you might need Dictionaries & Language Packs as well)
  • IE Tab this extension will switch a tab to InternetExplorer engine with one click, very handy for web developers, to check how the site look lin IE and FF
  • YesScript this is a "must have" extension. By simply clicking on a icon at task bar it adds/removes current site to "black list" and completely disables javascript for that site.
  • TrashMail.net this extension can reduce spam to your email if you need register at untrusted sites.

    [EDIT]

  • Greasemonkey how many of you have an urge to changes something on a website you constantly visiting, like view youtube videos always in highest possible quality, or by clicking on image in image.google.com see the image and not website? This extension will NOT provide you with all that, but thousands of already existing scripts that made for this extension might. The scripts are JavaScript. The best part of this is that firefox doesn't need to be restared when installing/uninstalling scripts, simply refresh the page and scripts will kick in.
    a few I like:
  • Greasefire this extension is an addition to greasemonkey, it will check and notify if any scripts available for opened website.
  • dragdropupload in Firefox 3 a new feature was introduced to prevent file upload spoofing, if you click on upload file field it brings up file select window, which I personally found quiet annoying, because more often then not, it's faster for me to type the path to a file then actually select it and you can't modify manually the path already selected file. With this extension you can drag a file from an opened explorer window and drop it directly into upload file field on a webpage. Unfortunately current version of this extension doesn't work in FF3.5

26

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

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

With this mod you'll be able add to your gallery videos (as remote images) from the following media sites:
youtube.com (since v1.9 playlist also supported)
metacafe.com
liveleak.com
stupidvideos.com (only url from <embed> can be used (or url with #NN at the end) and no autoplay)
video.yahoo.com
vids.myspace.com (only works with myspace player videos) (removed since v1.11)
break.com
spikedhumor.com
hulu.com (no autoplay)
myvideo.de (no autoplay) (added in v1.1)
rutube.ru (added in v1.2)
dailymotion.com (added in v1.3)
mtv.com (added in v1.3)
sevenload.com (added in v1.5)
izlesene.com (no autoplay) (added in v1.6)
mynet.com (added in v1.6)
onsmash.com (added in v1.6)
gametrailers.com (added in v1.6)
gamespot.com (added in v1.6)
smotri.com (added in v1.7)
collegehumor.com (added in v1.7)
googlewave.com (added in v1.8 ) (experimental, must have google wave account to view)
220.ro (added in v1.8)
trilulilu.ro (video links only!) (added in v1.8)
funnyordie.com (added in v1.8)
dailyhaha.com (no autoplay) (added in v1.8)
megavideo.com (no autoplay) (added in v1.8)
aniboom.com (added in v1.9)
vimeo.com (added in v1.9)
tm-tube.com (added in v1.9)
vevo.com (added in v1.10)
mp3upload.ca (added in v1.11)
zippyshare.com (audio only!) (added in v1.11)

Since version 1.4 new BBCode tag added: [media]media site url[/media] (check out Tweak 4 for more info)
Since version 1.5 can automatically fetch thumbnails from most media sites and save them locally on the server. For now this feature only works if media site submitted via members upload form, not ACP.

----------------- [ Screenshots / Demo ] -----------------


You can see the demo here



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

includes/functions.php
download.php
member.php

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

includes/media_sites.php
templates/<your template>/icons/*.gif (an icon for each site)
templates/<your template>/media/*.html (media template for each site)


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


Step 1

Download attached media_sites_vXX.zip and media_sites_templates_and_icons_vXX.zip packages. Unpack them and upload to your 4images root directory, restoring the following directory tree:

includes/media_sites.php

copy all files from template/default/icons/ folder to templates/<your template>/icons/ on your site

copy all files from template/default/media/ folder to templates/<your template>/media/ on your site


Step 2

Open includes/functions.php
Find:
function check_remote_media($remote_media_file) {

Insert below:
/*
  MOD MEDIA SITES
  BEGIN INSERT
*/
  
if (media_sites($remote_media_file))
    return 
1;
/*
  MOD MEDIA SITES
  END INSERT
*/



Step 2.1

Find:
function get_file_extension($file_name) {

Insert below:
/*
  MOD MEDIA SITES
  BEGIN INSERT
*/
  
if ($data media_sites($file_name))
    return 
$data[0];
/*
  MOD MEDIA SITES
  END INSERT
*/



Step 2.2

Find:
    $media $site_template->parse_template("media/".$file_extension);

Insert above:
/*
  MOD MEDIA SITES
  START INSERT
*/
    
media_sites_template_vars($media_src);
/*
  MOD MEDIA SITES
  END INSERT
*/



Step 2.3

At the end, above closing ?> insert:
/*
  MOD MEDIA SITES
  BEGIN INSERT
*/
include(ROOT_PATH."includes/media_sites.php");
/*
  MOD MEDIA SITES
  END INSERT
*/



Step 2.4 (added in v1.2)

Find:
function get_basename($path) {

Insert below:
/*
  MOD MEDIA SITES
  BEGIN INSERT
*/
  
if ($data media_sites($path))
    return 
$data[1]['media_file'];
/*
  MOD MEDIA SITES
  END INSERT
*/



Step 2.5 (added in v1.2)

Find:
function get_basefile($path) {

Insert below:
/*
  MOD MEDIA SITES
  BEGIN INSERT
*/
  
if ($data media_sites($path))
    return 
$data[1]['media_file'];
/*
  MOD MEDIA SITES
  END INSERT
*/



Step 2.6 (optional, needed for bbcode in comments) (added in v1.4)

Find:
    $text preg_replace($search_array$replace_array$text);

Insert above:
/*
  MOD MEDIA SITES
  BEGIN INSERT
*/
    
$text media_sites_bbcode($text);
/*
  MOD MEDIA SITES
  END INSERT
*/



Step 2.7 (optional, it disables download button, you can skip entire step 3 if you apply this) (added in 2009-06-20)

Find:
  if (!check_permission("auth_download"$image_row['cat_id'])) {

Replace with:
/*
  MOD MEDIA SITES
  BEGIN REPLACE
*/
  
if (!check_permission("auth_download"$image_row['cat_id']) || media_sites($image_row['image_media_file'])) {
/*
  MOD MEDIA SITES
  END REPLACE
*/




Step 3

Open download.php
Find:
    while ($image_row $site_db->fetch_array($result)) {

Insert below:
/*
  MOD MEDIA SITES
  BEGIN INSERT
*/
      
if (empty($image_row['image_download_url']) && $data media_sites($image_row['image_media_file']))
        continue;
/*
  MOD MEDIA SITES
  END INSERT
*/



Step 3.1

Find:
  $remote_url 0;
  if (!empty(
$image_row['image_download_url'])) {


Replace with:
/*
  MOD MEDIA SITES
  BEGIN REPLACE
*/
  
$remote_url 0;
  if (empty(
$image_row['image_download_url']) && $data media_sites($image_row['image_media_file'], 1))
  {
    
$file['file_path'] = $data[1]['media_dl'];
    
$remote_url 1;
  }
  elseif (!empty(
$image_row['image_download_url'])) {
/*
  MOD MEDIA SITES
  END REPLACE
*/



Step 4

In ACP (Admin Control Panel) -> Settings -> add into "Valid file extensions" list (you can add any or all, in any order):
break,
dailymotion,
hulu,
liveleak,
metacafe,
mtv,
myvideo_de,
rutube_ru,
sevenload,
spikedhumor,
stupidvideos,
yahoovideo,
youtube,
izlesene,
mynet,
onsmash,
gametrailers,
gamespot,
smotri,
collegehumor,
googlewave,
220_ro,
trilulilu_ro,
funnyordie,
dailyhaha,
megavideo,
youtube_pl,
aniboom,
vimeo,
tm_tube,
vevo,
mp3upload,
zippyshare




Step 5 (added in v1.4)

Open member.php
Find:
  $remote_media_file format_url(un_htmlspecialchars(trim($HTTP_POST_VARS['remote_media_file'])));
Insert below:
/*
  MOD MEDIA SITES
  BEGIN INSERT
*/
  
if ($media_sites_data media_sites($remote_media_file))
    
$remote_media_file $media_sites_data[1]['media_src'];
/*
  MOD MEDIA SITES
  END INSERT
*/



Step 5.1 (added in v1.5)

Find:
    if (!$uploaderror) {

Insert above:
/*
  MOD MEDIA SITES
  BEGIN INSERT
*/
    
if (empty($new_thumb_name) && $data media_sites_thumb($media_sites_data$cat_id$direct_upload))
    {
      
$new_thumb_name $data[0];
    }
/*
  MOD MEDIA SITES
  END INSERT
*/



Step 5.2 (added in v1.9)

Find:
      $media $site_template->parse_template("media/".$file_extension);


Insert above:
/*
  MOD MEDIA SITES
  START INSERT
*/
      
media_sites_template_vars($new_name);
/*
  MOD MEDIA SITES
  END INSERT
*/



Go to upload image form and use "URL:" field to upload media site videos.

Tweaks and version history in the next reply.

Attachments:

27
Plugins / [Plugin] Valid file extensions manager v1.1 (2010-07-04)
« on: January 18, 2009, 11:20:36 AM »
This plugin will help manage "Allowed upload extensions". It will allow you edit and save includes/upload_definitions.php, update existing or create new media templates.
Also, it can automatically create/update mime type from an error message.

Download attached mime.zip package, extract mime.php and upload into admin/plugins/ directory.

Then login to ACP (Admin Control Panel), on left side you should see new menu "Valid file extensions manager"



Version history:

v1.1 (2010-07-04)
- added support for [MOD] Media sites

v1.0 (2009-01-18)
- initial release

28
FAQ, Tips / How to add FLV (Flash Video) support
« on: January 17, 2009, 02:49:46 AM »
Ok, this question become quiet popular at this forum. So here it is the answer.
In this tutorial we will use free for non-commercial usage JW FLV Media Player v4.3.

1. Go to ACP (Admin Control Panel) -> Settings -> Scroll down and find Valid file extensions, add to the list flv (don't forget put comma). Save the settings.

2. Open includes/upload_definitions.php

Insert at the end of the file, above closing ?>
Code: (PHP) [Select]
$mime_type_match['flv'] = array("application/x-shockwave-flash", "application/octet-stream", "video/flv", "video/x-flv");


3. Create a new template: templates/<your template>/media/flv.html
with this code inside:
Code: (template) [Select]
<script type='text/javascript' src='swfobject.js'></script>
<div id='mediaspace'>This div will be replaced</div>
<script type='text/javascript'>
  var s1 = new SWFObject('player.swf','ply','470','320','9','#ffffff');
  s1.addParam('allowfullscreen','true');
  s1.addParam('allowscriptaccess','always');
  s1.addParam('wmode','opaque');
  s1.addParam('flashvars','file=<?=urlencode("{media_src}")?>&autostart=true');
  s1.write('mediaspace');
</script>

4. Download the player from the link above.
NOTE At the time this tutorial is written the player's download page has "Include the JW Viral Plugin" checkbox, when checked, the downloaded package will have player-viral.swf file, instead of player.swf.
In this tutorial we'll use JW FLV Media Player 4.3 without the "JW Viral plugin" (checkbox at download page must be unchecked).

From the downloaded package take only player.swf and swfobject.js, upload them to the root of your 4images gallery (this is important, in my tests it didn't work when I uploaded these files into a subdirectory).

5. Create an templates/<your template>/icons/flv.gif icon (this icon will be showed when no thumbnail available)

6. Try upload a .flv file, if you get an error about Invalid file type, follow this instructions

29

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

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

This mod will allows post comments and/or rate comments without page refresh, just like on youtube.com


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

You can see how it works here. You can login using any username and password. Also the demo has settings on left side.


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

details.php
templates/<your template>/comment_bit.html
templates/<your template>/comment_form.html
templates/<your template>/commentsperpage_dropdown_form.html
templates/<your template>/details.html
templates/<your template>/style.css
lang/<your language>/main.php

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

install_ajaxcomments.php
ajaxcomments.php
js/ajax.js
js/ajaxcomments.js

templates/<your template>/images/good.png
templates/<your template>/images/good_off.png
templates/<your template>/images/bad.png
templates/<your template>/images/bad_off.png
templates/<your template>/images/minus.png
templates/<your template>/images/plus.png



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


Step 1

Download attached ajaxcomments.zip package (you must login to be able download it). Unpack it and upload to your 4images root directory, restoring the following directory tree:
install_ajaxcomments.php
ajaxcomments.php
js/ajax.js
js/ajaxcomments.js

templates/<your template>/images/good.png
templates/<your template>/images/good_off.png
templates/<your template>/images/bad.png
templates/<your template>/images/bad_off.png
templates/<your template>/images/minus.png
templates/<your template>/images/plus.png


Step 2

Start install_ajaxcomments.php by typing in your browser: http://your_site/4images/install_ajaxcomments.php
Install database.


Step 3

If you want show comments in pages, install [MOD] Paging for comments
If you don't want pages for comments, make sure you skip steps where says "(only if done Step 3)"
Also, if you skip this step, you'll need set COMMENTS_PAGES to 0 (refer Tweak 1 for more info)


Step 4

Open details.php
Find:
include(ROOT_PATH.'includes/page_header.php');

Insert below:
/*
  MOD AJAX COMMENTS
  BEGIN INSERT
*/
include(ROOT_PATH."ajaxcomments.php");
/*
  MOD AJAX COMMENTS
  END INSERT
*/




Step 4.1

Find:  $sql "SELECT c.comment_id, c.image_id, c.user_id, c.user_name AS comment_user_name, c.comment_headline, c.comment_text, c.comment_ip, c.comment_date".get_user_table_field(", u.""user_level").get_user_table_field(", u.""user_name").get_user_table_field(", u.""user_email").get_user_table_field(", u.""user_showemail").get_user_table_field(", u.""user_invisible").get_user_table_field(", u.""user_joindate").get_user_table_field(", u.""user_lastaction").get_user_table_field(", u.""user_comments").get_user_table_field(", u.""user_homepage").get_user_table_field(", u.""user_icq")."
(if you have hard time find this line, it's in "Show Comments" section)

Add at the end of the line:
Code: [Select]
,c.comment_rating,c.comment_votes,c.comment_rating_users

Step 4.2 (only if done Step 3)

Find:
$commentsperpage_dropdown "\n<select name=\"commentsetperpage\" onchange=\"if (this.options[this.selectedIndex].value != 0){ forms['commentsperpage'].submit() }\" class=\"select\">\n";


Replace it with:
/*
  MOD AJAX COMMENTS
  REPLACE START
*/
$commentsperpage_dropdown "\n<select name=\"commentsetperpage\" onchange=\"if (this.options[this.selectedIndex].value != 0){ return CommentsPerPage(this.form); }\" class=\"select\">\n";
/*
  MOD AJAX COMMENTS
  REPLACE END
*/



Step 4.3 (only if done Step 3)

Find:
if ($action == "postcomment") {

Replace it with:
/*
  MOD AJAX COMMENTS
  REPLACE START
*/
if (($action == "postcomment" || (!isset($HTTP_POST_VARS['page']) && !isset($HTTP_GET_VARS['page']))) && !COMMENTS_ORDER) {
/*
  MOD AJAX COMMENTS
  REPLACE END
*/




Step 4.4 (only if done Step 3)

Find:
Code: [Select]
 "paging" => $getpaging->get_paging(),
Replace it with:
Code: [Select]
/*
  MOD AJAX COMMENTS
  REPLACE START
*/
      "paging" => str_replace(array("<a ", 'onSubmit="'), array('<a onclick="return CommentsPage(this);" ', 'onSubmit="return CommentsPerPage(this);'), $getpaging->get_paging()),
/*
  MOD AJAX COMMENTS
  REPLACE END
*/


Step 4.5

A. (only if done Step 3)
Find:
Code: [Select]
         WHERE c.image_id = $image_id
          ORDER BY c.comment_date ASC";

Replace it with:
Code: [Select]
         WHERE c.image_id = $image_id
          ORDER BY c.comment_date ".(COMMENTS_ORDER ? "DESC" : "ASC")."";


B. (only if skipped Step 3)
Find:
Code: [Select]
         WHERE c.image_id = $image_id
          ORDER BY c.comment_date ASC

Replace it with:
Code: [Select]
         WHERE c.image_id = $image_id
          ORDER BY c.comment_date ".(COMMENTS_ORDER ? "DESC" : "ASC")."


Step 4.6

Find:
      $comments .= $site_template->parse_template("comment_bit");

Insert above:
/*
  MOD AJAX COMMENTS
  BEGIN INSERT
*/
      
if (COMMENT_RATING_ENABLE)
      {
        
$comment_row[$i]['cat_id'] = $cat_id;
        
$comment_row[$i]['image_allow_comments'] = $image_allow_comments;
        
comment_rating_template($comment_row[$i]);
      }
/*
  MOD AJAX COMMENTS
  END INSERT
*/



Step 4.7

Find:
  $site_template->register_vars("comments"$comments);

Replace it with:
/*
  MOD AJAX COMMENTS
  START REPLACE
*/
  
$site_template->register_vars(array(
    
"comments" => $comments,
    
"comments_num" => $num_comments,
    
"commentbg" => (isset($row_bg_number)) ? $row_bg_number 0,
    
"page" => $page,
    
"perpage" => $commentperpage,
  ));

/*
  MOD AJAX COMMENTS
  END REPLACE
*/



Step 5

Open: lang/<your language>/main.php
At the end, above closing ?> insert:
$lang['comment_rating'] = "Vote for this comment";
$lang['comment_rating_good'] = "Good comment";
$lang['comment_rating_bad'] = "Bad comment";
$lang['comment_rating_success'] = "Thank you for rating this comment";
$lang['comment_rating_error'] = "Sorry, your vote was rejected:";
$lang['comment_rating_check'] = array(
  
=> "Not rated yet",
  
=> "Invalid comment id",
  
=> "Guests are not allowed to vote",
  
=> "Permission denied",
  
=> "You can't vote on your own comments",
  
=> "You've already voted for this comment",
  
=> "Comment rating disabled",
);



Step 6
Open: templates/<your template/style.css

Add at the end:
Code: [Select]
.comment_rating0 {
}
.comment_rating1 {
  color: green;
}
.comment_rating2 {
  color: red;
}



  • Step 7 - 10 are template related, if you are using default template, you can simply download attached ajaxcomments_default_template.zip package, unpack it and replace files in your template with files from the package.
  • In some steps I will only give the code to add and might give brief explanation what it does, your task is to find the place where you want that code to be. This means, you need to know basic HTML.
  • Examine the provided code, it might contain additional comments with additional information.
  • If you read "an element will be used to display..." make sure such element doesn't have any children elements, unless stated otherwise.

(i.e. <div id="t"><span>blah</span></div> <div> is a parent element and <span> is it's child element)
  • In my templates I used combination of DIV and SPAN, it's not required, you can replace them with other elements, as long as you restore the ID and as already been said elements don't have children elements.
  • The search in a file starts from the position of the last search in the same file NOT from the top of the file. Knowing that, make sure you don't replace something in the new, already added code.
  • If you found two or more instances of a string, you must work only on the first found instance, unless instructed otherwise.


P.S. if you don't understand my explanations, download attached ajaxcomments_template_default.zip package and look how its done there.



Step 7
Open: templates/<your template/details.html template

Insert below {header} or <body>:
Code: [Select]
<!--mod ajax comments insert start-->
<script type="text/javascript">
var ajaxCommentBG = parseInt('{commentbg}');
var ajaxCommentRatingHide = parseInt('{commentratinghide}');
var ajaxCommentsUrl = '{ajaxcommentsurl}';
var URL_ID = '{url_id}';
var Page = parseInt('{page}');
var PerPage = parseInt('{perpage}');

</script>
<script type="text/javascript" src="js/ajax.js"></script>
<script type="text/javascript" src="js/ajaxcomments.js"></script>

<!-- uncomment and place this div where you want messages related to comment rating to be showed (additionally to tooltips), you can use this div to display floating messages -->
<!-- <div id="commentratingmsg"></div> -->

<!--mod ajax comments insert end-->

an element with id="commentratingmsg" can be used to display messages after vote for a comment.


Step 7.1 (only if done Step 3)

Replace {paging_stats}
With:
Code: [Select]
<!--mod ajax comments insert start-->
<span id="pagingstats">
<!--mod ajax comments insert end-->
{paging_stats}
<!--mod ajax comments insert start-->
</span>
<!--mod ajax comments insert end-->

an element id="pagingstats" will be used to display paging information.


Step 7.2 (only if done Step 3)

Replace {if paging} with:
Code: [Select]
<!--mod ajax comments insert start-->
<div id="pagingtable"{ifno paging} style="display:none;"{endifno paging}>
<!--mod ajax comments insert end-->

If you have two {if paging}, replace second with:
Code: [Select]
<!--mod ajax comments insert start-->
<div id="pagingtable2"{ifno paging} style="display:none;"{endifno paging}>
<!--mod ajax comments insert end-->

an element id="pagingtable" and id="pagingtable2" will be used to show/hide paging table


Step 7.3 (only if done Step 3)

Replace {paging} with:
Code: [Select]
<!--mod ajax comments insert start-->
<span id="paging">
<!--mod ajax comments insert end-->
{paging}
<!--mod ajax comments insert start-->
</span>
<!--mod ajax comments insert end-->

If you have two {paging}, replace second with:
Code: [Select]
<!--mod ajax comments insert start-->
<span id="paging2">
<!--mod ajax comments insert end-->
{paging}
<!--mod ajax comments insert start-->
</span>
<!--mod ajax comments insert end-->

an element id="paging" and id="paging2" will be used to display paging links.


Step 7.4 (only if done Step 3)

Replace {endif paging} with:
Code: [Select]
<!--mod ajax comments insert start-->
</div>
<!--mod ajax comments insert end-->

If you have two {endif paging}, replace second with the same code.



Step 7.5

Replace {comments} with:
Code: [Select]
<!--COMMENTSTART-->
{comments}
<!--COMMENTEND-->
(these HTML comments are required, they are used as "markers" to detect where to insert new image comments)


Step 7.6

Insert the whole table where {comments} is between <span id="commentstable"> and </span>
Example:
Code: [Select]
<table width="100%" border="0" cellpadding="3" cellspacing="1">
  <tr>
    <td valign="top" class="head1">{lang_author}</td>
    <td valign="top" class="head1">{lang_comment}</td>
  </tr>
  {comments}
</table>

The result is:
Code: [Select]
<span id="commentstable">
  <table width="100%" border="0" cellpadding="3" cellspacing="1">
    <tr>
      <td valign="top" class="head1">{lang_author}</td>
      <td valign="top" class="head1">{lang_comment}</td>
    </tr>
    {comments}
  </table>
</span>

an element with id="commentstable" will be used to display comments. This element can contain children elements.


Step 7.7

Add:
Code: [Select]
<!--mod ajax comments insert start in "commentformmsg" will be displayed any messages related to posting comments.
keep in mind a <br /> will be automatically appended to the front of the message-->
<b><div id="commentformmsg"></div></b>
<!--mod ajax comments insert end-->

an element with id="commentformmsg" will be used to display messages related to comment posting.


Step 8
Open: templates/<your template/comment_bit.html template

Add:
Code: [Select]
<!--mod ajax comments insert start -->
{if comment_rating_enable}<span id="cmsg{comment_id}" title="{comment_vote_tooltip}"><span id="cr{comment_id}" class="comment_rating{comment_class}">{comment_rating_str}</span> {comment_rating_link_good} {comment_rating_link_bad} <span id="crv{comment_id}">{comment_votes}</span> {lang_votes}</span>{endif comment_rating_enable}
<!--mod ajax comments insert end -->

an element with id="cmsg{comment_id}" will be used to show tooltips after visitor voted on a comment.
an element with id="cr{comment_id}" will be used to display comment rating.
an element with id="crv{comment_id}" will be used to display number of comment votes.




Step 8.1

Replace {comment_text}
With:
Code: [Select]
<!--mod ajax comments insert start -->
<a href="#" id="cilh{comment_id}" onClick="return aCTog({comment_id});" style="{if comment_hide}display:inline;{endif comment_hide}{ifno comment_hide}display:none;{endifno comment_hide}"><img id="cih{comment_id}" src="{template_image_url}/plus.png" border="0" /></a>
<div id="commentbox{comment_id}"{if comment_hide} style="display:none;"{endif comment_hide}>
<!--mod ajax comments insert end -->

  {comment_text}

<!--mod ajax comments insert start -->
</div>
<!--mod ajax comments insert end -->

an element with id="cilh{comment_id}" will be used if a comment rating reached "Hide comment if rating below"
en element with id="commentbox{comment_id}" will be used to display comments in.



Step 9

Open: templates/<your template/comment_form.html template
Code: [Select]
<form name="commentform" action="{self}" method="post" onsubmit="postbutton.disabled=true;">
Replace with:
Code: [Select]
<form name="commentform" action="{self}" method="post" onsubmit="return ajaxCommentSubmit(this,'{self}');">
This line is required for the javascript code, it will be used to detect where the



Step 10 (only if done Step 3)

Open: templates/<your template/commentspage_dropdown_form.html template
Find:
Code: [Select]
<form method="post" action="{self}#comments" name="commentsperpage">
Replace it with:
Code: [Select]
<form method="post" action="{self}#comments" name="commentsperpage" onsubmit="return CommentPerPage(this);">



This is it. I hope I didn't forget anything. (I did not check my installation instructions, ran out of steam for today) :roll: Done. Works fine on unmodified 4images v1.7.7


Tweaks and version history in the next reply.

30
When images deleted along with the comments the comments count per user is not being updated. Thanks to alekinna for finding and providing the fix.

In admin/categories.php
Find TWO times:
$sql "DELETE FROM ".COMMENTS_TABLE."

Insert above EACH:
  global $user_table_fields;
  if (!empty(
$user_table_fields['user_comments']))
  {
    
$sql "SELECT user_id
            FROM "
.COMMENTS_TABLE."
            WHERE image_id IN (
$image_ids_sql) AND user_id <> ".GUEST;
    
$result $site_db->query($sql);
  
    while (
$row $site_db->fetch_array($result))
    {
      
$sql "UPDATE ".USERS_TABLE."
              SET "
.get_user_table_field("""user_comments")." = ".get_user_table_field("""user_comments")." - 1
              WHERE "
.get_user_table_field("""user_id")." = ".$row['user_id'];
      
$site_db->query($sql);
    }
  }



Open admin/images.php
Find:function delete_images($image_ids$delfromserver 1) {
Insert below:
  global $user_table_fields;

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