From 9c029c5b1163076059297dcf0f1cf8a6f96920bb Mon Sep 17 00:00:00 2001 From: rsgrinko Date: Fri, 17 Dec 2021 14:58:32 +0300 Subject: [PATCH] =?UTF-8?q?[+]=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=20=D0=BF=D0=BE=D0=BB=D1=8C=D0=B7=D0=BE=D0=B2=D0=B0?= =?UTF-8?q?=D1=82=D0=B5=D0=BB=D1=8C=20=D0=A1=D0=98=D0=A1=D0=A2=D0=95=D0=9C?= =?UTF-8?q?=D0=90=20=D0=B4=D0=BB=D1=8F=20=D0=BD=D0=BE=D0=B2=D1=8B=D1=85=20?= =?UTF-8?q?=D0=BF=D0=BB=D0=B0=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- inc/config.php | 5 +++++ inc/lib/CIoT.class.php | 2 +- inc/lib/CUser.class.php | 6 +++--- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/inc/config.php b/inc/config.php index 16894eb..7f148dc 100644 --- a/inc/config.php +++ b/inc/config.php @@ -57,6 +57,11 @@ define('DB_PASSWORD', '2670135'); */ define('DB_NAME', 'rsgrinko_iotcore'); +/** + * ID системного пользователя + */ +define('SYSTEM_USER_ID', 10); + /** * Количество элементов, выводимых на страницу (для пагинации) */ diff --git a/inc/lib/CIoT.class.php b/inc/lib/CIoT.class.php index 2cca7c8..6d0ae98 100644 --- a/inc/lib/CIoT.class.php +++ b/inc/lib/CIoT.class.php @@ -73,7 +73,7 @@ class CIoT { * @param $fw */ public static function addDevice($mac, $chipid, $hw, $fw):void { - self::$DB->addItem('devices', array('mac' => $mac, 'chipid' => $chipid, 'hw' => $hw, 'fw' => $fw, 'user' => 'SYSTEM', 'time' => time(), 'last_active' => time())); + self::$DB->addItem('devices', array('mac' => $mac, 'chipid' => $chipid, 'hw' => $hw, 'fw' => $fw, 'user' => SYSTEM_USER_ID, 'time' => time(), 'last_active' => time())); $deviceId = self::getDeviceId($mac); self::$DB->addItem('relays', array('device' => $deviceId, 'relay1' => '0', 'relay2' => '0', 'relay3' => '0', 'relay4' => '0')); self::$DB->addItem('configs', array('device' => $deviceId, 'ds_resulution' => '9', 'sending_interval' => '2000')); diff --git a/inc/lib/CUser.class.php b/inc/lib/CUser.class.php index 78a1546..092b060 100644 --- a/inc/lib/CUser.class.php +++ b/inc/lib/CUser.class.php @@ -61,15 +61,15 @@ class CUser { * @param int $id * @return array|bool */ - public static function getFields($id = ''){ - if(empty($id) or $id == ''){ + public static function getFields($id = false){ + if(empty($id) or $id === false){ $id = self::$id; } if(is_array($id)){ $where = $id; } else { - $where = array('id'=>$id); + $where = array('id' => $id); } $result = self::$DB->getItem(self::$table, $where); if($result) {