コード例 #1
0
ファイル: cache.php プロジェクト: jackyxie/phpspider
 /**
  * 获取实例
  * 
  * @return void
  * @author seatle <*****@*****.**> 
  * @created time :2016-04-10 22:55
  */
 public static function init()
 {
     if (extension_loaded('Redis')) {
         $_instance = new Redis();
     } else {
         $errmsg = "extension redis is not installed";
         log::add($errmsg, "Error");
         return null;
     }
     // 这里不能用pconnect,会报错:Uncaught exception 'RedisException' with message 'read error on connection'
     $_instance->connect($GLOBALS['config']['redis']['host'], $GLOBALS['config']['redis']['port'], $GLOBALS['config']['redis']['timeout']);
     // 验证
     if ($GLOBALS['config']['redis']['pass']) {
         if (!$_instance->auth($GLOBALS['config']['redis']['pass'])) {
             $errmsg = "Redis Server authentication failed!!";
             log::add($errmsg, "Error");
             return null;
         }
     }
     // 不序列化的话不能存数组,用php的序列化方式其他语言又不能读取,所以这里自己用json序列化了,性能还比php的序列化好1.4倍
     //$_instance->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_NONE);     // don't serialize data
     //$_instance->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_PHP);      // use built-in serialize/unserialize
     //$_instance->setOption(Redis::OPT_SERIALIZER, Redis::SERIALIZER_IGBINARY); // use igBinary serialize/unserialize
     $_instance->setOption(Redis::OPT_PREFIX, $GLOBALS['config']['redis']['prefix'] . ":");
     return $_instance;
 }
コード例 #2
0
 public static function runDeamon()
 {
     if (!file_exists('/opt/homebridge/config.json')) {
         $response = array();
         $platform = array();
         $response['description'] = "Configuration Jeedom";
         $platform['platform'] = "Jeedom";
         $platform['name'] = "Jeedom";
         $platform['jeedom_ip'] = "127.0.0.1";
         $platform['jeedom_port'] = config::byKey('internalPort');
         $platform['jeedom_url'] = config::byKey('internalComplement');
         $platform['jeedom_api_key'] = config::byKey('api');
         $response['platforms'] = array();
         $response['platforms'][] = $platform;
         $response['accessories'] = array();
         $fp = fopen('/opt/homebridge/config.json', 'w');
         fwrite($fp, json_encode($response));
         fclose($fp);
     }
     log::add('homebridge', 'info', 'Lancement du démon homebridge');
     $cmd = 'nice -n 19 /usr/bin/nodejs /opt/homebridge/app.js';
     log::add('homebridge', 'info', 'Lancement démon homebridge : ' . $cmd);
     $result = exec('nohup ' . $cmd . ' >> ' . log::getPathToLog('homebridge') . ' 2>&1 &');
     if (!self::deamonRunning()) {
         sleep(10);
         if (!self::deamonRunning()) {
             log::add('homebridge', 'error', 'Impossible de lancer le démon homebridge', 'unableStartDeamon');
             return false;
         }
     }
     message::removeAll('homebridge', 'unableStartDeamon');
     log::add('homebridge', 'info', 'Démon homebridge lancé');
 }
コード例 #3
0
 function postNextTopStory()
 {
     // only post one story every three hours
     $tstamp = $this->statusObj->getState('lastTwitterPost');
     if (!isset($_GET['test']) and time() - $tstamp < 60 * TWITTER_INTERVAL_MINUTES) {
         return;
     }
     //echo 'continuing';
     require_once PATH_CORE . '/classes/content.class.php';
     $cObj = new content($this->db);
     require_once PATH_CORE . '/classes/log.class.php';
     $logObj = new log($this->db);
     $topStories = $cObj->fetchUpcomingStories();
     $uid = 1;
     while ($data = $this->db->readQ($topStories)) {
         if (!$this->checkLog($uid, $data->siteContentId) and $data->score >= TWITTER_SCORE_THRESHOLD) {
             // post to twitter
             $result = $this->update($data->siteContentId, $data->title);
             if ($result) {
                 $logItem = $logObj->serialize(0, $uid, 'postTwitter', $data->siteContentId);
                 $logObj->add($logItem);
                 $this->statusObj->setState('lastTwitterPost', time());
             }
             // only do one at a time
             return;
         }
     }
 }
コード例 #4
0
ファイル: install.php プロジェクト: stef3569/plugin-openzwave
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";
}
コード例 #5
0
 function logHourlyStats()
 {
     require_once PATH_CORE . '/classes/log.class.php';
     $logObj = new log($this->db);
     // record recentSessions
     $q = $this->db->query("SELECT count(id) as cnt FROM fbSessions WHERE fb_sig_time>=date_sub(NOW(), INTERVAL 10 MINUTE);");
     $data = $this->db->readQ($q);
     $cnt = $data->cnt;
     $logItem = $logObj->serialize(0, 0, 'sessionsRecent', $cnt);
     $logObj->add($logItem);
     // record sessions in last hour
     $q = $this->db->query("SELECT count(id) as cnt FROM fbSessions WHERE fb_sig_time>=date_sub(NOW(), INTERVAL 60 MINUTE);");
     $data = $this->db->readQ($q);
     $cnt = $data->cnt;
     $logItem = $logObj->serialize(0, 0, 'sessionsHour', $cnt);
     $logObj->add($logItem);
 }
コード例 #6
0
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";
}
コード例 #7
0
ファイル: index2.php プロジェクト: gavinjx/autophp
 public function indexAction()
 {
     try {
         echo "\r\n <br /> hello, i'm indexAction in controller_index, nice 2 meet u! <br />\r\n ";
         echo "\r\n <br /> now set language to zh-cn! <br />\r\n ";
         i18n::setLanguage('en-us');
         echo "\r\n <br /> in english, my name is: " . i18n::get('author') . " <br />\r\n ";
         echo "\r\n <br /> now set language to zh-cn! <br />\r\n ";
         i18n::setLanguage('zh-cn');
         echo "\r\n <br /> in chinese, my name is: " . i18n::get('author') . " <br />\r\n ";
         $mDemo = new model_demo();
         $uin = 10000;
         $uinfo = $mDemo->getUserInfo($uin);
         $uinfo2 = $mDemo->getUserInfo2($uin);
         $update = $mDemo->updateInfo(6, 1);
         var_dump($uinfo, $uinfo2, $update);
         $confs = array('title' => 'page title', 'time' => date('Ymd H:i:s'), 'name' => 'ricolau');
         log::add('error', 'im test~!');
     } catch (exception_i18n $e) {
         //i18n 的异常,一般是由于语言包不存在
         $code = $e->getCode();
         if ($code == exception_i18n::type_language_not_exist) {
             echo "\r\n <br /> exception: language of " . i18n::getLanguage() . ' not exist!\\r\\n <br />';
         }
         echo $e->getMessage();
     } catch (Exception $e) {
         //如果实在还是有exception,那就捕捉到这里吧,ignore 忽略处理的话。代码继续执行 $this->render(),不会白页。
         //throw $e;  //如果把这个异常抛上去,当前页面就木有了,上层接收到的话自己处理就好了,比如报个异常啥的
         $code = $e->getCode();
         echo $e->getMessage();
     }
     //一般来说 render 这块儿可以不用 try 和 cache,只有 template 或 slot 不存在才会有异常而已。
     //但是建议和上面部分业务代码的try cache 结构分离,从而可以更好的决定,如果业务数据有问题,页面是否还继续render()
     try {
         //按变量单独 assign
         $this->assign('uinfo', $uinfo);
         $this->assign('updateresult', $update);
         //批量assign 一个数组可以!
         $this->massign($confs);
         $this->render();
     } catch (exception_render $e) {
         //一般来说这个exception  不会有,模板放好了就行了么
         $code = $e->getCode();
         if ($code == exception_render::type_tpl_not_exist) {
             echo '\\r\\n <br /> exception: template not exist!\\r\\n <br />';
         } elseif ($code == exception_render::type_slot_not_exist) {
             echo '\\r\\n <br /> exception: template not exist!\\r\\n <br />';
         }
         echo $e->getMessage();
     }
     // equals to $this->render('index', 'index');
     return;
     //绝对不要用 exit!!!!!
 }
コード例 #8
0
 public static function getDisplayIds($pebbleId)
 {
     $displayIds = '';
     foreach (eqLogic::byType('jebble') as $jebble) {
         if ($jebble->getIsEnable() && $jebble->getId() == $pebbleId) {
             $displayIds = $jebble->getConfiguration('display_ids');
             log::add('jebble', 'debug', 'ids:' . $displayIds);
             break;
         }
     }
     return $displayIds;
 }
コード例 #9
0
 public static function cron30($_eqlogic_id = null)
 {
     if ($_eqlogic_id !== null) {
         $eqLogics = array(eqLogic::byId($_eqlogic_id));
     } else {
         $eqLogics = eqLogic::byType('wazeintime');
         sleep(rand(0, 120));
     }
     foreach ($eqLogics as $wazeintime) {
         if ($wazeintime->getIsEnable() == 1) {
             try {
                 $start = $wazeintime->getPosition('start');
                 $end = $wazeintime->getPosition('end');
                 $row = $wazeintime->getConfiguration('NOA') ? '' : 'row-';
                 $wazeRouteurl = 'https://www.waze.com/' . $row . 'RoutingManager/routingRequest?from=x%3A' . $start['lon'] . '+y%3A' . $start['lat'] . '&to=x%3A' . $end['lon'] . '+y%3A' . $end['lat'] . '&at=0&returnJSON=true&returnGeometries=true&returnInstructions=true&timeout=60000&nPaths=3&options=AVOID_TRAILS%3At';
                 $request_http = new com_http($wazeRouteurl);
                 $request_http->setUserAgent('User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:43.0) Gecko/20100101 Firefox/43.0');
                 $json = json_decode($request_http->exec(6, 2), true);
                 if (isset($json['error'])) {
                     throw new Exception($json['error']);
                 }
                 $data = self::extractInfo($json);
                 $wazeRoutereturl = 'https://www.waze.com/' . $row . 'RoutingManager/routingRequest?from=x%3A' . $end['lon'] . '+y%3A' . $end['lat'] . '&to=x%3A' . $start['lon'] . '+y%3A' . $start['lat'] . '&at=0&returnJSON=true&returnGeometries=true&returnInstructions=true&timeout=60000&nPaths=3&options=AVOID_TRAILS%3At';
                 $request_http = new com_http($wazeRoutereturl);
                 $request_http->setUserAgent('User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:43.0) Gecko/20100101 Firefox/43.0');
                 $json = json_decode($request_http->exec(6, 2), true);
                 if (isset($json['error'])) {
                     throw new Exception($json['error']);
                 }
                 $data = array_merge($data, self::extractInfo($json, 'ret'));
                 log::add('wazeintime', 'debug', 'Data : ' . print_r($data, true));
                 foreach ($wazeintime->getCmd('info') as $cmd) {
                     if ($cmd->getLogicalId() == 'lastrefresh') {
                         $cmd->event(date('H:i'));
                         continue;
                     }
                     if (!isset($data[$cmd->getLogicalId()])) {
                         continue;
                     }
                     if ($cmd->formatValue($data[$cmd->getLogicalId()]) != $cmd->execCmd()) {
                         $cmd->setCollectDate('');
                         $cmd->event($data[$cmd->getLogicalId()]);
                     }
                 }
                 $wazeintime->refreshWidget();
             } catch (Exception $e) {
                 log::add('wazeintime', 'error', $e->getMessage());
             }
         }
     }
 }
コード例 #10
0
function gCalendar_remove()
{
    $cron = cron::byClassAndFunction('gCalendar', 'pull');
    if (is_object($cron)) {
        $cron->remove();
    }
    // supprimer les fichiers cache et le répertoire //
    array_map('unlink', glob(GCALENDAR_CACHE_PATH . "gCalendar_*.tmp.xml"));
    if (rmdir(GCALENDAR_CACHE_PATH) === true) {
        log::add('gCalendar', 'info', 'gCalendar_remove(): Le répertoire (' . GCALENDAR_CACHE_PATH . ') et ses fichiers ont correctement été supprimés.');
    } else {
        log::add('gCalendar', 'error', 'gCalendar_remove(): Impossible de supprimer le répertoire: ' . GCALENDAR_CACHE_PATH);
    }
}
コード例 #11
0
ファイル: sarah.class.php プロジェクト: Wators/jeedom_plugins
 public static function cron()
 {
     $now = date('Y-m-d H:i:s', strtotime('-1 second', strtotime(date('Y-m-d H:i:s'))));
     $lastDatetime = cache::byKey('sarah::lastRetrievalInternalEvent', $now);
     foreach (internalEvent::getNewInternalEvent('sarah') as $internalEvent) {
         if (in_array($internalEvent->getEvent(), array('update::interactQuery'))) {
             foreach (sarah::byType('sarah') as $sarah) {
                 if ($sarah->ping()) {
                     log::add('sarah', 'info', 'Mise à jour de la grammaire de Sarah');
                     $sarah->updateSrvSarah();
                 } else {
                     cache::save('sarah::lastRetrievalInternalEvent', $lastDatetime, 0);
                 }
             }
         }
     }
 }
コード例 #12
0
ファイル: connection.class.php プロジェクト: GaelGRIFFON/core
 public static function failed()
 {
     $connection = connection::byIp(getClientIp());
     if (!is_object($connection)) {
         $connection = new connection();
         $connection->setIp(getClientIp());
     }
     $connection->setFailure($connection->getFailure() + 1);
     $connection->setStatus('Failed');
     if ($connection->getFailure() > config::byKey('security::retry') && strtotime($connection->getDatetime()) + 60 * config::byKey('security::backlogtime') > strtotime('now') && !$connection->isProtect()) {
         $connection->setStatus('Ban');
         log::add('connection', 'error', __('Attention tentative d\'intrusion détectée venant de l\'IP : ', __FILE__) . $connection->getIp());
     }
     try {
         $connection->save();
     } catch (Exception $e) {
     }
 }
コード例 #13
0
ファイル: trains.class.php プロジェクト: bemar/jeedom_trains
 public static function cron($_eqlogic_id = null, $force = false)
 {
     if ($_eqlogic_id !== null) {
         $eqLogics = array(eqLogic::byId($_eqlogic_id));
     } else {
         $eqLogics = eqLogic::byType('trains');
     }
     foreach ($eqLogics as $trains) {
         if ($trains->getIsEnable() == 1) {
             if ($force || date('Hi', time()) >= $trains->getConfiguration('trains_maj_deb') && date('Hi', time()) <= $trains->getConfiguration('trains_maj_fin')) {
                 log::add('trains', 'debug', 'Pull ' . ($force ? 'Forcé' : 'Cron') . ' pour trains ');
                 $baseUrl = 'http://www.gares-sncf.com/fr/train-times/departure/' . $trains->getConfiguration('trains_depart') . '/gl';
                 $arrivee = $trains->getConfiguration('trains_arrivee');
                 $response = file_get_contents($baseUrl);
                 $json = json_decode($response, true);
                 $departs = [];
                 foreach ($json['trains'] as $depart) {
                     $trainCourant = (object) [];
                     if ($arrivee == '' || $trains->string_contains($depart['origdest'], $arrivee)) {
                         $trainCourant->dest = $depart['origdest'];
                         $trainCourant->type = $depart['type'];
                         $trainCourant->voie = $depart['voie'];
                         $trainCourant->heure = $depart['heure'];
                         $trainCourant->etat = $depart['etat'];
                         $trainCourant->retard = $depart['retard'];
                         $trainCourant->infos = $depart['infos'];
                         $departs[] = $trainCourant;
                     }
                 }
                 log::add('trains', 'debug', 'Date de mise à jour des infos récupérées : ' . $json['updated']);
                 log::add('trains', 'debug', 'infos récupérées : ' . json_encode($departs));
                 $result = (object) [];
                 $result->updated = $json['updated'];
                 $result->departs = $departs;
                 $trainsCmd = $trains->getCmd(null, 'Departs');
                 if (is_object($trainsCmd)) {
                     $trainsCmd->event(json_encode($result));
                 }
                 $trains->refreshWidget();
             }
         }
     }
 }
コード例 #14
0
 public static function cron()
 {
     foreach (self::byType('networks') as $networks) {
         $autorefresh = $networks->getConfiguration('autorefresh');
         if ($networks->getIsEnable() == 1 && $autorefresh != '') {
             try {
                 $c = new Cron\CronExpression($autorefresh, new Cron\FieldFactory());
                 if ($c->isDue()) {
                     try {
                         $networks->ping();
                     } catch (Exception $exc) {
                         log::add('networks', 'error', __('Erreur pour ', __FILE__) . $networks->getHumanName() . ' : ' . $exc->getMessage());
                     }
                 }
             } catch (Exception $exc) {
                 log::add('networks', 'error', __('Expression cron non valide pour ', __FILE__) . $networks->getHumanName() . ' : ' . $autorefresh);
             }
         }
     }
 }
コード例 #15
0
ファイル: install.php プロジェクト: sfrias/plugin-openzwave
function openzwave_update()
{
    if (!file_exists(dirname(__FILE__) . '/../data')) {
        mkdir(dirname(__FILE__) . '/../data');
        if (file_exists('/opt/python-openzwave/xml_backups')) {
            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');
        }
    }
    $cron = cron::byClassAndFunction('openzwave', 'pull');
    if (is_object($cron)) {
        $cron->remove();
    }
    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');
    }
    openzwave::syncconfOpenzwave();
}
コード例 #16
0
ファイル: xbmc.class.php プロジェクト: Wators/jeedom_plugins
 public function execute($_options = null)
 {
     $xbmc = $this->getEqLogic();
     $requestHeader = 'http://' . $xbmc->getConfiguration('login') . ':' . $xbmc->getConfiguration('password') . '@' . $xbmc->getConfiguration('addr');
     if ($this->getConfiguration('parameters') == '') {
         $json = array('jsonrpc' => '2.0', 'method' => $this->getConfiguration('request'), 'id' => 1);
     } else {
         $parameters = $this->getConfiguration('parameters');
         if ($this->type == 'action' && $_options != null) {
             switch ($this->subType) {
                 case 'message':
                     $parameters = str_replace('#title#', $_options['title'], $parameters);
                     $parameters = str_replace('#message#', $_options['message'], $parameters);
                     break;
                 case 'color':
                     $parameters = str_replace('#color#', $_options['color'], $parameters);
                     break;
                 case 'slider':
                     $parameters = str_replace('#slider#', $_options['slider'], $parameters);
                     break;
                 default:
                     break;
             }
         }
         $json = array('jsonrpc' => '2.0', 'method' => $this->getConfiguration('request'), 'params' => json_decode($parameters, true), 'id' => 1);
     }
     $request = json_encode($json);
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_POST, 1);
     curl_setopt($ch, CURLOPT_URL, $requestHeader . "/jsonrpc");
     curl_setopt($ch, CURLOPT_TIMEOUT, 1);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
     $response = curl_exec($ch);
     if ($response === false) {
         log::add('xbmc', 'Error', 'Erreur curl : ' . curl_error($ch) . ' sur la commande XBMC ' . $this->name);
         throw new Exception('[XBMC] Erreur curl : ' . curl_error($ch) . ' sur la commande XBMC ' . $this->name);
     }
     curl_close($ch);
     return $response;
 }
コード例 #17
0
 public function execute($_options = null)
 {
     $notifymyAndroid = $this->getEqLogic();
     if ($_options === null) {
         throw new Exception(__('Les options de la fonction ne peuvent etre null', __FILE__));
     }
     if ($_options['message'] == '' && $_options['title'] == '') {
         throw new Exception(__('Le message et le sujet ne peuvent être vide', __FILE__));
     }
     if ($_options['title'] == '') {
         $_options['title'] = __('[Jeedom] - Notification', __FILE__);
     }
     log::add('notifymyAndroid', 'event', 'Envoi: Priorité : ' . $this->getConfiguration('priority') . ' Titre : ' . $_options['title'] . ' Message : ' . $_options['message']);
     $url = NOTIFYMYANDROIDADDR . '?apikey=' . $notifymyAndroid->getConfiguration('key') . '&application=Jeedom&event=' . urlencode($_options['title']) . '&description=' . urlencode($_options['message']) . '&priority=' . $this->getConfiguration('priority');
     log::add('notifymyAndroid', 'debug', 'Url d\'envoi:' . $url);
     $ch = curl_init($url);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     $result = curl_exec($ch);
     curl_close($ch);
     if (strlen($result) != 102) {
         throw new Exception(__($result, __FILE__));
     }
 }
コード例 #18
0
ファイル: install.php プロジェクト: cedric222/arduidom
function arduidom_update()
{
    arduidom::stopdaemon();
    $MigrationCheck = config::byKey('db_version', 'arduidom', 0);
    if ($MigrationCheck < 108) {
        arduidom::MigrateDatas();
        arduidom::start();
    }
    if ($MigrationCheck < 145) {
        arduidom::stopdaemon();
        $daemon_path = realpath(dirname(__FILE__) . '/../../ressources');
        log::add('arduidom', 'info', "Suppression de arduidom1.py devenu inutile => " . unlink($daemon_path . "/arduidom1.py"));
        log::add('arduidom', 'info', "Suppression de arduidom2.py devenu inutile => " . unlink($daemon_path . "/arduidom2.py"));
        log::add('arduidom', 'info', "Suppression de arduidom3.py devenu inutile => " . unlink($daemon_path . "/arduidom3.py"));
        log::add('arduidom', 'info', "Suppression de arduidom4.py devenu inutile => " . unlink($daemon_path . "/arduidom4.py"));
        log::add('arduidom', 'info', "Suppression de arduidom5.py devenu inutile => " . unlink($daemon_path . "/arduidom5.py"));
        log::add('arduidom', 'info', "Suppression de arduidom6.py devenu inutile => " . unlink($daemon_path . "/arduidom6.py"));
        log::add('arduidom', 'info', "Suppression de arduidom7.py devenu inutile => " . unlink($daemon_path . "/arduidom7.py"));
        log::add('arduidom', 'info', "Suppression de arduidom8.py devenu inutile => " . unlink($daemon_path . "/arduidom8.py"));
        config::save('db_version', 145, 'arduidom');
        // Inscrit la version de migration dans la config
        arduidom::start();
    }
    arduidom::startdaemon();
    $cron = cron::byClassAndFunction('arduidom', 'checkdaemon');
    if (!is_object($cron)) {
        $cron = new cron();
        $cron->setClass('arduidom');
        $cron->setFunction('checkdaemon');
        $cron->setEnable(1);
        $cron->setDeamon(0);
        $cron->setSchedule('* * * * *');
        $cron->save();
    }
    $cron->stop();
    @exec("sudo usermod -G dialout www-data");
}
コード例 #19
0
ファイル: data.php プロジェクト: henningvs/de-map
    $ffj->nameShort = 'Freifunk Jena';
    $ffj->url = 'https://freifunk-jena.de/ffmap/';
    $ffj->parser = 'Ffmap';
    $parser->addAdditional('ffj', $ffj);
    $ffffm = new stdClass();
    $ffffm->name = 'Frankfurt am Main';
    $ffffm->nameShort = 'Frankfurt am Main';
    $ffffm->url = 'http://map.ffm.freifunk.net/';
    $ffffm->parser = 'Ffmap';
    $parser->addAdditional('ffffm', $ffffm);
    $parseResult = $parser->getParsed(true);
    $response = array('communities' => $parseResult['communities'], 'allTheRouters' => $parseResult['routerList']);
    if (is_array($dbAccess)) {
        $db = new mysqli($dbAccess['host'], $dbAccess['user'], $dbAccess['pass'], $dbAccess['db']);
        $log = new log($db);
        $log->add(sizeof($parseResult['routerList']));
    }
}
/**
 * if processonly is set we handle a reparse cron request
 */
if (isset($_REQUEST['processonly']) && isset($parser)) {
    $report = array('communities' => sizeof($response['communities']), 'nodes' => sizeof($response['allTheRouters']), 'stats' => $parser->getParseStatistics());
    echo json_encode($report, JSON_PRETTY_PRINT);
} else {
    echo json_encode($response, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP);
}
function getFromCache($key)
{
    $filename = dirname(__FILE__) . '/cache/result_' . $key . '.json';
    if (!file_exists($filename)) {
コード例 #20
0
             $filename = PATH_CACHE . '/read_' . $cid . '_com_m.cac';
             if (file_exists($filename)) {
                 unlink($filename);
             }
             $filename = PATH_CACHE . '/read_' . $cid . '_com_n.cac';
             if (file_exists($filename)) {
                 unlink($filename);
             }
         }
         $cObj->updateCommentCount($cid);
     }
     if (!$error) {
         require_once PATH_CORE . '/classes/log.class.php';
         $logObj = new log($db);
         $logItem = $logObj->serialize(0, $userid, 'comment', $siteCommentId, 0, $cid);
         $inLog = $logObj->add($logItem);
         $code = '<div id="dialogMessage"><h2>Your comment has been published successfully.</h2><p>What would you like to do next?</p>';
         $code .= '<ul class="bullet_list">' . $storyOption . '<li><a href="#" onclick="hideDialog(); return shareStory(this,' . $cid . ');">Share story with friends</a></li><li><a href="?p=invite" onclick="hideDialog(); return switchPage(\'invite\');">Invite friends to ' . SITE_TITLE . '</a></li></ul></div>';
     } else {
         $code = '<div id="dialogMessage">Sorry, there was a problem publishing your comment. Error: ' . $errorMsg . '</div>';
     }
     break;
 case 'requestVerify':
     // send it
     // to do - this code is duped in pagesignup, move to account.class.php
     global $init;
     // ask NewsCloud to send an email verification request
     /*
     require_once (PATH_CORE.'/classes/systemStatus.class.php');
     $ssObj=new systemStatus($db);
     $partnerid=$ssObj->getState('partnerid');				
コード例 #21
0
ファイル: db.php プロジェクト: jackyxie/phpspider
 public static function query($sql)
 {
     $sql = trim($sql);
     // 初始化数据库
     self::_init_mysql();
     self::$rsid = @mysqli_query(self::$conn, $sql);
     if (self::$rsid === false) {
         // 不要每次都ping,浪费流量浪费性能,执行出错了才重新连接
         $errno = mysqli_errno(self::$conn);
         if ($errno == 2013 || $errno == 2006) {
             $errmsg = mysqli_error(self::$conn);
             log::add($errmsg, "Error");
             @mysqli_close(self::$conn);
             self::$conn = null;
             return self::query($sql);
         }
         $errmsg = "Query SQL: " . $sql;
         log::add($errmsg, "Warning");
         $errmsg = "Error SQL: " . mysqli_error(self::$conn);
         log::add($errmsg, "Warning");
         $backtrace = debug_backtrace();
         array_shift($backtrace);
         $narr = array('class', 'type', 'function', 'file', 'line');
         $err = "debug_backtrace:\n";
         foreach ($backtrace as $i => $l) {
             foreach ($narr as $k) {
                 if (!isset($l[$k])) {
                     $l[$k] = '';
                 }
             }
             $err .= "[{$i}] in function {$l['class']}{$l['type']}{$l['function']} ";
             if ($l['file']) {
                 $err .= " in {$l['file']} ";
             }
             if ($l['line']) {
                 $err .= " on line {$l['line']} ";
             }
             $err .= "\n";
         }
         log::add($err);
         return false;
     } else {
         self::$query_count++;
         return self::$rsid;
     }
 }
コード例 #22
0
ファイル: plugin.ajax.php プロジェクト: GaelGRIFFON/core
 $zip = new ZipArchive();
 $res = $zip->open($tmp);
 if ($res === TRUE) {
     if (!$zip->extractTo($cibDir . '/')) {
         $content = file_get_contents($tmp);
         throw new Exception(__('Impossible d\'installer le plugin. Les fichiers n\'ont pas pu être décompressés : ', __FILE__) . substr($content, 255));
     }
     $zip->close();
     log::add('update', 'update', __("OK\n", __FILE__));
     log::add('update', 'update', __('Installation de l\'objet...', __FILE__));
     try {
         $plugin = plugin::byId($logicalId);
     } catch (Exception $e) {
         throw new Exception(__('Impossible d\'installer le plugin. Le nom du plugin est différent de l\'ID ou le plugin n\'est pas correctement formé. Veuillez contacter l\'auteur.', __FILE__));
     }
     log::add('update', 'update', __("OK\n", __FILE__));
     if (is_object($plugin) && $plugin->isActive()) {
         $plugin->setIsEnable(1);
     }
 } else {
     switch ($res) {
         case ZipArchive::ER_EXISTS:
             $ErrMsg = "Le fichier existe déjà.";
             break;
         case ZipArchive::ER_INCONS:
             $ErrMsg = "L'archive zip est inconsistente.";
             break;
         case ZipArchive::ER_MEMORY:
             $ErrMsg = "Erreur mémoire.";
             break;
         case ZipArchive::ER_NOENT:
コード例 #23
0
ファイル: cmd.class.php プロジェクト: jimibi/core
 public function pushUrl($_value)
 {
     $url = $this->getConfiguration('jeedomPushUrl');
     if ($url == '') {
         $url = config::byKey('cmdPushUrl');
     }
     if ($url == '') {
         return;
     }
     $replace = array('#value#' => $_value, '#cmd_name#' => $this->getName(), '#cmd_id#' => $this->getId(), '#humanname#' => $this->getHumanName());
     $url = str_replace(array_keys($replace), $replace, $url);
     log::add('event', 'event', __('Appels de l\'URL de push pour la commande ', __FILE__) . $this->getHumanName() . ' : ' . $url);
     $http = new com_http($url);
     $http->setLogError(false);
     try {
         $http->exec();
     } catch (Exception $e) {
         log::add('cmd', 'error', __('Erreur push sur : ', __FILE__) . $url . ' => ' . $e->getMessage());
     }
 }
コード例 #24
0
 public function setRGBColor($_color)
 {
     if ($_color == '') {
         throw new Exception('Couleur non définie');
     }
     $eqLogic = $this->getEqLogic();
     $hex = str_replace("#", "", $_color);
     if (strlen($hex) == 3) {
         $r = hexdec(substr($hex, 0, 1) . substr($hex, 0, 1));
         $g = hexdec(substr($hex, 1, 1) . substr($hex, 1, 1));
         $b = hexdec(substr($hex, 2, 1) . substr($hex, 2, 1));
     } else {
         $r = hexdec(substr($hex, 0, 2));
         $g = hexdec(substr($hex, 2, 2));
         $b = hexdec(substr($hex, 4, 2));
     }
     log::add('openzwave', 'debug', '/ZWaveAPI/Run/devices[' . $eqLogic->getLogicalId() . '].SetColor(' . $r . ',' . $g . ',' . $b . ',0)');
     openzwave::callOpenzwave('/ZWaveAPI/Run/devices[' . $eqLogic->getLogicalId() . '].SetColor(' . $r . ',' . $g . ',' . $b . ',0)', $eqLogic->getConfiguration('serverID', 1));
     return true;
 }
コード例 #25
0
ファイル: jeeAlarm.php プロジェクト: Wators/jeedom_plugins
 * 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/>.
 */
if (php_sapi_name() != 'cli' || isset($_SERVER['REQUEST_METHOD']) || !isset($_SERVER['argc'])) {
    header("Status: 404 Not Found");
    header('HTTP/1.0 404 Not Found');
    $_SERVER['REDIRECT_STATUS'] = 404;
    echo "<h1>404 Not Found</h1>";
    echo "The page that you have requested could not be found.";
    exit;
}
require_once dirname(__FILE__) . "/../../../../core/php/core.inc.php";
if (isset($argv)) {
    foreach ($argv as $arg) {
        $argList = explode('=', $arg);
        if (isset($argList[0]) && isset($argList[1])) {
            $_GET[$argList[0]] = $argList[1];
        }
    }
}
$eqLogic = alarm::byId(init('eqLogic_id'));
if (!is_object($eqLogic)) {
    log::add('alarm', 'info', 'Alarme non trouvé verifier id : ' . init('eqLogic_id'));
    die('Alarme non trouvé verifier id : ' . init('eqLogic_id'));
}
set_time_limit(120);
$eqLogic->execute(init('trigger_id'), init('value'));
コード例 #26
0
ファイル: interactQuery.class.php プロジェクト: saez0pub/core
 public function executeAndReply($_parameters)
 {
     $interactDef = interactDef::byId($this->getInteractDef_id());
     if (!is_object($interactDef)) {
         return __('Inconsistance de la base de données', __FILE__);
     }
     if (isset($_parameters['profile']) && trim($interactDef->getPerson()) != '') {
         $person = strtolower($interactDef->getPerson());
         $person = explode('|', $person);
         if (!in_array($_parameters['profile'], $person)) {
             return __('Vous n\'êtes pas autorisé à exécuter cette action', __FILE__);
         }
     }
     $reply = $interactDef->selectReply();
     $replace = array();
     $tags = interactDef::getTagFromQuery($this->getQuery(), $_parameters['dictation']);
     $tags_replace = array();
     foreach ($tags as $key => $value) {
         $tags_replace['#' . $key . '#'] = $value;
         $replace['#' . $key . '#'] = $value;
     }
     $executeDate = null;
     $dateConvert = array('heure' => 'hour', 'mois' => 'month', 'semaine' => 'week', 'année' => 'year');
     if (isset($tags_replace['#duration#'])) {
         $tags_replace['#duration#'] = str_replace(array_keys($dateConvert), $dateConvert, $tags_replace['#duration#']);
         $executeDate = strtotime('+' . $tags_replace['#duration#']);
     }
     if (isset($tags_replace['#time#'])) {
         $time = str_replace(array('h'), array(':'), $tags_replace['#time#']);
         if (strlen($time) == 2) {
             $time .= ':00';
         } else {
             if (strlen($time) == 3) {
                 $time .= '00';
             }
         }
         $executeDate = strtotime($time);
         if ($executeDate < strtotime('now')) {
             $executeDate += 3600;
         }
     }
     if ($executeDate !== null && !isset($_parameters['execNow'])) {
         if (date('Y', $executeDate) < 2000) {
             return __('Erreur impossible de calculer la date de programmation', __FILE__);
         }
         if ($executeDate < strtotime('now') + 60) {
             $executeDate = strtotime('now') + 60;
         }
         $crons = cron::searchClassAndFunction('interactQuery', 'doIn', '"interactQuery_id":' . $this->getId());
         if (is_array($crons)) {
             foreach ($crons as $cron) {
                 if ($cron->getState() != 'run') {
                     $cron->remove();
                 }
             }
         }
         $cron = new cron();
         $cron->setClass('interactQuery');
         $cron->setFunction('doIn');
         $cron->setOption(array_merge(array('interactQuery_id' => intval($this->getId())), $_parameters));
         $cron->setLastRun(date('Y-m-d H:i:s'));
         $cron->setOnce(1);
         $cron->setSchedule(date('i', $executeDate) . ' ' . date('H', $executeDate) . ' ' . date('d', $executeDate) . ' ' . date('m', $executeDate) . ' * ' . date('Y', $executeDate));
         $cron->save();
         $replace['#value#'] = date('Y-m-d H:i:s', $executeDate);
         $result = scenarioExpression::setTags(str_replace(array_keys($replace), $replace, $reply));
         return $result;
     }
     $colors = config::byKey('convertColor');
     foreach ($this->getActions('cmd') as $action) {
         try {
             $options = array();
             if (isset($action['options'])) {
                 $options = $action['options'];
             }
             if ($tags != null) {
                 foreach ($options as &$option) {
                     $option = str_replace(array_keys($tags_replace), $tags_replace, $option);
                 }
                 if (isset($options['color']) && isset($colors[strtolower($options['color'])])) {
                     $options['color'] = $colors[strtolower($options['color'])];
                 }
             }
             $cmd = cmd::byId(str_replace('#', '', $action['cmd']));
             if (is_object($cmd) && $cmd->getType() == 'info') {
                 $replace['#unite#'] = $cmd->getUnite();
                 $replace['#commande#'] = $cmd->getName();
                 $replace['#objet#'] = '';
                 $replace['#equipement#'] = '';
                 $eqLogic = $cmd->getEqLogic();
                 if (is_object($eqLogic)) {
                     $replace['#equipement#'] = $eqLogic->getName();
                     $object = $eqLogic->getObject();
                     if (is_object($object)) {
                         $replace['#objet#'] = $object->getName();
                     }
                 }
             }
             $options['tags'] = $tags_replace;
             $return = scenarioExpression::createAndExec('action', $action['cmd'], $options);
             if (trim($return) != '') {
                 $replace['#valeur#'] = $return;
             }
         } catch (Exception $e) {
             log::add('interact', 'error', __('Erreur lors de l\'éxecution de ', __FILE__) . $action['cmd'] . __('. Détails : ', __FILE__) . $e->getMessage());
         }
     }
     $replace['#profile#'] = isset($_parameters['profile']) ? $_parameters['profile'] : '';
     if ($interactDef->getOptions('convertBinary') != '') {
         $convertBinary = $interactDef->getOptions('convertBinary');
         $convertBinary = explode('|', $convertBinary);
         $replace['1'] = $convertBinary[1];
         $replace['0'] = $convertBinary[0];
     }
     $result = scenarioExpression::setTags(str_replace(array_keys($replace), $replace, $reply));
     return $result;
 }
コード例 #27
0
ファイル: user.class.php プロジェクト: GaelGRIFFON/core
 /**
  * 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;
 }
コード例 #28
0
ファイル: plugin.class.php プロジェクト: saez0pub/core
 public function setIsEnable($_state)
 {
     if (version_compare(jeedom::version(), $this->getRequire()) == -1 && $_state == 1) {
         throw new Exception('Votre version de jeedom n\'est pas assez récente pour activer ce plugin');
     }
     $alreadyActive = config::byKey('active', $this->getId(), 0);
     if ($_state == 1) {
         if (config::byKey('jeeNetwork::mode') != 'master' && $this->getAllowRemote() != 1) {
             throw new Exception('Vous ne pouvez pas activer ce plugin sur un Jeedom configuré en esclave');
         }
         //market::checkPayment($this->getId());
         config::save('active', $_state, $this->getId());
     }
     if ($_state == 0) {
         $eqLogics = eqLogic::byType($this->getId());
         if (is_array($eqLogics)) {
             foreach ($eqLogics as $eqLogic) {
                 try {
                     $eqLogic->setConfiguration('previousIsEnable', $eqLogic->getIsEnable());
                     $eqLogic->setConfiguration('previousIsVisible', $eqLogic->getIsVisible());
                     $eqLogic->setIsEnable(0);
                     $eqLogic->setIsVisible(0);
                     $eqLogic->save();
                 } catch (Exception $e) {
                 }
             }
         }
         $listeners = listener::byClass($this->getId());
         if (is_array($listeners)) {
             foreach ($listeners as $listener) {
                 $listener->remove();
             }
         }
     }
     if ($alreadyActive == 0 && $_state == 1) {
         foreach (eqLogic::byType($this->getId()) as $eqLogic) {
             try {
                 $eqLogic->setIsEnable($eqLogic->getConfiguration('previousIsEnable', 1));
                 $eqLogic->setIsVisible($eqLogic->getConfiguration('previousIsVisible', 1));
                 $eqLogic->save();
             } catch (Exception $e) {
             }
         }
     }
     try {
         if ($_state == 1) {
             if ($alreadyActive == 1) {
                 $out = $this->callInstallFunction('update');
             } else {
                 $out = $this->callInstallFunction('install');
             }
         } else {
             if ($alreadyActive == 1) {
                 $out = $this->callInstallFunction('remove');
             }
         }
         if (isset($out) && trim($out) != '') {
             log::add($this->getId(), 'info', "Installation/remove/update result : " . $out);
         }
     } catch (Exception $e) {
         config::save('active', $alreadyActive, $this->getId());
         log::add('plugin', 'error', $e->getMessage());
         throw $e;
     }
     if ($_state == 0) {
         config::save('active', $_state, $this->getId());
     }
     return true;
 }
コード例 #29
0
ファイル: eibhelper.class.php プロジェクト: stawen/domovision
function EibdWrite($con, $addr, $val)
{
    //if(count($val)==1 && $val[0]<0x3F)
    if (!is_array($val)) {
        log::add('eibd', 'debug', 'groupswrite');
        $val = $val + 0 & 0x3f;
        $val |= 0x80;
        $data = pack("n", $val);
    } else {
        $header = 0x80;
        $data = pack("n", $header);
        for ($i = 0; $i < count($val); $i++) {
            $data .= pack("C", $val[$i]);
        }
    }
    $addr = gaddrparse($addr);
    $r = $con->EIBOpenT_Group($addr, 1);
    if ($r == -1) {
        return -1;
    }
    $r = $con->EIBSendAPDU($data);
    if ($r == -1) {
        return -1;
    }
    return $con->EIBReset();
}
コード例 #30
0
ファイル: jeedom.class.php プロジェクト: GaelGRIFFON/core
 public static function checkFilesystem()
 {
     $result = exec('dmesg | grep "I/O error" | wc -l');
     if ($result != 0) {
         log::add('core', 'error', __('Erreur : corruption sur le filesystem detecter (I/O error sur dmesg)', __FILE__));
         return false;
     }
     return true;
 }