The following files exists in this folder. Click to view.
login.php39 lines UTF-8 Unix (LF)
<?php
session_start();
$file_in = "accounts/users.json";
$users = json_decode(file_get_contents($file_in), true);
if(isset($_SESSION['user'])){
header('location: home.php');
exit();
}
if(isset($_COOKIE['remember'])){
foreach ($users['users'] as $a){ #Loopar igenom users.json
if($_COOKIE['remember'] == $a['password'] . sha1($a['userid']) and $a['active']){ #Ifall COOKIE matchar med accounts.json
$_SESSION['userlvl'] = $a['userlvl'];
$_SESSION['user'] = $a['user'];
$_SESSION['userid'] = $a['userid'];
header('location: home.php');
exit();
}
}
}
if(isset($_POST['username']) and isset($_POST['password'])){
foreach ($users['users'] as $a){ #Loopar igenom users.json
if($_POST['username'] == $a['user'] and sha1("LBM".$_POST['password']."Banking") == $a['password'] and $a['active']){ #Ifall POST matchar med accounts.json
$_SESSION['userlvl'] = $a['userlvl'];
$_SESSION['user'] = $a['user'];
$_SESSION['userid'] = $a['userid'];
if(isset($_POST['remember']) && $_POST['remember']) #Sätter en kaka ifall remember me är ikryssad
setcookie('remember', $a['password'] . sha1($a['userid']), time() + 2678400);
header('location: home.php');
exit();
}
}
}
header('location: index.php?action=login&mess=wrong');
exit();
?>