private static function load_config() { $config = snarf_scope(SERVER_ROOT . '/config.php'); $config['address'] = $address = getArg('a', 'address', get($config, 'ip', '0.0.0.0')); $port = get($config, 'port', 10000); if (strpos($address, ':') !== false) { $parts = explode(':', $address); $address = $parts[0]; $port = (int) $parts[1]; } $config['port'] = getArg('p', 'port', $port); self::$config = $config; }
<?php $xml = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>"; //*********************************************************************************************************************** // V1.0 : Script qui fournit l'etat des ouvertures parametrees et le message vocal associe //*************************************** API eedomus ****************************************************************** //*************************************** Messages personnels*********************************************************** $msg_allclosed = "Apres vérification, tout est bien fermé"; $msg_open = "Je detecte que "; $tabouvertures = array(); // recuperation des ID depuis la requete $periphs = getArg("periphIds", $mandatory = true, $default = ''); $resultPeriphId = getArg("resultPeriphId", $mandatory = false, $default = ''); $tabPeriphs = explode(",", $periphs); //reset de l'indicateur 'portes ouverte' if ($resultPeriphId) { SetValue($resultPeriphId, 0); } // recuperation du nom des peripheriques foreach ($tabPeriphs as $periphId) { $urlValue = "http://localhost/api/get?action=periph.caract&periph_id={$periphId}"; $arrValue = sdk_json_decode(utf8_encode(httpQuery($urlValue, 'GET'))); $name = utf8_decode($arrValue["body"]["name"]); $tabouvertures[] = array("NAME" => $name, "API" => $periphId, "ETAT" => 0); } //********************************************************************************************************************** $xml .= "<OUVERTURES>"; $idoors = 1; $nbouvert = 0; $annonce = $msg_allclosed; foreach ($tabouvertures as $ouvertures) {
/** * This function allows to verify the signature * * @return boolean True if succeed, false otherwise * @throws RestException */ public function verifySignature() { $remote_app = getArg('app'); $signature = getArg('signature', '`^[0-9a-f]{40}$`'); $timestamp = (int) getArg('timestamp', '`^[0-9]+$`'); if (!$remote_app || !$signature || !$timestamp) { throw new RestException('Missing arguments', 401); } if (!array_key_exists($remote_app, self::$remote_apps)) { throw new RestException('Unknown remote application', 401); } $dfn = self::$remote_apps[$remote_app]; $data = self::$method; $get = $_GET; unset($get['signature']); ksort($get); $p = array(); foreach ($get as $k => $v) { $p[] = $k . '=' . $v; } $p = count($p) ? '?' . implode('&', $p) : ''; $data .= '&' . '/' . implode('/', self::$ressource) . $p; $data .= '&' . self::$data; if ($timestamp + Config::get('rest_request_timeout') < time()) { throw new RestException('Request out of date', 401); } if ($signature != hash_hmac('sha1', $data, $dfn['secret'])) { throw new RestException('Bad signature', 401); } if (in_array('*', $dfn['endpoints'])) { return; } if (!array_key_exists(self::$ressource[0], $dfn['endpoints'])) { throw new RestException('Not allowed to use handler', 403); } if (in_array('*', $dfn['endpoints'][self::$ressource[0]])) { return; } if (!array_key_exists(self::$method, $dfn['endpoints'][self::$ressource[0]])) { throw new RestException('Not allowed to use handler with this method', 403); } }
* * Param : * periph : L'identifiant (Code API) du periferique mesurant le vent * * Retour : * XML : Résultat formaté au format XML * *******************************************************************************/ // Seulement utile en mode test //require_once ("../eedomusScriptsEmulator.php"); //////////////////////////////////////////////////////////////////////////////// // Definition des points cardianux $cardinalArray = array('fr' => array('short' => array(array('N', '', ''), array('N', 'N', 'E'), array('N', 'N', 'E'), array('N', 'E', ''), array('N', 'E', ''), array('E', 'N', 'E'), array('E', 'N', 'E'), array('E', '', ''), array('E', '', ''), array('E', 'S', 'E'), array('E', 'S', 'E'), array('S', 'E', ''), array('S', 'E', ''), array('S', 'S', 'E'), array('S', 'S', 'E'), array('S', '', ''), array('S', '', ''), array('S', 'S', 'O'), array('S', 'S', 'O'), array('S', 'O', ''), array('S', 'O', ''), array('O', 'S', 'O'), array('O', 'S', 'O'), array('O', '', ''), array('O', '', ''), array('O', 'N', 'O'), array('O', 'N', 'O'), array('N', 'O', ''), array('N', 'O', ''), array('N', 'N', 'O'), array('N', 'N', 'O'), array('N', '', '')), 'long' => array(array('Nord', '', ''), array('Nord', '-Nord', '-Est'), array('Nord', '-Nord', '-Est'), array('Nord', '-Est', ''), array('Nord', '-Est', ''), array('Est', '-Nord', '-Est'), array('Est', '-Nord', '-Est'), array('Est', '', ''), array('Est', '', ''), array('Est', '-Sud', '-Est'), array('Est', '-Sud', '-Est'), array('Sud', '-Est', ''), array('Sud', '-Est', ''), array('Sud', '-Sud', '-Est'), array('Sud', '-Sud', '-Est'), array('Sud', '', ''), array('Sud', '', ''), array('Sud', '-Sud', '-Ouest'), array('Sud', '-Sud', '-Ouest'), array('Sud', '-Ouest', ''), array('Sud', '-Ouest', ''), array('Ouest', '-Sud', '-Ouest'), array('Ouest', '-Sud', '-Ouest'), array('Ouest', '', ''), array('Ouest', '', ''), array('Ouest', '-Nord', '-Ouest'), array('Ouest', '-Nord', '-Ouest'), array('Nord', '-Ouest', ''), array('Nord', '-Ouest', ''), array('Nord', '-Nord', '-Ouest'), array('Nord', '-Nord', '-Ouest'), array('Nord', '', ''))), 'en' => array('short' => array(array('N', '', ''), array('N', 'N', 'E'), array('N', 'N', 'E'), array('N', 'E', ''), array('N', 'E', ''), array('E', 'N', 'E'), array('E', 'N', 'E'), array('E', '', ''), array('E', '', ''), array('E', 'S', 'E'), array('E', 'S', 'E'), array('S', 'E', ''), array('S', 'E', ''), array('S', 'S', 'E'), array('S', 'S', 'E'), array('S', '', ''), array('S', '', ''), array('S', 'S', 'W'), array('S', 'S', 'W'), array('S', 'W', ''), array('S', 'W', ''), array('W', 'S', 'W'), array('W', 'S', 'W'), array('W', '', ''), array('W', '', ''), array('W', 'N', 'W'), array('W', 'N', 'W'), array('N', 'W', ''), array('N', 'W', ''), array('N', 'N', 'W'), array('N', 'N', 'W'), array('N', '', '')), 'long' => array(array('North', '', ''), array('North', '-North', '-East'), array('North', '-North', '-East'), array('North', '-East', ''), array('North', '-East', ''), array('East', '-North', '-East'), array('East', '-North', '-East'), array('East', '', ''), array('East', '', ''), array('East', '-South', '-East'), array('East', '-South', '-East'), array('South', '-East', ''), array('South', '-East', ''), array('South', '-South', '-East'), array('South', '-South', '-East'), array('South', '', ''), array('South', '', ''), array('South', '-South', '-West'), array('South', '-South', '-West'), array('South', '-West', ''), array('South', '-West', ''), array('West', '-South', '-West'), array('West', '-South', '-West'), array('West', '', ''), array('West', '', ''), array('West', '-North', '-West'), array('West', '-North', '-West'), array('North', '-West', ''), array('North', '-West', ''), array('North', '-North', '-West'), array('North', '-North', '-West'), array('North', '', '')))); //////////////////////////////////////////////////////////////////////////////// // Lecture du paramêtre du script $periphId = getArg('periph', true); //////////////////////////////////////////////////////////////////////////////// // Lecture de la valeur $aVal = getValue($periphId); $value = $aVal['value']; $change = $aVal['change']; //////////////////////////////////////////////////////////////////////////////// // Recherche de la division $step = 360 / 32; $divId = 0; for ($d = 0; $d <= 360; $d += $step) { if ($value >= $d and $value <= $d + $step) { break; } $divId++; }
<?php $idperiph = getArg('idperiph'); $operation = getArg('operation', false, NULL); $print = getArg('print', false, false); //-- Reload auto each day $CACHE_DURATION = 24 * 60; // minutes $last_reload = loadVariable('last_reload'); if ((time() - $last_reload) / 60 > $CACHE_DURATION) { $operation = "reload"; } //-- switch ($operation) { case "reload": $conso_devices = array(); $list = getPeriphList(); foreach ($list as $device) { if ($device['utilisation_id'] == 26 && $device['controller_module_id'] != $idperiph) { $conso_devices[] = $device; } } saveVariable('conso_devices', $conso_devices); saveVariable('last_reload', time()); default: $total = 0; $print_devices = array("total" => 0, "devices" => array()); $conso_devices = loadVariable('conso_devices'); foreach ($conso_devices as $device) { $value = getValue($device["controller_module_id"]); if ($value["value"] > 0 && $device["parent_controller_module_id"] != "") {
} function getArg($argname) { if (empty($_POST[$argname])) { echo "no {$argname}"; return ""; } else { $arg = $_POST[$argname]; if (!isStringAllowed($arg)) { echo "illegal character in {$argname}"; return ""; } } return $_POST[$argname]; } $name = getArg("name"); if (empty($name)) { return; } if (strlen($name) > 32) { echo "account name too long"; return; } if (empty($_POST["password"])) { echo "no password"; return; } else { $password = $_POST["password"]; } ob_start(); exec("/usr/bin/id {$name}", $output);