View sourcecode

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

user.php

80 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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
include('check_login.php');
if(isset(
$_GET["action"])){
    switch(
$_GET["action"]){
        case 
"killCookie":
            
setcookie('username'''time() - 070414);
            
setcookie('password'''time() - 070414);
        }
}
$file_in="accounts/{$_SESSION["username"]}.json";
$json json_decode(file_get_contents("$file_in"), true);


?>
<!DOCTYPE html>
<html lang="sv">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?php echo"{$_SESSION["username"]}s Söderbank-konto"?></title>
    <link rel="stylesheet" href="/spectre/spectre-master/dist/spectre.css">
    <style>
        .box{
            border: solid 1px black;
        }

        .hLink{
            padding-right:4vw;
        }

        .aBox{
            text-align: left;
            float: left;
            padding-left: 1vw;
        }
        .sBox{
            text-align: right;
            padding-right: 10vw;
        }

        .barItem{
            padding-left:0.5vw;
            padding-right:0.5vw;
        }

    </style>
</head>


<body style="text-align: center;">
    <header class="navbar" style="padding: 0.5vw;">
        <section class="navbar-section"><a class="barItem" style="color:black;"><?php echo"{$_SESSION["username"]}"?></a><a href="pmanager.php" class="barItem">Byt lösenord</a></section>
        <section class="navbar-center"><img src="söderbank.png"></section>
        <section class="navbar-section"><?php if(isset($_COOKIE["username"])){echo"<a href=\"?action=killCookie\" class=\"btn btn-sm barItem\">Glöm mig</a>";}?><a href="logout.php"  class="barItem">Logga ut</a></section>
    </header>
    <h1>Välkommen, <?php echo $_SESSION["username"]?></h1>

    <div>
    <a class="btn btn-sm" href="func/deposit.php">Sätt in</a>
    <a class="btn btn-sm" href="func/withdraw.php">Ta ut</a>
    <a class="btn btn-sm" href="func/transfer.php">Överför</a>
    <a class="btn btn-sm" href="func/make_account.php">Skapa konto</a>
    </div>
    
    <br>

    <p>Dina konton:</p>
    <?php
    
foreach($json["{$_SESSION["username"]}"] as $a){
        echo 
"<div class=\"box\"><br><p class=\"aBox\"><a class=\"hLink\" href=\"func/history.php?mess={$a["account-name"]}\">Se Historik</a>{$a["account-type"]}{$a["account-name"]}</p>";
        
$aSum=0;
        for(
$i=0;$i<=count($a["transactions"])-1;$i+=3){
            
$aSum += $a["transactions"][$i];
        }

        echo 
"<p class=\"sBox\">Saldo: $aSum :-</p></div>";
    }
    
?>
</body>
</html>