function get($lastmodified, $api) { $sync = new Sync(); $output = array(); if ($lastmodified < $sync->get(Sync::USER)) { $output[Sync::USER] = getUser($api); } if ($lastmodified < $sync->get(Sync::SCENARIOS)) { $output[Sync::SCENARIOS] = getScenarios(); } if ($lastmodified < $sync->get(Sync::LIGHTS)) { $output[Sync::LIGHTS] = getLights(); } if ($lastmodified < $sync->get(Sync::ROOMS)) { $output[Sync::ROOMS] = getRooms(); } if ($lastmodified < $sync->get(Sync::PLANTS)) { $output[Sync::PLANTS] = getPlants(); } if ($lastmodified < $sync->get(Sync::DEVICES)) { $output[Sync::DEVICES] = getDevices(); } if ($lastmodified < $sync->get(Sync::SENSORS)) { $output[Sync::SENSORS] = getSensors(); } if ($lastmodified < $sync->get(Sync::EAN)) { $output[Sync::EAN] = getEan(); } return $output; }
function insertEvent($unixtime, $device, $source, $summary) { global $db; $unixtime = intval($unixtime); if (in_array($device, getDevices(), true) !== true) { die("Excuse me, what device is '{$device}'?"); } if (empty($summary)) { die("Error: empty summary."); } $device = SQLite3::escapeString($device); $source = SQLite3::escapeString($source); $summary = SQLite3::escapeString($summary); $details = SQLite3::escapeString($details); $ok = $db->exec("INSERT INTO events VALUES({$unixtime}, '{$device}', '{$source}', '{$summary}','{$details}')"); if (!$ok) { die("Error on {$unixtime},{$device},{$source},{$summary},{$details}"); } return $ok; }
# at least one matching criteria has to be defined if (!sizeof($device)) { print __("ERROR: No device matching criteria found\n"); exit(1); } # now verify the parameters given $verify = verifyDevice($device, true); if (isset($verify["err_msg"])) { print $verify["err_msg"] . "\n\n"; display_help($me); exit(1); } /* get devices matching criteria */ $devices = getDevices($device); if (!sizeof($devices)) { echo __("ERROR: No matching Devices found") . "\n"; echo __("Try php -q device_list.php") . "\n"; exit(1); } foreach ($devices as $item) { # get the data sources and graphs to act on $data_sources_to_act_on = array(); $graphs_to_act_on = array(); $data_sources = db_fetch_assoc("select data_local.id as local_data_id from data_local where data_local.device_id =" . $item["id"]);
if ($mode == "delete") { $updates = array(); foreach ($json["devices"] as $link) { $updates[$i++] = $link["id"]; } //insertLinks($updates, $developer, $authinfo["userid"], $authinfo["device"]); deleteAuth($updates, $authinfo["userid"], $username); xsuccess(count($updates) . " links updated", "json"); } else { if ($mode == "history") { $result = readHistory($authinfo["userid"], "json"); echo $result; die; } else { if ($mode == "devices") { $result = getDevices($authinfo["userid"], "json"); echo $result; die; } else { if ($mode == "addauth") { $device = $json["device"]; $r = addAuth($username, $authinfo["userid"], $device, $developer); if ($r["success"] == "") { xerror($r["error"], "json"); } else { xdevice($device, $r["success"], "json"); } } } } }
function get() { $arr = array('devices' => getDevices(), 'users' => getUsers()); return $arr; }
$devices[$c]['status'] = 'Off'; } if (strpos($device[5], 'Switch=True') !== false) { $devices[$c]['status'] = 'On'; } if ($device[4] == 'Multilevel Power Switch') { $temp = explode('<>Level=', $device[5]); $temp = explode('<>', $temp[1]); $devices[$c]['status'] = trim($temp[0]); } $c++; } //var_dump($devices); return $devices; } $devices = getDevices(); sleep(1); if ($node = filter_input(INPUT_POST, 'node_node', FILTER_VALIDATE_INT)) { //die(nl2br(print_r($_POST,true))); //DEVICE~2~255~Binary Switch //SETNODE~2~TESTLAMP~1 // if ($_POST['node_type'] == 'Multilevel Power Switch') { //clicked down if ($_POST['submit_y'] >= 66) { if ($_POST['node_status'] - 5 < 0) { $_POST['node_status'] = 0; } else { $_POST['node_status'] -= 5; } }
function _moduleContent(&$smarty, $module_name) { //include elastix framework include_once "libs/paloSantoGrid.class.php"; include_once "libs/paloSantoValidar.class.php"; include_once "libs/paloSantoConfig.class.php"; include_once "libs/paloSantoJSON.class.php"; include_once "libs/paloSantoForm.class.php"; include_once "libs/misc.lib.php"; include_once "libs/paloSantoNetwork.class.php"; //include module files include_once "modules/{$module_name}/configs/default.conf.php"; include_once "modules/{$module_name}/libs/paloSantoEndPoint.class.php"; include_once "modules/{$module_name}/libs/paloSantoFileEndPoint.class.php"; $lang = get_language(); $base_dir = dirname($_SERVER['SCRIPT_FILENAME']); $lang_file = "modules/{$module_name}/lang/{$lang}.lang"; if (file_exists("{$base_dir}/{$lang_file}")) { include_once "{$lang_file}"; } else { include_once "modules/{$module_name}/lang/en.lang"; } //global variables global $arrConf; global $arrConfModule; global $arrLang; global $arrLangModule; $arrConf = array_merge($arrConf, $arrConfModule); $arrLang = array_merge($arrLang, $arrLangModule); //folder path for custom templates $base_dir = dirname($_SERVER['SCRIPT_FILENAME']); $templates_dir = isset($arrConf['templates_dir']) ? $arrConf['templates_dir'] : 'themes'; $local_templates_dir = "{$base_dir}/modules/{$module_name}/" . $templates_dir . '/' . $arrConf['theme']; $pConfig = new paloConfig("/etc", "amportal.conf", "=", "[[:space:]]*=[[:space:]]*"); $arrAMP = $pConfig->leer_configuracion(false); $dsnAsterisk = $arrAMP['AMPDBENGINE']['valor'] . "://" . $arrAMP['AMPDBUSER']['valor'] . ":" . $arrAMP['AMPDBPASS']['valor'] . "@" . $arrAMP['AMPDBHOST']['valor']; $dsnSqlite = $arrConfModule['dsn_conn_database_1']; $accion = getAction(); $content = ""; // Asegurarse de que el arreglo siempre exista, aunque esté vacío if (!isset($_SESSION['elastix_endpoints'])) { $_SESSION['elastix_endpoints'] = array(); } switch ($accion) { case "endpoint_scan": $content = endpointScan($smarty, $module_name, $local_templates_dir, $dsnAsterisk, $dsnSqlite, $arrConf); break; case "endpoint_set": $content = endpointConfiguratedSet($smarty, $module_name, $local_templates_dir, $dsnAsterisk, $dsnSqlite, $arrConf); break; case "endpoint_unset": $content = endpointConfiguratedUnset($smarty, $module_name, $local_templates_dir, $dsnAsterisk, $dsnSqlite, $arrConf); break; case "getDevices": $content = getDevices($dsnAsterisk, $dsnSqlite); break; case "patton_data": $content = getPattonData($smarty, $module_name, $local_templates_dir, $dsnAsterisk, $dsnSqlite, $arrConf); break; case "vega_data": $content = getVegaData($smarty, $module_name, $local_templates_dir, $dsnAsterisk, $dsnSqlite, $arrConf); break; case "next_1": $content = getExtensionsForm($smarty, $module_name, $local_templates_dir, $dsnAsterisk, $dsnSqlite, $arrConf, false); break; case "next_1_vega": $content = getExtensionsVegaForm($smarty, $module_name, $local_templates_dir, $dsnAsterisk, $dsnSqlite, $arrConf, false); break; case "next_2": $content = getLinesForm($smarty, $module_name, $local_templates_dir, $dsnAsterisk, $dsnSqlite, $arrConf, false); break; case "next_2_vega": $content = getLinesVegaForm($smarty, $module_name, $local_templates_dir, $dsnAsterisk, $dsnSqlite, $arrConf, false); break; case "save": $content = savePatton($smarty, $module_name, $local_templates_dir, $dsnAsterisk, $dsnSqlite, $arrConf); break; case "save_vega": $content = saveVega($smarty, $module_name, $local_templates_dir, $dsnAsterisk, $dsnSqlite, $arrConf); break; case "return2": $content = getExtensionsForm($smarty, $module_name, $local_templates_dir, $dsnAsterisk, $dsnSqlite, $arrConf, true); break; case "return2_vega": $content = getExtensionsVegaForm($smarty, $module_name, $local_templates_dir, $dsnAsterisk, $dsnSqlite, $arrConf, true); break; default: // endpoint_show $content = buildReport($_SESSION['elastix_endpoints'], $smarty, $module_name, network()); break; } return $content; }
<col class="table-width-25pct" /> <col class="table-width-20pct" /> <col class="table-width-40pct" /> </colgroup> <thead> <tr> <th class="text-center">Actions</th> <th class="">Name</th> <th class="">Last User</th> <th class="">Description</th> </tr> </thead> <tbody id="deviceList"> <!-- Display a list of devices in the database --> <?php getDevices($curPage, $rowsPerPage); ?> </tbody> </table> </div> </div> </div><!-- #page-content --> </div><!-- #page-main --> </div><!-- #page-main-wrapper --> </div><!-- #page-wrapper --> </body> </html>
if (isset($verify["err_msg"])) { print $verify["err_msg"] . "\n\n"; display_help($me); exit(1); } $verify = verifyDevice($new, true); if (isset($verify["err_msg"])) { print $verify["err_msg"] . "\n\n"; display_help($me); exit(1); } #print "old2: "; print_r($old); #print "new2: "; print_r($new); # get all devices matching criteria $devices = getDevices($old); if (!sizeof($devices)) { echo __("ERROR: No matching Devices found") . "\n"; echo __("Try php -q device_list.php") . "\n"; exit(1); } #print "devices: "; print_r($devices); /* build raw SQL update command */ $sql_upd1 = "UPDATE device SET "; $sql_upd2 = ""; $sql_upd3 = " WHERE " . array_to_sql_or($devices, "id"); /* * if a new template is given, * how do we propagate the device template settings to the devices?
<?php // Brendan M. Lowe require_once "../inc/climate.php"; //No Session is created for this page because the Remote Pi's will be 'phoning home' to input.php to upload data switch ($_SERVER['REQUEST_METHOD']) { case 'POST': // Send output back to the python script/web browser echo json_encode($device_output); break; default: //GET - Index & Details if ($_GET['device_list'] == TRUE) { $device_output = getDevices(); $device_info = array(); while ($device = $device_output['info']->fetch_assoc()) { array_push($device_info, $device); } $device_output['info'] = $device_info; } // Send output back to the python script/web browser echo json_encode($device_output); }