Solved

stop forum flooding

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

Easy Project Management (No User Manual Required)

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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 …
These days socially coordinated efforts have turned into a critical requirement for enterprises.
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 how to count occurrences of each item in an array.

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now