Jump to content
MakeWebGames

Recommended Posts

Posted
$limit=mysql_query("SELECT * FROM attacklogs WHERE attacked = {$odata['userid']} AND attacker = {$ir['userid']} AND time > unix_timestamp()-????");


if(mysql_num_rows($limit) >= 2)
{
print "<hr width='50%'>Please read the error message.<hr width='50%'><h3>!ERROR</h3>You already attacked this user 2 times in the past 120 minutes.
<hr width='50%'><a href='index.php'>> Go Home</a><hr width='50%'>";
$h->endpage();
exit;
}

 

Just a little question as research didn't help too much, how would I adjust the unix_timestamp section of the code to make the time limit 120 minutes?

And would I be better off just running a 1 minute cron instead until 120 minutes have passed?

Posted (edited)

I wouldn't say it would be better. How you have it would be fine.

offtopic though, if your using V2 why are you using mysql_*? And another note, I know attack_logs is a relatively small table but why are you selecting all rows? You could do something like:

 $count = $db->fetch_single($db->query("select count (`some_id`) from `attack_logs` where `attacked` = {$odata['userid']} and `attacker` = {$userid} and `time` >= (unix_timestamp -(60*60*2))"));
if($count >= 2) {
   //give them their error message here
}
Edited by KyleMassacre

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.   Paste as plain text instead

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