View sourcecode

The following files exists in this folder. Click to view.

create_account.php

37 lines ASCII Unix (LF)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?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($filejson_encode($accountsJSON_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();
    }
?>