Repository navigation
Expand file tree
/
Copy pathaccount.php
More file actions
executable file
·398 lines (384 loc) · 11.1 KB
/
Copy pathaccount.php
File metadata and controls
executable file
·398 lines (384 loc) · 11.1 KB
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
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
session_start();
require_once('connect.php');
if($user = @$_SESSION['username']){
$checkmyid = mysqli_query($connect, "SELECT id FROM users WHERE username ='$user'");
$idstr = mysqli_fetch_assoc($checkmyid);
$id = $idstr['id'];
?>
<html>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="/forum/menu/dynamicmenu.css"/>
<head>
<Title>帳戶設定 - Labo 論壇</Title>
</head>
<style>
.profile{
float:left;
}
.table{
display:table;
border-collapse: collapse;
width: 95%;
}
.cell{
display: table-cell;
padding: 20px 0 20px 0;
}
.row{
display: table-row;
}
.wrapper{
width: 95%;
margin: 0 auto;
overflow: hidden;
border-radius: 5px;
}
.blank{
border:none;
border-bottom: 2px solid grey;
display: inline-block;
height:25px;
width: 100%;
font-size: 20px;
outline: none;
margin-bottom: 0;
transition: border-bottom 0.1s ease;
}
.blankborder{
display: block;
content: '';
transform: scaleX(0);
transition: transform 0.5s ease-in-out;
border-bottom: 2px solid orange;
margin-top: -2px;
}
.blank:focus ~.blankborder{
transform: scaleX(1);
}
.blank:focus{
border-bottom:none;
padding-bottom: 4px;
}
#usrtz-menu li{
list-style:none;
}
#usrtz-menu{
border: 2px solid orange;
cursor: pointer;
outline: 0;
margin: 0;
padding:0;
border-radius:0px 0px 4px 4px;
background-color:white;
}
.ui-selectmenu-menu ul{
transition: height 0.5s;
}
#usrtz-menu li:hover{
color:white;
background-color:orange;
}
#usrtz-menu li:active{
}
.ui-selectmenu-menu {
padding: 0;
margin: 0;
position: absolute;
top: 0;
left: 0;
transition: height 0.5s;
display: none;
width: 500px;
}
.ui-selectmenu-open {
display: block;
}
.ui-selectmenu-button {
display: inline-block;
overflow: hidden;
position: relative;
text-decoration: none;
cursor: pointer;
width: 500px;
border-radius: 4px 4px 0px 0px;
}
fieldset {
border: 0;
}
#usrtz-button
{
outline: none;
background: linear-gradient(to right, orange 50%, white 50%);
background-size: 200% 100%;
background-position: right bottom;
transition: all .5s ease-out;
}
#usrtz-button:focus{
background-position: left bottom;
}
.ui-menu-divider{
background-color:white;
}
.stylishselector, #visibletoggle{
text-decoration:none;
color:black;
background: linear-gradient(to right, orange 50%, white 50%);
background-size: 200% 100%;
background-position: right bottom;
transition: all .5s ease-out;
border-radius: 4px;
padding-left:10px;
padding-right: 10px;
}
.stylishselector:hover, #visibletoggle:hover{
background-position: left bottom;
}
</style>
<body>
<?php
require_once("ranking.php");
?>
<div id='contentdiv'>
<?php
$profilecheck = mysqli_query($connect, "SELECT * FROM users where username = '".$user."'");
$profilerow = mysqli_fetch_assoc($profilecheck);
$id = $profilerow['id'];
$username = $profilerow['username'];
$email = $profilerow['email'];
$regdate = $profilerow['date'];
$reply = $profilerow['replies'];
$score = $profilerow['score'];
$password = $profilerow['password'];
$pic =$profilerow['profile_pic'];
?>
<?php
echo "<img class='profile' src='/forum/$pic' width='150' height='150' style='vertical-align:middle'/>";
echo "<h1 style='display:inline-block;margin-left:42px;'>$username</h1>";
?>
</br>
<div class='wrapper'>
<?php
if(!@$_GET['action'] == 'edit'){
echo "<a href='account.php?action=edit'>修改個人資料</a>";
}
?>
<form action='?action=edit' method="POST" enctype="multipart/form-data">
<div class='title'>ID 設定</div>
<div class='table' style='clear:both'>
<div class='row'>
<div class='cell'>相片</br>
<?php
if(@$_GET['action'] == 'edit'){
//echo "<form method='POST'>";
echo "<a href='' class='stylishselector'>選擇個人資料相片</a>";
echo "<input type='file' id='file' name='profilepic' class='pic'/>";
echo "<div id='filename'></div>";
//echo "<input type='submit' id='picupload' name='picupload' value='Upload'></input>";
//echo "</form>";
}
?>
</div>
</div>
<div class='row'>
<div class='cell'>Email</br>
<?php
if(@$_GET['action'] == 'edit'){
echo "\n\t\t<input type='text' class='blank' autocomplete='off' name='email' value='$email'/>";
echo "\n\t\t<span class='blankborder'></span>";
}else{
echo $email;
}
?>
</div>
</div>
<?php
if(@$_GET['error'] == 1){
echo "<div class='row'>\n\t\t\t<div class='cell' style='color:red'>請檢查你輸入的密碼</div>\n\t\t</div>";
}else if(@$_GET['error'] == 2){
echo "<div class='row'>\n\t\t\t<div class='cell' style='color:red'>密碼位數不足,請輸入六位以上的密碼</div>\n\t\t</div>";
}
?>
<div class='row'>
<div class='cell'>密碼</br>
<?php
if(@$_GET['action'] == 'edit'){
echo "\n\t\t<input type='password' class='blank' autocomplete='off' name='password'/>";
echo "\n\t\t<span class='blankborder'></span>";
}
?>
</div>
</div>
<?php
if(@$_GET['action'] == 'edit'){
echo "\n\t\t<div class='row'>";
echo "\n\t\t\t<div class='cell'>重新輸入密碼</br>";
echo "\n\t\t\t<input type='password' class='blank' autocomplete='off' name='repassword'/>";
echo "\n\t\t\t<span class='blankborder'></span>";
echo "\n\t\t\t</div>";
echo "\n\t\t</div>";
}
?>
<div class='row'>
<div class='cell'>註冊日期</br>
<?php echo $regdate ?>
</div>
</div>
<div class='row'>
<!------ Put timezone check here... -->
<?php
$checkzone = mysqli_query($connect, "SELECT * FROM timezone;");
$checkmytimezone = mysqli_query($connect, "SELECT * FROM usertz WHERE id='$id';");
$mytimezone = mysqli_fetch_assoc($checkmytimezone);
$timezone = $mytimezone['timezid'];
?>
<div class='cell'>時區及地區</br>
<?php
if(@$_GET['action'] != 'edit'){
while($zone= mysqli_fetch_assoc($checkzone)){
if($zone['timezid'] == $timezone){
echo $zone['gmt'];
}
}
}else{
?>
<select name='usrtz' id='usrtz'>
<optgroup label="按時區選擇地區">
<?php
$checkzone = mysqli_query($connect, "SELECT * FROM timezone;");
$checkmytimezone = mysqli_query($connect, "SELECT * FROM usertz WHERE id='$id';");
$mytimezone = mysqli_fetch_assoc($checkmytimezone);
$timezone = $mytimezone['timezid'];
while($zone = mysqli_fetch_assoc($checkzone)){
echo "<option value='".$zone['timezid']."'";
if($zone['timezid'] == $timezone) echo " selected='selected'>";
else echo ">";
echo $zone['gmt']."</option>";
}
?>
</optgroup>
</select>
<?php } ?>
</br>
根據設定紀錄,你所在時區目前的時間:
<?php
//Check the user-timezone to display the time correctly
$check= mysqli_query($connect, "SELECT * FROM usertz u, users s WHERE s.id= u.id AND s.username='".@$_SESSION['username']."';");
$row=mysqli_fetch_assoc($check);
$usertz= $row['timezid'];
$check = mysqli_query($connect, "SELECT tz from timezone WHERE timezid='$usertz';");
$row = mysqli_fetch_assoc($check);
$usertime = $row['tz'];
mysqli_query($connect, "SET SESSION time_zone = '$usertime';");
$check = mysqli_query($connect, "SELECT NOW();");
$trow = mysqli_fetch_assoc($check)['NOW()'];
echo $trow;
?>
</div>
</div>
<?php
//Check if they have enough rights
$hideprofile = mysqli_fetch_assoc(mysqli_query($connect, "SELECT profile_invisible FROM roles WHERE rights='"
.$rights."'"))['profile_invisible'];
if($hideprofile && @$_GET['action']=='edit'){
echo "<br/><div class='row'>隱藏個人主頁</div><a href='' id='visibletoggle'>";
$checkvisible = mysqli_fetch_assoc(mysqli_query($connect, "SELECT visible FROM specialteam WHERE id='".$id."';"))['visible'];
if($checkvisible){
echo "Off";
}else{
echo "On";
}
echo "</a><input name='visibleblank' id='visibleblank' style='display:none' value='".$checkvisible."'></div>";
}
?>
</div>
</div>
<input type='submit' value="Submit" name="submit"/>
</form>
</div>
<!--- INITIALIZES JAVASCRIPT -->
<script
src="https://code.jquery.com/jquery-3.3.1.js"
integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60="
crossorigin="anonymous"></script>
<script
src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"
integrity="sha256-VazP97ZCwtekAsvgPBSUwPFKdrwD3unUfSGVYrahUqU="
crossorigin="anonymous"></script>
<script>
var menu = $('#usrtz').selectmenu({
change: function(event, ui){
alert($('#usrtz').val());
setOptionValue($('#usrtz').val())
}
}).selectmenu('refresh',true);
function setOptionValue(value){
var usertz = $('#usrtz');
usertz.val(value).change();
}
$('.stylishselector').on('click', function(e){
e.preventDefault();
$('#file')[0].click();
});
//Only hide if jquery is enabled
$('#file').css('display','none');
$('#file').change(function(e){
var fileName = e.target.files[0].name;
$('#filename').html("已選擇:"+fileName);
});
//Change anchor upon click
$('#visibletoggle').click(function(e){
e.preventDefault();
var content = $('#visibletoggle').html();
if(content == "On"){
// Two steps: set text field to 1 and set text to Off
$('#visibletoggle').html("Off");
$('#visibleblank').val("1");
}else{
// Two steps: set text field to 0 and set text to On
$('#visibletoggle').html("On");
$('#visibleblank').val("0");
}
});
</script>
</body>
</html>
<?php
}
if(isset($_POST['submit'])){
if(!empty($_FILES['profilepic']['name'])){
echo "true";
$uploaddir = 'images/';
$filename = $username."-".$_FILES['profilepic']['name'];
$uploadfile = $uploaddir.$filename;
move_uploaded_file($_FILES['profilepic']['tmp_name'], $uploadfile);
mysqli_query($connect, "UPDATE users SET profile_pic ='images/".$filename."' WHERE id=$id;");
}
mysqli_query($connect, "UPDATE usertz SET timezid='".@$_POST['usrtz']."' WHERE id='".$id."';");
mysqli_query($connect, "UPDATE users SET email='".@$_POST['email']."' WHERE username='".$username."';");
//Saves password if password blank is filled
if(@$_POST['password']){
if(@$_POST['password'] == @$_POST['repassword']){
if(strlen(@$_POST['password']) >= 6){
$encrypt = password_hash(@$_POST['password'], PASSWORD_DEFAULT);
mysqli_query($connect, "UPDATE users SET password='".$encrypt."' WHERE username='".$username."';");
}else{
echo "<script>window.location = '?action=edit&error=2'</script>";
}
}else{
echo "<script>window.location = '?action=edit&error=1'</script>";
}
}
//echo "<script>window.location = '?'</script>";
//Saves hiding if available
//We have to check the rights again
$hideprofile = mysqli_fetch_assoc(mysqli_query($connect, "SELECT profile_invisible FROM roles WHERE rights='"
.$rights."'"))['profile_invisible'];
if($hideprofile){
mysqli_query($connect, "UPDATE specialteam SET visible='".@$_POST['visibleblank']."' WHERE id='".$id."';");
}
}
?>