示例#1
0
function safe($action)
{
    $ip = get_ip();
    $hours = intval(get_varia('safe_' . $action . '_hours'));
    $times = intval(get_varia('safe_' . $action . '_times'));
    $time = time() - $hours * 60 * 60;
    $obj = new safe();
    $obj->set_where("saf_action = '{$action}'");
    $obj->set_where("saf_time < {$time}");
    $obj->del();
    $obj->set_where('');
    $obj->set_where("saf_ip = '{$ip}'");
    $obj->set_where("saf_action = '{$action}'");
    if ($obj->get_count() > $times - 1) {
        header('location:./safe.html');
        exit;
    } else {
        $obj->set_value("saf_ip", $ip);
        $obj->set_value("saf_action", $action);
        $obj->set_value("saf_time", time());
        $obj->add();
    }
}