-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogress.php
More file actions
545 lines (318 loc) · 11.9 KB
/
progress.php
File metadata and controls
545 lines (318 loc) · 11.9 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
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
<?Php
/*
* Progress
* @package Borno CMS
* @author Arnob Roy
*
*
*/
/* // including function */
include('functions.php');
//include end
if(!isset($_SERVER['HTTP_REFERER'])){
if(isset($_GET['key']) or isset($_GET['active_account'])){}
else{
//if not isset $_GET['key'] and $_SERVER['HTTP_REFERER'] than die();
// die() -> borno_die();
// use borno_die(); function
borno_die('Ops! you can not access this page.');
}
}
/*
*
* Forget Password Progress
*
*/
if(isset($_POST['forgetpassword'])){
$email= $_POST['forgetpassword']; // the email
if(filter_var($email, FILTER_VALIDATE_EMAIL)){// checking the email
$qry = borno_query("SELECT * FROM $prefix_users WHERE email='".mysqli_escape($email)."'");
$count= mysqli_num_rows($qry);
if($count==1){
$row= mysqli_fetch_array($qry);
$key = base64_encode($row['active_key']);//active key with encode.
/*
* We wanna sending a mail
*
*/
$subject = 'Forget Password Request';#subject
$to = $row['email'];#email
$message="Dear user,
You have requested for you Password. By clicking the next link you can do that.
<a href='".get_the_option('site_address')."/sign-in.php?key=".$key."'>Click The Link</a>
Thanks
";# the message
// Send mail
if(sent_mail($to , $subject , $message)){
// now the mail successfully sent
}
else{//if mail not sent success fully
$msg = 'Unable To Reset password. We can not send the mail';
}
}
else{// if email not found or found grater than 1
$msg = 'Unable To Reset password';
}
}
else{// if $email is not a valid mail
$msg = 'Unable To Reset password';
}
if(isset($msg)){
// if isset $msg set session msg
$_SESSION['forget_pass'] =$msg;
}
else{
$_SESSION['forget_pass'] ='We have sent a mail in your mail address.';
}
header('Location:sign-in.php?forget=true');//sending to the sign in page
}
/*
*
* First step , User get a mail with a link in there email address , if user click the link than the action ....
*
*
*
*/
else if(isset($_GET['key'])){
$key = base64_decode($_GET['key']);// decode the key
$qry =borno_query("SELECT * FROM $prefix_users WHERE active_key='".mysqli_escape($key)."'");//query
$count= mysqli_num_rows($qry); // count
if($count ==1){ // if count == 1
//ganarate a new password
$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789". '0123456789``-~!@#$%^*()_+,.;:[]{}|oxyz';
$new_password = substr(str_shuffle($chars),0,8); // new password
$db_cp = base64_encode(md5($new_password));//encoding password
//change active key
$user_active_key = md5(substr(str_shuffle($chars),0,8)); // create a new user active key
while(!is_user_active_code_exists($user_active_key)){
break 1; //looking if the active key not exists
}
/*
* Sending mail
*/
$row=mysqli_fetch_array($qry); // make a row
$subject = 'New Password'; // Subject
$to = $row['email']; // email
$message="Dear user,
<br>
Your password has been reset. Here is your account information:
Email : ".$row['email']." <br>
Password : ".$new_password." <br>
<a href='".get_the_option('site_address')."/sign-in.php'>Sign in</a> <br>
";//email with new password
/**
*
*mail sent function
*
**/
if(sent_mail($to , $subject , $message)){
//progress
//change password
update_user($row['id'],'password',$db_cp);
//change active key
update_user($row['id'],'active_key',$user_active_key);
//add a password change log
add_user_meta('passwordchange','forget_pass',$row['id']);
//update reset log
$get_count = the_user( $row['id'], 'reset_pass');
$new_count = $get_count +1 ;
update_user($row['id'],'reset_pass',$new_count);
// message
$msg ='Your password has been updated successfully.';
}
else{
//if mail not sent successfully
$msg = 'Unable to send mail';
}
}
else{ // if the key not existing in our database echo the message
$msg = 'The activation key is invalid.';
}
if(isset($msg)){
// if isset($msg) set session
$_SESSION['keyprogress']= $msg ;
header('Location:sign-in.php?passwordupdated=true'); // header to passwordupdated page
}
}
else if(isset($_GET['signup'])){
if(isset($_COOKIE['accountcount']) and $_COOKIE['accountcount']==1){
die('Multiple account is not allowed. You have already created an account from this computer.');//multiple account not allowed
}
/*
*
* Sign up Progress
*
*/
if(isset($_POST['signup'])){
if(isset($_POST['fullname']) && isset($_POST['username']) && isset($_POST['email']) && !empty($_POST['password'])){
if( $_POST['password'] == $_POST['repassword'] ){
if(!empty($_POST['username']) && validate_username($_POST['username'])){
if(!empty($_POST['fullname'])){
if(!filter_var($_POST['fullname'], FILTER_VALIDATE_INT))
{
if(validate_name($_POST['fullname'])){
//action
if(filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)){
//checking the captcha
if($_POST['captchaform']==$_SESSION['rand_code']){
if($_POST['checkboxagree']==true){
$email = $_POST['email'];//email
$username= $_POST['username'];//username
$qry = borno_query("SELECT * FROM $table_user WHERE username='".mysqli_escape($username)."' or email='".mysqli_escape($email)."'");
$count = mysqli_num_rows($qry);
if($count==0){
// then add the user
$name = htmlspecialchars($_POST['fullname']);
$username = htmlentities($_POST['username']);
$password = base64_encode(md5($_POST['password']));
$email = $_POST['email'];
if(isset($_GET['refer'])){
$refer = htmlentities($_GET['refer']);
}
else{
$refer = '';
}
$level = get_the_option('user_defult_level');//the user level
//ad user
$account_active=0;
$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789". '0123456789``-=~!@#$%^&*()_+,./<>?;:[]{}\|oxyz';
$user_active_key = md5(substr(str_shuffle($chars),0,8));
//adding user
$user_active_key = add_user($name ,$username , $email ,$password,$refer,$level,$account_active);
$user_active_key ;
//mail
//subject
$subject = 'New Account Information';
//to
$to = $email;
//message
$message="Dear user, <br>
Here is your password ".$new_password."<br>
Account Info<br>
Email =". $email."<br>
Password = **********<br>
Please verify the account from the next link.
<a href='".get_the_option('site_address')."/sign-in.php?active_account=".$user_active_key."'>Verify Account</a>";
/**
*
*mail sent function
*
**/
if(sent_mail($to , $subject , $message)){
$_SESSION['signup_done'] = true;
$msgw ='<div class="alert alert-success">An auto--generate mail has been sent into your mail box. Check that and verify your account</div>';
}
else{//if mail not sent success fully
$_SESSION['signup_done'] = true;
$msgw ='<div class="alert alert-warning">There are a mail server error, the process of sending mail is failed. So you can not verify your account. But Your account is created . Contact with the site administrator to
active your account</div>';
}
//welcome mail end
$world = '<div class="alert alert-danger width-300">
<button type="button" class="close" data-dismiss="alert">×</button>
Your account has been successfully created.
</div> ';
//Calculate 60 days in the future
//seconds * minutes * hours * days + current time
$inTwoMonths = 60 * 60 * 24 * 60 + time();
setcookie('accountcount', 0, $inTwoMonths);
header("Location:sign-up.php?reg_success");
}
else{
$msg = ' <div class="alert alert-danger">
<button type="button" class="close" data-dismiss="alert">×</button>
The email or username you filled is already exists.
</div> ';
//echo 'email or username already exists';
}
}
else{
$msg = ' <div class="alert alert-danger">
<button type="button" class="close" data-dismiss="alert">×</button>
You have to agree with the site conditions.
</div> ';
//echo 'You must agreed with our term and condition';
}
}
else{
$msg = ' <div class="alert alert-danger">
<button type="button" class="close" data-dismiss="alert">×</button>
Invalid captcha.
</div> ';
}
}
else{
$msg = ' <div class="alert alert-danger">
<button type="button" class="close" data-dismiss="alert">×</button>
Invalid email address.
</div> ';
}
}
else{
$msg = ' <div class="alert alert-danger">
<button type="button" class="close" data-dismiss="alert">×</button>
Invalid name.
</div> ';
}
}
else
{
$msg = ' <div class="alert alert-danger">
<button type="button" class="close" data-dismiss="alert">×</button>
Invalid character. Please fill a proper name.
</div> ';
}
}
}//
else{
$msg = ' <div class="alert alert-danger">
<button type="button" class="close" data-dismiss="alert">×</button>
Invalid username.
</div> ';
}
}
else{
$msg = ' <div class="alert alert-danger">
<button type="button" class="close" data-dismiss="alert">×</button>
Invalid username
</div> ';
}
}
else{
$msg = ' <div class="alert alert-danger">
<button type="button" class="close" data-dismiss="alert">×</button>
All field is required.
</div> ';
}
if(isset($msg)){
$_SESSION['signupproblem'] = $msg;
header('Location:sign-up.php?fullname='.$_POST['fullname'].'&username='.$_POST['username'].'&email='.$_POST['email']);
}
else if(isset($msgw)){
$_SESSION['signupproblem'] = $msgw;
header("Location:sign-up.php?reg_success");
}
}
}
/*
*
* Active account .
* Return form sign up
*
**/
else if(isset($_GET['active_account'])){
$active_account_key = $_GET['active_account'];
$qry =borno_query("SELECT * FROM $table_user WHERE active_key='".mysqli_escape($active_account_key)."'");
$count= mysqli_num_rows($qry);
if($count==1){
$row =mysqli_fetch_array($qry);
$user_id = $row['id'];
update_user($user_id,'account_active','1');
$msg = 'Account Activated';
}
else{
$msg = 'Invalid key';
}
$_SESSION['activemessage']=$msg;
header('Location:sign-in.php?actived=true');
}