Subversion Repositories ALCASAR

Rev

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