Skip to content

Commit 2c4a749

Browse files
committed
Code style
1 parent b9e6387 commit 2c4a749

File tree

9 files changed

+242
-236
lines changed

9 files changed

+242
-236
lines changed

modules/commands/commands.class.php

+1
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ function run()
168168
function admin(&$out)
169169
{
170170

171+
$out['VISIBLE_DELAYS'] = 0;
171172
global $ajax;
172173
if ($ajax) {
173174

modules/control_modules/control_modules.class.php

+42-41
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ function run()
6161
global $mode2;
6262
$rec = SQLSelectOne("SELECT * FROM project_modules WHERE NAME='" . $name . "'");
6363
$rec['NAME'] = $name;
64-
64+
6565
if ($mode2 == "update") {
6666
global $title;
6767
global $category;
@@ -127,52 +127,53 @@ function run()
127127
}
128128
$this->redirect("?");
129129
}
130-
131-
if(preg_match('|<#(.*?)#>|si', $rec['TITLE'], $arr)) {
132-
$rec['TITLE'] = constant($arr[1]);
133-
} else {
134-
$rec['TITLE'] = $rec['TITLE'];
135-
}
136-
130+
131+
if (preg_match('|<#(.*?)#>|si', $rec['TITLE'], $arr)) {
132+
$rec['TITLE'] = constant($arr[1]);
133+
} else {
134+
$rec['TITLE'] = $rec['TITLE'];
135+
}
136+
137137
outHash($rec, $out);
138-
139-
//Получим конфиг модуля
140-
141-
include_once(DIR_MODULES . $name . '/' . $name . '.class.php');
142-
$module = new $name();
143-
144-
$genConfig = [];
145-
$iter = 0;
146-
147-
$config = $this->getConfig();
148-
if (is_array($config)) {
149-
foreach($config as $key => $value) {
138+
139+
//Получим конфиг модуля
140+
141+
include_once(DIR_MODULES . $name . '/' . $name . '.class.php');
142+
$module = new $name();
143+
144+
$genConfig = [];
145+
$iter = 0;
146+
147+
$config = $this->getConfig();
148+
if (is_array($config)) {
149+
foreach ($config as $key => $value) {
150150
$genConfig[$iter]['KEY'] = $key;
151151
$genConfig[$iter]['VALUE'] = $value;
152152
$iter++;
153153
}
154154

155155
}
156156

157-
$out['MODULE_CONFIG'] = $genConfig;
158-
159-
//Выгружаем инфо из коннекта
160-
$marketInfo = file_get_contents("https://connect.smartliving.ru/market/?op=list&search=".urlencode($rec['TITLE']));
161-
$marketInfo = json_decode($marketInfo, TRUE);
162-
$marketInfo = $marketInfo["PLUGINS"][0];
163-
164-
if(is_array($marketInfo)) {
165-
$out['MARKET_ID'] = $marketInfo['ID'];
166-
$out['MARKET_REPOSITORY_URL'] = $marketInfo['REPOSITORY_URL'];
167-
$out['MARKET_AUTHOR'] = $marketInfo['AUTHOR'];
168-
$out['MARKET_SUPPORT_URL'] = $marketInfo['SUPPORT_URL'];
169-
$out['MARKET_DESCRIPTION_RU'] = $marketInfo['DESCRIPTION_RU'];
170-
$out['MARKET_LATEST_VERSION'] = $marketInfo['LATEST_VERSION'];
171-
$out['MARKET_PRICE'] = $marketInfo['PRICE'];
172-
$out['MARKET_URL'] = $marketInfo['URL'];
173-
$out['MARKET_LATEST_VERSION_COMMENT'] = $marketInfo['LATEST_VERSION_COMMENT'];
174-
$out['MARKET_LATEST_VERSION_URL'] = $marketInfo['LATEST_VERSION_URL'];
175-
}
157+
$out['MODULE_CONFIG'] = $genConfig;
158+
159+
$url = "https://connect.smartliving.ru/market/?op=list&search=" . urlencode($rec['TITLE']);
160+
$marketInfo = file_get_contents($url);
161+
$marketInfo = json_decode($marketInfo, TRUE);
162+
if (isset($marketInfo["PLUGINS"][0])) {
163+
$marketInfo = $marketInfo["PLUGINS"][0];
164+
if (is_array($marketInfo)) {
165+
$out['MARKET_ID'] = $marketInfo['ID'];
166+
$out['MARKET_REPOSITORY_URL'] = $marketInfo['REPOSITORY_URL'];
167+
$out['MARKET_AUTHOR'] = $marketInfo['AUTHOR'];
168+
$out['MARKET_SUPPORT_URL'] = $marketInfo['SUPPORT_URL'];
169+
$out['MARKET_DESCRIPTION_RU'] = $marketInfo['DESCRIPTION_RU'];
170+
$out['MARKET_LATEST_VERSION'] = $marketInfo['LATEST_VERSION'];
171+
$out['MARKET_PRICE'] = $marketInfo['PRICE'];
172+
$out['MARKET_URL'] = $marketInfo['URL'];
173+
$out['MARKET_LATEST_VERSION_COMMENT'] = $marketInfo['LATEST_VERSION_COMMENT'];
174+
$out['MARKET_LATEST_VERSION_URL'] = $marketInfo['LATEST_VERSION_URL'];
175+
}
176+
}
176177
}
177178

178179
if ($mode == 'repository_uninstall') {
@@ -188,11 +189,11 @@ function run()
188189

189190
for ($i = 0; $i < $lstCnt; $i++) {
190191
$rec = SQLSelectOne("SELECT *, DATE_FORMAT(ADDED, '%d.%m.%Y %H:%i') AS DAT FROM project_modules WHERE NAME='" . $lst[$i]['FILENAME'] . "'");
191-
if (IsSet($rec['ID'])) {
192+
if (isset($rec['ID'])) {
192193
outHash($rec, $lst[$i]);
193194
}
194195
$ignored = SQLSelectOne("SELECT ID FROM ignore_updates WHERE NAME LIKE '" . DBSafe($lst[$i]['NAME']) . "'");
195-
if ($ignored['ID']) {
196+
if (isset($ignored['ID'])) {
196197
$lst[$i]['IGNORED'] = 1;
197198
}
198199
}

modules/devices/devices.class.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,13 @@ function link(&$out)
149149
$out['PREFIX'] = $this->prefix;
150150
}
151151

152-
if ($this->add_title) {
152+
if (isset($this->add_title)) {
153153
$out['ADD_TITLE'] = urlencode($this->add_title);
154154
}
155155

156156
if ($this->linked_object) {
157157
$device_rec = SQLSelectOne("SELECT ID,TITLE FROM devices WHERE LINKED_OBJECT LIKE '" . DBSafe($this->linked_object) . "'");
158-
if ($device_rec['TITLE']) {
158+
if (isset($device_rec['TITLE'])) {
159159
$out['TITLE'] = $device_rec['TITLE'];
160160
if ($this->preview) {
161161
$data = $this->processDevice($device_rec['ID']);

modules/devices/devices_edit.inc.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
$out['NO_NAV'] = 1;
1515
}
1616

17-
if ($rec['LINKED_OBJECT'] != '') {
17+
if (isset($rec['LINKED_OBJECT']) && $rec['LINKED_OBJECT'] != '') {
1818
$object_rec = SQLSelectOne("SELECT ID FROM objects WHERE TITLE='" . $rec['LINKED_OBJECT'] . "'");
1919
if ($object_rec['ID']) {
2020
$properties = SQLSelect("SELECT pvalues.*, properties.TITLE as PROPERTY FROM pvalues LEFT JOIN properties ON properties.ID=pvalues.PROPERTY_ID WHERE pvalues.OBJECT_ID=" . $object_rec['ID'] . " AND pvalues.LINKED_MODULES!='' ORDER BY UPDATED DESC");
@@ -524,7 +524,7 @@
524524
}
525525
}
526526

527-
if (!$rec['LOCATION_ID']) {
527+
if (!isset($rec['LOCATION_ID'])) {
528528
$rec['LOCATION_ID'] = gr('location_id', 'int');
529529
}
530530

@@ -537,7 +537,7 @@
537537
if (isset($v['TITLE'])) {
538538
$types[] = array('NAME' => $k, 'TITLE' => $v['TITLE']);
539539
}
540-
if ($k == $rec['TYPE'] && $rec['TYPE'] != '') {
540+
if (isset($rec['TYPE']) && $k == $rec['TYPE'] && $rec['TYPE'] != '') {
541541
$out['TYPE_TITLE'] = $v['TITLE'];
542542
}
543543
}

modules/objects/objects.class.php

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ function __construct()
2626
$this->title = "<#LANG_MODULE_OBJECT_INSTANCES#>";
2727
$this->module_category = "<#LANG_SECTION_OBJECTS#>";
2828
$this->checkInstalled();
29+
$this->id = '';
2930
}
3031

3132
/**

modules/objects/objects_edit.inc.php

+18-12
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@
1010
$table_name = 'objects';
1111
$rec = SQLSelectOne("SELECT * FROM $table_name WHERE ID='$id'");
1212

13-
$device_rec = SQLSelectOne("SELECT * FROM devices WHERE LINKED_OBJECT='" . $rec['TITLE'] . "'");
14-
if (isset($device_rec['ID'])) {
15-
$out['DEVICE_ID'] = $device_rec['ID'];
16-
$out['DEVICE_TITLE'] = $device_rec['TITLE'];
13+
if (isset($rec['TITLE'])) {
14+
$device_rec = SQLSelectOne("SELECT * FROM devices WHERE LINKED_OBJECT='" . $rec['TITLE'] . "'");
15+
if (isset($device_rec['ID'])) {
16+
$out['DEVICE_ID'] = $device_rec['ID'];
17+
$out['DEVICE_TITLE'] = $device_rec['TITLE'];
18+
}
1719
}
1820

1921
$class_changed_from = '';
@@ -93,8 +95,10 @@
9395
for ($classes_i = 0; $classes_i < $classes_total; $classes_i++) {
9496
$class_id_opt[$tmp[$classes_i]['ID']] = $tmp[$classes_i]['TITLE'];
9597
}
96-
for ($i = 0; $i < $classes_total; $i++) {
97-
if ($rec['CLASS_ID'] == $tmp[$i]['ID']) $tmp[$i]['SELECTED'] = 1;
98+
if (isset($rec['CLASS_ID'])) {
99+
for ($i = 0; $i < $classes_total; $i++) {
100+
if ($rec['CLASS_ID'] == $tmp[$i]['ID']) $tmp[$i]['SELECTED'] = 1;
101+
}
98102
}
99103
$out['CLASS_ID_OPTIONS'] = $tmp;
100104
//options for 'Location' (select)
@@ -103,8 +107,10 @@
103107
for ($locations_i = 0; $locations_i < $locations_total; $locations_i++) {
104108
$location_id_opt[$tmp[$locations_i]['ID']] = $tmp[$locations_i]['TITLE'];
105109
}
106-
for ($i = 0; $i < $locations_total; $i++) {
107-
if ($rec['LOCATION_ID'] == $tmp[$i]['ID']) $tmp[$i]['SELECTED'] = 1;
110+
if (isset($rec['LOCATION_ID'])) {
111+
for ($i = 0; $i < $locations_total; $i++) {
112+
if ($rec['LOCATION_ID'] == $tmp[$i]['ID']) $tmp[$i]['SELECTED'] = 1;
113+
}
108114
}
109115
$out['LOCATION_ID_OPTIONS'] = $tmp;
110116
}
@@ -150,7 +156,7 @@
150156
$props = $cl->getParentProperties($rec['CLASS_ID'], '', 1);
151157

152158
$my_props = SQLSelect("SELECT * FROM properties WHERE OBJECT_ID='" . $rec['ID'] . "'");
153-
if ($my_props[0]['ID']) {
159+
if (isset($my_props[0]['ID'])) {
154160
foreach ($my_props as $p) {
155161
$props[] = $p;
156162
}
@@ -303,7 +309,7 @@
303309
$my_meth = SQLSelectOne("SELECT ID FROM methods WHERE OBJECT_ID='" . $rec['ID'] . "' AND TITLE LIKE '" . DBSafe($methods[$i]['TITLE']) . "'");
304310
$obj_name = SQLSelectOne("SELECT TITLE FROM `objects` WHERE ID = {$rec['ID']}");
305311
$methods[$i]['OBJECT_TITLE'] = $obj_name['TITLE'];
306-
if ($my_meth['ID']) {
312+
if (isset($my_meth['ID'])) {
307313
$methods[$i]['CUSTOMIZED'] = 1;
308314
}
309315
}
@@ -322,12 +328,12 @@
322328
}
323329
outHash($rec, $out);
324330

325-
if (!$rec['ID'] && $this->class_id) {
331+
if (!isset($rec['ID']) && isset($this->class_id)) {
326332
$out['CLASS_ID'] = $this->class_id;
327333
}
328334

329335
$out['SCRIPTS'] = SQLSelect("SELECT ID, TITLE FROM scripts ORDER BY TITLE");
330336

331-
if ($out['TITLE']) {
337+
if (isset($out['TITLE'])) {
332338
$this->owner->owner->data['TITLE'] = $out['TITLE'];
333339
}

modules/xray/xray.class.php

+20-13
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ function __construct()
2626
$this->title = "X-Ray";
2727
$this->module_category = "<#LANG_SECTION_SYSTEM#>";
2828
$this->checkInstalled();
29+
$this->cycle = '';
2930
}
3031

3132
/**
@@ -129,6 +130,7 @@ function run()
129130

130131
function service_control(&$out)
131132
{
133+
132134
$cycle = $this->cycle;
133135
if (!$this->cycle) {
134136
$this->cycle = gr('cycle');
@@ -326,7 +328,7 @@ function context(&$out)
326328
$methods = SQLSelect("SELECT methods.ID, methods.TITLE, classes.TITLE AS CLASS, objects.TITLE AS OBJECT, methods.CLASS_ID, methods.OBJECT_ID FROM methods LEFT JOIN classes ON methods.CLASS_ID=classes.ID LEFT JOIN objects ON methods.OBJECT_ID=objects.ID WHERE (methods.CODE LIKE '%" . DBSafe($k) . "%' OR methods.TITLE LIKE '" . DBSafe($v) . "')");
327329
$total = count($methods);
328330
for ($i = 0; $i < $total; $i++) {
329-
if (!$found['method' . $methods[$i]['ID']]) {
331+
if (!isset($found['method' . $methods[$i]['ID']])) {
330332
$rec = array();
331333
$rec['TYPE'] = 'method';
332334
$rec['TITLE'] = $methods[$i]['TITLE'];
@@ -575,7 +577,7 @@ function admin(&$out)
575577
$result = array();
576578

577579
foreach ($files as $file_item) {
578-
if ($file_item['SELECTED']) {
580+
if (isset($file_item['SELECTED'])) {
579581
$file = $file_item['TITLE'];
580582
$filename = $path . '/' . $file;
581583
if (file_exists($filename)) {
@@ -620,7 +622,7 @@ function admin(&$out)
620622
foreach ($res_lines as $line) {
621623
if (preg_match('/<b>(\d+?:\d+?:\d+?) ([\d\.]+)<\\/b>/uis', $line, $m)) {
622624
$tm = strtotime(date('Y-m-d', filemtime($filename)) . ' ' . $m[1]) + (float)$m[1];
623-
$result[] = array('TM' => $tm + (float)$m2, 'CONTENT' => $line);
625+
$result[] = array('TM' => $tm + (float)$m[2], 'CONTENT' => $line);
624626
}
625627
}
626628
} else {
@@ -694,20 +696,23 @@ function admin(&$out)
694696
$responce['TOTAL'] = $total;
695697

696698
for ($i = 0; $i < $total; $i++) {
697-
@$tmp = unserialize($res[$i]['EXECUTED_PARAMS']);
698-
if ($tmp['ORIGINAL_OBJECT_TITLE'] && !$res[$i]['OBJECT']) {
699-
$res[$i]['OBJECT'] = $tmp['ORIGINAL_OBJECT_TITLE'];
700-
$res[$i]['EXECUTED_PARAMS'] = serialize($tmp);
699+
if (isset($res[$i]['EXECUTED_PARAMS']) && $res[$i]['EXECUTED_PARAMS']!='') {
700+
$tmp = json_decode($res[$i]['EXECUTED_PARAMS'],true);
701+
if (isset($tmp['ORIGINAL_OBJECT_TITLE']) && !isset($res[$i]['OBJECT'])) {
702+
$res[$i]['OBJECT'] = $tmp['ORIGINAL_OBJECT_TITLE'];
703+
$res[$i]['EXECUTED_PARAMS'] = serialize($tmp);
704+
}
701705
}
702-
706+
703707
$responce['LIST'][$i]['METHOD'] = $res[$i]['OBJECT'] . '.' . $res[$i]['TITLE'];
704708
if ($res[$i]['DESCRIPTION']) {
705709
$responce['LIST'][$i]['DESC'] = $res[$i]['DESCRIPTION'];
706710
} else {
707711
$responce['LIST'][$i]['DESC'] = '';
708712
}
709-
710-
$responce['LIST'][$i]['PARAMS'] = htmlspecialchars(str_replace(',"', ', "', $res[$i]['EXECUTED_PARAMS']));
713+
if (isset($res[$i]['EXECUTED_PARAMS'])) {
714+
$responce['LIST'][$i]['PARAMS'] = htmlspecialchars(str_replace(',"', ', "', $res[$i]['EXECUTED_PARAMS']));
715+
}
711716
$responce['LIST'][$i]['EXECUTED'] = $res[$i]['EXECUTED'];
712717
$responce['LIST'][$i]['SOURCE'] = $res[$i]['EXECUTED_SRC'];
713718
}
@@ -921,9 +926,11 @@ function admin(&$out)
921926

922927
$responce['LIST'][$i]['ADDED'] = $res[$i]['ADDED'];
923928
}
924-
925-
$responce['LIST'] = array_reverse($responce['LIST']);
926-
929+
930+
if (isset($responce['LIST']) && is_array($responce['LIST'])) {
931+
$responce['LIST'] = array_reverse($responce['LIST']);
932+
}
933+
927934
echo json_encode($responce);
928935
}
929936

0 commit comments

Comments
 (0)