瀏覽代碼

When adding an ip address to a user, you can write a comment instead of a mac.

root 8 月之前
父節點
當前提交
92151c719e
共有 1 個文件被更改,包括 8 次插入3 次删除
  1. 8 3
      html/admin/users/edituser.php

+ 8 - 3
html/admin/users/edituser.php

@@ -121,10 +121,14 @@ if (isset($_POST["showDevice"])) {
 
 if (isset($_POST["addauth"])) {
     $fip = substr(trim($_POST["newip"]), 0, 18);
-    $fmac = NULL;
-    if (isset($_POST["newmac"])) {
+    $fcomment = NULL;
+    if (!empty(trim($_POST["newmac"]))) {
         $fmac = mac_dotted(substr(trim($_POST["newmac"]), 0, 17));
-    }
+        if (!checkValidMac($fmac)) { 
+                $fmac=NULL;
+                $fcomment = trim($_POST["newmac"]); 
+            }
+        }
     if ($fip) {
         if (checkValidIp($fip)) {
             $ip_aton = ip2long($fip);
@@ -164,6 +168,7 @@ if (isset($_POST["addauth"])) {
             if (!empty($fid)) {
                 $new['dhcp'] = $f_dhcp;
                 $new['created_by'] = 'manual';
+                if (!empty($fcomment)) { $new['comments'] = $fcomment; }
                 update_record($db_link, "User_auth", "id=" . $fid, $new);
                 LOG_WARNING($db_link, "Add ip for login: " . $user_info["login"] . ": ip => $fip, mac => $fmac", $fid);
                 header("Location: /admin/users/editauth.php?id=" . $fid);