The following files exists in this folder. Click to view.
create_account.php37 lines ASCII Unix (LF)
<?php
$file_in = "accounts/accounts.json";
$accounts = json_decode(file_get_contents($file_in), true);
if(isset($_POST['username']) and isset($_POST['password'])){
foreach ($accounts['accounts'] as $a){ #Loopar igenom accounts.json
if($_POST['username'] == $a['user']){ #Ifall POST matchar med accounts.json
if(sha1("LBM".$_POST['password']."Banking") == $a['password']){
header('location: index.php?action=login&mess=exists');
exit();
}
else{
header('location: index.php?action=login&mess=used&action=new_user');
exit();
}
}
}
$hash_pass = sha1("LBM".$_POST['password']."Banking");
$accounts['accounts'][] = ['user'=> $_POST['username'], 'password'=> $hash_pass, 'userlvl'=> 'user'];
$file = fopen($file_in, "w");
fwrite($file, json_encode($accounts, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT));
fclose($file);
$new_file = "accounts/".$_POST['username'].".json";
$file = fopen($new_file, "w");
fclose($file);
header('location: index.php?action=login&mess=created');
exit();
}
else{
header('location: index.php?action=login&mess=error');
exit();
}
?>