Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

stop forum flooding

Posted on 2008-10-24
1
Medium Priority
?
467 Views
Last Modified: 2012-05-05
ok i have been having problems with people flooding my forum... any suggestions how i could stop this?
(i have shortend down my reply script)
<table width="70%" class='maintables'>
<tr class='headline'><td>Reply</td></tr>
	<tr class='maintables'>
		<td align="center">
<?php 
			$id=$_GET['id'];
			if(isset($_POST['submit'])) {
				$name=$puser;
				$yourpost=$_POST['yourpost'];
				$subject=$_POST['title'];
				if(strlen($yourpost)<1) {
					print "You did not type in a post."; //no post entered
				}else{
					$thedate=date("U"); //get unix timestamp
					$displaytime = time();
					//we now strip HTML injections
					$subject=strip_tags($subject);
					$name=strip_tags($name);
					//This is where the bbcode come in.
					$message = new BBCode;
					$message->selection = $yourpost;
					$message->parseCode(); // set to 1 if you want to disable bbcode
					$message->parseEmoticons();
					$yourpost = $message->parsed;
					$insertpost="INSERT INTO `forumtutorial_posts` (`author`,`forum`,`title`,`post`,`showtime`,`realtime`,`lastposter`,`parentid`) values('$name','$forum','$subject','$yourpost','$thedate','$thedate','$name','$id')";
					mysql_query($insertpost) or die("Could not insert post"); //insert post
 
					$updatepost="UPDATE `forumtutorial_posts` SET `numreplies`=`numreplies`+'1', `lastposter`='$name', `lastrepliedto`='$thedate' WHERE `postid`='$id'";
					mysql_query($updatepost) or die("Could not update post");
 
 
                                  $updatep="UPDATE `users` SET `post_count`=`post_count`+'1' WHERE `Username`='$name'";
					mysql_query($updatep) or die("Could not update post");
 
 
					print "Message posted, go back to <A href='index.php?page=message&id=$id&forum=$forum'>Message</a>.";
				}
			}else{
				$gettopic="SELECT * FROM `forumtutorial_posts` WHERE `postid`='$id'";
				$gettopic2=mysql_query($gettopic) or die("Could not get topic");
				$gettopic3=mysql_fetch_array($gettopic2);
				$message=strip_tags($getreplies3['post']);
				$message=nl2br($message);
				?>
                
                <?php  if($gettopic3['forumlock'] == 0)
{
     ?> Your message:
     
   
     
     
                    <br><form action='index.php?page=reply&forum=<? echo $forum; ?>&id=<? echo $_GET['id']; ?>' method='post' name='myform'>
					  <div style='padding-left: 5px; padding-top:5px;'></div>
 
					  <input name="title" type="hidden" value="<?php echo $gettopic3['title'];?>" />
				      <textarea id="inputforum" class="inputforum" name='yourpost' rows='5' cols='40'><?php if(isset($_POST['quote'])) {
                        $quote= $_POST['quote'];
						   $query = "SELECT * FROM forumtutorial_posts where postid=$quote"; 
if ($result = mysql_query($query)){
    if (mysql_num_rows($result)) {
        $array = mysql_fetch_assoc($result);}
      
?> quote by:<?php echo $array['author'];?>
<br>[quote]<?
echo $array['post']; }}?> [/quote]</textarea>
					  <br>
				      <input type='submit'class="submit-btn" name='submit' value=''>
				          </p>
                </form><?
}
else
{
    echo 'forum is locked';
}
?>
  
				<?
			}
			?>		</td>
  </tr>
</table>
<?
$pagenum = isset($_GET['pagenum']) ? $_GET['pagenum'] : "1";
 
$gettopic="SELECT * from forumtutorial_posts where postid='$id'";
$gettopic2=mysql_query($gettopic) or die("Could not get topic");
$gettopic3=mysql_fetch_array($gettopic2);
?>
 
<?php
 
//Here we count the number of results
//Edit $data to be your query
$data = mysql_query("SELECT * from forumtutorial_posts where parentid='$id'") or die(mysql_error());
$rows = mysql_num_rows($data);
 
//This is the number of results displayed per page
$page_rows = 4;
 
//This sets the range to display in our query
$max = 'limit ' .($pagenum - 1) * $page_rows .',' .$page_rows;
//This is your query again, the same one... the only difference is we add $max into it
{
?>
<?
}?>
<p>&nbsp;</p>
</body>
 
</html>

Open in new window

0
Comment
Question by:runnerjp
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 31

Accepted Solution

by:
Frosty555 earned 2000 total points
ID: 22797192
Every time the user makes a post, update their user profile (e.g. whatever table you are using to store user information) to store the date/time of the last post.

Next time a user tries to post, first check how long it has been between the current date, and the last post date. If less than a minute or so has elapsed, fail with a validation error telling the user to wait. Only allow posts after a certain amount of time has elapsed.
0

Featured Post

The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses four methods for overlaying images in a container on a web page
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question