Skip to content

Commit e53c420

Browse files
authored
Merge pull request #3168 from jeedom/3121-clean-jeenetwork-leftovers
remove jeeNetwork leftovers but keep system halt & reboot
2 parents 82da65f + 78134ef commit e53c420

File tree

1 file changed

+7
-136
lines changed

1 file changed

+7
-136
lines changed

core/api/proApi.php

Lines changed: 7 additions & 136 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@
147147
$result = jeedom::version();
148148
$advice = '';
149149
$productName = config::byKey('product_name');
150-
$health[] = array('plugin' => 'core', 'type' => 'Version '. $productName , 'defaut' => $defaut, 'result' => $result, 'advice' => $advice);
150+
$health[] = array('plugin' => 'core', 'type' => 'Version ' . $productName, 'defaut' => $defaut, 'result' => $result, 'advice' => $advice);
151151

152152
$defaut = 0;
153153
$result = phpversion();
@@ -199,7 +199,7 @@
199199
$result = 'OK';
200200
} else {
201201
$filename = __DIR__ . '/../../cache.tar.gz';
202-
$result = 'OK (' . date('Y-m-d H:i:s',(int) filemtime($filename)) . ')';
202+
$result = 'OK (' . date('Y-m-d H:i:s', (int) filemtime($filename)) . ')';
203203
}
204204
} else {
205205
$result = 'NOK';
@@ -569,8 +569,8 @@
569569
$jsonrpc->makeSuccess($scenario->stop());
570570
}
571571
if ($params['state'] == 'run') {
572-
$scenario->addTag('trigger','api');
573-
$scenario->addTag('trigger_message',__('Scénario exécuté sur appel API', __FILE__));
572+
$scenario->addTag('trigger', 'api');
573+
$scenario->addTag('trigger_message', __('Scénario exécuté sur appel API', __FILE__));
574574
$jsonrpc->makeSuccess($scenario->launch());
575575
}
576576
if ($params['state'] == 'enable') {
@@ -584,147 +584,18 @@
584584
throw new Exception(__('Le paramètre "state" ne peut être vide et doit avoir pour valeur [run,stop,enable,disable]', __FILE__));
585585
}
586586

587-
/* * ************************JeeNetwork*************************** */
588-
if ($jsonrpc->getMethod() == 'jeeNetwork::handshake') {
589-
if (config::byKey('jeeNetwork::mode') != 'slave') {
590-
throw new Exception(__('Impossible d\'ajouter une box Jeedom non esclave à un réseau Jeedom', __FILE__));
591-
}
592-
$auiKey = config::byKey('auiKey');
593-
if ($auiKey == '') {
594-
$auiKey = config::genKey(255);
595-
config::save('auiKey', $auiKey);
596-
}
597-
$return = array(
598-
'mode' => config::byKey('jeeNetwork::mode'),
599-
'nbUpdate' => update::nbNeedUpdate(),
600-
'version' => jeedom::version(),
601-
'nbMessage' => message::nbMessage(),
602-
'auiKey' => $auiKey,
603-
'jeedom::url' => config::byKey('jeedom::url'),
604-
'ngrok::port' => config::byKey('ngrok::port'),
605-
);
606-
if (!filter_var(network::getNetworkAccess('external', 'ip'), FILTER_VALIDATE_IP) && network::getNetworkAccess('external', 'ip') != '') {
607-
$return['jeedom::url'] = network::getNetworkAccess('internal');
608-
}
609-
foreach (plugin::listPlugin(true) as $plugin) {
610-
if ($plugin->getAllowRemote() == 1) {
611-
$return['plugin'][] = $plugin->getId();
612-
}
613-
}
614-
$address = (isset($params['address']) && $params['address'] != '') ? $params['address'] : getClientIp();
615-
config::save('jeeNetwork::master::ip', $address);
616-
config::save('jeeNetwork::master::apikey', $params['apikey_master']);
617-
config::save('jeeNetwork::slave::id', $params['slave_id']);
618-
if (config::byKey('internalAddr') == '') {
619-
config::save('internalAddr', $params['slave_ip']);
620-
}
621-
jeeNetwork::testMaster();
622-
$jsonrpc->makeSuccess($return);
623-
}
587+
/* * ************************System*************************** */
624588

625-
if ($jsonrpc->getMethod() == 'jeeNetwork::reload') {
626-
foreach (plugin::listPlugin(true) as $plugin) {
627-
try {
628-
$plugin->launch('slaveReload');
629-
} catch (Exception $ex) {
630-
}
631-
}
632-
$jsonrpc->makeSuccess('ok');
633-
}
634-
635-
if ($jsonrpc->getMethod() == 'jeeNetwork::halt') {
589+
if ($jsonrpc->getMethod() == 'jeedom::halt') {
636590
jeedom::haltSystem();
637591
$jsonrpc->makeSuccess('ok');
638592
}
639593

640-
if ($jsonrpc->getMethod() == 'jeeNetwork::reboot') {
594+
if ($jsonrpc->getMethod() == 'jeedom::reboot') {
641595
jeedom::rebootSystem();
642596
$jsonrpc->makeSuccess('ok');
643597
}
644598

645-
if ($jsonrpc->getMethod() == 'jeeNetwork::update') {
646-
jeedom::update('', 0);
647-
$jsonrpc->makeSuccess('ok');
648-
}
649-
650-
if ($jsonrpc->getMethod() == 'jeeNetwork::checkUpdate') {
651-
update::checkAllUpdate();
652-
$jsonrpc->makeSuccess('ok');
653-
}
654-
655-
if ($jsonrpc->getMethod() == 'jeeNetwork::receivedBackup') {
656-
if (config::byKey('jeeNetwork::mode') == 'slave') {
657-
throw new Exception(__('Seul un maître peut recevoir une sauvegarde', __FILE__));
658-
}
659-
$jeeNetwork = jeeNetwork::byId($params['slave_id']);
660-
if (!is_object($jeeNetwork)) {
661-
throw new Exception(__('Aucun esclave correspondant à l\'ID :', __FILE__) . ' ' . secureXSS($params['slave_id']));
662-
}
663-
if (substr(config::byKey('backup::path'), 0, 1) != '/') {
664-
$backup_dir = __DIR__ . '/../../' . config::byKey('backup::path');
665-
} else {
666-
$backup_dir = config::byKey('backup::path');
667-
}
668-
$uploaddir = $backup_dir . '/slave/';
669-
if (!file_exists($uploaddir)) {
670-
mkdir($uploaddir);
671-
}
672-
if (!file_exists($uploaddir)) {
673-
throw new Exception(__('Répertoire de téléversement non trouvé :', __FILE__) . ' ' . secureXSS($uploaddir));
674-
}
675-
$_file = $_FILES['file'];
676-
$extension = strtolower(strrchr($_file['name'], '.'));
677-
if (!in_array($extension, array('.tar.gz', '.gz', '.tar'))) {
678-
throw new Exception(__('Extension du fichier non valide (autorisé .tar.gz, .tar et .gz) :', __FILE__) . ' ' . secureXSS($extension));
679-
}
680-
if (filesize($_file['tmp_name']) > 50000000) {
681-
throw new Exception(__('La taille du fichier est trop importante (maximum 50Mo)', __FILE__));
682-
}
683-
$uploadfile = $uploaddir . $jeeNetwork->getId() . '-' . $jeeNetwork->getName() . '-' . $jeeNetwork->getConfiguration('version') . '-' . date('Y-m-d_H\hi') . '.tar' . $extension;
684-
if (!move_uploaded_file($_file['tmp_name'], $uploadfile)) {
685-
throw new Exception(__('Impossible de téléverser le fichier', __FILE__));
686-
}
687-
system('find ' . $uploaddir . $jeeNetwork->getId() . '*' . ' -mtime +' . config::byKey('backup::keepDays') . ' -print | xargs -r rm');
688-
$jsonrpc->makeSuccess('ok');
689-
}
690-
691-
if ($jsonrpc->getMethod() == 'jeeNetwork::restoreBackup') {
692-
if (config::byKey('jeeNetwork::mode') != 'slave') {
693-
throw new Exception(__('Seul un esclave peut restaurer une sauvegarde', __FILE__));
694-
}
695-
if (substr(config::byKey('backup::path'), 0, 1) != '/') {
696-
$uploaddir = __DIR__ . '/../../' . config::byKey('backup::path');
697-
} else {
698-
$uploaddir = config::byKey('backup::path');
699-
}
700-
if (!file_exists($uploaddir)) {
701-
mkdir($uploaddir);
702-
}
703-
if (!file_exists($uploaddir)) {
704-
throw new Exception(__('Répertoire de téléversement non trouvé :', __FILE__) . ' ' . secureXSS($uploaddir));
705-
}
706-
$_file = $_FILES['file'];
707-
$extension = strtolower(strrchr($_file['name'], '.'));
708-
if (!in_array($extension, array('.tar.gz', '.gz', '.tar'))) {
709-
throw new Exception(__('Extension du fichier non valide (autorisé .tar.gz, .tar et .gz) :', __FILE__) . ' ' . secureXSS($extension));
710-
}
711-
if (filesize($_file['tmp_name']) > 50000000) {
712-
throw new Exception(__('La taille du fichier est trop importante (maximum 50Mo)', __FILE__));
713-
}
714-
$backup_name = 'backup-' . jeedom::version() . '-' . date("d-m-Y-H\hi") . '.tar.gz';
715-
$uploadfile = $uploaddir . '/' . $backup_name;
716-
if (!move_uploaded_file($_file['tmp_name'], $uploadfile)) {
717-
throw new Exception(__('Impossible de téléverser le fichier', __FILE__));
718-
}
719-
jeedom::restore($uploadfile, true);
720-
$jsonrpc->makeSuccess('ok');
721-
}
722-
723-
if ($jsonrpc->getMethod() == 'jeeNetwork::backup') {
724-
jeedom::backup(true);
725-
$jsonrpc->makeSuccess('ok');
726-
}
727-
728599
/* * ************************Backup*************************** */
729600

730601
if ($jsonrpc->getMethod() == 'backup::list') {

0 commit comments

Comments
 (0)