forked from tbelliard/gepi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsecurity_panel_archives.php
executable file
·246 lines (227 loc) · 8.11 KB
/
security_panel_archives.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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
<?php
/*
*
* Copyright 2001-2011 Thomas Belliard, Laurent Delineau, Edouard Hue, Eric Lebrun
*
* This file is part of GEPI.
*
* GEPI is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* GEPI is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with GEPI; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
// Initialisations files
require_once("../lib/initialisations.inc.php");
// Resume session
$resultat_session = $session_gepi->security_check();
if ($resultat_session == 'c') {
header("Location: ../utilisateurs/mon_compte.php?change_mdp=yes");
die();
} else if ($resultat_session == '0') {
header("Location: ../logout.php?auto=1");
die();
}
if (!checkAccess()) {
header("Location: ../logout.php?auto=1");
die();
}
if (isset($_POST['duree2'])) {
$duree2 = $_POST['duree2'];
} else {
if (isset($_GET['duree2'])) {
$duree2 = $_GET['duree2'];
} else {
$duree2 = '20dernieres';
}
}
if(($duree2!="20dernieres")&&
($duree2!="2")&&
($duree2!="7")&&
($duree2!="15")&&
($duree2!="30")&&
($duree2!="60")&&
($duree2!="183")&&
($duree2!="365")&&
($duree2!="all")
) {
$duree2="20dernieres";
}
//**************** EN-TETE *****************
$titre_page = "Sécurité Gepi - Archives -";
require_once("../lib/header.inc.php");
//**************** FIN EN-TETE *****************
echo "<p class=bold><a href='index.php'><img src='../images/icons/back.png' alt='Retour' class='back_link'/> Retour</a> | <a href='security_policy.php'>Définir la politique de sécurité</a> | <a href='security_panel.php'>Panneau de sécurité</a></p>\n";
echo "<br />\n";
echo "<form action=\"security_panel_archives.php\" name=\"form_affiche_alerte\" method=\"post\">\n";
echo "Afficher l'historique des alertes : <select name=\"duree2\" size=\"1\">\n";
echo "<option ";
if ($duree2 == '20dernieres') echo "selected";
echo " value='20dernieres'>les 20 dernières</option>\n";
echo "<option ";
if ($duree2 == 2) echo "selected";
echo " value=2>depuis Deux jours</option>\n";
echo "<option ";
if ($duree2 == 7) echo "selected";
echo " value=7>depuis Une semaine</option>\n";
echo "<option ";
if ($duree2 == 15) echo "selected";
echo " value=15 >depuis Quinze jours</option>\n";
echo "<option ";
if ($duree2 == 30) echo "selected";
echo " value=30>depuis Un mois</option>\n";
echo "<option ";
if ($duree2 == 60) echo "selected";
echo " value=60>depuis Deux mois</option>\n";
echo "<option ";
if ($duree2 == 183) echo "selected";
echo " value=183>depuis Six mois</option>\n";
echo "<option ";
if ($duree2 == 365) echo "selected";
echo " value=365>depuis Un an</option>\n";
echo "<option ";
if ($duree2 == 'all') echo "selected";
echo " value='all'>depuis Le début</option>\n";
echo "</select>\n";
echo " <input type=\"submit\" name=\"Valider\" value=\"Valider\" /><br /><br />\n";
echo "</form>\n";
//echo "<table class='menu' style='width: 90%;'>\n";
echo "<table class='boireaus' style='width: 90%;'>\n";
echo "<tr>\n";
echo "<th colspan='5'>Historique des alertes</th>\n";
echo "</tr>\n";
/*
echo "<tr>\n";
echo "<td style='width: 20%;'>Utilisateur</td>\n";
echo "<td>Date</td>\n";
echo "<td>Niv.</td>\n";
echo "<td>Description</td>\n";
echo "<td style='width: 20%;'>Actions</td>\n";
echo "</tr>\n";
*/
echo "<tr>\n";
echo "<th style='width: 20%;'>\n";
echo "<a href='".$_SERVER['PHP_SELF']."?order_by=login";
if(isset($duree2)){echo "&duree2=$duree2";}
echo "' style='display:inline;'>Utilisateur</a>\n";
echo "/";
echo "<a href='".$_SERVER['PHP_SELF']."?order_by=ip";
if(isset($duree2)){echo "&duree2=$duree2";}
echo "' style='display:inline;'>IP</a>\n";
echo "</th>\n";
echo "<th>\n";
// Le tri par date est le mode standard... pas besoin de paramètre
echo "<a href='".$_SERVER['PHP_SELF'];
if(isset($duree2)){echo "?duree2=$duree2";}
echo "' style='display:inline;'>Date</a>\n";
echo "</th>\n";
echo "<th>\n";
echo "<a href='".$_SERVER['PHP_SELF']."?order_by=niveau";
if(isset($duree2)){echo "&duree2=$duree2";}
echo "' style='display:inline;'>Niv</a>\n";
echo "</th>\n";
echo "<th>Description</th>\n";
echo "<th style='width: 20%;'>Actions</th>\n";
echo "</tr>\n";
$requete = '';
$requete1 = '';
if ($duree2 != 'all') {$requete = "(t.date > now() - interval " . $duree2 . " day) ";}
if ($duree2 == '20dernieres') {$requete1 = "LIMIT 0,20"; $requete='1';}
if ($duree2 == 'all') {$requete='1';}
//$sql ="SELECT t.* FROM tentatives_intrusion t WHERE ((t.statut != 'new') AND ".$requete.") ORDER BY t.date DESC ".$requete1;
$sql ="SELECT t.* FROM tentatives_intrusion t WHERE ((t.statut != 'new') AND ".$requete.")";
$sql.=" ORDER BY ";
if(isset($_GET['order_by'])) {
$order_by=$_GET['order_by'];
if($order_by=='niveau') {
$sql.="t.niveau DESC, ";
}
elseif($order_by=='login') {
$sql.="t.login, ";
}
elseif($order_by=='ip') {
$sql.="t.adresse_ip, ";
}
else {
unset($order_by);
}
}
$sql.="t.date DESC ".$requete1;
//echo $sql;
$req = mysqli_query($GLOBALS["mysqli"], $sql);
if (!$req) echo mysqli_error($GLOBALS["mysqli"]);
$alt=1;
while ($row = mysqli_fetch_object($req)) {
$alt=$alt*(-1);
$user = null;
echo "<tr class='lig$alt white_hover'>\n";
echo "<td>\n";
if ($row->login != "-") {
// On récupère des informations sur l'utilisateur :
$user_req = mysqli_query($GLOBALS["mysqli"], "SELECT u.login, u.nom, u.prenom, u.statut, u.etat, u.niveau_alerte, u.observation_securite FROM utilisateurs u WHERE (u.login = '".$row->login . "')");
$user = mysqli_fetch_object($user_req);
}
if (!empty($user)) {
echo $user->login ." - ".$row->adresse_ip."<br/>\n";
echo "<b>".$user->prenom . " " . $user->nom."</b>\n";
echo "<br/>".$user->statut;
if ($user->etat == "actif") {
//echo " (compte actif)";
echo " (<span style='color:green;'>compte actif</span>)";
} else {
//echo " (compte désactivé)";
echo " (<span style='color:red;'>compte désactivé</span>)";
}
echo "<br/>Score cumulé : ".$user->niveau_alerte;
} else {
echo "<b>Attaque extérieure</b><br/>\n";
echo "Adresse IP : ".$row->adresse_ip."<br/>\n";
}
echo "</td>\n";
echo "<td>".$row->date."</td>\n";
echo "<td>".$row->niveau."</td>\n";
echo "<td><p class='small'><b>Page : ".$row->fichier."</b><br/>".stripslashes($row->description)."</p></td>\n";
echo "<td>\n";
if (!empty($user)) {
echo "<p>\n";
if ($user->etat == "actif") {
echo "<a style='padding: 2px;' href='security_panel.php?action=desactiver&user_login=".$user->login;
if(isset($order_by)) {echo "&order_by=$order_by";}
echo add_token_in_url()."'>Désactiver le compte</a>\n";
} else {
echo "<a style='padding: 2px;' href='security_panel.php?action=activer&user_login=".$user->login;
if(isset($order_by)) {echo "&order_by=$order_by";}
echo add_token_in_url()."'>Réactiver le compte</a>\n";
}
echo "<br />\n";
if ($user->observation_securite == 0) {
echo "<a style='padding: 2px;' href='security_panel.php?action=observer&user_login=".$user->login;
if(isset($order_by)) {echo "&order_by=$order_by";}
echo add_token_in_url()."'>Placer en observation</a>\n";
} else {
echo "<a style='padding: 2px;' href='security_panel.php?action=stop_observation&user_login=".$user->login;
if(isset($order_by)) {echo "&order_by=$order_by";}
echo add_token_in_url()."'>Retirer l'observation</a>\n";
}
echo "<br />\n";
echo "<a style='padding: 2px;' href='security_panel.php?action=reinit_cumul&user_login=".$user->login;
if(isset($order_by)) {echo "&order_by=$order_by";}
echo add_token_in_url()."'>Réinitialiser cumul</a>\n";
echo "</p>\n";
} else {
echo "<p class='small'><i>Aucune action disponible</i><br />(l'alerte n'est pas liée à un utilisateur du système)</p>\n";
}
echo "</td>\n";
echo "</tr>\n";
}
echo "</table>\n";
require("../lib/footer.inc.php");
?>