Skip to content
Permalink
Browse files
Fixes
* ENABLE_FORK option added to config (instead of DISABLE_FORK)
* Script edit updated
* pChart fullscreen option changed
  • Loading branch information
sergejey committed Feb 11, 2020
1 parent f7d9dd0 commit d09551e11eb76b0ac41432492d7227f4efaf1412
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 32 deletions.
@@ -103,4 +103,4 @@ Define('GETURL_WARNING_TIMEOUT',5); // TIMEOUT LIMIT FOR getUR
//Define('VERBOSE_LOG_IGNORE','.checkstate, ThisComputer.uptime'); // IGNORE SOME DATA
//Define('DISABLE_SIMPLE_DEVICES',1); // disables simple devices behavior
//Define('AUDIO_PLAYER','omxplayer --no-osd'); // audio-player for linux
//Define('DISABLE_FORK',1); // disable process fork (more stable with low memory systems)
//Define('ENABLE_FORK',1); // enables process fork (consumes more memory but speeds up some operations)
@@ -994,12 +994,10 @@ function callMethodSafe($method_name, $params = 0)
function callAPI($api_url, $method = 'GET', $params = 0)
{
$is_child = false;
$fork_disabled = false;
$fork_disabled = true;

if (defined('DISABLE_FORK') && DISABLE_FORK) {
$fork_disabled = true;
} elseif (!function_exists('pcntl_fork')) {
$fork_disabled = true;
if (defined('ENABLE_FORK') && ENABLE_FORK && function_exists('pcntl_fork')) {
$fork_disabled = false;
}

if (!$fork_disabled) {
@@ -1014,6 +1012,7 @@ function callAPI($api_url, $method = 'GET', $params = 0)
// child
$is_child = true;
register_shutdown_function(create_function('$pars', 'posix_kill(getmypid(), SIGKILL);'), array());
set_time_limit(60);
}
}

@@ -146,6 +146,7 @@ function isItPythonCode($code) {
$tmp=explode("\n",$code);
if (count($tmp)==1) return false;
if (preg_match('/\);/ui',$code)) return false;
if (preg_match('/{\\n/uis',$code)) return false;
if (preg_match('/;$/ui',$code)) return false;
if (preg_match('/;\\n/ui',$code)) return false;
if (preg_match('/\$\w+.+;/ui',$code)) return false;
@@ -72,37 +72,35 @@

//UPDATING RECORD
if ($ok) {

$linked_object = '';
$linked_property = '';
if (preg_match('/^if(.+?){/is', $rec['CODE'], $m)) {
$conditions = trim($m[1], '()');
if (preg_match('/getglobal\(["\'](\w+)\.(\w+)["\']\)/is', $conditions, $m2)) {
$linked_object=$m2[1];
$linked_property=$m2[2];
} elseif (preg_match('/gg\(["\'](\w+)\.(\w+)["\']\)/is', $conditions, $m2)) {
$linked_object=$m2[1];
$linked_property=$m2[2];
} elseif (preg_match('/timeis/is', $conditions) ||
preg_match('/timebefore/is', $conditions) ||
preg_match('/timeafter/is', $conditions) ||
preg_match('/timebetween/is', $conditions)) {
$linked_object='ClockChime';
$linked_property='time';

if (!isset($_REQUEST['auto_link']) || $_REQUEST['auto_link']==1) {
if (preg_match('/^if(.+?){/is', $rec['CODE'], $m)) {
$conditions = trim($m[1], '()');
if (preg_match('/getglobal\(["\'](\w+)\.(\w+)["\']\)/is', $conditions, $m2)) {
$linked_object=$m2[1];
$linked_property=$m2[2];
} elseif (preg_match('/gg\(["\'](\w+)\.(\w+)["\']\)/is', $conditions, $m2)) {
$linked_object=$m2[1];
$linked_property=$m2[2];
} elseif (preg_match('/timeis/is', $conditions) ||
preg_match('/timebefore/is', $conditions) ||
preg_match('/timeafter/is', $conditions) ||
preg_match('/timebetween/is', $conditions)) {
$linked_object='ClockChime';
$linked_property='time';
}
}
}

if ($linked_object!='' && $linked_property!='') {
$rec['AUTO_LINK_AVAILABLE']=1;
if (!$old_code) {
if ($linked_object!='' && $linked_property!='') {
$rec['AUTO_LINK_AVAILABLE']=1;
$rec['AUTO_LINK']=1;
} else {
$rec['AUTO_LINK_AVAILABLE']=0;
}
} else {
$rec['AUTO_LINK_AVAILABLE']=0;
}
if (!$rec['AUTO_LINK']) {
$linked_object='';
$linked_property='';
$rec['AUTO_LINK']=0;
}

$rec['LINKED_OBJECT'] = $linked_object;
@@ -253,14 +253,14 @@


if (!is_array($_GET['p'])) {
$code = '<iframe allowfullscreen="true" src="' . ROOTHTML . 'module/charts.html?id=config&period=' . $_GET['subop'] . '&chart_type=' . urlencode($_GET['chart_type']) . '&group=' . $group . '&property=' . urlencode($_GET['p']) . '&height=' . $height . '&theme=grid-light" width=100% height=' . ($height) . ' frameBorder=0></iframe>';
$code = '<iframe allowfullscreen="true" src="' . ROOTHTML . 'module/charts.html?id=config&enable_fullscreen=1&period=' . $_GET['subop'] . '&chart_type=' . urlencode($_GET['chart_type']) . '&group=' . $group . '&property=' . urlencode($_GET['p']) . '&height=' . $height . '&theme=grid-light" width=100% height=' . ($height) . ' frameBorder=0></iframe>';
} else {
$p_url = '';
foreach ($_GET['p'] as $p) {
$p_url .= '&properties[]=' . urlencode($p);
}
$p_url .= '&height=' . $height;
$code = '<iframe allowfullscreen="true" src="' . ROOTHTML . 'module/charts.html?id=config&period=' . $_GET['subop'] . '&chart_type=' . urlencode($_GET['chart_type']) . '&group=' . $group . $p_url . '&theme=grid-light&frameBorder=0" width=100% height=' . $height . '></iframe>';
$code = '<iframe allowfullscreen="true" src="' . ROOTHTML . 'module/charts.html?id=config&enable_fullscreen=1&period=' . $_GET['subop'] . '&chart_type=' . urlencode($_GET['chart_type']) . '&group=' . $group . $p_url . '&theme=grid-light&frameBorder=0" width=100% height=' . $height . '></iframe>';
}
} else {
$code = '<img src="' . ROOTHTML . '3rdparty/jpgraph/?p=' . $p . '&type=' . $_GET['subop'] . '&width=500&"/>';

0 comments on commit d09551e

Please sign in to comment.