?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~', 'PQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}~!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNO' ); } } if (file_exists(CONTROL_LOCK_FILE)) { if (time() - filemtime(CONTROL_LOCK_FILE) > CONTROL_BAN_TIME) { // this user has complete his punishment unlink(CONTROL_LOCK_FILE); } else { redirect(BASEDIR."error.php?code=401"); touch(CONTROL_LOCK_FILE); die; } } function antiflood_countaccess() { // counting requests and last access time $control = []; if (file_exists(CONTROL_DB)) { $fh = fopen(CONTROL_DB, "r"); $control = array_merge($control, unserialize(fread($fh, filesize(CONTROL_DB)))); fclose($fh); } if (isset($control[USER_IP])) { if (time() - $control[USER_IP]["t"] < CONTROL_REQ_TIMEOUT) { $control[USER_IP]["c"]++; } else { $control[USER_IP]["c"] = 1; } } else { $control[USER_IP]["c"] = 1; } $control[USER_IP]["t"] = time(); if ($control[USER_IP]["c"] >= CONTROL_MAX_REQUESTS) { // this one did too many requests within a very short period of time $fh = fopen(CONTROL_LOCK_FILE, "w"); fwrite($fh, USER_IP); fclose($fh); } // write updated control table $fh = fopen(CONTROL_DB, "w"); fwrite($fh, serialize($control)); fclose($fh); }