Solved

stop forum flooding

Posted on 2008-10-24
1
460 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 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
JSON help 8 43
Echo'd value as selected in dropdown 20 39
PHP MYSQLI Connection in Function in a class 4 26
sitemap.xml 3 24
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…

739 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