Dmitriev Roman 3 bulan lalu
induk
melakukan
4084658fe7

+ 7 - 7
docs/databases/postgres/en/create_db.sql

@@ -107,7 +107,7 @@ firmware VARCHAR(100),
 vendor_id INTEGER NOT NULL DEFAULT 1,
 device_name VARCHAR(50),
 building_id INTEGER NOT NULL DEFAULT 1,
-ip INET,
+ip INET DEFAULT NULL,
 ip_int BIGINT,
 login VARCHAR(50),
 password VARCHAR(255),
@@ -219,7 +219,7 @@ CREATE TABLE dhcp_log (
 id BIGSERIAL PRIMARY KEY,
 mac MACADDR NOT NULL,
 ip_int BIGINT NOT NULL,
-ip INET NOT NULL,
+ip INET DEFAULT NULL,
 action VARCHAR(10) NOT NULL,
 ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
 auth_id BIGINT NOT NULL,
@@ -236,7 +236,7 @@ COMMENT ON COLUMN dhcp_log.circuit_id IS 'DHCP option 82 circuit ID';
 CREATE TABLE dhcp_queue (
 id BIGSERIAL PRIMARY KEY,
 mac MACADDR NOT NULL,
-ip INET NOT NULL,
+ip INET DEFAULT NULL,
 action VARCHAR(10) NOT NULL,
 ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
 dhcp_hostname VARCHAR(250)
@@ -325,7 +325,7 @@ mac VARCHAR(12),
 ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
 device_id BIGINT,
 port_id BIGINT,
-ip VARCHAR(16) NOT NULL DEFAULT '',
+ip INET DEFAULT NULL,
 auth_id BIGINT,
 dhcp_hostname VARCHAR(250)
 );
@@ -381,7 +381,7 @@ CREATE TABLE remote_syslog (
 id BIGSERIAL PRIMARY KEY,
 ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
 device_id BIGINT NOT NULL,
-ip VARCHAR(15) NOT NULL,
+ip INET DEFAULT NULL,
 message TEXT NOT NULL
 );
 COMMENT ON TABLE remote_syslog IS 'Syslog messages from network devices';
@@ -457,7 +457,7 @@ CREATE TABLE user_auth (
 id SERIAL PRIMARY KEY,
 user_id BIGINT NOT NULL DEFAULT 0,
 ou_id INTEGER,
-ip VARCHAR(18) NOT NULL DEFAULT '',
+ip INET DEFAULT NULL,
 ip_int BIGINT NOT NULL DEFAULT 0,
 save_traf SMALLINT NOT NULL DEFAULT 0,
 enabled SMALLINT NOT NULL DEFAULT 0,
@@ -620,7 +620,7 @@ id BIGSERIAL PRIMARY KEY,
 ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
 auth_id BIGINT NOT NULL DEFAULT 0,
 customer VARCHAR(50) NOT NULL DEFAULT 'system',
-ip VARCHAR(18) NOT NULL DEFAULT '127.0.0.1',
+ip INET NOT NULL DEFAULT '127.0.0.1',
 message TEXT NOT NULL,
 level SMALLINT NOT NULL DEFAULT 1
 );

+ 7 - 7
docs/databases/postgres/ru/create_db.sql

@@ -107,7 +107,7 @@ firmware VARCHAR(100),
 vendor_id INTEGER NOT NULL DEFAULT 1,
 device_name VARCHAR(50),
 building_id INTEGER NOT NULL DEFAULT 1,
-ip INET,
+ip INET DEFAULT NULL,
 ip_int BIGINT,
 login VARCHAR(50),
 password VARCHAR(255),
@@ -219,7 +219,7 @@ CREATE TABLE dhcp_log (
 id BIGSERIAL PRIMARY KEY,
 mac MACADDR NOT NULL,
 ip_int BIGINT NOT NULL,
-ip INET NOT NULL,
+ip INET DEFAULT NULL,
 action VARCHAR(10) NOT NULL,
 ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
 auth_id BIGINT NOT NULL,
@@ -236,7 +236,7 @@ COMMENT ON COLUMN dhcp_log.circuit_id IS 'DHCP опция 82 circuit ID';
 CREATE TABLE dhcp_queue (
 id BIGSERIAL PRIMARY KEY,
 mac MACADDR NOT NULL,
-ip INET NOT NULL,
+ip INET DEFAULT NULL,
 action VARCHAR(10) NOT NULL,
 ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
 dhcp_hostname VARCHAR(250)
@@ -325,7 +325,7 @@ mac VARCHAR(12),
 ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
 device_id BIGINT,
 port_id BIGINT,
-ip VARCHAR(16) NOT NULL DEFAULT '',
+ip INET DEFAULT NULL,
 auth_id BIGINT,
 dhcp_hostname VARCHAR(250)
 );
@@ -381,7 +381,7 @@ CREATE TABLE remote_syslog (
 id BIGSERIAL PRIMARY KEY,
 ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
 device_id BIGINT NOT NULL,
-ip VARCHAR(15) NOT NULL,
+ip INET DEFAULT NULL,
 message TEXT NOT NULL
 );
 COMMENT ON TABLE remote_syslog IS 'Syslog сообщения от сетевых устройств';
@@ -457,7 +457,7 @@ CREATE TABLE user_auth (
 id SERIAL PRIMARY KEY,
 user_id BIGINT NOT NULL DEFAULT 0,
 ou_id INTEGER,
-ip VARCHAR(18) NOT NULL DEFAULT '',
+ip INET DEFAULT NULL,
 ip_int BIGINT NOT NULL DEFAULT 0,
 save_traf SMALLINT NOT NULL DEFAULT 0,
 enabled SMALLINT NOT NULL DEFAULT 0,
@@ -617,7 +617,7 @@ id BIGSERIAL PRIMARY KEY,
 ts TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
 auth_id BIGINT NOT NULL DEFAULT 0,
 customer VARCHAR(50) NOT NULL DEFAULT 'system',
-ip VARCHAR(18) NOT NULL DEFAULT '127.0.0.1',
+ip INET NOT NULL DEFAULT '127.0.0.1',
 message TEXT NOT NULL,
 level SMALLINT NOT NULL DEFAULT 1
 );

+ 5 - 5
html/admin/devices/edit_gw_instances.php

@@ -4,15 +4,15 @@ require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/idfilter.php");
 
-$device=get_record($db_link,'devices',"id=".$id);
-$user_info = get_record_sql($db_link,"SELECT * FROM user_list WHERE id=".$device['user_id']);
+$device=get_record($db_link,'devices',"id=?", [$id]);
+$user_info = get_record_sql($db_link,"SELECT * FROM user_list WHERE id=?", [$device['user_id']]);
 
 if (isset($_POST["s_remove"])) {
     $s_id = $_POST["gs_id"];
     foreach ($s_id as $key => $val) {
         if (isset($val)) {
-            LOG_INFO($db_link, "Remove filter instances from gateway id: $val ". dump_record($db_link,'device_filter_instances','id='.$val));
-            delete_record($db_link, "device_filter_instances", "id=" . $val);
+            LOG_INFO($db_link, "Remove filter instances from gateway id: $val ". dump_record($db_link,'device_filter_instances','id=?',[$val]));
+            delete_record($db_link, "device_filter_instances", "id=?", [$val]);
         }
     }
     header("Location: " . $_SERVER["REQUEST_URI"]);
@@ -57,7 +57,7 @@ print_url($device['device_name'],"/admin/devices/editdevice.php?id=$id"); ?>
         </td>
 </tr>
 <?php
-$gateway_instances = get_records_sql($db_link,'SELECT device_filter_instances.*,filter_instances.name,filter_instances.description FROM device_filter_instances LEFT JOIN filter_instances ON device_filter_instances.instance_id = filter_instances.id WHERE device_filter_instances.device_id='.$id);
+$gateway_instances = get_records_sql($db_link,'SELECT device_filter_instances.*,filter_instances.name,filter_instances.description FROM device_filter_instances LEFT JOIN filter_instances ON device_filter_instances.instance_id = filter_instances.id WHERE device_filter_instances.device_id=?',[ $id ]);
 foreach ( $gateway_instances as $row ) {
     print "<tr align=center>\n";
     print "<td class=\"data\" style='padding:0' width=30><input type=checkbox name=gs_id[] value='{$row['id']}'></td>\n";

+ 5 - 5
html/admin/devices/edit_gw_subnets.php

@@ -4,15 +4,15 @@ require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/idfilter.php");
 
-$device=get_record($db_link,'devices',"id=".$id);
-$user_info = get_record_sql($db_link,"SELECT * FROM user_list WHERE id=".$device['user_id']);
+$device=get_record($db_link,'devices',"id=?", [$id]);
+$user_info = get_record_sql($db_link,"SELECT * FROM user_list WHERE id=?", [$device['user_id']]);
 
 if (isset($_POST["s_remove"])) {
     $s_id = $_POST["gs_id"];
     foreach ($s_id as $key => $val) {
         if (isset($val)) {
-            LOG_INFO($db_link, "Remove subnet from gateway id: $val ". dump_record($db_link,'gateway_subnets','id='.$val));
-            delete_record($db_link, "gateway_subnets", "id=" . $val);
+            LOG_INFO($db_link, "Remove subnet from gateway id: $val ". dump_record($db_link,'gateway_subnets','id=?',[$val]));
+            delete_record($db_link, "gateway_subnets", "id=?" , [ $val ]);
         }
     }
     header("Location: " . $_SERVER["REQUEST_URI"]);
@@ -55,7 +55,7 @@ print_url($device['device_name'],"/admin/devices/editdevice.php?id=$id"); ?>
         </td>
 </tr>
 <?php
-$gateway_subnets = get_records_sql($db_link,'SELECT gateway_subnets.*,subnets.subnet,subnets.description FROM gateway_subnets LEFT JOIN subnets ON gateway_subnets.subnet_id = subnets.id WHERE gateway_subnets.device_id='.$id);
+$gateway_subnets = get_records_sql($db_link,'SELECT gateway_subnets.*,subnets.subnet,subnets.description FROM gateway_subnets LEFT JOIN subnets ON gateway_subnets.subnet_id = subnets.id WHERE gateway_subnets.device_id=?', [$id]);
 foreach ( $gateway_subnets as $row ) {
     print "<tr align=center>\n";
     print "<td class=\"data\" style='padding:0' width=30><input type=checkbox name=gs_id[] value='{$row['id']}'></td>\n";

+ 10 - 9
html/admin/devices/edit_l3int.php

@@ -4,17 +4,17 @@ require_once ($_SERVER['DOCUMENT_ROOT']."/inc/auth.php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/languages/" . HTML_LANG . ".php");
 require_once ($_SERVER['DOCUMENT_ROOT']."/inc/idfilter.php");
 
-$device = get_record($db_link,'devices',"id=".$id);
+$device = get_record($db_link,'devices',"id=?",[$id]);
 $snmp=getSnmpAccess($device);
-$user_info = get_record_sql($db_link,"SELECT * FROM user_list WHERE id=".$device['user_id']);
+$user_info = get_record_sql($db_link,"SELECT * FROM user_list WHERE id=?",[$device['user_id']]);
 $int_list = getIpAdEntIfIndex($db_link,$device['ip'],$snmp);
 
 if (isset($_POST["s_remove"])) {
     $s_id = $_POST["s_id"];
     foreach ($s_id as $key => $val) {
         if (isset($val)) {
-            LOG_INFO($db_link, "Remove l3_interface id: $val ". dump_record($db_link,'device_l3_interfaces','id='.$val));
-            delete_record($db_link, "device_l3_interfaces", "id=" . $val);
+            LOG_INFO($db_link, "Remove l3_interface id: $val ". dump_record($db_link,'device_l3_interfaces','id=?',[$val]));
+            delete_record($db_link, "device_l3_interfaces", "id=?", [$val]);
         }
     }
     header("Location: " . $_SERVER["REQUEST_URI"]);
@@ -29,7 +29,7 @@ if (isset($_POST['s_save'])) {
         for ($j = 0; $j < $len_all; $j ++) {
             if (intval($_POST['n_id'][$j]) != $save_id) { continue; }
             $new['interface_type'] = $_POST['s_type'][$j]*1;
-            update_record($db_link, "device_l3_interfaces", "id='{$save_id}'", $new);
+            update_record($db_link, "device_l3_interfaces", "id=?", $new, [$save_id]);
         }
     }
     header("Location: " . $_SERVER["REQUEST_URI"]);
@@ -73,7 +73,8 @@ print_editdevice_submenu($page_url,$id,$device['device_type'],$user_info['login'
 	</td>
 </tr>
 <?php
-$t_l3_interface = get_records($db_link,'device_l3_interfaces',"device_id=$id ORDER BY name");
+
+$t_l3_interface = get_records_sql($db_link,"SELECT * FROM device_l3_interfaces WHERE device_id=? ORDER BY name", [ $id ]);
 
 $int_by_name = [];
 foreach ($int_list as $row) { 
@@ -88,7 +89,7 @@ foreach ( $t_l3_interface as $row ) {
     if (empty($row['snmpin']) and !empty($int_by_name[$row['name']])) {
         $fix['snmpin']=$int_by_name[$row['name']]['index'];
         if (!empty($fix)) {
-            update_record($db_link,'device_l3_interfaces','id='.$row['id'],$fix);
+            update_record($db_link,'device_l3_interfaces','id=?',$fix, [ $row['id'] ]);
             }
         $fixed = 1;
         }
@@ -100,14 +101,14 @@ foreach ( $t_l3_interface as $row ) {
     if (!empty($int_list[$row['snmpin']]) and $int_list[$row['snmpin']]['name'] !== $row['name']) {
         $fix['name']=$int_list[$row['snmpin']]['name'];
         if (!empty($fix)) {
-            update_record($db_link,'device_l3_interfaces','id='.$row['id'],$fix);
+            update_record($db_link,'device_l3_interfaces','id=?', $fix, [$row['id']]);
             }
         $fixed = 1;
         }
     }
 
 if ($fixed) {
-    $t_l3_interface = get_records($db_link,'device_l3_interfaces',"device_id=$id ORDER BY name");
+    $t_l3_interface = get_records_sql($db_link,"SELECT * FROM device_l3_interfaces WHERE device_id=? ORDER BY name", [ $id ]);
     }
 
 foreach ( $t_l3_interface as $row ) {

+ 10 - 10
html/admin/devices/editdevice.php

@@ -9,8 +9,8 @@ if (isset($_POST["editdevice"]) and isset($id)) {
     } else {
         $sw_ports = 0;
     }
-    $sSQL = "SELECT count(id) from device_ports WHERE device_ports.device_id=$id";
-    $$d_ports = get_single_field($db_link,$sSQL);
+    $sSQL = "SELECT count(id) from device_ports WHERE device_ports.device_id=?";
+    $$d_ports = get_single_field($db_link,$sSQL, [$id]);
     if ($d_ports != $sw_ports) {
         LOG_DEBUG($db_link, "Device id: $id changed port count!");
         if ($sw_ports > $d_ports) {
@@ -26,10 +26,10 @@ if (isset($_POST["editdevice"]) and isset($id)) {
         if ($sw_ports < $d_ports) {
             LOG_DEBUG($db_link, "Device id: $id remove connection for port from $d_ports to $sw_ports");
             for ($port = $d_ports; $port > $sw_ports; $port--) {
-                $port_id = get_id_record($db_link, 'device_ports', "device_id='" . $id . "' and port='" . $port . "'");
+                $port_id = get_id_record($db_link, 'device_ports', "device_id=? and port=?", [ $id, $port ]);
                 if ($port_id) {
-                    delete_record($db_link, "device_ports", "id='" . $port_id . "'");
-                    run_sql($db_link, "DELETE FROM connections WHERE port_id='" . $port_id . "'");
+                    delete_record($db_link, "device_ports", "id=?" ,[ $port_id ]);
+                    run_sql($db_link, "DELETE FROM connections WHERE port_id=?", [ $port_id ]);
                 } else {
                     LOG_DEBUG($db_link, "Device id: $id port_id not found for port: $port!");
                 }
@@ -41,10 +41,10 @@ if (isset($_POST["editdevice"]) and isset($id)) {
         $new['ip'] = $_POST["f_ip"];
         $new['ip_int'] = ip2long($new['ip']);
     }
-    $cur_device = get_record_sql($db_link, "SELECT * FROM devices WHERE id=" . $id);
+    $cur_device = get_record_sql($db_link, "SELECT * FROM devices WHERE id=?", [ $id ]);
     //main device info
     if (!empty($new['ip'])) {
-        $cur_auth = get_record_sql($db_link, "SELECT * FROM user_auth WHERE deleted=0 AND ip='" . $new['ip'] . "'");
+        $cur_auth = get_record_sql($db_link, "SELECT * FROM user_auth WHERE deleted=0 AND ip=?",[ $new['ip'] ]);
     }
     if (isset($_POST["f_device_model_id"])) {
         $new['device_model_id'] = $_POST["f_device_model_id"] * 1;
@@ -158,13 +158,13 @@ if (isset($_POST["editdevice"]) and isset($id)) {
         $new['user_acl'] = 0;
     }
 
-    update_record($db_link, "devices", "id='$id'", $new);
+    update_record($db_link, "devices", "id=?", $new, [ $id ]);
     header("Location: " . $_SERVER["REQUEST_URI"]);
     exit;
 }
 
-$device = get_record($db_link, 'devices', "id=" . $id);
-$user_info = get_record_sql($db_link, "SELECT * FROM user_list WHERE id=" . $device['user_id']);
+$device = get_record($db_link, 'devices', "id=?" ,[ $id]);
+$user_info = get_record_sql($db_link, "SELECT * FROM user_list WHERE id=?", [ $device['user_id'] ]);
 unset($_POST);
 
 require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/header.php");

+ 4 - 4
html/admin/devices/editport.php

@@ -9,7 +9,7 @@ if (isset($_POST["editport"])) {
     $new['nagios'] = $_POST["f_nagios"] * 1;
     $new['skip'] = $_POST["f_skip"] * 1;
     $new['description'] = $_POST["f_description"];
-    update_record($db_link, "device_ports", "id='$id'", $new);
+    update_record($db_link, "device_ports", "id=?", $new, [ $id ]);
 
     $target_id = $_POST["f_target_port"];
     bind_ports($db_link, $id, $target_id);
@@ -20,10 +20,10 @@ if (isset($_POST["editport"])) {
 
 unset($_POST);
 
-$port = get_record($db_link, 'device_ports', "id=" . $id);
+$port = get_record($db_link, 'device_ports', "id=?" ,[ $id]);
 $device_id = $port['device_id'];
-$device = get_record($db_link, 'devices', "id=" . $device_id);
-$user_info = get_record_sql($db_link, "SELECT * FROM user_list WHERE id=" . $device['user_id']);
+$device = get_record($db_link, 'devices', "id=?" , [ $device_id ]);
+$user_info = get_record_sql($db_link, "SELECT * FROM user_list WHERE id=?", [ $device['user_id'] ]);
 
 require_once($_SERVER['DOCUMENT_ROOT'] . "/inc/header.php");
 

+ 22 - 9
html/admin/devices/index-passive.php

@@ -15,6 +15,8 @@ $unknown=1;
 if (!isset($_POST['f_unknown']) and isset($_POST['OK'])) { $unknown=0; }
 if (isset($_POST['f_unknown'])) { $unknown=$_POST['f_unknown']*1; }
 
+$params =[];
+
 $unknown_checked='';
 if ($unknown) { $unknown_checked='checked="checked"'; }
 
@@ -25,16 +27,23 @@ if ($sort_field == 'model_name') { $sort_table = 'M'; }
 
 $sort_url = "<a href=index-passive.php?ou=" . $rou;
 
-if ($rou == 0) { $ou_filter = ''; } else { $ou_filter = " and L.ou_id=$rou "; }
+if ($rou == 0) { $ou_filter = ''; } else { $ou_filter = " and L.ou_id=? "; $params[]=$rou; }
 
 if ($rsubnet == 0) { $subnet_filter = ''; } else {
     $subnet_range = get_subnet_range($db_link,$rsubnet);
-    if (!empty($subnet_range)) { $subnet_filter = " and A.ip_int>=".$subnet_range['start']." and A.ip_int<=".$subnet_range['stop']; }
+    if (!empty($subnet_range)) { 
+        $subnet_filter = " and A.ip_int>=? and A.ip_int<=?";
+        $params[]=$subnet_range['start'];
+        $params[]=$subnet_range['stop'];
+        }
     }
 
 $d_filter='';
-if ($f_building_id > 0) { $d_filter .= ' and D.building_id=' . $f_building_id; }
-if ($f_devtype_id > 0) { $d_filter .= ' and D.device_type=' . $f_devtype_id; } else { $d_filter .= ' and D.device_type>2'; }
+if ($f_building_id > 0) { $d_filter .= ' and D.building_id=?'; $params[]=$f_building_id; }
+if ($f_devtype_id > 0) { 
+    $d_filter .= ' and D.device_type=?'; 
+    $params[]= $f_devtype_id;
+    } else { $d_filter .= ' and D.device_type>2'; }
 
 $ip_list_filter = $ou_filter.$subnet_filter;
 
@@ -105,14 +114,15 @@ print_device_submenu($page_url);
 $u_filter='';
 if ($unknown and $f_vendor_select==0) { $u_filter=' AND V.id<>1 '; } else {
     if (!empty($f_vendor_select) and $f_vendor_select>=1) {
-        $u_filter = " AND V.id=".$f_vendor_select." ";
+        $u_filter = " AND V.id=? ";
+        $params[]=$f_vendor_select;
         }
     }
 
 $countSQL="SELECT Count(*) FROM user_auth A, user_list L, devices D, device_models M, vendors V
 WHERE D.user_id=L.id AND A.ip = D.ip AND D.device_model_id=M.id AND M.vendor_id=V.id AND A.deleted =0
 $u_filter $ip_list_filter $d_filter";
-$count_records = get_single_field($db_link,$countSQL);
+$count_records = get_single_field($db_link,$countSQL, $params);
 $total=ceil($count_records/$displayed);
 if ($page>$total) { $page=$total; }
 if ($page<1) { $page=1; }
@@ -140,9 +150,12 @@ $sSQL = "SELECT A.id, D.id as dev_id, D.device_type, A.ip, A.mac, A.user_id, L.l
 FROM user_auth A, user_list L, devices D, device_models M, vendors V
 WHERE D.user_id=L.id AND A.ip = D.ip AND D.device_model_id=M.id AND M.vendor_id=V.id AND A.deleted =0
 $u_filter $ip_list_filter $d_filter
-ORDER BY $sort_table.$sort_field $order LIMIT $displayed OFFSET $start";
-
-$users = get_records_sql($db_link,$sSQL);
+ORDER BY $sort_table.$sort_field $order LIMIT ? OFFSET ?";
+$params[]=$displayed;
+$params[]=$start;
+var_dump($sSQL);
+die;
+$users = get_records_sql($db_link,$sSQL, $params);
 foreach ($users as $user) {
     if ($user['last_found'] == '0000-00-00 00:00:00') { $user['last_found'] = ''; }
     print "<tr align=center>\n";

+ 3 - 3
html/inc/sql.php

@@ -621,12 +621,12 @@ function get_single_field($db, $sql, $params = []) {
 /**
  * Получить ID записи из таблицы по фильтру
  */
-function get_id_record($db, $table, $filter) {
+function get_id_record($db, $table, $filter, $params=[]) {
     if (empty($filter)) {
         return 0;
     }
     
-    $record = get_record($db, $table, $filter);
+    $record = get_record($db, $table, $filter, $params);
     return !empty($record['id']) ? $record['id'] : 0;
 }
 
@@ -915,7 +915,7 @@ function update_record($db, $table, $filter, $newvalue, $filter_params = [])
             return;
             }
         if ($table !== "sessions") {
-            LOG_VERBOSE($db, "Change table $table WHERE $filter set $changed_log");
+            LOG_VERBOSE($db, "Change table $table WHERE $filter set $changed_log | params: " . json_encode($filter_params, JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES));
             }
         return $sql_result;
     } catch (PDOException $e) {