Navigation
Last Seen Users
inflames00:11:21
topek00:18:07
madsen00:57:51
sandyaj01:42:03
adamo9402:54:56
HunorR04:19:54
Hamyncgagjavy04:29:40
BRETLEE003504:38:59
wepo04:44:23
veselinvankov04:55:05

Members: 27,611
Newest: adamo94
Downloads v7
Downloads v6
One-click Translation
Translate This Site

Member Poll
Which version of PHP-Fusion are you using?

6.xx.xx
6.xx.xx
4% [19 Votes]

7.00.xx
7.00.xx
8% [38 Votes]

7.01.xx
7.01.xx
8% [40 Votes]

7.02.xx
7.02.xx
81% [404 Votes]

Votes: 501
You must login to vote.
Started: 26/03/2012 11:58

Polls Archive
Login
Username

Password



Not a member yet?
Click here to register.

Forgotten your password?
Request a new one here.
Connect via Facebook
Connect via Facebook
Our Coders
Shoutbox
You must login to post a message.

24-05-2013 04:24
Hi, I do think this is a great site. I stumbledupon it Wink I may revisit yet again since i have saved as a favorite it. <a href="http://review
sonraspberryketone
.tripod.co.uk">Raspb
erry

24-05-2013 01:10
mainkan disini games Permainan Memasak secara online

24-05-2013 00:42

23-05-2013 18:23

23-05-2013 01:18
swarovski schmuckswarovski schmuck swarovski schmuck günstigswarovski schmuck günstig

23-05-2013 01:17
monster beatsmonster beats beats by drebeats by dre

23-05-2013 01:16
ugg pas cherugg pas cher bottes uggbottes ugg

23-05-2013 01:14
ugg pas cherugg pas cher

23-05-2013 01:12
<a href="http://www.bo
ttesuggpaschersold
e.com/">ugg pas cher</a>ugg pas cher

22-05-2013 05:14

Shoutbox Archive
In memoriam

Nick Jones
1973-2011

Sponsors
Articles Hierarchy
Comments Advanced View and Anti-Spam Captcha Image
Here is a small modification that I've made to the php fusion so that we can enjoy a fully functional well displayed paged COMMENTS (15 per page) + captcha image anti-spam protection and not this a bit silly math calculation....

First of all you have to edit files so make a copy before editing each one. Now let's stick to the business:

**************************
Open your includes/comments_include.php and replace the code within with this one:

<?php
/*---------------------------------------------------+
| PHP-Fusion 6 Content Management System
+----------------------------------------------------+
| Copyright  2002 - 2005 Nick Jones
| http://www.php-fusion.co.uk/
+----------------------------------------------------+
| Released under the terms & conditions of v2 of the
| GNU General Public License. For details refer to
| the included gpl.txt file or visit http://gnu.org
+----------------------------------------------------+
| Comments system developed by CrappoMan
| email: simonpatterson@dsl.pipex.com
+----------------------------------------------------*/
if (!defined("IN_FUSION")) { header("Location:../index.php"); exit; }

include LOCALE.LOCALESET."comments.php";

function showcomments($ctype,$cdb,$ccol,$cid,$clink,$rowstartt) {

    global $settings,$locale,$userdata,$aidlink;
    

    if (isset($_POST['post_comment'])) {
global $settings,$locale,$userdata,$aidlink;


if (isset($_POST['post_comment'])) {
if (dbrows(dbquery("SELECT $ccol FROM ".DB_PREFIX."$cdb WHERE $ccol='$cid'"))==0) {
fallback(BASEDIR."index.php");
}
if (iMEMBER) {
$comment_name = $userdata['user_id'];
} elseif ($settings['guestposts'] == "1") {
$comment_name = trim(stripinput($_POST['comment_name']));
$comment_name = preg_replace("(^[0-9]*)", "", $comment_name);
if (isNum($comment_name)) $comment_name="";
}
$comment_message = trim(stripinput(censorwords($_POST['comment_message'])));
$comment_smileys = isset($_POST['disable_smileys']) ? "0" : "1";
if ($comment_name != "" && $comment_message != "") {
if (!check_captcha($_POST['captcha_encode'], $_POST['captcha_code'])) {
if (checkrights("C")) {
$result = dbquery("INSERT INTO ".DB_PREFIX."comments VALUES('', '$cid', '$ctype', '$comment_name', '$comment_message', '$comment_smileys', '".time()."', '".USER_IP."')");
redirect($clink);
}
else { $error .= "· <span class='alt'><b>Please enter correct verification code!</b></span><br />\n"; }
}
else {
$result = dbquery("INSERT INTO ".DB_PREFIX."comments VALUES('', '$cid', '$ctype', '$comment_name', '$comment_message', '$comment_smileys', '".time()."', '".USER_IP."')");
redirect($clink);
}
}
}
} else {
$invalid = true;
$comment_message2 = trim(stripinput(censorwords($_POST['comment_message'])));
}

    tablebreak();
    $rows = dbrows(dbquery("SELECT tcm.*,user_name FROM ".DB_PREFIX."comments tcm
        LEFT JOIN ".DB_PREFIX."users tcu ON tcm.comment_name=tcu.user_id
        WHERE comment_item_id='$cid' AND comment_type='$ctype'
        ORDER BY comment_datestamp DESC")); // Ausgabe der Anzahl an Threads no sticky
    if (!isset($rowstartt) || !isNum($rowstartt)) $rowstartt = 0;
    if ($rows==0) $rowstartt = 0;
    opentable($locale['c100']);
    if ($rows > 15) {
        echo "<table cellspacing='1' cellpadding='0' border='0' width='100%'><tr><td valign='bottom'>";
        $clink2 = str_replace('.htm','',$clink);
        echo forumpagenav($rowstartt,15,$rows,3,$clink2)."</td></tr></table>\n";
    }
    $result10 = dbquery(
        "SELECT tcm.*,user_name FROM ".DB_PREFIX."comments tcm
        LEFT JOIN ".DB_PREFIX."users tcu ON tcm.comment_name=tcu.user_id
        WHERE comment_item_id='$cid' AND comment_type='$ctype'
        ORDER BY comment_datestamp DESC LIMIT ".$rowstartt.", 15"
    );
    if (dbrows($result10) != 0) {
        $i = 0;
        echo "<table width='100%' cellpadding='0' cellspacing='1' class='tbl-border'>\n";
        while ($data = dbarray($result10)) {
            echo "<tr>\n<td class='".($i% 2==0?"tbl1":"tbl2")."'><span class='comment-name'>\n";
            if ($data['user_name']) {
                echo "<a href='".BASEDIR.seoname($data['user_name'])."-user".$data['comment_name'].".htm'>".$data['user_name']."</a>";
            } else {
                echo $data['comment_name'];
            }
            if ($data['comment_smileys'] == "1") {
                $comment_message = parsesmileys($data['comment_message']);
            } else {
                $comment_message = $data['comment_message'];
            }
            $comment_message = nl2br(parseubb($comment_message));
            echo "</span>\n<span class='small'>".$locale['041'].showdate("longdate", $data['comment_datestamp'])."</span><br>\n";
            echo $comment_message."</td>\n</tr>\n";
            $i++;
        }
        if (checkrights("C")) echo "<tr>\n<td align='right' class='".($i% 2==0?"tbl1":"tbl2")."'><a href='".ADMIN."comments.php".$aidlink."&ctype=$ctype&cid=$cid'>".$locale['c106']."</a></td>\n</tr>\n";        
        echo "</table>\n";
        if ($rows > 15) {
        echo "<table cellspacing='1' cellpadding='0' border='0' width='100%'><tr><td valign='bottom'>";
        $clink2 = str_replace('.htm','',$clink);
        echo forumpagenav($rowstartt,15,$rows,3,$clink2)."</td></tr></table>\n";
    }
    } else {
        echo $locale['c101']."\n";
    }
    closetable();
    tablebreak();


    opentable($locale['c102']);
    if (iMEMBER || $settings['guestposts'] == "1") {
        echo "<p align='center'><font color='red'>".$error."</font></p>";
        echo "<form name='inputform' method='post' action='$clink'>
<table align='center' cellspacing='0' cellpadding='0' class='tbl'>\n";
        if (iGUEST) {
            echo "<tr>
<td>".$locale['c103']."</td>
</tr>
<tr>
<td><input type='text' name='comment_name' maxlength='50' class='textbox' style='width:100%;'></td>
</tr>\n";
        }
        echo "<tr>
<td align='center'><textarea name='comment_message' rows='6' class='textbox' style='width:400px'>"; if($invalid) echo $comment_message2; echo"</textarea><br>
<input type='button' value='b' class='button' style='font-weight:bold;width:25px;' onClick=\"addText('comment_message', '[b]', '[/b]');\">
<input type='button' value='i' class='button' style='font-style:italic;width:25px;' onClick=\"addText('comment_message', '[i]', '[/i]');\">
<input type='button' value='u' class='button' style='text-decoration:underline;width:25px;' onClick=\"addText('comment_message', '[u]', '[/u]');\">
<input type='button' value='url' class='button' style='width:30px;' onClick=\"addText('comment_message', '[url]', '[/url]');\">
<input type='button' value='mail' class='button' style='width:35px;' onClick=\"addText('comment_message', '[mail]', '[/mail]');\">
<input type='button' value='img' class='button' style='width:30px;' onClick=\"addText('comment_message', '[img]', '[/img]');\">
<input type='button' value='center' class='button' style='width:45px;' onClick=\"addText('comment_message', '[center]', '[/center]');\">
<input type='button' value='small' class='button' style='width:40px;' onClick=\"addText('comment_message', '[small]', '[/small]');\">
<input type='button' value='code' class='button' style='width:40px;' onClick=\"addText('comment_message', '[code]', '[/code]');\">
<input type='button' value='quote' class='button' style='width:45px;' onClick=\"addText('comment_message', '[quote]', '[/quote]');\">
<br><br>
".displaysmileys("comment_message")."
</td>
</tr>
<tr><td class='tbl' align='left'><b>Anti-Spam Code:</b>    ".make_captcha()."</tr>
<tr><td class='tbl' align='left'><b>Enter Anti-Spam Code:</b><input type='text' name='captcha_code' class='textbox' width='100'></td></td></tr>
<tr>
<td align='center'><input type='checkbox' name='disable_smileys' value='1'>".$locale['c107']."<br><br>
<input type='submit' name='post_comment' value='".$locale['c102']."' class='button'></td>
</tr>
</table>
</form>\n";
    } else {
        echo $locale['c105']."\n";
    }
    closetable();
}
?>


Save, Close and Upload file.

*************************

Open maincore.php and find the following line:

function makepagenav($start,$count,$total,$range=0,$link=""){

ABOVE this line, place the following:

function commentpagenav($start,$count,$total,$range=0,$link=""){
global $locale;
if ($link == "") $link = FUSION_SELF."?";
$res="";
$pg_cnt=ceil($total / $count);
if ($pg_cnt > 1) {
$idx_back = $start - $count;
$idx_next = $start + $count;
$cur_page=ceil(($start + 1) / $count);
$res.="<table cellspacing='1' cellpadding='1' border='0' class='tbl-border'>\n<tr>\n";
$res.="<td class='tbl2'><span class='small'>".$locale['052']."$cur_page".$locale['053']."$pg_cnt</span></td>\n";
if ($idx_back >= 0) {
if ($cur_page > ($range + 1)) $res.="<td class='tbl2'><a class='small' href='$link"."rowstartt=0'><<</a></td>\n";
$res.="<td class='tbl2'><a class='small' href='$link"."rowstartt=$idx_back'><</a></td>\n";
}
$idx_fst=max($cur_page - $range, 1);
$idx_lst=min($cur_page + $range, $pg_cnt);
if ($range==0) {
$idx_fst = 1;
$idx_lst=$pg_cnt;
}
for($i=$idx_fst;$i<=$idx_lst;$i++) {
$offset_page=($i - 1) * $count;
if ($i==$cur_page) {
$res.="<td class='tbl1'><span class='small'><b>$i</b></span></td>\n";
} else {
$res.="<td class='tbl1'><a class='small' href='$link"."rowstartt=$offset_page'>$i</a></td>\n";
}
}
if ($idx_next < $total) {
$res.="<td class='tbl2'><a class='small' href='$link"."rowstartt=$idx_next'>></a></td>\n";
if ($cur_page < ($pg_cnt - $range)) $res.="<td class='tbl2'><a class='small' href='$link"."rowstartt=".($pg_cnt-1)*$count."'>>></a></td>\n";
}
$res.="</tr>\n</table>\n";

}
return $res;
}

*************************

Ok done, now in order to display your comments correctly, all you have to do is lets say to open readarticle.php

Find the line that includes comments include (looks like this):

if ($data['article_allow_comments']) showcomments("A","articles","article_id",$article_id,FUSION_SELF."?article_id=$article_id");

And add 6th parameter within the showcomments() function called $rowstartt like that:

if ($data['article_allow_comments']) showcomments("A","articles","article_id",$article_id,FUSION_SELF."?article_id=$article_id",$rowstartt);

You can do that on all pages on which you want to add comments, e.g. news.php, just add the $rowstartt 6th parameter and it will display correctly and etc...

*************************

Regards, Webadmin88

PS: For technical support regarding this mod, click here .

PS2: Please note that if you are a SuperAdministrator or Administrator, you don't have to fill out the anti-spam measure, I thought this is crucial when you are and admin LOL :)
1
Diemux on August 04 2008 05:46:53

Tried to implant this but got the following error:

Parse error: syntax error, unexpected T_ELSE in /home/undergro/public_html/includes/comments_include.php on line 51

1
Diemux on August 07 2008 05:48:46

Issue resolved with correct code. Article updated.

291
webadmin88 on August 24 2008 11:52:49

Thank you- I am really proud with this one =)

Post Comment
Please Login to Post a Comment.
Ratings
Rating is available to Members only.

Please login or register to vote.

Awesome! Awesome! 75% [3 Votes]
Very Good Very Good 0% [No Votes]
Good Good 0% [No Votes]
Average Average 0% [No Votes]
Poor Poor 25% [1 Vote]