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