1
<?php
2
/**
3
 *   File functions:
4
 *   skarbiec.php - deposits
5
 *
6
 *   @name                 : skarbiec.php
7
 *   @copyright            : Orodlin Team based on Gamers-Fusion ver 2.5
8
 *   @author               : Mzaszatko
9
 *   @version              : 1.3
10
 *   @since                : 28.04.2007
11
 *
12
 */
13
14
$title = 'Krasnoludzki Bank';
15
require_once('includes/head.php');
16
require_once('languages/'.$player -> lang.'/skarbiec.php');
17
18
/**
19
* Get the localization for game
20
*/
21
if ($player -> location != 'Ardulith')
22
{
23
    error (ERROR);
24
}
25
/**
26
* Assign variables to template
27
*/
28
$smarty -> assign(array('Description' => DESCRIPTION,
29
                        'Addday' => ADDDAY,
30
                        'Addweek' => ADDWEEK,
31
                        'Return' => CITYRETURN,
32
                        'Deposits' => DEPOSITS));
33
34
/**
35
* Add deposit for day
36
*/
37
38
if (isset ($_GET['akcja']) && $_GET['akcja'] == 'addday')
39
{
40
    $smarty -> assign(array('Daddday' => D_ADDDAY,
41
                            'Dpayday' => D_PAYDAY));
42
43
        if (isset ($_GET['step']) && $_GET['step'] == 'payday')
44
        {
45
                integercheck($_POST['amount']);
46
                if (!isset($_POST['amount']))
47
                {
48
                error(D_EMPTY);
49
                }
50
                if (!ereg("^[0-9]*$", $_POST['amount']))
51
                {
52
                error(D_EMPTYMONEY);
53
                }
54
                if ($_POST['amount'] > $player -> credits)
55
                {
56
                error(D_NOMONEY);
57
                }
58
59
                $db -> Execute("INSERT INTO `vault` (`owner`, `time`, `amount`, `type`) VALUES (".$player -> id.", '7',".$_POST['amount'].", '1')");
60
                $db -> Execute("UPDATE `players` SET `credits` = `credits` -".$_POST['amount']." WHERE `id`=".$player -> id);
61
                $smarty -> assign(array('Ile' => $_POST['amount'],
62
                                        'Dyoupay' => D_YOUPAY,
63
                                        'Dyoupaygold' => D_YOUPAYGOLD,
64
                                        'Dreturn' => D_RETURN,
65
                                        'Ile' => $_POST['amount']));
66
        }
67
}
68
/**
69
* Add deposit for week
70
*/
71
if (isset ($_GET['akcja']) && $_GET['akcja'] == 'addweek')
72
{
73
    $smarty -> assign(array('Waddweek' => W_ADDWEEK,
74
                            'Wpayweek' => W_PAYWEEK));
75
76
        if (isset ($_GET['step']) && $_GET['step'] == 'payweek')
77
        {
78
                integercheck($_POST['amount']);
79
                if (!isset($_POST['amount']))
80
                {
81
                error(W_EMPTY);
82
                }
83
                if (!ereg("^[0-9]*$", $_POST['amount']))
84
                {
85
                error(W_EMPTYMONEY);
86
                }
87
                if ($_POST['amount'] > $player -> credits)
88
                {
89
                error(W_NOMONEY);
90
                }
91
92
                $db -> Execute("INSERT INTO `vault` (`owner`, `time`, `amount`, `type`) VALUES(".$player -> id.", '45',".$_POST['amount'].", '10')");
93
                $db -> Execute("UPDATE `players` SET `credits`=`credits`-".$_POST['amount']." WHERE `id`=".$player -> id);
94
                $smarty -> assign(array('Wyoupay' => W_YOUPAY,
95
                                        'Wreturn' => W_RETURN,
96
                                        'Wyoupaygold' => W_YOUPAYGOLD,
97
                                        'Ile' => $_POST['amount']));
98
        }
99
}
100
101
/**
102
* Players deposits
103
*/
104
105
if (isset ($_GET['akcja']) && $_GET['akcja'] == 'deposits')
106
{
107
    $deposit = $db -> Execute('SELECT * FROM `vault` WHERE `owner`='.$player ->id.' AND `time`!= 0 ORDER BY `time` asc');
108
    $arrid = array();
109
    $arrtime = array();
110
    $arramount = array();
111
    $arrtype = array();
112
    $i = 0;
113
        while (!$deposit -> EOF)
114
        {
115
            $arrid[$i] = $deposit -> fields['id'];
116
            $arrtime[$i] = $deposit -> fields['time'];
117
            $arramount[$i] = $deposit -> fields['amount'];
118
            $arrtype[$i] = $deposit -> fields['type'];
119
            $deposit -> MoveNext();
120
            $i = $i + 1;
121
        }
122
     $deposit -> Close();
123
     $smarty -> assign(array('Id' => $arrid,
124
                             'Amount' => $arramount,
125
                             'Type' => $arrtype,
126
                             'Time' => $arrtime,
127
                             'Mdescription' => M_DESCRIPTION,
128
                             'Mreturn' => M_RETURN,
129
                             'Mamount' => M_AMOUNT,
130
                             'Mtype' => M_TYPE,
131
                             'Mtime' => M_TIME));
132
}
133
134
135
/**
136
* Initialization of variables
137
*/
138
139
if (!isset($_GET['akcja']))
140
{
141
    $_GET['akcja'] = '';
142
}
143
if (!isset($_GET['step']))
144
{
145
    $_GET['step'] = '';
146
}
147
148
/**
149
* Assing variables and display page
150
*/
151
152
$smarty -> assign ( array("Akcja" => $_GET['akcja'], "Step" => $_GET['step']));
153
$smarty -> display ('skarbiec.tpl');
154
155
require_once("includes/foot.php");
156
?>