Subversion Repositories ALCASAR

Rev

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

Rev Author Line No. Line
2182 tom.houday 1
<?php
2315 tom.houday 2
# $Id: menu.php 2993 2022-03-06 23:02:08Z rexy $
2817 rexy 3
// written by Rexy & Tom HOUDAYER
2182 tom.houday 4
 
2315 tom.houday 5
/****************************************************************
6
*			GLOBAL FILE PATHS			*
7
*****************************************************************/
8
define('CONF_FILE', '/usr/local/etc/alcasar.conf');
9
define('ACC_ACCESS_LOG', '/var/Save/security/acc_access.log');
10
 
11
/****************************************************************
12
*			FILE reading test			*
13
*****************************************************************/
14
$conf_files = array(CONF_FILE, ACC_ACCESS_LOG);
15
foreach ($conf_files as $file) {
16
	if (!file_exists($file)) {
17
		exit("Requested file $file isn't present");
18
	}
19
	if (!is_readable($file)) {
20
		exit("Can't read the file $file");
21
	}
2267 richard 22
}
2315 tom.houday 23
 
24
/****************************************************************
25
*			Read CONF_FILE				*
26
*****************************************************************/
27
$file_conf = fopen(CONF_FILE, 'r');
28
if (!$file_conf) {
29
	exit('Error opening the file '.CONF_FILE);
30
}
2182 tom.houday 31
while (!feof($file_conf)) {
2315 tom.houday 32
	$buffer = fgets($file_conf, 4096);
33
	if ((strpos($buffer, '=') !== false) && (substr($buffer, 0, 1) !== '#')) {
2450 tom.houday 34
		$tmp = explode('=', $buffer, 2);
2315 tom.houday 35
		$conf[trim($tmp[0])] = trim($tmp[1]);
2182 tom.houday 36
	}
37
}
38
fclose($file_conf);
1911 raphael.pi 39
 
2315 tom.houday 40
// Retrieve the user's profil
2528 fabien.rak 41
$user_htdigest = $_SERVER['REMOTE_USER'];
2315 tom.houday 42
exec('sudo alcasar-profil.sh --list | cut -d":" -f2', $output);
43
$admin_members   = explode(' ', ltrim($output[0], " \t"));
44
$backup_members  = explode(' ', ltrim($output[1], " \t"));
45
$manager_members = explode(' ', ltrim($output[2], " \t"));
46
 
47
if (in_array($user_htdigest, $admin_members)) {
48
	$right = 0; // admin
49
} else if (in_array($user_htdigest, $backup_members)) {
50
	$right = 1; // backup
51
} else if (in_array($user_htdigest, $manager_members)) {
52
	$right = 2; // manager
53
} else {
54
	exit();     // Unknown account
1911 raphael.pi 55
}
56
 
2182 tom.houday 57
$installed_version = $conf['VERSION'];
1911 raphael.pi 58
 
2315 tom.houday 59
// Choice of language
60
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
61
	$Langue = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
62
	$Language = strtolower(substr(chop($Langue[0]), 0, 2));
374 richard 63
}
2315 tom.houday 64
if ($Language === 'fr') {	// French
65
	$l_home			= "ACCUEIL";
66
	$l_system		= "SYSTÈME";
67
	$l_auth			= "AUTHENTIFICATION";
68
	$l_filter		= "FILTRAGE";
69
	$l_statistics		= "STATISTIQUES";
70
	$l_backup		= "SAUVEGARDES";
71
	$l_activity		= "Activité";
72
	$l_blacklist		= "Liste noire";
73
	$l_whitelist		= "Liste blanche";
74
	$l_network		= "Réseau";
75
	$l_ldap			= "LDAP/A.D.";
76
	$l_access_nb		= "Nb d'accès à l'ACC";
77
	$l_create_user		= "Créer des utilisateurs";
78
	$l_edit_user		= "Gérer les utilisateurs";
79
	$l_create_group		= "Créer un groupe";
2338 tom.houday 80
	$l_edit_group		= "Gérer les groupes";
2315 tom.houday 81
	$l_import_empty		= "Importer / Vider";
82
	$l_protocols		= "Protocoles";
83
	$l_stat_user_day	= "Par connexion";
84
	$l_stat_con		= "Journal global";
2858 rexy 85
	$l_stat_daily		= "Usage quotidien";
2315 tom.houday 86
	$l_stat_global_network	= "Trafic global";
87
	$l_stat_detail_network	= "Trafic détaillé";
88
	$l_security		= "Sécurité";
89
	$l_menu			= "Menu";
2992 rexy 90
	$l_sms			= "Inscription par SMS";
91
	$l_mail			= "Inscription par E-mail";
2315 tom.houday 92
	$l_backup_archive	= "Archives";
2852 rexy 93
	$l_accountability_logs		= "Journaux d'imputabilité";
2315 tom.houday 94
	$l_since		= "depuis le :";
2852 rexy 95
	$l_doc_language = "fr";
96
} else if ($Language === 'es') {	// Spanish
97
	$l_home			= "INICIO";
98
	$l_system		= "SISTEMA";
99
	$l_auth			= "GESTIONAR";
100
	$l_filter		= "FILTRADO";
101
	$l_statistics		= "ESTADISTICAS";
102
	$l_backup		= "BACKUPS";
103
	$l_activity		= "Actividad";
104
	$l_blacklist		= "Lista Negra";
105
	$l_whitelist		= "Lista Blanca";
106
	$l_network		= "Red";
107
	$l_ldap			= "LDAP/A.D.";
108
	$l_access_nb		= "Registros de accesos ACC";
109
	$l_create_user		= "Crear usuarios";
110
	$l_edit_user		= "Administrar usuarios";
111
	$l_create_group		= "Crear un grupo";
112
	$l_edit_group		= "Administrar grupos";
113
	$l_import_empty		= "Importar / Purgar";
114
	$l_protocols		= "Protocolos";
115
	$l_stat_user_day	= "Por conexión";
116
	$l_stat_con		= "Registros globales";
117
	$l_stat_daily		= "Uso diario";
118
	$l_stat_global_network	= "Tráfico global";
119
	$l_stat_detail_network	= "Tráfico detallado";
120
	$l_security		= "Seguridad";
121
	$l_menu			= "Principal";
2992 rexy 122
	$l_sms			= "Registro por sms";
123
	$l_mail			= "Registro por E-mail";
2852 rexy 124
	$l_backup_archive	= "Archivos";
125
	$l_accountability_logs		= "registros de responsabilidad";
126
	$l_since		= "desde: ";
127
	$l_doc_language = "en";
2315 tom.houday 128
} else {			// English
129
	$Language		= 'en';
130
	$l_home			= "HOME";
131
	$l_system		= "SYSTEM";
132
	$l_auth			= "AUTHENTICATION";
133
	$l_filter		= "FILTERING";
134
	$l_statistics		= "STATISTICS";
135
	$l_backup		= "BACKUPS";
136
	$l_activity		= "Activity";
137
	$l_blacklist		= "Blacklist";
138
	$l_whitelist		= "Whitelist";
139
	$l_network		= "Network";
140
	$l_ldap			= "LDAP/A.D.";
141
	$l_access_nb		= "ACC access Nbr";
142
	$l_create_user		= "Create users";
143
	$l_edit_user		= "Manage users";
144
	$l_create_group		= "Create a group";
145
	$l_edit_group		= "Manage groups";
146
	$l_import_empty		= "Import / Empty";
147
	$l_protocols		= "Protocols";
2527 fabien.rak 148
	$l_stat_user_day	= "By connection";
2315 tom.houday 149
	$l_stat_con		= "Global accounting";
2527 fabien.rak 150
	$l_stat_daily		= "Daily use";
151
	$l_stat_global_network	= "Global traffic";
152
	$l_stat_detail_network	= "Detailed traffic";
153
	$l_security		= "Security";
2315 tom.houday 154
	$l_menu			= "Main";
2992 rexy 155
	$l_sms			= "SMS registration";
156
	$l_mail			= "E-mail registration";
2315 tom.houday 157
	$l_backup_archive	= "Archives";
2852 rexy 158
	$l_accountability_logs		= "accountability logs";
2315 tom.houday 159
	$l_since		= "since:";
2852 rexy 160
	$l_doc_language = "en";
374 richard 161
}
1911 raphael.pi 162
 
2315 tom.houday 163
// Get access log count
164
$tab = file(ACC_ACCESS_LOG);
165
$accAccessCounter = count($tab);
166
$field = explode('|', $tab[0]);
167
$accAccessFirstDate = explode(' ', $field[0])[0];
374 richard 168
?>
2315 tom.houday 169
<!DOCTYPE html>
170
<html>
171
<head>
172
	<meta charset="utf-8">
173
	<title>Menu - ALCASAR</title>
2817 rexy 174
	<link rel="stylesheet" type="text/css" href="/css/acc.css">
2809 rexy 175
	<link rel="stylesheet" type="text/css" href="/css/menu.css">
2315 tom.houday 176
	<script src="/js/jquery.min.js"></script>
177
	<script>
178
		$(document).ready(function () {
179
			$('.menu a[href="#"]').click(function (event) {
180
				event.preventDefault();
181
				if ($(this).parent().hasClass('active')) {
182
					$(this).parent().removeClass('active');
183
				} else {
184
					$('.menu li.active').removeClass('active');
185
					$(this).parent().addClass('active');
186
				}
187
			});
188
		});
189
	</script>
190
</head>
191
<body>
192
	<div class="panel">
193
		<div class="panel-header">
194
			<?= $l_menu ?>
195
		</div>
2813 rexy 196
		<div class="panel-row">
2315 tom.houday 197
			<div class="menu">
198
				<ul>
2815 rexy 199
					<li><div class="caret"></div><a href="welcome.php" target="REXY2"><?= $l_home ?></a></li>
2315 tom.houday 200
					<?php if ($right === 0):			// admin ?>
201
						<li>
202
							<div class="caret"></div><a href="#"><?= $l_system ?></a>
203
							<ul>
204
								<li><div class="caret"></div><a href="admin/network.php" target="REXY2"><?= $l_network ?></a></li>
205
								<li><div class="caret"></div><a href="admin/services.php" target="REXY2">Services</a></li>
206
								<li><div class="caret"></div><a href="admin/ldap.php" target="REXY2"><?= $l_ldap ?></a></li>
207
							</ul>
208
						</li>
209
					<?php endif; ?>
210
					<?php if ($right === 0 || $right === 2):	// admin, manager ?>
211
						<li>
212
							<div class="caret"></div><a href="#"><?= $l_auth ?></a>
213
							<ul>
214
								<li><div class="caret"></div><a href="manager/htdocs/activity.php" target="REXY2"><?= $l_activity ?></a></li>
215
								<li><div class="caret"></div><a href="manager/htdocs/user_new.php" target="REXY2"><?= $l_create_user ?></a></li>
216
								<li><div class="caret"></div><a href="manager/htdocs/find.php" target="REXY2"><?= $l_edit_user ?></a></li>
217
								<li><div class="caret"></div><a href="manager/htdocs/group_new.php" target="REXY2"><?= $l_create_group ?></a></li>
218
								<li><div class="caret"></div><a href="manager/htdocs/show_groups.php" target="REXY2"><?= $l_edit_group ?></a></li>
219
								<li><div class="caret"></div><a href="manager/htdocs/import_user.php" target="REXY2"><?= $l_import_empty ?></a></li>
220
								<li><div class="caret"></div><a href="manager/auth_exceptions.php" target="REXY2">Exceptions</a></li>
2991 rexy 221
								<li><div class="caret"></div><a href="manager/htdocs/user_by_sms.php" target="REXY2"><?= $l_sms ?></a></li>
222
								<li><div class="caret"></div><a href="manager/htdocs/user_by_email.php" target="REXY2"><?= $l_mail ?></a></li>
2315 tom.houday 223
							</ul>
224
						</li>
225
					<?php endif; ?>
226
					<?php if ($right === 0):			// admin ?>
227
						<li>
228
							<div class="caret"></div><a href="#"><?= $l_filter ?></a>
229
							<ul>
230
								<li><div class="caret"></div><a href="admin/bl_filter.php" target="REXY2"><?= $l_blacklist ?></a></li>
231
								<li><div class="caret"></div><a href="admin/wl_filter.php" target="REXY2"><?= $l_whitelist ?></a></li>
232
								<li><div class="caret"></div><a href="admin/protocols_filter.php" target="REXY2"><?= $l_protocols ?></a></li>
233
							</ul>
234
						</li>
235
					<?php endif; ?>
236
					<?php if ($right === 0):			// admin ?>
237
						<li>
238
							<div class="caret"></div><a href="#"><?= $l_statistics ?></a>
239
							<ul>
240
								<li><div class="caret"></div><a href="manager/htdocs/user_stats.php" target="REXY2"><?= $l_stat_user_day ?></a></li>
241
								<li><div class="caret"></div><a href="manager/htdocs/accounting.php" target="REXY2"><?= $l_stat_con ?></a></li>
242
								<li><div class="caret"></div><a href="manager/htdocs/stats.php" target="REXY2"><?= $l_stat_daily ?></a></li>
2809 rexy 243
								<li><div class="caret"></div><a href="manager/vnstat.php" target="REXY2"><?= $l_stat_global_network ?></a></li>
2825 rexy 244
								<!--<li><div class="caret"></div><a href="manager/nfsen.php" target="REXY2"><?= $l_stat_detail_network ?></a></li> -->
2315 tom.houday 245
								<li><div class="caret"></div><a href="manager/htdocs/security.php" target="REXY2"><?= $l_security ?></a></li>
246
							</ul>
247
						</li>
248
					<?php endif; ?>
249
					<?php if ($right === 0 || $right === 1):	// admin, backup ?>
250
						<li>
251
							<div class="caret"></div><a href="#"><?= $l_backup ?></a>
252
							<ul>
253
								<li><div class="caret"></div><a href="backup/sauvegarde.php" target="REXY2"><?= $l_backup_archive ?></a></li>
2852 rexy 254
								<li><div class="caret"></div><a href="backup/log_generation.php" target="REXY2"><?= $l_accountability_logs ?></a></li>
2315 tom.houday 255
							</ul>
256
						</li>
257
					<?php endif; ?>
258
				</ul>
259
			</div>
260
		</div>
261
	</div>
262
	<br>
263
	<div class="panel">
264
		<div class="panel-header">
265
			Documents
266
		</div>
2813 rexy 267
		<div class="panel-row">
2315 tom.houday 268
			<div class="menu">
269
				<ul>
2852 rexy 270
					<li><div class="caret"></div><a href="<?= "alcasar-$installed_version-presentation-$l_doc_language.pdf" ?>" target="_blank">Presentation</a></li>
271
					<li><div class="caret"></div><a href="<?= "alcasar-$installed_version-installation-$l_doc_language.pdf" ?>" target="_blank">Installation</a></li>
272
					<li><div class="caret"></div><a href="<?= "alcasar-$installed_version-exploitation-$l_doc_language.pdf" ?>" target="_blank">Exploitation</a></li>
2315 tom.houday 273
					<li><div class="caret"></div><a href="<?= "alcasar-$installed_version-technique.pdf" ?>" target="_blank">Technique</a></li>
274
				</ul>
275
			</div>
276
		</div>
277
	</div>
278
	<br>
279
	<div class="panel">
280
		<div class="panel-header">
281
			<?= $l_access_nb ?>
282
		</div>
2813 rexy 283
		<div class="panel-row" style="text-align: center;">
2315 tom.houday 284
			<a href="admin_log.php" target="REXY2"><?= $accAccessCounter ?></a><br>
285
			<?= $l_since ?> <?= $accAccessFirstDate ?>
286
		</div>
287
	</div>
288
</body>
289
</html>