Skip to content

Commit

Permalink
Minor updates
Browse files Browse the repository at this point in the history
* Blockly fixes
* Objects fixes
  • Loading branch information
sergejey committed Sep 10, 2019
1 parent ab883ed commit b3ba737
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 52 deletions.
2 changes: 1 addition & 1 deletion 3rdparty/googleblockly/index.php
Expand Up @@ -154,7 +154,7 @@ function init() {
if (xmlDom) { if (xmlDom) {
Blockly.mainWorkspace.clear(); Blockly.mainWorkspace.clear();
try { try {
Blockly.Xml.domToWorkspace(Blockly.mainWorkspace, xmlDom); Blockly.Xml.domToWorkspace(xmlDom,Blockly.mainWorkspace);
} catch (e) { } catch (e) {
Blockly.mainWorkspace.clear(); Blockly.mainWorkspace.clear();
alert('Error loading script: ' + e); alert('Error loading script: ' + e);
Expand Down
7 changes: 5 additions & 2 deletions api.php
Expand Up @@ -26,6 +26,9 @@


$method = $_SERVER['REQUEST_METHOD']; $method = $_SERVER['REQUEST_METHOD'];
$url = $_SERVER['REQUEST_URI']; $url = $_SERVER['REQUEST_URI'];
if (preg_match('/\/api\.php\?/',$url)) {
$url=preg_replace('/\/api\.php\?/','/api.php/',$url);
}
$url = preg_replace('/\?.+/', '', $url); $url = preg_replace('/\?.+/', '', $url);
$request = explode('/', trim($url, '/')); $request = explode('/', trim($url, '/'));


Expand All @@ -48,7 +51,7 @@
include_once("./lib/loader.php"); include_once("./lib/loader.php");
include_once("./load_settings.php"); include_once("./load_settings.php");


StartMeasure('TOTAL'); startMeasure('TOTAL');
$startedTime=getmicrotime(); $startedTime=getmicrotime();
register_shutdown_function('apiShutdown'); register_shutdown_function('apiShutdown');


Expand Down Expand Up @@ -204,7 +207,7 @@
foreach($locations as $k=>$v) { foreach($locations as $k=>$v) {
$location=array(); $location=array();
$location['id']=$v['ID']; $location['id']=$v['ID'];
$location['title']=$v['TITLE']; $location['title']=processTitle($v['TITLE']);
$location['priority']=$v['PRIORITY']; $location['priority']=$v['PRIORITY'];
$location['object']=getRoomObjectByLocation($v['ID'],1); $location['object']=getRoomObjectByLocation($v['ID'],1);
$result['rooms'][]=$location; $result['rooms'][]=$location;
Expand Down
2 changes: 1 addition & 1 deletion lib/objects.class.php
Expand Up @@ -1012,7 +1012,7 @@ function callAPI($api_url, $method = 'GET', $params = 0)
curl_setopt($api_ch, CURLOPT_POST, 1); curl_setopt($api_ch, CURLOPT_POST, 1);
curl_setopt($api_ch, CURLOPT_POSTFIELDS, $params); curl_setopt($api_ch, CURLOPT_POSTFIELDS, $params);
} }
$url = str_replace('/api/', '/api.php/', $url); $url = preg_replace('/^\/api\//', ROOTHTML.'api.php/', $url);
curl_setopt($api_ch, CURLOPT_URL, $url); curl_setopt($api_ch, CURLOPT_URL, $url);
curl_exec($api_ch); curl_exec($api_ch);


Expand Down
4 changes: 4 additions & 0 deletions modules/blockly_code/blockly_code.class.php
Expand Up @@ -168,6 +168,10 @@ function admin(&$out) {
} }


$out['XML']=$rec['XML']; $out['XML']=$rec['XML'];
//$out['XML']='';

//dprint($rec);

$out['CODE_TYPE']=(int)$rec['CODE_TYPE']; $out['CODE_TYPE']=(int)$rec['CODE_TYPE'];




Expand Down
6 changes: 2 additions & 4 deletions modules/objects/objects.class.php
Expand Up @@ -929,10 +929,8 @@ function setProperty($property, $value, $no_linked = 0, $source = '')
$property_linked_history[$this->object_title . '.' . $property][$prop['ONCHANGE']] = 1; $property_linked_history[$this->object_title . '.' . $property][$prop['ONCHANGE']] = 1;
$params = array(); $params = array();
$params['PROPERTY'] = $property; $params['PROPERTY'] = $property;
if ($value!=$old_value) { $params['NEW_VALUE'] = (string)$value;
$params['NEW_VALUE'] = (string)$value; $params['OLD_VALUE'] = (string)$old_value;
$params['OLD_VALUE'] = (string)$old_value;
}
$params['SOURCE'] = (string)$source; $params['SOURCE'] = (string)$source;
//$this->callMethod($prop['ONCHANGE'], $params); //$this->callMethod($prop['ONCHANGE'], $params);
$this->callMethodSafe($prop['ONCHANGE'], $params); $this->callMethodSafe($prop['ONCHANGE'], $params);
Expand Down
84 changes: 42 additions & 42 deletions scripts/cycle_ping.php
@@ -1,42 +1,42 @@
<?php <?php


chdir(dirname(__FILE__) . '/../'); chdir(dirname(__FILE__) . '/../');


include_once './config.php'; include_once './config.php';
include_once './lib/loader.php'; include_once './lib/loader.php';
include_once './lib/threads.php'; include_once './lib/threads.php';


set_time_limit(0); set_time_limit(0);


include_once("./load_settings.php"); include_once("./load_settings.php");
include_once(DIR_MODULES . "control_modules/control_modules.class.php"); include_once(DIR_MODULES . "control_modules/control_modules.class.php");


$ctl = new control_modules(); $ctl = new control_modules();


include_once(DIR_MODULES . 'pinghosts/pinghosts.class.php'); include_once(DIR_MODULES . 'pinghosts/pinghosts.class.php');


$pinghosts = new pinghosts(); $pinghosts = new pinghosts();


$checked_time = 0; $checked_time = 0;


echo date("H:i:s") . " running " . basename(__FILE__) . PHP_EOL; echo date("H:i:s") . " running " . basename(__FILE__) . PHP_EOL;


while (1) while (1)
{ {
if (time() - $checked_time > 10) if (time() - $checked_time > 10)
{ {
$checked_time = time(); $checked_time = time();
setGlobal((str_replace('.php', '', basename(__FILE__))) . 'Run', time(), 1); setGlobal((str_replace('.php', '', basename(__FILE__))) . 'Run', time(), 1);


// checking all hosts // checking all hosts
$pinghosts->checkAllHosts(1); $pinghosts->checkAllHosts();
} }


if (file_exists('./reboot') || IsSet($_GET['onetime'])) if (file_exists('./reboot') || IsSet($_GET['onetime']))
{ {
exit; exit;
} }
sleep(1); sleep(1);
} }


DebMes("Unexpected close of cycle: " . basename(__FILE__)); DebMes("Unexpected close of cycle: " . basename(__FILE__));
8 changes: 6 additions & 2 deletions templates/blockly_code/blockly_code.html
Expand Up @@ -141,8 +141,12 @@


[#if TYPE=="php"#] [#if TYPE=="php"#]
<div id="xml_row"[#if CODE_TYPE!="1"#] style="display:none"[#endif#]> <div id="xml_row"[#if CODE_TYPE!="1"#] style="display:none"[#endif#]>
[ <a href="#" onClick="return [#CODE_FIELD#]_editBlocklyUpdated();"><#LANG_EDIT#></a> ] <a href="#" onClick="return [#CODE_FIELD#]_editBlocklyUpdated();" class="btn btn-default btn-success"><#LANG_EDIT#></a>
<textarea name="xml" id="xml_code" rows="5" cols="60" class="span10" style="display:none">[#XML#]</textarea> <br/>
<small><a href="#" onClick="$('#xml_area').toggle();return false;"><#LANG_SHOW#> XML</a></small>
<div id="xml_area" style="display:none">
<textarea name="xml" id="xml_code" rows="5" cols="60" class="form-control">[#XML#]</textarea>
</div>
</div> </div>
[#endif TYPE#] [#endif TYPE#]


Expand Down

0 comments on commit b3ba737

Please sign in to comment.