}
closedir($dh);
}
+
+ // Create the symbolic links for .htpasswd and gui.css
+ // in each www/ext directory.
+ if (!$early) {
+ $dh = @opendir("{$g['www_path']}/ext");
+ if ($dh) {
+ while (($extd = readdir($dh)) !== false) {
+ if (($extd === ".") || ($extd === ".."))
+ continue;
+ if (is_dir("{$g['www_path']}/ext/$extd")) {
+ // Create links
+ symlink("{$g['www_path']}/.htpasswd",".htpasswd");
+ symlink("{$g['www_path']}/gui.css","gui.css");
+ }
+ }
+ closedir($dh);
+ }
+ }
+
+
}
function system_console_configure() {
if (!($_SERVER['REMOTE_USER'] === $config['system']['username'])) {
$allowed[] = '';
if (isset($config['system']['group'][$groupindex[$config['system']['user'][$userindex[$_SERVER['REMOTE_USER']]]['groupname']]]['pages'])) {
- $allowed = &$config['system']['group'][$groupindex[$config['system']['user'][$userindex[$_SERVER['REMOTE_USER']]]['groupname']]]['pages'];
+ $allowed = &$config['system']['group'][$groupindex[$config['system']['user'][$userindex[$_SERVER['REMOTE_USER']]]['groupname']]]['pages'];
}
// If the user is attempting to hit the default page, set it to specifically look for /index.php.
$_SERVER['PHP_SELF'] = '/index.php';
// Strip the leading / from the currently requested PHP page
- if (!in_array(basename($_SERVER['PHP_SELF']),$allowed)) {
+ // With extensions there also is a path to be concerned with
+ if ( !in_array(ltrim($_SERVER['PHP_SELF'],"/"),$allowed) ) {
// The currently logged in user is not allowed to access the page
// they are attempting to go to. Redirect them to an allowed page.
}
-
?>
\ No newline at end of file
function dynamic_menu(&$menu, $menu_title) {
global $allowed, $config;
-
+
// Make sure the admin can see everything
if ($_SERVER['REMOTE_USER'] === $config['system']['username']) {
unset($allowed);
- foreach ($menu as $item) {
- $allowed[] = $item[0];
+ foreach ($menu as $item) {
+ $allowed[] = $item[0];
}
}
}
}
}
-
+
// Check for issues when changing the web admin username
// $allowed is set in auth.inc *IF* the user is not the webGUI admin
// so, if it's not set here, they were the admin user when they submited the admin username change.
($_SERVER['REMOTE_USER'] != $config['system']['username'])) {
// webGUI username was just changed, let us change what PHP sees the remote user as so
// the menu will build properly. When user hits next link, they will be prompted to reauthenticate.
- $_SERVER['REMOTE_USER'] = $config['system']['username'];
+ $_SERVER['REMOTE_USER'] = $config['system']['username'];
+
}
$menu['System']['General setup'] = array('system.php');
$menu['Status']['Captive portal'] = array('status_captiveportal.php');
}
+// Add Extensions, if they exist
+if (is_dir("{$g['www_path']}/ext")){
+ $dh = @opendir("{$g['www_path']}/ext");
+ if ($dh) {
+ while (($extd = readdir($dh)) !== false) {
+ if (($extd === ".") || ($extd === ".."))
+ continue;
+ $extfiles=explode("\n",trim(file_get_contents("{$g['www_path']}/ext/" . $extd . "/menu2.inc")));
+ $menu['Extensions'][array_shift($extfiles)]=$extfiles;
+ }
+ closedir($dh);
+ }
+}
+
$menu['Diagnostics']['Logs'] = array('diag_logs.php',
'diag_logs_filter.php',
'diag_logs_dhcp.php',
dynamic_menu($menu['Services'], 'Services');
dynamic_menu($menu['VPN'], 'VPN');
dynamic_menu($menu['Status'], 'Status');
-?>
-
-<?php
-/* extensions section */
-if (is_dir("{$g['www_path']}/ext")):
-?>
- <strong>Extensions</strong><br>
-<?php
-$dh = @opendir("{$g['www_path']}/ext");
-if ($dh) {
- while (($extd = readdir($dh)) !== false) {
- if (($extd === ".") || ($extd === ".."))
- continue;
- @include("{$g['www_path']}/ext/" . $extd . "/menu.inc");
- }
- closedir($dh);
-}
-endif;
-?>
-
-<?php
+// If Extensions exist, add them to the menu
+if (isset($menu['Extensions']))
+ dynamic_menu($menu['Extensions'], 'Extensions');
dynamic_menu($menu['Diagnostics'], 'Diagnostics');
?>
</span>
<?php if (!$pgtitle_omit): ?>
<p class="pgtitle"><?=gentitle($pgtitle);?></p>
<?php endif; ?>
+