Created
January 31, 2013 11:17
-
-
Save SharpMan/4682207 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (isset($_POST['login']) AND isset($_POST['password']) AND !empty($_POST['login']) AND !empty($_POST['password'])) { | |
if ($loginArray = Application::$cache->get('login')){ | |
var_dump($loginArray); | |
if(array_key_exists($_SERVER['REMOTE_ADDR'], $loginArray)){ | |
if($loginArray[$_SERVER['REMOTE_ADDR']]["nb"] >= 7){ | |
$timeLeft = (time () - $loginArray[$_SERVER['REMOTE_ADDR']]["lastTime"]) /60; | |
if($timeLeft >= 5) { | |
$loginArray[$_SERVER['REMOTE_ADDR']]["nb"] = 0; | |
User::login(); | |
} | |
else{ | |
echo '<div class="alert alert-error"><p>Vous devez attendre '.round(5 - $timeLeft, 0).' minutes avant de retenter de vous connecter</p></div>'; | |
} | |
} | |
else{ | |
$loginArray[$_SERVER['REMOTE_ADDR']]["nb"]++; | |
$loginArray[$_SERVER['REMOTE_ADDR']]["lastTime"] = time(); | |
User::login(); | |
} | |
} | |
else{ | |
$newArray = array ( | |
$_SERVER['REMOTE_ADDR'] => array("lastTime" => time(), "nb" => "1") | |
); | |
$loginArray = array_merge($loginArray, $newArray); | |
User::login(); | |
} | |
Application::$cache->set('login',$loginArray); | |
} | |
else{ | |
$loginArray = array ( | |
$_SERVER['REMOTE_ADDR'] => array("lastTime" => time(), "nb" => "1") | |
); | |
Application::$cache->set('login',$loginArray); | |
User::login(); | |
} | |
} else { | |
echo '<div class="alert alert-error"><p>Vous n\'avez pas remplis tous les champs !</p></div>'; | |
//header("Refresh: 3;URL=index.php?c=misc&a=home"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment