forked from MakaRax/HabboPHP
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprofile.php
109 lines (77 loc) · 3.43 KB
/
profile.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
<?php
#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|
#| #|
#| HABBOPHP - http://habbophp.com #|
#| Copyright © 2012 Valentin & Robin. All rights reserved. #|
#| #|
#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|#|
require 'init.php';
$tpl->assign('groups','index');
$prefix = substr($user->password,0,2);
$tpl->assign('prefix',$prefix);
$tpl->display('header.tpl');
$page = (isset($_GET['page'])) ? safe($_GET['page'],'HTML') : 'index';
if($page == 'index'){
if(isset($_POST['tab'])){
$user->updateUser('motto',safe($_POST['motto'],'HTML'));
if(EMULATOR == 'phoenix'){
$user->updateUser('hide_online',safe($_POST['visibility'],'HTML'));
$user->updateUser('hide_inroom',safe($_POST['followFriendMode'],'HTML'));
$Syntaxe_email='#^[\w.-]+@[\w.-]+\.[a-zA-Z]{2,6}$#';
$db->query('SELECT * FROM users WHERE mail = "'.safe($_POST['email'],'SQL').'" LIMIT 1');
$mail_exist = $db->NumRowsC();
$Error = new Error();
if(isset($_POST['email']) && empty($_POST['email']))
$Error->set('email',$tpl->assign('error_mail',$tpl->getConfigVars('register_error_email')));
elseif(!preg_match($Syntaxe_email,$_POST['email'])){
$Error->set('email',$tpl->assign('error_mail',$tpl->getConfigVars('register_error_email_syntaxe')));
echo 'coucou' ;
}
elseif($_POST['email'] != $user->mail){
if($mail_exist >= 1){
$Error->set('email',$tpl->assign('error_mail',$tpl->getConfigVars('register_error_email_exist')));
}
}
if($Error->ErrorPresent())
$tpl->assign('error','true');
else{
$user->updateUser('mail',safe($_POST['email']));
$tpl->assign('ok','ture');
$user->refreshData();
}
}
}
$tpl->display('profile.tpl');
}
if($page == 'password'){
if(isset($_POST['tab'])){
$Error = new Error();
if($prefix != 'FB'){
$lastPassword = hashMe($_POST['lastPassword']);
$req = $db->query('SELECT password FROM users WHERE password="'.safe($lastPassword,'SQL').'"');
if(isset($_POST['lastPassword']) && empty($_POST['lastPassword']))
$Error->set('lastPassword',$tpl->assign('error_last_password','true'));
elseif ($db->NumRowsC() == 0)
$Error->set('lastPassword',$tpl->assign('profile_error_last_password_correct','true'));
}
if(isset($_POST['newPassword']) && empty($_POST['newPassword']))
$Error->set('newPassword',$tpl->assign('profile_error_new_password_empty','true'));
elseif(strlen($_POST['newPassword']) <= 5)
$Error->set('password',$tpl->assign('profile_error_new_password_strlen','true'));
if(isset($_POST['newPasswordConfirm']) && empty($_POST['newPasswordConfirm']))
$Error->set('password',$tpl->assign('profile_error_new_passwordConfirm_empty','true'));
if(trim($_POST['newPasswordConfirm']) != trim($_POST['newPassword']))
$Error->set('password',$tpl->assign('profile_error_not_egale','true'));
if($Error->ErrorPresent())
$tpl->assign('error','true');
else{
$req = $db->query('UPDATE users SET password="'.hashMe($_POST['newPassword'],'SQL').'" WHERE id="'.$user->id.'"');
if($req){
$tpl->assign('success','true');
}
}
}
$tpl->display('profile-password.tpl');
}
$tpl->display('footer.tpl');
?>