Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class_auth.php
- class Login {
- function __construct() {
- if (isset($_POST['user']) and isset($_POST['pass'])) {
- //method for 1 xml file for all users
- if (file_exists('data' . DIRECTORY_SEPARATOR . 'users_hktlaetaetl.xml')) {
- //Open xml
- $xml = @simplexml_load_file('data' . DIRECTORY_SEPARATOR . 'users_hktlaetaetl.xml');
- //Loop on xml file and find the username $_POST['user']
- $good_user = 0;
- $good_pass = 0;
- $name = '';
- $level = 'user';
- foreach ($xml->children() as $user) {
- foreach ($user->attributes() as $attrib => $value) {
- if ($attrib == 'login') {
- if ($value == $_POST['user']) {
- $good_user = 1;
- }
- }
- if ($attrib == 'pass') {
- if ($value == md5('Gg%gzµ1ß«o' . $_POST['pass'])) {
- $good_pass = 1;
- }
- }
- if ($attrib == 'name') {
- $name = $value;
- }
- if ($attrib == 'level') {
- $level = $value;
- }
- }
- if (($good_user == 1) and ($good_pass == 1)) {
- $good_name = $name;
- $good_level = $level;
- $connected = 1;
- }
- }
- if ($connected == 1) {
- $_SESSION['user']->name = $good_name;
- $_SESSION['user']->level = $good_level;
- echo 'connected. redirect to homepage in 2 seconds or <a href="./index.php">click here</a>';
- echo '<script type="text/javascript">
- function redirect(){ window.location = "index.php"; }
- setTimeout(\'redirect()\', 2000);
- </script>';
- }
- if ($good_user == 0) {
- echo 'user doesn\'t exist. <button onclick="javascript:back();">go back</button>';
- } else {
- if ($good_pass == 0) {
- echo 'wrong password.<button onclick="javascript:back();">go back</button>';
- }
- }
- }
- }
- else {
- header('Location: index.php');
- }
- }
- }
Add Comment
Please, Sign In to add comment