Subversion Repositories ALCASAR

Rev

Rev 2825 | Rev 2858 | 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 2852 2020-07-18 10:08:26Z 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";
85
	$l_stat_daily		= "Usage journalier";
86
	$l_stat_global_network	= "Trafic global";
87
	$l_stat_detail_network	= "Trafic détaillé";
88
	$l_security		= "Sécurité";
89
	$l_menu			= "Menu";
90
	$l_gammu		= "Auto enregistrement (SMS)";
91
	$l_backup_archive	= "Archives";
2852 rexy 92
	$l_accountability_logs		= "Journaux d'imputabilité";
2315 tom.houday 93
	$l_since		= "depuis le :";
2852 rexy 94
	$l_doc_language = "fr";
95
} else if ($Language === 'es') {	// Spanish
96
	$l_home			= "INICIO";
97
	$l_system		= "SISTEMA";
98
	$l_auth			= "GESTIONAR";
99
	$l_filter		= "FILTRADO";
100
	$l_statistics		= "ESTADISTICAS";
101
	$l_backup		= "BACKUPS";
102
	$l_activity		= "Actividad";
103
	$l_blacklist		= "Lista Negra";
104
	$l_whitelist		= "Lista Blanca";
105
	$l_network		= "Red";
106
	$l_ldap			= "LDAP/A.D.";
107
	$l_access_nb		= "Registros de accesos ACC";
108
	$l_create_user		= "Crear usuarios";
109
	$l_edit_user		= "Administrar usuarios";
110
	$l_create_group		= "Crear un grupo";
111
	$l_edit_group		= "Administrar grupos";
112
	$l_import_empty		= "Importar / Purgar";
113
	$l_protocols		= "Protocolos";
114
	$l_stat_user_day	= "Por conexión";
115
	$l_stat_con		= "Registros globales";
116
	$l_stat_daily		= "Uso diario";
117
	$l_stat_global_network	= "Tráfico global";
118
	$l_stat_detail_network	= "Tráfico detallado";
119
	$l_security		= "Seguridad";
120
	$l_menu			= "Principal";
121
	$l_gammu		= "Auto-registro (SMS)";
122
	$l_backup_archive	= "Archivos";
123
	$l_accountability_logs		= "registros de responsabilidad";
124
	$l_since		= "desde: ";
125
	$l_doc_language = "en";
2315 tom.houday 126
} else {			// English
127
	$Language		= 'en';
128
	$l_home			= "HOME";
129
	$l_system		= "SYSTEM";
130
	$l_auth			= "AUTHENTICATION";
131
	$l_filter		= "FILTERING";
132
	$l_statistics		= "STATISTICS";
133
	$l_backup		= "BACKUPS";
134
	$l_activity		= "Activity";
135
	$l_blacklist		= "Blacklist";
136
	$l_whitelist		= "Whitelist";
137
	$l_network		= "Network";
138
	$l_ldap			= "LDAP/A.D.";
139
	$l_access_nb		= "ACC access Nbr";
140
	$l_create_user		= "Create users";
141
	$l_edit_user		= "Manage users";
142
	$l_create_group		= "Create a group";
143
	$l_edit_group		= "Manage groups";
144
	$l_import_empty		= "Import / Empty";
145
	$l_protocols		= "Protocols";
2527 fabien.rak 146
	$l_stat_user_day	= "By connection";
2315 tom.houday 147
	$l_stat_con		= "Global accounting";
2527 fabien.rak 148
	$l_stat_daily		= "Daily use";
149
	$l_stat_global_network	= "Global traffic";
150
	$l_stat_detail_network	= "Detailed traffic";
151
	$l_security		= "Security";
2315 tom.houday 152
	$l_menu			= "Main";
153
	$l_gammu		= "Auto registration (SMS)";
154
	$l_backup_archive	= "Archives";
2852 rexy 155
	$l_accountability_logs		= "accountability logs";
2315 tom.houday 156
	$l_since		= "since:";
2852 rexy 157
	$l_doc_language = "en";
374 richard 158
}
1911 raphael.pi 159
 
2315 tom.houday 160
// Get access log count
161
$tab = file(ACC_ACCESS_LOG);
162
$accAccessCounter = count($tab);
163
$field = explode('|', $tab[0]);
164
$accAccessFirstDate = explode(' ', $field[0])[0];
374 richard 165
?>
2315 tom.houday 166
<!DOCTYPE html>
167
<html>
168
<head>
169
	<meta charset="utf-8">
170
	<title>Menu - ALCASAR</title>
2817 rexy 171
	<link rel="stylesheet" type="text/css" href="/css/acc.css">
2809 rexy 172
	<link rel="stylesheet" type="text/css" href="/css/menu.css">
2315 tom.houday 173
	<script src="/js/jquery.min.js"></script>
174
	<script>
175
		$(document).ready(function () {
176
			$('.menu a[href="#"]').click(function (event) {
177
				event.preventDefault();
178
				if ($(this).parent().hasClass('active')) {
179
					$(this).parent().removeClass('active');
180
				} else {
181
					$('.menu li.active').removeClass('active');
182
					$(this).parent().addClass('active');
183
				}
184
			});
185
		});
186
	</script>
187
</head>
188
<body>
189
	<div class="panel">
190
		<div class="panel-header">
191
			<?= $l_menu ?>
192
		</div>
2813 rexy 193
		<div class="panel-row">
2315 tom.houday 194
			<div class="menu">
195
				<ul>
2815 rexy 196
					<li><div class="caret"></div><a href="welcome.php" target="REXY2"><?= $l_home ?></a></li>
2315 tom.houday 197
					<?php if ($right === 0):			// admin ?>
198
						<li>
199
							<div class="caret"></div><a href="#"><?= $l_system ?></a>
200
							<ul>
201
								<li><div class="caret"></div><a href="admin/network.php" target="REXY2"><?= $l_network ?></a></li>
202
								<li><div class="caret"></div><a href="admin/services.php" target="REXY2">Services</a></li>
203
								<li><div class="caret"></div><a href="admin/ldap.php" target="REXY2"><?= $l_ldap ?></a></li>
204
							</ul>
205
						</li>
206
					<?php endif; ?>
207
					<?php if ($right === 0 || $right === 2):	// admin, manager ?>
208
						<li>
209
							<div class="caret"></div><a href="#"><?= $l_auth ?></a>
210
							<ul>
211
								<li><div class="caret"></div><a href="manager/htdocs/activity.php" target="REXY2"><?= $l_activity ?></a></li>
212
								<li><div class="caret"></div><a href="manager/htdocs/user_new.php" target="REXY2"><?= $l_create_user ?></a></li>
213
								<li><div class="caret"></div><a href="manager/htdocs/find.php" target="REXY2"><?= $l_edit_user ?></a></li>
214
								<li><div class="caret"></div><a href="manager/htdocs/group_new.php" target="REXY2"><?= $l_create_group ?></a></li>
215
								<li><div class="caret"></div><a href="manager/htdocs/show_groups.php" target="REXY2"><?= $l_edit_group ?></a></li>
216
								<li><div class="caret"></div><a href="manager/htdocs/import_user.php" target="REXY2"><?= $l_import_empty ?></a></li>
217
								<li><div class="caret"></div><a href="manager/auth_exceptions.php" target="REXY2">Exceptions</a></li>
218
								<li><div class="caret"></div><a href="manager/htdocs/autoregistration.php" target="REXY2"><?= $l_gammu ?></a></li>
219
							</ul>
220
						</li>
221
					<?php endif; ?>
222
					<?php if ($right === 0):			// admin ?>
223
						<li>
224
							<div class="caret"></div><a href="#"><?= $l_filter ?></a>
225
							<ul>
226
								<li><div class="caret"></div><a href="admin/bl_filter.php" target="REXY2"><?= $l_blacklist ?></a></li>
227
								<li><div class="caret"></div><a href="admin/wl_filter.php" target="REXY2"><?= $l_whitelist ?></a></li>
228
								<li><div class="caret"></div><a href="admin/protocols_filter.php" target="REXY2"><?= $l_protocols ?></a></li>
229
							</ul>
230
						</li>
231
					<?php endif; ?>
232
					<?php if ($right === 0):			// admin ?>
233
						<li>
234
							<div class="caret"></div><a href="#"><?= $l_statistics ?></a>
235
							<ul>
236
								<li><div class="caret"></div><a href="manager/htdocs/user_stats.php" target="REXY2"><?= $l_stat_user_day ?></a></li>
237
								<li><div class="caret"></div><a href="manager/htdocs/accounting.php" target="REXY2"><?= $l_stat_con ?></a></li>
238
								<li><div class="caret"></div><a href="manager/htdocs/stats.php" target="REXY2"><?= $l_stat_daily ?></a></li>
2809 rexy 239
								<li><div class="caret"></div><a href="manager/vnstat.php" target="REXY2"><?= $l_stat_global_network ?></a></li>
2825 rexy 240
								<!--<li><div class="caret"></div><a href="manager/nfsen.php" target="REXY2"><?= $l_stat_detail_network ?></a></li> -->
2315 tom.houday 241
								<li><div class="caret"></div><a href="manager/htdocs/security.php" target="REXY2"><?= $l_security ?></a></li>
242
							</ul>
243
						</li>
244
					<?php endif; ?>
245
					<?php if ($right === 0 || $right === 1):	// admin, backup ?>
246
						<li>
247
							<div class="caret"></div><a href="#"><?= $l_backup ?></a>
248
							<ul>
249
								<li><div class="caret"></div><a href="backup/sauvegarde.php" target="REXY2"><?= $l_backup_archive ?></a></li>
2852 rexy 250
								<li><div class="caret"></div><a href="backup/log_generation.php" target="REXY2"><?= $l_accountability_logs ?></a></li>
2315 tom.houday 251
							</ul>
252
						</li>
253
					<?php endif; ?>
254
				</ul>
255
			</div>
256
		</div>
257
	</div>
258
	<br>
259
	<div class="panel">
260
		<div class="panel-header">
261
			Documents
262
		</div>
2813 rexy 263
		<div class="panel-row">
2315 tom.houday 264
			<div class="menu">
265
				<ul>
2852 rexy 266
					<li><div class="caret"></div><a href="<?= "alcasar-$installed_version-presentation-$l_doc_language.pdf" ?>" target="_blank">Presentation</a></li>
267
					<li><div class="caret"></div><a href="<?= "alcasar-$installed_version-installation-$l_doc_language.pdf" ?>" target="_blank">Installation</a></li>
268
					<li><div class="caret"></div><a href="<?= "alcasar-$installed_version-exploitation-$l_doc_language.pdf" ?>" target="_blank">Exploitation</a></li>
2315 tom.houday 269
					<li><div class="caret"></div><a href="<?= "alcasar-$installed_version-technique.pdf" ?>" target="_blank">Technique</a></li>
270
				</ul>
271
			</div>
272
		</div>
273
	</div>
274
	<br>
275
	<div class="panel">
276
		<div class="panel-header">
277
			<?= $l_access_nb ?>
278
		</div>
2813 rexy 279
		<div class="panel-row" style="text-align: center;">
2315 tom.houday 280
			<a href="admin_log.php" target="REXY2"><?= $accAccessCounter ?></a><br>
281
			<?= $l_since ?> <?= $accAccessFirstDate ?>
282
		</div>
283
	</div>
284
</body>
285
</html>