Kaynağa Gözat

脱敏值replace

ShuanghongS 2 ay önce
ebeveyn
işleme
0b99de14e8
3 değiştirilmiş dosya ile 33 ekleme ve 1 silme
  1. 4 0
      include.ini.php
  2. 1 1
      service/login.class.php
  3. 28 0
      utils/common.class.php

+ 4 - 0
include.ini.php

@@ -81,6 +81,10 @@ function _isRevenueDisplay() {
     return $_SESSION['ONLINE_USER']['revenue_active'] == 't';
 }
 
+function _isDesensitizationKln() {
+    return $_SESSION['ONLINE_USER']['is_desensitization_kln'] == 't';
+}
+
 function _isNewUser() {
     return _isCustomerLogin() && empty($_SESSION['ONLINE_USER']['permission']);
 }

+ 1 - 1
service/login.class.php

@@ -29,7 +29,7 @@ class login {
         customer_search_type, customer_destination, can_add_ams, can_add_isf, air_station, air_sales, ocean_station, ocean_sales,ocean_following_sales,ocean_following_sales_or,air_following_sales,air_following_sales_or, trucking_station, ocean_dest_op, can_see_password, can_add_opsales_code, ocean_station_or, ocean_agent_or, ocean_sales_or, ocean_dest_op_or, air_station_or, air_sales_or, trucking_station_or, 
         can_add_user, can_add_employee, can_add_contact, company_name, ams_email, isf_email, customer_discharge, online_active, is_super, ocean_agent,active, can_send_email, view_file_format as docdownload, container_status, consolidated_cbsa_code, can_add_aci, 
         air_customers, air_customer_search_type,trucking_customers,trucking_customer_search_type, upload_document, view_file_format, event_type, belong_schemas, main_schemas, error_login_count, EXTRACT(EPOCH FROM (now()-COALESCE(error_login_time, now()))) as second, po_status, view_air_file_format, 
-        special_customer_event, can_edi_vgm, isf_aci_ams_station,login_version,is_kerry_shipment,can_visit_delivery,currency_group,revenue_active from public.ra_online_user u where md5(lower(user_login)) = ?";
+        special_customer_event, can_edi_vgm, isf_aci_ams_station,login_version,is_kerry_shipment,can_visit_delivery,currency_group,revenue_active,is_desensitization_kln from public.ra_online_user u where md5(lower(user_login)) = ?";
     }
 
     public function do_login() {

+ 28 - 0
utils/common.class.php

@@ -876,6 +876,9 @@ class common {
     }
 
     public static function echo_json_encode($code,$data){
+        if(_isDesensitizationKln()){
+            common::maskShipperName($data);
+        }
         $resData = array();
         $resData["code"] = $code;
         $resData["data"] =$data;
@@ -883,6 +886,31 @@ class common {
         echo json_encode($resData);
     }
 
+    public static function maskShipperName(&$data) {
+        if (is_array($data)) {
+            foreach ($data as $key => &$value) {
+                if ($key === 'shipperName' || $key === 'consigneeName' 
+                    || $key === 'Shipper'  || $key === 'Consignee'
+                    || $key === 'shipper'  || $key === 'consignee') {
+                    if(is_array($value)){
+                        $temp = array();
+                        foreach($value as $vk =>$vv){
+                            $temp[$vk] = '**********';
+                        }
+                        $value = $temp;
+                    } else {
+                        $value = '**********'; // 替换为脱敏值
+                    }
+                } else {
+                    // 递归处理子数组
+                    common::maskShipperName($value);
+                }
+            }
+            unset($value); // 解除引用
+        }
+        // 如果是标量(string, int 等),不做处理
+    }
+
     /*
      * MM/DD/YYYY To YYYY-MM-DD
      */