diff --git a/core/ajax/log.ajax.php b/core/ajax/log.ajax.php index b0cac43631..e6a4ac78a1 100644 --- a/core/ajax/log.ajax.php +++ b/core/ajax/log.ajax.php @@ -68,8 +68,8 @@ init('log'), intval(init('position', 0)), init('search'), - intval(init('colored', 0)), - init('numbered', true), + boolval(init('colored', 0)), + boolval(init('numbered', 1)), intval(init('numberStart', 0)) ) ); diff --git a/core/api/jeeApi.php b/core/api/jeeApi.php index 6806670a2a..97f0641852 100644 --- a/core/api/jeeApi.php +++ b/core/api/jeeApi.php @@ -27,22 +27,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__)); @@ -110,7 +112,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') != '') { @@ -493,7 +495,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); @@ -1328,6 +1330,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(); diff --git a/core/class/jeedom.class.php b/core/class/jeedom.class.php index a9344be112..9c5f8da609 100644 --- a/core/class/jeedom.class.php +++ b/core/class/jeedom.class.php @@ -614,8 +614,9 @@ public static function apiAccess($_apikey = '', $_plugin = 'core') { } $apikey = self::getApiKey($_plugin); if (trim($apikey) != '' && $apikey === $_apikey) { + /** @var bool $_RESTRICTED */ global $_RESTRICTED; - $_RESTRICTED = config::byKey('api::' . $_plugin . '::restricted', 'core', 0); + $_RESTRICTED = config::byKey('api::' . $_plugin . '::restricted', 'core', false); return true; } return false; diff --git a/core/class/log.class.php b/core/class/log.class.php index 2fabc5caca..ef9044caf5 100644 --- a/core/class/log.class.php +++ b/core/class/log.class.php @@ -226,14 +226,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) { $path = (!file_exists($_log) || !is_file($_log)) ? self::getPathToLog($_log) : $_log; if (!file_exists($path)) { return false; @@ -260,20 +260,20 @@ public static function get($_log = 'core', $_begin, $_nbLines) { return $page; } - /* + /** * Get the log delta from $_position to the end of the file * New position is stored in $_position when eof is reached * * @param string $_log Log filename (default 'core') * @param int $_position Bytes representing position from the begining of the file (default 0) * @param string $_search Text to find in log file (default '') - * @param int $_colored Should lines be colored (default 0) [0: no ; 1: global log colors ; 2: scenario colors] + * @param int $_colored Should lines be colored * @param boolean $_numbered Should lines be numbered (default true) * @param int $_numStart At what number should lines number start (default 0) * @param int $_max Max number of returned lines (default 4000) * @return array Array containing log to append to buffer and new position for next call */ - public static function getDelta($_log = 'core', $_position = 0, $_search = '', $_colored = 0, $_numbered = true, $_numStart = 0, $_max = 4000) { + public static function getDelta($_log = 'core', $_position = 0, $_search = '', $_colored = false, $_numbered = true, $_numStart = 0, $_max = 4000) { // Add path to file if needed $filename = (file_exists($_log) && is_file($_log)) ? $_log : self::getPathToLog($_log); // Check if log file exists and is readable @@ -281,7 +281,12 @@ public static function getDelta($_log = 'core', $_position = 0, $_search = '', $ return array('position' => 0, 'line' => 0, 'logText' => ''); // Locate EOF fseek($fp, 0, SEEK_END); - $_position = min($_position, ftell($fp)); + // If log file has been truncated/altered (EOF is smaller than requested position) + // Then we restart from the start of the file + if (ftell($fp) < $_position) { + $_position = 0; + $_numStart = 0; + } // Set file pointer at requested position or at EOF fseek($fp, $_position); // Iterate the file @@ -305,66 +310,96 @@ public static function getDelta($_log = 'core', $_position = 0, $_search = '', $ $_position = ftell($fp); fclose($fp); - // Display only the last jeedom.log.maxLines + // Display only the last maxLines $logText = ''; + $nbLogs = count($logs); - // If logs are TRUNCATED, then add a message - if (count($logs) > $_max) { + if ($nbLogs == 0) { + return array('position' => $_position, 'line' => $_numStart, 'logText' => $logText); + } + if ($nbLogs > $_max) { + // If logs must be TRUNCATED, then add a message $logText .= "-------------------- TRUNCATED LOG --------------------\n"; $logs = array_slice($logs, -$_max, $_max); } // Merge all lignes $logText .= implode('', $logs); + // Clear logs from HTML + $logText = secureXSS($logText); + + // Apply color in logs + if ($_colored) { + // Highlight searched text first (when more than 3 chars) + if (strlen($_search) > 2) { + $srch = preg_quote($_search, '/'); + $logText = preg_replace('/(' . $srch . ')/i', '$1', $logText); + } + + $search = array(); $replace = array(); + $search[] = '[DEBUG]'; $replace[] = ' D<&>EBUG '; + $search[] = '[INFO]'; $replace[] = ' I<&>NFO '; + $search[] = '[NOTICE]'; $replace[] = 'N<&>OTICE '; + $search[] = '[WARNING]'; $replace[] = 'W<&>ARNING'; + $search[] = '[ERROR]'; $replace[] = ' E<&>RROR '; + $search[] = '[CRITICAL]'; $replace[] = ' C<&>RITI '; + $search[] = '[ALERT]'; $replace[] = ' A<&>LERT '; + $search[] = '[EMERGENCY]'; $replace[] = ' E<&>MERG '; + + $search[] = '[ OK ]'; $replace[] = '[  O<&>K  ]'; + $search[] = '[ KO ]'; $replace[] = '[  K<&>O  ]'; + $search[] = ' OK '; $replace[] = ' O<&>K '; + $search[] = ' KO '; $replace[] = ' K<&>O '; + $search[] = 'ERROR'; $replace[] = 'E<&>RROR'; + $search[] = 'PHP Notice:'; $replace[] = 'PHP N<&>otice:'; + $search[] = 'PHP Warning:'; $replace[] = 'PHP War<&>ning:'; + $search[] = 'PHP Stack trace:'; $replace[] = 'PHP S<&>tack trace:'; + + $search[] = ':br:'; $replace[] = '
'; + $search[] = ':bg-success:'; $replace[] = ''; + $search[] = ':bg-info:'; $replace[] = ''; + $search[] = ':bg-warning:'; $replace[] = ''; + $search[] = ':bg-danger:'; $replace[] = ''; + $search[] = ':/bg:'; $replace[] = ''; + $search[] = ':fg-success:'; $replace[] = ''; + $search[] = ':fg-info:'; $replace[] = ''; + $search[] = ':fg-warning:'; $replace[] = ''; + $search[] = ':fg-danger:'; $replace[] = ''; + $search[] = ':/fg:'; $replace[] = ''; + $search[] = ':b:'; $replace[] = ''; + $search[] = ':/b:'; $replace[] = ''; + $search[] = ':s:'; $replace[] = ''; + $search[] = ':/s:'; $replace[] = ''; + $search[] = ':i:'; $replace[] = ''; + $search[] = ':/i:'; $replace[] = ''; + $search[] = ':hide:'; $replace[] = ''; - // Apply color in system logs - if ($_colored == 1) { - $search = array( - '<', - '>', - 'WARNING:', - 'Erreur', - 'OK', - '[DEBUG]', - '[INFO]', - '[NOTICE]', - '[WARNING]', - '[ERROR]', - '[CRITICAL]', - '[ALERT]', - '[EMERGENCY]', - '-------------------- TRUNCATED LOG --------------------' - ); - $replace = array( - '<', - '>', - 'WARNING', - 'Erreur', - 'OK', - 'DEBUG', - 'INFO', - 'NOTICE', - 'WARNING', - 'ERROR', - 'CRITI', - 'ALERT', - 'EMERG', - '-------------------- TRUNCATED LOG --------------------' - ); - $logText = str_replace($search, $replace, $logText); - } - // Apply color in scenario logs - elseif ($_colored == 2) { - $search = array(); - $replace = array(); foreach($GLOBALS['JEEDOM_SCLOG_TEXT'] as $item) { $search[] = $item['txt']; - $replace[] = str_replace('::', $item['txt'], $item['replace']); + // Insert a marker into subject string to avoid replacing it multiple times + $subject = $item['txt'][0] . '<&>' . substr($item['txt'], 1); + $replace[] = str_replace('::', $subject, $item['replace']); + } + + $replacables = array( + array('txt' => 'WARNING:', 'replace' => '::'), + array('txt' => 'Erreur', 'replace' => '::'), + array('txt' => 'OK', 'replace' => '::'), + array('txt' => 'Log :', 'replace' => '   ::'), + array('txt' => '-------------------- TRUNCATED LOG --------------------', 'replace' => '::') + ); + foreach($replacables as $item) { + if (strlen($item['txt']) >= 2) { + $search[] = $item['txt']; + // Insert a marker into subject string to avoid replacing it multiple times + $subject = $item['txt'][0] . '<&>' . substr($item['txt'], 1); + $replace[] = str_replace('::', $subject, $item['replace']); + } } - $search[] = ' Start : '; - $replace[] = ' -- Start : '; - $search[] = 'Log :'; - $replace[] = '   Log :'; + // Replace everything in log $logText = str_replace($search, $replace, $logText); + // Remove all inserted markers + $logText = str_replace('<&>', '', $logText); } // Return the lines to the end of the file, the new position and line number diff --git a/core/class/scenario.class.php b/core/class/scenario.class.php index b386610b07..59b63b6106 100644 --- a/core/class/scenario.class.php +++ b/core/class/scenario.class.php @@ -914,9 +914,9 @@ public function execute($_trigger = '', $_message = '') { return; } if (count($this->getTags()) == 0) { - $this->setLog('Start : ' . trim($_message, "'") . '.'); + $this->setLog($GLOBALS['JEEDOM_SCLOG_TEXT']['start']['txt'] . ' ' . trim($_message, "'") . '.'); } else { - $this->setLog('Start : ' . trim($_message, "'") . '. Tags : ' . json_encode($this->getTags())); + $this->setLog($GLOBALS['JEEDOM_SCLOG_TEXT']['start']['txt'] . ' ' . trim($_message, "'") . '. Tags : ' . json_encode($this->getTags())); } $this->setLastLaunch(date('Y-m-d H:i:s')); $this->setState('in progress'); diff --git a/core/class/scenarioExpression.class.php b/core/class/scenarioExpression.class.php index 8930e6d8f3..6b1833b4c2 100644 --- a/core/class/scenarioExpression.class.php +++ b/core/class/scenarioExpression.class.php @@ -428,6 +428,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; @@ -1064,10 +1065,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 @@ -1233,7 +1234,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; } diff --git a/core/config/jeedom.config.php b/core/config/jeedom.config.php index 0b4b4cb0db..fe284ccf58 100644 --- a/core/config/jeedom.config.php +++ b/core/config/jeedom.config.php @@ -972,26 +972,27 @@ 'startOnEvent' => array('txt' => __('Scénario exécuté sur événement', __FILE__), 'replace' => ''), 'startAutoOnShedule' => array('txt' => __('Scénario exécuté automatiquement sur programmation', __FILE__), 'replace' => ''), 'finishOk' => array('txt' => __('Fin correcte du scénario', __FILE__), 'replace' => ''), - 'sheduledOn' => array('txt' => ' ' . __('programmée à :', __FILE__) . ' ', 'replace' => ''), - 'startByScenario' => array('txt' => __('Lancement provoqué par le scénario :', __FILE__) . ' ', 'replace' => ''), + 'sheduledOn' => array('txt' => ' ' . __('programmée à :', __FILE__) . ' ', 'replace' => ''), + 'startByScenario' => array('txt' => __('Lancement provoqué par le scénario :', __FILE__) . ' ', 'replace' => ''), 'startCausedBy' => array('txt' => __('Lancement provoqué', __FILE__), 'replace' => ''), 'startSubTask' => array('txt' => __('************Lancement sous tâche**************', __FILE__), 'replace' => ''), 'endSubTask' => array('txt' => __('************FIN sous tâche**************', __FILE__), 'replace' => ''), 'sheduleNow' => array('txt' => ' ' . __('lancement immédiat', __FILE__) . ' ', 'replace' => ''), - 'execAction' => array('txt' => __('Exécution du sous-élément de type [action] :', __FILE__) . ' ', 'replace' => ''), - 'execCondition' => array('txt' => __('Exécution du sous-élément de type [condition] :', __FILE__) . ' ', 'replace' => ''), + 'execAction' => array('txt' => '- ' . __('Exécution du sous-élément de type [action] :', __FILE__) . ' ', 'replace' => ''), + 'execCondition' => array('txt' => '- ' . __('Exécution du sous-élément de type [condition] :', __FILE__) . ' ', 'replace' => ''), - 'execCmd' => array('txt' => __('Exécution de la commande', __FILE__) . ' ', 'replace' => ''), - 'execCode' => array('txt' => __('Exécution d\'un bloc code', __FILE__), 'replace' => ''), - 'launchScenario' => array('txt' => __('Lancement du scénario :', __FILE__) . ' ', 'replace' => ''), - 'launchScenarioSync' => array('txt' => __('Lancement du scénario en mode synchrone', __FILE__), 'replace' => ''), - 'task' => array('txt' => __('Tâche :', __FILE__) . ' ', 'replace' => ''), - 'event' => array('txt' => __('Changement de', __FILE__) . ' ', 'replace' => ''), + 'execCmd' => array('txt' => __('Exécution de la commande', __FILE__) . ' ', 'replace' => ''), + 'execCode' => array('txt' => __('Exécution d\'un bloc code', __FILE__) . ' ', 'replace' => ''), + 'launchScenario' => array('txt' => __('Lancement du scénario :', __FILE__) . ' ', 'replace' => ''), + 'launchScenarioSync' => array('txt' => __('Lancement du scénario en mode synchrone', __FILE__) . ' ', 'replace' => ''), + 'start' => array('txt' => '-- ' . __('Début :', __FILE__), 'replace' => '::'), + 'task' => array('txt' => __('Tâche :', __FILE__) . ' ', 'replace' => ''), + 'event' => array('txt' => __('Changement de', __FILE__) . ' ', 'replace' => ''), - 'stopTimeout' => array('txt' => __('Arrêt du scénario car il a dépassé son temps de timeout :', __FILE__) . ' ', 'replace' => ''), + 'stopTimeout' => array('txt' => __('Arrêt du scénario car il a dépassé son temps de timeout :', __FILE__) . ' ', 'replace' => ''), 'disableNoSubtask' => array('txt' => __('Scénario désactivé non lancement de la sous tâche', __FILE__), 'replace' => ''), - 'disableEqNoExecCmd' => array('txt' => __('Equipement désactivé - impossible d\'exécuter la commande :', __FILE__) . ' ', 'replace' => ''), + 'disableEqNoExecCmd' => array('txt' => __('Equipement désactivé - impossible d\'exécuter la commande :', __FILE__) . ' ', 'replace' => ''), 'toStartUnfound' => array('txt' => __('Eléments à lancer non trouvé', __FILE__), 'replace' => ''), 'invalideShedule' => array('txt' => __(', heure programmée invalide :', __FILE__) . ' ', 'replace' => ''), 'noCmdFoundFor' => array('txt' => __('[Erreur] Aucune commande trouvée pour', __FILE__) . ' ', 'replace' => ''), @@ -999,8 +1000,7 @@ 'unfoundCmdCheckId' => array('txt' => __('Commande introuvable - Vérifiez l\'id', __FILE__), 'replace' => ''), 'unfoundEq' => array('txt' => __('Action sur l\'équipement impossible. Equipement introuvable - Vérifiez l\'id :', __FILE__) . ' ', 'replace' => ''), 'unfoundScenario' => array('txt' => __('Action sur scénario impossible. Scénario introuvable - Vérifiez l\'id :', __FILE__) . ' ', 'replace' => ''), - 'disableScenario' => array('txt' => __('Impossible d\'exécuter le scénario :', __FILE__) . ' ', 'replace' => ''), - 'invalidExpr' => array('txt' => __('Expression non valide :', __FILE__) . ' ', 'replace' => ''), + 'disableScenario' => array('txt' => __('Impossible d\'exécuter le scénario :', __FILE__) . ' ', 'replace' => ''), + 'invalidExpr' => array('txt' => __('Expression non valide :', __FILE__) . ' ', 'replace' => ''), 'invalidDuration' => array('txt' => __('Aucune durée trouvée pour l\'action sleep ou la durée n\'est pas valide :', __FILE__) . ' ', 'replace' => ''), ); -//$this->setLog( $GLOBALS['JEEDOM_SCLOG_TEXT']['startCausedBy']['txt'] ) diff --git a/core/i18n/de_DE.json b/core/i18n/de_DE.json index 8d9150ac90..137e31a18d 100644 --- a/core/i18n/de_DE.json +++ b/core/i18n/de_DE.json @@ -3776,6 +3776,7 @@ "Exécution d\\'un bloc code": "Ausführung eines Codeblocks", "Lancement du scénario :": "Start des Szenarios:", "Lancement du scénario en mode synchrone": "Starten des Szenarios im synchronen Modus", + "Début :": "Anfang:", "Tâche :": "Aufgabe:", "Changement de": "Änderung von", "Arrêt du scénario car il a dépassé son temps de timeout :": "Beenden des Szenarios, weil die Zeitüberschreitung überschritten wurde:", @@ -4992,8 +4993,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:", @@ -5045,4 +5045,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:" } -} \ No newline at end of file +} diff --git a/core/i18n/en_US.json b/core/i18n/en_US.json index d121186c13..c7476a45b9 100644 --- a/core/i18n/en_US.json +++ b/core/i18n/en_US.json @@ -3776,6 +3776,7 @@ "Exécution d\\'un bloc code": "Execution of a code block", "Lancement du scénario :": "Launch of the scenario:", "Lancement du scénario en mode synchrone": "Launch of the scenario in synchronous mode", + "Début :": "Start:", "Tâche :": "Task:", "Changement de": "Change of", "Arrêt du scénario car il a dépassé son temps de timeout :": "Stopping the scenario because it has exceeded its timeout time:", @@ -4992,8 +4993,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 :", @@ -5045,4 +5045,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:" } -} \ No newline at end of file +} diff --git a/core/i18n/es_ES.json b/core/i18n/es_ES.json index 4ecba5e6fb..f45f7dd110 100644 --- a/core/i18n/es_ES.json +++ b/core/i18n/es_ES.json @@ -3776,6 +3776,7 @@ "Exécution d\\'un bloc code": "Ejecución de un bloque de código", "Lancement du scénario :": "Lanzamiento del escenario:", "Lancement du scénario en mode synchrone": "Lanzamiento del escenario en modo síncrono", + "Début :": "Inicio :", "Tâche :": "Mancha :", "Changement de": "Cambio de", "Arrêt du scénario car il a dépassé son temps de timeout :": "Deteniendo el escenario porque ha excedido su tiempo de espera:", @@ -4992,8 +4993,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:", @@ -5045,4 +5045,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í:" } -} \ No newline at end of file +} diff --git a/core/i18n/fr_FR.json b/core/i18n/fr_FR.json index ff8170447d..1ad639097a 100644 --- a/core/i18n/fr_FR.json +++ b/core/i18n/fr_FR.json @@ -3776,6 +3776,7 @@ "Exécution d\\'un bloc code": "Exécution d\\'un bloc code", "Lancement du scénario :": "Lancement du scénario :", "Lancement du scénario en mode synchrone": "Lancement du scénario en mode synchrone", + "Début :": "Début :", "Tâche :": "Tâche :", "Changement de": "Changement de", "Arrêt du scénario car il a dépassé son temps de timeout :": "Arrêt du scénario car il a dépassé son temps de timeout :", @@ -4992,8 +4993,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 :", @@ -5045,4 +5045,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 :" } -} \ No newline at end of file +} diff --git a/core/i18n/id_ID.json b/core/i18n/id_ID.json index 0f5372d635..2963c17121 100644 --- a/core/i18n/id_ID.json +++ b/core/i18n/id_ID.json @@ -3776,6 +3776,7 @@ "Exécution d\\'un bloc code": "Exécution d\\'un bloc code", "Lancement du scénario :": "Lancement du scénario :", "Lancement du scénario en mode synchrone": "Lancement du scénario en mode synchrone", + "Début :": "Start :", "Tâche :": "Tâche :", "Changement de": "Changement de", "Arrêt du scénario car il a dépassé son temps de timeout :": "Arrêt du scénario car il a dépassé son temps de timeout :", @@ -4992,8 +4993,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 :", @@ -5045,4 +5045,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 :" } -} \ No newline at end of file +} diff --git a/core/i18n/it_IT.json b/core/i18n/it_IT.json index dc675049bd..57c4c83e97 100644 --- a/core/i18n/it_IT.json +++ b/core/i18n/it_IT.json @@ -3776,6 +3776,7 @@ "Exécution d\\'un bloc code": "Exécution d\\'un bloc code", "Lancement du scénario :": "Lancement du scénario :", "Lancement du scénario en mode synchrone": "Lancement du scénario en mode synchrone", + "Début :": "Inizi:", "Tâche :": "Tâche :", "Changement de": "Changement de", "Arrêt du scénario car il a dépassé son temps de timeout :": "Arrêt du scénario car il a dépassé son temps de timeout :", @@ -4992,8 +4993,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 :", @@ -5045,4 +5045,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:" } -} \ No newline at end of file +} diff --git a/core/i18n/ja_JP.json b/core/i18n/ja_JP.json index 7e5ce62939..11b98914b0 100644 --- a/core/i18n/ja_JP.json +++ b/core/i18n/ja_JP.json @@ -3776,6 +3776,7 @@ "Exécution d\\'un bloc code": "Exécution d\\'un bloc code", "Lancement du scénario :": "Lancement du scénario :", "Lancement du scénario en mode synchrone": "Lancement du scénario en mode synchrone", + "Début :": "開始:", "Tâche :": "Tâche :", "Changement de": "Changement de", "Arrêt du scénario car il a dépassé son temps de timeout :": "Arrêt du scénario car il a dépassé son temps de timeout :", @@ -4992,8 +4993,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 :", @@ -5045,4 +5045,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 :" } -} \ No newline at end of file +} diff --git a/core/i18n/pt_PT.json b/core/i18n/pt_PT.json index 1a962ee010..fd5f972085 100644 --- a/core/i18n/pt_PT.json +++ b/core/i18n/pt_PT.json @@ -3776,6 +3776,7 @@ "Exécution d\\'un bloc code": "Execução de um bloco de código", "Lancement du scénario :": "Lançamento do cenário:", "Lancement du scénario en mode synchrone": "Lançamento do cenário em modo síncrono", + "Début :": "Inicio:", "Tâche :": "Tarefa:", "Changement de": "Mudança de", "Arrêt du scénario car il a dépassé son temps de timeout :": "O cenário interrompeu porque excedeu o tempo limite:", @@ -4992,8 +4993,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:", @@ -5045,4 +5045,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:" } -} \ No newline at end of file +} diff --git a/core/i18n/ru_RU.json b/core/i18n/ru_RU.json index 069e4ffc3c..9e9e745709 100644 --- a/core/i18n/ru_RU.json +++ b/core/i18n/ru_RU.json @@ -3776,6 +3776,7 @@ "Exécution d\\'un bloc code": "Exécution d\\'un bloc code", "Lancement du scénario :": "Lancement du scénario :", "Lancement du scénario en mode synchrone": "Lancement du scénario en mode synchrone", + "Début :": "Начало:", "Tâche :": "Tâche :", "Changement de": "Changement de", "Arrêt du scénario car il a dépassé son temps de timeout :": "Arrêt du scénario car il a dépassé son temps de timeout :", @@ -4992,8 +4993,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 :", @@ -5045,4 +5045,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 :" } -} \ No newline at end of file +} diff --git a/core/i18n/tr.json b/core/i18n/tr.json index 884fa66b7b..b34f183e87 100644 --- a/core/i18n/tr.json +++ b/core/i18n/tr.json @@ -3776,6 +3776,7 @@ "Exécution d\\'un bloc code": "Exécution d\\'un bloc code", "Lancement du scénario :": "Lancement du scénario :", "Lancement du scénario en mode synchrone": "Lancement du scénario en mode synchrone", + "Début :": "Başlangıç:", "Tâche :": "Tâche :", "Changement de": "Changement de", "Arrêt du scénario car il a dépassé son temps de timeout :": "Arrêt du scénario car il a dépassé son temps de timeout :", @@ -4992,8 +4993,7 @@ "Aucune méthode correspondante :": "Karşılık gelen yöntem yok:" }, "core\/api\/jeeApi.php": { - "Token invalide": "Geçersiz simge", - "Commande inconnue :": "Bilinmeyen komut:", + "Commande inconnue ou Token invalide": "Bilinmeyen komut veya Geçersiz simge", "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": "Bu işlemi gerçekleştirme yetkiniz yok", "Vous n\\'êtes pas autorisé à effectuer cette action, IP :": "Vous n\\'êtes pas autorisé à effectuer cette action, IP :", @@ -5016,7 +5016,7 @@ "Demande API pour les commandes": "Siparişler için API isteği", "Demande API pour les variables": "Değişkenler için API isteği", "Requête invalide. Version JSON-RPC invalide :": "Geçersiz istek. Geçersiz JSON-RPC sürümü:", - "L\\'identifiant ou le mot de passe ne peuvent pas être vide": "Kullanıcı adı veya şifre boş bırakılamaz", + "L\\'identifiant ou le mot de passe ne peuvent pas être vide": "Kullanıcı adı şifre boş bırakılamaz", "Echec lors de l\\'authentification": "Kimlik doğrulaması başarısız oldu", "Aucune méthode correspondante :": "Karşılık gelen yöntem yok:", "Objet introuvable :": "Nesne bulunamadı:", @@ -5045,4 +5045,4 @@ "Son trouvé path :": "Bulunan yolu:", "Erreur aucun fichier trouvé à supprimer alors que le répertoire fait :": "Dizin yapılırken silinecek dosya bulunamadı hatası:" } -} \ No newline at end of file +} diff --git a/core/js/log.class.js b/core/js/log.class.js index 0c7b66c38b..739b966c8a 100644 --- a/core/js/log.class.js +++ b/core/js/log.class.js @@ -60,7 +60,9 @@ jeedom.log.removeAll = function(_params) { domUtils.ajax(paramsAJAX); } +// DEPRECATED: jeedom.log.getScTranslations -> remove in 4.6? jeedom.log.getScTranslations = function(_params) { + jeedomUtils.deprecatedFunc('jeedom.log.getScTranslations', 'none', '4.6', '4.4') var paramsSpecifics = {}; var params = domUtils.extend({}, jeedom.private.default_params, paramsSpecifics, _params || {}); var paramsAJAX = jeedom.private.getParamsAJAX(params); @@ -71,7 +73,9 @@ jeedom.log.getScTranslations = function(_params) { domUtils.ajax(paramsAJAX); } +// DEPRECATED: jeedom.log.get -> remove in 4.6? jeedom.log.get = function(_params) { + jeedomUtils.deprecatedFunc('jeedom.log.get', 'jeedom.log.getDelta', '4.6', '4.4') var paramsRequired = ['log']; var paramsSpecifics = { global: _params.global || true, @@ -180,7 +184,9 @@ jeedom.log.clear = function(_params) { domUtils.ajax(paramsAJAX); } +// DEPRECATED: jeedom.log.autoupdate -> remove in 4.6? jeedom.log.autoupdate = function(_params) { + jeedomUtils.deprecatedFunc('jeedom.log.autoupdate', 'jeedom.log.autoUpdateDelta', '4.6', '4.4') if (!isset(_params.once)) _params['once'] = 0 if (!isset(_params.callNumber)) _params.callNumber = 0 if (!isset(_params.log)) return @@ -357,11 +363,19 @@ jeedom.log.autoUpdateDelta = function(_params) { if (!_params.display.isVisible()) return // Exit if Paused - if (_params.callNumber > 0 && isset(_params.control) && _params.control.getAttribute('data-state') != 1) { + if ( + _params.callNumber > 0 + && isset(_params.control) + && _params.control.getAttribute('data-state') != 1 + ) { return } // Exit if a newer instance on another log is running - if (_params.callNumber > 0 && isset(jeedom.log.currentAutoupdate[_params.display.getAttribute('id')]) && jeedom.log.currentAutoupdate[_params.display.getAttribute('id')].log != _params.log) { + if ( + _params.callNumber > 0 + && isset(jeedom.log.currentAutoupdate[_params.display.getAttribute('id')]) + && jeedom.log.currentAutoupdate[_params.display.getAttribute('id')].log != _params.log + ) { return } @@ -396,7 +410,7 @@ jeedom.log.autoUpdateDelta = function(_params) { }) // Setup callback: On search field update - _params.search.unRegisterEvent('keypress').registerEvent('keypress', function (event) { + _params.search.unRegisterEvent('keyup').registerEvent('keyup', function (event) { // Reset log position and empty view _params.position = 0; _params.lineNum = 0; @@ -414,29 +428,34 @@ jeedom.log.autoUpdateDelta = function(_params) { } // Disable auto update if log is scrolled - if (_params.callNumber > 1 && (_params.display.scrollTop + _params.display.offsetHeight + 10) < _params.display.scrollHeight) { + if ( + _params.callNumber > 1 + && (_params.display.scrollTop + _params.display.offsetHeight + 10) < _params.display.scrollHeight + ) { if (_params.control.getAttribute('data-state') == 1) { _params.control.click() } return } - var dom_brutlogcheck = document.getElementById('brutlogcheck') + let dom_brutlogcheck = document.getElementById('brutlogcheck') // If element does NOT exists OR is disabled, Then colored - var colorMe = dom_brutlogcheck == null || !dom_brutlogcheck.checked + let colorMe = dom_brutlogcheck == null || !dom_brutlogcheck.checked jeedom.log.getDelta({ log: _params.log, slaveId: _params.slaveId, position: _params.position, search: (!isset(_params.search)) ? '' : _params.search.value.toLowerCase(), - colored: (colorMe ? ((_params.display.id == 'pre_scenariolog') ? 2 : 1) : 0), // 0: no color ; 1: global log colors ; 2: Scenario colors - numbered: (_params.display.id == 'pre_globallog'), + colored: (colorMe ? 1 : 0), + numbered: (_params.display.id == 'pre_globallog' ? 1 : 0), numberStart: _params.lineNum, global: (_params.callNumber == 1), success: function(result) { - // Optimise search operation - var searchString = (!isset(_params.search)) ? '' : _params.search.value.toLowerCase() + // Reset display if start at position 0 (log file has been truncated/altered) + if (result.position == 0) { + _params.display.empty() + } // Store log file current position _params.position = result.position; // Store log file current line @@ -470,7 +489,8 @@ jeedom.log.autoUpdateDelta = function(_params) { }); } -//Standard log replacement: +// Standard log replacement: +// DEPRECATED: jeedom.log.colorReplacement -> remove in 4.6? jeedom.log.colorReplacement = { 'WARNING:': '--startTg--span class="warning"--endTg--WARNING--startTg--/span--endTg--:', 'Erreur': '--startTg--span class="danger"--endTg--Erreur--startTg--/span--endTg--', @@ -481,7 +501,10 @@ jeedom.log.colorReplacement = { '[ALERT]': '--startTg--span class="label label-xs label-warning"--endTg--ALERT--startTg--/span--endTg--', '[ERROR]': '--startTg--span class="label label-xs label-danger"--endTg--ERROR--startTg--/span--endTg--', } + +// DEPRECATED: jeedom.log.stringColorReplace -> remove in 4.6? jeedom.log.stringColorReplace = function(_str) { + jeedomUtils.deprecatedFunc('jeedom.log.stringColorReplace', 'none', '4.6', '4.4') for (var re in jeedom.log.colorReplacement) { _str = _str.split(re).join(jeedom.log.colorReplacement[re]) } @@ -492,31 +515,37 @@ jeedom.log.stringColorReplace = function(_str) { return _str } -//scenario log replacement: +// Scenario log replacement: +// DEPRECATED: jeedom.log.colorScReplacement -> remove in 4.6? jeedom.log.colorScReplacement = null -jeedom.log.getScTranslations({ - global: false, - success: function(result) { - jeedom.log.colorScReplacement = JSON.parse(result) - jeedom.log.colorScReplacement[' Start : '] = { - 'txt': ' Start : ', - 'replace': ' -- Start : ' - } - jeedom.log.colorScReplacement['Log :'] = { - 'txt': 'Log :', - 'replace': '   Log :' - } - }, - error: function() { - console.log('Unable to get jeedom scenario translations') - } -}) +// DEPRECATED: jeedom.log.scenarioColorReplace -> remove in 4.6? jeedom.log.scenarioColorReplace = function(_str) { + jeedomUtils.deprecatedFunc('jeedom.log.scenarioColorReplace', 'none', '4.6', '4.4') + if (jeedom.log.colorScReplacement == null) { + // Only load translations if we are going to use them + jeedom.log.getScTranslations({ + global: false, + success: function(result) { + jeedom.log.colorScReplacement = JSON.parse(result) + jeedom.log.colorScReplacement[' Start : '] = { + 'txt': ' Start : ', + 'replace': ' -- Start : ' + } + jeedom.log.colorScReplacement['Log :'] = { + 'txt': 'Log :', + 'replace': '   Log :' + } + }, + error: function() { + console.log('Unable to get jeedom scenario translations') + } + }) + + } if (jeedom.log.colorScReplacement == null) return _str for (var item in jeedom.log.colorScReplacement) { _str = _str.split(jeedom.log.colorScReplacement[item]['txt']).join(jeedom.log.colorScReplacement[item]['replace'].replace('::', jeedom.log.colorScReplacement[item]['txt'])) } return _str } - diff --git a/core/php/jeeScenario.php b/core/php/jeeScenario.php index f1ea96ad3c..9e44937502 100644 --- a/core/php/jeeScenario.php +++ b/core/php/jeeScenario.php @@ -28,7 +28,7 @@ } else { try { $scenario = scenario::byId(init('scenario_id')); - }catch (Error $e) { + } catch (Error $e) { log::add('scenario', 'error', __('Scenario :', __FILE__) . ' ' . init('scenario_id') . '. ' . __('Erreur :', __FILE__) . ' ' . $e->getMessage()); cache::set('scenarioCacheAttr' . init('scenario_id'), utils::setJsonAttr(cache::byKey('scenarioCacheAttr' . init('scenario_id'))->getValue(), 'state', 'error')); die(); diff --git a/desktop/css/bootstrap.css b/desktop/css/bootstrap.css index 1d17a78544..a223fe1eb4 100644 --- a/desktop/css/bootstrap.css +++ b/desktop/css/bootstrap.css @@ -4429,4 +4429,3 @@ button.close { transform: translate3d(0,0,0); } } - diff --git a/desktop/css/desktop.main.css b/desktop/css/desktop.main.css index 3914a6b9e5..9900e10c44 100644 --- a/desktop/css/desktop.main.css +++ b/desktop/css/desktop.main.css @@ -4695,11 +4695,18 @@ div.eqLogic-widget.editingMode .panelLink { width: 100%; margin-top: 5px; } + #pre_globallog mark, + #pre_scenariolog mark, + #pre_eventlog mark { + color: #000; + background-color: #ff0; + display: inline-flex; + padding: 0em; + } #pre_globallog span, #pre_eventlog span { height: 12px; min-width: 60px; - padding: 0px 4px; margin-bottom: -1px !important; line-height: 10px; } diff --git a/desktop/js/backup.js b/desktop/js/backup.js index ecb414768b..1ec4ad5b4b 100644 --- a/desktop/js/backup.js +++ b/desktop/js/backup.js @@ -74,6 +74,7 @@ if (!jeeFrontEnd.backup) { type: 'POST', url: 'core/ajax/log.ajax.php', data: { + // Warning get is slow, prefer getDelta in ajax or use jeedom.log.autoUpdateDelta js class action: 'get', log: _log, }, diff --git a/desktop/js/update.js b/desktop/js/update.js index 56a44c92b1..602406de9a 100644 --- a/desktop/js/update.js +++ b/desktop/js/update.js @@ -54,6 +54,7 @@ if (!jeeFrontEnd.update) { type: 'POST', url: 'core/ajax/log.ajax.php', data: { + // Warning get is slow, prefer getDelta in ajax or use jeedom.log.autoUpdateDelta js class action: 'get', log: _log, }, diff --git a/desktop/modal/log.display.php b/desktop/modal/log.display.php index 1b37b01656..42341448dd 100644 --- a/desktop/modal/log.display.php +++ b/desktop/modal/log.display.php @@ -70,7 +70,7 @@ }) document.getElementById('bt_resetLogSearch').addEventListener('click', function (event) { - document.getElementById('in_eventLogSearch').jeeValue('') + document.getElementById('in_eventLogSearch').jeeValue('').triggerEvent('keyup') }) document.getElementById("bt_logdisplayclearLog").addEventListener('click', function(event) { @@ -93,4 +93,4 @@ window.open('core/php/downloadFile.php?pathfile=log/' + jeephp2js.md_logDislay_Name, "_blank", null) }) })() - \ No newline at end of file + diff --git a/desktop/modal/scenario.log.execution.php b/desktop/modal/scenario.log.execution.php index fd5e846850..0489230a23 100644 --- a/desktop/modal/scenario.log.execution.php +++ b/desktop/modal/scenario.log.execution.php @@ -59,9 +59,9 @@ var jeeM = jeeFrontEnd.md_scenarioLog jeeM.init() - //Manage events outside parents delegations: + // Manage events outside parents delegations: document.getElementById('bt_resetScenarioLogSearch').addEventListener('click', function(event) { - document.getElementById('in_scenarioLogSearch').value = '' + document.getElementById('in_scenarioLogSearch').jeeValue('').triggerEvent('keyup') }) document.getElementById('bt_scenarioLogEmpty').addEventListener('click', function(event) {