*

Recent

Author Topic: One comment Per Game  (Read 4480 times)

Danny

  • Newbie
  • *
  • Posts: 41
  • Force: +5/-0
One comment Per Game
« on: January 26, 2009, 10:32:55 AM »
Noticed the game commenting system can be quite spammy, so i put this in place so you can only comment once on each game.

open play.php in the pages dir.
Find:
Code: [Select]
$commenter = $usrdata['userid'];
$gameid = $ID;
$comment = clean($_POST['comment']);
$date = time();
if($autoapprovecomments == 1){
$approved = 1;
}else{
$approved = 0;
}
$db->query(sprintf('INSERT INTO dd_comments SET
gameid=\'%u\',
commenter=\'%u\',
comment=\'%s\',
date=\'%u\',
approved=\'%u\'
', $ID, $commenter, $comment, $date, $approved));
if($autoapprovecomments == 1){
$msgcom = 'Comment Posted.';
}else{
$msgcom = 'Comment Posted, Awaiting admin approval.';
}
echo '<div class=\'msg\'>'.$msgcom.'</div><br />';
}

Replace with:

Code: [Select]
if(!isset($userid)){
echo 'Please login first.';
exit;
}
if($_SESSION['ALREADYCOMMENTED'] != $ID){
$commenter = $usrdata['userid'];
$gameid = $ID;
$comment = clean($_POST['comment']);
$date = time();
if($autoapprovecomments == 1){
$approved = 1;
}else{
$approved = 0;
}
$db->query(sprintf('INSERT INTO dd_comments SET
gameid=\'%u\',
commenter=\'%u\',
comment=\'%s\',
date=\'%u\',
approved=\'%u\'
', $ID, $commenter, $comment, $date, $approved));
if($autoapprovecomments == 1){
$msgcom = 'Comment Posted.';
}else{
$msgcom = 'Comment Posted, Awaiting admin approval.';
}
echo '<div class=\'msg\'>'.$msgcom.'</div><br />';
$_SESSION['ALREADYCOMMENTED'] = $ID;
}
}

Now, you have to be loggedin, and only allow one comment per game.
« Last Edit: January 27, 2009, 06:23:43 AM by Danny »

maverick

  • Newbie
  • *
  • Posts: 34
  • Force: +0/-1
Re: One comment Per Game
« Reply #1 on: January 27, 2009, 02:18:58 AM »
syntax error on line 168

Danny

  • Newbie
  • *
  • Posts: 41
  • Force: +5/-0
Re: One comment Per Game
« Reply #2 on: January 27, 2009, 06:23:26 AM »
Sorry about that. Fixed the code.