]> jfr.im git - irc/unrealircd/unrealircd-webpanel.git/commitdiff
Add user-edit page (WIP) and some minor fixes
authorValerie Pond <redacted>
Tue, 7 Feb 2023 00:56:12 +0000 (00:56 +0000)
committerValerie Pond <redacted>
Tue, 7 Feb 2023 00:56:12 +0000 (00:56 +0000)
Contains some other minor fixes including footer, js, misc/strings

css/unrealircd-admin.css
footer.php
js/unrealircd-admin.js
misc/modes-parser.php [new file with mode: 0644]
misc/strings.php
settings/index.php
settings/user-edit.php
tools/ip-whois.php

index cc4e5507c06f62807c1e7bce2b3d60f5ecf9278c..972a6cbd104274cbe8f100715c810fd950cda293 100644 (file)
@@ -15,7 +15,6 @@
        margin: 2px;
 }
 
-  
 .short-form-control {
        width: 70%;
 }
index 9e0d64533732d9c820cd4ea1225af83a7630c59f..b3b1f3775d3a537b08e1135bda9c64a79127ec4d 100644 (file)
       <a
         href="https://unrealircd.org"
         role="button"
-        data-mdb-ripple-color="dark"
-        ><img  class="btn btn-link btn-floating btn-xs text-white" src="<?php echo BASE_URL; ?>img/favicon.ico" width="25" height="25"></i
-      ></a>
+        data-mdb-ripple-color="dark">
+        <img  class="btn btn-link btn-floating btn-xs text-white" src="<?php echo BASE_URL; ?>img/favicon.ico" width="25" height="25"></a>
     
     <?php $arr = []; Hook::run(HOOKTYPE_FOOTER, $arr); ?>
     </section>
     
 
-</footer>
-</body>
-</html>
 </div>
 </div>
+
+</footer>
+</body>
+</html>
\ No newline at end of file
index 33ae9845951dce3302be7ad23b47217d24e4a221..9c34cfe279439a8bac1173df559c996bc0d3d17d 100644 (file)
@@ -40,4 +40,4 @@ function toggle_checkbox(source) {
     for (var i = 0, n = checkboxes.length; i < n; i++) {
         checkboxes[i].checked = source.checked;
     }
-}
\ No newline at end of file
+}
diff --git a/misc/modes-parser.php b/misc/modes-parser.php
new file mode 100644 (file)
index 0000000..a4abe2d
--- /dev/null
@@ -0,0 +1,2 @@
+<?php
+
index 199c0f15fe8db5289697f4702d92c4450633e257..b6f7d24ed25a254676ecd73dc7f146fbc7f1a215 100644 (file)
@@ -64,3 +64,26 @@ function show_nick_only($str)
                $str = substr($str, 0, $x);
        return $str;
 }
+
+
+function how_long_ago($timestamp)
+{
+       $now = time();
+       $diff = $now - strtotime($timestamp);
+
+       $units = array(
+               31536000 => 'year',
+               2592000 => 'month',
+               604800 => 'week',
+               86400 => 'day',
+               3600 => 'hour',
+               60 => 'minute',
+               1 => 'second'
+       );
+
+       foreach ($units as $unit => $text) {
+               if ($diff < $unit) continue;
+               $numberOfUnits = floor($diff / $unit);
+               return $numberOfUnits.' '.$text.(($numberOfUnits>1)?'s':'').' ago';
+       }
+}
\ No newline at end of file
index 705c4c2dd8e60f5b011c647a8379b691c3bd8d29..540d04bbe7b43fd2c92b0b5632be76b51a16b47c 100644 (file)
@@ -139,12 +139,13 @@ Click on a username to view more information.
                {
                        
                        echo "<td scope=\"col\"><input type=\"checkbox\" value='" .$user->id . "' name=\"userch[]\"></td>";
-                       echo "<td scope=\"col\">".$user->username."</td>";
+                       echo "<td scope=\"col\"><a href=\"".BASE_URL."settings/user-edit.php?id=$user->id\">$user->username</a></td>";
                        echo "<td scope=\"col\">".$user->first_name."</td>";
                        echo "<td scope=\"col\">".$user->last_name."</td>";
-                       echo "<td scope=\"col\">".$user->created."</td>";
+                       echo "<td scope=\"col\"><code>".$user->created."</code></td>";
                        echo "<td scope=\"col\">".$user->bio."</td>";
-                       echo "<td scope=\"col\">".$user->user_meta['last_login']."</td>";
+                       $last = (isset($user->user_meta['last_login'])) ? "<code>".$user->user_meta['last_login'] . "</code> <span class=\"badge rounded-pill badge-dark\">".how_long_ago($user->user_meta['last_login'])."</span>" : "none";
+                       echo "<td scope=\"col\">$last</td>";
                        echo "</tr>";
                }
        ?></tbody></table><p><button type="button" class="btn btn-danger" data-toggle="modal" data-target="#myModal2">
index 59d90af29f2b2efb6b7a7cee9f0fa5187352bc46..3f1aa29d4699b2a92e3e69936a9fc03bfefadcb2 100644 (file)
@@ -1,4 +1,64 @@
 <?php
 
 require_once "../common.php";
-require_once "../header.php";
\ No newline at end of file
+require_once "../header.php";
+
+do_log($_POST, $_GET, $_FILES);
+
+$us = unreal_get_current_user();
+$id = (isset($_GET['id'])) ? $_GET['id'] : $us->id;
+$edit_user = new PanelUser(NULL, $id);
+$can_edit = (current_user_can(PERMISSION_MANAGE_USERS) || $edit_user->id == $us->id) ? "" : "disabled";
+
+?>
+<h4>Edit User: "<?php echo $edit_user->username; ?>"</h4>
+<br><br>
+<form method="post" action="user-edit.php?id=<?php echo $edit_user->id; ?>" autocomplete="off" enctype="multipart/form-data">
+
+<div class="input-group mb-3">
+    <div class="input-group-prepend">
+        <span class="input-group-text" style="width: 100px;">@</span>
+    </div><input disabled type="text" class="form-control" name="username" id="username" placeholder="<?php echo $edit_user->username; ?>">
+</div>
+
+<div class="input-group mb-3">
+    <div class="input-group-prepend">
+        <span class="input-group-text" style="width: 100px;">First Name</span>
+    </div><input <?php echo $can_edit; ?> type="text" class="form-control" name="first_name" id="first_name" placeholder="<?php echo $edit_user->first_name; ?>">
+</div>
+
+
+<div class="input-group mb-3">
+    <div class="input-group-prepend">
+        <span class="input-group-text" style="width: 100px;">Last Name</span>
+    </div><input <?php echo $can_edit; ?> type="text" class="form-control" name="last_name" id="last_name" placeholder="<?php echo $edit_user->last_name; ?>">
+</div>
+
+
+<div class="input-group mb-3">
+    <div class="input-group-prepend">
+        <span class="input-group-text" style="width: 100px;">Bio</span>
+    </div><textarea <?php echo $can_edit; ?> class="form-control" name="bio" id="username"><?php echo $edit_user->bio; ?></textarea>
+</div>
+
+
+<div class="input-group mb-3">
+    <div class="input-group-prepend">
+        <span class="input-group-text" style="width: 100px;">Email</span>
+    </div><input <?php echo $can_edit; ?> type="text" class="form-control" name="email" id="email" autocomplete="off">
+</div>
+
+<div class="input-group mb-3">
+    <div class="input-group-prepend">
+        <span class="input-group-text" style="width: 100px;">Password</span>
+    </div><input <?php echo $can_edit; ?> type="password" class="form-control" name="password" id="password" autocomplete="off">
+    <div class="input-group-append">
+               <br><button type="submit" name="update_pass" class="btn btn-primary">Update Password</button>
+       </div>
+</div>
+
+<br>
+<button type="submit" name="update_user" class="btn btn-primary">Update User</button><br><p>
+<h6>Note: This button will not update your password.<br>
+Please use the 'Update Password' button on the Password field for this instead.</h6></p>
+</form>
\ No newline at end of file
index fe52f6df62ee962c6e2a7ab9b4db1ed7fe3fd34e..ea76a177bffe2f97d356ee7b9af153a3a4e246e4 100644 (file)
@@ -96,7 +96,7 @@ if ($ip)
                        </button>
                </div>
                <div class="modal-body">
-            <code><?php echo str_replace("\n", "<br>",$whois); ?></code>
+            <code><?php echo str_replace("\n", "<br>",htmlspecialchars($whois)); ?></code>
                </div>
                <div class="modal-footer">
             <button id="CloseButton" type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>