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