Subversion Repositories ALCASAR

Rev

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>
2818 rexy 2
<html>
3
<head>
4
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
5
	<title>ALCASAR Report</title>
6
	<link rel="stylesheet" href="/css/bootstrap.min.css">
7
	<link rel="stylesheet" href="/css/acc.css">
8
	<script src="/js/jquery.min.js"></script>
9
	<script src="/js/bootstrap.min.js"></script>
10
</head>
2010 raphael.pi 11
<body>
12
<?php
2818 rexy 13
# Cette page permet de générer les journaux d'imputabilité dans une archive avec mot de passe.
14
# 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.
2011 raphael.pi 15
 
2010 raphael.pi 16
# Choice of language
17
if(isset($_SERVER['HTTP_ACCEPT_LANGUAGE']))
18
{
19
	$Langue = explode(",",$_SERVER['HTTP_ACCEPT_LANGUAGE']);
20
	$Language = strtolower(substr(chop($Langue[0]),0,2));
21
}
22
if($Language == 'fr')
23
{
2818 rexy 24
	$l_title = "Journaux d'imputabilité";
2010 raphael.pi 25
	$l_info = "Génération des journaux d'imputabilité";
2170 richard 26
	$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 27
	$l_password = "Entrez votre mot de passe afin de protéger l'archive contenant le document généré";
2010 raphael.pi 28
	$l_submit = "Continuer";
29
	$l_date1="Commençant le ...";
30
	$l_date2="Terminant le ...";
2142 richard 31
	$l_hours="à ...";
2010 raphael.pi 32
	$l_options_info = "Que désirez vous?";
33
	$l_options_1="Tous les journaux";
34
	$l_options_2="Selectionnez un intervale ...";
35
	$l_options_3="Selectionnez depuis une date ...";
2853 rexy 36
	$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";
2010 raphael.pi 37
	$l_load="Chargement...";
38
	$l_download="Télécharger l'archive";
39
	$l_error="Vous devez remplir les informations du formulaire!";
40
	$l_demandeur="Nom du demandeur :";
41
	$l_commentary="Raison :";
42
	$l_info_form="Information du demandeur :";
43
	$l_logtab="Dernières entrées :";
44
	$l_empty_log="Les journaux sont vides";
2853 rexy 45
} else if($Language == 'es') {
46
	$l_title = "Registros de responsabilidad";
47
	$l_info = "Generación de registros de Imputabilidades";
48
	$l_log_info = "Está iniciando el proceso para generar un documento reservado para una investigación judicial o administrativa. Todos los usuarios serán advertidos.";
49
	$l_password = "Ingrese una contraseña para proteger el archivo que contiene el documento.";
50
	$l_submit = "Continuar";
51
	$l_date1="Desde el...";
52
	$l_date2="Hasta...";
53
	$l_hours=" a las...";
54
	$l_options_info = "¿Qué desea?";
55
	$l_options_1="Todos los registros";
56
	$l_options_2="Seleccione un rango...";
57
	$l_options_3="Seleccione desde una fecha específica...";
58
	$l_create="¡Los usuarios han sido advertidos y su archivo ha sido creado! ¡No olvide la contraseña!";
59
	$l_load="Cargando...";
60
	$l_download="Descargar archivo";
61
	$l_error="¡¡Es necesario que complete los criterios en el formulario!!";
62
	$l_demandeur="Nombre del solicitante:";
63
	$l_commentary="Motivo:";
64
	$l_info_form="Informacion del usuario";
65
	$l_logtab="Ultimas entradas:";
66
	$l_empty_log="Sin datos en los registros";
67
} else {
2818 rexy 68
	$l_title = "Imputabilities logs";
2010 raphael.pi 69
	$l_info = "Imputabilities logs generation";
2170 richard 70
	$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 71
	$l_password = "Enter your password to protect the archive which contains the document.";
2010 raphael.pi 72
	$l_submit = "Proceed";
73
	$l_date1="Start at ...";
74
	$l_date2="End at ...";
2142 richard 75
	$l_hours="at ...";
2010 raphael.pi 76
	$l_options_info = "What do you want?";
77
	$l_options_1="All logs";
78
	$l_options_2="Select a range ...";
79
	$l_options_3="Select from a specific date ...";
80
	$l_create="Users have been warned and your archive has been created! Don't forget your password!";
81
	$l_load="Loading...";
82
	$l_download="Download archive";
83
	$l_error="You need to submit form informations!!";
84
	$l_demandeur="Applicant name :";
85
	$l_commentary="Reason :";
86
	$l_info_form="User Information";
87
	$l_logtab="Last entries :";
88
	$l_empty_log="Logs are empty";
89
}
90
$filename='/var/www/html/acc/backup/log_info.txt';
91
if(isset($_POST['submit']))
92
{
93
	$password=$_POST['password'];
94
	$demandeur=$_POST['demandeur'];
95
	$raison=$_POST['comment'];
2818 rexy 96
# si le mot de passe est vide ou si il contient des espaces
2010 raphael.pi 97
	if($password != "" && $demandeur != "" && $raison != "")
98
	{
2818 rexy 99
# Génération de log
2182 tom.houday 100
		$text=date("Y-m-d H:i:s")."|||".$demandeur."|||".$raison."|||".$_SERVER['REMOTE_ADDR'];
2818 rexy 101
# supprimer les nouvelles lignes
2010 raphael.pi 102
		$text = str_replace("\n", ' ', $text);
103
		$text = str_replace("\r", ' ', $text);
104
		file_put_contents($filename, $text.PHP_EOL, FILE_APPEND);
2818 rexy 105
# Création des journaux dans une archive avec mot de passe.
2010 raphael.pi 106
		$filename_logs="imputabilities_logs.zip";
107
		switch($_POST['submit'])
108
		{
109
			case 'query_all':
2299 tom.houday 110
				exec("sudo alcasar-generate_log.sh ".escapeshellarg($password));
2010 raphael.pi 111
				break;
112
			case 'query_range':
113
				$date1_selected= $_POST['start-year'].'-'.$_POST['start-month'].'-'.$_POST['start-day'].' '.$_POST['start-hour'].':'.$_POST['start-min'].':'.$_POST['start-sec'];
114
				$date2_selected= $_POST['stop-year'].'-'.$_POST['stop-month'].'-'.$_POST['stop-day'].' '.$_POST['stop-hour'].':'.$_POST['stop-min'].':'.$_POST['stop-sec'];
2299 tom.houday 115
				exec("sudo alcasar-generate_log.sh ".escapeshellarg($password)." ".escapeshellarg($date1_selected)." ".escapeshellarg($date2_selected));
2010 raphael.pi 116
				break;
117
			case 'query_simple':
118
				$date1_selected= $_POST['start-year'].'-'.$_POST['start-month'].'-'.$_POST['start-day'].' '.$_POST['start-hour'].':'.$_POST['start-min'].':'.$_POST['start-sec'];
2299 tom.houday 119
				exec("sudo alcasar-generate_log.sh ".escapeshellarg($password)." ".escapeshellarg($date1_selected));
2010 raphael.pi 120
				break;
121
		}
2818 rexy 122
# Interface permettant de télécharger les journaux d'imputabilité
2010 raphael.pi 123
		echo "<h3>$l_create</h3>";
124
		echo "<a href=\"$filename_logs\" class=\"btn btn-info btn-lg\">";
125
		echo "	<span class=\"glyphicon glyphicon-download-alt\"></span> $l_download";
126
		echo "</a>";
127
	}
128
	else
129
	{
130
		echo "$l_error";	
131
	}
132
}
133
else
134
{
2818 rexy 135
# Interface permettant de configurer la génération des journaux d'imputabilité.
136
	echo "<div class=\"panel\">\n";
137
	echo "<div class=\"panel-header\">$l_title</div>";
138
	echo "<div class=\"panel-row\">";
2527 fabien.rak 139
	echo "	<div style=\"margin-top:16px;margin-left:15px;\">";
2010 raphael.pi 140
	echo "		<div>";
141
	echo "				<fieldset>";
142
	echo "					<h3>$l_info</h3>";
143
	echo "					<p>$l_log_info</p>";
144
	echo "				</fieldset>";
145
	echo "<h4> $l_options_info  </h4>";
146
	echo "<div class=\"radio\">";
2527 fabien.rak 147
	echo "<label><input type=\"radio\" name=\"optradio\" onclick=\"radio_interact1()\"  style=\"margin-top: -1px;\" checked> $l_options_1 </label>";
2010 raphael.pi 148
	echo "</div>";
149
	echo "<div class=\"radio\">";
2527 fabien.rak 150
	echo "<label><input type=\"radio\" name=\"optradio\" onclick=\"radio_interact2()\" style=\"margin-top: -1px;\" > $l_options_2 </label>";
2010 raphael.pi 151
	echo "</div>";
152
	echo "<div class=\"radio\">";
2527 fabien.rak 153
	echo "<label><input type=\"radio\" name=\"optradio\" onclick=\"radio_interact3()\" style=\"margin-top: -1px;\"> $l_options_3 </label>";
2010 raphael.pi 154
	echo "</div>";
155
	echo "<form name=\"form_log\" method=\"post\" action=\"log_generation.php\" role=\"form\">";
156
	echo "<p> $l_password </p><input name=\"password\" type=\"password\" size=\"25\">";
157
	echo "<h2>$l_info_form</h2>";
158
	echo "<p>$l_demandeur</p><textarea name='demandeur' style=\"height:25px;\"></textarea>";
159
	echo "<p>$l_commentary</p><textarea name='comment'></textarea>";
160
	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>";	
161
}
162
echo "<br><div style=\"height:1px;background:#717171;border-bottom:1px solid #313030:\"></div>";
163
echo "<h2>$l_logtab</h2>";
164
if(file_exists($filename)){
165
	echo "<div class=\"container\">";     
166
	echo "<table class=\"table table-striped\">";
167
	echo "<thead>";
168
	echo "<tr>";
169
	echo "<th>Date</th>";
170
	echo "<th>User</th>";
171
	echo "<th>Reason</th>";
172
	echo "<th>IP address</th>";
173
	echo "</tr>";
174
	echo "</thead>";
175
	echo "<tbody>";
2182 tom.houday 176
	$fichier = fopen($filename, "r");
177
	$content = file($filename);
178
	$content = array_reverse($content);
179
	foreach($content as $line){
2010 raphael.pi 180
		$infos=explode("|||", $line);
181
		echo "<tr>";
2182 tom.houday 182
		echo "<td>$infos[0]</td>";
183
		echo "<td>$infos[1]</td>";
184
		echo "<td>$infos[2]</td>";
185
		echo "<td>$infos[3]</td>";
2010 raphael.pi 186
		echo "</tr>";
2182 tom.houday 187
	}
188
	echo "</tbody>";
189
	echo "</table>";
190
	echo "</div>";
2010 raphael.pi 191
}
192
else
193
{
194
	echo "<p>$l_empty_log</p>";
195
}
196
 
197
#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
198
 
199
echo "<script>";
200
 
201
echo "function radio_interact1() {";
202
echo "document.getElementById(\"query_option\").innerHTML = '";
203
echo "</br></br><button type=\"submit\" class=\"btn btn-primary\" name=\"submit\" value=\"query_all\"> $l_submit</button>";
204
echo "';}";
205
 
206
echo "function radio_interact2() {";
207
echo "    document.getElementById(\"query_option\").innerHTML = '";
208
 
209
echo "$l_date1 <select name=\"start-year\">";
210
$year = date('Y');
211
$years = $year-50;
212
for ($i = $year; $i >= $years; $i--) {
213
    $sel = ($i == $year) ? ' selected="selected"' : '';
214
    $i = str_pad($i, 2, '0', STR_PAD_LEFT);
215
    echo "<option value=\"$i\"$sel>$i</option>";
216
}
217
echo "</select>";
218
echo "-<select name=\"start-month\">";
219
$month = date('m');
220
for ($i = 1; $i <= 12; $i++) {
221
    $sel = ($i == $month) ? ' selected="selected"' : '';
222
    $i = str_pad($i, 2, '0', STR_PAD_LEFT);
223
    echo "<option value=\"$i\"$sel>$i</option>";
224
}
225
 
226
echo "</select>";
227
echo "-<select name=\"start-day\">";
228
$day = date('d');
229
for ($i = 1; $i <= 31; $i++) {
230
    $sel = ($i == $day) ? ' selected="selected"' : '';
231
    $i = str_pad($i, 2, '0', STR_PAD_LEFT);
232
    echo "<option value=\"$i\"$sel>$i</option>";
233
}
234
 
235
echo "</select>";
236
echo "$l_hours <select name=\"start-hour\">";
237
$hour = date('G');
238
for ($i = 0; $i <= 23; $i++) {
239
    $sel = ($i == $hour) ? ' selected="selected"' : '';
240
    $i = str_pad($i, 2, '0', STR_PAD_LEFT);
241
    echo "<option value=\"$i\"$sel>$i</option>";
242
}
243
echo "</select>";
244
echo ":<select name=\"start-min\">";
245
$min = date('i');
246
for ($i = 0; $i <= 59; $i++) {
247
    $sel = ($i == $min) ? ' 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-sec\">";
253
$sec = date('s');
254
for ($i = 0; $i <= 59; $i++) {
255
    $sel = ($i == $sec) ? ' 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 "</br>";
261
 
262
echo "$l_date2 <select name=\"stop-year\">";
263
$year = date('Y');
264
$years = $year-50;
265
for ($i = $year; $i >= $years; $i--) {
266
    $sel = ($i == $year) ? ' 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 "-<select name=\"stop-month\">";
272
$month = date('m')+1;
273
for ($i = 1; $i <= 12; $i++) {
274
    $sel = ($i == $month) ? ' selected="selected"' : '';
275
    $i = str_pad($i, 2, '0', STR_PAD_LEFT);
276
    echo "<option value=\"$i\"$sel>$i</option>";
277
}
278
 
279
echo "</select>";
280
echo "-<select name=\"stop-day\">";
281
$day = date('d');
282
for ($i = 1; $i <= 31; $i++) {
283
    $sel = ($i == $day) ? ' selected="selected"' : '';
284
    $i = str_pad($i, 2, '0', STR_PAD_LEFT);
285
    echo "<option value=\"$i\"$sel>$i</option>";
286
}
287
 
288
echo "</select>";
289
echo "$l_hours <select name=\"stop-hour\">";
290
$hour = date('G');
291
for ($i = 0; $i <= 23; $i++) {
292
    $sel = ($i == $hour) ? ' selected="selected"' : '';
293
    $i = str_pad($i, 2, '0', STR_PAD_LEFT);
294
    echo "<option value=\"$i\"$sel>$i</option>";
295
}
296
echo "</select>";
297
echo ":<select name=\"stop-min\">";
298
$min = date('i');
299
for ($i = 0; $i <= 59; $i++) {
300
    $sel = ($i == $min) ? ' 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-sec\">";
306
$sec = date('s');
307
for ($i = 0; $i <= 59; $i++) {
308
    $sel = ($i == $sec) ? ' 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 "</br></br><button type=\"submit\" class=\"btn btn-primary\" name=\"submit\" value=\"query_range\"> $l_submit</button>";
314
echo "';}";
315
 
316
 
317
 
318
echo "function radio_interact3() {";
319
echo "    document.getElementById(\"query_option\").innerHTML = '";
320
 
321
echo "$l_date1 <select name=\"start-year\">";
322
$year = date('Y');
323
$years = $year-50;
324
for ($i = $year; $i >= $years; $i--) {
325
    $sel = ($i == $year) ? ' selected="selected"' : '';
326
    $i = str_pad($i, 2, '0', STR_PAD_LEFT);
327
    echo "<option value=\"$i\"$sel>$i</option>";
328
}
329
echo "</select>";
330
echo "-<select name=\"start-month\">";
331
$month = date('m');
332
for ($i = 1; $i <= 12; $i++) {
333
    $sel = ($i == $month) ? ' selected="selected"' : '';
334
    $i = str_pad($i, 2, '0', STR_PAD_LEFT);
335
    echo "<option value=\"$i\"$sel>$i</option>";
336
}
337
 
338
echo "</select>";
339
echo "-<select name=\"start-day\">";
340
$day = date('d');
341
for ($i = 1; $i <= 31; $i++) {
342
    $sel = ($i == $day) ? ' selected="selected"' : '';
343
    $i = str_pad($i, 2, '0', STR_PAD_LEFT);
344
    echo "<option value=\"$i\"$sel>$i</option>";
345
}
346
 
347
echo "</select>";
348
echo "$l_hours <select name=\"start-hour\">";
349
$hour = date('G');
350
for ($i = 0; $i <= 23; $i++) {
351
    $sel = ($i == $hour) ? ' selected="selected"' : '';
352
    $i = str_pad($i, 2, '0', STR_PAD_LEFT);
353
    echo "<option value=\"$i\"$sel>$i</option>";
354
}
355
echo "</select>";
356
echo ":<select name=\"start-min\">";
357
$min = date('i');
358
for ($i = 0; $i <= 59; $i++) {
359
    $sel = ($i == $min) ? ' 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-sec\">";
365
$sec = date('s');
366
for ($i = 0; $i <= 59; $i++) {
367
    $sel = ($i == $sec) ? ' 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 "</br></br><button type=\"submit\" class=\"btn btn-primary\" name=\"submit\" value=\"query_simple\"> $l_submit</button>";
373
echo "';}";
374
echo "</script>";
375
 
376
echo "</form>";
377
echo "</div>";
378
echo "</div>";
379
echo "</div>";
380
?>
2818 rexy 381
</div>
2010 raphael.pi 382
</body>
383
</html>