-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathprofile.php
222 lines (194 loc) · 9.35 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
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
<?php
/// Require the header that already contains the sidebar and top of the website and head body tags
$page = "Профиль";
require_once 'header.php';
require 'includes/vendor/autoload.php';
$authenticator = new PHPGangsta_GoogleAuthenticator();
$plansql = $odb -> prepare("SELECT `users`.`expire`, `plans`.`name`, `plans`.`concurrents`, `plans`.`mbt` FROM `users`, `plans` WHERE `plans`.`ID` = `users`.`membership` AND `users`.`ID` = :id");
$plansql -> execute(array(":id" => $_SESSION['ID']));
$row = $plansql -> fetch();
$date = date("m-d-Y", $row['expire']);
if (!$user->hasMembership($odb)){
$row['mbt'] = 0;
$row['concurrents'] = 0;
$row['name'] = 'No membership';
$date = 'No membership';
}
if(!empty($_POST['update'])){
if(empty($_POST['old']) || empty($_POST['new'])){
$error = 'Вам нужно ввести оба пароля';
}
$SQLCheckCurrent = $odb -> prepare("SELECT COUNT(*) FROM `users` WHERE `ID` = :ID AND `password` = :password");
$SQLCheckCurrent -> execute(array(':ID' => $_SESSION['ID'], ':password' => SHA1(md5($_POST['old']))));
$countCurrent = $SQLCheckCurrent -> fetchColumn(0);
if ($countCurrent == 0){
$error = 'Текущий пароль неверный';
}
$notify = error($error);
if(empty($error)){
$SQLUpdate = $odb -> prepare("UPDATE `users` SET `password` = :password WHERE `username` = :username AND `ID` = :id");
$SQLUpdate -> execute(array(':password' => SHA1(md5($_POST['new'])),':username' => $_SESSION['username'], ':id' => $_SESSION['ID']));
$notify = success('Пароль успешно изменен');
}
}
if(isset($_POST['enable2']))
{
$id = $_SESSION['ID'];
$SQLinsert = $odb -> prepare("UPDATE `users` SET `2auth` = '1' WHERE `ID` = :id");
$SQLinsert -> execute(array( ':id' => $id));
$notify = success('2х этапная авторизация включена, пожалуйста, отсканируйте QR-код в своем приложении!');
}
?>
<!-- Page Content -->
<div id="page-wrapper">
<div class="container-fluid">
<div class="row bg-title">
<div class="col-lg-3 col-md-4 col-sm-4 col-xs-12">
<h4 class="page-title"><?php echo $page; ?></h4>
</div>
<div class="col-lg-9 col-sm-8 col-md-8 col-xs-12">
<ol class="breadcrumb">
<li><a href="#"><?php echo $sitename; ?></a></li>
<li class="active"><?php echo $page; ?></li>
</ol>
</div>
<!-- /.col-lg-12 -->
</div>
<?php
if(isset($notify)){
echo '<div class="row col-md-12">' . $notify . "</div>";
}
?>
<div class="row">
<div class="col-md-4 col-xs-12">
<div class="white-box">
<div class="user-bg"> <img width="100%" alt="user" src="includes/theme/plugins/images/large/img1.jpg">
<div class="overlay-box">
<div class="user-content"> <a href="javascript:void(0)"><img src="includes/theme/plugins/images/users/avatar.png" class="thumb-lg img-circle" alt="img"></a>
<h4 class="text-white"><?php echo $_SESSION['username']; ?></h4>
<h5 class="text-white">user@maostress</h5>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-8 col-xs-12">
<div class="white-box">
<ul class="nav nav-tabs tabs customtab">
<li class="active tab"><a href="#logins" data-toggle="tab"> <span class="visible-xs"><i class="fa fa-user"></i></span> <span class="hidden-xs">Входы</span> </a> </li>
<li class="tab"><a href="#attacks" data-toggle="tab" aria-expanded="true"> <span class="visible-xs"><i class="fa fa-envelope-o"></i></span> <span class="hidden-xs">Атаки</span> </a> </li>
<li class="tab"><a href="#settings" data-toggle="tab" aria-expanded="false"> <span class="visible-xs"><i class="fa fa-cog"></i></span> <span class="hidden-xs">Изменить пароль</span> </a> </li>
<li class="tab"><a href="#2auth" data-toggle="tab" aria-expanded="false"> <span class="visible-xs"><i class="fa fa-cog"></i></span> <span class="hidden-xs">2Auth</span> </a> </li>
</ul>
<div class="tab-content">
<div class="tab-pane" id="logins">
<table class="table">
<thead>
<tr>
<th style="font-size: 12px;">IP Адрес</th>
<th style="font-size: 12px;">Страна</th>
<th style="font-size: 12px;">Дата</th>
</tr>
</thead>
<tbody style="font-size: 12px;">
<?php
$SQLGetLogs = $odb -> query("SELECT * FROM `loginlogs` WHERE `username`='{$_SESSION['username']}' ORDER BY `date` DESC LIMIT 0, 5");
while($getInfo = $SQLGetLogs -> fetch(PDO::FETCH_ASSOC)){
$IP = $getInfo['ip'];
$country = $getInfo['country'];
$date = date("m-d-Y, h:i:s a" ,$getInfo['date']);
echo '<tr>
<td>'.htmlspecialchars($IP).'</td>
<td>'.$country.'</td>
<td>'.$date.'</td>
</tr>';
}
?>
</tbody>
</table>
</div>
<div class="tab-pane" id="attacks">
<table class="table">
<thead>
<tr>
<th style="font-size: 12px;">Хост</th>
<th style="font-size: 12px;">Порт</th>
<th style="font-size: 12px;">Время</th>
<th style="font-size: 12px;">Метод</th>
<th style="font-size: 12px;">Дата</th>
</tr>
</thead>
<tbody style="font-size: 12px;">
<?php
$SQLGetLogs = $odb -> query("SELECT * FROM `logs` WHERE user='{$_SESSION['username']}' ORDER BY `date` DESC LIMIT 10");
while($getInfo = $SQLGetLogs -> fetch(PDO::FETCH_ASSOC)){
$IP = $getInfo['ip'];
$port = $getInfo['port'];
$time = $getInfo['time'];
$method = $odb->query("SELECT `fullname` FROM `methods` WHERE `name` = '{$getInfo['method']}'")->fetchColumn(0);
$date = date("m-d-Y, h:i:s a" ,$getInfo['date']);
echo '<tr><td>'.htmlspecialchars($IP).'</td><td>'.$port.'</td><td>'.$time.' seconds</td><td>'.htmlspecialchars($method).'</td><td>'.$date.'</td></tr>';
}
?>
</tbody>
</table>
</div>
<div class="tab-pane" id="settings">
<form class="form-horizontal push-10-t push-10" method="post">
<div class="form-group">
<div class="col-xs-12">
<div class="form-material">
<input class="form-control" type="password" id="old" name="old" placeholder="Введите старый пароль..">
</div>
</div>
</div>
<div class="form-group">
<div class="col-xs-12">
<div class="form-material">
<input class="form-control" type="password" id="new" name="new" placeholder="Введите новый пароль..">
</div>
</div>
</div>
<div class="form-group">
<div class="col-xs-12">
<button class="btn btn-sm btn-danger" name="update" value="change" type="submit">
<i class="fa fa-plus push-5-r"></i> Изменить
</button>
</div>
</div>
</form>
</div>
<div class="tab-pane" id="2auth">
<form method="post">
<?php
// Enable the area for 2auth
// User Info
$SQLSelect = $odb->prepare("SELECT * FROM `users` WHERE `id` = :renew");
$SQLSelect -> execute(array(':renew' => $_SESSION['ID']));
while ($show = $SQLSelect->fetch(PDO::FETCH_ASSOC)) {
$twoauthstatus = $show['2auth'];
}
// Disanled
if($twoauthstatus == "0")
{
echo '<button name="enable2" class="btn btn-outline btn-info" type="submit">Enable</button>';
}
else
{
$website = $_SERVER['SERVER_NAME']; //Your Website
$qrCodeUrl = $authenticator->getQRCodeGoogleUrl($sitename, $AuthSecret,$website);
echo '<div class="alert alert-info"> Убедитесь, что вы отсканировали приведенный ниже код, если вы включили 2Auth.</div>';
echo '<img src="' .$qrCodeUrl. '"></img>';
}
?>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<?php
require_once 'footer.php';
?>