<?php
defined('PROTECTOR') or die('Все работает!');
$time=time();
$temp = mysql_query("SELECT * FROM `temp` WHERE `user`='$log' and `status`='off'");

While($temp = mysql_fetch_array($temp)){
if($temp[status]==off and $temp[ltime]+300<=$time){
mysql_query("DELETE FROM `temp` WHERE `user`='$log' and `id`='$temp[id]'")or die (mysql_error());
}

}

$temp = mysql_fetch_array($temp);
if($temp[status]==off and $temp[ltime]+300<=$time){
mysql_query("DELETE FROM `temp` WHERE `user`='$log' and `id`='$temp[id]'")or die (mysql_error());
}
$per=$time-1200;
$tim = mysql_query("SELECT * FROM `temp` WHERE `user`='$log' and `ltime`<'$per'");
While($temp = mysql_fetch_array($tim)){
mysql_query("DELETE FROM `temp` WHERE `user`='$log' and `ltime`='$temp[ltime]'")or die (mysql_error());
}
?>