]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/commitdiff
Move users stuff in users/ directory. Plus add new REQUIRED CONFIG ITEM,
authorBram Matthys <redacted>
Wed, 11 Jan 2023 08:33:23 +0000 (09:33 +0100)
committerBram Matthys <redacted>
Wed, 11 Jan 2023 08:35:45 +0000 (09:35 +0100)
which is called BASE_DIR. See config.php.sample

common.php
config.php.sample
header.php
users/details.php [moved from user-lookup.php with 92% similarity]
users/index.php [moved from users.php with 97% similarity]

index 3394fb0d44dd499cf137b1042b20593df4d3221d..cde08bd9bcda203c847d1cab89738878351fc741 100644 (file)
@@ -1,6 +1,7 @@
 <?php
 define('UPATH', dirname(__FILE__));
 require_once "config.php";
+if (!defined('BASE_DIR')) die("You need to define BASE_DIR in config.php (see config.php.sample for documentation)");
 require_once "Classes/class-hook.php";
 if (!is_dir(UPATH . "/vendor"))
        die("The vendor/ directory is missing. Most likely the admin forgot to run 'composer install'\n");
@@ -14,7 +15,7 @@ require_once "Classes/class-rpc.php";
 require_once "plugins.php";
 
 $pages = Array("Overview"      => "index.php",
-                          "Users"              => "users.php",
+                          "Users"              => "users/index.php",
                           "Channels"   => "channels.php",
                           "Server Bans"        => "tkl.php",
                           "Spamfilter" => "spamfilter.php",
index 96a53143caa9c9949d70d1ce32124cbd6d297c48..0095a3866192fcf68e2461e0ab9bffce37aecd09 100644 (file)
@@ -5,10 +5,16 @@
  * 
  */
 
-
  if (!defined('UPATH'))
     die("Access denied");
 
+/**
+ * The base URL, how this panel can be accessed.
+ * This would be '/' if you installed in the web root,
+ * or something like '/webpanel/' if you go to http://x.y.z/webpanel
+ * IMPORTANT: needs a trailing slash!
+*/
+define( 'BASE_URL', '/' );
 
 /**
  *  The RPC User name as defined in your unrealircd.conf
index 11abee578cd950008d9f7df584dee82c6b879486..b812db2e91ce88adb02bba97ed34bad8684cf6c2 100644 (file)
@@ -14,8 +14,8 @@
 
 <script src="js/unrealircd-admin.js"></script>
 <title>UnrealIRCd Panel</title>
-<link rel="icon" type="image/x-icon" href="img/favicon.ico">
-<link href="css/unrealircd-admin.css" rel="stylesheet">
+<link rel="icon" type="image/x-icon" href="<?php echo BASE_URL; ?>img/favicon.ico">
+<link href="<?php echo BASE_URL; ?>css/unrealircd-admin.css" rel="stylesheet">
 </head>
 <body role="document">
 <div class="container-fluid">
        <!-- 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="img/favicon.ico" height="25" width="25"> UnrealIRCd Admin Panel</a>
+                       <a class="navbar-brand" href="index.php"><img src="<?php echo BASE_URL; ?>img/favicon.ico" height="25" width="25"> UnrealIRCd Admin Panel</a>
 <?php
 
+$active_page = false;
+/* Needs to be a separate step due to multiple matches */
+foreach($pages as $name=>$page)
+       if (str_ends_with($_SERVER['SCRIPT_FILENAME'], $page))
+               $active_page = $page;
+
 foreach($pages as $name=>$page)
 {
        $class = "class=\"nav-item\"";
-       if (str_ends_with($_SERVER['SCRIPT_FILENAME'], $page))
+       if ($page == $active_page)
                $class = str_replace("\"nav-item\"", "\"nav-item active\"", $class);
        
-       echo "                  <li $class><a class=\"nav-link\" href=\"$page\">$name</a></li> \n";
+       echo "                  <li $class><a class=\"nav-link\" href=\"".BASE_URL.$page."\">$name</a></li> \n";
 }
 ?>
        
similarity index 92%
rename from user-lookup.php
rename to users/details.php
index 89800ddc1b7d3ce066a6707cc6601e428378b9b1..c3d9c4cb1e8657472ce6fea60d12eded49e9b8be 100644 (file)
@@ -1,6 +1,6 @@
 <?php
-require_once "common.php";
-require_once "header.php";
+require_once "../common.php";
+require_once "../header.php";
 
 $title = "User Lookup";
 $nickname = "";
@@ -21,7 +21,7 @@ if (isset($_GET['nick']))
 <title><?php echo $title; ?></title>
 <h4><?php echo $title; ?></h4>
 <br>
-<form method="get" action="user-lookup.php">
+<form method="get" action="details.php">
 <div class="input-group short-form-control justify-content-center align-items-center">
        <input style="margin: 0%; height: 24px;" class="left-pan form-control" id="nick" name="nick" type="text" value=<?php echo $nickname; ?>>
        <div class="input-group-append">
similarity index 97%
rename from users.php
rename to users/index.php
index ebb9e93b44cbd349ce551bc78ea77fa5c7091aeb..2f06e80ca89350d1f11eb7a12106a32777afb41d 100644 (file)
--- a/users.php
@@ -1,6 +1,6 @@
 <?php
-require_once "common.php";
-require_once "header.php";
+require_once "../common.php";
+require_once UPATH . "/header.php";
 
 if (!empty($_POST)) {
        do_log($_POST);
@@ -93,7 +93,7 @@ Click on a username to view more information.
        </thead>
        
        <tbody>
-       <form action="users.php" method="post">
+       <form method="post">
        <?php
 
                foreach($users as $user)
@@ -127,7 +127,7 @@ Click on a username to view more information.
                        echo "<tr>";
                        echo "<th scope=\"row\"><input type=\"checkbox\" value='" . base64_encode($user->id)."' name=\"userch[]\"></th>";
                        $isBot = (strpos($user->user->modes, "B") !== false) ? ' <span class="badge-pill badge-dark">Bot</span>' : "";
-                       echo "<td><a href=\"user-lookup.php?nick=".$user->id."\">$user->name$isBot</a></td>";
+                       echo "<td><a href=\"details.php?nick=".$user->id."\">$user->name$isBot</a></td>";
                        echo "<td>".$user->hostname." (".$user->ip.")</td>";
                        $account = (isset($user->user->account)) ? $user->user->account : '<span class="badge-pill badge-primary">None</span>';
                        echo "<td>".$account."</td>";
@@ -241,4 +241,4 @@ Click on a username to view more information.
     });
 </script>
 
-<?php require_once 'footer.php'; ?>
+<?php require_once UPATH.'/footer.php'; ?>