/
edit.php
241 lines (191 loc) · 6.68 KB
/
edit.php
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
<?php
// @author jack krawczyk -- @jackk
// last updated: Nov 28, 2012
// This interface is where a user goes to edit their account information:
// Charity, password, charge per indulgence, monthly limit
// The edit interface is dictated via GET data passing.
// includes for php
include 'includes.php';
// reroute if not logged in
if(! isset($_COOKIE['EMAIL_floathope']))
{
header("Location: index.php");
}
// reroute if edit type not selected
if(! isset($_GET['type']))
{
header("Location: profile.php");
}
// parse out userid from userCookie
$userArray = json_decode(htmlspecialchars_decode($_COOKIE['USER_floathope']));
//get name information
$userid = $userArray->{'userid'};
?>
<!DOCTYPE html>
<html>
<head>
<title>Float Hope - Home</title>
<link rel="shortcut icon" href="dove.png" type="image/x-icon">
<link href="css/bootstrap.css" rel="stylesheet">
<link href="css/bootstrap-responsive.css" rel="stylesheet">
<style type="text/css">
body {
padding-top: 60px;
padding-bottom: 40px;
}
</style>
<!-- Load Scripts -->
<script src="jquery-1.7.1.js"></script>
<script src="jquery-cookie.js"></script>
<?php getGoogleAnalytics(); ?>
</head>
<body>
<div class="navbar navbar-fixed-top">
<div class="navbar-inner">
<div class="container">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a class="brand" href="index.php">float hope</a>
<div class="nav-collapse">
<ul class="nav">
<li><a href="index.php">Home</a></li>
<li><a href="site.php">Indulgences</a></li>
<li class="active"><a href="profile.php">My Profile</a></li>
</ul>
<ul class="nav pull-right">
<li><a href="logout.php">Log out</a>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="span6">
<div class="user-module">
<?php
switch($_GET['type'])
{
// ***************************
// Edit user charity
// ***************************
case "charity":
// get charities
$charities = getCharities();
// get current charity
$userCharity = $userArray->{'charityList'};
$myCharity = $userCharity[0];
echo "<h2>Edit Your Featured Charity</h2>";
echo "<p>Select the charity that will benefit from your indulgences.</p>";
echo "<form class='form-horizontal' method='POST' action='profile.php'>";
echo '<div class="control-group">';
echo "<div id='inputs-charity' class='controls'>";
$counter_charity = 0;
foreach($charities as $cid => $charity_name)
{
echo "<label class=\"radio\">";
if($charity_name == $myCharity)
echo " <input id='charity$counter_charity' name='charity' type='radio' value='$cid' checked />$charity_name <br />\n";
else
echo " <input id='charity$counter_charity' name='charity' type='radio' value='$cid' />$charity_name <br />\n";
echo "</label>\n";
$counter_charity++;
}
echo "</div></div>";
// Charity Flag
echo "<input type='hidden' name='flag' value='charity'>";
// Submit button
echo "<div class='control-group' style='padding-top: 10px;'>
<div class='controls'>
<input type='submit' id='submit' value='Save' class='btn btn-primary btn-large' />
</div>
</div>";
echo "</form>";
break;
// ***************************
// Edit Indulgence Limits
// ***************************
case "payment":
echo "<h2>Edit Your Indulgence Limits</h2>";
echo "<form class='form-horizontal' method='POST' action='profile.php'>";
// get charge information
$chargeInfo = getChargeInfo($userid);
foreach($chargeInfo as $limit => $charge)
{
$monthlyDollarLimit = $limit;
$chargePerVisit = number_format($charge, 2);
}
// Charge Per Indulgence
echo "<div class='control-group' style='padding-top: 10px;'>
<label class='control-label' for='inputChargePer' style='padding-right:20px;'>Charge per Indulgence:</label>
<div class='controls'>
$ <input type='text' name='inputChargePer' value='$chargePerVisit' style='width:50px;' />
</div>
</div>";
// Monthly Limit
echo "<div class='control-group' style='padding-top: 10px;'>
<label class='control-label' for='inputMonthlyLimit' style='padding-right:20px;'>Monthly Limit:</label>
<div class='controls'>
$ <input type='text' name='inputMonthlyLimit' value='$monthlyDollarLimit' style='width:50px;' />
</div>
</div>";
// Payment Flag
echo "<input type='hidden' name='flag' value='payment'>";
// Submit button
echo "<div class='control-group' style='padding-top: 10px;'>
<div class='controls'>
<input type='submit' id='submit' value='Save' class='btn btn-primary btn-large' />
</div>
</div>";
echo "</form>";
break;
// ***************************
// Password Information
// ***************************
case "password":
echo "<h2>Change Your Password</h2>";
echo "<form class='form-horizontal' method='POST' action='profile.php'>";
// Current password
echo "<div class='control-group' style='padding-top: 10px;'>
<label class='control-label' for='currentPass' style='padding-right:20px;'>Current Password:</label>
<div class='controls'>
<input type='password' name='currentPass' style='width:125px;' />
</div>
</div>";
// New password
echo "<hr><div class='control-group' style='padding-top: 10px;'>
<label class='control-label' for='newPass1' style='padding-right:20px;'>New Password:</label>
<div class='controls'>
<input type='password' name='newPass1' style='width:125px;' />
</div>
</div>";
// Confirm password
echo "<div class='control-group' style='padding-top: 10px;'>
<label class='control-label' for='newPass2' style='padding-right:20px;'> </label>
<div class='controls'>
<input type='password' name='newPass2' style='width:125px;' />
</div>
</div>";
// Payment Flag
echo "<input type='hidden' name='flag' value='password'>";
// Submit button
echo "<div class='control-group' style='padding-top: 10px;'>
<div class='controls'>
<input type='submit' id='submit' value='Save' class='btn btn-primary btn-large' />
</div>
</div>";
echo "</form>";
break;
}
?>
</div></div> <!-- End hero-unit & left column -->
<div class="span6"><div class="user-module"> <!-- Start right column -->
<p></p>
</div></div> <!-- End user module & right column -->
</div>
</div>
</body>
</html>