Subversion Repositories ALCASAR

Rev

Rev 2299 | Rev 2527 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log

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