View sourcecode

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

login.php

32 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
25
26
27
28
29
30
31
32
<?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();
?>