]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/blobdiff - header.php
Fix header referencing to overview from other directories
[irc/unrealircd/unrealircd-webpanel.git] / header.php
index b812db2e91ce88adb02bba97ed34bad8684cf6c2..ba77221cd69f17a2f242b36d835288c27a0bec1e 100644 (file)
@@ -12,6 +12,9 @@
 <!-- Latest compiled JavaScript -->
 <script src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.bundle.min.js"></script>
 
+<!-- Font Awesome icons -->
+<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.1/css/all.min.css">
+
 <script src="js/unrealircd-admin.js"></script>
 <title>UnrealIRCd Panel</title>
 <link rel="icon" type="image/x-icon" href="<?php echo BASE_URL; ?>img/favicon.ico">
        <!-- Fixed navbar -->
        <nav class="navbar navbar-expand-sm navbar-dark bg-dark fixed-top">
                <ul class="nav navbar-nav">
-                       <a class="navbar-brand" href="index.php"><img src="<?php echo BASE_URL; ?>img/favicon.ico" height="25" width="25"> UnrealIRCd Admin Panel</a>
+                       <a class="navbar-brand" href="<?php echo BASE_URL; ?>/index.php"><img src="<?php echo BASE_URL; ?>img/favicon.ico" height="25" width="25"> UnrealIRCd Admin Panel</a>
 <?php
 
-$active_page = false;
+$active_page = NULL;
 /* Needs to be a separate step due to multiple matches */
-foreach($pages as $name=>$page)
-       if (str_ends_with($_SERVER['SCRIPT_FILENAME'], $page))
+foreach ($pages as $name => $page)
+{
+       $script = $_SERVER['SCRIPT_FILENAME'];
+       if (str_ends_with($script, BASE_URL . "index.php") || !strlen($page))
+       {
+               $active_page = "";
+       }
+       else if (!str_ends_with($page, ".php"))
+       {
+               $script2 = rtrim($script, "/index.php");
+               if (str_ends_with($script2, $page))
+                       $active_page = $page;
+       }
+       else if (str_ends_with($script, $page))
+       {
                $active_page = $page;
-
+       } elseif (!$active_page)
+               $active_page = false;
+}
 foreach($pages as $name=>$page)
 {
        $class = "class=\"nav-item\"";
-       if ($page == $active_page)
+       if (is_string($active_page) && $page == $active_page)
                $class = str_replace("\"nav-item\"", "\"nav-item active\"", $class);
        
        echo "                  <li $class><a class=\"nav-link\" href=\"".BASE_URL.$page."\">$name</a></li> \n";