View sourcecode

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

delete_user.php

24 lines UTF-8 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
<?php
    session_start
();
    include(
'check_login.php');

    
$file_in "accounts/users.json";
    
$users json_decode(file_get_contents($file_in), true);

    if(isset(
$_POST['username']) and isset($_POST['password'])){
        foreach (
$users['users'] as &$a){ #Loopar igenom users.json för att kolla så att namn och lösen stämmer
            
if($_POST['username'] == $a['user'] and sha1("LBM".$_POST['password']."Banking") == $a['password'] and $a['active']){ #Ifall POST matchar med accounts.json
                
$a['active'] = False//Sätter avtive till false för att inaktivera kontot
                
$file fopen($file_in"w");
                
fwrite($filejson_encode($usersJSON_UNESCAPED_UNICODE JSON_PRETTY_PRINT));
                
fclose($file);

                
header('location: logout.php?action=deleted'); 
                exit();
            }
        }
    }
    
header('location: delete_user_form.php?mess=wrong');
    exit();

?>