function ajax_cli() { $cmd = explode(' ', trim($_REQUEST['q'])); $method = array_shift($cmd); if (substr($method, 0, 3) == 'hm.') { print_r(HMRPC(substr($method, 3), $cmd)); if ($method == 'hm.setInstallMode') { print 'You have 60 seconds to pair your device. After completing the pairing, click here to create an entry for it: <a href="' . actionUrl('pair', 'devices') . '">Pairing Complete</a>.'; } } else { profile_point('starting command'); eval(trim($_REQUEST['q'])); profile_point('command executed'); print chr(10); print_r($GLOBALS['profiler_log']); } }
function h2_init_hubbub_environment() { if (substr($_SERVER['REQUEST_URI'], 0, 1) == '/') { interpretQueryString($_SERVER['REQUEST_URI']); } profile_point(' - query strings'); $GLOBALS['obj']['user'] = new HubbubUser(); profile_point(' - user'); l10n_load('mvc/l10n'); profile_point(' - l10n'); if (isset($_REQUEST['hubbub_msg'])) { // we're receiving a message from another server $GLOBALS['msg']['touser'] = $_REQUEST['controller']; // invoke the endpoint controller to handle message $_REQUEST['controller'] = 'endpoint'; $_REQUEST['action'] = 'index'; } }
require 'lib/config.php'; profile_point('config loaded'); h2_init_hubbub_environment(); // if there was output up to this point, it has to be an error message $GLOBALS['content.startuperrors'] = trim(ob_get_clean()); // enable gzip compression by default profile_point('environment ready'); WriteToFile('log/activity.log', 'call ' . $_REQUEST['controller'] . '-' . $_REQUEST['action'] . "\n"); // instantiate controller, invoke action, render view $_REQUEST['controller'] = getDefault($_REQUEST['controller'], cfg('service/defaultcontroller')); $baseCtr = h2_getController($_REQUEST['controller']); profile_point('controller invoked'); h2_invokeAction($baseCtr, $_REQUEST['action']); profile_point('action executed'); $GLOBALS['content']['main'] = h2_invokeView($baseCtr, $_REQUEST['action']); profile_point('view executed'); // output through page template $templateName = cfg('page/template', 'default'); switch ($templateName) { case 'blank': print $GLOBALS['content']['main']; break; default: header('content-type: text/html;charset=UTF-8'); require 'themes/' . cfg('theme/name', 'default') . '/' . $templateName . '.php'; break; } /* temporarily disabled (fixme) if($_REQUEST['controller'] != 'endpoint') h2_statlog('web', $_REQUEST['controller'].'.'.$_REQUEST['action']); else
function invokeTemplate($templateName) { switch ($templateName) { case 'blank': print $GLOBALS['content']['main']; break; default: header('content-type: text/html;charset=UTF-8'); require 'themes/' . cfg('theme/name', 'default') . '/' . $templateName . '.php'; break; } profile_point('H2Dispatcher.invokeTemplate(' . $templateName . ')'); return $this; }
break; case 'INTEGER': return $val + 0; break; case 'FLOAT': return $val + 0.0; break; } return 0; } foreach ($dev['PARAMSETS'] as $psetType) { $saveP = array(); $p = HMRPC('getParamset', array($ds['d_id'], $psetType)); profile_point('getParamset ' . $psetType); $pdes = HMRPC('getParamsetDescription', array($ds['d_id'], $psetType)); profile_point('getParamsetDescription ' . $psetType); ?> <table width="100%" style="max-width: 700px;" class="border-bottom"><?php if (is_array($pdes)) { foreach ($pdes as $k => $ps) { $ps['WRITABLE'] = ($ps['OPERATIONS'] & 2) == 2 && $k != 'AES_ACTIVE'; if ($ps['WRITABLE'] && $doSave) { $fVal = parseParam($_POST[$k], $ps); if ($fVal != $p[$k]) { $saveP[$k] = $fVal; $p[$k] = $fVal; } } ?> <tr>
function cqrequest($rq_array, $post = array(), $timeout = 10, $headerMode = true, $onlyHeaders = false) { $rq = array(); $content = array(); $active = null; $idx = 0; $multi_handler = curl_multi_init(); if (!is_array($rq_array)) { $rq_array = array(array('url' => $rq_array)); } // configure each request foreach ($rq_array as $rparam) { if (trim($rparam['url']) != '') { profile_point('cqrequest(' . substr($rparam['url'], 0, 64) . '...)'); $idx++; $channel = curl_init(); curl_setopt($channel, CURLOPT_URL, $rparam['url']); $combinedParams = $post; if (is_array($rparam['params'])) { $combinedParams = array_merge($rparam['params'], $post); } if (sizeof($combinedParams) > 0) { curl_setopt($channel, CURLOPT_POST, 1); curl_setopt($channel, CURLOPT_POSTFIELDS, $combinedParams); } curl_setopt($channel, CURLOPT_HEADER, 1); curl_setopt($channel, CURLOPT_TIMEOUT, $timeout); curl_setopt($channel, CURLOPT_RETURNTRANSFER, 1); curl_multi_add_handle($multi_handler, $channel); $rq[$idx] = array($channel, $rparam); } } if (sizeof($rq) == 0) { return array(); } // execute do { $mrc = curl_multi_exec($multi_handler, $active); } while ($mrc == CURLM_CALL_MULTI_PERFORM); // wait for return while ($active && $mrc == CURLM_OK) { if (curl_multi_select($multi_handler) != -1) { do { $mrc = curl_multi_exec($multi_handler, $active); } while ($mrc == CURLM_CALL_MULTI_PERFORM); } } // cleanup foreach ($rq as $idx => $rparam) { $result = http_parse_request(curl_multi_getcontent($rparam[0])); $result['param'] = $rparam[1]; $content[$idx] = $result; curl_multi_remove_handle($multi_handler, $channel); $lastIdx = $idx; } curl_multi_close($multi_handler); if (sizeof($content) == 1) { $content = $content[$lastIdx]; } profile_point('cqrequest() done'); return $content; }
<div id="wstate"></div> <?php include 'templates/modeset.php'; profile_point('modeset widget complete'); ?> <div id="container" style="margin-left: 60px;"><?php include 'templates/check-timer-system.php'; profile_point('timer system check'); $renderer = new H2DeviceRenderer(); profile_point('H2DeviceRenderer ready'); $clientIdentifier = 'client/' . $_SERVER['REMOTE_ADDR']; $clientSettings = $nv->get($clientIdentifier); $clientSettings['lastseen'] = time(); $nv->set($clientIdentifier, $clientSettings); foreach ($this->devices as $dtype => $dt) { if (!$clientSettings['hide' . $dtype]) { ?> <div class="smalltext bottomborder"><?php echo htmlspecialchars($dtype); ?> </div><?php foreach ($dt as $ds) { $renderer->display($ds); } } } ?> </div> <?php include 'templates/weatherinfo.php';
$version = explode('.', phpversion()); if (!($version[0] > 4 && $version[1] > 2)) { die('Error: PHP 5.3 or greater needed'); } $GLOBALS['profiler_start'] = microtime(); $GLOBALS['APP.BASEDIR'] = dirname(__FILE__); // init environment ob_start("ob_gzhandler"); ob_start(); chdir($GLOBALS['APP.BASEDIR']); require 'lib/genlib.php'; require 'lib/hubbub2.php'; require 'lib/database.php'; profile_point('classes ready'); require 'lib/config.php'; profile_point('config loaded'); h2_init_hubbub_environment(); // if there was output up to this point, it has to be an error message $GLOBALS['content.startuperrors'] = trim(ob_get_clean()); // enable gzip compression by default profile_point('environment ready'); WriteToFile('log/activity.log', 'call ' . $_REQUEST['controller'] . '-' . $_REQUEST['action'] . "\n"); // instantiate controller, invoke action, render view include 'mvc/test/test.rewrite.php'; /* temporarily disabled (fixme) if($_REQUEST['controller'] != 'endpoint') h2_statlog('web', $_REQUEST['controller'].'.'.$_REQUEST['action']); else h2_statlog('ept', $GLOBALS['stats']['msgtype'].'('.$GLOBALS['stats']['response'].')'); */
$('#css_theme').attr('href', '<?php echo cfg('service/subdir'); ?> /themes/default/all.css.php?scheme='+sunState); } }, 5*1000); </script> </body> <?php if (cfg('debug')) { ?> <!-- <?php profile_point('page template end'); echo implode("\n", $GLOBALS['profiler_log']); ?> RAM usage: <?php echo ceil(memory_get_peak_usage() / 1024); ?> kBytes uname: <?php echo php_uname(); ?> pid: <?php echo getmypid(); ?> user: <?php
$eventAdresses[] = 'SUNRISE+' . $sunRiseIn; } if ($sunSetIn > -$sunEventDistance && $sunSetIn <= 0) { $eventAdresses[] = 'SUNSET' . $sunSetIn; } if ($sunSetIn < $sunEventDistance && $sunSetIn >= 0) { $eventAdresses[] = 'SUNSET+' . $sunSetIn; } if ($sunRiseIn == 0) { $eventAdresses[] = 'SUNRISE'; } if ($sunSetIn == 0) { $eventAdresses[] = 'SUNSET'; } } $eventAdresses[] = 'TICK-' . strtoupper($mainWeather['main']); $this->callEventHandlers($eventAdresses, $_REQUEST); print json_encode($GLOBALS['log']); profile_point('done'); $_REQUEST['log'] = $GLOBALS['log']; ob_start(); include 'mvc/svc/svc.ajax_camscript.php'; ob_get_clean(); /* WriteToFile('log/event.log', date('Y-m-d H:i:s').' tick event '.json_encode($_REQUEST).chr(10) .'- '.json_encode($eventAdresses).chr(10) .'- '.json_encode($GLOBALS['log']).chr(10) #.'- '.json_encode($GLOBALS['profiler_log']).chr(10) ); */ }
function DB_GetList($query, $parameters = null, $opt = array()) { DB_Connect(); $result = array(); $error = ''; $query = DB_ParseQueryParams($query, $parameters); $lines = mysql_query($query, $GLOBALS['db_link']) or $error = mysql_error($GLOBALS['db_link']) . '{ ' . $query . ' }'; if (trim($error) != '') { $DBERR = $error; logError('error_sql', $DBERR); } else { while ($line = mysql_fetch_array($lines, MYSQL_ASSOC)) { if (isset($keyByField)) { $result[$line[$keyByField]] = $line; } else { $result[] = $line; } } mysql_free_result($lines); } profile_point('DB_GetList(' . substr($query, 0, 40) . '...)'); return $result; }
function query($query, $parameters = null) { $query = $this->parseQueryParams($query, $parameters); if (substr($query, -1, 1) == ';') { $query = substr($query, 0, -1); } $rs = mysql_query($query) or critical(mysql_error() . '{ ' . $query . ' }'); profile_point('DB_Update(' . $query . ')'); }
<?php # init environment $GLOBALS['profiler_start'] = microtime(); $GLOBALS['APP.BASEDIR'] = dirname(__FILE__); ob_start("ob_gzhandler"); chdir($GLOBALS['APP.BASEDIR']); require 'lib/h2genlib.php'; require 'lib/h2config.php'; require 'lib/h2ha.php'; if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) { $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_X_FORWARDED_FOR']; } o(new H2User(), 'user'); profile_point('libraries loaded'); o(new H2Dispatcher($_REQUEST))->initEnvironment()->receiveData()->initController($_REQUEST['controller'])->invokeAction($_REQUEST['action'])->invokeView('main')->invokeTemplate(cfg('page/template', 'page'))->cleanup();