From 392a16648fb69ff60e21a3b342579772bfb39e07 Mon Sep 17 00:00:00 2001 From: rsgrinko Date: Thu, 2 Dec 2021 09:05:50 +0300 Subject: [PATCH 1/9] add comments --- test.php | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/test.php b/test.php index d6d2bd1..bdeb7f4 100644 --- a/test.php +++ b/test.php @@ -1,12 +1,11 @@ Date: Thu, 2 Dec 2021 14:04:42 +0300 Subject: [PATCH 2/9] add comments --- .vscode/c_cpp_properties.json | 19 ++++++++++++ inc/func.php | 58 +++++++++++++++++++++++++++-------- logout.php | 12 ++++---- 3 files changed, 71 insertions(+), 18 deletions(-) create mode 100644 .vscode/c_cpp_properties.json diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000..46cf7f4 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,19 @@ +{ + "configurations": [ + { + "name": "Win32", + "includePath": [ + "${workspaceFolder}/**" + ], + "defines": [ + "_DEBUG", + "UNICODE", + "_UNICODE" + ], + "cStandard": "c17", + "cppStandard": "c++17", + "intelliSenseMode": "windows-msvc-x64" + } + ], + "version": 4 +} \ No newline at end of file diff --git a/inc/func.php b/inc/func.php index ce6edc6..af3bb1b 100644 --- a/inc/func.php +++ b/inc/func.php @@ -1,11 +1,17 @@ '.print_r($arr, true).''; @@ -47,8 +62,12 @@ function pre($arr, $stop = false) { } } - -// проверка принадлежности пользователя к устройтсву +/** + * Проверка принадлежности пользователя к устройтсву + * + * @param int $deviceId + * @param int $userId + */ function isHaveAccessToDevice($deviceId, $userId){ global $DB; $arDevice = $DB->query('SELECT user FROM devices WHERE id="'.$deviceId.'"'); @@ -64,7 +83,9 @@ function isHaveAccessToDevice($deviceId, $userId){ } } -// получение ip пользователя +/** + * Получение ip пользователя + */ function getIp() { $keys = [ 'HTTP_CLIENT_IP', @@ -81,6 +102,9 @@ function getIp() { } } +/** + * Получение информации о клиенте + */ function getClientInfo() { $userAgent = strtolower($_SERVER['HTTP_USER_AGENT']); if (preg_match('/opera/', $userAgent)) { @@ -149,7 +173,13 @@ function getClientInfo() { 'ip' => $real_ip ); } - + +/** + * Получение устройств, принадлежащих пользователю + * + * @param int $userId + * @return array|bool + */ function getUserDevices($userId) { global $DB; $res = $DB->query('SELECT * FROM devices WHERE user="'.$userId.'"'); @@ -160,7 +190,11 @@ function getUserDevices($userId) { } } - +/** + * Получение ОС пользователя + * + * @return string + */ function getOS() { $userAgent = $_SERVER['HTTP_USER_AGENT']; $oses = [ diff --git a/logout.php b/logout.php index b93295b..29a1a4c 100644 --- a/logout.php +++ b/logout.php @@ -1,10 +1,10 @@ Date: Thu, 2 Dec 2021 14:09:24 +0300 Subject: [PATCH 3/9] add description into ajax files --- ajax/changeRelayState.php | 3 +++ ajax/getDallasData.php | 5 ++++- ajax/getRelayState.php | 3 +++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ajax/changeRelayState.php b/ajax/changeRelayState.php index 282b680..1ba1a84 100644 --- a/ajax/changeRelayState.php +++ b/ajax/changeRelayState.php @@ -1,4 +1,7 @@ Date: Thu, 2 Dec 2021 17:45:17 +0300 Subject: [PATCH 4/9] add comments --- inc/config.php | 56 ++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 43 insertions(+), 13 deletions(-) diff --git a/inc/config.php b/inc/config.php index 92c07b2..91c77d3 100644 --- a/inc/config.php +++ b/inc/config.php @@ -1,18 +1,48 @@ Date: Thu, 2 Dec 2021 17:46:43 +0300 Subject: [PATCH 5/9] add comments (master) --- inc/config.php | 56 ++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 43 insertions(+), 13 deletions(-) diff --git a/inc/config.php b/inc/config.php index 92c07b2..91c77d3 100644 --- a/inc/config.php +++ b/inc/config.php @@ -1,18 +1,48 @@ Date: Thu, 2 Dec 2021 17:52:02 +0300 Subject: [PATCH 6/9] add comments --- inc/lib/CCache.class.php | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/inc/lib/CCache.class.php b/inc/lib/CCache.class.php index 14b9e47..61d51c3 100644 --- a/inc/lib/CCache.class.php +++ b/inc/lib/CCache.class.php @@ -12,12 +12,12 @@ class CCache { /** - * @var $cache_dir Дирректория хранения файлов кэша + * @var string $cache_dir Директория хранения файлов кэша */ private static $cache_dir; /** - * @var int $quantity Количество оборащений к кэшу + * @var int $quantity Количество обращений к кэшу */ public static $quantity = 0; @@ -40,7 +40,7 @@ class CCache private static $class_author = 'Roman S Grinko (rsgrinko@gmail.com)'; private static $class_description = 'Класс для кэширования данных и работы с кэшэм'; - public static function classinfo() + public static function classinfo():array { $result = []; $result['VERSION'] = self::$class_version; @@ -55,7 +55,7 @@ class CCache * @param $dir Дирректория хранения файлов кэша * @param bool $enabled Флаг включения кэширования */ - public static function init($dir, $enabled = true) + public static function init($dir, $enabled = true):void { self::$cache_dir = $dir; self::$cache_enabled = $enabled; @@ -67,7 +67,7 @@ class CCache * @param $name Имя элемента кэша * @return bool Флаг наличия или отсутствия кэша */ - public static function checkCache($name) + public static function checkCache($name):bool { // Проверка наличия элемента в кэше if (!self::$cache_enabled) { return false; @@ -103,7 +103,7 @@ class CCache * @param $arValue Значение элемента кэша * @return bool Флаг успешной или неудачной записи данных */ - public static function writeCache($name, $arValue) + public static function writeCache($name, $arValue):bool { // Записать элемент в кэш if (!self::$cache_enabled) { return false; @@ -122,7 +122,7 @@ class CCache * * @return bool Флаг успеха */ - public static function clearCache() + public static function clearCache():bool { // Очистить кэш foreach (scandir(self::$cache_dir) as $file) { if ($file == '.' or $file == '..') continue; @@ -141,7 +141,7 @@ class CCache * @param $name Имя элемента кэша * @return bool Флаг успеха */ - public static function delFromCache($name) + public static function delFromCache($name):bool { // Удалить элемент из кэша if (self::checkCache($name)) { if (!unlink(self::$cache_dir . md5($name) . '.tmp')) { @@ -170,9 +170,10 @@ class CCache /** * Получение общего размера кэша в байтах - * @return false|int Размер кэша в байтах или false + * + * @return int Размер кэша в байтах или false */ - public static function getCacheSize() + public static function getCacheSize():int { // Получить размер кэша $return_size = 0; foreach (scandir(self::$cache_dir) as $file) { @@ -184,6 +185,7 @@ class CCache /** * Получение времени существованя кэша в секундах + * * @param $name Имя элемента кэша * @return false|int Время в секундах или false */ From aac4a3b9b70384a4210cffe89c786edcb3390e9b Mon Sep 17 00:00:00 2001 From: rsgrinko Date: Thu, 2 Dec 2021 17:57:10 +0300 Subject: [PATCH 7/9] add comments --- inc/lib/CPagination.class.php | 39 +++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/inc/lib/CPagination.class.php b/inc/lib/CPagination.class.php index bdce96f..8b58f44 100644 --- a/inc/lib/CPagination.class.php +++ b/inc/lib/CPagination.class.php @@ -1,10 +1,10 @@ $value){ $url .= $key.'='.$value.'&'; From 0b0c1e508a13c451f991142e129e2d19bb60b2b5 Mon Sep 17 00:00:00 2001 From: rsgrinko Date: Thu, 2 Dec 2021 17:58:03 +0300 Subject: [PATCH 8/9] fix --- inc/bootstrap.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/inc/bootstrap.php b/inc/bootstrap.php index abbb816..e70a25d 100644 --- a/inc/bootstrap.php +++ b/inc/bootstrap.php @@ -1,14 +1,14 @@ Date: Thu, 2 Dec 2021 18:01:12 +0300 Subject: [PATCH 9/9] fix --- inc/lib/CIoT.class.php | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/inc/lib/CIoT.class.php b/inc/lib/CIoT.class.php index f3c3cea..755b2de 100644 --- a/inc/lib/CIoT.class.php +++ b/inc/lib/CIoT.class.php @@ -1,10 +1,10 @@ query('SELECT id FROM devices WHERE mac="'.$mac.'"'); if($result) { return true; @@ -34,7 +48,12 @@ class CIoT { } } - public static function getDeviceId($mac){ + + /** + * Получение идентификатора устройства по мак адресу + */ + public static function getDeviceId($mac) + { $result = self::$DB->query('SELECT id FROM devices WHERE mac="'.$mac.'"'); if($result) { return $result[0]['id'];