Skip to content

Commit

Permalink
Backport fixes from jeedom#2369
Browse files Browse the repository at this point in the history
  • Loading branch information
BadWolf42 committed Jan 14, 2024
1 parent 48b59d0 commit 6c8bddb
Show file tree
Hide file tree
Showing 17 changed files with 64 additions and 66 deletions.
2 changes: 1 addition & 1 deletion core/ajax/log.ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
}

if (init('action') == 'get') {
ajax::success(log::get(init('log'), init('start', 0), init('nbLine', 99999)));
ajax::success(log::get(init('log', 'core'), init('start', 0), init('nbLine', 99999)));
}

throw new Exception(__('Aucune méthode correspondante à :', __FILE__) . ' ' . init('action'));
Expand Down
15 changes: 10 additions & 5 deletions core/api/jeeApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,24 @@
echo "The page that you have requested could not be found.";
die();
}
/** @var user|null $_USER_GLOBAL */
global $_USER_GLOBAL;
$_USER_GLOBAL = null;
/** @var bool $_RESTRICTED */
global $_RESTRICTED;
$_RESTRICTED = false;
if (init('type') != '') {
try {
if (init('type') == 'ask') {
if (trim(init('token')) == '' || strlen(init('token')) < 64) {
throw new Exception(__('Token invalide', __FILE__));
throw new Exception(__('Commande inconnue ou Token invalide', __FILE__));
}
$cmd = cmd::byId(init('cmd_id'));
if (!is_object($cmd)) {
throw new Exception(__('Commande inconnue :', __FILE__) . ' ' . init('cmd_id'));
throw new Exception(__('Commande inconnue ou Token invalide', __FILE__));
}
if (trim($cmd->getCache('ask::token', config::genKey())) != init('token')) {
throw new Exception(__('Token invalide', __FILE__));
throw new Exception(__('Commande inconnue ou Token invalide', __FILE__));
}
if (!$cmd->askResponse(init('response'))) {
throw new Exception(__('Erreur response ask, temps écoulé ou réponse invalide', __FILE__));
Expand Down Expand Up @@ -108,7 +110,7 @@
if ($type == 'interact') {
$query = init('query');
if (init('utf8', 0) == 1) {
$query = utf8_encode($query);
$query = mb_convert_encoding($query, 'UTF-8', 'ISO-8859-1');
}
$param = array();
if (init('emptyReply') != '') {
Expand Down Expand Up @@ -491,7 +493,7 @@
if (isset($params['key'])) {
$jsonrpc->makeSuccess(jeeObject::getGlobalSummary($params['key']));
}
$return = array();
/** @var array $def */
$def = config::byKey('object:summary');
foreach ($def as $key => &$value) {
$value['value'] = jeeObject::getGlobalSummary($key);
Expand Down Expand Up @@ -1300,6 +1302,9 @@
/* Mobile API */
if ($jsonrpc->getMethod() == 'getJson') {
log::add('api', 'debug', 'Demande du RDK to send with Json');
if (!is_object($_USER_GLOBAL)) {
throw new Exception(__('Utilisateur non défini', __FILE__), -32500);
}
$registerDevice = $_USER_GLOBAL->getOptions('registerDevice', array());
if (!is_array($registerDevice)) {
$registerDevice = array();
Expand Down
2 changes: 1 addition & 1 deletion core/class/jeedom.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -1493,7 +1493,7 @@ public static function massReplace($_options = array(), $_eqlogics = array(), $_
$sourceEq = eqLogic::byId($_sourceId);
$targetEq = eqLogic::byId($_targetId);
if (!is_object($sourceEq) || !is_object($targetEq)) continue;

//replace equipment where used:
jeedom::replaceTag(array('eqLogic'.$_sourceId => 'eqLogic'.$_targetId));

Expand Down
11 changes: 4 additions & 7 deletions core/class/log.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,14 +225,14 @@ public static function removeAll() {
return true;
}

/*
/**
*
* @param string $_log
* @param int $_begin
* @param int $_nbLines
* @return boolean|array
*/
public static function get($_log = 'core', $_begin, $_nbLines) {
public static function get($_log, $_begin, $_nbLines) {
self::chunk($_log);
$path = (!file_exists($_log) || !is_file($_log)) ? self::getPathToLog($_log) : $_log;
if (!file_exists($path)) {
Expand All @@ -246,11 +246,8 @@ public static function get($_log = 'core', $_begin, $_nbLines) {
while ($log->valid() && $linesRead != $_nbLines) {
$line = trim($log->current()); //get current line
if ($line != '') {
if (function_exists('mb_convert_encoding')) {
array_unshift($page, mb_convert_encoding($line, 'UTF-8'));
} else {
array_unshift($page, $line);
}
$line = secureXSS($line);
array_unshift($page, mb_convert_encoding($line, 'UTF-8', 'ISO-8859-1'));
}
$log->next();
$linesRead++;
Expand Down
17 changes: 12 additions & 5 deletions core/class/scenarioExpression.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ public static function color_gradient($_from_color, $_to_color, $_min, $_max, $_
$RedOrigin = hexdec(substr($startcol, 1, 2));
$GrnOrigin = hexdec(substr($startcol, 3, 2));
$BluOrigin = hexdec(substr($startcol, 5, 2));
$RetVal = array();
if ($graduations >= 2) {
$GradientSizeRed = (hexdec(substr($endcol, 1, 2)) - $RedOrigin) / $graduations;
$GradientSizeGrn = (hexdec(substr($endcol, 3, 2)) - $GrnOrigin) / $graduations;
Expand Down Expand Up @@ -1020,10 +1021,10 @@ public static function time_diff($_date1, $_date2, $_format = 'd', $_rnd = 2) {
$dureeAbs %= 60;
$s = $dureeAbs;
$ret = '';
if ($j > 0) $ret .= "${j}j ";
if ($h > 0) $ret .= "${h}h ";
if ($m > 0) $ret .= "${m}min ";
if ($s > 0) $ret .= "${s}s";
if ($j > 0) $ret .= $j . 'j ';
if ($h > 0) $ret .= $h . 'h ';
if ($m > 0) $ret .= $m . 'min ';
if ($s > 0) $ret .= $s . 's';
return (trim($ret));
case 'df':
return round($duree / 86400, $_rnd); // en jours decimaux avec signe
Expand Down Expand Up @@ -1177,7 +1178,13 @@ public static function getRequestTags($_expression) {
return array_merge($return, $new);
}

public static function tag(&$_scenario = null, $_name, $_default = '') {
/**
* @param null|scenario $_scenario
* @param string $_name
* @param string $_default
* @return string
*/
public static function tag(&$_scenario, $_name, $_default = '') {
if ($_scenario == null) {
return $_default;
}
Expand Down
29 changes: 14 additions & 15 deletions core/config/jeedom.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -952,35 +952,34 @@
'startOnEvent' => array('txt' => __('Scénario exécuté sur événement', __FILE__), 'replace' => '<label class="success">::</label>'),
'startAutoOnShedule' => array('txt' => __('Scénario exécuté automatiquement sur programmation', __FILE__), 'replace' => '<label class="success">::</label>'),
'finishOk' => array('txt' => __('Fin correcte du scénario', __FILE__), 'replace' => '<label class="success">::</label>'),
'sheduledOn' => array('txt' => ' ' . __('programmée à :', __FILE__) . ' ', 'replace' => '<label class="success"> :: </label>'),
'startByScenario' => array('txt' => __('Lancement provoqué par le scénario :', __FILE__) . ' ', 'replace' => '<label class="success">:: </label>'),
'sheduledOn' => array('txt' => ' ' . __('programmée à :', __FILE__) . ' ', 'replace' => '<label class="success">::</label>'),
'startByScenario' => array('txt' => __('Lancement provoqué par le scénario :', __FILE__) . ' ', 'replace' => '<label class="success">::</label>'),
'startCausedBy' => array('txt' => __('Lancement provoqué', __FILE__), 'replace' => '<label class="success">::</label>'),
'startSubTask' => array('txt' => __('************Lancement sous tâche**************', __FILE__), 'replace' => '<label class="success">::</label>'),
'endSubTask' => array('txt' => __('************FIN sous tâche**************', __FILE__), 'replace' => '<label class="success">::</label>'),
'sheduleNow' => array('txt' => ' ' . __('lancement immédiat', __FILE__) . ' ', 'replace' => '<label class="success">::</label>'),

'execAction' => array('txt' => __('Exécution du sous-élément de type [action] :', __FILE__) . ' ', 'replace' => '<label class="info">- ::</label>'),
'execCondition' => array('txt' => __('Exécution du sous-élément de type [condition] :', __FILE__) . ' ', 'replace' => '<label class="info">- ::</label>'),
'execAction' => array('txt' => '- ' . __('Exécution du sous-élément de type [action] :', __FILE__) . ' ', 'replace' => '<label class="info">::</label>'),
'execCondition' => array('txt' => '- ' . __('Exécution du sous-élément de type [condition] :', __FILE__) . ' ', 'replace' => '<label class="info">::</label>'),

'execCmd' => array('txt' => __('Exécution de la commande', __FILE__) . ' ', 'replace' => '<label class="warning">:: </label>'),
'execCode' => array('txt' => __('Exécution d\'un bloc code', __FILE__), 'replace' => '<label class="warning">:: </label>'),
'launchScenario' => array('txt' => __('Lancement du scénario :', __FILE__) . ' ', 'replace' => '<label class="warning">:: </label>'),
'launchScenarioSync' => array('txt' => __('Lancement du scénario en mode synchrone', __FILE__), 'replace' => '<label class="warning">:: </label>'),
'task' => array('txt' => __('Tâche :', __FILE__) . ' ', 'replace' => '<label class="warning">:: </label>'),
'event' => array('txt' => __('Changement de', __FILE__) . ' ', 'replace' => '<label class="warning">:: </label>'),
'execCmd' => array('txt' => __('Exécution de la commande', __FILE__) . ' ', 'replace' => '<label class="warning">::</label>'),
'execCode' => array('txt' => __('Exécution d\'un bloc code', __FILE__) . ' ', 'replace' => '<label class="warning">::</label>'),
'launchScenario' => array('txt' => __('Lancement du scénario :', __FILE__) . ' ', 'replace' => '<label class="warning">::</label>'),
'launchScenarioSync' => array('txt' => __('Lancement du scénario en mode synchrone', __FILE__) . ' ', 'replace' => '<label class="warning">::</label>'),
'task' => array('txt' => __('Tâche :', __FILE__) . ' ', 'replace' => '<label class="warning">::</label>'),
'event' => array('txt' => __('Changement de', __FILE__) . ' ', 'replace' => '<label class="warning">::</label>'),

'stopTimeout' => array('txt' => __('Arrêt du scénario car il a dépassé son temps de timeout :', __FILE__) . ' ', 'replace' => '<label class="danger">:: </label>'),
'stopTimeout' => array('txt' => __('Arrêt du scénario car il a dépassé son temps de timeout :', __FILE__) . ' ', 'replace' => '<label class="danger">::</label>'),
'disableNoSubtask' => array('txt' => __('Scénario désactivé non lancement de la sous tâche', __FILE__), 'replace' => '<label class="danger">::</label>'),
'disableEqNoExecCmd' => array('txt' => __('Equipement désactivé - impossible d\'exécuter la commande :', __FILE__) . ' ', 'replace' => '<label class="danger">:: </label>'),
'disableEqNoExecCmd' => array('txt' => __('Equipement désactivé - impossible d\'exécuter la commande :', __FILE__) . ' ', 'replace' => '<label class="danger">::</label>'),
'toStartUnfound' => array('txt' => __('Eléments à lancer non trouvé', __FILE__), 'replace' => '<label class="danger">::</label>'),
'invalideShedule' => array('txt' => __(', heure programmée invalide :', __FILE__) . ' ', 'replace' => '<label class="danger">::</label>'),
'noCmdFoundFor' => array('txt' => __('[Erreur] Aucune commande trouvée pour', __FILE__) . ' ', 'replace' => '<label class="danger">::</label>'),
'unfoundCmd' => array('txt' => __('Commande introuvable', __FILE__), 'replace' => '<label class="danger">::</label>'),
'unfoundCmdCheckId' => array('txt' => __('Commande introuvable - Vérifiez l\'id', __FILE__), 'replace' => '<label class="danger">::</label>'),
'unfoundEq' => array('txt' => __('Action sur l\'équipement impossible. Equipement introuvable - Vérifiez l\'id :', __FILE__) . ' ', 'replace' => '<label class="danger">::</label>'),
'unfoundScenario' => array('txt' => __('Action sur scénario impossible. Scénario introuvable - Vérifiez l\'id :', __FILE__) . ' ', 'replace' => '<label class="danger">::</label>'),
'disableScenario' => array('txt' => __('Impossible d\'exécuter le scénario :', __FILE__) . ' ', 'replace' => '<label class="danger">:: </label>'),
'invalidExpr' => array('txt' => __('Expression non valide :', __FILE__) . ' ', 'replace' => '<label class="danger">:: </label>'),
'disableScenario' => array('txt' => __('Impossible d\'exécuter le scénario :', __FILE__) . ' ', 'replace' => '<label class="danger">::</label>'),
'invalidExpr' => array('txt' => __('Expression non valide :', __FILE__) . ' ', 'replace' => '<label class="danger">::</label>'),
'invalidDuration' => array('txt' => __('Aucune durée trouvée pour l\'action sleep ou la durée n\'est pas valide :', __FILE__) . ' ', 'replace' => '<label class="danger">::</label>'),
);
//$this->setLog( $GLOBALS['JEEDOM_SCLOG_TEXT']['startCausedBy']['txt'] )
5 changes: 2 additions & 3 deletions core/i18n/de_DE.json
Original file line number Diff line number Diff line change
Expand Up @@ -4847,8 +4847,7 @@
"Aucune méthode correspondante :": "Keine entsprechende Methode:"
},
"core\/api\/jeeApi.php": {
"Token invalide": "Ungültiger Token",
"Commande inconnue :": "Unbekannter Befehl:",
"Commande inconnue ou Token invalide": "Unbekannter Befehl oder Ungültiger Token",
"Erreur response ask, temps écoulé ou réponse invalide": "Antwortanfragefehler, verstrichene Zeit oder ungültige Antwort",
"Vous n\\'êtes pas autorisé à effectuer cette action": "Sie sind nicht berechtigt, diese Aktion auszuführen",
"Vous n\\'êtes pas autorisé à effectuer cette action, IP :": "Sie sind nicht berechtigt, diese Aktion auszuführen, IP:",
Expand Down Expand Up @@ -4899,4 +4898,4 @@
"Son trouvé path :": "Sein gefundener Weg:",
"Erreur aucun fichier trouvé à supprimer alors que le répertoire fait :": "Fehler Es wurde keine Datei zum Löschen gefunden, während das Verzeichnis Folgendes tut:"
}
}
}
5 changes: 2 additions & 3 deletions core/i18n/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -4847,8 +4847,7 @@
"Aucune méthode correspondante :": "No corresponding method:"
},
"core\/api\/jeeApi.php": {
"Token invalide": "Invalid token",
"Commande inconnue :": "Unknown command:",
"Commande inconnue ou Token invalide": "Unknown command or Invalid token",
"Erreur response ask, temps écoulé ou réponse invalide": "Response ask error, time elapsed or invalid response",
"Vous n\\'êtes pas autorisé à effectuer cette action": "You are not authorized to perform this action",
"Vous n\\'êtes pas autorisé à effectuer cette action, IP :": "You are not authorized to perform this action, IP :",
Expand Down Expand Up @@ -4899,4 +4898,4 @@
"Son trouvé path :": "Sound found path:",
"Erreur aucun fichier trouvé à supprimer alors que le répertoire fait :": "Error no file found to delete while the directory size is:"
}
}
}
5 changes: 2 additions & 3 deletions core/i18n/es_ES.json
Original file line number Diff line number Diff line change
Expand Up @@ -4847,8 +4847,7 @@
"Aucune méthode correspondante :": "No hay método correspondiente:"
},
"core\/api\/jeeApi.php": {
"Token invalide": "Token inválido",
"Commande inconnue :": "Comando desconocido:",
"Commande inconnue ou Token invalide": "Comando desconocido o Token inválido",
"Erreur response ask, temps écoulé ou réponse invalide": "Error de solicitud de respuesta, tiempo transcurrido o respuesta no válida",
"Vous n\\'êtes pas autorisé à effectuer cette action": "No tiene autorización para realizar esta acción",
"Vous n\\'êtes pas autorisé à effectuer cette action, IP :": "No está autorizado para realizar esta acción, IP:",
Expand Down Expand Up @@ -4899,4 +4898,4 @@
"Son trouvé path :": "Su camino encontrado:",
"Erreur aucun fichier trouvé à supprimer alors que le répertoire fait :": "Error: no se encontró ningún archivo para eliminar mientras el directorio sí:"
}
}
}
5 changes: 2 additions & 3 deletions core/i18n/fr_FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -4847,8 +4847,7 @@
"Aucune méthode correspondante :": "Aucune méthode correspondante :"
},
"core\/api\/jeeApi.php": {
"Token invalide": "Token invalide",
"Commande inconnue :": "Commande inconnue :",
"Commande inconnue ou Token invalide": "Commande inconnue ou Token invalide",
"Erreur response ask, temps écoulé ou réponse invalide": "Erreur response ask, temps écoulé ou réponse invalide",
"Vous n\\'êtes pas autorisé à effectuer cette action": "Vous n\\'êtes pas autorisé à effectuer cette action",
"Vous n\\'êtes pas autorisé à effectuer cette action, IP :": "Vous n\\'êtes pas autorisé à effectuer cette action, IP :",
Expand Down Expand Up @@ -4899,4 +4898,4 @@
"Son trouvé path :": "Son trouvé path :",
"Erreur aucun fichier trouvé à supprimer alors que le répertoire fait :": "Erreur aucun fichier trouvé à supprimer alors que le répertoire fait :"
}
}
}
5 changes: 2 additions & 3 deletions core/i18n/id_ID.json
Original file line number Diff line number Diff line change
Expand Up @@ -4847,8 +4847,7 @@
"Aucune méthode correspondante :": "Aucune méthode correspondante :"
},
"core\/api\/jeeApi.php": {
"Token invalide": "Token invalide",
"Commande inconnue :": "Commande inconnue :",
"Commande inconnue ou Token invalide": "Commande inconnue ou Token invalide",
"Erreur response ask, temps écoulé ou réponse invalide": "Erreur response ask, temps écoulé ou réponse invalide",
"Vous n\\'êtes pas autorisé à effectuer cette action": "Vous n\\'êtes pas autorisé à effectuer cette action",
"Vous n\\'êtes pas autorisé à effectuer cette action, IP :": "Vous n\\'êtes pas autorisé à effectuer cette action, IP :",
Expand Down Expand Up @@ -4899,4 +4898,4 @@
"Son trouvé path :": "Son trouvé path :",
"Erreur aucun fichier trouvé à supprimer alors que le répertoire fait :": "Erreur aucun fichier trouvé à supprimer alors que le répertoire fait :"
}
}
}
5 changes: 2 additions & 3 deletions core/i18n/it_IT.json
Original file line number Diff line number Diff line change
Expand Up @@ -4847,8 +4847,7 @@
"Aucune méthode correspondante :": "Nessun metodo corrispondente:"
},
"core\/api\/jeeApi.php": {
"Token invalide": "Token non valido",
"Commande inconnue :": "Comando sconosciuto:",
"Commande inconnue ou Token invalide": "Comando sconosciuto o Token non valido",
"Erreur response ask, temps écoulé ou réponse invalide": "Erreur response ask, temps écoulé ou réponse invalide",
"Vous n\\'êtes pas autorisé à effectuer cette action": "Non sei autorizzato a eseguire questa azione",
"Vous n\\'êtes pas autorisé à effectuer cette action, IP :": "Vous n\\'êtes pas autorisé à effectuer cette action, IP :",
Expand Down Expand Up @@ -4899,4 +4898,4 @@
"Son trouvé path :": "Il suo percorso trovato:",
"Erreur aucun fichier trouvé à supprimer alors que le répertoire fait :": "Errore nessun file trovato da eliminare mentre la directory fa:"
}
}
}
5 changes: 2 additions & 3 deletions core/i18n/ja_JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -4847,8 +4847,7 @@
"Aucune méthode correspondante :": "対応する方法はありません:"
},
"core\/api\/jeeApi.php": {
"Token invalide": "Token invalide",
"Commande inconnue :": "不明なコマンド:",
"Commande inconnue ou Token invalide": "不明なコマンド / Token invalide",
"Erreur response ask, temps écoulé ou réponse invalide": "Erreur response ask, temps écoulé ou réponse invalide",
"Vous n\\'êtes pas autorisé à effectuer cette action": "このアクションを実行する権限がありません",
"Vous n\\'êtes pas autorisé à effectuer cette action, IP :": "Vous n\\'êtes pas autorisé à effectuer cette action, IP :",
Expand Down Expand Up @@ -4899,4 +4898,4 @@
"Son trouvé path :": "Son trouvé path :",
"Erreur aucun fichier trouvé à supprimer alors que le répertoire fait :": "Erreur aucun fichier trouvé à supprimer alors que le répertoire fait :"
}
}
}
5 changes: 2 additions & 3 deletions core/i18n/pt_PT.json
Original file line number Diff line number Diff line change
Expand Up @@ -4847,8 +4847,7 @@
"Aucune méthode correspondante :": "Nenhum método correspondente:"
},
"core\/api\/jeeApi.php": {
"Token invalide": "Token inválido",
"Commande inconnue :": "Comando desconhecido:",
"Commande inconnue ou Token invalide": "Comando desconhecido ou Token inválido",
"Erreur response ask, temps écoulé ou réponse invalide": "Erro de pergunta de resposta, tempo decorrido ou resposta inválida",
"Vous n\\'êtes pas autorisé à effectuer cette action": "Não está autorizado a executar esta ação",
"Vous n\\'êtes pas autorisé à effectuer cette action, IP :": "Não está autorizado a realizar esta ação, IP:",
Expand Down Expand Up @@ -4899,4 +4898,4 @@
"Son trouvé path :": "Caminho encontrado:",
"Erreur aucun fichier trouvé à supprimer alors que le répertoire fait :": "Erro, nenhum arquivo, para excluir, encontrado no diretório:"
}
}
}
Loading

0 comments on commit 6c8bddb

Please sign in to comment.