Plugging Commenters Hack

Main >> Content >> Tutorials >> Cutenews >> Plugging Commenters Hack

Plugging commenters hack means that all the people who comments you will be shown right under your blog with a link to their sites. You have probably seen it on many sites. I have also started using it now. Just take a look at the bottom of my blog if you're not sure what I mean.
Step 1: Open your functions.inc.php in notepad or whatever program you use. Scroll down to the bottom, copy the code under and paste it right before the ?>.
//////////////////////////////////////////////////////////////////
// Function: Lists all commenters with mail or url when available
function list_commenters($news, $linebreak, $separator) {
$alle_comments = file("./data/comments.txt");
$i=0;
foreach($alle_comments as $comments_line)
{
$comments_line = trim($comments_line);
$comments_line_arr = explode("|>|", $comments_line);
if($news == $comments_line_arr[0])
{
$individual_comment = explode("||", $comments_line_arr[1]);
foreach ($individual_comment as $single_comment)
{
$single_comment_arr = explode("|", $single_comment);
if (($single_comment_arr[0] != "") && (!stristr($output, $single_comment_arr[1])))
{
$i++;
if($single_comment_arr[2] != "none")
{
if( preg_match("/^[\.A-z0-9_\-]+[@][A-z0-9_\-]+([.][A-z0-9_\-]+)+[A-z]{1,4}$/", $single_comment_arr[2])){ $url_target = "";$mail_or_url = "mailto:"; }
else
{
$url_target = "target=\"_blank\"";
$mail_or_url = "";
if(substr($single_comment_arr[2],0,3) == "www") $mail_or_url = "http://";
}
$output .= "<a $url_target href=\"$mail_or_url".stripslashes($single_comment_arr[2])."\">".stripslashes($single_comment_arr[1])."</a>".$separator;
}
else $output .= $single_comment_arr[1].$separator;
if (fmod($i, $linebreak)==0) $output .= "<br />";
}
}

}
}
if (fmod($i, $linebreak)=="0") $output = substr($output, 0, -(strlen($separator)+6));
else $output = substr($output, 0, -strlen($separator));
return $output;
}

Step 2: Open shows.inc.php, scroll your way down to line 363 and paste this code in there, right after the part saying $output = str_replace("{title}......
if(CountComments($news_arr[0], $archive) > 0){
$output = str_replace('[commenters-header]', '', $output);
$output = str_replace('[/commenters-header]', '', $output);
$output = preg_replace("#\{commenters:(.*):(.*)\}#ie", "list_commenters('".$news_arr[0]."', '\\1', '\\2')", $output);
}
else $output = preg_replace("#\[commenters-header\](.*?)\[/commenters-header\]#i", "", $output);

Step 3: In the same page (shows.inc.php), go to line 691, paste the code under right after this code $output = $template_active;.
if(CountComments($news_arr[0], $archive) > 0){
$output = str_replace('[commenters-header]', '', $output);
$output = str_replace('[/commenters-header]', '', $output);
$output = preg_replace("#\{commenters:(.*):(.*)\}#ie", "list_commenters('".$news_arr[0]."', '\\1', '\\2')", $output);
}
else $output = preg_replace("#\[commenters-header\](.*?)\[/commenters-header\]#i", "", $output);

Step 3: Save both functions.inc.php and shows.inc.php, then upload them to your website by using FTP.

Step 4: Now log on to your cutenews account, click Options >> Edit Templates. Paste the code under at the bottom of your Full story and Active news. Where it says commenters:5 5 means that there will be 5 names in a row. You can just change that part if you want to:) and the - will be between each name. You can also change that, maybe use a bullet or something else instead.
[commenters-header]{commenters:5: - }[/commenters-header]

Step 5: Just save the template and you're done. Some of you may receive an error saying that ..comments.txt file could not be found. To get rid of this error open the functions.inc.php again scroll down to line 732 and change the line with this code:
$alle_comments = file("cutenews/data/comments.txt");