Create a new column in the users table called last_AP . Give it an int(11) data type.
My SQL is rusty, if this is wrong someone correct it
ALTER TABLE users ADD last_AP int(11);
Next, at the bottom of your globals file add this:
$AP_Interval = 60;
if(time() - $ir['last_AP'] >= $AP_Interval){
$db->query("UPDATE users SET ap=ap+1, last_AP=".time()." WHERE userid=".$userid);
}
This is the logic behind adding the code. It will keep it in tune across multiple pages as an Ajax timeout set at 60 seconds will only work for however long the player stays o