Ver código fonte

fix translation and mass changed form

Roman Dmitriev 2 anos atrás
pai
commit
85a2039c16
3 arquivos alterados com 15 adições e 18 exclusões
  1. 2 2
      html/inc/common.php
  2. 1 1
      html/inc/languages/russian.php
  3. 12 15
      html/utils/auth_apply.php

+ 2 - 2
html/inc/common.php

@@ -3060,7 +3060,7 @@ function expand_log_str($db, $msg)
     $result = preg_replace($auth_pattern, $auth_replace, $msg);
 
     $user_pattern = '/(user_id:|user|user id:|user id)\s+(\d+)\s+/i';
-    $user_replace = '<a href=/admin/users/edituser.php?id=${2}>user_id:${2}</a>';
+    $user_replace = '<a href=/admin/users/edituser.php?id=${2}>user_id:${2}</a> ';
     $result = preg_replace($user_pattern, $user_replace, $result);
 
     $mac_pattern = '/\s+\[(\w{12})\]\s+/i';
@@ -3091,7 +3091,7 @@ function expand_log_str($db, $msg)
         $device_name = $matches[1];
         $device_id = get_device_id($db, $device_name);
         if (isset($device_id) and $device_id > 0) {
-            $device_replace = 'at device <a href=/admin/devices/editdevice.php?id=' . $device_id . '>${1}</a>';
+            $device_replace = 'at device <a href=/admin/devices/editdevice.php?id=' . $device_id . '>${1}</a> ';
             $result = preg_replace($device_pattern, $device_replace, $result);
         }
     }

+ 1 - 1
html/inc/languages/russian.php

@@ -455,7 +455,7 @@ define("WEB_user_add_mac","Mac (необязательно)");
 define("WEB_user_list_apply","Применить к списку");
 define("WEB_new_user","Новый юзер");
 define("WEB_user_deleted","принадлежит несуществующему юзеру. Вероятно запись удалена");
-define("WEB_user_bind_mac","Привязать мак в юзеру");
+define("WEB_user_bind_mac","Привязать мак к юзеру");
 define("WEB_user_unbind_mac","Отвязать мак от юзера");
 
 /* public */

+ 12 - 15
html/utils/auth_apply.php

@@ -96,34 +96,31 @@ if (isset($_POST["ApplyForAll"])) {
 
             if (!empty($auth)) {
                 $ret = update_record($db_link, "User_auth", "id='" . $val . "'", $auth);
-                if (!$ret) {
-                    $all_ok = 0;
-                }
+                if (!$ret) { $all_ok = 0; }
+            }
 
             //bind mac rule
             if (isset($_POST["e_bind_mac"])) {
                 $first_auth = get_record_sql($db_link,"SELECT user_id,mac FROM User_auth WHERE id=".$val);
-                if ($a_bind_mac) {
-                    if (!empty($first_auth) and !empty($first_auth['mac'])) {
-                        $auth_rules = get_record_sql($db_link,"SELECT * FROM auth_rules WHERE user_id=".$first_auth['user_id']." AND type=2 AND rule='".$first_auth['mac']."'");
-                        if (empty($auth_rules)) {
+                if (!empty($first_auth) and !empty($first_auth['mac'])) {
+                    if ($a_bind_mac) {
+                            $auth_rules = get_record_sql($db_link,"SELECT * FROM auth_rules WHERE user_id=".$first_auth['user_id']." AND type=2 AND rule='".$first_auth['mac']."'");
+                            if (empty($auth_rules)) {
                                 $new['user_id']=$first_auth['user_id'];
                                 $new['type']=2;
                                 $new['rule']=$first_auth['mac'];
                                 insert_record($db_link,"auth_rules",$new);
                                 LOG_INFO($db_link,"Created auto rule for user_id: ".$first_auth['user_id']." and mac ".$first_auth['mac']);
-                            } else {
+                                } else {
                                 LOG_INFO($db_link,"Auto rule for user_id: ".$first_auth['user_id']." and mac ".$first_auth['mac']." already exists");
+                                }
+                            } else {
+                                run_sql($db_link,"DELETE FROM auth_rules WHERE user_id=".$first_auth['user_id']." AND type=2");
+                                LOG_INFO($db_link,"Remove auto rule for user_id: ".$first_auth['user_id']." and mac ".$first_auth['mac']);
                             }
-                        }
                     } else {
-                        run_sql($db_link,"DELETE FROM auth_rules WHERE user_id=".$first_auth['user_id']." AND type=2");
-                        LOG_INFO($db_link,"Remove auto rule for user_id: ".$first_auth['user_id']." and mac ".$first_auth['mac']);
+                        LOG_ERROR($db_link,"Auto rule for user_id: ".$first_auth['user_id']." not created. Record not found or empty mac.");
                     }
-                header("Location: " . $_SERVER["REQUEST_URI"]);
-                exit;
-                }
-
             }
         }
     }