Subversion Repositories ALCASAR

Rev

Rev 2527 | Rev 2853 | 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 ...";
36
	$l_load="Chargement...";
37
	$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";
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";
45
 
46
}
47
else
48
{
2818 rexy 49
	$l_title = "Imputabilities logs";
2010 raphael.pi 50
	$l_info = "Imputabilities logs generation";
2170 richard 51
	$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 52
	$l_password = "Enter your password to protect the archive which contains the document.";
2010 raphael.pi 53
	$l_submit = "Proceed";
54
	$l_date1="Start at ...";
55
	$l_date2="End at ...";
2142 richard 56
	$l_hours="at ...";
2010 raphael.pi 57
	$l_options_info = "What do you want?";
58
	$l_options_1="All logs";
59
	$l_options_2="Select a range ...";
60
	$l_options_3="Select from a specific date ...";
61
	$l_create="Users have been warned and your archive has been created! Don't forget your password!";
62
	$l_load="Loading...";
63
	$l_download="Download archive";
64
	$l_error="You need to submit form informations!!";
65
	$l_demandeur="Applicant name :";
66
	$l_commentary="Reason :";
67
	$l_info_form="User Information";
68
	$l_logtab="Last entries :";
69
	$l_empty_log="Logs are empty";
70
}
71
$filename='/var/www/html/acc/backup/log_info.txt';
72
if(isset($_POST['submit']))
73
{
74
	$password=$_POST['password'];
75
	$demandeur=$_POST['demandeur'];
76
	$raison=$_POST['comment'];
2818 rexy 77
# si le mot de passe est vide ou si il contient des espaces
2010 raphael.pi 78
	if($password != "" && $demandeur != "" && $raison != "")
79
	{
2818 rexy 80
# Génération de log
2182 tom.houday 81
		$text=date("Y-m-d H:i:s")."|||".$demandeur."|||".$raison."|||".$_SERVER['REMOTE_ADDR'];
2818 rexy 82
# supprimer les nouvelles lignes
2010 raphael.pi 83
		$text = str_replace("\n", ' ', $text);
84
		$text = str_replace("\r", ' ', $text);
85
		file_put_contents($filename, $text.PHP_EOL, FILE_APPEND);
2818 rexy 86
# Création des journaux dans une archive avec mot de passe.
2010 raphael.pi 87
		$filename_logs="imputabilities_logs.zip";
88
		switch($_POST['submit'])
89
		{
90
			case 'query_all':
2299 tom.houday 91
				exec("sudo alcasar-generate_log.sh ".escapeshellarg($password));
2010 raphael.pi 92
				break;
93
			case 'query_range':
94
				$date1_selected= $_POST['start-year'].'-'.$_POST['start-month'].'-'.$_POST['start-day'].' '.$_POST['start-hour'].':'.$_POST['start-min'].':'.$_POST['start-sec'];
95
				$date2_selected= $_POST['stop-year'].'-'.$_POST['stop-month'].'-'.$_POST['stop-day'].' '.$_POST['stop-hour'].':'.$_POST['stop-min'].':'.$_POST['stop-sec'];
2299 tom.houday 96
				exec("sudo alcasar-generate_log.sh ".escapeshellarg($password)." ".escapeshellarg($date1_selected)." ".escapeshellarg($date2_selected));
2010 raphael.pi 97
				break;
98
			case 'query_simple':
99
				$date1_selected= $_POST['start-year'].'-'.$_POST['start-month'].'-'.$_POST['start-day'].' '.$_POST['start-hour'].':'.$_POST['start-min'].':'.$_POST['start-sec'];
2299 tom.houday 100
				exec("sudo alcasar-generate_log.sh ".escapeshellarg($password)." ".escapeshellarg($date1_selected));
2010 raphael.pi 101
				break;
102
		}
2818 rexy 103
# Interface permettant de télécharger les journaux d'imputabilité
2010 raphael.pi 104
		echo "<h3>$l_create</h3>";
105
		echo "<a href=\"$filename_logs\" class=\"btn btn-info btn-lg\">";
106
		echo "	<span class=\"glyphicon glyphicon-download-alt\"></span> $l_download";
107
		echo "</a>";
108
	}
109
	else
110
	{
111
		echo "$l_error";	
112
	}
113
}
114
else
115
{
2818 rexy 116
# Interface permettant de configurer la génération des journaux d'imputabilité.
117
	echo "<div class=\"panel\">\n";
118
	echo "<div class=\"panel-header\">$l_title</div>";
119
	echo "<div class=\"panel-row\">";
2527 fabien.rak 120
	echo "	<div style=\"margin-top:16px;margin-left:15px;\">";
2010 raphael.pi 121
	echo "		<div>";
122
	echo "				<fieldset>";
123
	echo "					<h3>$l_info</h3>";
124
	echo "					<p>$l_log_info</p>";
125
	echo "				</fieldset>";
126
	echo "<h4> $l_options_info  </h4>";
127
	echo "<div class=\"radio\">";
2527 fabien.rak 128
	echo "<label><input type=\"radio\" name=\"optradio\" onclick=\"radio_interact1()\"  style=\"margin-top: -1px;\" checked> $l_options_1 </label>";
2010 raphael.pi 129
	echo "</div>";
130
	echo "<div class=\"radio\">";
2527 fabien.rak 131
	echo "<label><input type=\"radio\" name=\"optradio\" onclick=\"radio_interact2()\" style=\"margin-top: -1px;\" > $l_options_2 </label>";
2010 raphael.pi 132
	echo "</div>";
133
	echo "<div class=\"radio\">";
2527 fabien.rak 134
	echo "<label><input type=\"radio\" name=\"optradio\" onclick=\"radio_interact3()\" style=\"margin-top: -1px;\"> $l_options_3 </label>";
2010 raphael.pi 135
	echo "</div>";
136
	echo "<form name=\"form_log\" method=\"post\" action=\"log_generation.php\" role=\"form\">";
137
	echo "<p> $l_password </p><input name=\"password\" type=\"password\" size=\"25\">";
138
	echo "<h2>$l_info_form</h2>";
139
	echo "<p>$l_demandeur</p><textarea name='demandeur' style=\"height:25px;\"></textarea>";
140
	echo "<p>$l_commentary</p><textarea name='comment'></textarea>";
141
	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>";	
142
}
143
echo "<br><div style=\"height:1px;background:#717171;border-bottom:1px solid #313030:\"></div>";
144
echo "<h2>$l_logtab</h2>";
145
if(file_exists($filename)){
146
	echo "<div class=\"container\">";     
147
	echo "<table class=\"table table-striped\">";
148
	echo "<thead>";
149
	echo "<tr>";
150
	echo "<th>Date</th>";
151
	echo "<th>User</th>";
152
	echo "<th>Reason</th>";
153
	echo "<th>IP address</th>";
154
	echo "</tr>";
155
	echo "</thead>";
156
	echo "<tbody>";
2182 tom.houday 157
	$fichier = fopen($filename, "r");
158
	$content = file($filename);
159
	$content = array_reverse($content);
160
	foreach($content as $line){
2010 raphael.pi 161
		$infos=explode("|||", $line);
162
		echo "<tr>";
2182 tom.houday 163
		echo "<td>$infos[0]</td>";
164
		echo "<td>$infos[1]</td>";
165
		echo "<td>$infos[2]</td>";
166
		echo "<td>$infos[3]</td>";
2010 raphael.pi 167
		echo "</tr>";
2182 tom.houday 168
	}
169
	echo "</tbody>";
170
	echo "</table>";
171
	echo "</div>";
2010 raphael.pi 172
}
173
else
174
{
175
	echo "<p>$l_empty_log</p>";
176
}
177
 
178
#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
179
 
180
echo "<script>";
181
 
182
echo "function radio_interact1() {";
183
echo "document.getElementById(\"query_option\").innerHTML = '";
184
echo "</br></br><button type=\"submit\" class=\"btn btn-primary\" name=\"submit\" value=\"query_all\"> $l_submit</button>";
185
echo "';}";
186
 
187
echo "function radio_interact2() {";
188
echo "    document.getElementById(\"query_option\").innerHTML = '";
189
 
190
echo "$l_date1 <select name=\"start-year\">";
191
$year = date('Y');
192
$years = $year-50;
193
for ($i = $year; $i >= $years; $i--) {
194
    $sel = ($i == $year) ? ' selected="selected"' : '';
195
    $i = str_pad($i, 2, '0', STR_PAD_LEFT);
196
    echo "<option value=\"$i\"$sel>$i</option>";
197
}
198
echo "</select>";
199
echo "-<select name=\"start-month\">";
200
$month = date('m');
201
for ($i = 1; $i <= 12; $i++) {
202
    $sel = ($i == $month) ? ' selected="selected"' : '';
203
    $i = str_pad($i, 2, '0', STR_PAD_LEFT);
204
    echo "<option value=\"$i\"$sel>$i</option>";
205
}
206
 
207
echo "</select>";
208
echo "-<select name=\"start-day\">";
209
$day = date('d');
210
for ($i = 1; $i <= 31; $i++) {
211
    $sel = ($i == $day) ? ' selected="selected"' : '';
212
    $i = str_pad($i, 2, '0', STR_PAD_LEFT);
213
    echo "<option value=\"$i\"$sel>$i</option>";
214
}
215
 
216
echo "</select>";
217
echo "$l_hours <select name=\"start-hour\">";
218
$hour = date('G');
219
for ($i = 0; $i <= 23; $i++) {
220
    $sel = ($i == $hour) ? ' selected="selected"' : '';
221
    $i = str_pad($i, 2, '0', STR_PAD_LEFT);
222
    echo "<option value=\"$i\"$sel>$i</option>";
223
}
224
echo "</select>";
225
echo ":<select name=\"start-min\">";
226
$min = date('i');
227
for ($i = 0; $i <= 59; $i++) {
228
    $sel = ($i == $min) ? ' selected="selected"' : '';
229
    $i = str_pad($i, 2, '0', STR_PAD_LEFT);
230
    echo "<option value=\"$i\"$sel>$i</option>";
231
}
232
echo "</select>";
233
echo ":<select name=\"start-sec\">";
234
$sec = date('s');
235
for ($i = 0; $i <= 59; $i++) {
236
    $sel = ($i == $sec) ? ' selected="selected"' : '';
237
    $i = str_pad($i, 2, '0', STR_PAD_LEFT);
238
    echo "<option value=\"$i\"$sel>$i</option>";
239
}
240
echo "</select>";
241
echo "</br>";
242
 
243
echo "$l_date2 <select name=\"stop-year\">";
244
$year = date('Y');
245
$years = $year-50;
246
for ($i = $year; $i >= $years; $i--) {
247
    $sel = ($i == $year) ? ' 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=\"stop-month\">";
253
$month = date('m')+1;
254
for ($i = 1; $i <= 12; $i++) {
255
    $sel = ($i == $month) ? ' selected="selected"' : '';
256
    $i = str_pad($i, 2, '0', STR_PAD_LEFT);
257
    echo "<option value=\"$i\"$sel>$i</option>";
258
}
259
 
260
echo "</select>";
261
echo "-<select name=\"stop-day\">";
262
$day = date('d');
263
for ($i = 1; $i <= 31; $i++) {
264
    $sel = ($i == $day) ? ' selected="selected"' : '';
265
    $i = str_pad($i, 2, '0', STR_PAD_LEFT);
266
    echo "<option value=\"$i\"$sel>$i</option>";
267
}
268
 
269
echo "</select>";
270
echo "$l_hours <select name=\"stop-hour\">";
271
$hour = date('G');
272
for ($i = 0; $i <= 23; $i++) {
273
    $sel = ($i == $hour) ? ' selected="selected"' : '';
274
    $i = str_pad($i, 2, '0', STR_PAD_LEFT);
275
    echo "<option value=\"$i\"$sel>$i</option>";
276
}
277
echo "</select>";
278
echo ":<select name=\"stop-min\">";
279
$min = date('i');
280
for ($i = 0; $i <= 59; $i++) {
281
    $sel = ($i == $min) ? ' selected="selected"' : '';
282
    $i = str_pad($i, 2, '0', STR_PAD_LEFT);
283
    echo "<option value=\"$i\"$sel>$i</option>";
284
}
285
echo "</select>";
286
echo ":<select name=\"stop-sec\">";
287
$sec = date('s');
288
for ($i = 0; $i <= 59; $i++) {
289
    $sel = ($i == $sec) ? ' selected="selected"' : '';
290
    $i = str_pad($i, 2, '0', STR_PAD_LEFT);
291
    echo "<option value=\"$i\"$sel>$i</option>";
292
}
293
echo "</select>";
294
echo "</br></br><button type=\"submit\" class=\"btn btn-primary\" name=\"submit\" value=\"query_range\"> $l_submit</button>";
295
echo "';}";
296
 
297
 
298
 
299
echo "function radio_interact3() {";
300
echo "    document.getElementById(\"query_option\").innerHTML = '";
301
 
302
echo "$l_date1 <select name=\"start-year\">";
303
$year = date('Y');
304
$years = $year-50;
305
for ($i = $year; $i >= $years; $i--) {
306
    $sel = ($i == $year) ? ' selected="selected"' : '';
307
    $i = str_pad($i, 2, '0', STR_PAD_LEFT);
308
    echo "<option value=\"$i\"$sel>$i</option>";
309
}
310
echo "</select>";
311
echo "-<select name=\"start-month\">";
312
$month = date('m');
313
for ($i = 1; $i <= 12; $i++) {
314
    $sel = ($i == $month) ? ' selected="selected"' : '';
315
    $i = str_pad($i, 2, '0', STR_PAD_LEFT);
316
    echo "<option value=\"$i\"$sel>$i</option>";
317
}
318
 
319
echo "</select>";
320
echo "-<select name=\"start-day\">";
321
$day = date('d');
322
for ($i = 1; $i <= 31; $i++) {
323
    $sel = ($i == $day) ? ' selected="selected"' : '';
324
    $i = str_pad($i, 2, '0', STR_PAD_LEFT);
325
    echo "<option value=\"$i\"$sel>$i</option>";
326
}
327
 
328
echo "</select>";
329
echo "$l_hours <select name=\"start-hour\">";
330
$hour = date('G');
331
for ($i = 0; $i <= 23; $i++) {
332
    $sel = ($i == $hour) ? ' selected="selected"' : '';
333
    $i = str_pad($i, 2, '0', STR_PAD_LEFT);
334
    echo "<option value=\"$i\"$sel>$i</option>";
335
}
336
echo "</select>";
337
echo ":<select name=\"start-min\">";
338
$min = date('i');
339
for ($i = 0; $i <= 59; $i++) {
340
    $sel = ($i == $min) ? ' selected="selected"' : '';
341
    $i = str_pad($i, 2, '0', STR_PAD_LEFT);
342
    echo "<option value=\"$i\"$sel>$i</option>";
343
}
344
echo "</select>";
345
echo ":<select name=\"start-sec\">";
346
$sec = date('s');
347
for ($i = 0; $i <= 59; $i++) {
348
    $sel = ($i == $sec) ? ' selected="selected"' : '';
349
    $i = str_pad($i, 2, '0', STR_PAD_LEFT);
350
    echo "<option value=\"$i\"$sel>$i</option>";
351
}
352
echo "</select>";
353
echo "</br></br><button type=\"submit\" class=\"btn btn-primary\" name=\"submit\" value=\"query_simple\"> $l_submit</button>";
354
echo "';}";
355
echo "</script>";
356
 
357
echo "</form>";
358
echo "</div>";
359
echo "</div>";
360
echo "</div>";
361
?>
2818 rexy 362
</div>
2010 raphael.pi 363
</body>
364
</html>