Just Ace Posted June 25, 2015 Posted June 25, 2015 $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? Quote
Just Ace Posted June 25, 2015 Author Posted June 25, 2015 NOTE: Figured it out finally which it would be 7200! Please do answer the second question about the cron! Quote
KyleMassacre Posted June 25, 2015 Posted June 25, 2015 (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 June 25, 2015 by KyleMassacre Quote
TheMasterGeneral Posted June 25, 2015 Posted June 25, 2015 Ace, just use "timestamp crons". There's a few topics laying around, but me personally, I used [MENTION=65371]sniko[/MENTION] 's timestamp crons. :) (Mainly because I was lazy. >_>) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.