-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
207 lines (161 loc) · 5.93 KB
/
index.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
<?php
session_start();
require_once 'config.php';
require_once 'head.php';
?>
<div class="body-wrapper">
<div class="container">
<?php
//require_once('err_check.php');
if ($_POST['logout']) {
session_unset();
setcookie('user_id', '', 0, "/");
// setcookie('login', '', 0, "/");
// setcookie('password', '', 0, "/");
setcookie('group', '', 0, "/");
setcookie('name', '', 0, "/");
$_POST = [];
header('Location: /');
}
if ($_POST) {
$login = trim($_POST['login']);
$login = stripslashes( $login );
$login = htmlspecialchars( $login );
$login = mysqli_real_escape_string( $connect, $login );
$auth = mysqli_query($connect, "SELECT salt FROM users WHERE `login` = '$login' LIMIT 1");
if (mysqli_num_rows($auth) == 1) {
$row = mysqli_fetch_assoc($auth);
$salt = $row['salt'];
$password = md5(md5($_POST['password']) . $salt);
$auth1 = mysqli_query($connect, "SELECT * FROM users WHERE `login` = '$login' AND `password` = '$password' LIMIT 1");
if (mysqli_num_rows($auth1) == 1) {
$row1 = mysqli_fetch_assoc($auth1);
$login_row = $row1['login'];
$password_row = $row1['password'];
// $_SESSION['user_id'] = $row1['id'];
// $_SESSION['login'] = $row1['login'];
// $_SESSION['password'] = $row1['password'];
// $_SESSION['group_id'] = $row1['group'];
// $_SESSION['name'] = $row1['fio'];
$cookie_time = 86400; // ставим куку на сутки
if (isset($_POST['remember'])) {
setcookie('user_id', $row1['id'], time() + $cookie_time, "/");
// setcookie('login', $row1['login'], time() + $cookie_time, "/");
// setcookie('password', $row1['password'], time() + $cookie_time, "/");
setcookie('group', $row1['group'], time() + $cookie_time, "/");
setcookie('name', $row1['user_name'], time() + $cookie_time, "/");
}
header('Location: /');
}
}
}
if (!$_COOKIE['user_id']) {
require_once('auth_form.php');
} else {
$query = mysqli_query($connect, "SELECT *, d.id as id_ats
FROM db_ats d
LEFT JOIN name_dslam ON name_dslam.id = d.id_dslam
LEFT JOIN street ON street.id = d.id_ul
LEFT JOIN np ON np.id = d.id_np
LEFT JOIN gpon ON gpon.id = d.id_gpon
ORDER BY date_edit DESC LIMIT 14");
require_once('header.php');
require_once('search-form.php');
?>
<div class="block block__table">
<h3><?= $table_title ?></h3>
<div class="block__table-body">
<table class="table table-striped align-middle table__hovered">
<?= $table_head ?>
<tbody>
<?php
while ($line = mysqli_fetch_assoc($query)) {
$tootip_gpon = $line['phone'];
if ($search) {
switch ($what) {
case 0: {
$string1 = "<span style=\"font-weight: 500; color: red;\">" . $search . "</span>";
$line['phone'] = mb_ereg_replace($search, $string1, $line['phone']);
break;
}
case 1: {
$search = mb_strtoupper($search, 'utf-8');
$string1 = "<span style=\"font-weight: 500; color: red;\">" . $search . "</span>";
$line['client'] = mb_strtoupper($line['client'], 'utf-8');
$line['client'] = mb_ereg_replace($search, $string1, $line['client']);
break;
}
case 2: {
$search = mb_strtoupper($search, 'utf-8');
$string1 = "<span style=\"font-weight: 500; color: red;\">" . $search . "</span>";
$line['street_name'] = mb_strtoupper($line['street_name'], 'utf-8');
$line['street_name'] = mb_ereg_replace($search, $string1, $line['street_name']);
break;
}
case 3: {
$string1 = "<span style=\"font-weight: 500; color: red;\">" . $search . "</span>";
$line['line_data'] = mb_ereg_replace($search, $string1, $line['line_data']);
break;
}
}
}
print "
<tr class=\"table__row\" onclick=\"javascript:document.location.href='client.php?id=" . $line['id_ats'] . "'\" style=\"cursor:pointer\">";
if ($line["id_gpon"]) {
print "<th scope=\"row\"><div class=\"text-break text-wrap\" style=\"width: 150px; font-size: 14px;\">" . $line['phone'] . "</div></th>";
} else {
print "<th scope=\"row\">" . $line['phone'] . "</th>";
}
if ($line['line_data'] && $line['cross_data']) {
print "<td>" . $line['line_data'] . " | " . $line['cross_data'] . "</td>";
}
if ($line['line_data'] && !$line['cross_data']) {
print "<td>" . $line['line_data'] . "</td>";
}
if (!$line['line_data'] && $line['cross_data']) {
print "<td>" . $line['cross_data'] . "</td>";
}
if (!$line['line_data'] && !$line['cross_data'] && $line['status'] == 0) {
print "<td></td>";
}
if (!$line['line_data'] && !$line['cross_data'] && $line['status'] == 1) {
echo "<td><div data-tooltip=\"tooltip\" data-bs-placement=\"bottom\" title=\"Відключений\" class=\"d-inline text-danger\"><i class=\"fa-solid fa-triangle-exclamation fs-4\"></i></div></td>";
}
print "<td>" . $line['client'] . "</td><td>";
if ($line["np_name"]) {
if ($line['street_name'] || $line['nomer_doma'] || $line['korpus'] || $line['kv']) {
echo $line['np_name'] . ", ";
} else {
echo $line['np_name'];
}
}
if ($line['street_name']) {
echo $line['street_name'];
}
if ($line['nomer_doma']) {
echo " " . $line['nomer_doma'];
}
if ($line['korpus']) {
echo "/" . $line['korpus'];
}
if ($line['kv']) {
echo " КВ." . $line['kv'];
}
print "</td></tr>";
}
?>
</tbody>
</table>
</div>
</div>
<?php
}
require_once('footer.php');
?>
</div>
</div>
<?php
require_once('scripts.php');
?>
</body>
</html>