@@ -11,109 +11,109 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | function inc_log_dist($message, $logname = null, $logdir = null, $logsuf = null) { |
| 18 | - static $test_repertoire = []; |
|
| 19 | - static $compteur = []; |
|
| 20 | - static $debugverb = ''; // pour ne pas le recalculer au reappel |
|
| 21 | - |
|
| 22 | - if (is_null($logname) or !is_string($logname)) { |
|
| 23 | - $logname = defined('_FILE_LOG') ? _FILE_LOG : 'spip'; |
|
| 24 | - } |
|
| 25 | - if (!isset($compteur[$logname])) { |
|
| 26 | - $compteur[$logname] = 0; |
|
| 27 | - } |
|
| 28 | - if ( |
|
| 29 | - $logname != 'maj' |
|
| 30 | - and defined('_MAX_LOG') |
|
| 31 | - and ( |
|
| 32 | - $compteur[$logname]++ > _MAX_LOG |
|
| 33 | - or !$GLOBALS['nombre_de_logs'] |
|
| 34 | - or !$GLOBALS['taille_des_logs'] |
|
| 35 | - ) |
|
| 36 | - ) { |
|
| 37 | - return; |
|
| 38 | - } |
|
| 39 | - |
|
| 40 | - // si spip_log() est appelé dans mes_options, toutes les constantes n'ont pas été définies |
|
| 41 | - $logfile = |
|
| 42 | - ($logdir ?? (defined('_DIR_LOG') ? _DIR_LOG : _DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES)) |
|
| 43 | - .$logname |
|
| 44 | - .($logsuf ?? (defined ('_FILE_LOG_SUFFIX') ? _FILE_LOG_SUFFIX : '.log')); |
|
| 45 | - |
|
| 46 | - if (!isset($test_repertoire[$d = dirname($logfile)])) { |
|
| 47 | - $test_repertoire[$d] = false; // eviter une recursivite en cas d'erreur de sous_repertoire |
|
| 48 | - $test_repertoire[$d] = (@is_dir($d) ? true : (function_exists('sous_repertoire') ? sous_repertoire( |
|
| 49 | - $d, |
|
| 50 | - '', |
|
| 51 | - false, |
|
| 52 | - true |
|
| 53 | - ) : false)); |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - // Si le repertoire défini n'existe pas, poser dans tmp/ |
|
| 57 | - if (!$test_repertoire[$d]) { |
|
| 58 | - $logfile = _DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES . $logname . '.log'; |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - $rotate = 0; |
|
| 62 | - $pid = '(pid ' . @getmypid() . ')'; |
|
| 63 | - |
|
| 64 | - // accepter spip_log( Array ) |
|
| 65 | - if (!is_string($message)) { |
|
| 66 | - $message = var_export($message, true); |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - if (!$debugverb and defined('_LOG_FILELINE') and _LOG_FILELINE) { |
|
| 70 | - $debug = debug_backtrace(); |
|
| 71 | - $l = $debug[1]['line']; |
|
| 72 | - $fi = $debug[1]['file']; |
|
| 73 | - if (strncmp($fi, _ROOT_RACINE, strlen(_ROOT_RACINE)) == 0) { |
|
| 74 | - $fi = substr($fi, strlen(_ROOT_RACINE)); |
|
| 75 | - } |
|
| 76 | - $fu = $debug[2]['function'] ?? ''; |
|
| 77 | - $debugverb = "$fi:L$l:$fu" . '():'; |
|
| 78 | - } |
|
| 79 | - |
|
| 80 | - $m = date('Y-m-d H:i:s') . ' ' . ($GLOBALS['ip'] ?? '') . ' ' . $pid . ' ' |
|
| 81 | - //distinguer les logs prives et publics dans les grep |
|
| 82 | - . $debugverb |
|
| 83 | - . (test_espace_prive() ? ':Pri:' : ':Pub:') |
|
| 84 | - . preg_replace("/\n*$/", "\n", $message); |
|
| 85 | - |
|
| 86 | - |
|
| 87 | - if ( |
|
| 88 | - @is_readable($logfile) |
|
| 89 | - and (!$s = @filesize($logfile) or $s > $GLOBALS['taille_des_logs'] * 1024) |
|
| 90 | - ) { |
|
| 91 | - $rotate = $GLOBALS['nombre_de_logs']; |
|
| 92 | - $m .= "[-- rotate --]\n"; |
|
| 93 | - } |
|
| 94 | - |
|
| 95 | - $f = @fopen($logfile, 'ab'); |
|
| 96 | - if ($f) { |
|
| 97 | - fputs($f, (defined('_LOG_BRUT') and _LOG_BRUT) ? $m : str_replace('<', '<', $m)); |
|
| 98 | - fclose($f); |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - if ( |
|
| 102 | - $rotate-- > 0 |
|
| 103 | - and function_exists('spip_unlink') |
|
| 104 | - ) { |
|
| 105 | - spip_unlink($logfile . '.' . $rotate); |
|
| 106 | - while ($rotate--) { |
|
| 107 | - @rename($logfile . ($rotate ? '.' . $rotate : ''), $logfile . '.' . ($rotate + 1)); |
|
| 108 | - } |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - // Dupliquer les erreurs specifiques dans le log general |
|
| 112 | - if ( |
|
| 113 | - defined('_FILE_LOG') |
|
| 114 | - and ($logname !== _FILE_LOG) |
|
| 115 | - ) { |
|
| 116 | - inc_log_dist($logname == 'maj' ? 'cf maj.log' : $message); |
|
| 117 | - } |
|
| 118 | - $debugverb = ''; |
|
| 18 | + static $test_repertoire = []; |
|
| 19 | + static $compteur = []; |
|
| 20 | + static $debugverb = ''; // pour ne pas le recalculer au reappel |
|
| 21 | + |
|
| 22 | + if (is_null($logname) or !is_string($logname)) { |
|
| 23 | + $logname = defined('_FILE_LOG') ? _FILE_LOG : 'spip'; |
|
| 24 | + } |
|
| 25 | + if (!isset($compteur[$logname])) { |
|
| 26 | + $compteur[$logname] = 0; |
|
| 27 | + } |
|
| 28 | + if ( |
|
| 29 | + $logname != 'maj' |
|
| 30 | + and defined('_MAX_LOG') |
|
| 31 | + and ( |
|
| 32 | + $compteur[$logname]++ > _MAX_LOG |
|
| 33 | + or !$GLOBALS['nombre_de_logs'] |
|
| 34 | + or !$GLOBALS['taille_des_logs'] |
|
| 35 | + ) |
|
| 36 | + ) { |
|
| 37 | + return; |
|
| 38 | + } |
|
| 39 | + |
|
| 40 | + // si spip_log() est appelé dans mes_options, toutes les constantes n'ont pas été définies |
|
| 41 | + $logfile = |
|
| 42 | + ($logdir ?? (defined('_DIR_LOG') ? _DIR_LOG : _DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES)) |
|
| 43 | + .$logname |
|
| 44 | + .($logsuf ?? (defined ('_FILE_LOG_SUFFIX') ? _FILE_LOG_SUFFIX : '.log')); |
|
| 45 | + |
|
| 46 | + if (!isset($test_repertoire[$d = dirname($logfile)])) { |
|
| 47 | + $test_repertoire[$d] = false; // eviter une recursivite en cas d'erreur de sous_repertoire |
|
| 48 | + $test_repertoire[$d] = (@is_dir($d) ? true : (function_exists('sous_repertoire') ? sous_repertoire( |
|
| 49 | + $d, |
|
| 50 | + '', |
|
| 51 | + false, |
|
| 52 | + true |
|
| 53 | + ) : false)); |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + // Si le repertoire défini n'existe pas, poser dans tmp/ |
|
| 57 | + if (!$test_repertoire[$d]) { |
|
| 58 | + $logfile = _DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES . $logname . '.log'; |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + $rotate = 0; |
|
| 62 | + $pid = '(pid ' . @getmypid() . ')'; |
|
| 63 | + |
|
| 64 | + // accepter spip_log( Array ) |
|
| 65 | + if (!is_string($message)) { |
|
| 66 | + $message = var_export($message, true); |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + if (!$debugverb and defined('_LOG_FILELINE') and _LOG_FILELINE) { |
|
| 70 | + $debug = debug_backtrace(); |
|
| 71 | + $l = $debug[1]['line']; |
|
| 72 | + $fi = $debug[1]['file']; |
|
| 73 | + if (strncmp($fi, _ROOT_RACINE, strlen(_ROOT_RACINE)) == 0) { |
|
| 74 | + $fi = substr($fi, strlen(_ROOT_RACINE)); |
|
| 75 | + } |
|
| 76 | + $fu = $debug[2]['function'] ?? ''; |
|
| 77 | + $debugverb = "$fi:L$l:$fu" . '():'; |
|
| 78 | + } |
|
| 79 | + |
|
| 80 | + $m = date('Y-m-d H:i:s') . ' ' . ($GLOBALS['ip'] ?? '') . ' ' . $pid . ' ' |
|
| 81 | + //distinguer les logs prives et publics dans les grep |
|
| 82 | + . $debugverb |
|
| 83 | + . (test_espace_prive() ? ':Pri:' : ':Pub:') |
|
| 84 | + . preg_replace("/\n*$/", "\n", $message); |
|
| 85 | + |
|
| 86 | + |
|
| 87 | + if ( |
|
| 88 | + @is_readable($logfile) |
|
| 89 | + and (!$s = @filesize($logfile) or $s > $GLOBALS['taille_des_logs'] * 1024) |
|
| 90 | + ) { |
|
| 91 | + $rotate = $GLOBALS['nombre_de_logs']; |
|
| 92 | + $m .= "[-- rotate --]\n"; |
|
| 93 | + } |
|
| 94 | + |
|
| 95 | + $f = @fopen($logfile, 'ab'); |
|
| 96 | + if ($f) { |
|
| 97 | + fputs($f, (defined('_LOG_BRUT') and _LOG_BRUT) ? $m : str_replace('<', '<', $m)); |
|
| 98 | + fclose($f); |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + if ( |
|
| 102 | + $rotate-- > 0 |
|
| 103 | + and function_exists('spip_unlink') |
|
| 104 | + ) { |
|
| 105 | + spip_unlink($logfile . '.' . $rotate); |
|
| 106 | + while ($rotate--) { |
|
| 107 | + @rename($logfile . ($rotate ? '.' . $rotate : ''), $logfile . '.' . ($rotate + 1)); |
|
| 108 | + } |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + // Dupliquer les erreurs specifiques dans le log general |
|
| 112 | + if ( |
|
| 113 | + defined('_FILE_LOG') |
|
| 114 | + and ($logname !== _FILE_LOG) |
|
| 115 | + ) { |
|
| 116 | + inc_log_dist($logname == 'maj' ? 'cf maj.log' : $message); |
|
| 117 | + } |
|
| 118 | + $debugverb = ''; |
|
| 119 | 119 | } |
@@ -39,9 +39,9 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | // si spip_log() est appelé dans mes_options, toutes les constantes n'ont pas été définies |
| 41 | 41 | $logfile = |
| 42 | - ($logdir ?? (defined('_DIR_LOG') ? _DIR_LOG : _DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES)) |
|
| 42 | + ($logdir ?? (defined('_DIR_LOG') ? _DIR_LOG : _DIR_RACINE._NOM_TEMPORAIRES_INACCESSIBLES)) |
|
| 43 | 43 | .$logname |
| 44 | - .($logsuf ?? (defined ('_FILE_LOG_SUFFIX') ? _FILE_LOG_SUFFIX : '.log')); |
|
| 44 | + .($logsuf ?? (defined('_FILE_LOG_SUFFIX') ? _FILE_LOG_SUFFIX : '.log')); |
|
| 45 | 45 | |
| 46 | 46 | if (!isset($test_repertoire[$d = dirname($logfile)])) { |
| 47 | 47 | $test_repertoire[$d] = false; // eviter une recursivite en cas d'erreur de sous_repertoire |
@@ -55,11 +55,11 @@ discard block |
||
| 55 | 55 | |
| 56 | 56 | // Si le repertoire défini n'existe pas, poser dans tmp/ |
| 57 | 57 | if (!$test_repertoire[$d]) { |
| 58 | - $logfile = _DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES . $logname . '.log'; |
|
| 58 | + $logfile = _DIR_RACINE._NOM_TEMPORAIRES_INACCESSIBLES.$logname.'.log'; |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | $rotate = 0; |
| 62 | - $pid = '(pid ' . @getmypid() . ')'; |
|
| 62 | + $pid = '(pid '.@getmypid().')'; |
|
| 63 | 63 | |
| 64 | 64 | // accepter spip_log( Array ) |
| 65 | 65 | if (!is_string($message)) { |
@@ -74,10 +74,10 @@ discard block |
||
| 74 | 74 | $fi = substr($fi, strlen(_ROOT_RACINE)); |
| 75 | 75 | } |
| 76 | 76 | $fu = $debug[2]['function'] ?? ''; |
| 77 | - $debugverb = "$fi:L$l:$fu" . '():'; |
|
| 77 | + $debugverb = "$fi:L$l:$fu".'():'; |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - $m = date('Y-m-d H:i:s') . ' ' . ($GLOBALS['ip'] ?? '') . ' ' . $pid . ' ' |
|
| 80 | + $m = date('Y-m-d H:i:s').' '.($GLOBALS['ip'] ?? '').' '.$pid.' ' |
|
| 81 | 81 | //distinguer les logs prives et publics dans les grep |
| 82 | 82 | . $debugverb |
| 83 | 83 | . (test_espace_prive() ? ':Pri:' : ':Pub:') |
@@ -102,9 +102,9 @@ discard block |
||
| 102 | 102 | $rotate-- > 0 |
| 103 | 103 | and function_exists('spip_unlink') |
| 104 | 104 | ) { |
| 105 | - spip_unlink($logfile . '.' . $rotate); |
|
| 105 | + spip_unlink($logfile.'.'.$rotate); |
|
| 106 | 106 | while ($rotate--) { |
| 107 | - @rename($logfile . ($rotate ? '.' . $rotate : ''), $logfile . '.' . ($rotate + 1)); |
|
| 107 | + @rename($logfile.($rotate ? '.'.$rotate : ''), $logfile.'.'.($rotate + 1)); |
|
| 108 | 108 | } |
| 109 | 109 | } |
| 110 | 110 | |