public function execute($_options = array()) { $replace = array(); switch ($this->getSubType()) { case 'slider': $replace['#slider#'] = $_options['slider']; break; case 'color': $replace['#color#'] = $_options['color']; break; case 'message': $replace['#title#'] = $_options['title']; $replace['#message#'] = $_options['message']; break; } $eqLogic = $this->getEqLogic(); $url = 'https://maker.ifttt.com/trigger/' . $this->getConfiguration('event', 'jeedom') . '/with/key/' . $eqLogic->getConfiguration('key') . '?'; if ($this->getConfiguration('value1') != '') { $url .= 'value1=' . urlencode(jeedom::evaluateExpression(str_replace(array_keys($replace), $replace, $this->getConfiguration('value1')))) . '&'; } if ($this->getConfiguration('value2') != '') { $url .= 'value2=' . urlencode(jeedom::evaluateExpression(str_replace(array_keys($replace), $replace, $this->getConfiguration('value2')))) . '&'; } if ($this->getConfiguration('value3') != '') { $url .= 'value3=' . urlencode(jeedom::evaluateExpression(str_replace(array_keys($replace), $replace, $this->getConfiguration('value3')))) . '&'; } $url = trim($url, '&'); $request_http = new com_http($url); $request_http->exec(5, 3); }
/** * Ajoute une clef à la config * @param string $_key nom de la clef * @param string $_value valeur de la clef * @return boolean vrai si ok faux sinon */ public static function save($_key, $_value, $_plugin = 'core') { if (is_object($_value) || is_array($_value)) { $_value = json_encode($_value, JSON_UNESCAPED_UNICODE); } if (isset(self::$cache[$_plugin . '::' . $_key])) { unset(self::$cache[$_plugin . '::' . $_key]); } $defaultConfiguration = self::getDefaultConfiguration($_plugin); if (isset($defaultConfiguration[$_plugin][$_key]) && $_value == $defaultConfiguration[$_plugin][$_key]) { self::remove($_key, $_plugin); return true; } $jeedomConfig = jeedom::getConfiguration($_key, true); if ($jeedomConfig != '' && $jeedomConfig == $_value) { self::remove($_key); return true; } $values = array('plugin' => $_plugin, 'key' => $_key, 'value' => $_value); $sql = 'REPLACE config SET `key`=:key, `value`=:value, plugin=:plugin'; return DB::Prepare($sql, $values, DB::FETCH_TYPE_ROW); }
function openzwave_update() { if (openzwave::deamonRunning()) { echo 'Stop zwave network...'; openzwave::stopDeamon(); echo "OK\n"; } echo 'Stop cron...'; $cron = cron::byClassAndFunction('openzwave', 'pull'); if (config::byKey('jeeNetwork::mode') != 'slave') { if (!is_object($cron)) { $cron = new cron(); } $cron->setClass('openzwave'); $cron->setFunction('pull'); $cron->setEnable(1); $cron->setDeamon(1); $cron->setDeamonSleepTime(0.5); $cron->setTimeout(1440); $cron->setSchedule('* * * * *'); $cron->save(); $cron->stop(); } else { if (is_object($cron)) { $cron->remove(); } } echo "OK\n"; echo 'Check zwave system...'; if (count(eqLogic::byType('zwave')) > 0) { log::add('openzwave', 'error', 'Attention vous etes sur la nouvelle version d\'openzwave, des actions de votre part sont necessaire merci d\'aller voir https://jeedom.fr/blog/?p=1576'); } if (config::byKey('port', 'openzwave', 'none') != 'none') { if (method_exists('openzwave', 'getVersion')) { if (version_compare(config::byKey('openzwave_version', 'openzwave'), openzwave::getVersion('openzwave'), '>')) { if (jeedom::getHardwareName() == 'Jeedomboard') { config::save('allowStartDeamon', 0, 'openzwave'); openzwave::updateOpenzwave(false); config::save('allowStartDeamon', 1, 'openzwave'); } else { log::add('openzwave', 'error', __('Attention votre version d\'openzwave est dépassée sur le démon local, il faut ABSOLUMENT la mettre à jour', __FILE__)); } } } } if (config::byKey('jeeNetwork::mode') == 'master') { foreach (jeeNetwork::byPlugin('openzwave') as $jeeNetwork) { try { if ($jeeNetwork->configByKey('port', 'openzwave', 'none') != 'none') { if (version_compare($jeeNetwork->sendRawRequest('getVersion', array('plugin' => 'openzwave', 'module' => 'openzwave')), openzwave::getVersion('openzwave'), '>')) { log::add('openzwave', 'error', __('Attention votre version d\'openzwave est dépassée sur', __FILE__) . ' ' . $jeeNetwork->getName() . ' ' . __('il faut ABSOLUMENT la mettre à jour', __FILE__)); } } } catch (Exception $e) { } } } echo "OK\n"; }
function openzwave_update() { log::add('openzwave', 'error', __('Après toute installation/mise à jour pensez bien à mettre à jour les dépendances Openzwave (voir documentation)', __FILE__)); if (!file_exists(dirname(__FILE__) . '/../data')) { mkdir(dirname(__FILE__) . '/../data'); } shell_exec('cp -R /opt/python-openzwave/xml_backups ' . dirname(__FILE__) . '/../data'); shell_exec('cp -R /opt/python-openzwave/zwcfg_*.xml ' . dirname(__FILE__) . '/../data'); shell_exec('rm -rf /opt/python-openzwave/xml_backups'); shell_exec('rm -rf /opt/python-openzwave/zwcfg_*.xml'); config::save('allowStartDeamon', 0, 'openzwave'); echo 'Stop zwave network...'; openzwave::stop(); openzwave::stopDeamon(); echo "OK\n"; echo 'Stop cron...'; $cron = cron::byClassAndFunction('openzwave', 'pull'); if (is_object($cron)) { $cron->remove(); } echo "OK\n"; echo 'Check zwave system...'; if (count(eqLogic::byType('zwave')) > 0) { log::add('openzwave', 'error', 'Attention vous etes sur la nouvelle version d\'openzwave, des actions de votre part sont necessaire merci d\'aller voir https://jeedom.fr/blog/?p=1576'); } if (config::byKey('port', 'openzwave', 'none') != 'none') { if (method_exists('openzwave', 'getVersion')) { if (version_compare(config::byKey('openzwave_version', 'openzwave'), openzwave::getVersion('openzwave'), '>')) { if (jeedom::getHardwareName() == 'Jeedomboard') { openzwave::updateOpenzwave(false); } else { log::add('openzwave', 'error', __('Attention votre version d\'openzwave est dépassée sur le démon local, il faut ABSOLUMENT la mettre à jour', __FILE__)); } } } } if (config::byKey('jeeNetwork::mode') == 'master') { foreach (jeeNetwork::byPlugin('openzwave') as $jeeNetwork) { try { if ($jeeNetwork->configByKey('port', 'openzwave', 'none') != 'none') { if (version_compare($jeeNetwork->sendRawRequest('getVersion', array('plugin' => 'openzwave', 'module' => 'openzwave')), openzwave::getVersion('openzwave'), '>')) { log::add('openzwave', 'error', __('Attention votre version d\'openzwave est dépassée sur', __FILE__) . ' ' . $jeeNetwork->getName() . ' ' . __('il faut ABSOLUMENT la mettre à jour', __FILE__)); } } } catch (Exception $e) { } } } echo "OK\n"; echo 'Redemarrage zwave network...'; try { config::save('allowStartDeamon', 1, 'openzwave'); openzwave::runDeamon(); } catch (Exception $e) { } echo "OK\n"; }
/** * Retourne un object utilisateur (si les information de connection sont valide) * @param string $_login nom d'utilisateur * @param string $_mdp motsz de passe en sha1 * @return user object user */ public static function connect($_login, $_mdp, $_passAlreadyEncode = false) { if ($_passAlreadyEncode) { $sMdp = $_mdp; } else { $sMdp = sha1($_mdp); } if (config::byKey('ldap:enable') == '1') { log::add("connection", "debug", __('Authentification par LDAP', __FILE__)); $ad = self::connectToLDAP(); if ($ad !== false) { log::add("connection", "debug", __('Connection au LDAP OK', __FILE__)); $ad = ldap_connect(config::byKey('ldap:host'), config::byKey('ldap:port')); ldap_set_option($ad, LDAP_OPT_PROTOCOL_VERSION, 3); ldap_set_option($ad, LDAP_OPT_REFERRALS, 0); if (!ldap_bind($ad, 'uid=' . $_login . ',' . config::byKey('ldap:basedn'), $_mdp)) { log::add("connection", "info", __('Mot de passe erroné (', __FILE__) . $_login . ')'); return false; } log::add("connection", "debug", __('Bind user OK', __FILE__)); $result = ldap_search($ad, 'uid=' . $_login . ',' . config::byKey('ldap:basedn'), config::byKey('ldap:filter')); log::add("connection", "info", __('Recherche LDAP (', __FILE__) . $_login . ')'); if ($result) { $entries = ldap_get_entries($ad, $result); if ($entries['count'] > 0) { $user = self::byLogin($_login); if (is_object($user)) { $user->setPassword($sMdp); $user->setOptions('lastConnection', date('Y-m-d H:i:s')); $user->save(); return $user; } $user = new user(); $user->setLogin($_login); $user->setPassword($sMdp); $user->setOptions('lastConnection', date('Y-m-d H:i:s')); $user->save(); log::add("connection", "info", __('Utilisateur créé depuis le LDAP : ', __FILE__) . $_login); jeedom::event('user_connect'); log::add('event', 'event', __('Connexion de l\'utilisateur ', __FILE__) . $_login); return $user; } else { $user = self::byLogin($_login); if (is_object($user)) { $user->remove(); } log::add("connection", "info", __('Utilisateur non autorisé à accéder à Jeedom (', __FILE__) . $_login . ')'); return false; } } else { $user = self::byLogin($_login); if (is_object($user)) { $user->remove(); } log::add("connection", "info", __('Utilisateur non autorisé à accéder à Jeedom (', __FILE__) . $_login . ')'); return false; } return false; } else { log::add("connection", "info", __('Impossible de se connecter au LDAP', __FILE__)); } } $values = array('login' => $_login, 'password' => $sMdp); $sql = 'SELECT ' . DB::buildField(__CLASS__) . ' FROM user WHERE login=:login AND password=:password'; $user = DB::Prepare($sql, $values, DB::FETCH_TYPE_ROW, PDO::FETCH_CLASS, __CLASS__); if (is_object($user)) { $user->setOptions('lastConnection', date('Y-m-d H:i:s')); $user->save(); jeedom::event('user_connect'); log::add('event', 'event', __('Connexion de l\'utilisateur ', __FILE__) . $_login); if ($user->getOptions('validity_limit') != '' && strtotime('now') > strtotime($user->getOptions('validity_limit'))) { $user->remove(); return false; } } return $user; }
if (!move_uploaded_file($_FILES['file']['tmp_name'], $uploaddir . '/' . $_FILES['file']['name'])) { throw new Exception(__('Impossible de déplacer le fichier temporaire', __FILE__)); } if (!file_exists($uploaddir . '/' . $_FILES['file']['name'])) { throw new Exception(__('Impossible d\'uploader le fichier (limite du serveur web ?)', __FILE__)); } ajax::success(); } if (init('action') == 'haltSystem') { ajax::success(jeedom::haltSystem()); } if (init('action') == 'rebootSystem') { ajax::success(jeedom::rebootSystem()); } if (init('action') == 'forceSyncHour') { ajax::success(jeedom::forceSyncHour()); } if (init('action') == 'saveCustom') { $path = dirname(__FILE__) . '/../../'; if (init('version') != 'desktop' && init('version') != 'mobile') { throw new Exception(__('La version ne peut etre que desktop ou mobile', __FILE__)); } if (init('type') != 'js' && init('type') != 'css') { throw new Exception(__('La version ne peut etre que js ou css', __FILE__)); } $path .= init('version') . '/custom/'; if (!file_exists($path)) { mkdir($path); } $path .= 'custom.' . init('type'); if (file_exists($path)) {
public function setOptions($_key, $_value) { $this->options = utils::setJsonAttr($this->options, $_key, jeedom::fromHumanReadable($_value)); }
public function save() { if ($this->getQuery() == '') { throw new Exception(__('La commande (demande) ne peut pas être vide', __FILE__)); } $this->setLink_id(str_replace('#', '', jeedom::fromHumanReadable($this->getLink_id()))); return DB::save($this); }
if (!isConnect('admin')) { throw new Exception(__('401 - Accès non autorisé', __FILE__)); } $scenario = scenario::byId(init('id')); if (!is_object($scenario)) { throw new Exception(__('Scénario ID inconnu', __FILE__)); } ajax::success(utils::o2a($scenario->copy(init('name')))); } if (init('action') == 'get') { $scenario = scenario::byId(init('id')); if (!is_object($scenario)) { throw new Exception(__('Scénario ID inconnu', __FILE__)); } $return = utils::o2a($scenario); $return['trigger'] = jeedom::toHumanReadable($return['trigger']); $return['forecast'] = $scenario->calculateScheduleDate(); $return['elements'] = array(); foreach ($scenario->getElement() as $element) { $return['elements'][] = $element->getAjaxElement(); } ajax::success($return); } if (init('action') == 'save') { if (!isConnect('admin')) { throw new Exception(__('401 - Accès non autorisé', __FILE__)); } $time_dependance = 0; $time_keyword = array('#time#', '#seconde#', '#heure#', '#minute#', '#jour#', '#mois#', '#annee#', '#timestamp#', '#date#', '#semaine#', '#sjour#', '#njour#', '#smois#'); foreach ($time_keyword as $keyword) { if (strpos(init('scenario'), $keyword) !== false) {
public function launch($_function) { if ($_function == '') { throw new Exception('La fonction à lancer ne peut être vide'); } if (!class_exists($this->getId()) || !method_exists($this->getId(), $_function)) { throw new Exception('Il n\'existe aucune méthode : ' . $this->getId() . '::' . $_function . '()'); } $cmd = 'php ' . dirname(__FILE__) . '/../../core/php/jeePlugin.php '; $cmd .= ' plugin_id=' . $this->getId(); $cmd .= ' function=' . $_function; if (jeedom::checkOngoingThread($cmd) > 0) { return true; } exec($cmd . ' >> /dev/null 2>&1 &'); return true; }
<?php if (!hasRight('sysinfo', true)) { throw new Exception('{{401 - Accès non autorisé}}'); } ?> <iframe id="frame_sysinfo" src="<?php echo jeedom::getCurrentSysInfoFolder(); ?> /index.php" style="width : 100%;height : 1200px;border : none;"></iframe> <script> var hWindow = $(window).height() - $('header').height() - $('footer').height() - 50; $('#frame_sysinfo').height(hWindow); </script>
public static function deamonRunning() { $pid_file = realpath(dirname(__FILE__) . '/../../../../tmp/rfxcom.pid'); if (!file_exists($pid_file)) { $pid = jeedom::retrievePidThread('rfxcmd.py'); if ($pid != '' && is_numeric($pid)) { exec('kill -9 ' . $pid); } return false; } $pid = trim(file_get_contents($pid_file)); if ($pid == '' || !is_numeric($pid)) { $pid = jeedom::retrievePidThread('rfxcmd.py'); if ($pid != '' && is_numeric($pid)) { exec('kill -9 ' . $pid); } return false; } $result = exec('ps -p' . $pid . ' e | grep "rfxcmd" | wc -l'); if ($result == 0) { unlink($pid_file); return false; } return true; }
public function toHtml($_version) { if ($this->getIsEnable() != 1) { return ''; } if (!$this->hasRight('r')) { return ''; } $_version = jeedom::versionAlias($_version); $replace = array('#id#' => $this->getId(), '#name#' => $this->getIsEnable() ? $this->getName() : '<del>' . $this->getName() . '</del>', '#background_color#' => $this->getBackgroundColor($_version), '#eqLink#' => $this->getLinkToConfiguration()); $Departs = $this->getCmd(null, 'Departs'); $replace['#Departs#'] = is_object($Departs) ? $Departs->execCmd() : ''; $RefreshAction = $this->getCmd(null, 'RefreshAction'); $replace['#refresh_id#'] = is_object($RefreshAction) ? $RefreshAction->getId() : ''; return template_replace($replace, getTemplate('core', $_version, 'eqlogic', 'trains')); }
throw new Exception(__('Cmd ID inconnu : ', __FILE__) . init('id')); } $return = jeedom::toHumanReadable(utils::o2a($cmd)); $eqLogic = $cmd->getEqLogic(); $return['eqLogic_name'] = $eqLogic->getName(); $return['plugin'] = $eqLogic->getEqType_Name(); if ($eqLogic->getObject_id() > 0) { $return['object_name'] = $eqLogic->getObject()->getName(); } ajax::success($return); } if (init('action') == 'save') { if (!isConnect('admin')) { throw new Exception(__('401 - Accès non autorisé', __FILE__)); } $cmd_ajax = jeedom::fromHumanReadable(json_decode(init('cmd'), true)); $cmd = cmd::byId($cmd_ajax['id']); if (!is_object($cmd)) { $cmd = new cmd(); } utils::a2o($cmd, $cmd_ajax); $cmd->save(); ajax::success(); } if (init('action') == 'changeHistoryPoint') { if (!isConnect('admin')) { throw new Exception(__('401 - Accès non autorisé', __FILE__)); } $history = history::byCmdIdDatetime(init('cmd_id'), init('datetime')); if (!is_object($history)) { throw new Exception(__('Aucun point ne correspond pour l\'historique : ', __FILE__) . init('cmd_id') . ' - ' . init('datetime'));
$result['nbInteractQuery'] = count(interactQuery::byInteractDefId($result['id'])); $result['nbEnableInteractQuery'] = count(interactQuery::byInteractDefId($result['id'], true)); if ($result['link_type'] == 'cmd' && $result['link_id'] != '') { $link_id = ''; foreach (explode('&&', $result['link_id']) as $cmd_id) { $cmd = cmd::byId($cmd_id); if (is_object($cmd)) { $link_id .= cmd::cmdToHumanReadable('#' . $cmd->getId() . '# && '); } } $result['link_id'] = trim(trim($link_id), '&&'); } ajax::success(jeedom::toHumanReadable($result)); } if (init('action') == 'save') { $interact_json = jeedom::fromHumanReadable(json_decode(init('interact'), true)); if (isset($interact_json['id'])) { $interact = interactDef::byId($interact_json['id']); } if (!isset($interact) || !is_object($interact)) { $interact = new interactDef(); } utils::a2o($interact, $interact_json); $interact->save(); ajax::success(utils::o2a($interact)); } if (init('action') == 'regenerateInteract') { interactDef::regenerateInteract(); ajax::success(); } if (init('action') == 'remove') {
<label class="col-lg-4 control-label">{{Dépendance OpenZwave locale}}</label> <div class="col-lg-3"> <a class="btn btn-warning bt_installDeps"><i class="fa fa-check"></i> {{Installer/Mettre à jour}}</a> </div> </div>'; } else { echo '<div class="alert alert danger">{{Jeedom n\'a pas les droits sudo sur votre système, il faut lui ajouter pour qu\'il puisse installer le démon openzwave, voir <a target="_blank" href="https://jeedom.fr/doc/documentation/installation/fr_FR/doc-installation.html#autre">ici</a> partie 1.7.4}}</div>'; } ?> <div class="form-group"> <label class="col-sm-4 control-label">{{Port clé Z-Wave}}</label> <div class="col-sm-4"> <select class="configKey form-control" data-l1key="port"> <option value="none">{{Aucun}}</option> <?php foreach (jeedom::getUsbMapping('', true) as $name => $value) { echo '<option value="' . $name . '">' . $name . ' (' . $value . ')</option>'; } ?> </select> </div> </div> <div class="form-group"> <label class="col-sm-4 control-label">{{Port du Serveur (laisser vide par défault)}}</label> <div class="col-sm-2"> <input class="configKey form-control" data-l1key="port_server" placeholder="8083" /> </div> </div> <div class="form-group"> <label class="col-sm-4 control-label">{{Mode "direct push" (recommandé)}}</label> <div class="col-sm-2">
public static function whatDoYouKnow($_object = null) { $results = jeedom::whatDoYouKnow($_object); $reply = ''; foreach ($results as $object) { $reply .= __('*** Je sais que pour ', __FILE__) . $object['name'] . " : \n"; foreach ($object['eqLogic'] as $eqLogic) { foreach ($eqLogic['cmd'] as $cmd) { $reply .= $eqLogic['name'] . ' ' . $cmd['name'] . ' = ' . $cmd['value'] . ' ' . $cmd['unite'] . "\n"; } } } return $reply; }
public static function cron() { if (config::byKey('market::allowDNS') == 1 && !network::test('external', false, 120)) { network::dns_start(); } if (config::byKey('network::disableMangement') == 1) { return; } if (!jeedom::isCapable('sudo')) { return; } try { $gws = self::checkGw(); if (count($gws) == 0) { log::add('network', 'error', __('Aucune interface réseau trouvée, je redemarre tous les réseaux', __FILE__)); exec('sudo service networking restart'); return; } foreach ($gws as $iface => $gw) { if ($gw['ping'] != 'ok') { if (strpos($iface, 'tun') !== false) { continue; } if (strpos($iface, 'br0') !== false) { continue; } log::add('network', 'error', __('La passerelle distante de l\'interface ', __FILE__) . $iface . __(' est injoignable, je la redemarre pour essayer de corriger', __FILE__)); exec('sudo ifdown ' . $iface); sleep(5); exec('sudo ifup --force ' . $iface); } } } catch (Exception $e) { } }
public static function updateSystem() { if (config::byKey('update::autoSystem') == 1 && jeedom::isCapable('systemUpdate') && jeedom::isCapable('sudo')) { $output = array(); $return_val = -1; log::remove('system_update'); exec('sudo apt-get -y update >> ' . log::getPathToLog('system_update') . ' 2>&1', $output, $return_val); if ($return_val != 0) { log::add('update', 'error', __('Echec de la mise à jour des dépot, veuillez consulter la log system_update', __FILE__)); return; } exec('sudo DEBIAN_FRONTEND=noninteractive apt-get -q -y -o "Dpkg::Options::=--force-confdef" -o "Dpkg::Options::=--force-confold" dist-upgrade >> ' . log::getPathToLog('system_update') . ' 2>&1', $output, $return_val); if ($return_val != 0) { log::add('update', 'error', __('Echec de la mise à jour des paquets, veuillez consulter la log system_update', __FILE__)); return; } exec('sudo apt-get -y autoremove >> ' . log::getPathToLog('system_update') . ' 2>&1', $output, $return_val); if ($return_val != 0) { log::add('update', 'error', __('Echec su nettoyage des paquets, veuillez consulter la log system_update', __FILE__)); return; } exec('sudo service cron restart'); } }
<?php require_once dirname(__FILE__) . '/../../core/php/core.inc.php'; if (!isConnect('admin')) { throw new Exception(__('401 - Accès non autorisé', __FILE__)); } if ($_GET['shut'] == 1) { jeedom::haltSystem(); } else { jeedom::rebootSystem(); }
$cron->save(); $cron = cron::byClassAndFunction('plugin', 'cron30'); if (!is_object($cron)) { echo "Création de plugin::cron30\n"; $cron = new cron(); } $cron->setClass('plugin'); $cron->setFunction('cron30'); $cron->setSchedule('*/30 * * * * *'); $cron->setTimeout(60); $cron->save(); $dynamic_apache_path = dirname(__FILE__) . '/../core/config/apache_jeedom_dynamic_rules'; if (!file_exists($dynamic_apache_path)) { touch($dynamic_apache_path); } if (jeedom::isCapable('sudo')) { if (!file_exists('/var/log/auth.log')) { exec('sudo touch /var/log/auth.log'); exec('sudo service fail2ban restart'); } exec('sudo service cron restart'); } cache::deleteBySearch('widgetHtml'); cache::deleteBySearch('cmdWidgetdashboard'); cache::deleteBySearch('cmdWidgetmobile'); cache::deleteBySearch('scenarioHtmldashboard'); config::save('hardware_name', ''); } catch (Exception $e) { echo "Error : "; echo $e->getMessage(); }
public function getAjaxElement($_mode = 'ajax') { $return = utils::o2a($this); if ($_mode == 'array') { if (isset($return['id'])) { unset($return['id']); } if (isset($return['scenarioElement_id'])) { unset($return['scenarioElement_id']); } if (isset($return['log'])) { unset($return['log']); } if (isset($return['_expression'])) { unset($return['_expression']); } } $return['subElements'] = array(); foreach ($this->getSubElement() as $subElement) { $subElement_ajax = utils::o2a($subElement); if ($_mode == 'array') { if (isset($subElement_ajax['id'])) { unset($subElement_ajax['id']); } if (isset($subElement_ajax['scenarioElement_id'])) { unset($subElement_ajax['scenarioElement_id']); } if (isset($subElement_ajax['log'])) { unset($subElement_ajax['log']); } if (isset($subElement_ajax['_expression'])) { unset($subElement_ajax['_expression']); } } $subElement_ajax['expressions'] = array(); foreach ($subElement->getExpression() as $expression) { $expression_ajax = utils::o2a($expression); if ($_mode == 'array') { if (isset($expression_ajax['id'])) { unset($expression_ajax['id']); } if (isset($expression_ajax['scenarioSubElement_id'])) { unset($expression_ajax['scenarioSubElement_id']); } if (isset($expression_ajax['log'])) { unset($expression_ajax['log']); } if (isset($expression_ajax['_expression'])) { unset($expression_ajax['_expression']); } } if ($expression->getType() == 'element') { $element = self::byId($expression->getExpression()); if (is_object($element)) { $expression_ajax['element'] = $element->getAjaxElement($_mode); if ($_mode == 'array') { if (isset($expression_ajax['element']['id'])) { unset($expression_ajax['element']['id']); } if (isset($expression_ajax['element']['scenarioElement_id'])) { unset($expression_ajax['element']['scenarioElement_id']); } if (isset($expression_ajax['element']['log'])) { unset($expression_ajax['element']['log']); } if (isset($expression_ajax['element']['_expression'])) { unset($expression_ajax['element']['_expression']); } } } } $expression_ajax = jeedom::toHumanReadable($expression_ajax); $subElement_ajax['expressions'][] = $expression_ajax; } $return['subElements'][] = $subElement_ajax; } return $return; }
public static function runDeamon($_debug = false) { if (config::byKey('allowStartDeamon', 'openzwave', 1) == 0) { return; } try { self::stopDeamon(); } catch (Exception $e) { } log::add('openzwave', 'info', 'Lancement du démon openzwave'); $port = config::byKey('port', 'openzwave'); if ($port != 'auto') { $port = jeedom::getUsbMapping($port, true); if (@(!file_exists($port))) { throw new Exception(__('Le port : ', __FILE__) . print_r($port, true) . __(' n\'existe pas', __FILE__)); } exec('sudo chmod 777 ' . $port . ' > /dev/null 2>&1'); } $port_server = config::byKey('port_server', 'openzwave', 8083); $openzwave_path = realpath(dirname(__FILE__) . '/../../ressources/zwaveserver'); $config_path = realpath(dirname(__FILE__) . '/../../ressources/openzwave/config'); $log = $_debug ? 'Debug' : 'Info'; $cmd = '/usr/bin/python ' . $openzwave_path . '/openZWave.py --pidfile=/tmp/openzwave.pid --device=' . $port . ' --log=' . $log . ' --port=' . $port_server . ' --config=' . $config_path; log::add('openzwave', 'info', 'Lancement démon openzwave : ' . $cmd); $result = exec($cmd . ' >> ' . log::getPathToLog('openzwave') . ' 2>&1 &'); if (strpos(strtolower($result), 'error') !== false || strpos(strtolower($result), 'traceback') !== false) { log::add('openzwave', 'error', $result); return false; } $i = 0; while ($i < 30) { if (self::deamonRunning()) { break; } sleep(1); $i++; } if ($i >= 30) { log::add('openzwave', 'error', 'Impossible de lancer le démon openzwave, vérifiez le port', 'unableStartDeamon'); return false; } message::removeAll('openzwave', 'unableStartDeamon'); log::add('openzwave', 'info', 'Démon openzwave lancé'); }
public function toHtml($_version = 'dashboard') { if ($this->getIsEnable() != 1) { return ''; } if (!$this->hasRight('r')) { return ''; } $_version = jeedom::versionAlias($_version); $background = $this->getBackgroundColor($_version); $replace = array('#name#' => $this->getName(), '#id#' => $this->getId(), '#background_color#' => $background, '#eqLink#' => $this->getLinkToConfiguration(), '#height#' => $this->getDisplay('height', 'auto'), '#width#' => $this->getDisplay('width', '200px'), '#temperature_airneufexterieur#' => jeedom::evaluateExpression($this->getConfiguration('temperature_airneufexterieur')), '#temperature_airneufinsuflé#' => jeedom::evaluateExpression($this->getConfiguration('temperature_airneufinsuflé')), '#temperature_airvicie#' => jeedom::evaluateExpression($this->getConfiguration('temperature_airvicie')), '#temperature_airvicierejete#' => jeedom::evaluateExpression($this->getConfiguration('temperature_airvicierejete'))); $parameters = $this->getDisplay('parameters'); if (is_array($parameters)) { foreach ($parameters as $key => $value) { $replace['#' . $key . '#'] = $value; } } $html = template_replace($replace, getTemplate('core', $_version, 'eqLogic', 'vmc')); return $html; }
<?php if (jeedom::getHardwareName() == 'Jeedomboard' && jeedom::isCapable('sudo')) { echo '**************Mise à jour du système (peut etre très long)**************'; echo shell_exec('sudo touch /var/log/auth.log'); echo 'Mise à jour des sources'; echo shell_exec('sudo apt-get update'); echo "OK\n"; echo 'Mise à jour des paquets'; echo shell_exec('sudo apt-get dist-upgrade'); echo "OK\n"; echo 'Redemarrage fail2ban'; echo shell_exec('sudo service fail2ban restart'); echo "OK\n"; }
* * Jeedom is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Jeedom is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Jeedom. If not, see <http://www.gnu.org/licenses/>. */ require_once dirname(__FILE__) . "/../../../../core/php/core.inc.php"; if (!jeedom::apiAccess(init('apikey'))) { connection::failed(); echo 'Clef API non valide, vous n\'etes pas autorisé à effectuer cette action (jeeZwave)'; die; } if (isset($_GET['test'])) { echo 'OK'; die; } if (isset($_GET['stopOpenzwave'])) { config::save('allowStartDeamon', 0, 'openzwave'); openzwave::stopDeamon(); die; } if (isset($_GET['startOpenzwave'])) { log::add('openzwave', 'debug', 'Restart Zwave deamon');
*/ try { require_once dirname(__FILE__) . '/../../core/php/core.inc.php'; include_file('core', 'authentification', 'php'); if (!isConnect()) { throw new Exception(__('401 - Accès non autorisé', __FILE__)); } if (init('action') == 'getConf') { if (!isConnect('admin')) { throw new Exception(__('401 - Accès non autorisé', __FILE__)); } $plugin = plugin::byId(init('id')); $return = utils::o2a($plugin); $return['activate'] = $plugin->isActive(); $return['configurationPath'] = $plugin->getPathToConfigurationById(); $return['checkVersion'] = version_compare(jeedom::version(), $plugin->getRequire()); $return['status'] = market::getInfo(array('logicalId' => $plugin->getId(), 'type' => 'plugin')); $return['update'] = utils::o2a(update::byLogicalId($plugin->getId())); ajax::success($return); } if (init('action') == 'toggle') { if (!isConnect('admin')) { throw new Exception(__('401 - Accès non autorisé', __FILE__)); } $plugin = plugin::byId(init('id')); if (!is_object($plugin)) { throw new Exception(__('Plugin introuvable : ', __FILE__) . init('id')); } $plugin->setIsEnable(init('state')); ajax::success(); }
public function checkCmdAlert($_value) { if ($this->getConfiguration('jeedomCheckCmdOperator') == '' || $this->getConfiguration('jeedomCheckCmdTest') == '' || $this->getConfiguration('jeedomCheckCmdTime') == '' || is_nan($this->getConfiguration('jeedomCheckCmdTime'))) { return; } $check = jeedom::evaluateExpression($_value . $this->getConfiguration('jeedomCheckCmdOperator') . $this->getConfiguration('jeedomCheckCmdTest')); if ($check == 1 || $check || $check == '1') { if ($this->getConfiguration('jeedomCheckCmdTime') == 0) { $this->executeAlertCmdAction(); return; } $cron = cron::byClassAndFunction('cmd', 'cmdAlert', array('cmd_id' => intval($this->getId()))); if (!is_object($cron)) { $cron = new cron(); } $cron->setClass('cmd'); $cron->setFunction('cmdAlert'); $cron->setOnce(1); $cron->setOption(array('cmd_id' => intval($this->getId()))); $next = strtotime('+ ' . ($this->getConfiguration('jeedomCheckCmdTime') + 1) . ' minutes ' . date('Y-m-d H:i:s')); $schedule = date('i', $next) . ' ' . date('H', $next) . ' ' . date('d', $next) . ' ' . date('m', $next) . ' * ' . date('Y', $next); $cron->setSchedule($schedule); $cron->setLastRun(date('Y-m-d H:i:s')); $cron->save(); } else { $cron = cron::byClassAndFunction('cmd', 'cmdAlert', array('cmd_id' => intval($this->getId()))); if (is_object($cron)) { $cron->remove(); } } }
<div class="col-sm-6"> <select class="eqLogicAttr form-control" data-l1key="object_id"> <option value="">{{Aucun}}</option> <?php foreach (object::all() as $object) { echo '<option value="' . $object->getId() . '">' . $object->getName() . '</option>'; } ?> </select> </div> </div> <div class="form-group"> <label class="col-sm-4 control-label">{{Catégorie}}</label> <div class="col-sm-8"> <?php foreach (jeedom::getConfiguration('eqLogic:category') as $key => $value) { echo '<label class="checkbox-inline">'; echo '<input type="checkbox" class="eqLogicAttr" data-l1key="category" data-l2key="' . $key . '" />' . $value['name']; echo '</label>'; } ?> </div> </div> <div class="form-group"> <label class="col-sm-4 control-label"></label> <div class="col-sm-8"> <input type="checkbox" class="eqLogicAttr bootstrapSwitch" data-label-text="{{Activer}}" data-l1key="isEnable" checked/> <input type="checkbox" class="eqLogicAttr bootstrapSwitch" data-label-text="{{Visible}}" data-l1key="isVisible" checked/> </div> </div> <div class="form-group expertModeVisible">
if ($market->getCost() != $market->getRealCost()) { echo '<span data-l1key="rating" style="font-size: 1em;text-decoration:line-through;">' . number_format($market->getRealCost(), 2) . ' €</span> '; } echo '<span data-l1key="rating" style="font-size: 1.5em;">' . number_format($market->getCost(), 2) . ' € TTC</span>'; } else { echo '<span data-l1key="rating" style="font-size: 1.5em;">{{Gratuit}}</span>'; } ?> </div> </div> <?php if ($market->getCertification() != 'Officiel') { echo '<div class="alert alert-warning">{{Attention ce plugin n\'est pas un plugin officiel en cas de soucis avec celui-ci (direct ou indirect) toute demande de support peut être refusée}}</div>'; } $compatibilityHardware = $market->getHardwareCompatibility(); if (is_array($compatibilityHardware) && count($compatibilityHardware) > 0 && $compatibilityHardware[jeedom::getHardwareName()] != 1) { echo '<div class="alert alert-danger">{{Attention ce plugin ne semble pas être compatible avec votre système}}</div>'; } ?> <div style="display: none;width : 100%" id="div_alertMarketDisplay"></div> <?php if (count($market->getImg('screenshot')) > 0) { ?> <div style='padding:25px;'> <div class="variable-width" style="height : 200px;"> <?php foreach ($market->getImg('screenshot') as $screenshot) { echo '<div class="item" >'; echo '<a class="fancybox cursor" href="' . config::byKey('market::address') . '/' . $screenshot . '" rel="group" >'; echo '<img data-lazy="' . config::byKey('market::address') . '/' . $screenshot . '" style="height : 200px;" />';