2010 |
raphael.pi |
1 |
<!DOCTYPE html>
|
|
|
2 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
|
3 |
<TITLE>ALCASAR Report</TITLE>
|
|
|
4 |
<link rel="stylesheet" type="text/css" href="../../../css/bootstrap.min.css">
|
|
|
5 |
<script src="../../../js/jquery.js"></script>
|
|
|
6 |
<script src="../../../js/bootstrap.min.js"></script>
|
|
|
7 |
<style>
|
|
|
8 |
body{
|
|
|
9 |
background-color: #EFEFEF;
|
|
|
10 |
}
|
|
|
11 |
</style>
|
|
|
12 |
</HEAD>
|
|
|
13 |
<body>
|
|
|
14 |
|
|
|
15 |
<?php
|
2011 |
raphael.pi |
16 |
|
2010 |
raphael.pi |
17 |
#Cette page permet de générer les journaux d'imputabilité dans une archive avec mot de passe.
|
|
|
18 |
#Lors de la création de cette archive, tous les utilisateurs d'alcasar seront prévenus lors de leur prochaine connexion par un message d'alerte.
|
|
|
19 |
#Cette page a été créé suite à la demande d'une préfecture de police afin de faciliter le déroulement des affaires judiciaires UNIQUEMENT.
|
|
|
20 |
|
|
|
21 |
|
|
|
22 |
# Choice of language
|
|
|
23 |
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE']))
|
|
|
24 |
{
|
|
|
25 |
$Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
|
|
|
26 |
$Language = strtolower(substr(chop($Langue[0]),0,2));
|
|
|
27 |
}
|
|
|
28 |
if($Language == 'fr')
|
|
|
29 |
{
|
|
|
30 |
$l_info = "Génération des journaux d'imputabilité";
|
|
|
31 |
$l_log_info = "Vous allez générer des journaux qui avertiront tous les utilisateurs. En effet, cette pratique est réservée uniquement de le cadre d'une enquête judiciaire. Vous comprenez donc les risques en continuant ici.";
|
|
|
32 |
$l_password = "Entrez votre mot de passe afin de protéger votre archive contenant le PDF des journaux d'imputabilité";
|
|
|
33 |
$l_submit = "Continuer";
|
|
|
34 |
$l_date1="Commençant le ...";
|
|
|
35 |
$l_date2="Terminant le ...";
|
|
|
36 |
$l_hours="Jusqu\'au ...";
|
|
|
37 |
$l_options_info = "Que désirez vous?";
|
|
|
38 |
$l_options_1="Tous les journaux";
|
|
|
39 |
$l_options_2="Selectionnez un intervale ...";
|
|
|
40 |
$l_options_3="Selectionnez depuis une date ...";
|
|
|
41 |
$l_load="Chargement...";
|
|
|
42 |
$l_create="Les utilisateurs ont été prévenus de cette action et l'archive a bien été crée, retenez bien votre mot de passe car il sera impossible de vous le redonner";
|
|
|
43 |
$l_download="Télécharger l'archive";
|
|
|
44 |
$l_error="Vous devez remplir les informations du formulaire!";
|
|
|
45 |
$l_demandeur="Nom du demandeur :";
|
|
|
46 |
$l_commentary="Raison :";
|
|
|
47 |
$l_info_form="Information du demandeur :";
|
|
|
48 |
$l_logtab="Dernières entrées :";
|
|
|
49 |
$l_empty_log="Les journaux sont vides";
|
|
|
50 |
|
|
|
51 |
}
|
|
|
52 |
else
|
|
|
53 |
{
|
|
|
54 |
$l_info = "Imputabilities logs generation";
|
|
|
55 |
$l_log_info = "You are generating logs which will warn users. In fact, this action is only reserved for a judicial investigation. So, you understand risks if you proceed.";
|
|
|
56 |
$l_password = "Enter your password to protect your archive which contains the PDF of imputabilities logs.";
|
|
|
57 |
$l_submit = "Proceed";
|
|
|
58 |
$l_date1="Start at ...";
|
|
|
59 |
$l_date2="End at ...";
|
|
|
60 |
$l_hours="At ...";
|
|
|
61 |
$l_options_info = "What do you want?";
|
|
|
62 |
$l_options_1="All logs";
|
|
|
63 |
$l_options_2="Select a range ...";
|
|
|
64 |
$l_options_3="Select from a specific date ...";
|
|
|
65 |
$l_create="Users have been warned and your archive has been created! Don't forget your password!";
|
|
|
66 |
$l_load="Loading...";
|
|
|
67 |
$l_download="Download archive";
|
|
|
68 |
$l_error="You need to submit form informations!!";
|
|
|
69 |
$l_demandeur="Applicant name :";
|
|
|
70 |
$l_commentary="Reason :";
|
|
|
71 |
$l_info_form="User Information";
|
|
|
72 |
$l_logtab="Last entries :";
|
|
|
73 |
$l_empty_log="Logs are empty";
|
|
|
74 |
}
|
|
|
75 |
|
|
|
76 |
|
|
|
77 |
$filename='/var/www/html/acc/backup/log_info.txt';
|
|
|
78 |
|
|
|
79 |
if(isset($_POST['submit']))
|
|
|
80 |
{
|
|
|
81 |
$password=$_POST['password'];
|
|
|
82 |
$demandeur=$_POST['demandeur'];
|
|
|
83 |
$raison=$_POST['comment'];
|
|
|
84 |
|
|
|
85 |
#si le mot de passe est vide ou si il contient des espaces
|
|
|
86 |
if($password != "" && $demandeur != "" && $raison != "")
|
|
|
87 |
{
|
|
|
88 |
#Génération de log
|
|
|
89 |
$text=date("Y-m-d H:i:s")."|||".$demandeur."|||".$raison."|||".$_SERVER['REMOTE_ADDR']."|||";
|
|
|
90 |
#supprimer les nouvelles lignes
|
|
|
91 |
$text = str_replace("\n", ' ', $text);
|
|
|
92 |
$text = str_replace("\r", ' ', $text);
|
|
|
93 |
|
|
|
94 |
|
|
|
95 |
file_put_contents($filename, $text.PHP_EOL, FILE_APPEND);
|
|
|
96 |
|
|
|
97 |
|
|
|
98 |
|
|
|
99 |
#Création des journaux dans une archive avec mot de passe.
|
|
|
100 |
$filename_logs="imputabilities_logs.zip";
|
|
|
101 |
switch($_POST['submit'])
|
|
|
102 |
{
|
|
|
103 |
case 'query_all':
|
|
|
104 |
exec("sudo alcasar-generate_log.sh '$password'");
|
|
|
105 |
break;
|
|
|
106 |
case 'query_range':
|
|
|
107 |
$date1_selected= $_POST['start-year'].'-'.$_POST['start-month'].'-'.$_POST['start-day'].' '.$_POST['start-hour'].':'.$_POST['start-min'].':'.$_POST['start-sec'];
|
|
|
108 |
$date2_selected= $_POST['stop-year'].'-'.$_POST['stop-month'].'-'.$_POST['stop-day'].' '.$_POST['stop-hour'].':'.$_POST['stop-min'].':'.$_POST['stop-sec'];
|
|
|
109 |
exec("sudo alcasar-generate_log.sh '$password' '$date1_selected' '$date2_selected' ");
|
|
|
110 |
break;
|
|
|
111 |
case 'query_simple':
|
|
|
112 |
$date1_selected= $_POST['start-year'].'-'.$_POST['start-month'].'-'.$_POST['start-day'].' '.$_POST['start-hour'].':'.$_POST['start-min'].':'.$_POST['start-sec'];
|
|
|
113 |
exec("sudo alcasar-generate_log.sh '$password' '$date1_selected'");
|
|
|
114 |
break;
|
|
|
115 |
|
|
|
116 |
}
|
|
|
117 |
|
|
|
118 |
|
|
|
119 |
#Interface permettant de télécharger les journaux d'imputabilité
|
|
|
120 |
echo "<h3>$l_create</h3>";
|
|
|
121 |
echo "<a href=\"$filename_logs\" class=\"btn btn-info btn-lg\">";
|
|
|
122 |
echo " <span class=\"glyphicon glyphicon-download-alt\"></span> $l_download";
|
|
|
123 |
echo "</a>";
|
|
|
124 |
}
|
|
|
125 |
else
|
|
|
126 |
{
|
|
|
127 |
echo "$l_error";
|
|
|
128 |
}
|
|
|
129 |
|
|
|
130 |
|
|
|
131 |
|
|
|
132 |
|
|
|
133 |
}
|
|
|
134 |
else
|
|
|
135 |
{
|
|
|
136 |
#Interface permettant de configurer la génération des journaux d'imputabilité.
|
|
|
137 |
echo "<div>";
|
|
|
138 |
echo " <div style=\"margin-top:20px\">";
|
|
|
139 |
echo " <div>";
|
|
|
140 |
|
|
|
141 |
echo " <fieldset>";
|
|
|
142 |
echo " <h3>$l_info</h3>";
|
|
|
143 |
echo " <p>$l_log_info</p>";
|
|
|
144 |
echo " </fieldset>";
|
|
|
145 |
|
|
|
146 |
echo "<h4> $l_options_info </h4>";
|
|
|
147 |
echo "<div class=\"radio\">";
|
|
|
148 |
echo "<label><input type=\"radio\" name=\"optradio\" onclick=\"radio_interact1()\" checked> $l_options_1 </label>";
|
|
|
149 |
echo "</div>";
|
|
|
150 |
echo "<div class=\"radio\">";
|
|
|
151 |
echo "<label><input type=\"radio\" name=\"optradio\" onclick=\"radio_interact2()\"> $l_options_2 </label>";
|
|
|
152 |
echo "</div>";
|
|
|
153 |
echo "<div class=\"radio\">";
|
|
|
154 |
echo "<label><input type=\"radio\" name=\"optradio\" onclick=\"radio_interact3()\"> $l_options_3 </label>";
|
|
|
155 |
echo "</div>";
|
|
|
156 |
echo "<form name=\"form_log\" method=\"post\" action=\"log_generation.php\" role=\"form\">";
|
|
|
157 |
echo "<p> $l_password </p><input name=\"password\" type=\"password\" size=\"25\">";
|
|
|
158 |
echo "<h2>$l_info_form</h2>";
|
|
|
159 |
echo "<p>$l_demandeur</p><textarea name='demandeur' style=\"height:25px;\"></textarea>";
|
|
|
160 |
echo "<p>$l_commentary</p><textarea name='comment'></textarea>";
|
|
|
161 |
echo "<p id=\"query_option\"></br></br><button type=\"submit\" onClick=\"this.classList.add('disabled');\" class=\"btn btn-primary\" name=\"submit\" value=\"query_all\"> $l_submit </button></p>";
|
|
|
162 |
|
|
|
163 |
|
|
|
164 |
|
|
|
165 |
}
|
|
|
166 |
|
|
|
167 |
echo "<br><div style=\"height:1px;background:#717171;border-bottom:1px solid #313030:\"></div>";
|
|
|
168 |
echo "<h2>$l_logtab</h2>";
|
|
|
169 |
if(file_exists($filename)){
|
|
|
170 |
|
|
|
171 |
echo "<div class=\"container\">";
|
|
|
172 |
echo "<table class=\"table table-striped\">";
|
|
|
173 |
echo "<thead>";
|
|
|
174 |
echo "<tr>";
|
|
|
175 |
echo "<th>Date</th>";
|
|
|
176 |
echo "<th>User</th>";
|
|
|
177 |
echo "<th>Reason</th>";
|
|
|
178 |
echo "<th>IP address</th>";
|
|
|
179 |
echo "</tr>";
|
|
|
180 |
echo "</thead>";
|
|
|
181 |
echo "<tbody>";
|
|
|
182 |
$fichier = fopen($filename, "r");
|
|
|
183 |
$content = file($filename);
|
|
|
184 |
foreach($content as $line){
|
|
|
185 |
$infos=explode("|||", $line);
|
|
|
186 |
echo "<tr>";
|
|
|
187 |
echo "<td>$infos[0]</td>";
|
|
|
188 |
echo "<td>$infos[1]</td>";
|
|
|
189 |
echo "<td>$infos[2]</td>";
|
|
|
190 |
echo "<td>$infos[3]</td>";
|
|
|
191 |
echo "</tr>";
|
|
|
192 |
}
|
|
|
193 |
|
|
|
194 |
echo "</tbody>";
|
|
|
195 |
echo "</table>";
|
|
|
196 |
echo "</div>";
|
|
|
197 |
|
|
|
198 |
|
|
|
199 |
}
|
|
|
200 |
else
|
|
|
201 |
{
|
|
|
202 |
echo "<p>$l_empty_log</p>";
|
|
|
203 |
}
|
|
|
204 |
|
|
|
205 |
#javascript permettant de generer les dropdown des dates. Il faut s'assurer que les données envoyées soient au bon format afin d'etre traité dans alcasar-generation_logs.sh
|
|
|
206 |
|
|
|
207 |
echo "<script>";
|
|
|
208 |
|
|
|
209 |
echo "function radio_interact1() {";
|
|
|
210 |
echo "document.getElementById(\"query_option\").innerHTML = '";
|
|
|
211 |
echo "</br></br><button type=\"submit\" class=\"btn btn-primary\" name=\"submit\" value=\"query_all\"> $l_submit</button>";
|
|
|
212 |
echo "';}";
|
|
|
213 |
|
|
|
214 |
echo "function radio_interact2() {";
|
|
|
215 |
echo " document.getElementById(\"query_option\").innerHTML = '";
|
|
|
216 |
|
|
|
217 |
echo "$l_date1 <select name=\"start-year\">";
|
|
|
218 |
$year = date('Y');
|
|
|
219 |
$years = $year-50;
|
|
|
220 |
for ($i = $year; $i >= $years; $i--) {
|
|
|
221 |
$sel = ($i == $year) ? ' selected="selected"' : '';
|
|
|
222 |
$i = str_pad($i, 2, '0', STR_PAD_LEFT);
|
|
|
223 |
echo "<option value=\"$i\"$sel>$i</option>";
|
|
|
224 |
}
|
|
|
225 |
echo "</select>";
|
|
|
226 |
echo "-<select name=\"start-month\">";
|
|
|
227 |
$month = date('m');
|
|
|
228 |
for ($i = 1; $i <= 12; $i++) {
|
|
|
229 |
$sel = ($i == $month) ? ' selected="selected"' : '';
|
|
|
230 |
$i = str_pad($i, 2, '0', STR_PAD_LEFT);
|
|
|
231 |
echo "<option value=\"$i\"$sel>$i</option>";
|
|
|
232 |
}
|
|
|
233 |
|
|
|
234 |
echo "</select>";
|
|
|
235 |
echo "-<select name=\"start-day\">";
|
|
|
236 |
$day = date('d');
|
|
|
237 |
for ($i = 1; $i <= 31; $i++) {
|
|
|
238 |
$sel = ($i == $day) ? ' selected="selected"' : '';
|
|
|
239 |
$i = str_pad($i, 2, '0', STR_PAD_LEFT);
|
|
|
240 |
echo "<option value=\"$i\"$sel>$i</option>";
|
|
|
241 |
}
|
|
|
242 |
|
|
|
243 |
echo "</select>";
|
|
|
244 |
echo "$l_hours <select name=\"start-hour\">";
|
|
|
245 |
$hour = date('G');
|
|
|
246 |
for ($i = 0; $i <= 23; $i++) {
|
|
|
247 |
$sel = ($i == $hour) ? ' selected="selected"' : '';
|
|
|
248 |
$i = str_pad($i, 2, '0', STR_PAD_LEFT);
|
|
|
249 |
echo "<option value=\"$i\"$sel>$i</option>";
|
|
|
250 |
}
|
|
|
251 |
echo "</select>";
|
|
|
252 |
echo ":<select name=\"start-min\">";
|
|
|
253 |
$min = date('i');
|
|
|
254 |
for ($i = 0; $i <= 59; $i++) {
|
|
|
255 |
$sel = ($i == $min) ? ' selected="selected"' : '';
|
|
|
256 |
$i = str_pad($i, 2, '0', STR_PAD_LEFT);
|
|
|
257 |
echo "<option value=\"$i\"$sel>$i</option>";
|
|
|
258 |
}
|
|
|
259 |
echo "</select>";
|
|
|
260 |
echo ":<select name=\"start-sec\">";
|
|
|
261 |
$sec = date('s');
|
|
|
262 |
for ($i = 0; $i <= 59; $i++) {
|
|
|
263 |
$sel = ($i == $sec) ? ' selected="selected"' : '';
|
|
|
264 |
$i = str_pad($i, 2, '0', STR_PAD_LEFT);
|
|
|
265 |
echo "<option value=\"$i\"$sel>$i</option>";
|
|
|
266 |
}
|
|
|
267 |
echo "</select>";
|
|
|
268 |
echo "</br>";
|
|
|
269 |
|
|
|
270 |
echo "$l_date2 <select name=\"stop-year\">";
|
|
|
271 |
$year = date('Y');
|
|
|
272 |
$years = $year-50;
|
|
|
273 |
for ($i = $year; $i >= $years; $i--) {
|
|
|
274 |
$sel = ($i == $year) ? ' selected="selected"' : '';
|
|
|
275 |
$i = str_pad($i, 2, '0', STR_PAD_LEFT);
|
|
|
276 |
echo "<option value=\"$i\"$sel>$i</option>";
|
|
|
277 |
}
|
|
|
278 |
echo "</select>";
|
|
|
279 |
echo "-<select name=\"stop-month\">";
|
|
|
280 |
$month = date('m')+1;
|
|
|
281 |
for ($i = 1; $i <= 12; $i++) {
|
|
|
282 |
$sel = ($i == $month) ? ' selected="selected"' : '';
|
|
|
283 |
$i = str_pad($i, 2, '0', STR_PAD_LEFT);
|
|
|
284 |
echo "<option value=\"$i\"$sel>$i</option>";
|
|
|
285 |
}
|
|
|
286 |
|
|
|
287 |
echo "</select>";
|
|
|
288 |
echo "-<select name=\"stop-day\">";
|
|
|
289 |
$day = date('d');
|
|
|
290 |
for ($i = 1; $i <= 31; $i++) {
|
|
|
291 |
$sel = ($i == $day) ? ' selected="selected"' : '';
|
|
|
292 |
$i = str_pad($i, 2, '0', STR_PAD_LEFT);
|
|
|
293 |
echo "<option value=\"$i\"$sel>$i</option>";
|
|
|
294 |
}
|
|
|
295 |
|
|
|
296 |
echo "</select>";
|
|
|
297 |
echo "$l_hours <select name=\"stop-hour\">";
|
|
|
298 |
$hour = date('G');
|
|
|
299 |
for ($i = 0; $i <= 23; $i++) {
|
|
|
300 |
$sel = ($i == $hour) ? ' selected="selected"' : '';
|
|
|
301 |
$i = str_pad($i, 2, '0', STR_PAD_LEFT);
|
|
|
302 |
echo "<option value=\"$i\"$sel>$i</option>";
|
|
|
303 |
}
|
|
|
304 |
echo "</select>";
|
|
|
305 |
echo ":<select name=\"stop-min\">";
|
|
|
306 |
$min = date('i');
|
|
|
307 |
for ($i = 0; $i <= 59; $i++) {
|
|
|
308 |
$sel = ($i == $min) ? ' selected="selected"' : '';
|
|
|
309 |
$i = str_pad($i, 2, '0', STR_PAD_LEFT);
|
|
|
310 |
echo "<option value=\"$i\"$sel>$i</option>";
|
|
|
311 |
}
|
|
|
312 |
echo "</select>";
|
|
|
313 |
echo ":<select name=\"stop-sec\">";
|
|
|
314 |
$sec = date('s');
|
|
|
315 |
for ($i = 0; $i <= 59; $i++) {
|
|
|
316 |
$sel = ($i == $sec) ? ' selected="selected"' : '';
|
|
|
317 |
$i = str_pad($i, 2, '0', STR_PAD_LEFT);
|
|
|
318 |
echo "<option value=\"$i\"$sel>$i</option>";
|
|
|
319 |
}
|
|
|
320 |
echo "</select>";
|
|
|
321 |
echo "</br></br><button type=\"submit\" class=\"btn btn-primary\" name=\"submit\" value=\"query_range\"> $l_submit</button>";
|
|
|
322 |
echo "';}";
|
|
|
323 |
|
|
|
324 |
|
|
|
325 |
|
|
|
326 |
echo "function radio_interact3() {";
|
|
|
327 |
echo " document.getElementById(\"query_option\").innerHTML = '";
|
|
|
328 |
|
|
|
329 |
echo "$l_date1 <select name=\"start-year\">";
|
|
|
330 |
$year = date('Y');
|
|
|
331 |
$years = $year-50;
|
|
|
332 |
for ($i = $year; $i >= $years; $i--) {
|
|
|
333 |
$sel = ($i == $year) ? ' selected="selected"' : '';
|
|
|
334 |
$i = str_pad($i, 2, '0', STR_PAD_LEFT);
|
|
|
335 |
echo "<option value=\"$i\"$sel>$i</option>";
|
|
|
336 |
}
|
|
|
337 |
echo "</select>";
|
|
|
338 |
echo "-<select name=\"start-month\">";
|
|
|
339 |
$month = date('m');
|
|
|
340 |
for ($i = 1; $i <= 12; $i++) {
|
|
|
341 |
$sel = ($i == $month) ? ' selected="selected"' : '';
|
|
|
342 |
$i = str_pad($i, 2, '0', STR_PAD_LEFT);
|
|
|
343 |
echo "<option value=\"$i\"$sel>$i</option>";
|
|
|
344 |
}
|
|
|
345 |
|
|
|
346 |
echo "</select>";
|
|
|
347 |
echo "-<select name=\"start-day\">";
|
|
|
348 |
$day = date('d');
|
|
|
349 |
for ($i = 1; $i <= 31; $i++) {
|
|
|
350 |
$sel = ($i == $day) ? ' selected="selected"' : '';
|
|
|
351 |
$i = str_pad($i, 2, '0', STR_PAD_LEFT);
|
|
|
352 |
echo "<option value=\"$i\"$sel>$i</option>";
|
|
|
353 |
}
|
|
|
354 |
|
|
|
355 |
echo "</select>";
|
|
|
356 |
echo "$l_hours <select name=\"start-hour\">";
|
|
|
357 |
$hour = date('G');
|
|
|
358 |
for ($i = 0; $i <= 23; $i++) {
|
|
|
359 |
$sel = ($i == $hour) ? ' selected="selected"' : '';
|
|
|
360 |
$i = str_pad($i, 2, '0', STR_PAD_LEFT);
|
|
|
361 |
echo "<option value=\"$i\"$sel>$i</option>";
|
|
|
362 |
}
|
|
|
363 |
echo "</select>";
|
|
|
364 |
echo ":<select name=\"start-min\">";
|
|
|
365 |
$min = date('i');
|
|
|
366 |
for ($i = 0; $i <= 59; $i++) {
|
|
|
367 |
$sel = ($i == $min) ? ' selected="selected"' : '';
|
|
|
368 |
$i = str_pad($i, 2, '0', STR_PAD_LEFT);
|
|
|
369 |
echo "<option value=\"$i\"$sel>$i</option>";
|
|
|
370 |
}
|
|
|
371 |
echo "</select>";
|
|
|
372 |
echo ":<select name=\"start-sec\">";
|
|
|
373 |
$sec = date('s');
|
|
|
374 |
for ($i = 0; $i <= 59; $i++) {
|
|
|
375 |
$sel = ($i == $sec) ? ' selected="selected"' : '';
|
|
|
376 |
$i = str_pad($i, 2, '0', STR_PAD_LEFT);
|
|
|
377 |
echo "<option value=\"$i\"$sel>$i</option>";
|
|
|
378 |
}
|
|
|
379 |
echo "</select>";
|
|
|
380 |
echo "</br></br><button type=\"submit\" class=\"btn btn-primary\" name=\"submit\" value=\"query_simple\"> $l_submit</button>";
|
|
|
381 |
echo "';}";
|
|
|
382 |
echo "</script>";
|
|
|
383 |
|
|
|
384 |
echo "</form>";
|
|
|
385 |
echo "</div>";
|
|
|
386 |
echo "</div>";
|
|
|
387 |
echo "</div>";
|
|
|
388 |
?>
|
|
|
389 |
|
|
|
390 |
</body>
|
|
|
391 |
</html>
|
|
|
392 |
|
|
|
393 |
|
|
|
394 |
|
|
|
395 |
|