Solved

stop forum flooding

Posted on 2008-10-24
1
456 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
1 Comment
 
LVL 31

Accepted Solution

by:
Frosty555 earned 500 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Browser Chrome downloads colored link 5 41
php string detection problem 7 34
Javascript Form Change 5 23
Not allowed to load local recource. 4 14
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
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)

803 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