Jump to content

php: message flooding not showing error


runnerjp

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.