4images Forum & Community
4images Modifications / Modifikationen => Mods & Plugins (Releases & Support) => Topic started by: V@no on January 15, 2009, 07:48:56 AM
-
----------------- [ Index ] -----------------
- Introduction (#post_intro)
- Demo (#post_demo)
- List of changed/new files (#post_changes)
- Installation (#post_install)
- Tweaks (#post_tweaks)
- Version history (#post_history)
----------------- [ 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 (http://4images.vano.org/ajaxcomments). You can login using any username and password. Also the demo has settings on left side.
----------------- [ Changed files ] -----------------
details.php (#post_step4)
templates/<your template>/comment_bit.html (#post_step8)
templates/<your template>/comment_form.html (#post_step9)
templates/<your template>/commentsperpage_dropdown_form.html (#post_step10)
templates/<your template>/details.html (#post_step7)
templates/<your template>/style.css (#post_step6)
lang/<your language>/main.php (#post_step5)
----------------- [ 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 (#post_step1)
Download attached (#post_attachment) 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 (#post_step2)
Start install_ajaxcomments.php by typing in your browser: http://your_site/4images/install_ajaxcomments.php
Install database.
Step 3 (#post_step3)
If you want show comments in pages, install [MOD] Paging for comments (http://www.4homepages.de/forum/index.php?topic=5830.0)
If you don't want pages for comments, make sure you skip steps where says "(only if done Step 3 (#post_step3))"
Also, if you skip this step, you'll need set COMMENTS_PAGES to 0 (refer Tweak 1 (#post_tweak1) for more info)
Step 4 (#post_step4)
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 (#post_step4-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:,c.comment_rating,c.comment_votes,c.comment_rating_users
Step 4.2 (#post_step4-2) (only if done Step 3 (#post_step3))
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 (#post_step4-3) (only if done Step 3 (#post_step3))
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 (#post_step4-4) (only if done Step 3 (#post_step3))
Find:
"paging" => $getpaging->get_paging(),
Replace it with:
/*
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 (#post_step4-5)
A. (only if done Step 3 (#post_step3))
Find:
WHERE c.image_id = $image_id
ORDER BY c.comment_date ASC";
Replace it with:
WHERE c.image_id = $image_id
ORDER BY c.comment_date ".(COMMENTS_ORDER ? "DESC" : "ASC")."";
B. (only if skipped Step 3 (#post_step3))
Find:
WHERE c.image_id = $image_id
ORDER BY c.comment_date ASC
Replace it with:
WHERE c.image_id = $image_id
ORDER BY c.comment_date ".(COMMENTS_ORDER ? "DESC" : "ASC")."
Step 4.6 (#post_step4-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 (#post_step4-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 (#post_step5)
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(
0 => "Not rated yet",
1 => "Invalid comment id",
2 => "Guests are not allowed to vote",
3 => "Permission denied",
4 => "You can't vote on your own comments",
5 => "You've already voted for this comment",
6 => "Comment rating disabled",
);
Step 6 (#post_step6)
Open: templates/<your template/style.css
Add at the end:
.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 (#post_attachment) 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 (#post_attachment) ajaxcomments_template_default.zip package and look how its done there.
Step 7 (#post_step7)
Open: templates/<your template/details.html template
Insert below {header} or <body>:
<!--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 (#post_step7-1) (only if done Step 3 (#post_step3))
Replace {paging_stats}
With:
<!--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 (#post_step7-2) (only if done Step 3 (#post_step3))
Replace {if paging} with:
<!--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:
<!--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 (#post_step7-3) (only if done Step 3 (#post_step3))
Replace {paging} with:
<!--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:
<!--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 (#post_step7-4) (only if done Step 3 (#post_step3))
Replace {endif paging} with:
<!--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 (#post_step7-5)
Replace {comments} with:
<!--COMMENTSTART-->
{comments}
<!--COMMENTEND-->
(these HTML comments are required, they are used as "markers" to detect where to insert new image comments)
Step 7.6 (#post_step7-6)
Insert the whole table where {comments} is between <span id="commentstable"> and </span>
Example:
<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:
<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 (#post_step7-7)
Add:
<!--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 (#post_step8)
Open: templates/<your template/comment_bit.html template
Add:
<!--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 (#post_step8-1)
Replace {comment_text}
With:
<!--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 (#post_tweaks)"
en element with id="commentbox{comment_id}" will be used to display comments in.
Step 9 (#post_step9)
Open: templates/<your template/comment_form.html template
<form name="commentform" action="{self}" method="post" onsubmit="postbutton.disabled=true;">
Replace with:
<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 (#post_step10) (only if done Step 3 (#post_step3))
Open: templates/<your template/commentspage_dropdown_form.html template
Find:
<form method="post" action="{self}#comments" name="commentsperpage">
Replace it with:
<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 (#post_tweaks) and version history (#post_history) in the next reply.
-
----------------- [ Tweaks ] -----------------
Tweak 1 (#post_tweak1)
On top of ajaxcomments.php you can find the following settings:
define("COMMENT_RATING_ENABLE", true); //enable ratings for comments?
define("COMMENT_RATING_GUEST", false); //allow guests to vote?
define("COMMENT_RATING_OWN", false); //allow rate own comments?
define("COMMENT_RATING_HIDE", -3); //comment with rating below this number will be hidden by default (visitors still will be able read them by clicking at + icon)
define("COMMENTS_PAGES", true); //show pages for comments? must install http://www.4homepages.de/forum/index.php?topic=5830.0
define("COMMENTS_ORDER", 0); //sort comments 0 = ASC or 1 = DESC
Tweak 2 (#post_tweak2)
If you did any modifications in details.php in comments related sections, you'll need do the same modifications in ajaxcomments.php
I did copy/paste such parts from details.php into ajaxcomments.php with as little additional modifications as possible.
Also, if something doesn't work right and you go express you rage here, make sure you test with default template first.
----------------- [ Version history ] -----------------
v1.0.4 (2009-12-21) (more info here (http://www.4homepages.de/forum/index.php?topic=23866.msg144011#msg144011)) (to update - re-download the package and replace ajaxcomments.php)
- CHANGED: on servers with PHP v4.3.0 or newer with html_entity_decode (http://php.net/manual/function.html-entity-decode.php) enabled non-latin letters should be converted into proper charset.
v1.0.3 (2009-12-14) (more info here (http://www.4homepages.de/forum/index.php?topic=23866.msg143781#msg143781)) (to update - re-download the package and replace ajaxcomments.php)
- FIXED: with some charsets javascript would display garbage when posting comments.
- FIXED: misspelled constant, which affected displaying comment ratings properly.
v1.0.2 (2009-08-21) (more info here (http://www.4homepages.de/forum/index.php?topic=23866.msg140156#msg140156) thanks to bash-t) (to update - replace js/ajaxcomments.js)
- FIXED: when used reCAPTCHA (http://www.4homepages.de/forum/index.php?topic=22881.msg125037#msg125037) image was not automatically refreshed
v1.0.1 (2009-01-21) (more info here (http://www.4homepages.de/forum/index.php?topic=23866.msg131088#msg131088))
- FIXED: issue with non-latin letters didn't display properly in the comments. (re-download the package and replace ajaxcomments.php)
- FIXED JavaScript error in InternetExplorer after submitting a comment. (re-do Step 7.6 (#post_step7-6))
- CHANGED: anti-flood protection to 4images' default: 3 minutes between comments on the same image.
v1.0 (2009-01-15)
- first release
-
Reserved
-
wow, very Nice!
-
top :wink:
-
Parse error: syntax error, unexpected ']', expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/public_html/details.php on line 679
and on line 679 i have this $comment_row[] = $row;
I haven t done the step 3.
Could someone help me ?
-
15 lines above and below line 679 please.
-
Thanks for your reply V@no . Please see attached my details.php
-
In step 4.5 (#post_step4-5) you've replace the entire line, but you were supposed to replace only what it says. (I've added a note to that step)
Line 669 should look like this after the change:
ORDER BY c.comment_date ".(COMMENTS_ORDER ? "DESC" : "ASC")."";
P.S.
I don't know that text editor do you use, but it added extra line between each line. Nothing to worry about though, just file became a little bigger.
-
Hm... I have a problem. I'm from Poland, when we use a polish fonts, peculiar letters. What am i doing, when i write a comment, and fonts in this comment displaying like this: "%u015B%u0107"? Where i must insert a code like this?:
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-2" />
Sorry for my bad english :(
-
Hello and welcome to 4images forum.
Thank you for reporting this. In my tests I completely forgot check it with non-english text...
I hope it's fixed in v1.0.1
- fixed issue with non-latin letters didn't display properly in the comments. (re-download the package and replace ajaxcomments.php)
- changed anti-flood protection to 4images' default: 3 minutes between comments on the same image.
- fixed JavaScript error in InternetExplorer after submitting a comment. (re-do Step 7.6 (#post_step7-6))
Re-download the package and replace only ajaxcomments.php file.
Also, I've changed Step 7.6 (http://www.4homepages.de/forum/index.php?topic=23866.0#post_step7-6)
Apparently InternetExplorer chokes when JS tries change innerHTML in a table, so you'll need add a SPAN or DIV around the table with {comments} tag.
-
hello V@no
thanks for the nice mod
I have 2 problems
1- the comment text appears perfect for non-english but some texts (commentformmgs, comments:, joindate:, admin, edit, delete and username) appear like this "�������". the problem happens only after I go to another page or when I post new comments.
2- when I rate a comment (good or bad), the result does not appear instantly. I have to refresh the page. this problem DOES NOT happen if I rate after going to another page or after posting new comments.
I hope I can find solutions or hints.
thanks again
-
Hello and welcome to 4images forum.
Can I see it?
-
Hello and welcome to 4images forum.
Can I see it?
actually it is on my PC (apatchi)
it is a little bit confusing why comments are shown differently when I go to other pages or add comments??
-
Sorry, I can't reproduce it on my test site.
-
Sorry, I can't reproduce it on my test site.
I'll wait .. maybe you guys will make some improvements later :D
-
Well, I do follow the "problem solving flowsheet", so if I can't reproduce the error, nothing needs to be fixed :D
-
hi :D
this best mod for 4images
thank you very much
but Avatar Mod now working with this mod
http://www.4homepages.de/forum/index.php?topic=3978.0
Multiple pages showing this code
{if user_avatar_current} {user_avatar_current} {endif user_avatar_current}
Instead of Avatar picture
thanks
-
Yes, you'll need do Step 2 and 2.2 of avatar mod in ajaxcomments.php
-
thanx V@no
-
Is it possible to add ajax multiple pages in the multi-page of categories ??
-
Possible? - yes
Is it worth it? - I don't think it is. when page refreshes, you'll endup at the page you started on
-
Possible? - yes
Is it worth it? - I don't think it is. when page refreshes, you'll endup at the page you started on
You Right , Thus best
-
Yes, you'll need do Step 2 and 2.2 of avatar mod in ajaxcomments.php
Operating successfully, but there was another Error
first comment is not showing avatar
see pic
(http://filaty.com/i/901/10459/Untitled-1.jpg)
-
:roll:
-
First comment doesn't show when you open the details page or after you posted a comment?
If it's after you posted a comment, then zip your ajaxcomments.php (with all the changes) and attach to the reply.
I can't possibly know what could be wrong without seeing the code.
-
doesn't show when open the details
ajaxcomments.php and details.php in Attach
-
The problem has nothing to do with this mod. You didn't install avatar mod properly.
in details.php replace
$user_row_comment = get_user_info($comment_user_id);
$comment_user_id = $comment_row[$i]['user_id'];
with this:
$comment_user_id = $comment_row[$i]['user_id'];
$user_row_comment = get_user_info($comment_user_id);
-
Thank you very much
Now operating successfully
-
Hey V@no!
I am using you included Templates and trying to make the mod to add MEMBER PIC
and there are things your ajax comments php file is missing that the member.php has, like "user_showemail_yes" => $user_showemail_yes,
Im guessing where to put the member pic mod stuff..... Ill let you know if my guessing is good.
Also I have an orphaned "< "
Under the "There are no comments for this image"
Do you know where I can fix that?
thanks-
www.thelifephoptography.com
-
stupid me... details mods go inton the ajaxcomments.php not member.php mods...
Just waking up. Ok I still have the "<"Issue.. .
Sorry and thanks if you know..
-
ok... All is good with member pic mod and the ajax mod... only problem is orpahned
tag like this:
There are no comments for this image
<
Awsome mod. I wish everything could be in ajax...
-
fixed it///// My bad.... but this seems to be interfering with the news mod I am trying to so... more in a minute...
-
I'm glad you sort it out.
In the future, if your reply is last in the topic please edit your own post to add additional info and such, don't post second reply.
-
ok it works in tandem. It would be nice to know how to add the rating to the news articles the way you have added the rating to the comments..
-
Anytime I add any other mods information after this mods LANG file modification, 4images always crashes with white screen. For some reason your modifications for thelanguage file must be the last one of the file... just so you know....
-
Hi.
Where is it possible to download it?: ajaxcomments.zip
I do not endure it.
Sorry my bad English...:$
-
hi george and welcome to the 4images forum
attachments are always on the end of the 1st post, but here again:
http://www.4homepages.de/forum/index.php?action=dlattach;topic=23866.0;attach=4248
http://www.4homepages.de/forum/index.php?action=dlattach;topic=23866.0;attach=4249
-
Thanks you the help... :)
We made it download :D
Congratulations the forum!
-
<?php
/**************************************************************************
* *
* 4images - A Web Based Image Gallery Management System *
* ---------------------------------------------------------------- *
* *
* File: details.php *
* Copyright: (C) 2002 Jan Sorgalla *
* Email: jan@4homepages.de *
* Web: http://www.4homepages.de *
* Scriptversion: 1.7.6 *
* *
* Never released without support from: Nicky (http://www.nicky.net) *
* *
**************************************************************************
* *
* Dieses Script ist KEINE Freeware. Bitte lesen Sie die Lizenz- *
* bedingungen (Lizenz.txt) für weitere Informationen. *
* --------------------------------------------------------------- *
* This script is NOT freeware! Please read the Copyright Notice *
* (Licence.txt) for further information. *
* *
*************************************************************************/
$main_template = 'details';
define('GET_CACHES', 1);
define('ROOT_PATH', './');
include(ROOT_PATH.'global.php');
require(ROOT_PATH.'includes/sessions.php');
$user_access = get_permission();
include(ROOT_PATH.'includes/page_header.php');
/*
MOD AJAX COMMENTS
BEGIN INSERT
*/
include(ROOT_PATH."ajaxcomments.php");
/*
MOD AJAX COMMENTS
END INSERT
*/
if (!$image_id) {
redirect($url);
}
$additional_sql = "";
if (!empty($additional_image_fields)) {
foreach ($additional_image_fields as $key => $val) {
$additional_sql .= ", i.".$key;
}
}
$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".$additional_sql.", c.cat_name".get_user_table_field(", u.", "user_name").get_user_table_field(", u.", "user_email")."
FROM (".IMAGES_TABLE." i, ".CATEGORIES_TABLE." c)
LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = i.user_id)
WHERE i.image_id = $image_id AND i.image_active = 1 AND c.cat_id = i.cat_id";
$image_row = $site_db->query_firstrow($sql);
$cat_id = (isset($image_row['cat_id'])) ? $image_row['cat_id'] : 0;
$is_image_owner = ($image_row['user_id'] > USER_AWAITING && $user_info['user_id'] == $image_row['user_id']) ? 1 : 0;
if (!check_permission("auth_viewcat", $cat_id) || !check_permission("auth_viewimage", $cat_id) || !$image_row) {
redirect($url);
}
$random_cat_image = (defined("SHOW_RANDOM_IMAGE") && SHOW_RANDOM_IMAGE == 0) ? "" : get_random_image($cat_id);
$site_template->register_vars("random_cat_image", $random_cat_image);
unset($random_cat_image);
//-----------------------------------------------------
//--- Show Image --------------------------------------
//-----------------------------------------------------
$image_allow_comments = (check_permission("auth_readcomment", $cat_id)) ? $image_row['image_allow_comments'] : 0;
$image_name = format_text($image_row['image_name'], 2);
show_image($image_row, $mode, 0, 1);
$in_mode = 0;
$sql = "";
if ($mode == "lightbox") {
if (!empty($user_info['lightbox_image_ids'])) {
$image_id_sql = str_replace(" ", ", ", trim($user_info['lightbox_image_ids']));
$sql = "SELECT image_id, cat_id, image_name, image_media_file, image_thumb_file
FROM ".IMAGES_TABLE."
WHERE image_active = 1 AND image_id IN ($image_id_sql) AND (cat_id NOT IN (".get_auth_cat_sql("auth_viewimage", "NOTIN").", ".get_auth_cat_sql("auth_viewcat", "NOTIN")."))
ORDER BY ".$config['image_order']." ".$config['image_sort'].", image_id ".$config['image_sort'];
$in_mode = 1;
}
}
elseif ($mode == "search") {
if (!isset($session_info['searchid']) || empty($session_info['searchid'])) {
$session_info['search_id'] = $site_sess->get_session_var("search_id");
}
if (!empty($session_info['search_id'])) {
$search_id = unserialize($session_info['search_id']);
}
$sql_where_query = "";
if (!empty($search_id['image_ids'])) {
$sql_where_query .= "AND image_id IN (".$search_id['image_ids'].") ";
}
if (!empty($search_id['user_ids'])) {
$sql_where_query .= "AND user_id IN (".$search_id['user_ids'].") ";
}
if (!empty($search_id['search_new_images']) && $search_id['search_new_images'] == 1) {
$new_cutoff = time() - 60 * 60 * 24 * $config['new_cutoff'];
$sql_where_query .= "AND image_date >= $new_cutoff ";
}
if (!empty($search_id['search_cat']) && $search_id['search_cat'] != 0) {
$cat_id_sql = 0;
if (check_permission("auth_viewcat", $search_id['search_cat'])) {
$sub_cat_ids = get_subcat_ids($search_id['search_cat'], $search_id['search_cat'], $cat_parent_cache);
$cat_id_sql .= ", ".$search_id['search_cat'];
if (!empty($sub_cat_ids[$search_id['search_cat']])) {
foreach ($sub_cat_ids[$search_id['search_cat']] as $val) {
if (check_permission("auth_viewcat", $val)) {
$cat_id_sql .= ", ".$val;
}
}
}
}
$cat_id_sql = $cat_id_sql !== 0 ? "AND cat_id IN ($cat_id_sql)" : "";
}
else {
$cat_id_sql = get_auth_cat_sql("auth_viewcat", "NOTIN");
$cat_id_sql = $cat_id_sql !== 0 ? "AND cat_id NOT IN (".$cat_id_sql.")" : "";
}
if (!empty($sql_where_query)) {
$sql = "SELECT image_id, cat_id, image_name, image_media_file, image_thumb_file
FROM ".IMAGES_TABLE."
WHERE image_active = 1
$sql_where_query
$cat_id_sql
ORDER BY ".$config['image_order']." ".$config['image_sort'].", image_id ".$config['image_sort'];
$in_mode = 1;
}
}
if (!$in_mode || empty($sql)) {
$sql = "SELECT image_id, cat_id, image_name, image_media_file, image_thumb_file
FROM ".IMAGES_TABLE."
WHERE image_active = 1 AND cat_id = $cat_id
ORDER BY ".$config['image_order']." ".$config['image_sort'].", image_id ".$config['image_sort'];
}
$result = $site_db->query($sql);
$image_id_cache = array();
$next_prev_cache = array();
$break = 0;
$prev_id = 0;
while($row = $site_db->fetch_array($result)) {
$image_id_cache[] = $row['image_id'];
$next_prev_cache[$row['image_id']] = $row;
if ($break) {
break;
}
if ($prev_id == $image_id) {
$break = 1;
}
$prev_id = $row['image_id'];
}
$site_db->free_result();
if (!function_exists("array_search")) {
function array_search($needle, $haystack) {
$match = false;
foreach ($haystack as $key => $value) {
if ($value == $needle) {
$match = $key;
}
}
return $match;
}
}
$act_key = array_search($image_id, $image_id_cache);
$next_image_id = (isset($image_id_cache[$act_key + 1])) ? $image_id_cache[$act_key + 1] : 0;
$prev_image_id = (isset($image_id_cache[$act_key - 1])) ? $image_id_cache[$act_key - 1] : 0;
unset($image_id_cache);
// Get next and previous image
if (!empty($next_prev_cache[$next_image_id])) {
$next_image_name = format_text($next_prev_cache[$next_image_id]['image_name'], 2);
$next_image_url = $site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$next_image_id.((!empty($mode)) ? "&mode=".$mode : ""));
if (!get_file_path($next_prev_cache[$next_image_id]['image_media_file'], "media", $next_prev_cache[$next_image_id]['cat_id'], 0, 0)) {
$next_image_file = ICON_PATH."/404.gif";
}
else {
$next_image_file = get_file_path($next_prev_cache[$next_image_id]['image_media_file'], "media", $next_prev_cache[$next_image_id]['cat_id'], 0, 1);
}
if (!get_file_path($next_prev_cache[$next_image_id]['image_thumb_file'], "thumb", $next_prev_cache[$next_image_id]['cat_id'], 0, 0)) {
$next_thumb_file = ICON_PATH."/".get_file_extension($next_prev_cache[$next_image_id]['image_media_file']).".gif";
}
else {
$next_thumb_file = get_file_path($next_prev_cache[$next_image_id]['image_thumb_file'], "thumb", $next_prev_cache[$next_image_id]['cat_id'], 0, 1);
}
}
else {
$next_image_name = REPLACE_EMPTY;
$next_image_url = REPLACE_EMPTY;
$next_image_file = REPLACE_EMPTY;
$next_thumb_file = REPLACE_EMPTY;
}
if (!empty($next_prev_cache[$prev_image_id])) {
$prev_image_name = format_text($next_prev_cache[$prev_image_id]['image_name'], 2);
$prev_image_url = $site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$prev_image_id.((!empty($mode)) ? "&mode=".$mode : ""));
if (!get_file_path($next_prev_cache[$prev_image_id]['image_media_file'], "media", $next_prev_cache[$prev_image_id]['cat_id'], 0, 0)) {
$prev_image_file = ICON_PATH."/404.gif";
}
else {
$prev_image_file = get_file_path($next_prev_cache[$prev_image_id]['image_media_file'], "media", $next_prev_cache[$prev_image_id]['cat_id'], 0, 1);
}
if (!get_file_path($next_prev_cache[$prev_image_id]['image_thumb_file'], "thumb", $next_prev_cache[$prev_image_id]['cat_id'], 0, 0)) {
$prev_thumb_file = ICON_PATH."/".get_file_extension($next_prev_cache[$prev_image_id]['image_media_file']).".gif";
}
else {
$prev_thumb_file = get_file_path($next_prev_cache[$prev_image_id]['image_thumb_file'], "thumb", $next_prev_cache[$prev_image_id]['cat_id'], 0, 1);
}
}
else {
$prev_image_name = REPLACE_EMPTY;
$prev_image_url = REPLACE_EMPTY;
$prev_image_file = REPLACE_EMPTY;
$prev_thumb_file = REPLACE_EMPTY;
}
$site_template->register_vars(array(
"next_image_id" => $next_image_id,
"next_image_name" => $next_image_name,
"next_image_url" => $next_image_url,
"next_image_file" => $next_image_file,
"next_thumb_file" => $next_thumb_file,
"prev_image_id" => $prev_image_id,
"prev_image_name" => $prev_image_name,
"prev_image_url" => $prev_image_url,
"prev_image_file" => $prev_image_file,
"prev_thumb_file" => $prev_thumb_file
));
unset($next_prev_cache);
//-----------------------------------------------------
//--- Save Comment ------------------------------------
//-----------------------------------------------------
$error = 0;
if ($action == "postcomment" && isset($HTTP_POST_VARS[URL_ID])) {
$id = intval($HTTP_POST_VARS[URL_ID]);
$sql = "SELECT cat_id, image_allow_comments
FROM ".IMAGES_TABLE."
WHERE image_id = $id";
$row = $site_db->query_firstrow($sql);
if ($row['image_allow_comments'] == 0 || !check_permission("auth_postcomment", $row['cat_id']) || !$row) {
$msg = $lang['comments_deactivated'];
}
else {
$user_name = un_htmlspecialchars(trim($HTTP_POST_VARS['user_name']));
$comment_headline = un_htmlspecialchars(trim($HTTP_POST_VARS['comment_headline']));
$comment_text = un_htmlspecialchars(trim($HTTP_POST_VARS['comment_text']));
$captcha = (isset($HTTP_POST_VARS['captcha'])) ? un_htmlspecialchars(trim($HTTP_POST_VARS['captcha'])) : "";
// Flood Check
$sql = "SELECT comment_ip, comment_date
FROM ".COMMENTS_TABLE."
WHERE image_id = $id
ORDER BY comment_date DESC
LIMIT 1";
$spam_row = $site_db->query_firstrow($sql);
$spamtime = $spam_row['comment_date'] + 180;
if ($session_info['session_ip'] == $spam_row['comment_ip'] && time() <= $spamtime && $user_info['user_level'] != ADMIN) {
$msg .= (($msg != "") ? "<br />" : "").$lang['spamming'];
$error = 1;
}
$user_name_field = get_user_table_field("", "user_name");
if (!empty($user_name_field)) {
if ($site_db->not_empty("SELECT $user_name_field FROM ".USERS_TABLE." WHERE $user_name_field = '".strtolower($user_name)."' AND ".get_user_table_field("", "user_id")." <> '".$user_info['user_id']."'")) {
$msg .= (($msg != "") ? "<br />" : "").$lang['username_exists'];
$error = 1;
}
}
if ($user_name == "") {
$msg .= (($msg != "") ? "<br />" : "").$lang['name_required'];
$error = 1;
}
if ($comment_headline == "") {
$msg .= (($msg != "") ? "<br />" : "").$lang['headline_required'];
$error = 1;
}
if ($comment_text == "") {
$msg .= (($msg != "") ? "<br />" : "").$lang['comment_required'];
$error = 1;
}
if ($captcha_enable_comments && !captcha_validate($captcha)) {
$msg .= (($msg != "") ? "<br />" : "").$lang['captcha_required'];
$error = 1;
}
if (!$error) {
$sql = "INSERT INTO ".COMMENTS_TABLE."
(image_id, user_id, user_name, comment_headline, comment_text, comment_ip, comment_date)
VALUES
($id, ".$user_info['user_id'].", '$user_name', '$comment_headline', '$comment_text', '".$session_info['session_ip']."', ".time().")";
$site_db->query($sql);
$commentid = $site_db->get_insert_id();
update_comment_count($id, $user_info['user_id']);
$msg = $lang['comment_success'];
}
}
unset($row);
unset($spam_row);
}
//-----------------------------------------------------
//--- Show Comments -----------------------------------
//-----------------------------------------------------
if ($image_allow_comments == 1) {
$site_template->register_vars(array(
"has_rss" => true,
"rss_title" => "RSS Feed: ".$image_name." (".str_replace(':', '', $lang['comments']).")",
"rss_url" => $script_url."/rss.php?action=comments&".URL_IMAGE_ID."=".$image_id
));
$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").",c.comment_rating,c.comment_votes,c.comment_rating_users
FROM ".COMMENTS_TABLE." c
LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = c.user_id)
WHERE c.image_id = $image_id
ORDER BY c.comment_date ".(COMMENTS_ORDER ? "DESC" : "ASC")."";
$result = $site_db->query($sql);
$comment_row = array();
while ($row = $site_db->fetch_array($result)) {
$comment_row[] = $row;
}
$site_db->free_result($result);
$num_comments = sizeof($comment_row);
if (!$num_comments) {
$comments = "<tr><td class=\"commentrow1\" colspan=\"2\">".$lang['no_comments']."</td></tr>";
}
else {
$comments = "";
$bgcounter = 0;
for ($i = 0; $i < $num_comments; $i++) {
$row_bg_number = ($bgcounter++ % 2 == 0) ? 1 : 2;
$comment_user_email = "";
$comment_user_email_save = "";
$comment_user_mailform_link = "";
$comment_user_email_button = "";
$comment_user_homepage_button = "";
$comment_user_icq_button = "";
$comment_user_profile_button = "";
$comment_user_status_img = REPLACE_EMPTY;
$comment_user_name = format_text($comment_row[$i]['comment_user_name'], 2);
$comment_user_info = $lang['userlevel_guest'];
$comment_user_id = $comment_row[$i]['user_id'];
if (isset($comment_row[$i][$user_table_fields['user_name']]) && $comment_user_id != GUEST) {
$comment_user_name = format_text($comment_row[$i][$user_table_fields['user_name']], 2);
$comment_user_profile_link = !empty($url_show_profile) ? $site_sess->url(preg_replace("/{user_id}/", $comment_user_id, $url_show_profile)) : $site_sess->url(ROOT_PATH."member.php?action=showprofile&".URL_USER_ID."=".$comment_user_id);
$comment_user_profile_button = "<a href=\"".$comment_user_profile_link."\"><img src=\"".get_gallery_image("profile.gif")."\" border=\"0\" alt=\"".$comment_user_name."\" /></a>";
$comment_user_status_img = ($comment_row[$i][$user_table_fields['user_lastaction']] >= (time() - 300) && ((isset($comment_row[$i][$user_table_fields['user_invisible']]) && $comment_row[$i][$user_table_fields['user_invisible']] == 0) || $user_info['user_level'] == ADMIN)) ? "<img src=\"".get_gallery_image("user_online.gif")."\" border=\"0\" alt=\"Online\" />" : "<img src=\"".get_gallery_image("user_offline.gif")."\" border=\"0\" alt=\"Offline\" />";
$comment_user_homepage = (isset($comment_row[$i][$user_table_fields['user_homepage']])) ? format_url($comment_row[$i][$user_table_fields['user_homepage']]) : "";
if (!empty($comment_user_homepage)) {
$comment_user_homepage_button = "<a href=\"".$comment_user_homepage."\" target=\"_blank\"><img src=\"".get_gallery_image("homepage.gif")."\" border=\"0\" alt=\"".$comment_user_homepage."\" /></a>";
}
$comment_user_icq = (isset($comment_row[$i][$user_table_fields['user_icq']])) ? format_text($comment_row[$i][$user_table_fields['user_icq']]) : "";
if (!empty($comment_user_icq)) {
$comment_user_icq_button = "<a href=\"http://www.icq.com/people/about_me.php?uin=".$comment_user_icq."\" target=\"_blank\"><img src=\"http://status.icq.com/online.gif?icq=".$comment_user_icq."&img=5\" width=\"18\" height=\"18\" border=\"0\" alt=\"".$comment_user_icq."\" /></a>";
}
if (!empty($comment_row[$i][$user_table_fields['user_email']]) && (!isset($comment_row[$i][$user_table_fields['user_showemail']]) || (isset($comment_row[$i][$user_table_fields['user_showemail']]) && $comment_row[$i][$user_table_fields['user_showemail']] == 1))) {
$comment_user_email = format_text($comment_row[$i][$user_table_fields['user_email']]);
$comment_user_email_save = format_text(str_replace("@", " at ", $comment_row[$i][$user_table_fields['user_email']]));
if (!empty($url_mailform)) {
$comment_user_mailform_link = $site_sess->url(preg_replace("/{user_id}/", $comment_user_id, $url_mailform));
}
else {
$comment_user_mailform_link = $site_sess->url(ROOT_PATH."member.php?action=mailform&".URL_USER_ID."=".$comment_user_id);
}
$comment_user_email_button = "<a href=\"".$comment_user_mailform_link."\"><img src=\"".get_gallery_image("email.gif")."\" border=\"0\" alt=\"".$comment_user_email_save."\" /></a>";
}
if (!isset($comment_row[$i][$user_table_fields['user_level']]) || (isset($comment_row[$i][$user_table_fields['user_level']]) && $comment_row[$i][$user_table_fields['user_level']] == USER)) {
$comment_user_info = $lang['userlevel_user'];
}
elseif ($comment_row[$i][$user_table_fields['user_level']] == ADMIN) {
$comment_user_info = $lang['userlevel_admin'];
}
$comment_user_info .= "<br />";
$comment_user_info .= (isset($comment_row[$i][$user_table_fields['user_joindate']])) ? "<br />".$lang['join_date']." ".format_date($config['date_format'], $comment_row[$i][$user_table_fields['user_joindate']]) : "";
$comment_user_info .= (isset($comment_row[$i][$user_table_fields['user_comments']])) ? "<br />".$lang['comments']." ".$comment_row[$i][$user_table_fields['user_comments']] : "";
}
$comment_user_ip = ($user_info['user_level'] == ADMIN) ? $comment_row[$i]['comment_ip'] : "";
$admin_links = "";
if ($user_info['user_level'] == ADMIN) {
$admin_links .= "<a href=\"".$site_sess->url(ROOT_PATH."admin/index.php?goto=".urlencode("comments.php?action=editcomment&comment_id=".$comment_row[$i]['comment_id']))."\" target=\"_blank\">".$lang['edit']."</a> ";
$admin_links .= "<a href=\"".$site_sess->url(ROOT_PATH."admin/index.php?goto=".urlencode("comments.php?action=removecomment&comment_id=".$comment_row[$i]['comment_id']))."\" target=\"_blank\">".$lang['delete']."</a>";
}
elseif ($is_image_owner) {
$admin_links .= ($config['user_edit_comments'] != 1) ? "" : "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=editcomment&".URL_COMMENT_ID."=".$comment_row[$i]['comment_id'])."\">".$lang['edit']."</a> ";
$admin_links .= ($config['user_delete_comments'] != 1) ? "" : "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=removecomment&".URL_COMMENT_ID."=".$comment_row[$i]['comment_id'])."\">".$lang['delete']."</a>";
}
$site_template->register_vars(array(
"comment_id" => $comment_row[$i]['comment_id'],
"comment_user_id" => $comment_user_id,
"comment_user_status_img" => $comment_user_status_img,
"comment_user_name" => $comment_user_name,
"comment_user_info" => $comment_user_info,
"comment_user_profile_button" => $comment_user_profile_button,
"comment_user_email" => $comment_user_email,
"comment_user_email_save" => $comment_user_email_save,
"comment_user_mailform_link" => $comment_user_mailform_link,
"comment_user_email_button" => $comment_user_email_button,
"comment_user_homepage_button" => $comment_user_homepage_button,
"comment_user_icq_button" => $comment_user_icq_button,
"comment_user_ip" => $comment_user_ip,
"comment_headline" => format_text($comment_row[$i]['comment_headline'], 0, $config['wordwrap_comments'], 0, 0),
"comment_text" => format_text($comment_row[$i]['comment_text'], $config['html_comments'], $config['wordwrap_comments'], $config['bb_comments'], $config['bb_img_comments']),
"comment_date" => format_date($config['date_format']." ".$config['time_format'], $comment_row[$i]['comment_date']),
"row_bg_number" => $row_bg_number,
"admin_links" => $admin_links
));
/*
MOD AJAX COMMENTS
BEGIN INSERT
*/
if (COMMENT_RATING_ANABLE)
{
$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
*/
$comments .= $site_template->parse_template("comment_bit");
} // end while
} //end else/*
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
*/
unset($comments);
//-----------------------------------------------------
//--- BBCode & Form -----------------------------------
//-----------------------------------------------------
$allow_posting = check_permission("auth_postcomment", $cat_id);
$bbcode = "";
if ($config['bb_comments'] == 1 && $allow_posting) {
$site_template->register_vars(array(
"lang_bbcode" => $lang['bbcode'],
"lang_tag_prompt" => $lang['tag_prompt'],
"lang_link_text_prompt" => $lang['link_text_prompt'],
"lang_link_url_prompt" => $lang['link_url_prompt'],
"lang_link_email_prompt" => $lang['link_email_prompt'],
"lang_list_type_prompt" => $lang['list_type_prompt'],
"lang_list_item_prompt" => $lang['list_item_prompt']
));
$bbcode = $site_template->parse_template("bbcode");
}
if (!$allow_posting) {
$comment_form = "";
}
else {
$user_name = (isset($HTTP_POST_VARS['user_name']) && $error) ? format_text(trim(stripslashes($HTTP_POST_VARS['user_name'])), 2) : (($user_info['user_level'] != GUEST) ? format_text($user_info['user_name'], 2) : "");
$comment_headline = (isset($HTTP_POST_VARS['comment_headline']) && $error) ? format_text(trim(stripslashes($HTTP_POST_VARS['comment_headline'])), 2) : "";
$comment_text = (isset($HTTP_POST_VARS['comment_text']) && $error) ? format_text(trim(stripslashes($HTTP_POST_VARS['comment_text'])), 2) : "";
$site_template->register_vars(array(
"bbcode" => $bbcode,
"user_name" => $user_name,
"comment_headline" => $comment_headline,
"comment_text" => $comment_text,
"lang_post_comment" => $lang['post_comment'],
"lang_name" => $lang['name'],
"lang_headline" => $lang['headline'],
"lang_comment" => $lang['comment'],
"lang_captcha" => $lang['captcha'],
"lang_captcha_desc" => $lang['captcha_desc'],
"captcha_comments" => (bool)$captcha_enable_comments
));
$comment_form = $site_template->parse_template("comment_form");
}
$site_template->register_vars("comment_form", $comment_form);
unset($comment_form);
} // end if allow_comments
// Admin Links
$admin_links = "";
if ($user_info['user_level'] == ADMIN) {
$admin_links .= "<a href=\"".$site_sess->url(ROOT_PATH."admin/index.php?goto=".urlencode("images.php?action=editimage&image_id=".$image_id))."\" target=\"_blank\">".$lang['edit']."</a> ";
$admin_links .= "<a href=\"".$site_sess->url(ROOT_PATH."admin/index.php?goto=".urlencode("images.php?action=removeimage&image_id=".$image_id))."\" target=\"_blank\">".$lang['delete']."</a>";
}
elseif ($is_image_owner) {
$admin_links .= ($config['user_edit_image'] != 1) ? "" : "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=editimage&".URL_IMAGE_ID."=".$image_id)."\">".$lang['edit']."</a> ";
$admin_links .= ($config['user_delete_image'] != 1) ? "" : "<a href=\"".$site_sess->url(ROOT_PATH."member.php?action=removeimage&".URL_IMAGE_ID."=".$image_id)."\">".$lang['delete']."</a>";
}
$site_template->register_vars("admin_links", $admin_links);
// Update Hits
if ($user_info['user_level'] != ADMIN) {
$sql = "UPDATE ".IMAGES_TABLE."
SET image_hits = image_hits + 1
WHERE image_id = $image_id";
$site_db->query($sql);
}
//-----------------------------------------------------
//---Clickstream---------------------------------------
//-----------------------------------------------------
$clickstream = "<span class=\"clickstream\"><a href=\"".$site_sess->url(ROOT_PATH."index.php")."\" class=\"clickstream\">".$lang['home']."</a>".$config['category_separator'];
if ($mode == "lightbox" && $in_mode) {
$page_url = "";
if (preg_match("/".URL_PAGE."=([0-9]+)/", $url, $regs)) {
if (!empty($regs[1]) && $regs[1] != 1) {
$page_url = "?".URL_PAGE."=".$regs[1];
}
}
$clickstream .= "<a href=\"".$site_sess->url(ROOT_PATH."lightbox.php".$page_url)."\" class=\"clickstream\">".$lang['lightbox']."</a>".$config['category_separator'];
}
elseif ($mode == "search" && $in_mode) {
$page_url = "";
if (preg_match("/".URL_PAGE."=([0-9]+)/", $url, $regs)) {
if (!empty($regs[1]) && $regs[1] != 1) {
$page_url = "&".URL_PAGE."=".$regs[1];
}
}
$clickstream .= "<a href=\"".$site_sess->url(ROOT_PATH."search.php?show_result=1".$page_url)."\" class=\"clickstream\">".$lang['search']."</a>".$config['category_separator'];
}
else {
$clickstream .= get_category_path($cat_id, 1).$config['category_separator'];
}
$clickstream .= $image_name."</span>";
//-----------------------------------------------------
//--- Print Out ---------------------------------------
//-----------------------------------------------------
$site_template->register_vars(array(
"msg" => $msg,
"clickstream" => $clickstream,
"lang_category" => $lang['category'],
"lang_added_by" => $lang['added_by'],
"lang_description" => $lang['description'],
"lang_keywords" => $lang['keywords'],
"lang_date" => $lang['date'],
"lang_hits" => $lang['hits'],
"lang_downloads" => $lang['downloads'],
"lang_rating" => $lang['rating'],
"lang_votes" => $lang['votes'],
"lang_author" => $lang['author'],
"lang_comment" => $lang['comment'],
"lang_prev_image" => $lang['prev_image'],
"lang_next_image" => $lang['next_image'],
"lang_file_size" => $lang['file_size']
));
$site_template->print_template($site_template->parse_template($main_template));
include(ROOT_PATH.'includes/page_footer.php');
?>
Heres my details.php file ~! ! !
Parse error: syntax error, unexpected T_STRING in /home/g2gayan/public_html/tutezone/details.php on line 461
Parse error: syntax error, unexpected T_STRING in /home/g2gayan/public_html/tutezone/details.php on line 461
I got this error when When assessing the Image !
Please Help me.. i followed the tut ! i cudnt fix this :( please Help me sir !
-
When you paste new block of code into your .php file, make sure you paste it at the beginning of a new line, not at the end of existing line (unless specifically instructed to do otherwise).
replace
} //end else/*
with
} //end else
/*
-
When you paste new block of code into your .php file, make sure you paste it at the beginning of a new line, not at the end of existing line (unless specifically instructed to do otherwise).
replace
} //end else/*
with
} //end else
/*
Thank you sir :) it wasa silly mistake..im soryy..i was confused :D :mrgreen: Im ALways that when i get a error :mrgreen:
-
Tweak: If you want combine this Mod with the ReCapture Mod ( http://www.4homepages.de/forum/index.php?topic=22881.0 ) you might notice that the recapture image doesn't refresh if the user hasn't fulfil the challenge. Because the challenge cannot be repeated, the user has to get a new image with words he has to type. Here it is how it works without page relad:
Open js/ajaxcomments.js
Locate:
if (rsp['clear'] || rsp['error'])
{
if (ajaxGetObject('captcha_image'))
{
new_captcha_image();
}
if (ajaxGetObject("captcha_input"))
{
ajaxGetObject("captcha_input").value = "";
}
Insert below:
Recaptcha.reload();
That's all ;)
Regards,
Bash-T
-
Thank you.
I've added it into v1.0.2
-
Nice, Thank you! 8)
-
Hi I like to this mod ignore the comments that are collapsed and show the default comments un-collapsed
for example in one image that show 5 comments per page when a comment its collapsed there are still five comments but one collapsed, I like to show 6 comments 5 un-collapsed and the one that its collapsed (hidden)
-
Hi v@no,
I installed it successfully. But only one thing, captcha image doesn't validate and check, which means i can submit blank or type wrongly and submit. It accepts. Which can be cost ? Is it because of i didn't install recaptcha mod right ? I check ajaxcomments.php and i saw the code there's about checking captcha which is like this
if ($captcha_enable_comments && !captcha_validate($captcha)) {
$msg .= (($msg != "") ? "<br />" : "").$lang['captcha_required'];
$error = 1;
}
Other fields are working as normal, like headline, comment. Just that captcha ? Any idea what should i missing ? I am using latest version of 4images.
With Regards,
-
Make sure you test it as regular member or guest, NOT as admin
@live@ct:
it will be kind of difficult to do without proper database query...I'm clueless on how this can be done...
-
oops .. no wonder, i am testing with admin :( . Sorry . Works Perfect !
-
1- the comment text appears perfect for non-english but some texts (commentformmgs, comments:, joindate:, admin, edit, delete and username) appear like this "�������". the problem happens only after I go to another page or when I post new comments.
2- when I rate a comment (good or bad), the result does not appear instantly. I have to refresh the page. this problem DOES NOT happen if I rate after going to another page or after posting new comments.
I hope I can find solutions or hints.
thanks again
same problem here V@no....
I am pretty sure it's the issue with my code page... my database uses utf-8 and site uses cp1251... but how do you make them work together?...
-
Redownload the package v1.0.3 and replace ajaxcomments.php
Hopefully it won't break anything for these who didn't have this problem...
-
Re-download the package and replace only ajaxcomments.php file.
Also, I've changed Step 7.6 (http://www.4homepages.de/forum/index.php?topic=23866.0#post_step7-6)
Apparently InternetExplorer chokes when JS tries change innerHTML in a table, so you'll need add a SPAN or DIV around the table with {comments} tag.
Problem V@no... comments now get encoded into a diiferent encoding in the database... and this effects the display in my last comments MOD on the front page... screen attached...
could the rating of the comments function stay and can the posting be disabled through AJAX? would this be feasible?
-
The problem is the javascript. It always sends data in UTF8 encoding, disregarding the encoding of the page it is running from.
Because of that 4images automatically encode everything into html entities...this was done to make most compatible with any encodings and any mysql encodings.
If you capture the data sent by javascript, then you'll see any non-latin letters converted into unicode code. for example word тест will be sent as %u0442%u0435%u0441%u0442
Also, if your site charset is different from the text a user input when using non-ajax post, then browser will still convert non-latin letters into unicode html entities (&#xxxx)...
So, if you try convert html entities into your charset, then text from other encoding that might be in the input will be garbage. That's why 4images doesn't even attempt convert html entites into a charset, which allows input any text in any encoding on pages with any charsets.
I think you'd better off (easier) fixing the home page comments code then trying mess with this nonsense...
P.S.
These encodings are such pain the crack...
let's all at last switch to a long-to-live UTF-32 that will be enough for all the languages and dialects including dead Maya language and get over with this!
[EDIT]
Found a solution, but only for PHP v4.3.0 or newer:
Updated to v1.0.4
- CHANGED: on servers with PHP v4.3.0 or newer with html_entity_decode (http://php.net/manual/function.html-entity-decode.php) enabled non-latin letters should be converted into proper charset.
To update - re-download ajaxcomments_v1.0.4.zip (http://www.4homepages.de/forum/index.php?topic=23866.msg130731#post_attachment) and replace ajaxcomments.php
-
V@no, is there a way to disable AJAX comments (let the page refresh) but keep the AJAX comments ratings if you know what I mean...
I just have some functions that do not work with comment postings... but AJAX comment rating I would like to keep (otherwise I would have just uninstalled the MOD)...
-
Remove changes from steps 9 and 10
-
working great!
-
hallo zusammen
hab diesen MOD installiert und seit dem funktioniert der hier nicht mehr:
[Mod] Mail Owner of image when Comment is Posted
http://www.4homepages.de/forum/index.php?topic=2705.0
weiss Jemand wie man beide MODs gleichzeitig zum laufen bringt?
-
hallo zusammen
hab diesen MOD installiert und seit dem funktioniert der hier nicht mehr:
[Mod] Mail Owner of image when Comment is Posted
http://www.4homepages.de/forum/index.php?topic=2705.0
weiss Jemand wie man beide MODs gleichzeitig zum laufen bringt?
Do same modifications in ajaxcomments.php as in details.php
-
@ V@no!
Please help how do I remove this MOD. I have reversed the changes I made to details.php and main.php.
I get this error still "Parse error: syntax error, unexpected ']', expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/dharmaji/public_html/kaachaya.com/details.php on line 430 "
How do I reverse the effects made by install_ajaxcomments.php ??? Thanks in advance for a quick solution!
This is my full details.php
-
Hello kaachaya, welcome to 4images forum.
The error you showed is due to error you've made when modified details.php (you should always do backup before you do any modifications, very good and helpful practice ;)) (attached fixed version, but if you didn't install any mods in that file, I'd advise you use unmodified version from 4images package instead)
As of install_ajaxcomments.php, that file only modifies database structure.
You'll need manually delete these changes or run this query in phpmyadmin:
ALTER TABLE `4images_comments`
DROP `comment_rating`,
DROP `comment_votes`,
DROP `comment_rating_users`;
-
Hi V@no,
vielen Dank für diese schöne Modifikation. Leider habe ich das gleiche Problem wie tikle. Der [Mod] Mail Owner of image when Comment is Posted funktioniert nicht in der Kombination mit dem [MOD] AJAX Comments / Comments Rating v1.0.4. . E- Mails werden nicht verschickt. Gerade um User ansprechen zu können und ihre Aktivitäten in der Galerie zu fördern, wäre dies aus meiner Sicht wichtig und schön.
Deinen Hinweis ...
Do same modifications in ajaxcomments.php as in details.php
... habe ich versucht umzusetzen. Er hat aber leider nicht zum Erfolg geführt. Es wäre nett, wenn du helfen könntest.
Hier ist der Teil aus meiner details.php:
//-----------------------------------------------------
// Start Emailer for comments
//-----------------------------------------------------
$recipient_name = $image_row['user_name'];
$recipient_email = $image_row['user_email'];
$image_url = $script_url."/details.php?".URL_IMAGE_ID."=".$id;
$sql = "SELECT user_allowemails FROM ".USERS_TABLE." WHERE ".get_user_table_field("", "user_name")." = '".$recipient_name."'";
$result = $site_db->query($sql);
$row = $site_db->fetch_array($result);
$user_allowemails = ($row['user_allowemails']);
if ($image_row['user_id'] != $user_info['user_id'] && $user_allowemails == 1) {
include(ROOT_PATH.'includes/email.php');
$site_email = new Email();
$site_email->set_to($recipient_email);
$site_email->set_from($config['site_email'], $config['site_name']);
$site_email->set_subject($lang['send_comment_emailsubject']);
$site_email->register_vars(array(
"user_name" => stripslashes($user_name),
"recipient_name" => stripslashes($image_row['user_name']),
"image_name" => $image_row['image_name'],
"comment_date" => format_date($config['date_format']." ".$config['time_format'], $current_time),
"site_name" => $config['site_name'],
"image_url" => $image_url,
"comment_text" =>(stripslashes($comment_text)),
"comment_headline"=>(stripslashes($comment_headline)),
));
$site_email->set_body("comment_email", $config['language_dir']);
$site_email->send_email();
}
}
}
unset($row);
unset($spam_row);
}
Wenn ich diesen Code unterhalb der Zeile
update_comment_count($id, $user_info['user_id']);
einsetze erfolgt leider trotzdem kein E-Mailversand. Für deine oder die Hilfe anderer User wäre ich dankbar. Hat denn jemand beide MODs gleichzeitig funktionierend eingebaut? Wenn ja, wie muss man vorgehen?
Viele Grüße, Frank.
-
In ajaxcomments.php find:
update_comment_count($id, $user_info['user_id']);
Insert below :below::
$current_time = time();
$sql = "SELECT i.image_name, i.user_id" . get_user_table_field(", u.", "user_name") . get_user_table_field(", u.", "user_email") . get_user_table_field(", u.", "user_allowemails") . "
FROM " . IMAGES_TABLE . " i
LEFT JOIN " . USERS_TABLE . " u ON (" . get_user_table_field("u.", "user_id") . " = i.user_id)
WHERE image_id = $id";
$image_row = $site_db->query_firstrow($sql);
$image_name = $image_row['image_name'];
$user_id = $image_row['user_id'];
if ($image_row['user_id'] != $user_info['user_id'] && $image_row[$user_table_fields['user_allowemails']] == 1)
{
$recipient_name = $image_row[$user_table_fields['user_name']];
$recipient_email = $image_row[$user_table_fields['user_email']];
$image_url = $script_url."/details.php?".URL_IMAGE_ID."=".$id;
// Start Emailer fur comments
include(ROOT_PATH.'includes/email.php');
$site_email = new Email();
$site_email->set_to($recipient_email);
$site_email->set_from($config['site_email'], $config['site_name']);
$site_email->set_subject("Comment Posted");
$site_email->register_vars(array(
"user_name" => $recipient_name,
"recipient_name" => $recipient_name,
"image_name" => $image_row['image_name'],
"comment_date" => format_date($config['date_format']." ".$config['time_format'], $current_time),
"site_name" => $config['site_name'],
"image_url" => $image_url,
));
$site_email->set_body("comment_email", $config['language_dir']);
$site_email->send_email();
}
-
Hello VANo
you said find
ORDER BY c.comment_date ASC
with
ORDER BY c.comment_date ".(COMMENTS_ORDER ? "DESC" : "ASC")."
Now im confused, when i do, some syntax code after I have replaced it changes to dark brown, this is probebly due to the quote at the end of the code u told us to replace it with, now is this correct and is this what is suppose to happen?
Thank us ir
-
I just realized that there are two possible such lines and only one line that needs to be changed.
I've updated step 4.5 with new instructions.
-
Helo V@no
There seems to be a problem,
ok, number 1, when i post a comment it does not appear in real time, i then refresh the page and then the comment has appeared, at first i thought it was permission set, so i checked it and then it wasnt, i then tried it but previously before the update, comments appeared quickyl, but i think the page refreshed, and i love this MOD as it doesnt require refresh but it doesnt work, no comments appear.
O yeee, anoter thing, when user post 1 comment then they cant post another, when i log in as administrator i can post a comment continuously but i must refresh the page manually for it to appear, like i said i thought it may be the persmissions but it wasnt, and at first i thought it may be the captcha but it wasnt, a user cannot post more than 1 comment and also does not apper in real time... any ideas???
Thanks sir,
-
ok, number 1, when i post a comment it does not appear in real time, i then refresh the page and then the comment has appeared, at first i thought it was permission set, so i checked it and then it wasnt, i then tried it but previously before the update, comments appeared quickyl, but i think the page refreshed, and i love this MOD as it doesnt require refresh but it doesnt work, no comments appear.
Check for any javascript errors in your browser
Also if you done steps 7 and 8 manually, then try pre-modified attached (http://www.4homepages.de/forum/index.php?topic=23866.0#post_attachment) template files instead
O yeee, anoter thing, when user post 1 comment then they cant post another, when i log in as administrator i can post a comment continuously but i must refresh the page manually for it to appear, any ideas???
4images has built-in flood protection that prohibits non-administrators post more then 1 comment per 2 minutes. Administrators don't have such restriction.
-
thank u for the reply,
ok here is what i did
I had previously replaced the pre-modified html 4 part pages into my template, now i have a few problems..
I am using default 960 but now that i have uplaoded the pre-modified page (detail.html) my page had gone smaller to the smaller version default. also please can u tell me how to remove flood protection as it is stopping me from beta testing it. o ye one more thing, the JS folder, do i place the contents inside the folder into the 4images directory right? not 4images/template/<my template>? or is it the other way round and i have to have the contents inside the JS folder for it to work.
_______________
UPDATE****
Good news, it seems be working however, my pages are in details.html layout isnt 960px while all the other pages are, good news is that comenting works in real time and that now all i need to know is how to tweak the details so that it accepts 960px as i think i know what may have caused it, previously i had uploaded the pre-modifed pages realized the detail.html was default small version and then replaced it back with the default 960, and i think this is what was causing the problem. any ideas how to fix it...
So basically sir, all i ned is ur assistence in...
1) helping me to make the detail.html default 960px
2) stop flood protection to 20seconds not 2 minutes
3) and comment pages being created after 10 comments not 5,
GOD BLESS U sir
Thank u for all the hard work u do for us, i really do appreciate it
-
I had previously replaced the pre-modified html 4 part pages into my template, now i have a few problems..
I am using default 960 but now that i have uplaoded the pre-modified page (detail.html) my page had gone smaller to the smaller version default.
Remember, before you do any other modifications to a mod, make sure that it's working properly, otherwise you'll endup into a crossroads when you won't know was it mod's modifications screwed things up, or yours...So, install the mod without any additional modifications, test it, make sure everything is working properly, then start tweaking.
also please can u tell me how to remove flood protection as it is stopping me from beta testing it.
in details.php and ajaxcomments.php search for number 180 replace it with 0 (don't forget change it back when you are done ;))
o ye one more thing, the JS folder, do i place the contents inside the folder into the 4images directory right? not 4images/template/<my template>?
correct, JS folder must be inside your 4images root directory.
3) and comment pages being created after 10 comments not 5,
There should be a dropdown menu to select how many comments per page will be shown.
Template modifications - compare unmodified default and default_960px templates and do the differences in your templates.
-
******* update number 2
Sorry i deleted my previous comment, basicailly in the previous comment i said when i refresh the page the comments are all shown, and for example a user clicks on an image and then they will see, lets say 40 messages all in 1 page, when a user then makes a comment, everything then goes into order, so it will create pages, 1, 2, 3, 4, 5, 6, 7. When i then refresh the page again all the comments are shown in 1 page again, until someone makes comment which thens make allt he comments into pages. And i dont know if there is a bug but if it is like this and this is how it is created, is there a way to stop it being like this? or completly remove the paging comment system altogether.
Any ideas what i do should, P.S i will defiantely test first then modify
thanks mate
-
if you removed paging for comments, then you'll need remove all changes from steps that marked with "(only if done Step 3)"
and then set COMMENTS_PAGES to 0 (refer to Tweak 1 (http://www.4homepages.de/forum/index.php?topic=23866.0#post_tweak1))
-
V@no, i hope u r ok,
But this is a massive confusion... I deleted my previous comment because i read it 100x trying to see if i made any sense and because u didnt reply to me i thought that maybe i didnt make any sense, but i dont know how to explain it, its very hard my english is not so perfect and i cannot convey what i am trying to say. axxxxx what can i do ok i dont know if u r understanding my position :-(
basiicailly there are 2 very contradictary and confusing coding...
on http://www.4homepages.de/forum/index.php?topic=5830.0 (http://www.4homepages.de/forum/index.php?topic=5830.0) and so to step 1.2, in that code as u see, u saying replace 1 query code for another. Ok no problem. Lets say i do this, i go now into ajax commenting system and on step 4.5 http://www.4homepages.de/forum/index.php?topic=23866.0 (http://www.4homepages.de/forum/index.php?topic=23866.0) You are saying to us to replace one query for an another, but on paging system we already removed this query for another, so you mean remove paging system step 1.2 query now for ajax commenting step 4.5 query.
All night i not sleep becuase i reading my comment for u for last night tying to hope i make 1% sense and trying to see ur code if i am just being stupid :-( but 100/100 i check and check i am confused... what i did is first ajax commenting system, then it was having problem with commenting and i go back now and cover step 3 which i previously skipped, but as you see from my explanation that 1.2 contradicts 4.5 and vice versa. Im sorry Vano, i know i am stupid maybe i make no sense and i hope you can understand what i am saying im sorry please forgive me
:-(
-
Now I understand why my original instructions were specifically said to find/replace part of a line...
I've split step 4.5 into two different instructions.
-
Below is the code that will give me ASC to DESC for the comments so that it shows new comments first then old ones. However
$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").$additional_sql."
FROM ".COMMENTS_TABLE." c
LEFT JOIN ".USERS_TABLE." u ON (".get_user_table_field("u.", "user_id")." = c.user_id)
WHERE c.image_id = $image_id
ORDER BY c.comment_date DESC
LIMIT $offset, $commentperpage";]
The code highlighted red above was replaced by the code below because of Ajax commenting 4.5 MOD, do i revert it back to code above?...
WHERE c.image_id = $image_id
ORDER BY c.comment_date ".(COMMENTS_ORDER ? "DESC" : "ASC")."";
, so do i now revert it back? Thanku Vano, you are a good person.
-
You've said you don't want paging feature, so leave it without LIMIT $offset, $commentperpage
-
no sir sorry what i want to have the comments going from new to old regarding the paging, so right now i removed the paging and when i make comments it goes from oldest to newest, i want it to go from newest to oldest so i want the comments to go to the top not be placed at the botoom
-
Just read the comments from tweak 1.
-
@Vano,
I need your advice sir,
in step 8.1 it says replace {comment} with
<!--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 -->
However I have set my dreamweaver to highlight code to yellow if it does not look right. And inside the the code above the divs are highlights yellow. Now please just give me yes or no answer. Because i know u r very busy. Is this how it is suppose to be or is there error inside this code??
thnk u vano.
-
When it comes to 4images templates There is no HTML editor that could possibly show you on 100% if syntax is correct or not, because the template tags will be replaced with true html before page is displayed in your browser.
The only 100% proof if syntax is correct or not, is to view the page's source from the browser.
I can't tell you why it's showing it yellow, perhaps it doesn't like the template tags inside html tags...who knows, do the changes, then validate the HTML code from page source in the browser.
P.S.
Once again, please use [code][/code] tags when showing code, not colored text.
-
Hi,
if have installed this mod but have still a problem and i cannot find the solution.
If i enter the details page the comments look like:
(http://www.xup.in/pic,12375323/temp1.jpg) (http://www.xup.in/dl,12375323/temp1.jpg/)
the comment vote forms are shown on top and not near the comment it belongs to, but if use the paging and
switch to other comments it looks like:
(http://www.xup.in/pic,19105033/temp2.jpg) (http://www.xup.in/dl,19105033/temp2.jpg/)
the comment vote are now shown on top and also to every comment. Now i tried to vote for a comment from
another user this is what happens:
(http://www.xup.in/pic,30942392/temp3.jpg) (http://www.xup.in/dl,30942392/temp3.jpg/)
I voted for the bottom comment, then the vote form on top changed and is disabled, and the vote form near
the comment i have voted for is allready available but not clickable ones.
Also the vote counter is not changing at the vote form near the comment only the one on the top.
The Problem must be over the comments table:
(http://www.xup.in/pic,15088442/temp4.jpg) (http://www.xup.in/dl,15088442/temp4.jpg/)
Where is the mistake?
I have attached my details.php details.html, comment_form.html, comment_bit.html, comment_popup_form.html & ajaxcomments.php
(I will delete these attachments if i could solve my problem)
@Vano please help me.
Greetz X23
-
The question is, did it work before you started doing your own modifications?
-
The question is, did it work before you started doing your own modifications?
Hi,
what do you mean the comment related files? And all comment related function?
Yes it worked well then i tried to implement your ajax rating and have that
failure after doing it, im sure its something related to my template files but i cannot
understand what part of code is placing all the rate forms on top?
if i place for testing purposes some text in front of the table:
<span id="commentstable">
test
<table width="640px" border="0" cellpadding="3" cellspacing="1">
it looks like this:
(http://www.xup.in/pic,13826242/temp1.jpg) (http://www.xup.in/dl,13826242/temp1.jpg/)
What is placing the vote forms? is it the span tag?
How can i figure out to fix that?
EDIT:
Maybe it something with with comment_bit.html?
if i remove the comment tag:
<!--COMMENTSTART-->
<!--{comments}-->
<!--COMMENTEND-->
All vote forms are gone (sure) also that on top, so i think i have to check the comment_bit.html?!
EDIT2:
Strange, if i disable comment rating in ajaxcomments.php all the comment will be shown in the +
spoiler nevermind what rating they have if i change the pages of comments.
The first view is ok but after changing to another comments page (if paging) only spoilers are shown.
Then i tried to switch paging off but no reaction the paging is allready there
(i have installed paging for comments and universal paging class)
And yes it worked fine before i started with ajaxcomments... hmm im sure i made a mistake but
i cannot find a something missing or wrong related to your installation instructions.
Can you maybe look into my attached files on first post?
EDIT3:
Ok you can stop here, i tried your default template files and there its working fine,
must be some mistaken by me in one of my template files...
...i try to find out my damn bug.
Thanks
EDIT4:
Huh it's the comment_bit.html know i only have to check out whats exactly related to that file. :)
Feel's better now:
(http://www.xup.in/pic,94867452/temp1.jpg) (http://www.xup.in/dl,94867452/temp1.jpg/)
Greetz X23
-
Does anyone know how to show next to username in commets count of +/- rates which member received?
-
hi V@no,
thanks for great mod but can we make comments page navigation also in Ajax like youtube with out reload page ?
thank you
-
Yes, that is one of the features of this mod. Review step 3 for more info.
-
i tried it in my localhost and i notice two things
1- if you play video or flash and switch between comments pages it will reload the page and the video return to first part actually not a big problem but if we can change it like youtube you can switch between comments pages while playing the video :)
2- there is conflict between this mod and SEO in this thread
http://www.4homepages.de/forum/index.php?topic=17598.0
the problem is SEO script replace image_id with blank '' and because of that paging and comments perpage dropdown menu not working
EDIT:
i found solution for comments problem by changing javascript code in ajaxcomments.js
previous code
function CommentsPage(obj)
{
var href = obj.getAttribute("href");
var Query = href.substr(href.indexOf("?")+1);
var Url = ajaxCommentsUrl + (ajaxCommentsUrl.indexOf("?") != -1 ? '&' : '?') + 'js&action=commentget&' + Query;
return !ajaxSend([ajaxCommentsResponse, Url, "GET", null, obj]);
}
function CommentsPerPage(obj)
{
var Query = ajaxGetFormQuery(obj);
// var Query = ajaxGetFormQuery(obj,['page', Page]); // use this line if you want stay on the same page number
var Url = ajaxCommentsUrl + (ajaxCommentsUrl.indexOf("?") != -1 ? '&' : '?') + 'js&action=commentget&' + (obj.getAttribute('action').indexOf("?") != -1 ? obj.getAttribute('action').substring(obj.getAttribute('action').search("\\?")+1) : '');
return !ajaxSend([ajaxCommentsResponse, Url, "POST", Query, obj]);
}
replace with
function CommentsPage(obj)
{
var href = obj.getAttribute("href");
var Query = href.substr(href.indexOf("-")+1);
var Query1 = Query.split(".html?");
var Url = ajaxCommentsUrl + (ajaxCommentsUrl.indexOf("-") != -1 ? '&' : '?') + 'js&action=commentget&' + 'image_id=' + Query1[0] + '&' +Query1[1];
return !ajaxSend([ajaxCommentsResponse, Url, "GET", null, obj]);
}
function CommentsPerPage(obj)
{
var Query = ajaxGetFormQuery(obj);
var Query1 = obj.getAttribute('action').substring(obj.getAttribute('action').search("\\-")+1);
var Query2 = Query1.split(".html");
// var Query = ajaxGetFormQuery(obj,['page', Page]); // use this line if you want stay on the same page number
var Url = ajaxCommentsUrl + (ajaxCommentsUrl.indexOf("?") != -1 ? '&' : '?') + 'js&action=commentget&' + (obj.getAttribute('action').indexOf("-") != -1 ? 'image_id='+Query2[0]+Query2[1] : '');
return !ajaxSend([ajaxCommentsResponse, Url, "POST", Query, obj]);
}
because image url after SEO is (image-443.html)
Thank you
-
Just noticed something- In step 4.6, shouldn't "if (COMMENT_RATING_ANABLE)" be "if (COMMENT_RATING_ENABLE)"?
-
installed this mod: http://www.4homepages.de/forum/index.php?topic=29664.0
introduced in ajaxcomments.php changes using the code for the original details.php. mod is work, but after adding the comment button quote refers not to details.php? image_id =..., and on ajaxcomments.php. that is when you click on it to pass to a nonexistent page. you refresh the page - everything is working properly.
In addition, when you quote and reply to the message - the window is still open response.
have ideas about how to combine these mods?
-
FIX
Problem: When i post a comment the userpic is broken, but when i refresh the page it's there.
If you are using this mod with the "Userpic MOD" and get a broken image after you submit your comment follow those steps:
open ajaxcomments.php
find
get_user_table_field(", u.", "user_icq")."
replace with
get_user_table_field(", u.", "user_icq")." ,u.userpic,
find
"comment_user_ip" => $comment_user_ip,
add below
"comment_userpic" => ($config['userpic'] && $comment_row[$i]['userpic']) ? ROOT_PATH."data/userpic/".$comment_row[$i]['userpic'] : "",
thats it - now you dont have a broken image ;)
-
V@no,
I am trying to add something to that wonderful mod. I have a custom field named "user_karma". What I am trying to achieve is to update that field depending on how a comment is being rated. For example if someone rates my comment up i get +10 karma, when someone votes it down i get -10.
like "SET user_karma=user_karma+10 WHERE user_id = $user_id";".
I guess I have to modify the function "if ($action == "ratingset")". Can you give me some advise?
-
I'd suggest do it below
if (!($result = $site_db->query($sql)))
return false;
(inside comment_rating_update function)
Something like this:
if ($row['user_id'] != GUEST)
{
$sql = "UPDATE " . USERS_TABLE . "
SET user_karma = user_karma + " . ((int)$rating > 0 ? 10 : -10) . "
WHERE " . get_user_table_field("", "user_id") . " = " . $row['user_id'];
$result = $site_db->query($sql);
}
-
Thank's V@no, that works like a charm! : )
-
Hello,
There is a problem with version 1.8 and mod ajax comment.
Only the characters of type éààçùâô are displayed "?" And are not recognized in a new post comment.
The previous comments appear correctly.
Does anyone have a clue or a solution ?
Thanks a lot, have a nice day.
-
i couldent do that also :( :( :(