@@ -38,16 +38,16 @@ function __construct()
38
38
function saveParams ($ data = 0 )
39
39
{
40
40
$ p = array ();
41
- if (IsSet ($ this ->id )) {
41
+ if (isset ($ this ->id )) {
42
42
$ p ["id " ] = $ this ->id ;
43
43
}
44
- if (IsSet ($ this ->view_mode )) {
44
+ if (isset ($ this ->view_mode )) {
45
45
$ p ["view_mode " ] = $ this ->view_mode ;
46
46
}
47
- if (IsSet ($ this ->edit_mode )) {
47
+ if (isset ($ this ->edit_mode )) {
48
48
$ p ["edit_mode " ] = $ this ->edit_mode ;
49
49
}
50
- if (IsSet ($ this ->tab )) {
50
+ if (isset ($ this ->tab )) {
51
51
$ p ["tab " ] = $ this ->tab ;
52
52
}
53
53
return parent ::saveParams ($ p );
@@ -100,10 +100,10 @@ function run()
100
100
} else {
101
101
$ this ->usual ($ out );
102
102
}
103
- if (IsSet ($ this ->owner ->action )) {
103
+ if (isset ($ this ->owner ->action )) {
104
104
$ out ['PARENT_ACTION ' ] = $ this ->owner ->action ;
105
105
}
106
- if (IsSet ($ this ->owner ->name )) {
106
+ if (isset ($ this ->owner ->name )) {
107
107
$ out ['PARENT_NAME ' ] = $ this ->owner ->name ;
108
108
}
109
109
$ out ['VIEW_MODE ' ] = $ this ->view_mode ;
@@ -130,11 +130,12 @@ function processSubscription($event_name, &$details)
130
130
if ($ event_name == 'SAY ' ) {
131
131
$ level = (int )$ details ['level ' ];
132
132
$ message = $ details ['message ' ];
133
- $ this ->sendMessageToConnect ($ message , $ level );
133
+ $ image = $ details ['image ' ];
134
+ $ this ->sendMessageToConnect ($ message , $ level , $ image );
134
135
}
135
136
}
136
137
137
- function sendMessageToConnect ($ message , $ level )
138
+ function sendMessageToConnect ($ message , $ level = 0 , $ image = '' )
138
139
{
139
140
$ this ->getConfig ();
140
141
$ connect_username = $ this ->config ['CONNECT_USERNAME ' ]; //username
@@ -148,9 +149,20 @@ function sendMessageToConnect($message, $level)
148
149
'message ' => $ message ,
149
150
'level ' => (int )$ level
150
151
);
152
+ if ($ image != '' && file_exists ($ image )) {
153
+ if (function_exists ('curl_file_create ' )) { // php 5.6+
154
+ $ size = getimagesize ($ image );
155
+ $ cfile = curl_file_create ($ image , $ size ['mime ' ], basename ($ image ));
156
+ } else { //
157
+ $ cfile = '@ ' . realpath ($ image );
158
+ }
159
+ $ fields ['image ' ] = $ cfile ;
160
+ }
161
+ //DebMes("sending data: " . json_encode($fields), 'connect_msg');
151
162
$ url = 'https://connect.smartliving.ru/sync_device_data.php ' ;
152
163
$ ch = curl_init ();
153
164
curl_setopt ($ ch , CURLOPT_URL , $ url );
165
+ curl_setopt ($ ch , CURLOPT_HEADER , array ("Content-Type:multipart/form-data " ));
154
166
curl_setopt ($ ch , CURLOPT_POST , 1 );
155
167
curl_setopt ($ ch , CURLOPT_POSTFIELDS , $ fields );
156
168
curl_setopt ($ ch , CURLOPT_RETURNTRANSFER , 1 );
@@ -167,8 +179,8 @@ function sendMessageToConnect($message, $level)
167
179
}
168
180
}
169
181
$ result = curl_exec ($ ch );
182
+ //DebMes("sending result: " . $result, 'connect_msg');
170
183
curl_close ($ ch );
171
- //DebMes("Sending message result: $result",'connect_push');
172
184
}
173
185
174
186
function cloudBackup ()
@@ -467,7 +479,7 @@ function requestReverseFull($msg)
467
479
$ result = curl_exec ($ ch );
468
480
$ redirectURL = curl_getinfo ($ ch , CURLINFO_REDIRECT_URL );
469
481
if ($ redirectURL != '' ) {
470
- $ redirectURL = str_replace (BASE_URL ,'' ,$ redirectURL );
482
+ $ redirectURL = str_replace (BASE_URL , '' , $ redirectURL );
471
483
$ result = 'redirect: ' . $ redirectURL ;
472
484
$ data ['content_type ' ] = 'redirect ' ;
473
485
} else {
@@ -499,10 +511,10 @@ function sendReverseURL($data, $result)
499
511
$ header = array ('Content-Type: multipart/form-data ' );
500
512
$ url_requested = $ data ['url ' ];
501
513
$ fields = array ('url ' => $ url_requested );
502
- if (IsSet ($ data ['watermark ' ])) {
514
+ if (isset ($ data ['watermark ' ])) {
503
515
$ fields ['watermark ' ] = $ data ['watermark ' ];
504
516
}
505
- if (IsSet ($ data ['content_type ' ])) {
517
+ if (isset ($ data ['content_type ' ])) {
506
518
$ fields ['content_type ' ] = $ data ['content_type ' ];
507
519
}
508
520
if (preg_match ('/\.css$/is ' , $ url_requested )
@@ -573,7 +585,7 @@ function sendAllDevices()
573
585
if (is_object ($ object )) {
574
586
$ props = $ cl ->getParentProperties ($ object ->class_id , '' , 1 );
575
587
$ my_props = SQLSelect ("SELECT ID,TITLE FROM properties WHERE OBJECT_ID=' " . $ object ->id . "' " );
576
- if (IsSet ($ my_props [0 ])) {
588
+ if (isset ($ my_props [0 ])) {
577
589
foreach ($ my_props as $ p ) {
578
590
if ($ p ['TITLE ' ] == 'updated ' || $ p ['TITLE ' ] == 'updatedText ' ) continue ;
579
591
$ props [] = $ p ;
@@ -1019,17 +1031,17 @@ function usual(&$out)
1019
1031
$ this ->requestReverseFull ($ msg );
1020
1032
}
1021
1033
}
1022
-
1023
- if ($ this ->ajax && $ _GET ['op ' ] == 'status ' ) {
1024
- $ status = gg ('ThisComputer.cycle_connectRun ' );
1025
-
1034
+
1035
+ if ($ this ->ajax && $ _GET ['op ' ] == 'status ' ) {
1036
+ $ status = gg ('ThisComputer.cycle_connectRun ' );
1037
+
1026
1038
if ($ status == '' ) {
1027
- echo json_encode (array ('status ' => 0 ));
1039
+ echo json_encode (array ('status ' => 0 ));
1028
1040
} else {
1029
- echo json_encode (array ('status ' => 1 ));
1030
- }
1031
-
1032
- exit ;
1041
+ echo json_encode (array ('status ' => 1 ));
1042
+ }
1043
+
1044
+ exit ;
1033
1045
}
1034
1046
}
1035
1047
0 commit comments