Jump to content

Recommended Posts

The data below does not stop flooding if post is within the last 2min...

 

as you can see i have all error reporters in place... the query works fine...

 

Numbers of rows returned are 1...

 

but no error message ???

 

 

//stop flooding
$query = "SELECT max(unix_timestamp(`time`)) as t FROM messages WHERE reciever='$un' AND sender='$username'";
$res = mysql_query($query);
if (!$res)
{
   $errmsg = mysql_errno() . ' ' . mysql_error();
   echo "<br/>QUERY FAIL: ";
   echo "<br/>$sql <br/>";
   die($errmsg);
}
$num = mysql_num_rows($res);
if (!$num)
{
   echo "<br/>QUERY FOUND NO DATA: ";
   echo "<br/>$sql <br/>";
}

if(!$res) die("Query: $query\nError: ".mysql_error());
$lastMessageTime = mysql_num_rows($res) == 1 ? array_shift(mysql_fetch_array($res)) :
    0;
if ($lastMessageTime > 0 && $lastMessageTime < strtotime('+2 Minutes', $timestamp)) {
    $errors[] = 'Please wait 2 minutes between each message';
}

Link to comment
https://forums.phpfreaks.com/topic/196985-php-message-flooding-not-showing-error/
Share on other sites

Why not do the time check inside the sql?

 

$query = "SELECT sender FROM messages WHERE `time` < DATE_ADD(`time`, INTERVAL 2 MINUTE)  AND (reciever='$un' AND sender='$username') ORDER BY `time` DESC LIMIT 1";

 

Then if a row is returned by the query, they are considered flooding. This is untested. For more information on DATE_ADD see the MySQL Reference Manual.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.