public function install($_version = 'stable') { log::add('update', 'update', __('Début de la mise à jour de : ', __FILE__) . $this->getLogicalId() . "\n"); $tmp_dir = dirname(__FILE__) . '/../../tmp'; $tmp = $tmp_dir . '/' . $this->getLogicalId() . '.zip'; if (file_exists($tmp)) { unlink($tmp); } if (!is_writable($tmp_dir)) { exec('sudo chmod 777 -R ' . $tmp); } if (!is_writable($tmp_dir)) { throw new Exception(__('Impossible d\'écrire dans le répertoire : ', __FILE__) . $tmp . __('. Exécuter la commande suivante en SSH : sudo chmod 777 -R ', __FILE__) . $tmp_dir); } $url = config::byKey('market::address') . "/core/php/downloadFile.php?id=" . $this->getId() . '&version=' . $_version . '&hwkey=' . jeedom::getHardwareKey() . '&username='******'market::username')) . '&password='******'market::password') . '&password_type=sha1'; log::add('update', 'update', __('Téléchargement de ', __FILE__) . $this->getLogicalId() . '...'); file_put_contents($tmp, fopen($url, 'r')); if (!file_exists($tmp)) { throw new Exception(__('Impossible de télécharger le fichier depuis : ' . $url . '. Si l\'application est payante, l\'avez-vous achetée ?', __FILE__)); } log::add('update', 'update', __("OK\n", __FILE__)); switch ($this->getType()) { case 'plugin': $cibDir = dirname(__FILE__) . '/../../plugins/' . $this->getLogicalId(); if (!file_exists($cibDir) && !mkdir($cibDir, 0775, true)) { throw new Exception(__('Impossible de créer le dossier : ' . $cibDir . '. Problème de droits ?', __FILE__)); } try { $plugin = plugin::byId($this->getLogicalId()); if (is_object($plugin)) { log::add('update', 'update', __('Action de pre update...', __FILE__)); $plugin->callInstallFunction('pre_update'); log::add('update', 'update', __("OK\n", __FILE__)); } } catch (Exception $e) { } log::add('update', 'update', __('Décompression du zip...', __FILE__)); $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 ', __FILE__) . $this->getLogicalId() . '...'); try { $plugin = plugin::byId($this->getLogicalId()); } catch (Exception $e) { $this->remove(); 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__)); $update = update::byTypeAndLogicalId($this->getType(), $this->getLogicalId()); 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 = "Archive zip est inconsistente."; break; case ZipArchive::ER_MEMORY: $ErrMsg = "Erreur mémoire."; break; case ZipArchive::ER_NOENT: $ErrMsg = "Ce fichier n\\'existe pas."; break; case ZipArchive::ER_NOZIP: $ErrMsg = "Ceci n\\'est pas une archive zip."; break; case ZipArchive::ER_OPEN: $ErrMsg = "Le fichier ne peut pas être ouvert."; break; case ZipArchive::ER_READ: $ErrMsg = "Erreur de lecture."; break; case ZipArchive::ER_SEEK: $ErrMsg = "Erreur de recherche."; break; default: $ErrMsg = "Erreur inconnue (Code {$res})"; break; } throw new Exception(__('Impossible de décompresser le zip : ', __FILE__) . $tmp . __('. Erreur : ', __FILE__) . $ErrMsg . '. Avez vous acheté le plugin ?'); } break; default: log::add('update', 'update', __('Installation de du plugin,widget...', __FILE__)); $type = $this->getType(); if (class_exists($type) && method_exists($type, 'getFromMarket')) { $type::getFromMarket($this, $tmp); } log::add('update', 'update', __("OK\n", __FILE__)); break; } $update = update::byTypeAndLogicalId($this->getType(), $this->getLogicalId()); if (!is_object($update)) { $update = new update(); $update->setLogicalId($this->getLogicalId()); $update->setType($this->getType()); } $update->setLocalVersion($this->getDatetime($_version)); $update->setConfiguration('version', $_version); $update->save(); $update->checkUpdate(); }
</div> </div> <div class="form-group"> <label class="col-lg-2 col-md-3 col-sm-4 col-xs-6 control-label">{{Système}}</label> <div class="col-lg-4 col-md-4 col-sm-4 col-xs-4"> <span class="label label-info" style="font-size : 1em;"><?php echo jeedom::getHardwareName(); ?> </span> </div> </div> <div class="form-group expertModeVisible"> <label class="col-lg-2 col-md-3 col-sm-4 col-xs-6 control-label">{{Clef hardware}}</label> <div class="col-lg-3 col-md-4 col-sm-5 col-xs-6"> <span class="label label-info" style="font-size : 1em;"><?php echo jeedom::getHardwareKey(); ?> </span> </div> <div class="col-lg-1 col-md-2 col-sm-3"> <a class="btn btn-default form-control" id="bt_resetHwKey" >{{Remise à zéro}}</a> </div> </div> <div class="form-group"> <label class="col-lg-2 col-md-3 col-sm-4 col-xs-6 control-label">{{Langue}}</label> <div class="col-lg-2 col-md-3 col-sm-4 col-xs-6"> <select class="configKey form-control" data-l1key="language"> <option value="fr_FR">Français</option> <option value="en_US">English</option> <option value="de_DE">Deutsch</option> <option value="es_ES">Español</option>