Subversion Repositories ALCASAR

Rev

Rev 2317 | Rev 2818 | 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>
2527 fabien.rak 7
<link rel="stylesheet" href="../manager/htdocs/style.css">
2010 raphael.pi 8
<style>
9
body{
10
	background-color: #EFEFEF;
11
}
12
</style>
13
</HEAD>
14
<body>
15
 
16
<?php
2182 tom.houday 17
# $Id $
2011 raphael.pi 18
 
2010 raphael.pi 19
#Cette page permet de générer les journaux d'imputabilité dans une archive avec mot de passe.
20
#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.
21
#Cette page a été créé suite à la demande d'une préfecture de police afin de faciliter le déroulement des affaires judiciaires UNIQUEMENT.
22
 
23
 
24
# Choice of language
25
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE']))
26
{
27
	$Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
28
	$Language = strtolower(substr(chop($Langue[0]),0,2));
29
}
30
if($Language == 'fr')
31
{
32
	$l_info = "Génération des journaux d'imputabilité";
2170 richard 33
	$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 34
	$l_password = "Entrez votre mot de passe afin de protéger l'archive contenant le document généré";
2010 raphael.pi 35
	$l_submit = "Continuer";
36
	$l_date1="Commençant le ...";
37
	$l_date2="Terminant le ...";
2142 richard 38
	$l_hours="à ...";
2010 raphael.pi 39
	$l_options_info = "Que désirez vous?";
40
	$l_options_1="Tous les journaux";
41
	$l_options_2="Selectionnez un intervale ...";
42
	$l_options_3="Selectionnez depuis une date ...";
43
	$l_load="Chargement...";
44
	$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";
45
	$l_download="Télécharger l'archive";
46
	$l_error="Vous devez remplir les informations du formulaire!";
47
	$l_demandeur="Nom du demandeur :";
48
	$l_commentary="Raison :";
49
	$l_info_form="Information du demandeur :";
50
	$l_logtab="Dernières entrées :";
51
	$l_empty_log="Les journaux sont vides";
52
 
53
}
54
else
55
{
56
	$l_info = "Imputabilities logs generation";
2170 richard 57
	$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 58
	$l_password = "Enter your password to protect the archive which contains the document.";
2010 raphael.pi 59
	$l_submit = "Proceed";
60
	$l_date1="Start at ...";
61
	$l_date2="End at ...";
2142 richard 62
	$l_hours="at ...";
2010 raphael.pi 63
	$l_options_info = "What do you want?";
64
	$l_options_1="All logs";
65
	$l_options_2="Select a range ...";
66
	$l_options_3="Select from a specific date ...";
67
	$l_create="Users have been warned and your archive has been created! Don't forget your password!";
68
	$l_load="Loading...";
69
	$l_download="Download archive";
70
	$l_error="You need to submit form informations!!";
71
	$l_demandeur="Applicant name :";
72
	$l_commentary="Reason :";
73
	$l_info_form="User Information";
74
	$l_logtab="Last entries :";
75
	$l_empty_log="Logs are empty";
76
}
77
 
78
 
79
$filename='/var/www/html/acc/backup/log_info.txt';
80
 
81
if(isset($_POST['submit']))
82
{
83
	$password=$_POST['password'];
84
	$demandeur=$_POST['demandeur'];
85
	$raison=$_POST['comment'];
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é.
2527 fabien.rak 134
 
135
	echo "<table class=\"tableTop\" border='0' cellspacing='0' cellpadding='0'>";
136
	echo "<tbody >";	
137
	echo "	<tr>";
138
			echo "<th class='thBasicACC'>";
139
				echo "ALCASAR Report";
140
			echo "</th>";
141
			echo "</tr>";
142
	echo	"</tbody>";
143
	echo "<tr bgcolor='#FFCC66'><td class=\"tdSizeACC\">
144
						<img src='/images/pix.gif' width='1' height='2'></td></tr>";
145
	echo "</table>";
146
	echo "<div class =\"frameBorderACC\">";
147
	echo "	<div style=\"margin-top:16px;margin-left:15px;\">";
2010 raphael.pi 148
	echo "		<div>";
149
 
150
	echo "				<fieldset>";
151
	echo "					<h3>$l_info</h3>";
152
	echo "					<p>$l_log_info</p>";
153
	echo "				</fieldset>";
154
 
155
	echo "<h4> $l_options_info  </h4>";
156
	echo "<div class=\"radio\">";
2527 fabien.rak 157
	echo "<label><input type=\"radio\" name=\"optradio\" onclick=\"radio_interact1()\"  style=\"margin-top: -1px;\" checked> $l_options_1 </label>";
2010 raphael.pi 158
	echo "</div>";
159
	echo "<div class=\"radio\">";
2527 fabien.rak 160
	echo "<label><input type=\"radio\" name=\"optradio\" onclick=\"radio_interact2()\" style=\"margin-top: -1px;\" > $l_options_2 </label>";
2010 raphael.pi 161
	echo "</div>";
162
	echo "<div class=\"radio\">";
2527 fabien.rak 163
	echo "<label><input type=\"radio\" name=\"optradio\" onclick=\"radio_interact3()\" style=\"margin-top: -1px;\"> $l_options_3 </label>";
2010 raphael.pi 164
	echo "</div>";
165
	echo "<form name=\"form_log\" method=\"post\" action=\"log_generation.php\" role=\"form\">";
166
	echo "<p> $l_password </p><input name=\"password\" type=\"password\" size=\"25\">";
167
	echo "<h2>$l_info_form</h2>";
168
	echo "<p>$l_demandeur</p><textarea name='demandeur' style=\"height:25px;\"></textarea>";
169
	echo "<p>$l_commentary</p><textarea name='comment'></textarea>";
170
	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>";	
171
}
172
 
173
echo "<br><div style=\"height:1px;background:#717171;border-bottom:1px solid #313030:\"></div>";
174
echo "<h2>$l_logtab</h2>";
175
if(file_exists($filename)){
176
	echo "<div class=\"container\">";     
177
	echo "<table class=\"table table-striped\">";
178
	echo "<thead>";
179
	echo "<tr>";
180
	echo "<th>Date</th>";
181
	echo "<th>User</th>";
182
	echo "<th>Reason</th>";
183
	echo "<th>IP address</th>";
184
	echo "</tr>";
185
	echo "</thead>";
186
	echo "<tbody>";
2182 tom.houday 187
	$fichier = fopen($filename, "r");
188
	$content = file($filename);
189
	$content = array_reverse($content);
190
	foreach($content as $line){
2010 raphael.pi 191
		$infos=explode("|||", $line);
192
		echo "<tr>";
2182 tom.houday 193
		echo "<td>$infos[0]</td>";
194
		echo "<td>$infos[1]</td>";
195
		echo "<td>$infos[2]</td>";
196
		echo "<td>$infos[3]</td>";
2010 raphael.pi 197
		echo "</tr>";
2182 tom.houday 198
	}
199
	echo "</tbody>";
200
	echo "</table>";
201
	echo "</div>";
2010 raphael.pi 202
}
203
else
204
{
205
	echo "<p>$l_empty_log</p>";
206
}
207
 
208
#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
209
 
210
echo "<script>";
211
 
212
echo "function radio_interact1() {";
213
echo "document.getElementById(\"query_option\").innerHTML = '";
214
echo "</br></br><button type=\"submit\" class=\"btn btn-primary\" name=\"submit\" value=\"query_all\"> $l_submit</button>";
215
echo "';}";
216
 
217
echo "function radio_interact2() {";
218
echo "    document.getElementById(\"query_option\").innerHTML = '";
219
 
220
echo "$l_date1 <select name=\"start-year\">";
221
$year = date('Y');
222
$years = $year-50;
223
for ($i = $year; $i >= $years; $i--) {
224
    $sel = ($i == $year) ? ' selected="selected"' : '';
225
    $i = str_pad($i, 2, '0', STR_PAD_LEFT);
226
    echo "<option value=\"$i\"$sel>$i</option>";
227
}
228
echo "</select>";
229
echo "-<select name=\"start-month\">";
230
$month = date('m');
231
for ($i = 1; $i <= 12; $i++) {
232
    $sel = ($i == $month) ? ' selected="selected"' : '';
233
    $i = str_pad($i, 2, '0', STR_PAD_LEFT);
234
    echo "<option value=\"$i\"$sel>$i</option>";
235
}
236
 
237
echo "</select>";
238
echo "-<select name=\"start-day\">";
239
$day = date('d');
240
for ($i = 1; $i <= 31; $i++) {
241
    $sel = ($i == $day) ? ' selected="selected"' : '';
242
    $i = str_pad($i, 2, '0', STR_PAD_LEFT);
243
    echo "<option value=\"$i\"$sel>$i</option>";
244
}
245
 
246
echo "</select>";
247
echo "$l_hours <select name=\"start-hour\">";
248
$hour = date('G');
249
for ($i = 0; $i <= 23; $i++) {
250
    $sel = ($i == $hour) ? ' selected="selected"' : '';
251
    $i = str_pad($i, 2, '0', STR_PAD_LEFT);
252
    echo "<option value=\"$i\"$sel>$i</option>";
253
}
254
echo "</select>";
255
echo ":<select name=\"start-min\">";
256
$min = date('i');
257
for ($i = 0; $i <= 59; $i++) {
258
    $sel = ($i == $min) ? ' selected="selected"' : '';
259
    $i = str_pad($i, 2, '0', STR_PAD_LEFT);
260
    echo "<option value=\"$i\"$sel>$i</option>";
261
}
262
echo "</select>";
263
echo ":<select name=\"start-sec\">";
264
$sec = date('s');
265
for ($i = 0; $i <= 59; $i++) {
266
    $sel = ($i == $sec) ? ' selected="selected"' : '';
267
    $i = str_pad($i, 2, '0', STR_PAD_LEFT);
268
    echo "<option value=\"$i\"$sel>$i</option>";
269
}
270
echo "</select>";
271
echo "</br>";
272
 
273
echo "$l_date2 <select name=\"stop-year\">";
274
$year = date('Y');
275
$years = $year-50;
276
for ($i = $year; $i >= $years; $i--) {
277
    $sel = ($i == $year) ? ' selected="selected"' : '';
278
    $i = str_pad($i, 2, '0', STR_PAD_LEFT);
279
    echo "<option value=\"$i\"$sel>$i</option>";
280
}
281
echo "</select>";
282
echo "-<select name=\"stop-month\">";
283
$month = date('m')+1;
284
for ($i = 1; $i <= 12; $i++) {
285
    $sel = ($i == $month) ? ' selected="selected"' : '';
286
    $i = str_pad($i, 2, '0', STR_PAD_LEFT);
287
    echo "<option value=\"$i\"$sel>$i</option>";
288
}
289
 
290
echo "</select>";
291
echo "-<select name=\"stop-day\">";
292
$day = date('d');
293
for ($i = 1; $i <= 31; $i++) {
294
    $sel = ($i == $day) ? ' selected="selected"' : '';
295
    $i = str_pad($i, 2, '0', STR_PAD_LEFT);
296
    echo "<option value=\"$i\"$sel>$i</option>";
297
}
298
 
299
echo "</select>";
300
echo "$l_hours <select name=\"stop-hour\">";
301
$hour = date('G');
302
for ($i = 0; $i <= 23; $i++) {
303
    $sel = ($i == $hour) ? ' selected="selected"' : '';
304
    $i = str_pad($i, 2, '0', STR_PAD_LEFT);
305
    echo "<option value=\"$i\"$sel>$i</option>";
306
}
307
echo "</select>";
308
echo ":<select name=\"stop-min\">";
309
$min = date('i');
310
for ($i = 0; $i <= 59; $i++) {
311
    $sel = ($i == $min) ? ' selected="selected"' : '';
312
    $i = str_pad($i, 2, '0', STR_PAD_LEFT);
313
    echo "<option value=\"$i\"$sel>$i</option>";
314
}
315
echo "</select>";
316
echo ":<select name=\"stop-sec\">";
317
$sec = date('s');
318
for ($i = 0; $i <= 59; $i++) {
319
    $sel = ($i == $sec) ? ' selected="selected"' : '';
320
    $i = str_pad($i, 2, '0', STR_PAD_LEFT);
321
    echo "<option value=\"$i\"$sel>$i</option>";
322
}
323
echo "</select>";
324
echo "</br></br><button type=\"submit\" class=\"btn btn-primary\" name=\"submit\" value=\"query_range\"> $l_submit</button>";
325
echo "';}";
326
 
327
 
328
 
329
echo "function radio_interact3() {";
330
echo "    document.getElementById(\"query_option\").innerHTML = '";
331
 
332
echo "$l_date1 <select name=\"start-year\">";
333
$year = date('Y');
334
$years = $year-50;
335
for ($i = $year; $i >= $years; $i--) {
336
    $sel = ($i == $year) ? ' selected="selected"' : '';
337
    $i = str_pad($i, 2, '0', STR_PAD_LEFT);
338
    echo "<option value=\"$i\"$sel>$i</option>";
339
}
340
echo "</select>";
341
echo "-<select name=\"start-month\">";
342
$month = date('m');
343
for ($i = 1; $i <= 12; $i++) {
344
    $sel = ($i == $month) ? ' selected="selected"' : '';
345
    $i = str_pad($i, 2, '0', STR_PAD_LEFT);
346
    echo "<option value=\"$i\"$sel>$i</option>";
347
}
348
 
349
echo "</select>";
350
echo "-<select name=\"start-day\">";
351
$day = date('d');
352
for ($i = 1; $i <= 31; $i++) {
353
    $sel = ($i == $day) ? ' selected="selected"' : '';
354
    $i = str_pad($i, 2, '0', STR_PAD_LEFT);
355
    echo "<option value=\"$i\"$sel>$i</option>";
356
}
357
 
358
echo "</select>";
359
echo "$l_hours <select name=\"start-hour\">";
360
$hour = date('G');
361
for ($i = 0; $i <= 23; $i++) {
362
    $sel = ($i == $hour) ? ' selected="selected"' : '';
363
    $i = str_pad($i, 2, '0', STR_PAD_LEFT);
364
    echo "<option value=\"$i\"$sel>$i</option>";
365
}
366
echo "</select>";
367
echo ":<select name=\"start-min\">";
368
$min = date('i');
369
for ($i = 0; $i <= 59; $i++) {
370
    $sel = ($i == $min) ? ' selected="selected"' : '';
371
    $i = str_pad($i, 2, '0', STR_PAD_LEFT);
372
    echo "<option value=\"$i\"$sel>$i</option>";
373
}
374
echo "</select>";
375
echo ":<select name=\"start-sec\">";
376
$sec = date('s');
377
for ($i = 0; $i <= 59; $i++) {
378
    $sel = ($i == $sec) ? ' selected="selected"' : '';
379
    $i = str_pad($i, 2, '0', STR_PAD_LEFT);
380
    echo "<option value=\"$i\"$sel>$i</option>";
381
}
382
echo "</select>";
383
echo "</br></br><button type=\"submit\" class=\"btn btn-primary\" name=\"submit\" value=\"query_simple\"> $l_submit</button>";
384
echo "';}";
385
echo "</script>";
386
 
387
echo "</form>";
388
echo "</div>";
389
echo "</div>";
390
echo "</div>";
391
?>
392
 
393
</body>
394
</html>