使用php mysql和epoch时间戳无法运行后限制

时间:2014-07-22 20:36:14

标签: php mysql

我试图通过php,mysql以及存储在行timestamp(例如1406059107)中的数据库中的纪元时间戳来限制用户的帖子。

我的脚本第一次按预期执行并将用户限制为60秒,但之后我可以通过帖子充斥服务器,因为限制停止运行。

我尝试使用ASC代替DESC但没有成功。

$sql = "SELECT timestamp FROM phpbb_schedule WHERE username = " . (int) $user->data['user_id'] . " ORDER BY timestamp DESC";

$result = $db->sql_query_limit($sql, 1);
$row = $db->sql_fetchrow($result);
$db->sql_freeresult($result);

if (time() - $row['timestamp'] < 60)
{
    header( 'Location: someurl.php' );
    die ('Your can only input one request every 60 seconds.');
}
else
{
    echo 'success some other code goes here that inputs the data into the db and redirects this to another page';
}
  

注意:问题已解决我没有使用ORDER by timestamp并且发生了语法错误(请参阅注释)。

0 个答案:

没有答案
相关问题