Skip to content

Commit b5e6758

Browse files
authored
Merge pull request #3231 from jeedom/4.5.3
4.5.3 stable release
2 parents fc34602 + 745c8d7 commit b5e6758

25 files changed

Lines changed: 573 additions & 483 deletions

.editorconfig

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# This file is for unifying the coding style for different editors and IDEs.
2+
# More information at http://EditorConfig.org
3+
4+
# Set this file as the root
5+
root = true
6+
7+
# Global settings for all files
8+
[*]
9+
indent_style = space
10+
end_of_line = lf
11+
charset = utf-8
12+
trim_trailing_whitespace = true
13+
insert_final_newline = true
14+
15+
# PHP files
16+
[*.php]
17+
indent_size = 4
18+
19+
# Frontend files
20+
[*.{css,html,js,less,sass,scss}]
21+
indent_size = 2

core/ajax/plugin.ajax.php

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,21 @@
180180
$infoPost .= ' - (' . ($daemon_info['last_launch'] ?? __('Inconnue', __FILE__)) . ')';
181181
}
182182

183+
$healt = '[details="' . __('Santé', __FILE__) . '"]';
184+
$healt .= '<br>```<br>';
185+
foreach ((jeedom::health()) as $datas) {
186+
if ($datas['state'] === 2) {
187+
$healt .= "🟠 ";
188+
} else if ($datas['state']) {
189+
$healt .= "🟢 ";
190+
} else {
191+
$healt .= "🔴 ";
192+
}
193+
$healt .= $datas['name'] . ' : ' . str_replace(["\r","\n"], " ", $datas['result']) . '<br>';
194+
}
195+
$healt .= '<br>```<br>';
196+
$healt .= '[/details]<br>';
197+
183198
$infoPlugin = '';
184199
if (method_exists($plugin_id, 'getConfigForCommunity')) {
185200
$infoPlugin .= '**' . __('Informations complémentaires', __FILE__) . '**<br>';
@@ -190,7 +205,7 @@
190205
$communitUrl = 'https://community.jeedom.com';
191206
$ressource = '/new-topic?';
192207

193-
$finalBody = br2nl($header . $infoPost . $footer . $infoPlugin);
208+
$finalBody = br2nl($header . $infoPost . $footer . $healt . $infoPlugin);
194209

195210
$data = array(
196211
'category' => 'plugins/' . $plugin->getCategory(),

core/ajax/user.ajax.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
throw new Exception(__('Double authentification requise', __FILE__), -32012);
5353
}
5454
if (!login(init('username'), init('password'), init('twoFactorCode'))) {
55+
log::add('connection', 'info',network::getClientIp().' - '. __('Mot de passe ou nom d\'utilisateur incorrect', __FILE__));
5556
throw new Exception(__('Mot de passe ou nom d\'utilisateur incorrect', __FILE__));
5657
}
5758
}
@@ -78,6 +79,7 @@
7879
$_SESSION['user']->save();
7980
@session_write_close();
8081
}
82+
log::add('connection', 'info',network::getClientIp().' - '. __('Connexion réussie pour : ', __FILE__).$_SESSION['user']->getLogin());
8183
ajax::success();
8284
}
8385

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)