View sourcecode

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

does_deposit.php

47 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
<?php
session_start
();
$file_out="../accounts/{$_SESSION["username"]}.json";
$json=json_decode(file_get_contents($file_out), true);

if (isset(
$_POST["d_ammount"])){
    foreach(
$json["{$_SESSION["username"]}"] as &$us){
        if(
$us["account-name"] == $_POST["d_account"]){
            
array_unshift($us["transactions"], (int)$_POST["d_ammount"], date("Y/m/d"), "insättning");
            
$file fopen($file_out"w");
            
fwrite($filejson_encode($jsonJSON_UNESCAPED_UNICODE JSON_PRETTY_PRINT));
            
fclose($file);
        }
    }
    
$_POST["d_ammount"]=null;
}

if (isset(
$_POST["w_ammount"])){
    foreach(
$json["{$_SESSION["username"]}"] as $us){
        if(
$us["account-name"] == $_POST["w_account"]){
            
$bSum=0;
        for(
$i=0;$i<=count($us["transactions"])-1;$i+=3){
            
$bSum += $us["transactions"][$i];
        }
        }
    }
    if(
$_POST["w_ammount"]>$bSum){
        
$_POST["w_ammount"]=null;
       
header("location:withdraw.php?mess=HIGH"); 
       exit();
    }
    else{
        foreach(
$json["{$_SESSION["username"]}"] as &$us){
        if(
$us["account-name"] == $_POST["w_account"]){
            
array_unshift($us["transactions"], -(int)$_POST["w_ammount"], date("Y/m/d"), "uttag");
            
$file fopen($file_out"w");
            
fwrite($filejson_encode($jsonJSON_UNESCAPED_UNICODE JSON_PRETTY_PRINT));
            
fclose($file);
            }
        }
        
$_POST["d_ammount"]=null;
    }
}

header("location:../user.php");
exit();
?>