Ejemplo n.º 1
0
             $return['plugins'][] = utils::o2a($plugin);
         }
     }
     $return['custom'] = array();
     $return['custom']['js'] = file_exists(dirname(__FILE__) . '/../../mobile/custom/custom.js');
     $return['custom']['css'] = file_exists(dirname(__FILE__) . '/../../mobile/custom/custom.css');
     ajax::success($return);
 }
 if (!isConnect('admin')) {
     throw new Exception(__('401 - Accès non autorisé', __FILE__), -1234);
 }
 if (init('action') == 'ssh') {
     ajax::success(shell_exec(init('command')));
 }
 if (init('action') == 'update') {
     jeedom::update();
     ajax::success();
 }
 if (init('action') == 'clearDate') {
     $cache = cache::byKey('jeedom::lastDate');
     $cache->remove();
     ajax::success();
 }
 if (init('action') == 'backup') {
     jeedom::backup(true, init('noCloudUpload'));
     ajax::success();
 }
 if (init('action') == 'restore') {
     jeedom::restore(init('backup'), true);
     ajax::success();
 }
Ejemplo n.º 2
0
     $market = market::byId($params['plugin_id']);
     if (!is_object($market)) {
         throw new Exception(__('Impossible de trouver l\'objet associé : ', __FILE__) . $params['plugin_id']);
     }
     if (!isset($params['version'])) {
         $params['version'] = 'stable';
     }
     $market->remove();
     $jsonrpc->makeSuccess('ok');
 }
 /*             * ************************Update*************************** */
 if ($jsonrpc->getMethod() == 'update::all') {
     $jsonrpc->makeSuccess(utils::o2a(update::all()));
 }
 if ($jsonrpc->getMethod() == 'update::update') {
     jeedom::update('', 0);
     $jsonrpc->makeSuccess('ok');
 }
 if ($jsonrpc->getMethod() == 'update::checkUpdate') {
     update::checkAllUpdate();
     $jsonrpc->makeSuccess('ok');
 }
 /*             * ************************Network*************************** */
 if ($jsonrpc->getMethod() == 'network::restartNgrok') {
     config::save('market::allowDNS', 1);
     if (network::dns_run()) {
         network::dns_stop();
     }
     network::dns_start();
     $jsonrpc->makeSuccess();
 }
Ejemplo n.º 3
0
 public static function cron()
 {
     if (!self::isStarted()) {
         config::save('enableScenario', 1);
         config::save('enableCron', 1);
         $cache = cache::byKey('jeedom::usbMapping');
         $cache->remove();
         foreach (cron::all() as $cron) {
             if ($cron->running() && $cron->getClass() != 'jeedom' && $cron->getFunction() != 'cron') {
                 try {
                     $cron->halt();
                 } catch (Exception $e) {
                 }
             }
         }
         try {
             jeedom::start();
         } catch (Exception $e) {
         }
         try {
             plugin::start();
         } catch (Exception $e) {
         }
         touch('/tmp/jeedom_start');
         self::event('start');
         log::add('core', 'info', 'Démarrage de Jeedom OK');
     }
     self::isDateOk();
     try {
         $c = new Cron\CronExpression(config::byKey('update::check'), new Cron\FieldFactory());
         if ($c->isDue()) {
             $lastCheck = strtotime(config::byKey('update::lastCheck'));
             if (strtotime('now') - $lastCheck > 3600) {
                 if (config::byKey('update::auto') == 1) {
                     update::checkAllUpdate();
                     jeedom::update('', 0);
                 } else {
                     config::save('update::check', rand(1, 59) . ' ' . rand(6, 7) . ' * * *');
                     update::checkAllUpdate();
                     $updates = update::byStatus('update');
                     if (count($updates) > 0) {
                         $toUpdate = '';
                         foreach ($updates as $update) {
                             $toUpdate .= $update->getLogicalId() . ',';
                         }
                         message::add('update', __('De nouvelles mises à jour sont disponibles : ', __FILE__) . trim($toUpdate, ','), '', 'newUpdate');
                     }
                 }
             }
         }
         $c = new Cron\CronExpression('35 00 * * 0', new Cron\FieldFactory());
         if ($c->isDue()) {
             cache::clean();
             DB::optimize();
         }
         $c = new Cron\CronExpression('02 02 * * *', new Cron\FieldFactory());
         if ($c->isDue()) {
             try {
                 log::chunk();
                 cron::clean();
             } catch (Exception $e) {
                 log::add('log', 'error', $e->getMessage());
             }
         }
         $c = new Cron\CronExpression('21 23 * * *', new Cron\FieldFactory());
         if ($c->isDue()) {
             try {
                 scenario::cleanTable();
                 user::cleanOutdatedUser();
                 scenario::consystencyCheck();
             } catch (Exception $e) {
                 log::add('scenario', 'error', $e->getMessage());
             }
         }
     } catch (Exception $e) {
     }
 }
Ejemplo n.º 4
0
 public function doUpdate()
 {
     if ($this->getType() == 'core') {
         jeedom::update();
     } else {
         $market = market::byLogicalIdAndType($this->getLogicalId(), $this->getType());
         if (is_object($market)) {
             $market->install($this->getConfiguration('version', 'stable'));
         }
     }
     $this->refresh();
     $this->checkUpdate();
 }