@@ -341,8 +341,7 @@ |
||
| 341 | 341 | ) { |
| 342 | 342 | if ($use_copy) { |
| 343 | 343 | @copy($fichier_tmp, $fichier); |
| 344 | - } |
|
| 345 | - else { |
|
| 344 | + } else { |
|
| 346 | 345 | @rename($fichier_tmp, $fichier); |
| 347 | 346 | } |
| 348 | 347 | // eviter que PHP ne reserve le vieux timestamp |
@@ -16,12 +16,12 @@ discard block |
||
| 16 | 16 | **/ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | if (!defined('_TEST_FILE_EXISTS')) { |
| 23 | - /** Permettre d'éviter des tests file_exists sur certains hébergeurs */ |
|
| 24 | - define('_TEST_FILE_EXISTS', preg_match(',(online|free)[.]fr$,', $_ENV['HTTP_HOST'] ?? '')); |
|
| 23 | + /** Permettre d'éviter des tests file_exists sur certains hébergeurs */ |
|
| 24 | + define('_TEST_FILE_EXISTS', preg_match(',(online|free)[.]fr$,', $_ENV['HTTP_HOST'] ?? '')); |
|
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | #define('_SPIP_LOCK_MODE',0); // ne pas utiliser de lock (deconseille) |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | #define('_SPIP_LOCK_MODE',2); // utiliser le nfslock de spip |
| 30 | 30 | |
| 31 | 31 | if (_SPIP_LOCK_MODE == 2) { |
| 32 | - include_spip('inc/nfslock'); |
|
| 32 | + include_spip('inc/nfslock'); |
|
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | $GLOBALS['liste_verrous'] = []; |
@@ -52,24 +52,24 @@ discard block |
||
| 52 | 52 | * Ressource sur le fichier ouvert, sinon false. |
| 53 | 53 | **/ |
| 54 | 54 | function spip_fopen_lock($fichier, $mode, $verrou) { |
| 55 | - if (_SPIP_LOCK_MODE == 1) { |
|
| 56 | - if ($fl = @fopen($fichier, $mode)) { |
|
| 57 | - // verrou |
|
| 58 | - @flock($fl, $verrou); |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - return $fl; |
|
| 62 | - } elseif (_SPIP_LOCK_MODE == 2) { |
|
| 63 | - if (($verrou = spip_nfslock($fichier)) && ($fl = @fopen($fichier, $mode))) { |
|
| 64 | - $GLOBALS['liste_verrous'][$fl] = [$fichier, $verrou]; |
|
| 65 | - |
|
| 66 | - return $fl; |
|
| 67 | - } else { |
|
| 68 | - return false; |
|
| 69 | - } |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - return @fopen($fichier, $mode); |
|
| 55 | + if (_SPIP_LOCK_MODE == 1) { |
|
| 56 | + if ($fl = @fopen($fichier, $mode)) { |
|
| 57 | + // verrou |
|
| 58 | + @flock($fl, $verrou); |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + return $fl; |
|
| 62 | + } elseif (_SPIP_LOCK_MODE == 2) { |
|
| 63 | + if (($verrou = spip_nfslock($fichier)) && ($fl = @fopen($fichier, $mode))) { |
|
| 64 | + $GLOBALS['liste_verrous'][$fl] = [$fichier, $verrou]; |
|
| 65 | + |
|
| 66 | + return $fl; |
|
| 67 | + } else { |
|
| 68 | + return false; |
|
| 69 | + } |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + return @fopen($fichier, $mode); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | /** |
@@ -84,14 +84,14 @@ discard block |
||
| 84 | 84 | * true si succès, false sinon. |
| 85 | 85 | **/ |
| 86 | 86 | function spip_fclose_unlock($handle) { |
| 87 | - if (_SPIP_LOCK_MODE == 1) { |
|
| 88 | - @flock($handle, LOCK_UN); |
|
| 89 | - } elseif (_SPIP_LOCK_MODE == 2) { |
|
| 90 | - spip_nfsunlock(reset($GLOBALS['liste_verrous'][$handle]), end($GLOBALS['liste_verrous'][$handle])); |
|
| 91 | - unset($GLOBALS['liste_verrous'][$handle]); |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - return @fclose($handle); |
|
| 87 | + if (_SPIP_LOCK_MODE == 1) { |
|
| 88 | + @flock($handle, LOCK_UN); |
|
| 89 | + } elseif (_SPIP_LOCK_MODE == 2) { |
|
| 90 | + spip_nfsunlock(reset($GLOBALS['liste_verrous'][$handle]), end($GLOBALS['liste_verrous'][$handle])); |
|
| 91 | + unset($GLOBALS['liste_verrous'][$handle]); |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + return @fclose($handle); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | |
@@ -105,23 +105,23 @@ discard block |
||
| 105 | 105 | * Contenu du fichier |
| 106 | 106 | **/ |
| 107 | 107 | function spip_file_get_contents($fichier) { |
| 108 | - if (!str_ends_with($fichier, '.gz')) { |
|
| 109 | - if (function_exists('file_get_contents')) { |
|
| 110 | - // quand on est sous windows on ne sait pas si file_get_contents marche |
|
| 111 | - // on essaye : si ca retourne du contenu alors c'est bon |
|
| 112 | - // sinon on fait un file() pour avoir le coeur net |
|
| 113 | - $contenu = @file_get_contents($fichier); |
|
| 114 | - if (!$contenu && _OS_SERVEUR == 'windows') { |
|
| 115 | - $contenu = @file($fichier); |
|
| 116 | - } |
|
| 117 | - } else { |
|
| 118 | - $contenu = @file($fichier); |
|
| 119 | - } |
|
| 120 | - } else { |
|
| 121 | - $contenu = @gzfile($fichier); |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - return is_array($contenu) ? implode('', $contenu) : (string)$contenu; |
|
| 108 | + if (!str_ends_with($fichier, '.gz')) { |
|
| 109 | + if (function_exists('file_get_contents')) { |
|
| 110 | + // quand on est sous windows on ne sait pas si file_get_contents marche |
|
| 111 | + // on essaye : si ca retourne du contenu alors c'est bon |
|
| 112 | + // sinon on fait un file() pour avoir le coeur net |
|
| 113 | + $contenu = @file_get_contents($fichier); |
|
| 114 | + if (!$contenu && _OS_SERVEUR == 'windows') { |
|
| 115 | + $contenu = @file($fichier); |
|
| 116 | + } |
|
| 117 | + } else { |
|
| 118 | + $contenu = @file($fichier); |
|
| 119 | + } |
|
| 120 | + } else { |
|
| 121 | + $contenu = @gzfile($fichier); |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + return is_array($contenu) ? implode('', $contenu) : (string)$contenu; |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | |
@@ -146,48 +146,48 @@ discard block |
||
| 146 | 146 | * true si l'opération a réussie, false sinon. |
| 147 | 147 | **/ |
| 148 | 148 | function lire_fichier($fichier, &$contenu, $options = []) { |
| 149 | - $contenu = ''; |
|
| 150 | - // inutile car si le fichier n'existe pas, le lock va renvoyer false juste apres |
|
| 151 | - // economisons donc les acces disque, sauf chez free qui rale pour un rien |
|
| 152 | - if (_TEST_FILE_EXISTS && !@file_exists($fichier)) { |
|
| 153 | - return false; |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - #spip_timer('lire_fichier'); |
|
| 157 | - |
|
| 158 | - // pas de @ sur spip_fopen_lock qui est silencieux de toute facon |
|
| 159 | - if ($fl = spip_fopen_lock($fichier, 'r', LOCK_SH)) { |
|
| 160 | - // lire le fichier avant tout |
|
| 161 | - $contenu = spip_file_get_contents($fichier); |
|
| 162 | - |
|
| 163 | - // le fichier a-t-il ete supprime par le locker ? |
|
| 164 | - // on ne verifie que si la tentative de lecture a echoue |
|
| 165 | - // pour discriminer un contenu vide d'un fichier absent |
|
| 166 | - // et eviter un acces disque |
|
| 167 | - if (!$contenu && !@file_exists($fichier)) { |
|
| 168 | - spip_fclose_unlock($fl); |
|
| 169 | - |
|
| 170 | - return false; |
|
| 171 | - } |
|
| 172 | - |
|
| 173 | - // liberer le verrou |
|
| 174 | - spip_fclose_unlock($fl); |
|
| 175 | - |
|
| 176 | - // Verifications |
|
| 177 | - $ok = true; |
|
| 178 | - if (isset($options['phpcheck']) && $options['phpcheck'] == 'oui') { |
|
| 179 | - $ok &= (preg_match(",[?]>\n?$,", $contenu)); |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - #spip_log("$fread $fichier ".spip_timer('lire_fichier')); |
|
| 183 | - if (!$ok) { |
|
| 184 | - spip_log("echec lecture $fichier"); |
|
| 185 | - } |
|
| 186 | - |
|
| 187 | - return $ok; |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - return false; |
|
| 149 | + $contenu = ''; |
|
| 150 | + // inutile car si le fichier n'existe pas, le lock va renvoyer false juste apres |
|
| 151 | + // economisons donc les acces disque, sauf chez free qui rale pour un rien |
|
| 152 | + if (_TEST_FILE_EXISTS && !@file_exists($fichier)) { |
|
| 153 | + return false; |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + #spip_timer('lire_fichier'); |
|
| 157 | + |
|
| 158 | + // pas de @ sur spip_fopen_lock qui est silencieux de toute facon |
|
| 159 | + if ($fl = spip_fopen_lock($fichier, 'r', LOCK_SH)) { |
|
| 160 | + // lire le fichier avant tout |
|
| 161 | + $contenu = spip_file_get_contents($fichier); |
|
| 162 | + |
|
| 163 | + // le fichier a-t-il ete supprime par le locker ? |
|
| 164 | + // on ne verifie que si la tentative de lecture a echoue |
|
| 165 | + // pour discriminer un contenu vide d'un fichier absent |
|
| 166 | + // et eviter un acces disque |
|
| 167 | + if (!$contenu && !@file_exists($fichier)) { |
|
| 168 | + spip_fclose_unlock($fl); |
|
| 169 | + |
|
| 170 | + return false; |
|
| 171 | + } |
|
| 172 | + |
|
| 173 | + // liberer le verrou |
|
| 174 | + spip_fclose_unlock($fl); |
|
| 175 | + |
|
| 176 | + // Verifications |
|
| 177 | + $ok = true; |
|
| 178 | + if (isset($options['phpcheck']) && $options['phpcheck'] == 'oui') { |
|
| 179 | + $ok &= (preg_match(",[?]>\n?$,", $contenu)); |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + #spip_log("$fread $fichier ".spip_timer('lire_fichier')); |
|
| 183 | + if (!$ok) { |
|
| 184 | + spip_log("echec lecture $fichier"); |
|
| 185 | + } |
|
| 186 | + |
|
| 187 | + return $ok; |
|
| 188 | + } |
|
| 189 | + |
|
| 190 | + return false; |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | |
@@ -215,92 +215,92 @@ discard block |
||
| 215 | 215 | **/ |
| 216 | 216 | function ecrire_fichier($fichier, $contenu, $ignorer_echec = false, $truncate = true) { |
| 217 | 217 | |
| 218 | - #spip_timer('ecrire_fichier'); |
|
| 219 | - |
|
| 220 | - // verrouiller le fichier destination |
|
| 221 | - if ($fp = spip_fopen_lock($fichier, 'a', LOCK_EX)) { |
|
| 222 | - // ecrire les donnees, compressees le cas echeant |
|
| 223 | - // (on ouvre un nouveau pointeur sur le fichier, ce qui a l'avantage |
|
| 224 | - // de le recreer si le locker qui nous precede l'avait supprime...) |
|
| 225 | - if (str_ends_with($fichier, '.gz')) { |
|
| 226 | - $contenu = gzencode($contenu); |
|
| 227 | - } |
|
| 228 | - // si c'est une ecriture avec troncation , on fait plutot une ecriture complete a cote suivie unlink+rename |
|
| 229 | - // pour etre sur d'avoir une operation atomique |
|
| 230 | - // y compris en NFS : http://www.ietf.org/rfc/rfc1094.txt |
|
| 231 | - // sauf sous wintruc ou ca ne marche pas |
|
| 232 | - $ok = false; |
|
| 233 | - if ($truncate && _OS_SERVEUR != 'windows') { |
|
| 234 | - if (!function_exists('creer_uniqid')) { |
|
| 235 | - include_spip('inc/acces'); |
|
| 236 | - } |
|
| 237 | - $id = creer_uniqid(); |
|
| 238 | - // on ouvre un pointeur sur un fichier temporaire en ecriture +raz |
|
| 239 | - if ($fp2 = spip_fopen_lock("$fichier.$id", 'w', LOCK_EX)) { |
|
| 240 | - $s = @fwrite($fp2, $contenu, $a = strlen($contenu)); |
|
| 241 | - $ok = ($s == $a); |
|
| 242 | - spip_fclose_unlock($fp2); |
|
| 243 | - spip_fclose_unlock($fp); |
|
| 244 | - $fp = null; |
|
| 245 | - // unlink direct et pas spip_unlink car on avait deja le verrou |
|
| 246 | - // a priori pas besoin car rename ecrase la cible |
|
| 247 | - // @unlink($fichier); |
|
| 248 | - // le rename aussitot, atomique quand on est pas sous windows |
|
| 249 | - // au pire on arrive en second en cas de concourance, et le rename echoue |
|
| 250 | - // --> on a la version de l'autre process qui doit etre identique |
|
| 251 | - @rename("$fichier.$id", $fichier); |
|
| 252 | - // precaution en cas d'echec du rename |
|
| 253 | - if (!_TEST_FILE_EXISTS || @file_exists("$fichier.$id")) { |
|
| 254 | - @unlink("$fichier.$id"); |
|
| 255 | - } |
|
| 256 | - if ($ok) { |
|
| 257 | - $ok = file_exists($fichier); |
|
| 258 | - } |
|
| 259 | - } else // echec mais penser a fermer .. |
|
| 260 | - { |
|
| 261 | - spip_fclose_unlock($fp); |
|
| 262 | - $fp = null; |
|
| 263 | - } |
|
| 264 | - } |
|
| 265 | - // sinon ou si methode precedente a echoueee |
|
| 266 | - // on se rabat sur la methode ancienne |
|
| 267 | - if (!$ok && !is_null($fp)) { |
|
| 268 | - // ici on est en ajout ou sous windows, cas desespere |
|
| 269 | - if ($truncate) { |
|
| 270 | - @ftruncate($fp, 0); |
|
| 271 | - } |
|
| 272 | - $s = @fwrite($fp, $contenu, $a = strlen($contenu)); |
|
| 273 | - |
|
| 274 | - $ok = ($s == $a); |
|
| 275 | - spip_fclose_unlock($fp); |
|
| 276 | - } |
|
| 277 | - // on tente une dernière fois file_put_contents |
|
| 278 | - if (!$ok) { |
|
| 279 | - $l = file_put_contents($fichier, $contenu, $truncate ? LOCK_EX : LOCK_EX | FILE_APPEND); |
|
| 280 | - $ok = ($l === strlen($contenu)); |
|
| 281 | - } |
|
| 282 | - |
|
| 283 | - // liberer le verrou et fermer le fichier |
|
| 284 | - @chmod($fichier, _SPIP_CHMOD & 0666); |
|
| 285 | - if ($ok) { |
|
| 286 | - if (str_contains($fichier, '.php')) { |
|
| 287 | - spip_clear_opcode_cache(realpath($fichier)); |
|
| 288 | - } |
|
| 289 | - |
|
| 290 | - return $ok; |
|
| 291 | - } |
|
| 292 | - } |
|
| 293 | - |
|
| 294 | - if (!$ignorer_echec) { |
|
| 295 | - include_spip('inc/autoriser'); |
|
| 296 | - if (autoriser('chargerftp')) { |
|
| 297 | - raler_fichier($fichier); |
|
| 298 | - } |
|
| 299 | - spip_unlink($fichier); |
|
| 300 | - } |
|
| 301 | - spip_log("Ecriture fichier $fichier impossible", _LOG_INFO_IMPORTANTE); |
|
| 302 | - |
|
| 303 | - return false; |
|
| 218 | + #spip_timer('ecrire_fichier'); |
|
| 219 | + |
|
| 220 | + // verrouiller le fichier destination |
|
| 221 | + if ($fp = spip_fopen_lock($fichier, 'a', LOCK_EX)) { |
|
| 222 | + // ecrire les donnees, compressees le cas echeant |
|
| 223 | + // (on ouvre un nouveau pointeur sur le fichier, ce qui a l'avantage |
|
| 224 | + // de le recreer si le locker qui nous precede l'avait supprime...) |
|
| 225 | + if (str_ends_with($fichier, '.gz')) { |
|
| 226 | + $contenu = gzencode($contenu); |
|
| 227 | + } |
|
| 228 | + // si c'est une ecriture avec troncation , on fait plutot une ecriture complete a cote suivie unlink+rename |
|
| 229 | + // pour etre sur d'avoir une operation atomique |
|
| 230 | + // y compris en NFS : http://www.ietf.org/rfc/rfc1094.txt |
|
| 231 | + // sauf sous wintruc ou ca ne marche pas |
|
| 232 | + $ok = false; |
|
| 233 | + if ($truncate && _OS_SERVEUR != 'windows') { |
|
| 234 | + if (!function_exists('creer_uniqid')) { |
|
| 235 | + include_spip('inc/acces'); |
|
| 236 | + } |
|
| 237 | + $id = creer_uniqid(); |
|
| 238 | + // on ouvre un pointeur sur un fichier temporaire en ecriture +raz |
|
| 239 | + if ($fp2 = spip_fopen_lock("$fichier.$id", 'w', LOCK_EX)) { |
|
| 240 | + $s = @fwrite($fp2, $contenu, $a = strlen($contenu)); |
|
| 241 | + $ok = ($s == $a); |
|
| 242 | + spip_fclose_unlock($fp2); |
|
| 243 | + spip_fclose_unlock($fp); |
|
| 244 | + $fp = null; |
|
| 245 | + // unlink direct et pas spip_unlink car on avait deja le verrou |
|
| 246 | + // a priori pas besoin car rename ecrase la cible |
|
| 247 | + // @unlink($fichier); |
|
| 248 | + // le rename aussitot, atomique quand on est pas sous windows |
|
| 249 | + // au pire on arrive en second en cas de concourance, et le rename echoue |
|
| 250 | + // --> on a la version de l'autre process qui doit etre identique |
|
| 251 | + @rename("$fichier.$id", $fichier); |
|
| 252 | + // precaution en cas d'echec du rename |
|
| 253 | + if (!_TEST_FILE_EXISTS || @file_exists("$fichier.$id")) { |
|
| 254 | + @unlink("$fichier.$id"); |
|
| 255 | + } |
|
| 256 | + if ($ok) { |
|
| 257 | + $ok = file_exists($fichier); |
|
| 258 | + } |
|
| 259 | + } else // echec mais penser a fermer .. |
|
| 260 | + { |
|
| 261 | + spip_fclose_unlock($fp); |
|
| 262 | + $fp = null; |
|
| 263 | + } |
|
| 264 | + } |
|
| 265 | + // sinon ou si methode precedente a echoueee |
|
| 266 | + // on se rabat sur la methode ancienne |
|
| 267 | + if (!$ok && !is_null($fp)) { |
|
| 268 | + // ici on est en ajout ou sous windows, cas desespere |
|
| 269 | + if ($truncate) { |
|
| 270 | + @ftruncate($fp, 0); |
|
| 271 | + } |
|
| 272 | + $s = @fwrite($fp, $contenu, $a = strlen($contenu)); |
|
| 273 | + |
|
| 274 | + $ok = ($s == $a); |
|
| 275 | + spip_fclose_unlock($fp); |
|
| 276 | + } |
|
| 277 | + // on tente une dernière fois file_put_contents |
|
| 278 | + if (!$ok) { |
|
| 279 | + $l = file_put_contents($fichier, $contenu, $truncate ? LOCK_EX : LOCK_EX | FILE_APPEND); |
|
| 280 | + $ok = ($l === strlen($contenu)); |
|
| 281 | + } |
|
| 282 | + |
|
| 283 | + // liberer le verrou et fermer le fichier |
|
| 284 | + @chmod($fichier, _SPIP_CHMOD & 0666); |
|
| 285 | + if ($ok) { |
|
| 286 | + if (str_contains($fichier, '.php')) { |
|
| 287 | + spip_clear_opcode_cache(realpath($fichier)); |
|
| 288 | + } |
|
| 289 | + |
|
| 290 | + return $ok; |
|
| 291 | + } |
|
| 292 | + } |
|
| 293 | + |
|
| 294 | + if (!$ignorer_echec) { |
|
| 295 | + include_spip('inc/autoriser'); |
|
| 296 | + if (autoriser('chargerftp')) { |
|
| 297 | + raler_fichier($fichier); |
|
| 298 | + } |
|
| 299 | + spip_unlink($fichier); |
|
| 300 | + } |
|
| 301 | + spip_log("Ecriture fichier $fichier impossible", _LOG_INFO_IMPORTANTE); |
|
| 302 | + |
|
| 303 | + return false; |
|
| 304 | 304 | } |
| 305 | 305 | |
| 306 | 306 | /** |
@@ -320,12 +320,12 @@ discard block |
||
| 320 | 320 | * Écriture avec troncation ? |
| 321 | 321 | */ |
| 322 | 322 | function ecrire_fichier_securise($fichier, $contenu, $ecrire_quand_meme = false, $truncate = true) { |
| 323 | - if (!str_ends_with($fichier, '.php')) { |
|
| 324 | - spip_log('Erreur de programmation: ' . $fichier . ' doit finir par .php'); |
|
| 325 | - } |
|
| 326 | - $contenu = '<' . "?php die ('Acces interdit'); ?" . ">\n" . $contenu; |
|
| 323 | + if (!str_ends_with($fichier, '.php')) { |
|
| 324 | + spip_log('Erreur de programmation: ' . $fichier . ' doit finir par .php'); |
|
| 325 | + } |
|
| 326 | + $contenu = '<' . "?php die ('Acces interdit'); ?" . ">\n" . $contenu; |
|
| 327 | 327 | |
| 328 | - return ecrire_fichier($fichier, $contenu, $ecrire_quand_meme, $truncate); |
|
| 328 | + return ecrire_fichier($fichier, $contenu, $ecrire_quand_meme, $truncate); |
|
| 329 | 329 | } |
| 330 | 330 | |
| 331 | 331 | |
@@ -336,25 +336,25 @@ discard block |
||
| 336 | 336 | * @return bool |
| 337 | 337 | */ |
| 338 | 338 | function ecrire_fichier_calcule_si_modifie($fichier, $contenu, $force = false, $use_copy = false) { |
| 339 | - $fichier_tmp = $fichier . '.last'; |
|
| 340 | - if (!ecrire_fichier($fichier_tmp, $contenu, true)) { |
|
| 341 | - return false; |
|
| 342 | - } |
|
| 343 | - if ( |
|
| 344 | - $force |
|
| 345 | - || !file_exists($fichier) |
|
| 346 | - || md5_file($fichier) !== md5_file($fichier_tmp) |
|
| 347 | - ) { |
|
| 348 | - if ($use_copy) { |
|
| 349 | - @copy($fichier_tmp, $fichier); |
|
| 350 | - } |
|
| 351 | - else { |
|
| 352 | - @rename($fichier_tmp, $fichier); |
|
| 353 | - } |
|
| 354 | - // eviter que PHP ne reserve le vieux timestamp |
|
| 355 | - clearstatcache(true, $fichier); |
|
| 356 | - } |
|
| 357 | - return true; |
|
| 339 | + $fichier_tmp = $fichier . '.last'; |
|
| 340 | + if (!ecrire_fichier($fichier_tmp, $contenu, true)) { |
|
| 341 | + return false; |
|
| 342 | + } |
|
| 343 | + if ( |
|
| 344 | + $force |
|
| 345 | + || !file_exists($fichier) |
|
| 346 | + || md5_file($fichier) !== md5_file($fichier_tmp) |
|
| 347 | + ) { |
|
| 348 | + if ($use_copy) { |
|
| 349 | + @copy($fichier_tmp, $fichier); |
|
| 350 | + } |
|
| 351 | + else { |
|
| 352 | + @rename($fichier_tmp, $fichier); |
|
| 353 | + } |
|
| 354 | + // eviter que PHP ne reserve le vieux timestamp |
|
| 355 | + clearstatcache(true, $fichier); |
|
| 356 | + } |
|
| 357 | + return true; |
|
| 358 | 358 | } |
| 359 | 359 | |
| 360 | 360 | |
@@ -375,12 +375,12 @@ discard block |
||
| 375 | 375 | * true si l'opération a réussie, false sinon. |
| 376 | 376 | */ |
| 377 | 377 | function lire_fichier_securise($fichier, &$contenu, $options = []) { |
| 378 | - if ($res = lire_fichier($fichier, $contenu, $options)) { |
|
| 379 | - $contenu = substr((string) $contenu, strlen('<?php die (\'Acces interdit\'); ?> |
|
| 378 | + if ($res = lire_fichier($fichier, $contenu, $options)) { |
|
| 379 | + $contenu = substr((string) $contenu, strlen('<?php die (\'Acces interdit\'); ?> |
|
| 380 | 380 | ')); |
| 381 | - } |
|
| 381 | + } |
|
| 382 | 382 | |
| 383 | - return $res; |
|
| 383 | + return $res; |
|
| 384 | 384 | } |
| 385 | 385 | |
| 386 | 386 | /** |
@@ -395,25 +395,25 @@ discard block |
||
| 395 | 395 | * Chemin du fichier |
| 396 | 396 | **/ |
| 397 | 397 | function raler_fichier($fichier) { |
| 398 | - if (!defined('_SPIP_ECRIRE_SCRIPT')) { |
|
| 399 | - spip_initialisation_suite(); |
|
| 400 | - } |
|
| 401 | - include_spip('inc/minipres'); |
|
| 402 | - $dir = dirname($fichier); |
|
| 403 | - http_response_code(401); |
|
| 404 | - echo minipres(_T('texte_inc_meta_2'), "<h4 style='color: red'>" |
|
| 405 | - . _T('texte_inc_meta_1', ['fichier' => $fichier]) |
|
| 406 | - . " <a href='" |
|
| 407 | - . generer_url_ecrire('install', "etape=chmod&test_dir=$dir") |
|
| 408 | - . "'>" |
|
| 409 | - . _T('texte_inc_meta_2') |
|
| 410 | - . '</a> ' |
|
| 411 | - . _T( |
|
| 412 | - 'texte_inc_meta_3', |
|
| 413 | - ['repertoire' => joli_repertoire($dir)] |
|
| 414 | - ) |
|
| 415 | - . "</h4>\n"); |
|
| 416 | - exit; |
|
| 398 | + if (!defined('_SPIP_ECRIRE_SCRIPT')) { |
|
| 399 | + spip_initialisation_suite(); |
|
| 400 | + } |
|
| 401 | + include_spip('inc/minipres'); |
|
| 402 | + $dir = dirname($fichier); |
|
| 403 | + http_response_code(401); |
|
| 404 | + echo minipres(_T('texte_inc_meta_2'), "<h4 style='color: red'>" |
|
| 405 | + . _T('texte_inc_meta_1', ['fichier' => $fichier]) |
|
| 406 | + . " <a href='" |
|
| 407 | + . generer_url_ecrire('install', "etape=chmod&test_dir=$dir") |
|
| 408 | + . "'>" |
|
| 409 | + . _T('texte_inc_meta_2') |
|
| 410 | + . '</a> ' |
|
| 411 | + . _T( |
|
| 412 | + 'texte_inc_meta_3', |
|
| 413 | + ['repertoire' => joli_repertoire($dir)] |
|
| 414 | + ) |
|
| 415 | + . "</h4>\n"); |
|
| 416 | + exit; |
|
| 417 | 417 | } |
| 418 | 418 | |
| 419 | 419 | |
@@ -428,14 +428,14 @@ discard block |
||
| 428 | 428 | * - true si récent, false sinon |
| 429 | 429 | */ |
| 430 | 430 | function jeune_fichier($fichier, $n) { |
| 431 | - if (!file_exists($fichier)) { |
|
| 432 | - return false; |
|
| 433 | - } |
|
| 434 | - if (!$c = @filemtime($fichier)) { |
|
| 435 | - return false; |
|
| 436 | - } |
|
| 437 | - |
|
| 438 | - return (time() - $n <= $c); |
|
| 431 | + if (!file_exists($fichier)) { |
|
| 432 | + return false; |
|
| 433 | + } |
|
| 434 | + if (!$c = @filemtime($fichier)) { |
|
| 435 | + return false; |
|
| 436 | + } |
|
| 437 | + |
|
| 438 | + return (time() - $n <= $c); |
|
| 439 | 439 | } |
| 440 | 440 | |
| 441 | 441 | /** |
@@ -450,22 +450,22 @@ discard block |
||
| 450 | 450 | * - false si on n'arrive pas poser le verrou ou si la suppression échoue |
| 451 | 451 | */ |
| 452 | 452 | function supprimer_fichier($fichier, $lock = true) { |
| 453 | - if (!@file_exists($fichier)) { |
|
| 454 | - return true; |
|
| 455 | - } |
|
| 456 | - |
|
| 457 | - if ($lock) { |
|
| 458 | - // verrouiller le fichier destination |
|
| 459 | - if (!$fp = spip_fopen_lock($fichier, 'a', LOCK_EX)) { |
|
| 460 | - return false; |
|
| 461 | - } |
|
| 462 | - |
|
| 463 | - // liberer le verrou |
|
| 464 | - spip_fclose_unlock($fp); |
|
| 465 | - } |
|
| 466 | - |
|
| 467 | - // supprimer |
|
| 468 | - return @unlink($fichier); |
|
| 453 | + if (!@file_exists($fichier)) { |
|
| 454 | + return true; |
|
| 455 | + } |
|
| 456 | + |
|
| 457 | + if ($lock) { |
|
| 458 | + // verrouiller le fichier destination |
|
| 459 | + if (!$fp = spip_fopen_lock($fichier, 'a', LOCK_EX)) { |
|
| 460 | + return false; |
|
| 461 | + } |
|
| 462 | + |
|
| 463 | + // liberer le verrou |
|
| 464 | + spip_fclose_unlock($fp); |
|
| 465 | + } |
|
| 466 | + |
|
| 467 | + // supprimer |
|
| 468 | + return @unlink($fichier); |
|
| 469 | 469 | } |
| 470 | 470 | |
| 471 | 471 | /** |
@@ -475,12 +475,12 @@ discard block |
||
| 475 | 475 | * Chemin du fichier |
| 476 | 476 | */ |
| 477 | 477 | function spip_unlink($f) { |
| 478 | - if (!is_dir($f)) { |
|
| 479 | - supprimer_fichier($f, false); |
|
| 480 | - } else { |
|
| 481 | - @unlink("$f/.ok"); |
|
| 482 | - @rmdir($f); |
|
| 483 | - } |
|
| 478 | + if (!is_dir($f)) { |
|
| 479 | + supprimer_fichier($f, false); |
|
| 480 | + } else { |
|
| 481 | + @unlink("$f/.ok"); |
|
| 482 | + @rmdir($f); |
|
| 483 | + } |
|
| 484 | 484 | } |
| 485 | 485 | |
| 486 | 486 | /** |
@@ -494,26 +494,26 @@ discard block |
||
| 494 | 494 | * The absolute path of the PHP file to invalidate. |
| 495 | 495 | */ |
| 496 | 496 | function spip_clear_opcode_cache($filepath) { |
| 497 | - clearstatcache(true, $filepath); |
|
| 498 | - |
|
| 499 | - // Zend OPcache |
|
| 500 | - if (function_exists('opcache_invalidate')) { |
|
| 501 | - $invalidate = @opcache_invalidate($filepath, true); |
|
| 502 | - // si l'invalidation a echoue lever un flag |
|
| 503 | - if (!$invalidate && !defined('_spip_attend_invalidation_opcode_cache')) { |
|
| 504 | - define('_spip_attend_invalidation_opcode_cache', true); |
|
| 505 | - } |
|
| 506 | - } elseif (!defined('_spip_attend_invalidation_opcode_cache')) { |
|
| 507 | - // n'agira que si opcache est effectivement actif (il semble qu'on a pas toujours la fonction opcache_invalidate) |
|
| 508 | - define('_spip_attend_invalidation_opcode_cache', true); |
|
| 509 | - } |
|
| 510 | - // APC. |
|
| 511 | - if (function_exists('apc_delete_file')) { |
|
| 512 | - // apc_delete_file() throws a PHP warning in case the specified file was |
|
| 513 | - // not compiled yet. |
|
| 514 | - // @see http://php.net/apc-delete-file |
|
| 515 | - @apc_delete_file($filepath); |
|
| 516 | - } |
|
| 497 | + clearstatcache(true, $filepath); |
|
| 498 | + |
|
| 499 | + // Zend OPcache |
|
| 500 | + if (function_exists('opcache_invalidate')) { |
|
| 501 | + $invalidate = @opcache_invalidate($filepath, true); |
|
| 502 | + // si l'invalidation a echoue lever un flag |
|
| 503 | + if (!$invalidate && !defined('_spip_attend_invalidation_opcode_cache')) { |
|
| 504 | + define('_spip_attend_invalidation_opcode_cache', true); |
|
| 505 | + } |
|
| 506 | + } elseif (!defined('_spip_attend_invalidation_opcode_cache')) { |
|
| 507 | + // n'agira que si opcache est effectivement actif (il semble qu'on a pas toujours la fonction opcache_invalidate) |
|
| 508 | + define('_spip_attend_invalidation_opcode_cache', true); |
|
| 509 | + } |
|
| 510 | + // APC. |
|
| 511 | + if (function_exists('apc_delete_file')) { |
|
| 512 | + // apc_delete_file() throws a PHP warning in case the specified file was |
|
| 513 | + // not compiled yet. |
|
| 514 | + // @see http://php.net/apc-delete-file |
|
| 515 | + @apc_delete_file($filepath); |
|
| 516 | + } |
|
| 517 | 517 | } |
| 518 | 518 | |
| 519 | 519 | /** |
@@ -536,25 +536,25 @@ discard block |
||
| 536 | 536 | * |
| 537 | 537 | */ |
| 538 | 538 | function spip_attend_invalidation_opcode_cache($timestamp = null) { |
| 539 | - if ( |
|
| 540 | - function_exists('opcache_get_configuration') |
|
| 541 | - && @ini_get('opcache.enable') |
|
| 542 | - && @ini_get('opcache.validate_timestamps') |
|
| 543 | - && (($duree = (int) @ini_get('opcache.revalidate_freq')) || ($duree = 2)) |
|
| 544 | - && defined('_spip_attend_invalidation_opcode_cache') // des invalidations ont echouees |
|
| 545 | - ) { |
|
| 546 | - $wait = $duree + 1; |
|
| 547 | - if ($timestamp) { |
|
| 548 | - $wait -= (time() - $timestamp); |
|
| 549 | - if ($wait < 0) { |
|
| 550 | - $wait = 0; |
|
| 551 | - } |
|
| 552 | - } |
|
| 553 | - spip_log('Probleme de configuration opcache.revalidate_freq ' . $duree . 's : on attend ' . $wait . 's', _LOG_INFO_IMPORTANTE); |
|
| 554 | - if ($wait) { |
|
| 555 | - sleep($duree + 1); |
|
| 556 | - } |
|
| 557 | - } |
|
| 539 | + if ( |
|
| 540 | + function_exists('opcache_get_configuration') |
|
| 541 | + && @ini_get('opcache.enable') |
|
| 542 | + && @ini_get('opcache.validate_timestamps') |
|
| 543 | + && (($duree = (int) @ini_get('opcache.revalidate_freq')) || ($duree = 2)) |
|
| 544 | + && defined('_spip_attend_invalidation_opcode_cache') // des invalidations ont echouees |
|
| 545 | + ) { |
|
| 546 | + $wait = $duree + 1; |
|
| 547 | + if ($timestamp) { |
|
| 548 | + $wait -= (time() - $timestamp); |
|
| 549 | + if ($wait < 0) { |
|
| 550 | + $wait = 0; |
|
| 551 | + } |
|
| 552 | + } |
|
| 553 | + spip_log('Probleme de configuration opcache.revalidate_freq ' . $duree . 's : on attend ' . $wait . 's', _LOG_INFO_IMPORTANTE); |
|
| 554 | + if ($wait) { |
|
| 555 | + sleep($duree + 1); |
|
| 556 | + } |
|
| 557 | + } |
|
| 558 | 558 | } |
| 559 | 559 | |
| 560 | 560 | |
@@ -567,26 +567,26 @@ discard block |
||
| 567 | 567 | * @return bool Suppression reussie. |
| 568 | 568 | */ |
| 569 | 569 | function supprimer_repertoire($dir) { |
| 570 | - if (!file_exists($dir)) { |
|
| 571 | - return true; |
|
| 572 | - } |
|
| 573 | - if (!is_dir($dir) || is_link($dir)) { |
|
| 574 | - return @unlink($dir); |
|
| 575 | - } |
|
| 576 | - |
|
| 577 | - foreach (scandir($dir) as $item) { |
|
| 578 | - if ($item == '.' || $item == '..') { |
|
| 579 | - continue; |
|
| 580 | - } |
|
| 581 | - if (!supprimer_repertoire($dir . '/' . $item)) { |
|
| 582 | - @chmod($dir . '/' . $item, 0777); |
|
| 583 | - if (!supprimer_repertoire($dir . '/' . $item)) { |
|
| 584 | - return false; |
|
| 585 | - } |
|
| 586 | - }; |
|
| 587 | - } |
|
| 588 | - |
|
| 589 | - return @rmdir($dir); |
|
| 570 | + if (!file_exists($dir)) { |
|
| 571 | + return true; |
|
| 572 | + } |
|
| 573 | + if (!is_dir($dir) || is_link($dir)) { |
|
| 574 | + return @unlink($dir); |
|
| 575 | + } |
|
| 576 | + |
|
| 577 | + foreach (scandir($dir) as $item) { |
|
| 578 | + if ($item == '.' || $item == '..') { |
|
| 579 | + continue; |
|
| 580 | + } |
|
| 581 | + if (!supprimer_repertoire($dir . '/' . $item)) { |
|
| 582 | + @chmod($dir . '/' . $item, 0777); |
|
| 583 | + if (!supprimer_repertoire($dir . '/' . $item)) { |
|
| 584 | + return false; |
|
| 585 | + } |
|
| 586 | + }; |
|
| 587 | + } |
|
| 588 | + |
|
| 589 | + return @rmdir($dir); |
|
| 590 | 590 | } |
| 591 | 591 | |
| 592 | 592 | |
@@ -615,57 +615,57 @@ discard block |
||
| 615 | 615 | * Chemin du répertoire créé. |
| 616 | 616 | **/ |
| 617 | 617 | function sous_repertoire($base, $subdir = '', $nobase = false, $tantpis = false) { |
| 618 | - static $dirs = []; |
|
| 619 | - |
|
| 620 | - $base = str_replace('//', '/', $base); |
|
| 621 | - |
|
| 622 | - # suppr le dernier caractere si c'est un / |
|
| 623 | - $base = rtrim($base, '/'); |
|
| 624 | - |
|
| 625 | - if (!strlen($subdir)) { |
|
| 626 | - $n = strrpos($base, '/'); |
|
| 627 | - if ($n === false) { |
|
| 628 | - return $nobase ? '' : ($base . '/'); |
|
| 629 | - } |
|
| 630 | - $subdir = substr($base, $n + 1); |
|
| 631 | - $base = substr($base, 0, $n + 1); |
|
| 632 | - } else { |
|
| 633 | - $base .= '/'; |
|
| 634 | - $subdir = str_replace('/', '', $subdir); |
|
| 635 | - } |
|
| 636 | - |
|
| 637 | - $baseaff = $nobase ? '' : $base; |
|
| 638 | - if (isset($dirs[$base . $subdir])) { |
|
| 639 | - return $baseaff . $dirs[$base . $subdir]; |
|
| 640 | - } |
|
| 641 | - |
|
| 642 | - $path = $base . $subdir; # $path = 'IMG/distant/pdf' ou 'IMG/distant_pdf' |
|
| 643 | - |
|
| 644 | - if (file_exists("$path/.ok")) { |
|
| 645 | - return $baseaff . ($dirs[$base . $subdir] = "$subdir/"); |
|
| 646 | - } |
|
| 647 | - |
|
| 648 | - @mkdir($path, _SPIP_CHMOD); |
|
| 649 | - @chmod($path, _SPIP_CHMOD); |
|
| 650 | - |
|
| 651 | - if (is_dir($path) && is_writable($path)) { |
|
| 652 | - @touch("$path/.ok"); |
|
| 653 | - spip_log("creation $base$subdir/"); |
|
| 654 | - |
|
| 655 | - return $baseaff . ($dirs[$base . $subdir] = "$subdir/"); |
|
| 656 | - } |
|
| 657 | - |
|
| 658 | - // en cas d'echec c'est peut etre tout simplement que le disque est plein : |
|
| 659 | - // l'inode du fichier dir_test existe, mais impossible d'y mettre du contenu |
|
| 660 | - spip_log("echec creation $base{$subdir}"); |
|
| 661 | - if ($tantpis) { |
|
| 662 | - return ''; |
|
| 663 | - } |
|
| 664 | - if (!_DIR_RESTREINT) { |
|
| 665 | - $base = preg_replace(',^' . _DIR_RACINE . ',', '', $base); |
|
| 666 | - } |
|
| 667 | - $base .= $subdir; |
|
| 668 | - raler_fichier($base . '/.ok'); |
|
| 618 | + static $dirs = []; |
|
| 619 | + |
|
| 620 | + $base = str_replace('//', '/', $base); |
|
| 621 | + |
|
| 622 | + # suppr le dernier caractere si c'est un / |
|
| 623 | + $base = rtrim($base, '/'); |
|
| 624 | + |
|
| 625 | + if (!strlen($subdir)) { |
|
| 626 | + $n = strrpos($base, '/'); |
|
| 627 | + if ($n === false) { |
|
| 628 | + return $nobase ? '' : ($base . '/'); |
|
| 629 | + } |
|
| 630 | + $subdir = substr($base, $n + 1); |
|
| 631 | + $base = substr($base, 0, $n + 1); |
|
| 632 | + } else { |
|
| 633 | + $base .= '/'; |
|
| 634 | + $subdir = str_replace('/', '', $subdir); |
|
| 635 | + } |
|
| 636 | + |
|
| 637 | + $baseaff = $nobase ? '' : $base; |
|
| 638 | + if (isset($dirs[$base . $subdir])) { |
|
| 639 | + return $baseaff . $dirs[$base . $subdir]; |
|
| 640 | + } |
|
| 641 | + |
|
| 642 | + $path = $base . $subdir; # $path = 'IMG/distant/pdf' ou 'IMG/distant_pdf' |
|
| 643 | + |
|
| 644 | + if (file_exists("$path/.ok")) { |
|
| 645 | + return $baseaff . ($dirs[$base . $subdir] = "$subdir/"); |
|
| 646 | + } |
|
| 647 | + |
|
| 648 | + @mkdir($path, _SPIP_CHMOD); |
|
| 649 | + @chmod($path, _SPIP_CHMOD); |
|
| 650 | + |
|
| 651 | + if (is_dir($path) && is_writable($path)) { |
|
| 652 | + @touch("$path/.ok"); |
|
| 653 | + spip_log("creation $base$subdir/"); |
|
| 654 | + |
|
| 655 | + return $baseaff . ($dirs[$base . $subdir] = "$subdir/"); |
|
| 656 | + } |
|
| 657 | + |
|
| 658 | + // en cas d'echec c'est peut etre tout simplement que le disque est plein : |
|
| 659 | + // l'inode du fichier dir_test existe, mais impossible d'y mettre du contenu |
|
| 660 | + spip_log("echec creation $base{$subdir}"); |
|
| 661 | + if ($tantpis) { |
|
| 662 | + return ''; |
|
| 663 | + } |
|
| 664 | + if (!_DIR_RESTREINT) { |
|
| 665 | + $base = preg_replace(',^' . _DIR_RACINE . ',', '', $base); |
|
| 666 | + } |
|
| 667 | + $base .= $subdir; |
|
| 668 | + raler_fichier($base . '/.ok'); |
|
| 669 | 669 | } |
| 670 | 670 | |
| 671 | 671 | |
@@ -698,56 +698,56 @@ discard block |
||
| 698 | 698 | * Chemins des fichiers trouvés. |
| 699 | 699 | **/ |
| 700 | 700 | function preg_files($dir, $pattern = -1 /* AUTO */, $maxfiles = 10000, $recurs = []) { |
| 701 | - $nbfiles = 0; |
|
| 702 | - if ($pattern == -1) { |
|
| 703 | - $pattern = ''; |
|
| 704 | - } |
|
| 705 | - $fichiers = []; |
|
| 706 | - // revenir au repertoire racine si on a recu dossier/truc |
|
| 707 | - // pour regarder dossier/truc/ ne pas oublier le / final |
|
| 708 | - $dir = preg_replace(',/[^/]*$,', '', $dir); |
|
| 709 | - if ($dir == '') { |
|
| 710 | - $dir = '.'; |
|
| 711 | - } |
|
| 712 | - |
|
| 713 | - if (@is_dir($dir) && is_readable($dir) && ($d = opendir($dir))) { |
|
| 714 | - while (($f = readdir($d)) !== false && ($nbfiles < $maxfiles)) { |
|
| 715 | - if ( |
|
| 716 | - $f[0] != '.' |
|
| 717 | - && $f != 'CVS' |
|
| 718 | - && $f != 'remove.txt' |
|
| 719 | - && is_readable($f = "$dir/$f") |
|
| 720 | - ) { |
|
| 721 | - if (is_file($f)) { |
|
| 722 | - if (!$pattern || preg_match(";$pattern;iS", $f)) { |
|
| 723 | - $fichiers[] = $f; |
|
| 724 | - $nbfiles++; |
|
| 725 | - } |
|
| 726 | - } else { |
|
| 727 | - if (is_dir($f) && is_array($recurs)) { |
|
| 728 | - $rp = @realpath($f); |
|
| 729 | - if (!is_string($rp) || !strlen($rp)) { |
|
| 730 | - $rp = $f; |
|
| 731 | - } # realpath n'est peut etre pas autorise |
|
| 732 | - if (!isset($recurs[$rp])) { |
|
| 733 | - $recurs[$rp] = true; |
|
| 734 | - $beginning = $fichiers; |
|
| 735 | - $end = preg_files( |
|
| 736 | - "$f/", |
|
| 737 | - $pattern, |
|
| 738 | - $maxfiles - $nbfiles, |
|
| 739 | - $recurs |
|
| 740 | - ); |
|
| 741 | - $fichiers = array_merge((array)$beginning, (array)$end); |
|
| 742 | - $nbfiles = count($fichiers); |
|
| 743 | - } |
|
| 744 | - } |
|
| 745 | - } |
|
| 746 | - } |
|
| 747 | - } |
|
| 748 | - closedir($d); |
|
| 749 | - } |
|
| 750 | - sort($fichiers); |
|
| 751 | - |
|
| 752 | - return $fichiers; |
|
| 701 | + $nbfiles = 0; |
|
| 702 | + if ($pattern == -1) { |
|
| 703 | + $pattern = ''; |
|
| 704 | + } |
|
| 705 | + $fichiers = []; |
|
| 706 | + // revenir au repertoire racine si on a recu dossier/truc |
|
| 707 | + // pour regarder dossier/truc/ ne pas oublier le / final |
|
| 708 | + $dir = preg_replace(',/[^/]*$,', '', $dir); |
|
| 709 | + if ($dir == '') { |
|
| 710 | + $dir = '.'; |
|
| 711 | + } |
|
| 712 | + |
|
| 713 | + if (@is_dir($dir) && is_readable($dir) && ($d = opendir($dir))) { |
|
| 714 | + while (($f = readdir($d)) !== false && ($nbfiles < $maxfiles)) { |
|
| 715 | + if ( |
|
| 716 | + $f[0] != '.' |
|
| 717 | + && $f != 'CVS' |
|
| 718 | + && $f != 'remove.txt' |
|
| 719 | + && is_readable($f = "$dir/$f") |
|
| 720 | + ) { |
|
| 721 | + if (is_file($f)) { |
|
| 722 | + if (!$pattern || preg_match(";$pattern;iS", $f)) { |
|
| 723 | + $fichiers[] = $f; |
|
| 724 | + $nbfiles++; |
|
| 725 | + } |
|
| 726 | + } else { |
|
| 727 | + if (is_dir($f) && is_array($recurs)) { |
|
| 728 | + $rp = @realpath($f); |
|
| 729 | + if (!is_string($rp) || !strlen($rp)) { |
|
| 730 | + $rp = $f; |
|
| 731 | + } # realpath n'est peut etre pas autorise |
|
| 732 | + if (!isset($recurs[$rp])) { |
|
| 733 | + $recurs[$rp] = true; |
|
| 734 | + $beginning = $fichiers; |
|
| 735 | + $end = preg_files( |
|
| 736 | + "$f/", |
|
| 737 | + $pattern, |
|
| 738 | + $maxfiles - $nbfiles, |
|
| 739 | + $recurs |
|
| 740 | + ); |
|
| 741 | + $fichiers = array_merge((array)$beginning, (array)$end); |
|
| 742 | + $nbfiles = count($fichiers); |
|
| 743 | + } |
|
| 744 | + } |
|
| 745 | + } |
|
| 746 | + } |
|
| 747 | + } |
|
| 748 | + closedir($d); |
|
| 749 | + } |
|
| 750 | + sort($fichiers); |
|
| 751 | + |
|
| 752 | + return $fichiers; |
|
| 753 | 753 | } |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | $contenu = @gzfile($fichier); |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - return is_array($contenu) ? implode('', $contenu) : (string)$contenu; |
|
| 124 | + return is_array($contenu) ? implode('', $contenu) : (string) $contenu; |
|
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | |
@@ -321,9 +321,9 @@ discard block |
||
| 321 | 321 | */ |
| 322 | 322 | function ecrire_fichier_securise($fichier, $contenu, $ecrire_quand_meme = false, $truncate = true) { |
| 323 | 323 | if (!str_ends_with($fichier, '.php')) { |
| 324 | - spip_log('Erreur de programmation: ' . $fichier . ' doit finir par .php'); |
|
| 324 | + spip_log('Erreur de programmation: '.$fichier.' doit finir par .php'); |
|
| 325 | 325 | } |
| 326 | - $contenu = '<' . "?php die ('Acces interdit'); ?" . ">\n" . $contenu; |
|
| 326 | + $contenu = '<'."?php die ('Acces interdit'); ?".">\n".$contenu; |
|
| 327 | 327 | |
| 328 | 328 | return ecrire_fichier($fichier, $contenu, $ecrire_quand_meme, $truncate); |
| 329 | 329 | } |
@@ -336,7 +336,7 @@ discard block |
||
| 336 | 336 | * @return bool |
| 337 | 337 | */ |
| 338 | 338 | function ecrire_fichier_calcule_si_modifie($fichier, $contenu, $force = false, $use_copy = false) { |
| 339 | - $fichier_tmp = $fichier . '.last'; |
|
| 339 | + $fichier_tmp = $fichier.'.last'; |
|
| 340 | 340 | if (!ecrire_fichier($fichier_tmp, $contenu, true)) { |
| 341 | 341 | return false; |
| 342 | 342 | } |
@@ -550,7 +550,7 @@ discard block |
||
| 550 | 550 | $wait = 0; |
| 551 | 551 | } |
| 552 | 552 | } |
| 553 | - spip_log('Probleme de configuration opcache.revalidate_freq ' . $duree . 's : on attend ' . $wait . 's', _LOG_INFO_IMPORTANTE); |
|
| 553 | + spip_log('Probleme de configuration opcache.revalidate_freq '.$duree.'s : on attend '.$wait.'s', _LOG_INFO_IMPORTANTE); |
|
| 554 | 554 | if ($wait) { |
| 555 | 555 | sleep($duree + 1); |
| 556 | 556 | } |
@@ -578,9 +578,9 @@ discard block |
||
| 578 | 578 | if ($item == '.' || $item == '..') { |
| 579 | 579 | continue; |
| 580 | 580 | } |
| 581 | - if (!supprimer_repertoire($dir . '/' . $item)) { |
|
| 582 | - @chmod($dir . '/' . $item, 0777); |
|
| 583 | - if (!supprimer_repertoire($dir . '/' . $item)) { |
|
| 581 | + if (!supprimer_repertoire($dir.'/'.$item)) { |
|
| 582 | + @chmod($dir.'/'.$item, 0777); |
|
| 583 | + if (!supprimer_repertoire($dir.'/'.$item)) { |
|
| 584 | 584 | return false; |
| 585 | 585 | } |
| 586 | 586 | }; |
@@ -625,7 +625,7 @@ discard block |
||
| 625 | 625 | if (!strlen($subdir)) { |
| 626 | 626 | $n = strrpos($base, '/'); |
| 627 | 627 | if ($n === false) { |
| 628 | - return $nobase ? '' : ($base . '/'); |
|
| 628 | + return $nobase ? '' : ($base.'/'); |
|
| 629 | 629 | } |
| 630 | 630 | $subdir = substr($base, $n + 1); |
| 631 | 631 | $base = substr($base, 0, $n + 1); |
@@ -635,14 +635,14 @@ discard block |
||
| 635 | 635 | } |
| 636 | 636 | |
| 637 | 637 | $baseaff = $nobase ? '' : $base; |
| 638 | - if (isset($dirs[$base . $subdir])) { |
|
| 639 | - return $baseaff . $dirs[$base . $subdir]; |
|
| 638 | + if (isset($dirs[$base.$subdir])) { |
|
| 639 | + return $baseaff.$dirs[$base.$subdir]; |
|
| 640 | 640 | } |
| 641 | 641 | |
| 642 | - $path = $base . $subdir; # $path = 'IMG/distant/pdf' ou 'IMG/distant_pdf' |
|
| 642 | + $path = $base.$subdir; # $path = 'IMG/distant/pdf' ou 'IMG/distant_pdf' |
|
| 643 | 643 | |
| 644 | 644 | if (file_exists("$path/.ok")) { |
| 645 | - return $baseaff . ($dirs[$base . $subdir] = "$subdir/"); |
|
| 645 | + return $baseaff.($dirs[$base.$subdir] = "$subdir/"); |
|
| 646 | 646 | } |
| 647 | 647 | |
| 648 | 648 | @mkdir($path, _SPIP_CHMOD); |
@@ -652,7 +652,7 @@ discard block |
||
| 652 | 652 | @touch("$path/.ok"); |
| 653 | 653 | spip_log("creation $base$subdir/"); |
| 654 | 654 | |
| 655 | - return $baseaff . ($dirs[$base . $subdir] = "$subdir/"); |
|
| 655 | + return $baseaff.($dirs[$base.$subdir] = "$subdir/"); |
|
| 656 | 656 | } |
| 657 | 657 | |
| 658 | 658 | // en cas d'echec c'est peut etre tout simplement que le disque est plein : |
@@ -662,10 +662,10 @@ discard block |
||
| 662 | 662 | return ''; |
| 663 | 663 | } |
| 664 | 664 | if (!_DIR_RESTREINT) { |
| 665 | - $base = preg_replace(',^' . _DIR_RACINE . ',', '', $base); |
|
| 665 | + $base = preg_replace(',^'._DIR_RACINE.',', '', $base); |
|
| 666 | 666 | } |
| 667 | 667 | $base .= $subdir; |
| 668 | - raler_fichier($base . '/.ok'); |
|
| 668 | + raler_fichier($base.'/.ok'); |
|
| 669 | 669 | } |
| 670 | 670 | |
| 671 | 671 | |
@@ -738,7 +738,7 @@ discard block |
||
| 738 | 738 | $maxfiles - $nbfiles, |
| 739 | 739 | $recurs |
| 740 | 740 | ); |
| 741 | - $fichiers = array_merge((array)$beginning, (array)$end); |
|
| 741 | + $fichiers = array_merge((array) $beginning, (array) $end); |
|
| 742 | 742 | $nbfiles = count($fichiers); |
| 743 | 743 | } |
| 744 | 744 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | */ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | include_spip('inc/actions'); |
@@ -36,11 +36,11 @@ discard block |
||
| 36 | 36 | * - ou tableau d'information sur le squelette. |
| 37 | 37 | */ |
| 38 | 38 | function inc_iconifier_dist($objet, $id, $script, $visible = false, $flag_modif = true) { |
| 39 | - // compat avec anciens appels |
|
| 40 | - $objet = objet_type($objet); |
|
| 39 | + // compat avec anciens appels |
|
| 40 | + $objet = objet_type($objet); |
|
| 41 | 41 | |
| 42 | - return recuperer_fond( |
|
| 43 | - 'prive/objets/editer/logo', |
|
| 44 | - ['objet' => $objet, 'id_objet' => $id, 'editable' => $flag_modif] |
|
| 45 | - ); |
|
| 42 | + return recuperer_fond( |
|
| 43 | + 'prive/objets/editer/logo', |
|
| 44 | + ['objet' => $objet, 'id_objet' => $id, 'editable' => $flag_modif] |
|
| 45 | + ); |
|
| 46 | 46 | } |
@@ -18,206 +18,206 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | |
| 20 | 20 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 21 | - return; |
|
| 21 | + return; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | $GLOBALS['codes_langues'] = [ |
| 25 | - 'aa' => 'Afar', |
|
| 26 | - 'ab' => 'Abkhazian', |
|
| 27 | - 'af' => 'Afrikaans', |
|
| 28 | - 'am' => 'Amharic', |
|
| 29 | - 'an' => 'Aragonés', |
|
| 30 | - 'ar' => 'عربي', |
|
| 31 | - 'as' => 'Assamese', |
|
| 32 | - 'ast' => 'asturianu', |
|
| 33 | - 'ay' => 'Aymara', |
|
| 34 | - 'az' => 'Azərbaycan dili', |
|
| 35 | - 'ba' => 'Bashkir', |
|
| 36 | - 'be' => 'Беларуская', |
|
| 37 | - 'ber_tam' => 'Tamazigh', |
|
| 38 | - 'ber_tam_tfng' => 'Tamazigh tifinagh', |
|
| 39 | - 'bg' => 'български', |
|
| 40 | - 'bh' => 'Bihari', |
|
| 41 | - 'bi' => 'Bislama', |
|
| 42 | - 'bm' => 'Bambara', |
|
| 43 | - 'bn' => 'Bengali; Bangla', |
|
| 44 | - 'bo' => 'Tibetan', |
|
| 45 | - 'br' => 'brezhoneg', |
|
| 46 | - 'bs' => 'bosanski', |
|
| 47 | - 'ca' => 'català', |
|
| 48 | - 'co' => 'corsu', |
|
| 49 | - 'cpf' => 'Kréol réyoné', |
|
| 50 | - 'cpf_dom' => 'Kreyòl', |
|
| 51 | - 'cpf_hat' => 'Kreyòl (Peyi Dayiti)', |
|
| 52 | - 'cs' => 'čeština', |
|
| 53 | - 'cy' => 'Cymraeg', # welsh, gallois |
|
| 54 | - 'da' => 'dansk', |
|
| 55 | - 'de' => 'Deutsch', |
|
| 56 | - 'dz' => 'Bhutani', |
|
| 57 | - 'el' => 'ελληνικά', |
|
| 58 | - 'en' => 'English', |
|
| 59 | - 'en_hx' => 'H4ck3R', |
|
| 60 | - 'en_sm' => 'Smurf', |
|
| 61 | - 'eo' => 'Esperanto', |
|
| 62 | - 'es' => 'Español', |
|
| 63 | - 'es_co' => 'Colombiano', |
|
| 64 | - 'es_mx_pop' => 'Mexicano a lo güey', |
|
| 65 | - 'et' => 'eesti', |
|
| 66 | - 'eu' => 'euskara', |
|
| 67 | - 'fa' => 'فارسى', |
|
| 68 | - 'ff' => 'Fulah', // peul |
|
| 69 | - 'fi' => 'suomi', |
|
| 70 | - 'fj' => 'Fiji', |
|
| 71 | - 'fo' => 'føroyskt', |
|
| 72 | - 'fon' => 'fongbè', |
|
| 73 | - 'fr' => 'français', |
|
| 74 | - 'fr_fem' => 'français féminin', |
|
| 75 | - 'fr_sc' => 'schtroumpf', |
|
| 76 | - 'fr_lpc' => 'langue parlée complétée', |
|
| 77 | - 'fr_lsf' => 'langue des signes française', |
|
| 78 | - 'fr_spl' => 'français simplifié', |
|
| 79 | - 'fr_tu' => 'français copain', |
|
| 80 | - 'fy' => 'Frisian', |
|
| 81 | - 'ga' => 'Irish', |
|
| 82 | - 'gd' => 'Scots Gaelic', |
|
| 83 | - 'gl' => 'galego', |
|
| 84 | - 'gn' => 'Guarani', |
|
| 85 | - 'grc' => 'Ἀρχαία Ἑλληνική', // grec ancien |
|
| 86 | - 'gu' => 'Gujarati', |
|
| 87 | - 'ha' => 'Hausa', |
|
| 88 | - 'hac' => 'ک-هۆرامی', //"Kurdish-Horami" |
|
| 89 | - 'hbo' => 'עברית־התנך', // hebreu classique ou biblique |
|
| 90 | - 'haz' => 'هزاره گی', |
|
| 91 | - 'he' => 'עברית', |
|
| 92 | - 'hi' => 'हिंदी', |
|
| 93 | - 'hr' => 'hrvatski', |
|
| 94 | - 'hu' => 'magyar', |
|
| 95 | - 'hy' => 'Հայերեն',// Arménien |
|
| 96 | - 'ia' => 'Interlingua', |
|
| 97 | - 'id' => 'Indonesia', |
|
| 98 | - 'ie' => 'Interlingue', |
|
| 99 | - 'ik' => 'Inupiak', |
|
| 100 | - 'is' => 'íslenska', |
|
| 101 | - 'it' => 'italiano', |
|
| 102 | - 'it_fem' => 'italiana', |
|
| 103 | - 'iu' => 'Inuktitut', |
|
| 104 | - 'ja' => '日本語', |
|
| 105 | - 'jv' => 'Javanese', |
|
| 106 | - 'ka' => 'ქართული', |
|
| 107 | - 'kk' => 'қазақ тілі', // Kazakh |
|
| 108 | - 'kl' => 'kalaallisut', |
|
| 109 | - 'km' => 'ភាសាខ្មែរ',// Khmer |
|
| 110 | - 'kn' => 'Kannada', |
|
| 111 | - 'ko' => '한국어', |
|
| 112 | - 'kok' => 'कोंकणी', |
|
| 113 | - 'ks' => 'Kashmiri', |
|
| 114 | - 'ku' => 'کوردی', |
|
| 115 | - 'ky' => 'Kirghiz', |
|
| 116 | - 'la' => 'lingua latina', |
|
| 117 | - 'lb' => 'Lëtzebuergesch', |
|
| 118 | - 'ln' => 'Lingala', |
|
| 119 | - 'lo' => 'ພາສາລາວ', # lao |
|
| 120 | - 'lt' => 'lietuvių', |
|
| 121 | - 'lu' => 'luba-katanga', |
|
| 122 | - 'lv' => 'latviešu', |
|
| 123 | - 'man' => 'mandingue', # a traduire en mandingue |
|
| 124 | - 'mfv' => 'manjak', # ISO-639-3 |
|
| 125 | - 'mg' => 'Malagasy', |
|
| 126 | - 'mi' => 'Maori', |
|
| 127 | - 'mk' => 'македонски јазик', |
|
| 128 | - 'ml' => 'Malayalam', |
|
| 129 | - 'mn' => 'Монгол хэл', |
|
| 130 | - 'mo' => 'Moldavian', |
|
| 131 | - 'mos' => 'Moré', |
|
| 132 | - 'mr' => 'मराठी', |
|
| 133 | - 'ms' => 'Bahasa Malaysia', |
|
| 134 | - 'mt' => 'Maltese', |
|
| 135 | - 'my' => 'Burmese', |
|
| 136 | - 'na' => 'Nauru', |
|
| 137 | - 'nap' => 'napulitano', |
|
| 138 | - 'ne' => 'Nepali', |
|
| 139 | - 'nqo' => "N'ko", // www.manden.org |
|
| 140 | - 'nl' => 'Nederlands', |
|
| 141 | - 'no' => 'norsk', |
|
| 142 | - 'nb' => 'norsk bokmål', |
|
| 143 | - 'nn' => 'norsk nynorsk', |
|
| 144 | - 'oc' => 'òc', |
|
| 145 | - 'oc_lnc' => 'òc lengadocian', |
|
| 146 | - 'oc_ni' => 'òc niçard', |
|
| 147 | - 'oc_ni_la' => 'òc niçard (larg)', |
|
| 148 | - 'oc_ni_mis' => 'òc nissart (mistralenc)', |
|
| 149 | - 'oc_prv' => 'òc provençau', |
|
| 150 | - 'oc_gsc' => 'òc gascon', |
|
| 151 | - 'oc_lms' => 'òc lemosin', |
|
| 152 | - 'oc_auv' => 'òc auvernhat', |
|
| 153 | - 'oc_va' => 'òc vivaroaupenc', |
|
| 154 | - 'om' => '(Afan) Oromo', |
|
| 155 | - 'or' => 'Oriya', |
|
| 156 | - 'pa' => 'Punjabi', |
|
| 157 | - 'pbb' => 'Nasa Yuwe', |
|
| 158 | - 'pl' => 'polski', |
|
| 159 | - 'prs' => 'دری', // ISO-639-3 Dari (Afghanistan) |
|
| 160 | - 'ps' => 'پښتو', |
|
| 161 | - 'pt' => 'Português', |
|
| 162 | - 'pt_br' => 'Português do Brasil', |
|
| 163 | - 'qu' => 'Quechua', |
|
| 164 | - 'rm' => 'Rhaeto-Romance', |
|
| 165 | - 'rn' => 'Kirundi', |
|
| 166 | - 'ro' => 'română', |
|
| 167 | - 'roa' => "ch'ti", |
|
| 168 | - 'ru' => 'русский', |
|
| 169 | - 'rw' => 'Kinyarwanda', |
|
| 170 | - 'sa' => 'संस्कृत', |
|
| 171 | - 'sc' => 'sardu', |
|
| 172 | - 'scn' => 'sicilianu', |
|
| 173 | - 'sd' => 'Sindhi', |
|
| 174 | - 'sg' => 'Sangho', |
|
| 175 | - 'sh' => 'srpskohrvastski', |
|
| 176 | - 'sh_latn' => 'srpskohrvastski', |
|
| 177 | - 'sh_cyrl' => 'Српскохрватски', |
|
| 178 | - 'si' => 'Sinhalese', |
|
| 179 | - 'sk' => 'slovenčina', // (Slovakia) |
|
| 180 | - 'sl' => 'slovenščina', // (Slovenia) |
|
| 181 | - 'sm' => 'Samoan', |
|
| 182 | - 'sn' => 'Shona', |
|
| 183 | - 'so' => 'Somali', |
|
| 184 | - 'sq' => 'shqip', |
|
| 185 | - 'sr' => 'српски', |
|
| 186 | - 'src' => 'sardu logudorésu', // sarde cf 'sc' |
|
| 187 | - 'sro' => 'sardu campidanésu', |
|
| 188 | - 'ss' => 'Siswati', |
|
| 189 | - 'st' => 'Sesotho', |
|
| 190 | - 'su' => 'Sundanese', |
|
| 191 | - 'sv' => 'svenska', |
|
| 192 | - 'sw' => 'Kiswahili', |
|
| 193 | - 'ta' => 'தமிழ்', // Tamil |
|
| 194 | - 'te' => 'Telugu', |
|
| 195 | - 'tg' => 'Tajik', |
|
| 196 | - 'th' => 'ไทย', |
|
| 197 | - 'ti' => 'Tigrinya', |
|
| 198 | - 'tk' => 'Turkmen', |
|
| 199 | - 'tl' => 'Tagalog', |
|
| 200 | - 'tn' => 'Setswana', |
|
| 201 | - 'to' => 'Tonga', |
|
| 202 | - 'tr' => 'Türkçe', |
|
| 203 | - 'ts' => 'Tsonga', |
|
| 204 | - 'tt' => 'Татар', |
|
| 205 | - 'tw' => 'Twi', |
|
| 206 | - 'ty' => 'reo mā`ohi', // tahitien |
|
| 207 | - 'ug' => 'Uighur', |
|
| 208 | - 'uk' => 'українська', |
|
| 209 | - 'ur' => 'ٱردو', |
|
| 210 | - 'uz' => "O'zbekcha", |
|
| 211 | - 'vi' => 'Tiếng Việt', |
|
| 212 | - 'vo' => 'Volapuk', |
|
| 213 | - 'wa' => 'walon', |
|
| 214 | - 'wo' => 'Wolof', |
|
| 215 | - 'xh' => 'Xhosa', |
|
| 216 | - 'yi' => 'Yiddish', |
|
| 217 | - 'yo' => 'Yoruba', |
|
| 218 | - 'za' => 'Zhuang', |
|
| 219 | - 'zh' => '中文', // chinois (ecriture simplifiee) |
|
| 220 | - 'zh_tw' => '台灣中文', // chinois taiwan (ecr. traditionnelle) |
|
| 221 | - 'zu' => 'Zulu' |
|
| 25 | + 'aa' => 'Afar', |
|
| 26 | + 'ab' => 'Abkhazian', |
|
| 27 | + 'af' => 'Afrikaans', |
|
| 28 | + 'am' => 'Amharic', |
|
| 29 | + 'an' => 'Aragonés', |
|
| 30 | + 'ar' => 'عربي', |
|
| 31 | + 'as' => 'Assamese', |
|
| 32 | + 'ast' => 'asturianu', |
|
| 33 | + 'ay' => 'Aymara', |
|
| 34 | + 'az' => 'Azərbaycan dili', |
|
| 35 | + 'ba' => 'Bashkir', |
|
| 36 | + 'be' => 'Беларуская', |
|
| 37 | + 'ber_tam' => 'Tamazigh', |
|
| 38 | + 'ber_tam_tfng' => 'Tamazigh tifinagh', |
|
| 39 | + 'bg' => 'български', |
|
| 40 | + 'bh' => 'Bihari', |
|
| 41 | + 'bi' => 'Bislama', |
|
| 42 | + 'bm' => 'Bambara', |
|
| 43 | + 'bn' => 'Bengali; Bangla', |
|
| 44 | + 'bo' => 'Tibetan', |
|
| 45 | + 'br' => 'brezhoneg', |
|
| 46 | + 'bs' => 'bosanski', |
|
| 47 | + 'ca' => 'català', |
|
| 48 | + 'co' => 'corsu', |
|
| 49 | + 'cpf' => 'Kréol réyoné', |
|
| 50 | + 'cpf_dom' => 'Kreyòl', |
|
| 51 | + 'cpf_hat' => 'Kreyòl (Peyi Dayiti)', |
|
| 52 | + 'cs' => 'čeština', |
|
| 53 | + 'cy' => 'Cymraeg', # welsh, gallois |
|
| 54 | + 'da' => 'dansk', |
|
| 55 | + 'de' => 'Deutsch', |
|
| 56 | + 'dz' => 'Bhutani', |
|
| 57 | + 'el' => 'ελληνικά', |
|
| 58 | + 'en' => 'English', |
|
| 59 | + 'en_hx' => 'H4ck3R', |
|
| 60 | + 'en_sm' => 'Smurf', |
|
| 61 | + 'eo' => 'Esperanto', |
|
| 62 | + 'es' => 'Español', |
|
| 63 | + 'es_co' => 'Colombiano', |
|
| 64 | + 'es_mx_pop' => 'Mexicano a lo güey', |
|
| 65 | + 'et' => 'eesti', |
|
| 66 | + 'eu' => 'euskara', |
|
| 67 | + 'fa' => 'فارسى', |
|
| 68 | + 'ff' => 'Fulah', // peul |
|
| 69 | + 'fi' => 'suomi', |
|
| 70 | + 'fj' => 'Fiji', |
|
| 71 | + 'fo' => 'føroyskt', |
|
| 72 | + 'fon' => 'fongbè', |
|
| 73 | + 'fr' => 'français', |
|
| 74 | + 'fr_fem' => 'français féminin', |
|
| 75 | + 'fr_sc' => 'schtroumpf', |
|
| 76 | + 'fr_lpc' => 'langue parlée complétée', |
|
| 77 | + 'fr_lsf' => 'langue des signes française', |
|
| 78 | + 'fr_spl' => 'français simplifié', |
|
| 79 | + 'fr_tu' => 'français copain', |
|
| 80 | + 'fy' => 'Frisian', |
|
| 81 | + 'ga' => 'Irish', |
|
| 82 | + 'gd' => 'Scots Gaelic', |
|
| 83 | + 'gl' => 'galego', |
|
| 84 | + 'gn' => 'Guarani', |
|
| 85 | + 'grc' => 'Ἀρχαία Ἑλληνική', // grec ancien |
|
| 86 | + 'gu' => 'Gujarati', |
|
| 87 | + 'ha' => 'Hausa', |
|
| 88 | + 'hac' => 'ک-هۆرامی', //"Kurdish-Horami" |
|
| 89 | + 'hbo' => 'עברית־התנך', // hebreu classique ou biblique |
|
| 90 | + 'haz' => 'هزاره گی', |
|
| 91 | + 'he' => 'עברית', |
|
| 92 | + 'hi' => 'हिंदी', |
|
| 93 | + 'hr' => 'hrvatski', |
|
| 94 | + 'hu' => 'magyar', |
|
| 95 | + 'hy' => 'Հայերեն',// Arménien |
|
| 96 | + 'ia' => 'Interlingua', |
|
| 97 | + 'id' => 'Indonesia', |
|
| 98 | + 'ie' => 'Interlingue', |
|
| 99 | + 'ik' => 'Inupiak', |
|
| 100 | + 'is' => 'íslenska', |
|
| 101 | + 'it' => 'italiano', |
|
| 102 | + 'it_fem' => 'italiana', |
|
| 103 | + 'iu' => 'Inuktitut', |
|
| 104 | + 'ja' => '日本語', |
|
| 105 | + 'jv' => 'Javanese', |
|
| 106 | + 'ka' => 'ქართული', |
|
| 107 | + 'kk' => 'қазақ тілі', // Kazakh |
|
| 108 | + 'kl' => 'kalaallisut', |
|
| 109 | + 'km' => 'ភាសាខ្មែរ',// Khmer |
|
| 110 | + 'kn' => 'Kannada', |
|
| 111 | + 'ko' => '한국어', |
|
| 112 | + 'kok' => 'कोंकणी', |
|
| 113 | + 'ks' => 'Kashmiri', |
|
| 114 | + 'ku' => 'کوردی', |
|
| 115 | + 'ky' => 'Kirghiz', |
|
| 116 | + 'la' => 'lingua latina', |
|
| 117 | + 'lb' => 'Lëtzebuergesch', |
|
| 118 | + 'ln' => 'Lingala', |
|
| 119 | + 'lo' => 'ພາສາລາວ', # lao |
|
| 120 | + 'lt' => 'lietuvių', |
|
| 121 | + 'lu' => 'luba-katanga', |
|
| 122 | + 'lv' => 'latviešu', |
|
| 123 | + 'man' => 'mandingue', # a traduire en mandingue |
|
| 124 | + 'mfv' => 'manjak', # ISO-639-3 |
|
| 125 | + 'mg' => 'Malagasy', |
|
| 126 | + 'mi' => 'Maori', |
|
| 127 | + 'mk' => 'македонски јазик', |
|
| 128 | + 'ml' => 'Malayalam', |
|
| 129 | + 'mn' => 'Монгол хэл', |
|
| 130 | + 'mo' => 'Moldavian', |
|
| 131 | + 'mos' => 'Moré', |
|
| 132 | + 'mr' => 'मराठी', |
|
| 133 | + 'ms' => 'Bahasa Malaysia', |
|
| 134 | + 'mt' => 'Maltese', |
|
| 135 | + 'my' => 'Burmese', |
|
| 136 | + 'na' => 'Nauru', |
|
| 137 | + 'nap' => 'napulitano', |
|
| 138 | + 'ne' => 'Nepali', |
|
| 139 | + 'nqo' => "N'ko", // www.manden.org |
|
| 140 | + 'nl' => 'Nederlands', |
|
| 141 | + 'no' => 'norsk', |
|
| 142 | + 'nb' => 'norsk bokmål', |
|
| 143 | + 'nn' => 'norsk nynorsk', |
|
| 144 | + 'oc' => 'òc', |
|
| 145 | + 'oc_lnc' => 'òc lengadocian', |
|
| 146 | + 'oc_ni' => 'òc niçard', |
|
| 147 | + 'oc_ni_la' => 'òc niçard (larg)', |
|
| 148 | + 'oc_ni_mis' => 'òc nissart (mistralenc)', |
|
| 149 | + 'oc_prv' => 'òc provençau', |
|
| 150 | + 'oc_gsc' => 'òc gascon', |
|
| 151 | + 'oc_lms' => 'òc lemosin', |
|
| 152 | + 'oc_auv' => 'òc auvernhat', |
|
| 153 | + 'oc_va' => 'òc vivaroaupenc', |
|
| 154 | + 'om' => '(Afan) Oromo', |
|
| 155 | + 'or' => 'Oriya', |
|
| 156 | + 'pa' => 'Punjabi', |
|
| 157 | + 'pbb' => 'Nasa Yuwe', |
|
| 158 | + 'pl' => 'polski', |
|
| 159 | + 'prs' => 'دری', // ISO-639-3 Dari (Afghanistan) |
|
| 160 | + 'ps' => 'پښتو', |
|
| 161 | + 'pt' => 'Português', |
|
| 162 | + 'pt_br' => 'Português do Brasil', |
|
| 163 | + 'qu' => 'Quechua', |
|
| 164 | + 'rm' => 'Rhaeto-Romance', |
|
| 165 | + 'rn' => 'Kirundi', |
|
| 166 | + 'ro' => 'română', |
|
| 167 | + 'roa' => "ch'ti", |
|
| 168 | + 'ru' => 'русский', |
|
| 169 | + 'rw' => 'Kinyarwanda', |
|
| 170 | + 'sa' => 'संस्कृत', |
|
| 171 | + 'sc' => 'sardu', |
|
| 172 | + 'scn' => 'sicilianu', |
|
| 173 | + 'sd' => 'Sindhi', |
|
| 174 | + 'sg' => 'Sangho', |
|
| 175 | + 'sh' => 'srpskohrvastski', |
|
| 176 | + 'sh_latn' => 'srpskohrvastski', |
|
| 177 | + 'sh_cyrl' => 'Српскохрватски', |
|
| 178 | + 'si' => 'Sinhalese', |
|
| 179 | + 'sk' => 'slovenčina', // (Slovakia) |
|
| 180 | + 'sl' => 'slovenščina', // (Slovenia) |
|
| 181 | + 'sm' => 'Samoan', |
|
| 182 | + 'sn' => 'Shona', |
|
| 183 | + 'so' => 'Somali', |
|
| 184 | + 'sq' => 'shqip', |
|
| 185 | + 'sr' => 'српски', |
|
| 186 | + 'src' => 'sardu logudorésu', // sarde cf 'sc' |
|
| 187 | + 'sro' => 'sardu campidanésu', |
|
| 188 | + 'ss' => 'Siswati', |
|
| 189 | + 'st' => 'Sesotho', |
|
| 190 | + 'su' => 'Sundanese', |
|
| 191 | + 'sv' => 'svenska', |
|
| 192 | + 'sw' => 'Kiswahili', |
|
| 193 | + 'ta' => 'தமிழ்', // Tamil |
|
| 194 | + 'te' => 'Telugu', |
|
| 195 | + 'tg' => 'Tajik', |
|
| 196 | + 'th' => 'ไทย', |
|
| 197 | + 'ti' => 'Tigrinya', |
|
| 198 | + 'tk' => 'Turkmen', |
|
| 199 | + 'tl' => 'Tagalog', |
|
| 200 | + 'tn' => 'Setswana', |
|
| 201 | + 'to' => 'Tonga', |
|
| 202 | + 'tr' => 'Türkçe', |
|
| 203 | + 'ts' => 'Tsonga', |
|
| 204 | + 'tt' => 'Татар', |
|
| 205 | + 'tw' => 'Twi', |
|
| 206 | + 'ty' => 'reo mā`ohi', // tahitien |
|
| 207 | + 'ug' => 'Uighur', |
|
| 208 | + 'uk' => 'українська', |
|
| 209 | + 'ur' => 'ٱردو', |
|
| 210 | + 'uz' => "O'zbekcha", |
|
| 211 | + 'vi' => 'Tiếng Việt', |
|
| 212 | + 'vo' => 'Volapuk', |
|
| 213 | + 'wa' => 'walon', |
|
| 214 | + 'wo' => 'Wolof', |
|
| 215 | + 'xh' => 'Xhosa', |
|
| 216 | + 'yi' => 'Yiddish', |
|
| 217 | + 'yo' => 'Yoruba', |
|
| 218 | + 'za' => 'Zhuang', |
|
| 219 | + 'zh' => '中文', // chinois (ecriture simplifiee) |
|
| 220 | + 'zh_tw' => '台灣中文', // chinois taiwan (ecr. traditionnelle) |
|
| 221 | + 'zu' => 'Zulu' |
|
| 222 | 222 | |
| 223 | 223 | ]; |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | 'cpf_dom' => 'Kreyòl', |
| 51 | 51 | 'cpf_hat' => 'Kreyòl (Peyi Dayiti)', |
| 52 | 52 | 'cs' => 'čeština', |
| 53 | - 'cy' => 'Cymraeg', # welsh, gallois |
|
| 53 | + 'cy' => 'Cymraeg', # welsh, gallois |
|
| 54 | 54 | 'da' => 'dansk', |
| 55 | 55 | 'de' => 'Deutsch', |
| 56 | 56 | 'dz' => 'Bhutani', |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | 'hi' => 'हिंदी', |
| 93 | 93 | 'hr' => 'hrvatski', |
| 94 | 94 | 'hu' => 'magyar', |
| 95 | - 'hy' => 'Հայերեն',// Arménien |
|
| 95 | + 'hy' => 'Հայերեն', // Arménien |
|
| 96 | 96 | 'ia' => 'Interlingua', |
| 97 | 97 | 'id' => 'Indonesia', |
| 98 | 98 | 'ie' => 'Interlingue', |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | 'ka' => 'ქართული', |
| 107 | 107 | 'kk' => 'қазақ тілі', // Kazakh |
| 108 | 108 | 'kl' => 'kalaallisut', |
| 109 | - 'km' => 'ភាសាខ្មែរ',// Khmer |
|
| 109 | + 'km' => 'ភាសាខ្មែរ', // Khmer |
|
| 110 | 110 | 'kn' => 'Kannada', |
| 111 | 111 | 'ko' => '한국어', |
| 112 | 112 | 'kok' => 'कोंकणी', |
@@ -176,8 +176,8 @@ discard block |
||
| 176 | 176 | 'sh_latn' => 'srpskohrvastski', |
| 177 | 177 | 'sh_cyrl' => 'Српскохрватски', |
| 178 | 178 | 'si' => 'Sinhalese', |
| 179 | - 'sk' => 'slovenčina', // (Slovakia) |
|
| 180 | - 'sl' => 'slovenščina', // (Slovenia) |
|
| 179 | + 'sk' => 'slovenčina', // (Slovakia) |
|
| 180 | + 'sl' => 'slovenščina', // (Slovenia) |
|
| 181 | 181 | 'sm' => 'Samoan', |
| 182 | 182 | 'sn' => 'Shona', |
| 183 | 183 | 'so' => 'Somali', |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | |
| 40 | 40 | if ($notification = charger_fonction($quoi, 'notifications', true)) { |
| 41 | 41 | spip_log("$notification($quoi,$id" |
| 42 | - . ($options ? ',' . serialize($options) : '') |
|
| 42 | + . ($options ? ','.serialize($options) : '') |
|
| 43 | 43 | . ')', 'notifications'); |
| 44 | 44 | $notification($quoi, $id, $options); |
| 45 | 45 | } |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | |
| 158 | 158 | job_queue_add( |
| 159 | 159 | 'envoyer_mail', |
| 160 | - ">$email : " . $envoi['sujet'], |
|
| 160 | + ">$email : ".$envoi['sujet'], |
|
| 161 | 161 | [$email, $envoi['sujet'], $envoi['texte'], $envoi['from'], $envoi['headers']], |
| 162 | 162 | 'inc/' |
| 163 | 163 | ); |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\Notifications |
| 17 | 17 | **/ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | |
@@ -33,16 +33,16 @@ discard block |
||
| 33 | 33 | */ |
| 34 | 34 | function inc_notifications_dist($quoi, $id = 0, $options = []) { |
| 35 | 35 | |
| 36 | - // charger les fichiers qui veulent ajouter des definitions |
|
| 37 | - // ou faire des trucs aussi dans le pipeline, ca fait deux api pour le prix d'une ... |
|
| 38 | - pipeline('notifications', ['args' => ['quoi' => $quoi, 'id' => $id, 'options' => $options]]); |
|
| 36 | + // charger les fichiers qui veulent ajouter des definitions |
|
| 37 | + // ou faire des trucs aussi dans le pipeline, ca fait deux api pour le prix d'une ... |
|
| 38 | + pipeline('notifications', ['args' => ['quoi' => $quoi, 'id' => $id, 'options' => $options]]); |
|
| 39 | 39 | |
| 40 | - if ($notification = charger_fonction($quoi, 'notifications', true)) { |
|
| 41 | - spip_log("$notification($quoi,$id" |
|
| 42 | - . ($options ? ',' . serialize($options) : '') |
|
| 43 | - . ')', 'notifications'); |
|
| 44 | - $notification($quoi, $id, $options); |
|
| 45 | - } |
|
| 40 | + if ($notification = charger_fonction($quoi, 'notifications', true)) { |
|
| 41 | + spip_log("$notification($quoi,$id" |
|
| 42 | + . ($options ? ',' . serialize($options) : '') |
|
| 43 | + . ')', 'notifications'); |
|
| 44 | + $notification($quoi, $id, $options); |
|
| 45 | + } |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | /** |
@@ -56,15 +56,15 @@ discard block |
||
| 56 | 56 | * @param array $exclure |
| 57 | 57 | */ |
| 58 | 58 | function notifications_nettoyer_emails(&$emails, $exclure = []) { |
| 59 | - // filtrer et unifier |
|
| 60 | - include_spip('inc/filtres'); |
|
| 61 | - $emails = array_unique(array_filter(array_map('email_valide', array_map('trim', $emails)))); |
|
| 62 | - if ($exclure and count($exclure)) { |
|
| 63 | - // nettoyer les exclusions d'abord |
|
| 64 | - notifications_nettoyer_emails($exclure); |
|
| 65 | - // faire un diff |
|
| 66 | - $emails = array_diff($emails, $exclure); |
|
| 67 | - } |
|
| 59 | + // filtrer et unifier |
|
| 60 | + include_spip('inc/filtres'); |
|
| 61 | + $emails = array_unique(array_filter(array_map('email_valide', array_map('trim', $emails)))); |
|
| 62 | + if ($exclure and count($exclure)) { |
|
| 63 | + // nettoyer les exclusions d'abord |
|
| 64 | + notifications_nettoyer_emails($exclure); |
|
| 65 | + // faire un diff |
|
| 66 | + $emails = array_diff($emails, $exclure); |
|
| 67 | + } |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
@@ -79,90 +79,90 @@ discard block |
||
| 79 | 79 | * @param string $headers |
| 80 | 80 | */ |
| 81 | 81 | function notifications_envoyer_mails($emails, $texte, $sujet = '', $from = '', $headers = '') { |
| 82 | - // rien a faire si pas de texte ! |
|
| 83 | - if (!strlen($texte)) { |
|
| 84 | - return; |
|
| 85 | - } |
|
| 86 | - |
|
| 87 | - // si on ne specifie qu'un email, le mettre dans un tableau |
|
| 88 | - if (!is_array($emails)) { |
|
| 89 | - $emails = explode(',', $emails); |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - notifications_nettoyer_emails($emails); |
|
| 93 | - |
|
| 94 | - // tester si le mail est deja en html |
|
| 95 | - if ( |
|
| 96 | - strpos($texte, '<') !== false // eviter les tests suivants si possible |
|
| 97 | - and $ttrim = trim($texte) |
|
| 98 | - and substr($ttrim, 0, 1) == '<' |
|
| 99 | - and substr($ttrim, -1, 1) == '>' |
|
| 100 | - and stripos($ttrim, '</html>') !== false |
|
| 101 | - ) { |
|
| 102 | - if (!strlen($sujet)) { |
|
| 103 | - // dans ce cas on ruse un peu : extraire le sujet du title |
|
| 104 | - if (preg_match(',<title>(.*)</title>,Uims', $texte, $m)) { |
|
| 105 | - $sujet = $m[1]; |
|
| 106 | - } else { |
|
| 107 | - // fallback, on prend le body si on le trouve |
|
| 108 | - if (preg_match(',<body[^>]*>(.*)</body>,Uims', $texte, $m)) { |
|
| 109 | - $ttrim = $m[1]; |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - // et on extrait la premiere ligne de vrai texte... |
|
| 113 | - // nettoyer le html et les retours chariots |
|
| 114 | - $ttrim = textebrut($ttrim); |
|
| 115 | - $ttrim = str_replace("\r\n", "\r", $ttrim); |
|
| 116 | - $ttrim = str_replace("\r", "\n", $ttrim); |
|
| 117 | - // decouper |
|
| 118 | - $ttrim = explode("\n", trim($ttrim)); |
|
| 119 | - // extraire la premiere ligne de texte brut |
|
| 120 | - $sujet = array_shift($ttrim); |
|
| 121 | - } |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - // si besoin on ajoute le content-type dans les headers |
|
| 125 | - if (stripos($headers, 'Content-Type') === false) { |
|
| 126 | - $headers .= "Content-Type: text/html\n"; |
|
| 127 | - } |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - // si le sujet est vide, extraire la premiere ligne du corps |
|
| 131 | - // du mail qui est donc du texte |
|
| 132 | - if (!strlen($sujet)) { |
|
| 133 | - // nettoyer un peu les retours chariots |
|
| 134 | - $texte = str_replace("\r\n", "\r", $texte); |
|
| 135 | - $texte = str_replace("\r", "\n", $texte); |
|
| 136 | - // decouper |
|
| 137 | - $texte = explode("\n", trim($texte)); |
|
| 138 | - // extraire la premiere ligne |
|
| 139 | - $sujet = array_shift($texte); |
|
| 140 | - $texte = trim(implode("\n", $texte)); |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - $envoyer_mail = charger_fonction('envoyer_mail', 'inc'); |
|
| 144 | - foreach ($emails as $email) { |
|
| 145 | - // passer dans un pipeline qui permet un ajout eventuel |
|
| 146 | - // (url de suivi des notifications par exemple) |
|
| 147 | - $envoi = pipeline( |
|
| 148 | - 'notifications_envoyer_mails', |
|
| 149 | - [ |
|
| 150 | - 'email' => $email, |
|
| 151 | - 'sujet' => $sujet, |
|
| 152 | - 'texte' => $texte, |
|
| 153 | - 'from' => $from, |
|
| 154 | - 'headers' => $headers, |
|
| 155 | - ] |
|
| 156 | - ); |
|
| 157 | - $email = $envoi['email']; |
|
| 158 | - |
|
| 159 | - job_queue_add( |
|
| 160 | - 'envoyer_mail', |
|
| 161 | - ">$email : " . $envoi['sujet'], |
|
| 162 | - [$email, $envoi['sujet'], $envoi['texte'], $envoi['from'], $envoi['headers']], |
|
| 163 | - 'inc/' |
|
| 164 | - ); |
|
| 165 | - } |
|
| 82 | + // rien a faire si pas de texte ! |
|
| 83 | + if (!strlen($texte)) { |
|
| 84 | + return; |
|
| 85 | + } |
|
| 86 | + |
|
| 87 | + // si on ne specifie qu'un email, le mettre dans un tableau |
|
| 88 | + if (!is_array($emails)) { |
|
| 89 | + $emails = explode(',', $emails); |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + notifications_nettoyer_emails($emails); |
|
| 93 | + |
|
| 94 | + // tester si le mail est deja en html |
|
| 95 | + if ( |
|
| 96 | + strpos($texte, '<') !== false // eviter les tests suivants si possible |
|
| 97 | + and $ttrim = trim($texte) |
|
| 98 | + and substr($ttrim, 0, 1) == '<' |
|
| 99 | + and substr($ttrim, -1, 1) == '>' |
|
| 100 | + and stripos($ttrim, '</html>') !== false |
|
| 101 | + ) { |
|
| 102 | + if (!strlen($sujet)) { |
|
| 103 | + // dans ce cas on ruse un peu : extraire le sujet du title |
|
| 104 | + if (preg_match(',<title>(.*)</title>,Uims', $texte, $m)) { |
|
| 105 | + $sujet = $m[1]; |
|
| 106 | + } else { |
|
| 107 | + // fallback, on prend le body si on le trouve |
|
| 108 | + if (preg_match(',<body[^>]*>(.*)</body>,Uims', $texte, $m)) { |
|
| 109 | + $ttrim = $m[1]; |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + // et on extrait la premiere ligne de vrai texte... |
|
| 113 | + // nettoyer le html et les retours chariots |
|
| 114 | + $ttrim = textebrut($ttrim); |
|
| 115 | + $ttrim = str_replace("\r\n", "\r", $ttrim); |
|
| 116 | + $ttrim = str_replace("\r", "\n", $ttrim); |
|
| 117 | + // decouper |
|
| 118 | + $ttrim = explode("\n", trim($ttrim)); |
|
| 119 | + // extraire la premiere ligne de texte brut |
|
| 120 | + $sujet = array_shift($ttrim); |
|
| 121 | + } |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + // si besoin on ajoute le content-type dans les headers |
|
| 125 | + if (stripos($headers, 'Content-Type') === false) { |
|
| 126 | + $headers .= "Content-Type: text/html\n"; |
|
| 127 | + } |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + // si le sujet est vide, extraire la premiere ligne du corps |
|
| 131 | + // du mail qui est donc du texte |
|
| 132 | + if (!strlen($sujet)) { |
|
| 133 | + // nettoyer un peu les retours chariots |
|
| 134 | + $texte = str_replace("\r\n", "\r", $texte); |
|
| 135 | + $texte = str_replace("\r", "\n", $texte); |
|
| 136 | + // decouper |
|
| 137 | + $texte = explode("\n", trim($texte)); |
|
| 138 | + // extraire la premiere ligne |
|
| 139 | + $sujet = array_shift($texte); |
|
| 140 | + $texte = trim(implode("\n", $texte)); |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + $envoyer_mail = charger_fonction('envoyer_mail', 'inc'); |
|
| 144 | + foreach ($emails as $email) { |
|
| 145 | + // passer dans un pipeline qui permet un ajout eventuel |
|
| 146 | + // (url de suivi des notifications par exemple) |
|
| 147 | + $envoi = pipeline( |
|
| 148 | + 'notifications_envoyer_mails', |
|
| 149 | + [ |
|
| 150 | + 'email' => $email, |
|
| 151 | + 'sujet' => $sujet, |
|
| 152 | + 'texte' => $texte, |
|
| 153 | + 'from' => $from, |
|
| 154 | + 'headers' => $headers, |
|
| 155 | + ] |
|
| 156 | + ); |
|
| 157 | + $email = $envoi['email']; |
|
| 158 | + |
|
| 159 | + job_queue_add( |
|
| 160 | + 'envoyer_mail', |
|
| 161 | + ">$email : " . $envoi['sujet'], |
|
| 162 | + [$email, $envoi['sujet'], $envoi['texte'], $envoi['from'], $envoi['headers']], |
|
| 163 | + 'inc/' |
|
| 164 | + ); |
|
| 165 | + } |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | /** |
@@ -178,10 +178,10 @@ discard block |
||
| 178 | 178 | * @return string |
| 179 | 179 | */ |
| 180 | 180 | function email_notification_objet($id_objet, $type_objet, $modele) { |
| 181 | - $envoyer_mail = charger_fonction('envoyer_mail', 'inc'); // pour nettoyer_titre_email |
|
| 182 | - $id_type = id_table_objet($type_objet); |
|
| 181 | + $envoyer_mail = charger_fonction('envoyer_mail', 'inc'); // pour nettoyer_titre_email |
|
| 182 | + $id_type = id_table_objet($type_objet); |
|
| 183 | 183 | |
| 184 | - return recuperer_fond($modele, [$id_type => $id_objet, 'id' => $id_objet]); |
|
| 184 | + return recuperer_fond($modele, [$id_type => $id_objet, 'id' => $id_objet]); |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | 187 | /** |
@@ -196,7 +196,7 @@ discard block |
||
| 196 | 196 | * @return string |
| 197 | 197 | */ |
| 198 | 198 | function email_notification_article($id_article, $modele) { |
| 199 | - $envoyer_mail = charger_fonction('envoyer_mail', 'inc'); // pour nettoyer_titre_email |
|
| 199 | + $envoyer_mail = charger_fonction('envoyer_mail', 'inc'); // pour nettoyer_titre_email |
|
| 200 | 200 | |
| 201 | - return recuperer_fond($modele, ['id_article' => $id_article]); |
|
| 201 | + return recuperer_fond($modele, ['id_article' => $id_article]); |
|
| 202 | 202 | } |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @package SPIP\Core\Mail |
| 17 | 17 | **/ |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | |
@@ -31,27 +31,27 @@ discard block |
||
| 31 | 31 | * - la normalisation de la dernière adresse donnée sinon |
| 32 | 32 | **/ |
| 33 | 33 | function inc_email_valide_dist($adresses) { |
| 34 | - // eviter d'injecter n'importe quoi dans preg_match |
|
| 35 | - if (!is_string($adresses)) { |
|
| 36 | - return false; |
|
| 37 | - } |
|
| 38 | - |
|
| 39 | - // Si c'est un spammeur autant arreter tout de suite |
|
| 40 | - if (preg_match(",[\n\r].*(MIME|multipart|Content-),i", $adresses)) { |
|
| 41 | - spip_log("Tentative d'injection de mail : $adresses"); |
|
| 42 | - |
|
| 43 | - return false; |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - foreach (explode(',', $adresses) as $v) { |
|
| 47 | - // nettoyer certains formats |
|
| 48 | - // "Marie Toto <[email protected]>" |
|
| 49 | - $adresse = trim(preg_replace(',^[^<>"]*<([^<>"]+)>$,i', "\\1", $v)); |
|
| 50 | - // RFC 822 |
|
| 51 | - if (!preg_match('#^[^()<>@,;:\\"/[:space:]]+(@([-_0-9a-z]+\.)*[-_0-9a-z]+)$#i', $adresse)) { |
|
| 52 | - return false; |
|
| 53 | - } |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - return $adresse; |
|
| 34 | + // eviter d'injecter n'importe quoi dans preg_match |
|
| 35 | + if (!is_string($adresses)) { |
|
| 36 | + return false; |
|
| 37 | + } |
|
| 38 | + |
|
| 39 | + // Si c'est un spammeur autant arreter tout de suite |
|
| 40 | + if (preg_match(",[\n\r].*(MIME|multipart|Content-),i", $adresses)) { |
|
| 41 | + spip_log("Tentative d'injection de mail : $adresses"); |
|
| 42 | + |
|
| 43 | + return false; |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + foreach (explode(',', $adresses) as $v) { |
|
| 47 | + // nettoyer certains formats |
|
| 48 | + // "Marie Toto <[email protected]>" |
|
| 49 | + $adresse = trim(preg_replace(',^[^<>"]*<([^<>"]+)>$,i', "\\1", $v)); |
|
| 50 | + // RFC 822 |
|
| 51 | + if (!preg_match('#^[^()<>@,;:\\"/[:space:]]+(@([-_0-9a-z]+\.)*[-_0-9a-z]+)$#i', $adresse)) { |
|
| 52 | + return false; |
|
| 53 | + } |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + return $adresse; |
|
| 57 | 57 | } |
@@ -86,7 +86,7 @@ |
||
| 86 | 86 | ); |
| 87 | 87 | foreach ($s as $row) { |
| 88 | 88 | if (email_valide($row['email'])) { |
| 89 | - $r .= ', ' . $row['email']; |
|
| 89 | + $r .= ', '.$row['email']; |
|
| 90 | 90 | } |
| 91 | 91 | } |
| 92 | 92 | $args[2] = substr($r, 2); |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | **/ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | include_spip('base/abstract_sql'); |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | * Pile complétée du code compilé |
| 41 | 41 | **/ |
| 42 | 42 | function balise_FORMULAIRE_ECRIRE_AUTEUR($p) { |
| 43 | - return calculer_balise_dynamique($p, 'FORMULAIRE_ECRIRE_AUTEUR', ['id_auteur', 'id_article', 'email']); |
|
| 43 | + return calculer_balise_dynamique($p, 'FORMULAIRE_ECRIRE_AUTEUR', ['id_auteur', 'id_article', 'email']); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | /** |
@@ -58,44 +58,44 @@ discard block |
||
| 58 | 58 | * - chaîne vide sinon (erreur ou non affichage). |
| 59 | 59 | */ |
| 60 | 60 | function balise_FORMULAIRE_ECRIRE_AUTEUR_stat($args, $context_compil) { |
| 61 | - include_spip('inc/filtres'); |
|
| 62 | - // Pas d'id_auteur ni d'id_article ? Erreur de contexte |
|
| 63 | - $id = (int) $args[1]; |
|
| 64 | - if (!$args[0] && !$id) { |
|
| 65 | - $msg = [ |
|
| 66 | - 'zbug_champ_hors_motif', |
|
| 67 | - [ |
|
| 68 | - 'champ' => 'FORMULAIRE_ECRIRE_AUTEUR', |
|
| 69 | - 'motif' => 'AUTEURS/ARTICLES' |
|
| 70 | - ] |
|
| 71 | - ]; |
|
| 61 | + include_spip('inc/filtres'); |
|
| 62 | + // Pas d'id_auteur ni d'id_article ? Erreur de contexte |
|
| 63 | + $id = (int) $args[1]; |
|
| 64 | + if (!$args[0] && !$id) { |
|
| 65 | + $msg = [ |
|
| 66 | + 'zbug_champ_hors_motif', |
|
| 67 | + [ |
|
| 68 | + 'champ' => 'FORMULAIRE_ECRIRE_AUTEUR', |
|
| 69 | + 'motif' => 'AUTEURS/ARTICLES' |
|
| 70 | + ] |
|
| 71 | + ]; |
|
| 72 | 72 | |
| 73 | - erreur_squelette($msg, $context_compil); |
|
| 73 | + erreur_squelette($msg, $context_compil); |
|
| 74 | 74 | |
| 75 | - return ''; |
|
| 76 | - } |
|
| 77 | - // Si on est dans un contexte article, |
|
| 78 | - // sortir tous les mails des auteurs de l'article |
|
| 79 | - if (!$args[0] && $id) { |
|
| 80 | - $r = ''; |
|
| 81 | - $s = sql_allfetsel( |
|
| 82 | - 'email', |
|
| 83 | - 'spip_auteurs AS A LEFT JOIN spip_auteurs_liens AS L ON (A.id_auteur=L.id_auteur AND L.objet=\'article\')', |
|
| 84 | - "A.email != '' AND L.id_objet=$id" |
|
| 85 | - ); |
|
| 86 | - foreach ($s as $row) { |
|
| 87 | - if (email_valide($row['email'])) { |
|
| 88 | - $r .= ', ' . $row['email']; |
|
| 89 | - } |
|
| 90 | - } |
|
| 91 | - $args[2] = substr($r, 2); |
|
| 92 | - } |
|
| 75 | + return ''; |
|
| 76 | + } |
|
| 77 | + // Si on est dans un contexte article, |
|
| 78 | + // sortir tous les mails des auteurs de l'article |
|
| 79 | + if (!$args[0] && $id) { |
|
| 80 | + $r = ''; |
|
| 81 | + $s = sql_allfetsel( |
|
| 82 | + 'email', |
|
| 83 | + 'spip_auteurs AS A LEFT JOIN spip_auteurs_liens AS L ON (A.id_auteur=L.id_auteur AND L.objet=\'article\')', |
|
| 84 | + "A.email != '' AND L.id_objet=$id" |
|
| 85 | + ); |
|
| 86 | + foreach ($s as $row) { |
|
| 87 | + if (email_valide($row['email'])) { |
|
| 88 | + $r .= ', ' . $row['email']; |
|
| 89 | + } |
|
| 90 | + } |
|
| 91 | + $args[2] = substr($r, 2); |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - // On ne peut pas ecrire a un auteur dont le mail n'est pas valide |
|
| 95 | - if (!$args[2] || !email_valide($args[2])) { |
|
| 96 | - return ''; |
|
| 97 | - } |
|
| 94 | + // On ne peut pas ecrire a un auteur dont le mail n'est pas valide |
|
| 95 | + if (!$args[2] || !email_valide($args[2])) { |
|
| 96 | + return ''; |
|
| 97 | + } |
|
| 98 | 98 | |
| 99 | - // OK |
|
| 100 | - return $args; |
|
| 99 | + // OK |
|
| 100 | + return $args; |
|
| 101 | 101 | } |
@@ -11,134 +11,134 @@ |
||
| 11 | 11 | // plage invalide en iso-8859-1 mais souvent utilisee quand meme (windows) |
| 12 | 12 | // cf. http://openweb.eu.org/articles/caracteres_illegaux/ |
| 13 | 13 | // voir aussi copie de ces valeurs dans inc/charsets.php |
| 14 | - 128 => 8364, |
|
| 15 | - 129 => 129 /* ?? */, |
|
| 16 | - 130 => 8218, |
|
| 17 | - 131 => 402, |
|
| 18 | - 132 => 8222, |
|
| 19 | - 133 => 8230, |
|
| 20 | - 134 => 8224, |
|
| 21 | - 135 => 8225, |
|
| 22 | - 136 => 710, |
|
| 23 | - 137 => 8240, |
|
| 24 | - 138 => 352, |
|
| 25 | - 139 => 8249, |
|
| 26 | - 140 => 338, |
|
| 27 | - 141 => 141 /* ?? */, |
|
| 28 | - 142 => 381, |
|
| 29 | - 143 => 143 /* ?? */, |
|
| 30 | - 144 => 144 /* ?? */, |
|
| 31 | - 145 => 8216, |
|
| 32 | - 146 => 8217, |
|
| 33 | - 147 => 8220, |
|
| 34 | - 148 => 8221, |
|
| 35 | - 149 => 8226, |
|
| 36 | - 150 => 8211, |
|
| 37 | - 151 => 8212, |
|
| 38 | - 152 => 732, |
|
| 39 | - 153 => 8482, |
|
| 40 | - 154 => 353, |
|
| 41 | - 155 => 8250, |
|
| 42 | - 156 => 339, |
|
| 43 | - 157 => 157 /* ?? */, |
|
| 44 | - 158 => 382, |
|
| 45 | - 159 => 376, |
|
| 14 | + 128 => 8364, |
|
| 15 | + 129 => 129 /* ?? */, |
|
| 16 | + 130 => 8218, |
|
| 17 | + 131 => 402, |
|
| 18 | + 132 => 8222, |
|
| 19 | + 133 => 8230, |
|
| 20 | + 134 => 8224, |
|
| 21 | + 135 => 8225, |
|
| 22 | + 136 => 710, |
|
| 23 | + 137 => 8240, |
|
| 24 | + 138 => 352, |
|
| 25 | + 139 => 8249, |
|
| 26 | + 140 => 338, |
|
| 27 | + 141 => 141 /* ?? */, |
|
| 28 | + 142 => 381, |
|
| 29 | + 143 => 143 /* ?? */, |
|
| 30 | + 144 => 144 /* ?? */, |
|
| 31 | + 145 => 8216, |
|
| 32 | + 146 => 8217, |
|
| 33 | + 147 => 8220, |
|
| 34 | + 148 => 8221, |
|
| 35 | + 149 => 8226, |
|
| 36 | + 150 => 8211, |
|
| 37 | + 151 => 8212, |
|
| 38 | + 152 => 732, |
|
| 39 | + 153 => 8482, |
|
| 40 | + 154 => 353, |
|
| 41 | + 155 => 8250, |
|
| 42 | + 156 => 339, |
|
| 43 | + 157 => 157 /* ?? */, |
|
| 44 | + 158 => 382, |
|
| 45 | + 159 => 376, |
|
| 46 | 46 | |
| 47 | - 160 => 160, |
|
| 48 | - 161 => 161, |
|
| 49 | - 162 => 162, |
|
| 50 | - 163 => 163, |
|
| 51 | - 164 => 164, |
|
| 52 | - 165 => 165, |
|
| 53 | - 166 => 166, |
|
| 54 | - 167 => 167, |
|
| 55 | - 168 => 168, |
|
| 56 | - 169 => 169, |
|
| 57 | - 170 => 170, |
|
| 58 | - 171 => 171, |
|
| 59 | - 172 => 172, |
|
| 60 | - 173 => 173, |
|
| 61 | - 174 => 174, |
|
| 62 | - 175 => 175, |
|
| 63 | - 176 => 176, |
|
| 64 | - 177 => 177, |
|
| 65 | - 178 => 178, |
|
| 66 | - 179 => 179, |
|
| 67 | - 180 => 180, |
|
| 68 | - 181 => 181, |
|
| 69 | - 182 => 182, |
|
| 70 | - 183 => 183, |
|
| 71 | - 184 => 184, |
|
| 72 | - 185 => 185, |
|
| 73 | - 186 => 186, |
|
| 74 | - 187 => 187, |
|
| 75 | - 188 => 188, |
|
| 76 | - 189 => 189, |
|
| 77 | - 190 => 190, |
|
| 78 | - 191 => 191, |
|
| 79 | - 192 => 192, |
|
| 80 | - 193 => 193, |
|
| 81 | - 194 => 194, |
|
| 82 | - 195 => 195, |
|
| 83 | - 196 => 196, |
|
| 84 | - 197 => 197, |
|
| 85 | - 198 => 198, |
|
| 86 | - 199 => 199, |
|
| 87 | - 200 => 200, |
|
| 88 | - 201 => 201, |
|
| 89 | - 202 => 202, |
|
| 90 | - 203 => 203, |
|
| 91 | - 204 => 204, |
|
| 92 | - 205 => 205, |
|
| 93 | - 206 => 206, |
|
| 94 | - 207 => 207, |
|
| 95 | - 208 => 208, |
|
| 96 | - 209 => 209, |
|
| 97 | - 210 => 210, |
|
| 98 | - 211 => 211, |
|
| 99 | - 212 => 212, |
|
| 100 | - 213 => 213, |
|
| 101 | - 214 => 214, |
|
| 102 | - 215 => 215, |
|
| 103 | - 216 => 216, |
|
| 104 | - 217 => 217, |
|
| 105 | - 218 => 218, |
|
| 106 | - 219 => 219, |
|
| 107 | - 220 => 220, |
|
| 108 | - 221 => 221, |
|
| 109 | - 222 => 222, |
|
| 110 | - 223 => 223, |
|
| 111 | - 224 => 224, |
|
| 112 | - 225 => 225, |
|
| 113 | - 226 => 226, |
|
| 114 | - 227 => 227, |
|
| 115 | - 228 => 228, |
|
| 116 | - 229 => 229, |
|
| 117 | - 230 => 230, |
|
| 118 | - 231 => 231, |
|
| 119 | - 232 => 232, |
|
| 120 | - 233 => 233, |
|
| 121 | - 234 => 234, |
|
| 122 | - 235 => 235, |
|
| 123 | - 236 => 236, |
|
| 124 | - 237 => 237, |
|
| 125 | - 238 => 238, |
|
| 126 | - 239 => 239, |
|
| 127 | - 240 => 240, |
|
| 128 | - 241 => 241, |
|
| 129 | - 242 => 242, |
|
| 130 | - 243 => 243, |
|
| 131 | - 244 => 244, |
|
| 132 | - 245 => 245, |
|
| 133 | - 246 => 246, |
|
| 134 | - 247 => 247, |
|
| 135 | - 248 => 248, |
|
| 136 | - 249 => 249, |
|
| 137 | - 250 => 250, |
|
| 138 | - 251 => 251, |
|
| 139 | - 252 => 252, |
|
| 140 | - 253 => 253, |
|
| 141 | - 254 => 254, |
|
| 142 | - 255 => 255 |
|
| 47 | + 160 => 160, |
|
| 48 | + 161 => 161, |
|
| 49 | + 162 => 162, |
|
| 50 | + 163 => 163, |
|
| 51 | + 164 => 164, |
|
| 52 | + 165 => 165, |
|
| 53 | + 166 => 166, |
|
| 54 | + 167 => 167, |
|
| 55 | + 168 => 168, |
|
| 56 | + 169 => 169, |
|
| 57 | + 170 => 170, |
|
| 58 | + 171 => 171, |
|
| 59 | + 172 => 172, |
|
| 60 | + 173 => 173, |
|
| 61 | + 174 => 174, |
|
| 62 | + 175 => 175, |
|
| 63 | + 176 => 176, |
|
| 64 | + 177 => 177, |
|
| 65 | + 178 => 178, |
|
| 66 | + 179 => 179, |
|
| 67 | + 180 => 180, |
|
| 68 | + 181 => 181, |
|
| 69 | + 182 => 182, |
|
| 70 | + 183 => 183, |
|
| 71 | + 184 => 184, |
|
| 72 | + 185 => 185, |
|
| 73 | + 186 => 186, |
|
| 74 | + 187 => 187, |
|
| 75 | + 188 => 188, |
|
| 76 | + 189 => 189, |
|
| 77 | + 190 => 190, |
|
| 78 | + 191 => 191, |
|
| 79 | + 192 => 192, |
|
| 80 | + 193 => 193, |
|
| 81 | + 194 => 194, |
|
| 82 | + 195 => 195, |
|
| 83 | + 196 => 196, |
|
| 84 | + 197 => 197, |
|
| 85 | + 198 => 198, |
|
| 86 | + 199 => 199, |
|
| 87 | + 200 => 200, |
|
| 88 | + 201 => 201, |
|
| 89 | + 202 => 202, |
|
| 90 | + 203 => 203, |
|
| 91 | + 204 => 204, |
|
| 92 | + 205 => 205, |
|
| 93 | + 206 => 206, |
|
| 94 | + 207 => 207, |
|
| 95 | + 208 => 208, |
|
| 96 | + 209 => 209, |
|
| 97 | + 210 => 210, |
|
| 98 | + 211 => 211, |
|
| 99 | + 212 => 212, |
|
| 100 | + 213 => 213, |
|
| 101 | + 214 => 214, |
|
| 102 | + 215 => 215, |
|
| 103 | + 216 => 216, |
|
| 104 | + 217 => 217, |
|
| 105 | + 218 => 218, |
|
| 106 | + 219 => 219, |
|
| 107 | + 220 => 220, |
|
| 108 | + 221 => 221, |
|
| 109 | + 222 => 222, |
|
| 110 | + 223 => 223, |
|
| 111 | + 224 => 224, |
|
| 112 | + 225 => 225, |
|
| 113 | + 226 => 226, |
|
| 114 | + 227 => 227, |
|
| 115 | + 228 => 228, |
|
| 116 | + 229 => 229, |
|
| 117 | + 230 => 230, |
|
| 118 | + 231 => 231, |
|
| 119 | + 232 => 232, |
|
| 120 | + 233 => 233, |
|
| 121 | + 234 => 234, |
|
| 122 | + 235 => 235, |
|
| 123 | + 236 => 236, |
|
| 124 | + 237 => 237, |
|
| 125 | + 238 => 238, |
|
| 126 | + 239 => 239, |
|
| 127 | + 240 => 240, |
|
| 128 | + 241 => 241, |
|
| 129 | + 242 => 242, |
|
| 130 | + 243 => 243, |
|
| 131 | + 244 => 244, |
|
| 132 | + 245 => 245, |
|
| 133 | + 246 => 246, |
|
| 134 | + 247 => 247, |
|
| 135 | + 248 => 248, |
|
| 136 | + 249 => 249, |
|
| 137 | + 250 => 250, |
|
| 138 | + 251 => 251, |
|
| 139 | + 252 => 252, |
|
| 140 | + 253 => 253, |
|
| 141 | + 254 => 254, |
|
| 142 | + 255 => 255 |
|
| 143 | 143 | |
| 144 | 144 | ]; |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | **/ |
| 20 | 20 | |
| 21 | 21 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 22 | - return; |
|
| 22 | + return; |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | load_charset('iso-8859-1'); |
@@ -27,61 +27,61 @@ discard block |
||
| 27 | 27 | $trans = $GLOBALS['CHARSET']['iso-8859-1']; |
| 28 | 28 | |
| 29 | 29 | $mod = [ |
| 30 | - 0xA0 => 0x00A0, |
|
| 31 | - 0xA4 => 0x00A4, |
|
| 32 | - 0xAC => 0x060C, |
|
| 33 | - 0xAD => 0x00AD, |
|
| 34 | - 0xBB => 0x061B, |
|
| 35 | - 0xBF => 0x061F, |
|
| 36 | - 0xC1 => 0x0621, |
|
| 37 | - 0xC2 => 0x0622, |
|
| 38 | - 0xC3 => 0x0623, |
|
| 39 | - 0xC4 => 0x0624, |
|
| 40 | - 0xC5 => 0x0625, |
|
| 41 | - 0xC6 => 0x0626, |
|
| 42 | - 0xC7 => 0x0627, |
|
| 43 | - 0xC8 => 0x0628, |
|
| 44 | - 0xC9 => 0x0629, |
|
| 45 | - 0xCA => 0x062A, |
|
| 46 | - 0xCB => 0x062B, |
|
| 47 | - 0xCC => 0x062C, |
|
| 48 | - 0xCD => 0x062D, |
|
| 49 | - 0xCE => 0x062E, |
|
| 50 | - 0xCF => 0x062F, |
|
| 51 | - 0xD0 => 0x0630, |
|
| 52 | - 0xD1 => 0x0631, |
|
| 53 | - 0xD2 => 0x0632, |
|
| 54 | - 0xD3 => 0x0633, |
|
| 55 | - 0xD4 => 0x0634, |
|
| 56 | - 0xD5 => 0x0635, |
|
| 57 | - 0xD6 => 0x0636, |
|
| 58 | - 0xD7 => 0x0637, |
|
| 59 | - 0xD8 => 0x0638, |
|
| 60 | - 0xD9 => 0x0639, |
|
| 61 | - 0xDA => 0x063A, |
|
| 62 | - 0xE0 => 0x0640, |
|
| 63 | - 0xE1 => 0x0641, |
|
| 64 | - 0xE2 => 0x0642, |
|
| 65 | - 0xE3 => 0x0643, |
|
| 66 | - 0xE4 => 0x0644, |
|
| 67 | - 0xE5 => 0x0645, |
|
| 68 | - 0xE6 => 0x0646, |
|
| 69 | - 0xE7 => 0x0647, |
|
| 70 | - 0xE8 => 0x0648, |
|
| 71 | - 0xE9 => 0x0649, |
|
| 72 | - 0xEA => 0x064A, |
|
| 73 | - 0xEB => 0x064B, |
|
| 74 | - 0xEC => 0x064C, |
|
| 75 | - 0xED => 0x064D, |
|
| 76 | - 0xEE => 0x064E, |
|
| 77 | - 0xEF => 0x064F, |
|
| 78 | - 0xF0 => 0x0650, |
|
| 79 | - 0xF1 => 0x0651, |
|
| 80 | - 0xF2 => 0x0652 |
|
| 30 | + 0xA0 => 0x00A0, |
|
| 31 | + 0xA4 => 0x00A4, |
|
| 32 | + 0xAC => 0x060C, |
|
| 33 | + 0xAD => 0x00AD, |
|
| 34 | + 0xBB => 0x061B, |
|
| 35 | + 0xBF => 0x061F, |
|
| 36 | + 0xC1 => 0x0621, |
|
| 37 | + 0xC2 => 0x0622, |
|
| 38 | + 0xC3 => 0x0623, |
|
| 39 | + 0xC4 => 0x0624, |
|
| 40 | + 0xC5 => 0x0625, |
|
| 41 | + 0xC6 => 0x0626, |
|
| 42 | + 0xC7 => 0x0627, |
|
| 43 | + 0xC8 => 0x0628, |
|
| 44 | + 0xC9 => 0x0629, |
|
| 45 | + 0xCA => 0x062A, |
|
| 46 | + 0xCB => 0x062B, |
|
| 47 | + 0xCC => 0x062C, |
|
| 48 | + 0xCD => 0x062D, |
|
| 49 | + 0xCE => 0x062E, |
|
| 50 | + 0xCF => 0x062F, |
|
| 51 | + 0xD0 => 0x0630, |
|
| 52 | + 0xD1 => 0x0631, |
|
| 53 | + 0xD2 => 0x0632, |
|
| 54 | + 0xD3 => 0x0633, |
|
| 55 | + 0xD4 => 0x0634, |
|
| 56 | + 0xD5 => 0x0635, |
|
| 57 | + 0xD6 => 0x0636, |
|
| 58 | + 0xD7 => 0x0637, |
|
| 59 | + 0xD8 => 0x0638, |
|
| 60 | + 0xD9 => 0x0639, |
|
| 61 | + 0xDA => 0x063A, |
|
| 62 | + 0xE0 => 0x0640, |
|
| 63 | + 0xE1 => 0x0641, |
|
| 64 | + 0xE2 => 0x0642, |
|
| 65 | + 0xE3 => 0x0643, |
|
| 66 | + 0xE4 => 0x0644, |
|
| 67 | + 0xE5 => 0x0645, |
|
| 68 | + 0xE6 => 0x0646, |
|
| 69 | + 0xE7 => 0x0647, |
|
| 70 | + 0xE8 => 0x0648, |
|
| 71 | + 0xE9 => 0x0649, |
|
| 72 | + 0xEA => 0x064A, |
|
| 73 | + 0xEB => 0x064B, |
|
| 74 | + 0xEC => 0x064C, |
|
| 75 | + 0xED => 0x064D, |
|
| 76 | + 0xEE => 0x064E, |
|
| 77 | + 0xEF => 0x064F, |
|
| 78 | + 0xF0 => 0x0650, |
|
| 79 | + 0xF1 => 0x0651, |
|
| 80 | + 0xF2 => 0x0652 |
|
| 81 | 81 | ]; |
| 82 | 82 | |
| 83 | 83 | foreach ($mod as $num => $val) { |
| 84 | - $trans[$num] = $val; |
|
| 84 | + $trans[$num] = $val; |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | $GLOBALS['CHARSET']['iso-8859-6'] = $trans; |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | **/ |
| 21 | 21 | |
| 22 | 22 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 23 | - return; |
|
| 23 | + return; |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | load_charset('translit'); |
@@ -28,151 +28,151 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | $translit_c = [ |
| 30 | 30 | // vietnamien |
| 31 | - 225 => "a'", |
|
| 32 | - 224 => 'a`', |
|
| 33 | - 7843 => 'a?', |
|
| 34 | - 227 => 'a~', |
|
| 35 | - 7841 => 'a.', |
|
| 36 | - 226 => 'a^', |
|
| 37 | - 7845 => "a^'", |
|
| 38 | - 7847 => 'a^`', |
|
| 39 | - 7849 => 'a^?', |
|
| 40 | - 7851 => 'a^~', |
|
| 41 | - 7853 => 'a^.', |
|
| 42 | - 259 => 'a(', |
|
| 43 | - 7855 => "a('", |
|
| 44 | - 7857 => 'a(`', |
|
| 45 | - 7859 => 'a(?', |
|
| 46 | - 7861 => 'a(~', |
|
| 47 | - 7863 => 'a(.', |
|
| 48 | - 193 => "A'", |
|
| 49 | - 192 => 'A`', |
|
| 50 | - 7842 => 'A?', |
|
| 51 | - 195 => 'A~', |
|
| 52 | - 7840 => 'A.', |
|
| 53 | - 194 => 'A^', |
|
| 54 | - 7844 => "A^'", |
|
| 55 | - 7846 => 'A^`', |
|
| 56 | - 7848 => 'A^?', |
|
| 57 | - 7850 => 'A^~', |
|
| 58 | - 7852 => 'A^.', |
|
| 59 | - 258 => 'A(', |
|
| 60 | - 7854 => "A('", |
|
| 61 | - 7856 => 'A(`', |
|
| 62 | - 7858 => 'A(?', |
|
| 63 | - 7860 => 'A(~', |
|
| 64 | - 7862 => 'A(.', |
|
| 65 | - 233 => "e'", |
|
| 66 | - 232 => 'e`', |
|
| 67 | - 7867 => 'e?', |
|
| 68 | - 7869 => 'e~', |
|
| 69 | - 7865 => 'e.', |
|
| 70 | - 234 => 'e^', |
|
| 71 | - 7871 => "e^'", |
|
| 72 | - 7873 => 'e^`', |
|
| 73 | - 7875 => 'e^?', |
|
| 74 | - 7877 => 'e^~', |
|
| 75 | - 7879 => 'e^.', |
|
| 76 | - 201 => "E'", |
|
| 77 | - 200 => 'E`', |
|
| 78 | - 7866 => 'E?', |
|
| 79 | - 7868 => 'E~', |
|
| 80 | - 7864 => 'E.', |
|
| 81 | - 202 => 'E^', |
|
| 82 | - 7870 => "E^'", |
|
| 83 | - 7872 => 'E^`', |
|
| 84 | - 7874 => 'E^?', |
|
| 85 | - 7876 => 'E^~', |
|
| 86 | - 7878 => 'E^.', |
|
| 87 | - 237 => "i'", |
|
| 88 | - 236 => 'i`', |
|
| 89 | - 7881 => 'i?', |
|
| 90 | - 297 => 'i~', |
|
| 91 | - 7883 => 'i.', |
|
| 92 | - 205 => "I'", |
|
| 93 | - 204 => 'I`', |
|
| 94 | - 7880 => 'I?', |
|
| 95 | - 296 => 'I~', |
|
| 96 | - 7882 => 'I.', |
|
| 97 | - 243 => "o'", |
|
| 98 | - 242 => 'o`', |
|
| 99 | - 7887 => 'o?', |
|
| 100 | - 245 => 'o~', |
|
| 101 | - 7885 => 'o.', |
|
| 102 | - 244 => 'o^', |
|
| 103 | - 7889 => "o^'", |
|
| 104 | - 7891 => 'o^`', |
|
| 105 | - 7893 => 'o^?', |
|
| 106 | - 7895 => 'o^~', |
|
| 107 | - 7897 => 'o^.', |
|
| 108 | - 417 => 'o+', |
|
| 109 | - 7899 => "o+'", |
|
| 110 | - 7901 => 'o+`', |
|
| 111 | - 7903 => 'o+?', |
|
| 112 | - 7905 => 'o+~', |
|
| 113 | - 7907 => 'o+.', |
|
| 114 | - 211 => "O'", |
|
| 115 | - 210 => 'O`', |
|
| 116 | - 7886 => 'O?', |
|
| 117 | - 213 => 'O~', |
|
| 118 | - 7884 => 'O.', |
|
| 119 | - 212 => 'O^', |
|
| 120 | - 7888 => "O^'", |
|
| 121 | - 7890 => 'O^`', |
|
| 122 | - 7892 => 'O^?', |
|
| 123 | - 7894 => 'O^~', |
|
| 124 | - 7896 => 'O^.', |
|
| 125 | - 416 => 'O+', |
|
| 126 | - 7898 => "O+'", |
|
| 127 | - 7900 => 'O+`', |
|
| 128 | - 7902 => 'O+?', |
|
| 129 | - 7904 => 'O+~', |
|
| 130 | - 7906 => 'O+.', |
|
| 131 | - 250 => "u'", |
|
| 132 | - 249 => 'u`', |
|
| 133 | - 7911 => 'u?', |
|
| 134 | - 361 => 'u~', |
|
| 135 | - 7909 => 'u.', |
|
| 136 | - 432 => 'u+', |
|
| 137 | - 7913 => "u+'", |
|
| 138 | - 7915 => 'u+`', |
|
| 139 | - 7917 => 'u+?', |
|
| 140 | - 7919 => 'u+~', |
|
| 141 | - 7921 => 'u+.', |
|
| 142 | - 218 => "U'", |
|
| 143 | - 217 => 'U`', |
|
| 144 | - 7910 => 'U?', |
|
| 145 | - 360 => 'U~', |
|
| 146 | - 7908 => 'U.', |
|
| 147 | - 431 => 'U+', |
|
| 148 | - 7912 => "U+'", |
|
| 149 | - 7914 => 'U+`', |
|
| 150 | - 7916 => 'U+?', |
|
| 151 | - 7918 => 'U+~', |
|
| 152 | - 7920 => 'U+.', |
|
| 153 | - 253 => "y'", |
|
| 154 | - 7923 => 'y`', |
|
| 155 | - 7927 => 'y?', |
|
| 156 | - 7929 => 'y~', |
|
| 157 | - 7925 => 'y.', |
|
| 158 | - 221 => "Y'", |
|
| 159 | - 7922 => 'Y`', |
|
| 160 | - 7926 => 'Y?', |
|
| 161 | - 7928 => 'Y~', |
|
| 162 | - 7924 => 'Y.', |
|
| 163 | - 273 => 'd-', |
|
| 164 | - 208 => 'D-', |
|
| 31 | + 225 => "a'", |
|
| 32 | + 224 => 'a`', |
|
| 33 | + 7843 => 'a?', |
|
| 34 | + 227 => 'a~', |
|
| 35 | + 7841 => 'a.', |
|
| 36 | + 226 => 'a^', |
|
| 37 | + 7845 => "a^'", |
|
| 38 | + 7847 => 'a^`', |
|
| 39 | + 7849 => 'a^?', |
|
| 40 | + 7851 => 'a^~', |
|
| 41 | + 7853 => 'a^.', |
|
| 42 | + 259 => 'a(', |
|
| 43 | + 7855 => "a('", |
|
| 44 | + 7857 => 'a(`', |
|
| 45 | + 7859 => 'a(?', |
|
| 46 | + 7861 => 'a(~', |
|
| 47 | + 7863 => 'a(.', |
|
| 48 | + 193 => "A'", |
|
| 49 | + 192 => 'A`', |
|
| 50 | + 7842 => 'A?', |
|
| 51 | + 195 => 'A~', |
|
| 52 | + 7840 => 'A.', |
|
| 53 | + 194 => 'A^', |
|
| 54 | + 7844 => "A^'", |
|
| 55 | + 7846 => 'A^`', |
|
| 56 | + 7848 => 'A^?', |
|
| 57 | + 7850 => 'A^~', |
|
| 58 | + 7852 => 'A^.', |
|
| 59 | + 258 => 'A(', |
|
| 60 | + 7854 => "A('", |
|
| 61 | + 7856 => 'A(`', |
|
| 62 | + 7858 => 'A(?', |
|
| 63 | + 7860 => 'A(~', |
|
| 64 | + 7862 => 'A(.', |
|
| 65 | + 233 => "e'", |
|
| 66 | + 232 => 'e`', |
|
| 67 | + 7867 => 'e?', |
|
| 68 | + 7869 => 'e~', |
|
| 69 | + 7865 => 'e.', |
|
| 70 | + 234 => 'e^', |
|
| 71 | + 7871 => "e^'", |
|
| 72 | + 7873 => 'e^`', |
|
| 73 | + 7875 => 'e^?', |
|
| 74 | + 7877 => 'e^~', |
|
| 75 | + 7879 => 'e^.', |
|
| 76 | + 201 => "E'", |
|
| 77 | + 200 => 'E`', |
|
| 78 | + 7866 => 'E?', |
|
| 79 | + 7868 => 'E~', |
|
| 80 | + 7864 => 'E.', |
|
| 81 | + 202 => 'E^', |
|
| 82 | + 7870 => "E^'", |
|
| 83 | + 7872 => 'E^`', |
|
| 84 | + 7874 => 'E^?', |
|
| 85 | + 7876 => 'E^~', |
|
| 86 | + 7878 => 'E^.', |
|
| 87 | + 237 => "i'", |
|
| 88 | + 236 => 'i`', |
|
| 89 | + 7881 => 'i?', |
|
| 90 | + 297 => 'i~', |
|
| 91 | + 7883 => 'i.', |
|
| 92 | + 205 => "I'", |
|
| 93 | + 204 => 'I`', |
|
| 94 | + 7880 => 'I?', |
|
| 95 | + 296 => 'I~', |
|
| 96 | + 7882 => 'I.', |
|
| 97 | + 243 => "o'", |
|
| 98 | + 242 => 'o`', |
|
| 99 | + 7887 => 'o?', |
|
| 100 | + 245 => 'o~', |
|
| 101 | + 7885 => 'o.', |
|
| 102 | + 244 => 'o^', |
|
| 103 | + 7889 => "o^'", |
|
| 104 | + 7891 => 'o^`', |
|
| 105 | + 7893 => 'o^?', |
|
| 106 | + 7895 => 'o^~', |
|
| 107 | + 7897 => 'o^.', |
|
| 108 | + 417 => 'o+', |
|
| 109 | + 7899 => "o+'", |
|
| 110 | + 7901 => 'o+`', |
|
| 111 | + 7903 => 'o+?', |
|
| 112 | + 7905 => 'o+~', |
|
| 113 | + 7907 => 'o+.', |
|
| 114 | + 211 => "O'", |
|
| 115 | + 210 => 'O`', |
|
| 116 | + 7886 => 'O?', |
|
| 117 | + 213 => 'O~', |
|
| 118 | + 7884 => 'O.', |
|
| 119 | + 212 => 'O^', |
|
| 120 | + 7888 => "O^'", |
|
| 121 | + 7890 => 'O^`', |
|
| 122 | + 7892 => 'O^?', |
|
| 123 | + 7894 => 'O^~', |
|
| 124 | + 7896 => 'O^.', |
|
| 125 | + 416 => 'O+', |
|
| 126 | + 7898 => "O+'", |
|
| 127 | + 7900 => 'O+`', |
|
| 128 | + 7902 => 'O+?', |
|
| 129 | + 7904 => 'O+~', |
|
| 130 | + 7906 => 'O+.', |
|
| 131 | + 250 => "u'", |
|
| 132 | + 249 => 'u`', |
|
| 133 | + 7911 => 'u?', |
|
| 134 | + 361 => 'u~', |
|
| 135 | + 7909 => 'u.', |
|
| 136 | + 432 => 'u+', |
|
| 137 | + 7913 => "u+'", |
|
| 138 | + 7915 => 'u+`', |
|
| 139 | + 7917 => 'u+?', |
|
| 140 | + 7919 => 'u+~', |
|
| 141 | + 7921 => 'u+.', |
|
| 142 | + 218 => "U'", |
|
| 143 | + 217 => 'U`', |
|
| 144 | + 7910 => 'U?', |
|
| 145 | + 360 => 'U~', |
|
| 146 | + 7908 => 'U.', |
|
| 147 | + 431 => 'U+', |
|
| 148 | + 7912 => "U+'", |
|
| 149 | + 7914 => 'U+`', |
|
| 150 | + 7916 => 'U+?', |
|
| 151 | + 7918 => 'U+~', |
|
| 152 | + 7920 => 'U+.', |
|
| 153 | + 253 => "y'", |
|
| 154 | + 7923 => 'y`', |
|
| 155 | + 7927 => 'y?', |
|
| 156 | + 7929 => 'y~', |
|
| 157 | + 7925 => 'y.', |
|
| 158 | + 221 => "Y'", |
|
| 159 | + 7922 => 'Y`', |
|
| 160 | + 7926 => 'Y?', |
|
| 161 | + 7928 => 'Y~', |
|
| 162 | + 7924 => 'Y.', |
|
| 163 | + 273 => 'd-', |
|
| 164 | + 208 => 'D-', |
|
| 165 | 165 | |
| 166 | 166 | // allemand |
| 167 | - 228 => 'ae', |
|
| 168 | - 246 => 'oe', |
|
| 169 | - 252 => 'ue', |
|
| 170 | - 196 => 'Ae', |
|
| 171 | - 214 => 'Oe', |
|
| 172 | - 220 => 'Ue' |
|
| 167 | + 228 => 'ae', |
|
| 168 | + 246 => 'oe', |
|
| 169 | + 252 => 'ue', |
|
| 170 | + 196 => 'Ae', |
|
| 171 | + 214 => 'Oe', |
|
| 172 | + 220 => 'Ue' |
|
| 173 | 173 | ]; |
| 174 | 174 | |
| 175 | 175 | foreach ($translit_c as $u => $t) { |
| 176 | - $trans[$u] = $t; |
|
| 176 | + $trans[$u] = $t; |
|
| 177 | 177 | } |
| 178 | 178 | $GLOBALS['CHARSET']['translitcomplexe'] = $trans; |