Created
August 19, 2012 05:36
-
-
Save Ivajkin/3392307 to your computer and use it in GitHub Desktop.
Авторизация
This file contains hidden or 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
| <?php | |
| if(isset($_POST['login'])){ | |
| $pass = $_POST["pass"]; | |
| $login = $_POST["login"]; | |
| //$pass = 'pass'; | |
| //$login = 'login'; | |
| $cpass = crypt($pass, "$2a$07$SomeSaltWordsMakeItHarder$"); | |
| $passFile = file_get_contents("passFile.php"); | |
| $passData = json_decode($passFile); | |
| foreach($passData as $key => $value){ | |
| if(!strcmp($value->login,$login) && !strcmp(crypt($pass, $value->pass),$cpass)){ | |
| session_start(); | |
| $_SESSION['userKey'] = $key; | |
| $_SESSION['time'] = time(); | |
| $_SESSION['ip'] = $_SERVER['REMOTE_ADDR']; | |
| echo 'true'; | |
| exit; | |
| } | |
| } | |
| echo 'User not found'; | |
| exit; | |
| } | |
| if($_POST["action"] == 'logout'){ | |
| session_start(); | |
| session_unset(); | |
| session_destroy(); | |
| echo 'logout'; | |
| exit; | |
| } | |
| if (isset($_REQUEST[session_name()])){ | |
| //echo 'Session name detected: '.session_name().'<br />'; | |
| session_start(); | |
| } | |
| if (isset($_SESSION['userKey']) AND $_SESSION['ip'] == $_SERVER['REMOTE_ADDR']){ | |
| echo 'true'; | |
| if(isset($_GET['address'])) | |
| header("Location: ".$_GET['address']); | |
| return true; | |
| } | |
| else { | |
| echo 'Please login'; | |
| header("Location: http://coreatrade.com/admin/"); | |
| exit; | |
| } | |
| ?> |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Как другие части связанны с авторизацией?