-
Notifications
You must be signed in to change notification settings - Fork 35
/
myaccount.php
278 lines (258 loc) · 9.09 KB
/
myaccount.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
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
<?php
// load up global things
include_once 'autoloader.php';
if ( !isLoggedIn() ) { // if user is not logged in they cannot see this page
header( 'location: index.php' );
}
if ( !empty( $_SESSION['user_info']['fb_access_token'] ) ) { // get users facebook info is we have an access token
$fbUserInfo = getFacebookUserInfo( $_SESSION['user_info']['fb_access_token'] );
$fbDebugTokenInfo = getDebugAccessTokenInfo( $_SESSION['user_info']['fb_access_token'] );
}
?>
<!DOCTYPE html>
<html>
<head>
<!-- title of our page -->
<title>Easy, Code Is | My Account</title>
<!-- include fonts -->
<link href="https://fonts.googleapis.com/css?family=Coda" rel="stylesheet">
<!-- need this so everything looks good on mobile devices -->
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<!-- css styles for our my account page-->
<link href="css/global.css" rel="stylesheet" type="text/css">
<link href="css/myaccount.css" rel="stylesheet" type="text/css">
<!-- jquery -->
<script type="text/javascript" src="js/jquery.js"></script>
<!-- include our loader overlay script -->
<script type="text/javascript" src="js/loader.js"></script>
<script>
$( function() { // once the document is ready, do things
// initialize our loader overlay
loader.initialize();
$( '#change_password' ).on( 'click', function() { // onclick for our change password check box
if ( $( '#change_password_section' ).is( ':visible' ) ) { // if visible, hide it
$( '#change_password_section' ).hide();
} else { // if hidden, show it
$( '#change_password_section' ).show();
}
} );
$( '#update_button' ).on( 'click', function() { // onclick for our update button
processMyAccount();
} );
$( '.form-input' ).keyup( function( e ) {
if ( e.keyCode == 13 ) { // our enter key
processMyAccount();
}
} );
$( '.a-fb' ).on( 'click', function() { // on click for logout
loader.showLoader();
$.ajax( {
url: 'php/process_logout.php',
type: 'post',
dataType: 'json',
success: function( data ) {
loader.hideLoader();
window.location.href = 'index.php';
}
} );
} );
$( '.show-hide' ).on( 'click', function() { // on click for show hide section
// get section we are showing/hiding
var showHideSection = $( this ).data( 'section' );
if ( $( '#' + showHideSection ).is( ':visible' ) ) { // section is currently visible
// change text to show
$( this ).html( 'show' );
// hide section
$( '#' + showHideSection ).hide();
} else { // section is currently hidden
// changet text to hide
$( this ).html( 'hide' );
// show section
$( '#' + showHideSection ).show();
}
} );
} );
function processMyAccount() {
// clear error message
$( '#error_message' ).html( '' );
loader.showLoader();
$.ajax( {
url: 'php/process_myaccount.php',
data: $( '#myaccount_form' ).serialize(),
type: 'post',
dataType: 'json',
success: function( data ) {
if ( 'ok' == data.status ) {
window.location.reload();
} else if ( 'fail' == data.status ) {
$( '#error_message' ).html( data.message );
loader.hideLoader();
}
}
} );
}
</script>
</head>
<body>
<div class="site-header">
<div class="site-header-pad">
<a class="header-home-link" href="index.php">
Easy, Code Is
</a>
</div>
</div>
<div class="site-content-container">
<div class="site-content-centered">
<div class="site-content-section">
<div class="site-content-section-inner">
<div class="section-heading">My Account</div>
<form id="myaccount_form" name="myaccount_form">
<div id="error_message" class="error-message">
</div>
<div>
<div class="section-label">Email</div>
<div><input class="form-input" type="text" name="email" value="<?php echo $_SESSION['user_info']['email']; ?>" /></div>
</div>
<div class="section-mid-container">
<div class="section-label">First Name</div>
<div><input class="form-input" type="text" name="first_name" value="<?php echo $_SESSION['user_info']['first_name']; ?>" /></div>
</div>
<div class="section-mid-container">
<div class="section-label">Last Name</div>
<div><input class="form-input" type="text" name="last_name" value="<?php echo $_SESSION['user_info']['last_name']; ?>"/></div>
</div>
<div>
<div class="section-label">
<input type="checkbox" name="change_password" id="change_password" style="width:10px"/>
<label for="change_password">Change Passowrd</label>
</div>
</div>
<div id="change_password_section" style="display:none">
<div class="section-mid-container">
<div class="section-label">Password</div>
<div><input class="form-input" type="password" name="password" /></div>
</div>
<div class="section-mid-container">
<div class="section-label">Confirm Password</div>
<div><input class="form-input" type="password" name="confirm_password" /></div>
</div>
</div>
</form>
<div class="section-action-container">
<div class="section-button-container" id="update_button">
<div>Update</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="site-content-container">
<div class="site-content-centered">
<div class="site-content-section">
<div class="site-content-section-inner">
<div class="section-heading">Connected Facebook Account</div>
<?php if ( empty( $fbUserInfo ) || $fbUserInfo['has_errors'] ) : // could not get facebook user info ?>
<div class="a-fb">
<div class="fb-button-container">
<div>Login With Facebook to Connect Facebook Account</div>
</div>
</div>
<?php else : // display facebook user info ?>
<div>
<div class="pro-img-cont">
<img class="pro-img" src="<?php echo $fbUserInfo['fb_response']['picture']['data']['url']; ?>" />
</div>
</div>
<div class="section-mid-container">
<div class="section-label">
Email
</div>
<div>
<?php echo $fbUserInfo['fb_response']['email']; ?>
</div>
</div>
<div class="section-mid-container">
<div class="section-label">
First Name
</div>
<div>
<?php echo $fbUserInfo['fb_response']['first_name']; ?>
</div>
</div>
<div class="section-mid-container">
<div class="section-label">
Last Name
</div>
<div>
<?php echo $fbUserInfo['fb_response']['last_name']; ?>
</div>
</div>
<div class="section-mid-container">
<div class="section-label">
User Access Token Facebook Application
</div>
<div>
<?php echo $fbDebugTokenInfo['fb_response']['data']['application']; ?>
</div>
</div>
<div class="section-mid-container">
<div class="section-label">
User Access Token Issued
</div>
<div>
<?php echo date( 'm-d-Y h:i:s', $fbDebugTokenInfo['fb_response']['data']['issued_at'] ); ?>
</div>
</div>
<div class="section-mid-container">
<div class="section-label">
User Access Token Expires
</div>
<div>
<?php echo date( 'm-d-Y h:i:s', $fbDebugTokenInfo['fb_response']['data']['expires_at'] ); ?>
</div>
</div>
<div class="section-mid-container">
<div class="section-label">
User Access Token Scope
</div>
<div>
<?php echo implode( ',', $fbDebugTokenInfo['fb_response']['data']['scopes'] ); ?>
</div>
</div>
<div class="section-mid-container">
<div class="section-label">
User Info Raw FB Response
</div>
<div>
<div class="a-default show-hide" data-section="fb_user_info">
show
</div>
<div id="fb_user_info" class="show-hide-section">
<textarea class="show-hide-textarea"><?php print_r( $fbUserInfo['fb_response'] ); ?></textarea>
</div>
</div>
</div>
<div class="section-mid-container">
<div class="section-label">
User Access Token Debug Info Raw FB Response
</div>
<div>
<div class="a-default show-hide" data-section="fb_user_access_token_debug">
show
</div>
<div id="fb_user_access_token_debug" class="show-hide-section">
<textarea class="show-hide-textarea"><?php print_r( $fbDebugTokenInfo['fb_response'] ); ?></textarea>
</div>
</div>
</div>
<?php endif; ?>
</div>
</div>
</div>
</div>
<br />
<br />
<br />
</body>
</html>