@@ -49,13 +49,13 @@ discard block |
||
| 49 | 49 | // celle du texte) et public (spip_lang est la langue du texte) |
| 50 | 50 | $dir = _DIR_RESTREINT ? lang_dir() : lang_dir($GLOBALS['spip_lang']); |
| 51 | 51 | |
| 52 | - $p = 'puce' . (test_espace_prive() ? '_prive' : ''); |
|
| 52 | + $p = 'puce'.(test_espace_prive() ? '_prive' : ''); |
|
| 53 | 53 | if ($dir == 'rtl') { |
| 54 | 54 | $p .= '_rtl'; |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | if (!isset($GLOBALS[$p])) { |
| 58 | - $GLOBALS[$p] = '<span class="spip-puce ' . $dir . '"><b>–</b></span>'; |
|
| 58 | + $GLOBALS[$p] = '<span class="spip-puce '.$dir.'"><b>–</b></span>'; |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | return $GLOBALS[$p]; |
@@ -67,13 +67,13 @@ discard block |
||
| 67 | 67 | function spip_balisage_code(string $corps, bool $bloc = false, string $attributs = '', string $langage = ''): string { |
| 68 | 68 | |
| 69 | 69 | $echap = spip_htmlspecialchars($corps); // il ne faut pas passer dans entites_html, ne pas transformer les &#xxx; du code ! |
| 70 | - $class = 'spip_code ' . ($bloc ? 'spip_code_block' : 'spip_code_inline'); |
|
| 70 | + $class = 'spip_code '.($bloc ? 'spip_code_block' : 'spip_code_inline'); |
|
| 71 | 71 | if ($attributs) { |
| 72 | - $attributs = ' ' . trim($attributs); |
|
| 72 | + $attributs = ' '.trim($attributs); |
|
| 73 | 73 | } |
| 74 | 74 | if ($langage) { |
| 75 | 75 | $class .= " language-$langage"; |
| 76 | - $attributs .= ' data-language="' . $langage . '"'; |
|
| 76 | + $attributs .= ' data-language="'.$langage.'"'; |
|
| 77 | 77 | } |
| 78 | 78 | if ($bloc) { |
| 79 | 79 | $html = '<div class="precode">' |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | } else { |
| 87 | 87 | $echap = str_replace("\t", ' ', $echap); |
| 88 | 88 | $echap = str_replace(' ', ' ', $echap); |
| 89 | - $html = "<code class=\"$class\" dir=\"ltr\"$attributs>" . $echap . '</code>'; |
|
| 89 | + $html = "<code class=\"$class\" dir=\"ltr\"$attributs>".$echap.'</code>'; |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | return $html; |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | // XHTML - Preserver les balises-bloc : on liste ici tous les elements |
| 97 | 97 | // dont on souhaite qu'ils provoquent un saut de paragraphe |
| 98 | 98 | defined('_BALISES_BLOCS') || define('_BALISES_BLOCS', implode('|', CollecteurHtmlTag::$listeBalisesBloc)); |
| 99 | -defined('_BALISES_BLOCS_REGEXP') || define('_BALISES_BLOCS_REGEXP', ',</?(' . _BALISES_BLOCS . ')[>[:space:]],iS'); |
|
| 99 | +defined('_BALISES_BLOCS_REGEXP') || define('_BALISES_BLOCS_REGEXP', ',</?('._BALISES_BLOCS.')[>[:space:]],iS'); |
|
| 100 | 100 | |
| 101 | 101 | /** |
| 102 | 102 | * Echapper les elements perilleux en les passant en base64 |
@@ -116,7 +116,7 @@ discard block |
||
| 116 | 116 | return ''; |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | - return CollecteurHtmlTag::echappementHtmlBase64((string)$rempl, (string)$source, in_array($mode, ['div', 'span']) ? $mode === 'div' : null); |
|
| 119 | + return CollecteurHtmlTag::echappementHtmlBase64((string) $rempl, (string) $source, in_array($mode, ['div', 'span']) ? $mode === 'div' : null); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | |
@@ -136,7 +136,7 @@ discard block |
||
| 136 | 136 | $collections = $collecteurCode->collecter($pre); |
| 137 | 137 | $collections = array_reverse($collections); |
| 138 | 138 | foreach ($collections as $c) { |
| 139 | - $code = $c['opening'] . spip_htmlspecialchars($c['innerHtml']) . $c['closing']; |
|
| 139 | + $code = $c['opening'].spip_htmlspecialchars($c['innerHtml']).$c['closing']; |
|
| 140 | 140 | $pre = substr_replace($pre, $code, $c['pos'], $c['length']); |
| 141 | 141 | } |
| 142 | 142 | } |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | return $regs['raw']; |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | -defined('_PROTEGE_BLOCS') || define('_PROTEGE_BLOCS', ',<(' . implode('|', CollecteurHtmlTag::$listeBalisesAProteger) . ')(\b[^>]*)?>(.*)</\1>,UimsS'); |
|
| 194 | +defined('_PROTEGE_BLOCS') || define('_PROTEGE_BLOCS', ',<('.implode('|', CollecteurHtmlTag::$listeBalisesAProteger).')(\b[^>]*)?>(.*)</\1>,UimsS'); |
|
| 195 | 195 | |
| 196 | 196 | /** |
| 197 | 197 | * pour $source voir commentaire infra (echappe_retour) |
@@ -242,11 +242,11 @@ discard block |
||
| 242 | 242 | $callback_secure_prefix = ($callback_options['secure_prefix'] ?? ''); |
| 243 | 243 | foreach ($html_tags ?: CollecteurHtmlTag::$listeBalisesAProteger as $tag) { |
| 244 | 244 | if ( |
| 245 | - function_exists($f = $callback_prefix . $callback_secure_prefix . 'traiter_echap_' . $tag) |
|
| 246 | - || function_exists($f = $f . '_dist') |
|
| 245 | + function_exists($f = $callback_prefix.$callback_secure_prefix.'traiter_echap_'.$tag) |
|
| 246 | + || function_exists($f = $f.'_dist') |
|
| 247 | 247 | || $callback_secure_prefix && ( |
| 248 | - function_exists($f = $callback_prefix . 'traiter_echap_' . $tag) |
|
| 249 | - || function_exists($f = $f . '_dist') |
|
| 248 | + function_exists($f = $callback_prefix.'traiter_echap_'.$tag) |
|
| 249 | + || function_exists($f = $f.'_dist') |
|
| 250 | 250 | ) |
| 251 | 251 | ) { |
| 252 | 252 | $callbacks[$tag] = $f; |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | if (!is_string($letexte) || !strlen($letexte)) { |
| 287 | 287 | return $letexte; |
| 288 | 288 | } |
| 289 | - return CollecteurHtmlTag::retablir_depuisHtmlBase64((string)$letexte, (string)$source, (string)$filtre); |
|
| 289 | + return CollecteurHtmlTag::retablir_depuisHtmlBase64((string) $letexte, (string) $source, (string) $filtre); |
|
| 290 | 290 | } |
| 291 | 291 | |
| 292 | 292 | // Reinserer le javascript de confiance (venant des modeles) |
@@ -295,7 +295,7 @@ discard block |
||
| 295 | 295 | if (!is_string($letexte) || !strlen($letexte)) { |
| 296 | 296 | return $letexte; |
| 297 | 297 | } |
| 298 | - $letexte = CollecteurHtmlTag::retablir_depuisHtmlBase64((string)$letexte); |
|
| 298 | + $letexte = CollecteurHtmlTag::retablir_depuisHtmlBase64((string) $letexte); |
|
| 299 | 299 | |
| 300 | 300 | // Dans les appels directs hors squelette, securiser aussi ici |
| 301 | 301 | // c'est interdire_scripts() qui rétablit les scripts des modeles echappés avec _PROTEGE_JS_MODELES et _PROTEGE_PHP_MODELES |
@@ -364,8 +364,8 @@ discard block |
||
| 364 | 364 | $texte = nettoyer_raccourcis_typo($texte); |
| 365 | 365 | |
| 366 | 366 | // balises de sauts de ligne et paragraphe |
| 367 | - $texte = preg_replace('/<p( [^>]*)?' . '>/', "\r\r", $texte); |
|
| 368 | - $texte = preg_replace('/<br( [^>]*)?' . '>/', "\n", $texte); |
|
| 367 | + $texte = preg_replace('/<p( [^>]*)?'.'>/', "\r\r", $texte); |
|
| 368 | + $texte = preg_replace('/<br( [^>]*)?'.'>/', "\n", $texte); |
|
| 369 | 369 | |
| 370 | 370 | // on repasse les doubles \n en \r que nettoyer_raccourcis_typo() a pu modifier |
| 371 | 371 | $texte = str_replace("\n\n", "\r\r", $texte); |
@@ -390,15 +390,15 @@ discard block |
||
| 390 | 390 | // excédentaire est ensuite supprimé par l'appel à preg_replace() |
| 391 | 391 | $long = spip_substr($texte, 0, max($taille + 1 - $taille_suite, 1)); |
| 392 | 392 | $u = $GLOBALS['meta']['pcre_u']; |
| 393 | - $court = preg_replace('/(^|([^\s ])[\s ]+)([\s ]|[^\s ]+)?$/D' . $u, "\\2", $long); |
|
| 393 | + $court = preg_replace('/(^|([^\s ])[\s ]+)([\s ]|[^\s ]+)?$/D'.$u, "\\2", $long); |
|
| 394 | 394 | $points = $suite; |
| 395 | 395 | |
| 396 | 396 | // trop court ? ne pas faire de (...) |
| 397 | 397 | if (spip_strlen($court) < max(0.75 * $taille, 2)) { |
| 398 | 398 | $points = ''; |
| 399 | 399 | $long = spip_substr($texte, 0, $taille + 1); |
| 400 | - preg_match('/(^|([^\s ])[\s ]+)([\s ]|[^\s ]+)?$/D' . $u, $long, $m); |
|
| 401 | - $texte = preg_replace('/(^|([^\s ])[\s ]+)([\s ]|[^\s ]+)?$/D' . $u, "\\2", $long); |
|
| 400 | + preg_match('/(^|([^\s ])[\s ]+)([\s ]|[^\s ]+)?$/D'.$u, $long, $m); |
|
| 401 | + $texte = preg_replace('/(^|([^\s ])[\s ]+)([\s ]|[^\s ]+)?$/D'.$u, "\\2", $long); |
|
| 402 | 402 | // encore trop court ? couper au caractere |
| 403 | 403 | if (spip_strlen($texte) < 0.75 * $taille) { |
| 404 | 404 | $texte = spip_substr($long, 0, $taille); |
@@ -414,7 +414,7 @@ discard block |
||
| 414 | 414 | // supprimer l'eventuelle entite finale mal coupee |
| 415 | 415 | $texte = preg_replace('/&#?[a-z0-9]*$/S', '', $texte); |
| 416 | 416 | |
| 417 | - return quote_amp(trim($texte)) . $points; |
|
| 417 | + return quote_amp(trim($texte)).$points; |
|
| 418 | 418 | } |
| 419 | 419 | |
| 420 | 420 | |
@@ -422,16 +422,16 @@ discard block |
||
| 422 | 422 | if (isset($GLOBALS['visiteur_session']) && str_contains($texte, '<')) { |
| 423 | 423 | $tags = [ |
| 424 | 424 | 'javascript' => ['tag' => 'script', 'preg' => ',<script.*?($|</script.),isS', 'c' => '_PROTEGE_JS_MODELES'], |
| 425 | - 'php' => ['tag' => '?php', 'preg' => ',<\?php.*?($|\?' . '>),isS', 'c' => '_PROTEGE_PHP_MODELES'], |
|
| 425 | + 'php' => ['tag' => '?php', 'preg' => ',<\?php.*?($|\?'.'>),isS', 'c' => '_PROTEGE_PHP_MODELES'], |
|
| 426 | 426 | ]; |
| 427 | 427 | foreach ($tags as $k => $t) { |
| 428 | - if (stripos($texte, '<' . $t['tag']) !== false) { |
|
| 428 | + if (stripos($texte, '<'.$t['tag']) !== false) { |
|
| 429 | 429 | if (!defined($t['c'])) { |
| 430 | 430 | include_spip('inc/acces'); |
| 431 | 431 | define($t['c'], creer_uniqid()); |
| 432 | 432 | } |
| 433 | 433 | $collecteurHtmlTag = new CollecteurHtmlTag($t['tag'], $t['preg'], ''); |
| 434 | - $texte = $collecteurHtmlTag->echapper_enHtmlBase64($texte, $k . constant($t['c'])); |
|
| 434 | + $texte = $collecteurHtmlTag->echapper_enHtmlBase64($texte, $k.constant($t['c'])); |
|
| 435 | 435 | } |
| 436 | 436 | } |
| 437 | 437 | } |
@@ -544,7 +544,7 @@ discard block |
||
| 544 | 544 | if (!empty($options['wrap_suspect'])) { |
| 545 | 545 | $texte = wrap($texte, $options['wrap_suspect']); |
| 546 | 546 | } |
| 547 | - $texte = "<mark class='danger-js' title='" . attribut_html(_T('erreur_contenu_suspect')) . "'>⚠️</mark> " . $texte; |
|
| 547 | + $texte = "<mark class='danger-js' title='".attribut_html(_T('erreur_contenu_suspect'))."'>⚠️</mark> ".$texte; |
|
| 548 | 548 | } |
| 549 | 549 | |
| 550 | 550 | $texte = $collecteurModeles->retablir($texte); |
@@ -687,11 +687,11 @@ discard block |
||
| 687 | 687 | **/ |
| 688 | 688 | function supprime_img($letexte, $message = null) { |
| 689 | 689 | if ($message === null) { |
| 690 | - $message = '(' . _T('img_indisponible') . ')'; |
|
| 690 | + $message = '('._T('img_indisponible').')'; |
|
| 691 | 691 | } |
| 692 | 692 | |
| 693 | 693 | return preg_replace( |
| 694 | - ',<(img|doc|emb)([0-9]+)(\|([^>]*))?' . '\s*/?' . '>,i', |
|
| 694 | + ',<(img|doc|emb)([0-9]+)(\|([^>]*))?'.'\s*/?'.'>,i', |
|
| 695 | 695 | $message, |
| 696 | 696 | $letexte |
| 697 | 697 | ); |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | **/ |
| 23 | 23 | |
| 24 | 24 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 25 | - return; |
|
| 25 | + return; |
|
| 26 | 26 | } |
| 27 | 27 | include_spip('inc/filtres'); |
| 28 | 28 | include_spip('inc/lang'); |
@@ -44,21 +44,21 @@ discard block |
||
| 44 | 44 | **/ |
| 45 | 45 | function definir_puce() { |
| 46 | 46 | |
| 47 | - // Attention au sens, qui n'est pas defini de la meme facon dans |
|
| 48 | - // l'espace prive (spip_lang est la langue de l'interface, lang_dir |
|
| 49 | - // celle du texte) et public (spip_lang est la langue du texte) |
|
| 50 | - $dir = _DIR_RESTREINT ? lang_dir() : lang_dir($GLOBALS['spip_lang']); |
|
| 47 | + // Attention au sens, qui n'est pas defini de la meme facon dans |
|
| 48 | + // l'espace prive (spip_lang est la langue de l'interface, lang_dir |
|
| 49 | + // celle du texte) et public (spip_lang est la langue du texte) |
|
| 50 | + $dir = _DIR_RESTREINT ? lang_dir() : lang_dir($GLOBALS['spip_lang']); |
|
| 51 | 51 | |
| 52 | - $p = 'puce' . (test_espace_prive() ? '_prive' : ''); |
|
| 53 | - if ($dir == 'rtl') { |
|
| 54 | - $p .= '_rtl'; |
|
| 55 | - } |
|
| 52 | + $p = 'puce' . (test_espace_prive() ? '_prive' : ''); |
|
| 53 | + if ($dir == 'rtl') { |
|
| 54 | + $p .= '_rtl'; |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - if (!isset($GLOBALS[$p])) { |
|
| 58 | - $GLOBALS[$p] = '<span class="spip-puce ' . $dir . '"><b>–</b></span>'; |
|
| 59 | - } |
|
| 57 | + if (!isset($GLOBALS[$p])) { |
|
| 58 | + $GLOBALS[$p] = '<span class="spip-puce ' . $dir . '"><b>–</b></span>'; |
|
| 59 | + } |
|
| 60 | 60 | |
| 61 | - return $GLOBALS[$p]; |
|
| 61 | + return $GLOBALS[$p]; |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | /** |
@@ -66,30 +66,30 @@ discard block |
||
| 66 | 66 | */ |
| 67 | 67 | function spip_balisage_code(string $corps, bool $bloc = false, string $attributs = '', string $langage = ''): string { |
| 68 | 68 | |
| 69 | - $echap = spip_htmlspecialchars($corps); // il ne faut pas passer dans entites_html, ne pas transformer les &#xxx; du code ! |
|
| 70 | - $class = 'spip_code ' . ($bloc ? 'spip_code_block' : 'spip_code_inline'); |
|
| 71 | - if ($attributs) { |
|
| 72 | - $attributs = ' ' . trim($attributs); |
|
| 73 | - } |
|
| 74 | - if ($langage) { |
|
| 75 | - $class .= " language-$langage"; |
|
| 76 | - $attributs .= ' data-language="' . $langage . '"'; |
|
| 77 | - } |
|
| 78 | - if ($bloc) { |
|
| 79 | - $html = '<div class="precode">' |
|
| 80 | - . "<pre class=\"$class\" dir=\"ltr\" style=\"text-align: left;\"$attributs>" |
|
| 81 | - . '<code>' |
|
| 82 | - . $echap |
|
| 83 | - . '</code>' |
|
| 84 | - . '</pre>' |
|
| 85 | - . '</div>'; |
|
| 86 | - } else { |
|
| 87 | - $echap = str_replace("\t", ' ', $echap); |
|
| 88 | - $echap = str_replace(' ', ' ', $echap); |
|
| 89 | - $html = "<code class=\"$class\" dir=\"ltr\"$attributs>" . $echap . '</code>'; |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - return $html; |
|
| 69 | + $echap = spip_htmlspecialchars($corps); // il ne faut pas passer dans entites_html, ne pas transformer les &#xxx; du code ! |
|
| 70 | + $class = 'spip_code ' . ($bloc ? 'spip_code_block' : 'spip_code_inline'); |
|
| 71 | + if ($attributs) { |
|
| 72 | + $attributs = ' ' . trim($attributs); |
|
| 73 | + } |
|
| 74 | + if ($langage) { |
|
| 75 | + $class .= " language-$langage"; |
|
| 76 | + $attributs .= ' data-language="' . $langage . '"'; |
|
| 77 | + } |
|
| 78 | + if ($bloc) { |
|
| 79 | + $html = '<div class="precode">' |
|
| 80 | + . "<pre class=\"$class\" dir=\"ltr\" style=\"text-align: left;\"$attributs>" |
|
| 81 | + . '<code>' |
|
| 82 | + . $echap |
|
| 83 | + . '</code>' |
|
| 84 | + . '</pre>' |
|
| 85 | + . '</div>'; |
|
| 86 | + } else { |
|
| 87 | + $echap = str_replace("\t", ' ', $echap); |
|
| 88 | + $echap = str_replace(' ', ' ', $echap); |
|
| 89 | + $html = "<code class=\"$class\" dir=\"ltr\"$attributs>" . $echap . '</code>'; |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + return $html; |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | |
@@ -112,83 +112,83 @@ discard block |
||
| 112 | 112 | * @return string |
| 113 | 113 | */ |
| 114 | 114 | function code_echappement($rempl, $source = '', $no_transform = false, $mode = null) { |
| 115 | - if (!is_string($rempl) || !strlen($rempl)) { |
|
| 116 | - return ''; |
|
| 117 | - } |
|
| 115 | + if (!is_string($rempl) || !strlen($rempl)) { |
|
| 116 | + return ''; |
|
| 117 | + } |
|
| 118 | 118 | |
| 119 | - return CollecteurHtmlTag::echappementHtmlBase64((string)$rempl, (string)$source, in_array($mode, ['div', 'span']) ? $mode === 'div' : null); |
|
| 119 | + return CollecteurHtmlTag::echappementHtmlBase64((string)$rempl, (string)$source, in_array($mode, ['div', 'span']) ? $mode === 'div' : null); |
|
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | |
| 123 | 123 | // Echapper les <html>...</ html> |
| 124 | 124 | function traiter_echap_html_dist($regs, $options = []) { |
| 125 | - return $regs['innerHtml']; |
|
| 125 | + return $regs['innerHtml']; |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | // Echapper les <pre>...</ pre> |
| 129 | 129 | function traiter_echap_pre_dist($regs, $options = []) { |
| 130 | - // echapper les <code> dans <pre> |
|
| 131 | - $pre = $regs['innerHtml']; |
|
| 132 | - |
|
| 133 | - // echapper les < dans <code> |
|
| 134 | - if (str_contains($pre, '<')) { |
|
| 135 | - $collecteurCode = new CollecteurHtmlTag('code'); |
|
| 136 | - $collections = $collecteurCode->collecter($pre); |
|
| 137 | - $collections = array_reverse($collections); |
|
| 138 | - foreach ($collections as $c) { |
|
| 139 | - $code = $c['opening'] . spip_htmlspecialchars($c['innerHtml']) . $c['closing']; |
|
| 140 | - $pre = substr_replace($pre, $code, $c['pos'], $c['length']); |
|
| 141 | - } |
|
| 142 | - } |
|
| 143 | - return "<pre>$pre</pre>"; |
|
| 130 | + // echapper les <code> dans <pre> |
|
| 131 | + $pre = $regs['innerHtml']; |
|
| 132 | + |
|
| 133 | + // echapper les < dans <code> |
|
| 134 | + if (str_contains($pre, '<')) { |
|
| 135 | + $collecteurCode = new CollecteurHtmlTag('code'); |
|
| 136 | + $collections = $collecteurCode->collecter($pre); |
|
| 137 | + $collections = array_reverse($collections); |
|
| 138 | + foreach ($collections as $c) { |
|
| 139 | + $code = $c['opening'] . spip_htmlspecialchars($c['innerHtml']) . $c['closing']; |
|
| 140 | + $pre = substr_replace($pre, $code, $c['pos'], $c['length']); |
|
| 141 | + } |
|
| 142 | + } |
|
| 143 | + return "<pre>$pre</pre>"; |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | // Echapper les <code>...</ code> |
| 147 | 147 | function traiter_echap_code_dist($regs, $options = []) { |
| 148 | - $corps = $regs['innerHtml']; |
|
| 149 | - $att = $regs['attributs']; |
|
| 148 | + $corps = $regs['innerHtml']; |
|
| 149 | + $att = $regs['attributs']; |
|
| 150 | 150 | |
| 151 | - // ne pas mettre le <div...> s'il n'y a qu'une ligne |
|
| 152 | - if (str_contains($corps, "\n")) { |
|
| 153 | - // supprimer les sauts de ligne debut/fin |
|
| 154 | - // (mais pas les espaces => ascii art). |
|
| 155 | - $corps = preg_replace("/^[\n\r]+|[\n\r]+$/s", '', $corps); |
|
| 151 | + // ne pas mettre le <div...> s'il n'y a qu'une ligne |
|
| 152 | + if (str_contains($corps, "\n")) { |
|
| 153 | + // supprimer les sauts de ligne debut/fin |
|
| 154 | + // (mais pas les espaces => ascii art). |
|
| 155 | + $corps = preg_replace("/^[\n\r]+|[\n\r]+$/s", '', $corps); |
|
| 156 | 156 | |
| 157 | - $echap = spip_balisage_code($corps, true, $att); |
|
| 158 | - } else { |
|
| 159 | - $echap = spip_balisage_code($corps, false, $att); |
|
| 160 | - } |
|
| 157 | + $echap = spip_balisage_code($corps, true, $att); |
|
| 158 | + } else { |
|
| 159 | + $echap = spip_balisage_code($corps, false, $att); |
|
| 160 | + } |
|
| 161 | 161 | |
| 162 | - return $echap; |
|
| 162 | + return $echap; |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | // Echapper les <cadre>...</ cadre> aka <frame>...</ frame> |
| 166 | 166 | function traiter_echap_cadre_dist($regs, $options = []) { |
| 167 | - $echap = trim(entites_html($regs['innerHtml'])); |
|
| 168 | - // compter les lignes un peu plus finement qu'avec les \n |
|
| 169 | - $lignes = explode("\n", trim($echap)); |
|
| 170 | - $n = 0; |
|
| 171 | - foreach ($lignes as $l) { |
|
| 172 | - $n += floor(strlen($l) / 60) + 1; |
|
| 173 | - } |
|
| 174 | - $n = max($n, 2); |
|
| 175 | - $echap = "\n<textarea readonly='readonly' cols='40' rows='$n' class='spip_cadre spip_cadre_block' dir='ltr'>$echap</textarea>"; |
|
| 176 | - |
|
| 177 | - return $echap; |
|
| 167 | + $echap = trim(entites_html($regs['innerHtml'])); |
|
| 168 | + // compter les lignes un peu plus finement qu'avec les \n |
|
| 169 | + $lignes = explode("\n", trim($echap)); |
|
| 170 | + $n = 0; |
|
| 171 | + foreach ($lignes as $l) { |
|
| 172 | + $n += floor(strlen($l) / 60) + 1; |
|
| 173 | + } |
|
| 174 | + $n = max($n, 2); |
|
| 175 | + $echap = "\n<textarea readonly='readonly' cols='40' rows='$n' class='spip_cadre spip_cadre_block' dir='ltr'>$echap</textarea>"; |
|
| 176 | + |
|
| 177 | + return $echap; |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | function traiter_echap_frame_dist($regs, $options = []) { |
| 181 | - return traiter_echap_cadre_dist($regs); |
|
| 181 | + return traiter_echap_cadre_dist($regs); |
|
| 182 | 182 | } |
| 183 | 183 | |
| 184 | 184 | function traiter_echap_script_dist($regs, $options = []) { |
| 185 | - // rendre joli (et inactif) si c'est un script language=php |
|
| 186 | - if (strpos($regs['opening'], 'php')) { |
|
| 187 | - return highlight_string($regs['raw'], true); |
|
| 188 | - } |
|
| 185 | + // rendre joli (et inactif) si c'est un script language=php |
|
| 186 | + if (strpos($regs['opening'], 'php')) { |
|
| 187 | + return highlight_string($regs['raw'], true); |
|
| 188 | + } |
|
| 189 | 189 | |
| 190 | - // Cas normal : le script passe tel quel |
|
| 191 | - return $regs['raw']; |
|
| 190 | + // Cas normal : le script passe tel quel |
|
| 191 | + return $regs['raw']; |
|
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | defined('_PROTEGE_BLOCS') || define('_PROTEGE_BLOCS', ',<(' . implode('|', CollecteurHtmlTag::$listeBalisesAProteger) . ')(\b[^>]*)?>(.*)</\1>,UimsS'); |
@@ -207,69 +207,69 @@ discard block |
||
| 207 | 207 | * @return string|string[] |
| 208 | 208 | */ |
| 209 | 209 | function echappe_html( |
| 210 | - $letexte, |
|
| 211 | - $source = '', |
|
| 212 | - $no_transform = false, |
|
| 213 | - $html_tags = null, |
|
| 214 | - $callback_prefix = '', |
|
| 215 | - $callback_options = [] |
|
| 210 | + $letexte, |
|
| 211 | + $source = '', |
|
| 212 | + $no_transform = false, |
|
| 213 | + $html_tags = null, |
|
| 214 | + $callback_prefix = '', |
|
| 215 | + $callback_options = [] |
|
| 216 | 216 | ) { |
| 217 | - if (!is_string($letexte) || !strlen($letexte)) { |
|
| 218 | - return $letexte; |
|
| 219 | - } |
|
| 220 | - |
|
| 221 | - if ($no_transform !== false) { |
|
| 222 | - trigger_deprecation('spip', '5.0', 'Using "%s" arg is deprecated, use directly "%s" instead.', '$no_transform', 'Spip\Texte\Collecteur\HtmlTag::proteger_balisesHtml', __FUNCTION__); |
|
| 223 | - } |
|
| 224 | - |
|
| 225 | - // appels legacy avec un '' |
|
| 226 | - if (empty($html_tags)) { |
|
| 227 | - $html_tags = null; |
|
| 228 | - } |
|
| 229 | - |
|
| 230 | - // legacy : les appels fournissaient une preg pour repérer les balises HTML |
|
| 231 | - if ($html_tags && !is_array($html_tags)) { |
|
| 232 | - trigger_deprecation('spip', '5.0', 'Using a preg for "%s" arg is deprecated, use a tag array instead.', '$html_tags', __FUNCTION__); |
|
| 233 | - $t = explode(')', $html_tags, 2); |
|
| 234 | - $t = reset($t); |
|
| 235 | - $t = explode('(', $t, 2); |
|
| 236 | - $t = end($t); |
|
| 237 | - $html_tags = explode('|', $t); |
|
| 238 | - } |
|
| 239 | - |
|
| 240 | - $callbacks = []; |
|
| 241 | - if (!$no_transform) { |
|
| 242 | - $callback_secure_prefix = ($callback_options['secure_prefix'] ?? ''); |
|
| 243 | - foreach ($html_tags ?: CollecteurHtmlTag::$listeBalisesAProteger as $tag) { |
|
| 244 | - if ( |
|
| 245 | - function_exists($f = $callback_prefix . $callback_secure_prefix . 'traiter_echap_' . $tag) |
|
| 246 | - || function_exists($f = $f . '_dist') |
|
| 247 | - || $callback_secure_prefix && ( |
|
| 248 | - function_exists($f = $callback_prefix . 'traiter_echap_' . $tag) |
|
| 249 | - || function_exists($f = $f . '_dist') |
|
| 250 | - ) |
|
| 251 | - ) { |
|
| 252 | - $callbacks[$tag] = $f; |
|
| 253 | - } |
|
| 254 | - } |
|
| 255 | - } |
|
| 256 | - |
|
| 257 | - $letexte = CollecteurHtmlTag::proteger_balisesHtml($letexte, $source, $html_tags, $callbacks, $callback_options); |
|
| 258 | - |
|
| 259 | - if ($no_transform) { |
|
| 260 | - return $letexte; |
|
| 261 | - } |
|
| 262 | - |
|
| 263 | - // Echapper le php pour faire joli (ici, c'est pas pour la securite) |
|
| 264 | - // seulement si on a echappe les <script> |
|
| 265 | - // (derogatoire car on ne peut pas faire passer < ? ... ? > |
|
| 266 | - // dans une callback autonommee + la preg pour collecter est un peu spécifique |
|
| 267 | - if (in_array('script', $html_tags ?: CollecteurHtmlTag::$listeBalisesAProteger)) { |
|
| 268 | - $htmlTagCollecteur = new CollecteurHtmlTag('?', '@<[?].*($|[?]>)@UsS', ''); |
|
| 269 | - $letexte = $htmlTagCollecteur->echapper_enHtmlBase64($letexte, $source, fn ($c, $o) => highlight_string($c['raw'], true)); |
|
| 270 | - } |
|
| 271 | - |
|
| 272 | - return $letexte; |
|
| 217 | + if (!is_string($letexte) || !strlen($letexte)) { |
|
| 218 | + return $letexte; |
|
| 219 | + } |
|
| 220 | + |
|
| 221 | + if ($no_transform !== false) { |
|
| 222 | + trigger_deprecation('spip', '5.0', 'Using "%s" arg is deprecated, use directly "%s" instead.', '$no_transform', 'Spip\Texte\Collecteur\HtmlTag::proteger_balisesHtml', __FUNCTION__); |
|
| 223 | + } |
|
| 224 | + |
|
| 225 | + // appels legacy avec un '' |
|
| 226 | + if (empty($html_tags)) { |
|
| 227 | + $html_tags = null; |
|
| 228 | + } |
|
| 229 | + |
|
| 230 | + // legacy : les appels fournissaient une preg pour repérer les balises HTML |
|
| 231 | + if ($html_tags && !is_array($html_tags)) { |
|
| 232 | + trigger_deprecation('spip', '5.0', 'Using a preg for "%s" arg is deprecated, use a tag array instead.', '$html_tags', __FUNCTION__); |
|
| 233 | + $t = explode(')', $html_tags, 2); |
|
| 234 | + $t = reset($t); |
|
| 235 | + $t = explode('(', $t, 2); |
|
| 236 | + $t = end($t); |
|
| 237 | + $html_tags = explode('|', $t); |
|
| 238 | + } |
|
| 239 | + |
|
| 240 | + $callbacks = []; |
|
| 241 | + if (!$no_transform) { |
|
| 242 | + $callback_secure_prefix = ($callback_options['secure_prefix'] ?? ''); |
|
| 243 | + foreach ($html_tags ?: CollecteurHtmlTag::$listeBalisesAProteger as $tag) { |
|
| 244 | + if ( |
|
| 245 | + function_exists($f = $callback_prefix . $callback_secure_prefix . 'traiter_echap_' . $tag) |
|
| 246 | + || function_exists($f = $f . '_dist') |
|
| 247 | + || $callback_secure_prefix && ( |
|
| 248 | + function_exists($f = $callback_prefix . 'traiter_echap_' . $tag) |
|
| 249 | + || function_exists($f = $f . '_dist') |
|
| 250 | + ) |
|
| 251 | + ) { |
|
| 252 | + $callbacks[$tag] = $f; |
|
| 253 | + } |
|
| 254 | + } |
|
| 255 | + } |
|
| 256 | + |
|
| 257 | + $letexte = CollecteurHtmlTag::proteger_balisesHtml($letexte, $source, $html_tags, $callbacks, $callback_options); |
|
| 258 | + |
|
| 259 | + if ($no_transform) { |
|
| 260 | + return $letexte; |
|
| 261 | + } |
|
| 262 | + |
|
| 263 | + // Echapper le php pour faire joli (ici, c'est pas pour la securite) |
|
| 264 | + // seulement si on a echappe les <script> |
|
| 265 | + // (derogatoire car on ne peut pas faire passer < ? ... ? > |
|
| 266 | + // dans une callback autonommee + la preg pour collecter est un peu spécifique |
|
| 267 | + if (in_array('script', $html_tags ?: CollecteurHtmlTag::$listeBalisesAProteger)) { |
|
| 268 | + $htmlTagCollecteur = new CollecteurHtmlTag('?', '@<[?].*($|[?]>)@UsS', ''); |
|
| 269 | + $letexte = $htmlTagCollecteur->echapper_enHtmlBase64($letexte, $source, fn ($c, $o) => highlight_string($c['raw'], true)); |
|
| 270 | + } |
|
| 271 | + |
|
| 272 | + return $letexte; |
|
| 273 | 273 | } |
| 274 | 274 | |
| 275 | 275 | /** |
@@ -283,27 +283,27 @@ discard block |
||
| 283 | 283 | * @return array|mixed|string|string[] |
| 284 | 284 | */ |
| 285 | 285 | function echappe_retour($letexte, $source = '', $filtre = '') { |
| 286 | - if (!is_string($letexte) || !strlen($letexte)) { |
|
| 287 | - return $letexte; |
|
| 288 | - } |
|
| 289 | - return CollecteurHtmlTag::retablir_depuisHtmlBase64((string)$letexte, (string)$source, (string)$filtre); |
|
| 286 | + if (!is_string($letexte) || !strlen($letexte)) { |
|
| 287 | + return $letexte; |
|
| 288 | + } |
|
| 289 | + return CollecteurHtmlTag::retablir_depuisHtmlBase64((string)$letexte, (string)$source, (string)$filtre); |
|
| 290 | 290 | } |
| 291 | 291 | |
| 292 | 292 | // Reinserer le javascript de confiance (venant des modeles) |
| 293 | 293 | |
| 294 | 294 | function echappe_retour_modeles($letexte, $interdire_scripts = false) { |
| 295 | - if (!is_string($letexte) || !strlen($letexte)) { |
|
| 296 | - return $letexte; |
|
| 297 | - } |
|
| 298 | - $letexte = CollecteurHtmlTag::retablir_depuisHtmlBase64((string)$letexte); |
|
| 299 | - |
|
| 300 | - // Dans les appels directs hors squelette, securiser aussi ici |
|
| 301 | - // c'est interdire_scripts() qui rétablit les scripts des modeles echappés avec _PROTEGE_JS_MODELES et _PROTEGE_PHP_MODELES |
|
| 302 | - if ($interdire_scripts) { |
|
| 303 | - $letexte = interdire_scripts($letexte); |
|
| 304 | - } |
|
| 305 | - |
|
| 306 | - return trim($letexte); |
|
| 295 | + if (!is_string($letexte) || !strlen($letexte)) { |
|
| 296 | + return $letexte; |
|
| 297 | + } |
|
| 298 | + $letexte = CollecteurHtmlTag::retablir_depuisHtmlBase64((string)$letexte); |
|
| 299 | + |
|
| 300 | + // Dans les appels directs hors squelette, securiser aussi ici |
|
| 301 | + // c'est interdire_scripts() qui rétablit les scripts des modeles echappés avec _PROTEGE_JS_MODELES et _PROTEGE_PHP_MODELES |
|
| 302 | + if ($interdire_scripts) { |
|
| 303 | + $letexte = interdire_scripts($letexte); |
|
| 304 | + } |
|
| 305 | + |
|
| 306 | + return trim($letexte); |
|
| 307 | 307 | } |
| 308 | 308 | |
| 309 | 309 | |
@@ -331,129 +331,129 @@ discard block |
||
| 331 | 331 | * texte coupé |
| 332 | 332 | **/ |
| 333 | 333 | function couper($texte, $taille = 50, $suite = null) { |
| 334 | - if ($taille <= 0) { |
|
| 335 | - return ''; |
|
| 336 | - } |
|
| 337 | - $length = spip_strlen($texte); |
|
| 338 | - if (!$length) { |
|
| 339 | - return ''; |
|
| 340 | - } |
|
| 341 | - $offset = 400 + 2 * $taille; |
|
| 342 | - while ( |
|
| 343 | - $offset < $length |
|
| 344 | - && spip_strlen(preg_replace(',<(!--|\w|/)[^>]+>,Uims', '', spip_substr($texte, 0, $offset))) < $taille |
|
| 345 | - ) { |
|
| 346 | - $offset *= 2; |
|
| 347 | - } |
|
| 348 | - if ( |
|
| 349 | - $offset < $length |
|
| 350 | - && ($p_tag_ouvrant = strpos($texte, '<', $offset)) !== null |
|
| 351 | - ) { |
|
| 352 | - $p_tag_fermant = strpos($texte, '>', $offset); |
|
| 353 | - // prolonger la coupe jusqu'au tag fermant suivant eventuel |
|
| 354 | - if ($p_tag_fermant && ($p_tag_fermant < $p_tag_ouvrant)) { |
|
| 355 | - $offset = $p_tag_fermant + 1; |
|
| 356 | - } |
|
| 357 | - } |
|
| 358 | - // éviter de travailler sur 10ko pour extraire 150 caractères |
|
| 359 | - $texte = spip_substr($texte, 0, $offset); |
|
| 360 | - |
|
| 361 | - if (!function_exists('nettoyer_raccourcis_typo')) { |
|
| 362 | - include_spip('inc/lien'); |
|
| 363 | - } |
|
| 364 | - $texte = nettoyer_raccourcis_typo($texte); |
|
| 365 | - |
|
| 366 | - // balises de sauts de ligne et paragraphe |
|
| 367 | - $texte = preg_replace('/<p( [^>]*)?' . '>/', "\r\r", $texte); |
|
| 368 | - $texte = preg_replace('/<br( [^>]*)?' . '>/', "\n", $texte); |
|
| 369 | - |
|
| 370 | - // on repasse les doubles \n en \r que nettoyer_raccourcis_typo() a pu modifier |
|
| 371 | - $texte = str_replace("\n\n", "\r\r", $texte); |
|
| 372 | - |
|
| 373 | - // supprimer les tags |
|
| 374 | - $texte = supprimer_tags($texte); |
|
| 375 | - $texte = trim(str_replace("\n", ' ', $texte)); |
|
| 376 | - |
|
| 377 | - // tester s'il est nécessaire de couper le texte |
|
| 378 | - if (spip_strlen($texte) <= $taille) { |
|
| 379 | - $points = ''; |
|
| 380 | - } else { |
|
| 381 | - // points de suite |
|
| 382 | - if (is_null($suite)) { |
|
| 383 | - $suite = (defined('_COUPER_SUITE') ? _COUPER_SUITE : ' (...)'); |
|
| 384 | - } |
|
| 385 | - $taille_suite = spip_strlen(filtrer_entites($suite)); |
|
| 386 | - |
|
| 387 | - // couper au mot precedent (ou au début de la chaîne si c'est le premier mot) |
|
| 388 | - // on coupe avec un caractère de plus que la taille demandée afin de pouvoir |
|
| 389 | - // détecter si le dernier mot du texte coupé est complet ou non. ce caractère |
|
| 390 | - // excédentaire est ensuite supprimé par l'appel à preg_replace() |
|
| 391 | - $long = spip_substr($texte, 0, max($taille + 1 - $taille_suite, 1)); |
|
| 392 | - $u = $GLOBALS['meta']['pcre_u']; |
|
| 393 | - $court = preg_replace('/(^|([^\s ])[\s ]+)([\s ]|[^\s ]+)?$/D' . $u, "\\2", $long); |
|
| 394 | - $points = $suite; |
|
| 395 | - |
|
| 396 | - // trop court ? ne pas faire de (...) |
|
| 397 | - if (spip_strlen($court) < max(0.75 * $taille, 2)) { |
|
| 398 | - $points = ''; |
|
| 399 | - $long = spip_substr($texte, 0, $taille + 1); |
|
| 400 | - preg_match('/(^|([^\s ])[\s ]+)([\s ]|[^\s ]+)?$/D' . $u, $long, $m); |
|
| 401 | - $texte = preg_replace('/(^|([^\s ])[\s ]+)([\s ]|[^\s ]+)?$/D' . $u, "\\2", $long); |
|
| 402 | - // encore trop court ? couper au caractere |
|
| 403 | - if (spip_strlen($texte) < 0.75 * $taille) { |
|
| 404 | - $texte = spip_substr($long, 0, $taille); |
|
| 405 | - } |
|
| 406 | - } else { |
|
| 407 | - $texte = $court; |
|
| 408 | - } |
|
| 409 | - } |
|
| 410 | - |
|
| 411 | - // remettre les paragraphes |
|
| 412 | - $texte = preg_replace("/\r\r+/", "\n\n", $texte); |
|
| 413 | - |
|
| 414 | - // supprimer l'eventuelle entite finale mal coupee |
|
| 415 | - $texte = preg_replace('/&#?[a-z0-9]*$/S', '', $texte); |
|
| 416 | - |
|
| 417 | - return quote_amp(trim($texte)) . $points; |
|
| 334 | + if ($taille <= 0) { |
|
| 335 | + return ''; |
|
| 336 | + } |
|
| 337 | + $length = spip_strlen($texte); |
|
| 338 | + if (!$length) { |
|
| 339 | + return ''; |
|
| 340 | + } |
|
| 341 | + $offset = 400 + 2 * $taille; |
|
| 342 | + while ( |
|
| 343 | + $offset < $length |
|
| 344 | + && spip_strlen(preg_replace(',<(!--|\w|/)[^>]+>,Uims', '', spip_substr($texte, 0, $offset))) < $taille |
|
| 345 | + ) { |
|
| 346 | + $offset *= 2; |
|
| 347 | + } |
|
| 348 | + if ( |
|
| 349 | + $offset < $length |
|
| 350 | + && ($p_tag_ouvrant = strpos($texte, '<', $offset)) !== null |
|
| 351 | + ) { |
|
| 352 | + $p_tag_fermant = strpos($texte, '>', $offset); |
|
| 353 | + // prolonger la coupe jusqu'au tag fermant suivant eventuel |
|
| 354 | + if ($p_tag_fermant && ($p_tag_fermant < $p_tag_ouvrant)) { |
|
| 355 | + $offset = $p_tag_fermant + 1; |
|
| 356 | + } |
|
| 357 | + } |
|
| 358 | + // éviter de travailler sur 10ko pour extraire 150 caractères |
|
| 359 | + $texte = spip_substr($texte, 0, $offset); |
|
| 360 | + |
|
| 361 | + if (!function_exists('nettoyer_raccourcis_typo')) { |
|
| 362 | + include_spip('inc/lien'); |
|
| 363 | + } |
|
| 364 | + $texte = nettoyer_raccourcis_typo($texte); |
|
| 365 | + |
|
| 366 | + // balises de sauts de ligne et paragraphe |
|
| 367 | + $texte = preg_replace('/<p( [^>]*)?' . '>/', "\r\r", $texte); |
|
| 368 | + $texte = preg_replace('/<br( [^>]*)?' . '>/', "\n", $texte); |
|
| 369 | + |
|
| 370 | + // on repasse les doubles \n en \r que nettoyer_raccourcis_typo() a pu modifier |
|
| 371 | + $texte = str_replace("\n\n", "\r\r", $texte); |
|
| 372 | + |
|
| 373 | + // supprimer les tags |
|
| 374 | + $texte = supprimer_tags($texte); |
|
| 375 | + $texte = trim(str_replace("\n", ' ', $texte)); |
|
| 376 | + |
|
| 377 | + // tester s'il est nécessaire de couper le texte |
|
| 378 | + if (spip_strlen($texte) <= $taille) { |
|
| 379 | + $points = ''; |
|
| 380 | + } else { |
|
| 381 | + // points de suite |
|
| 382 | + if (is_null($suite)) { |
|
| 383 | + $suite = (defined('_COUPER_SUITE') ? _COUPER_SUITE : ' (...)'); |
|
| 384 | + } |
|
| 385 | + $taille_suite = spip_strlen(filtrer_entites($suite)); |
|
| 386 | + |
|
| 387 | + // couper au mot precedent (ou au début de la chaîne si c'est le premier mot) |
|
| 388 | + // on coupe avec un caractère de plus que la taille demandée afin de pouvoir |
|
| 389 | + // détecter si le dernier mot du texte coupé est complet ou non. ce caractère |
|
| 390 | + // excédentaire est ensuite supprimé par l'appel à preg_replace() |
|
| 391 | + $long = spip_substr($texte, 0, max($taille + 1 - $taille_suite, 1)); |
|
| 392 | + $u = $GLOBALS['meta']['pcre_u']; |
|
| 393 | + $court = preg_replace('/(^|([^\s ])[\s ]+)([\s ]|[^\s ]+)?$/D' . $u, "\\2", $long); |
|
| 394 | + $points = $suite; |
|
| 395 | + |
|
| 396 | + // trop court ? ne pas faire de (...) |
|
| 397 | + if (spip_strlen($court) < max(0.75 * $taille, 2)) { |
|
| 398 | + $points = ''; |
|
| 399 | + $long = spip_substr($texte, 0, $taille + 1); |
|
| 400 | + preg_match('/(^|([^\s ])[\s ]+)([\s ]|[^\s ]+)?$/D' . $u, $long, $m); |
|
| 401 | + $texte = preg_replace('/(^|([^\s ])[\s ]+)([\s ]|[^\s ]+)?$/D' . $u, "\\2", $long); |
|
| 402 | + // encore trop court ? couper au caractere |
|
| 403 | + if (spip_strlen($texte) < 0.75 * $taille) { |
|
| 404 | + $texte = spip_substr($long, 0, $taille); |
|
| 405 | + } |
|
| 406 | + } else { |
|
| 407 | + $texte = $court; |
|
| 408 | + } |
|
| 409 | + } |
|
| 410 | + |
|
| 411 | + // remettre les paragraphes |
|
| 412 | + $texte = preg_replace("/\r\r+/", "\n\n", $texte); |
|
| 413 | + |
|
| 414 | + // supprimer l'eventuelle entite finale mal coupee |
|
| 415 | + $texte = preg_replace('/&#?[a-z0-9]*$/S', '', $texte); |
|
| 416 | + |
|
| 417 | + return quote_amp(trim($texte)) . $points; |
|
| 418 | 418 | } |
| 419 | 419 | |
| 420 | 420 | |
| 421 | 421 | function protege_js_modeles($texte) { |
| 422 | - if (isset($GLOBALS['visiteur_session']) && str_contains($texte, '<')) { |
|
| 423 | - $tags = [ |
|
| 424 | - 'javascript' => ['tag' => 'script', 'preg' => ',<script.*?($|</script.),isS', 'c' => '_PROTEGE_JS_MODELES'], |
|
| 425 | - 'php' => ['tag' => '?php', 'preg' => ',<\?php.*?($|\?' . '>),isS', 'c' => '_PROTEGE_PHP_MODELES'], |
|
| 426 | - ]; |
|
| 427 | - foreach ($tags as $k => $t) { |
|
| 428 | - if (stripos($texte, '<' . $t['tag']) !== false) { |
|
| 429 | - if (!defined($t['c'])) { |
|
| 430 | - include_spip('inc/acces'); |
|
| 431 | - define($t['c'], creer_uniqid()); |
|
| 432 | - } |
|
| 433 | - $collecteurHtmlTag = new CollecteurHtmlTag($t['tag'], $t['preg'], ''); |
|
| 434 | - $texte = $collecteurHtmlTag->echapper_enHtmlBase64($texte, $k . constant($t['c'])); |
|
| 435 | - } |
|
| 436 | - } |
|
| 437 | - } |
|
| 438 | - return $texte; |
|
| 422 | + if (isset($GLOBALS['visiteur_session']) && str_contains($texte, '<')) { |
|
| 423 | + $tags = [ |
|
| 424 | + 'javascript' => ['tag' => 'script', 'preg' => ',<script.*?($|</script.),isS', 'c' => '_PROTEGE_JS_MODELES'], |
|
| 425 | + 'php' => ['tag' => '?php', 'preg' => ',<\?php.*?($|\?' . '>),isS', 'c' => '_PROTEGE_PHP_MODELES'], |
|
| 426 | + ]; |
|
| 427 | + foreach ($tags as $k => $t) { |
|
| 428 | + if (stripos($texte, '<' . $t['tag']) !== false) { |
|
| 429 | + if (!defined($t['c'])) { |
|
| 430 | + include_spip('inc/acces'); |
|
| 431 | + define($t['c'], creer_uniqid()); |
|
| 432 | + } |
|
| 433 | + $collecteurHtmlTag = new CollecteurHtmlTag($t['tag'], $t['preg'], ''); |
|
| 434 | + $texte = $collecteurHtmlTag->echapper_enHtmlBase64($texte, $k . constant($t['c'])); |
|
| 435 | + } |
|
| 436 | + } |
|
| 437 | + } |
|
| 438 | + return $texte; |
|
| 439 | 439 | } |
| 440 | 440 | |
| 441 | 441 | |
| 442 | 442 | function echapper_faux_tags($letexte) { |
| 443 | - if (!str_contains($letexte, '<')) { |
|
| 444 | - return $letexte; |
|
| 445 | - } |
|
| 446 | - $textMatches = preg_split(',(</?[a-z!][^<>]*>),', $letexte, -1, PREG_SPLIT_DELIM_CAPTURE); |
|
| 447 | - |
|
| 448 | - $letexte = ''; |
|
| 449 | - while (is_countable($textMatches) ? count($textMatches) : 0) { |
|
| 450 | - // un texte a echapper |
|
| 451 | - $letexte .= str_replace('<', '<', array_shift($textMatches)); |
|
| 452 | - // un tag html qui a servit a faite le split |
|
| 453 | - $letexte .= array_shift($textMatches); |
|
| 454 | - } |
|
| 455 | - |
|
| 456 | - return $letexte; |
|
| 443 | + if (!str_contains($letexte, '<')) { |
|
| 444 | + return $letexte; |
|
| 445 | + } |
|
| 446 | + $textMatches = preg_split(',(</?[a-z!][^<>]*>),', $letexte, -1, PREG_SPLIT_DELIM_CAPTURE); |
|
| 447 | + |
|
| 448 | + $letexte = ''; |
|
| 449 | + while (is_countable($textMatches) ? count($textMatches) : 0) { |
|
| 450 | + // un texte a echapper |
|
| 451 | + $letexte .= str_replace('<', '<', array_shift($textMatches)); |
|
| 452 | + // un tag html qui a servit a faite le split |
|
| 453 | + $letexte .= array_shift($textMatches); |
|
| 454 | + } |
|
| 455 | + |
|
| 456 | + return $letexte; |
|
| 457 | 457 | } |
| 458 | 458 | |
| 459 | 459 | /** |
@@ -473,107 +473,107 @@ discard block |
||
| 473 | 473 | * @return string |
| 474 | 474 | */ |
| 475 | 475 | function echapper_html_suspect($texte, $options = [], $connect = null, $env = []) { |
| 476 | - static $echapper_html_suspect; |
|
| 477 | - if (!$texte || !is_string($texte)) { |
|
| 478 | - return $texte; |
|
| 479 | - } |
|
| 480 | - |
|
| 481 | - if (!isset($echapper_html_suspect)) { |
|
| 482 | - $echapper_html_suspect = charger_fonction('echapper_html_suspect', 'inc', true); |
|
| 483 | - } |
|
| 484 | - // si fonction personalisee, on delegue |
|
| 485 | - if ($echapper_html_suspect) { |
|
| 486 | - // on collecte le tableau d'arg minimal pour ne pas casser un appel a une fonction inc_echapper_html_suspect() selon l'ancienne signature |
|
| 487 | - $args = [$texte, $options]; |
|
| 488 | - if ($connect || !empty($env)) { |
|
| 489 | - $args[] = $connect; |
|
| 490 | - } |
|
| 491 | - if (!empty($env)) { |
|
| 492 | - $args[] = $env; |
|
| 493 | - } |
|
| 494 | - return $echapper_html_suspect(...$args); |
|
| 495 | - } |
|
| 496 | - |
|
| 497 | - if (is_bool($options)) { |
|
| 498 | - $options = ['strict' => $options]; |
|
| 499 | - } |
|
| 500 | - $strict = $options['strict'] ?? true; |
|
| 501 | - |
|
| 502 | - // pas de balise html ou pas d'attribut sur les balises ? c'est OK |
|
| 503 | - if ( |
|
| 504 | - !str_contains($texte, '<') |
|
| 505 | - || !str_contains($texte, '=') |
|
| 506 | - ) { |
|
| 507 | - return $texte; |
|
| 508 | - } |
|
| 509 | - |
|
| 510 | - // dans le prive, on veut afficher tout echappé pour la moderation |
|
| 511 | - if (!isset($env['espace_prive'])) { |
|
| 512 | - // conserver le comportement historique en cas d'appel court sans env |
|
| 513 | - $env['espace_prive'] = test_espace_prive(); |
|
| 514 | - } |
|
| 515 | - if (!empty($env['espace_prive']) || !empty($env['wysiwyg'])) { |
|
| 516 | - // quand c'est du texte qui passe par propre on est plus coulant tant qu'il y a pas d'attribut du type onxxx= |
|
| 517 | - // car sinon on declenche sur les modeles ou ressources |
|
| 518 | - if ( |
|
| 519 | - !$strict && (!str_contains($texte, 'on') || !preg_match(",<\w+.*\bon\w+\s*=,UimsS", $texte)) |
|
| 520 | - ) { |
|
| 521 | - return $texte; |
|
| 522 | - } |
|
| 523 | - |
|
| 524 | - $collecteurModeles = new CollecteurModeles(); |
|
| 525 | - $texte = $collecteurModeles->echapper($texte); |
|
| 526 | - $texte = echappe_js($texte); |
|
| 527 | - |
|
| 528 | - $texte_to_check = $texte; |
|
| 529 | - // si les raccourcis liens vont etre interprétés, il faut les expanser avant de vérifier que le html est safe |
|
| 530 | - // car un raccourci peut etre utilisé pour faire un lien malin |
|
| 531 | - // et un raccourci est potentiellement modifié par safehtml, ce qui fait un faux positif dans is_html_safe |
|
| 532 | - if (!empty($options['expanser_liens'])) { |
|
| 533 | - $texte_to_check = expanser_liens($texte_to_check, $connect, $env); |
|
| 534 | - } |
|
| 535 | - if (!is_html_safe($texte_to_check)) { |
|
| 536 | - $texte = $options['texte_source_affiche'] ?? $texte; |
|
| 537 | - $texte = preg_replace(",<(/?\w+\b[^>]*>),", "<tt><\\1</tt>", $texte); |
|
| 538 | - $texte = str_replace('<', '<', $texte); |
|
| 539 | - $texte = str_replace('<tt>', '<tt>', $texte); |
|
| 540 | - $texte = str_replace('</tt>', '</tt>', $texte); |
|
| 541 | - if (!function_exists('attribut_html')) { |
|
| 542 | - include_spip('inc/filtres'); |
|
| 543 | - } |
|
| 544 | - if (!empty($options['wrap_suspect'])) { |
|
| 545 | - $texte = wrap($texte, $options['wrap_suspect']); |
|
| 546 | - } |
|
| 547 | - $texte = "<mark class='danger-js' title='" . attribut_html(_T('erreur_contenu_suspect')) . "'>⚠️</mark> " . $texte; |
|
| 548 | - } |
|
| 549 | - |
|
| 550 | - $texte = $collecteurModeles->retablir($texte); |
|
| 551 | - } |
|
| 552 | - |
|
| 553 | - // si on est là dans le public c'est le mode parano |
|
| 554 | - // on veut donc un rendu propre et secure, et virer silencieusement ce qui est dangereux |
|
| 555 | - else { |
|
| 556 | - $collecteurLiens = $collecteurModeles = null; |
|
| 557 | - if (!empty($options['expanser_liens'])) { |
|
| 558 | - $texte = expanser_liens($texte, $connect, $env); |
|
| 559 | - } |
|
| 560 | - else { |
|
| 561 | - $collecteurLiens = new CollecteurLiens(); |
|
| 562 | - $texte = $collecteurLiens->echapper($texte, ['sanitize_callback' => 'safehtml']); |
|
| 563 | - |
|
| 564 | - $collecteurModeles = new CollecteurModeles(); |
|
| 565 | - $texte = $collecteurModeles->echapper($texte); |
|
| 566 | - } |
|
| 567 | - $texte = safehtml($texte); |
|
| 568 | - if ($collecteurModeles) { |
|
| 569 | - $texte = $collecteurModeles->retablir($texte); |
|
| 570 | - } |
|
| 571 | - if ($collecteurLiens) { |
|
| 572 | - $texte = $collecteurLiens->retablir($texte); |
|
| 573 | - } |
|
| 574 | - } |
|
| 575 | - |
|
| 576 | - return $texte; |
|
| 476 | + static $echapper_html_suspect; |
|
| 477 | + if (!$texte || !is_string($texte)) { |
|
| 478 | + return $texte; |
|
| 479 | + } |
|
| 480 | + |
|
| 481 | + if (!isset($echapper_html_suspect)) { |
|
| 482 | + $echapper_html_suspect = charger_fonction('echapper_html_suspect', 'inc', true); |
|
| 483 | + } |
|
| 484 | + // si fonction personalisee, on delegue |
|
| 485 | + if ($echapper_html_suspect) { |
|
| 486 | + // on collecte le tableau d'arg minimal pour ne pas casser un appel a une fonction inc_echapper_html_suspect() selon l'ancienne signature |
|
| 487 | + $args = [$texte, $options]; |
|
| 488 | + if ($connect || !empty($env)) { |
|
| 489 | + $args[] = $connect; |
|
| 490 | + } |
|
| 491 | + if (!empty($env)) { |
|
| 492 | + $args[] = $env; |
|
| 493 | + } |
|
| 494 | + return $echapper_html_suspect(...$args); |
|
| 495 | + } |
|
| 496 | + |
|
| 497 | + if (is_bool($options)) { |
|
| 498 | + $options = ['strict' => $options]; |
|
| 499 | + } |
|
| 500 | + $strict = $options['strict'] ?? true; |
|
| 501 | + |
|
| 502 | + // pas de balise html ou pas d'attribut sur les balises ? c'est OK |
|
| 503 | + if ( |
|
| 504 | + !str_contains($texte, '<') |
|
| 505 | + || !str_contains($texte, '=') |
|
| 506 | + ) { |
|
| 507 | + return $texte; |
|
| 508 | + } |
|
| 509 | + |
|
| 510 | + // dans le prive, on veut afficher tout echappé pour la moderation |
|
| 511 | + if (!isset($env['espace_prive'])) { |
|
| 512 | + // conserver le comportement historique en cas d'appel court sans env |
|
| 513 | + $env['espace_prive'] = test_espace_prive(); |
|
| 514 | + } |
|
| 515 | + if (!empty($env['espace_prive']) || !empty($env['wysiwyg'])) { |
|
| 516 | + // quand c'est du texte qui passe par propre on est plus coulant tant qu'il y a pas d'attribut du type onxxx= |
|
| 517 | + // car sinon on declenche sur les modeles ou ressources |
|
| 518 | + if ( |
|
| 519 | + !$strict && (!str_contains($texte, 'on') || !preg_match(",<\w+.*\bon\w+\s*=,UimsS", $texte)) |
|
| 520 | + ) { |
|
| 521 | + return $texte; |
|
| 522 | + } |
|
| 523 | + |
|
| 524 | + $collecteurModeles = new CollecteurModeles(); |
|
| 525 | + $texte = $collecteurModeles->echapper($texte); |
|
| 526 | + $texte = echappe_js($texte); |
|
| 527 | + |
|
| 528 | + $texte_to_check = $texte; |
|
| 529 | + // si les raccourcis liens vont etre interprétés, il faut les expanser avant de vérifier que le html est safe |
|
| 530 | + // car un raccourci peut etre utilisé pour faire un lien malin |
|
| 531 | + // et un raccourci est potentiellement modifié par safehtml, ce qui fait un faux positif dans is_html_safe |
|
| 532 | + if (!empty($options['expanser_liens'])) { |
|
| 533 | + $texte_to_check = expanser_liens($texte_to_check, $connect, $env); |
|
| 534 | + } |
|
| 535 | + if (!is_html_safe($texte_to_check)) { |
|
| 536 | + $texte = $options['texte_source_affiche'] ?? $texte; |
|
| 537 | + $texte = preg_replace(",<(/?\w+\b[^>]*>),", "<tt><\\1</tt>", $texte); |
|
| 538 | + $texte = str_replace('<', '<', $texte); |
|
| 539 | + $texte = str_replace('<tt>', '<tt>', $texte); |
|
| 540 | + $texte = str_replace('</tt>', '</tt>', $texte); |
|
| 541 | + if (!function_exists('attribut_html')) { |
|
| 542 | + include_spip('inc/filtres'); |
|
| 543 | + } |
|
| 544 | + if (!empty($options['wrap_suspect'])) { |
|
| 545 | + $texte = wrap($texte, $options['wrap_suspect']); |
|
| 546 | + } |
|
| 547 | + $texte = "<mark class='danger-js' title='" . attribut_html(_T('erreur_contenu_suspect')) . "'>⚠️</mark> " . $texte; |
|
| 548 | + } |
|
| 549 | + |
|
| 550 | + $texte = $collecteurModeles->retablir($texte); |
|
| 551 | + } |
|
| 552 | + |
|
| 553 | + // si on est là dans le public c'est le mode parano |
|
| 554 | + // on veut donc un rendu propre et secure, et virer silencieusement ce qui est dangereux |
|
| 555 | + else { |
|
| 556 | + $collecteurLiens = $collecteurModeles = null; |
|
| 557 | + if (!empty($options['expanser_liens'])) { |
|
| 558 | + $texte = expanser_liens($texte, $connect, $env); |
|
| 559 | + } |
|
| 560 | + else { |
|
| 561 | + $collecteurLiens = new CollecteurLiens(); |
|
| 562 | + $texte = $collecteurLiens->echapper($texte, ['sanitize_callback' => 'safehtml']); |
|
| 563 | + |
|
| 564 | + $collecteurModeles = new CollecteurModeles(); |
|
| 565 | + $texte = $collecteurModeles->echapper($texte); |
|
| 566 | + } |
|
| 567 | + $texte = safehtml($texte); |
|
| 568 | + if ($collecteurModeles) { |
|
| 569 | + $texte = $collecteurModeles->retablir($texte); |
|
| 570 | + } |
|
| 571 | + if ($collecteurLiens) { |
|
| 572 | + $texte = $collecteurLiens->retablir($texte); |
|
| 573 | + } |
|
| 574 | + } |
|
| 575 | + |
|
| 576 | + return $texte; |
|
| 577 | 577 | } |
| 578 | 578 | |
| 579 | 579 | |
@@ -594,48 +594,48 @@ discard block |
||
| 594 | 594 | * texte sécurisé |
| 595 | 595 | **/ |
| 596 | 596 | function safehtml($t) { |
| 597 | - static $safehtml; |
|
| 598 | - |
|
| 599 | - if (!$t || !is_string($t)) { |
|
| 600 | - return $t; |
|
| 601 | - } |
|
| 602 | - # attention safehtml nettoie deux ou trois caracteres de plus. A voir |
|
| 603 | - if (!str_contains($t, '<')) { |
|
| 604 | - return str_replace("\x00", '', $t); |
|
| 605 | - } |
|
| 606 | - |
|
| 607 | - $collecteurIdiomes = null; |
|
| 608 | - if (stripos($t, '<:') !== false) { |
|
| 609 | - $collecteurIdiomes = new CollecteurIdiomes(); |
|
| 610 | - $t = $collecteurIdiomes->echapper($t); |
|
| 611 | - } |
|
| 612 | - $collecteurMultis = null; |
|
| 613 | - if (stripos($t, '<multi') !== false) { |
|
| 614 | - $collecteurMultis = new CollecteurMultis(); |
|
| 615 | - $t = $collecteurMultis->echapper($t, ['sanitize_callback' => 'safehtml']); |
|
| 616 | - } |
|
| 617 | - |
|
| 618 | - if (!function_exists('interdire_scripts')) { |
|
| 619 | - include_spip('inc/texte'); |
|
| 620 | - } |
|
| 621 | - $t = interdire_scripts($t); // jolifier le php |
|
| 622 | - $t = echappe_js($t); |
|
| 623 | - |
|
| 624 | - if (!isset($safehtml)) { |
|
| 625 | - $safehtml = charger_fonction('safehtml', 'inc', true); |
|
| 626 | - } |
|
| 627 | - if ($safehtml) { |
|
| 628 | - $t = $safehtml($t); |
|
| 629 | - } |
|
| 630 | - |
|
| 631 | - if ($collecteurMultis) { |
|
| 632 | - $t = $collecteurMultis->retablir($t); |
|
| 633 | - } |
|
| 634 | - if ($collecteurIdiomes) { |
|
| 635 | - $t = $collecteurIdiomes->retablir($t); |
|
| 636 | - } |
|
| 637 | - |
|
| 638 | - return interdire_scripts($t); // interdire le php (2 precautions) |
|
| 597 | + static $safehtml; |
|
| 598 | + |
|
| 599 | + if (!$t || !is_string($t)) { |
|
| 600 | + return $t; |
|
| 601 | + } |
|
| 602 | + # attention safehtml nettoie deux ou trois caracteres de plus. A voir |
|
| 603 | + if (!str_contains($t, '<')) { |
|
| 604 | + return str_replace("\x00", '', $t); |
|
| 605 | + } |
|
| 606 | + |
|
| 607 | + $collecteurIdiomes = null; |
|
| 608 | + if (stripos($t, '<:') !== false) { |
|
| 609 | + $collecteurIdiomes = new CollecteurIdiomes(); |
|
| 610 | + $t = $collecteurIdiomes->echapper($t); |
|
| 611 | + } |
|
| 612 | + $collecteurMultis = null; |
|
| 613 | + if (stripos($t, '<multi') !== false) { |
|
| 614 | + $collecteurMultis = new CollecteurMultis(); |
|
| 615 | + $t = $collecteurMultis->echapper($t, ['sanitize_callback' => 'safehtml']); |
|
| 616 | + } |
|
| 617 | + |
|
| 618 | + if (!function_exists('interdire_scripts')) { |
|
| 619 | + include_spip('inc/texte'); |
|
| 620 | + } |
|
| 621 | + $t = interdire_scripts($t); // jolifier le php |
|
| 622 | + $t = echappe_js($t); |
|
| 623 | + |
|
| 624 | + if (!isset($safehtml)) { |
|
| 625 | + $safehtml = charger_fonction('safehtml', 'inc', true); |
|
| 626 | + } |
|
| 627 | + if ($safehtml) { |
|
| 628 | + $t = $safehtml($t); |
|
| 629 | + } |
|
| 630 | + |
|
| 631 | + if ($collecteurMultis) { |
|
| 632 | + $t = $collecteurMultis->retablir($t); |
|
| 633 | + } |
|
| 634 | + if ($collecteurIdiomes) { |
|
| 635 | + $t = $collecteurIdiomes->retablir($t); |
|
| 636 | + } |
|
| 637 | + |
|
| 638 | + return interdire_scripts($t); // interdire le php (2 precautions) |
|
| 639 | 639 | } |
| 640 | 640 | |
| 641 | 641 | |
@@ -643,29 +643,29 @@ discard block |
||
| 643 | 643 | * Detecter si un texte est "safe" ie non modifie significativement par safehtml() |
| 644 | 644 | */ |
| 645 | 645 | function is_html_safe(string $texte): bool { |
| 646 | - if ($is_html_safe = charger_fonction('is_html_safe', 'inc', true)) { |
|
| 647 | - return $is_html_safe($texte); |
|
| 648 | - } |
|
| 649 | - |
|
| 650 | - // simplifier les retour ligne pour etre certain de ce que l'on compare |
|
| 651 | - $texte = str_replace("\r\n", "\n", $texte); |
|
| 652 | - // safehtml reduit aussi potentiellement les |
|
| 653 | - $texte = str_replace(' ', ' ', $texte); |
|
| 654 | - // safehtml remplace les entités html |
|
| 655 | - if (str_contains($texte, '&') && str_contains($texte, ';')) { |
|
| 656 | - $texte = html2unicode($texte, true); |
|
| 657 | - } |
|
| 658 | - // safehtml remplace les entités numériques |
|
| 659 | - if (str_contains($texte, '&#')) { |
|
| 660 | - $texte = unicode2charset($texte); |
|
| 661 | - } |
|
| 662 | - |
|
| 663 | - $texte_safe = safehtml($texte); |
|
| 664 | - |
|
| 665 | - // on teste sur strlen car safehtml supprime le contenu dangereux |
|
| 666 | - // mais il peut aussi changer des ' en " sur les attributs html, |
|
| 667 | - // donc un test d'egalite est trop strict |
|
| 668 | - return strlen($texte_safe) === strlen($texte); |
|
| 646 | + if ($is_html_safe = charger_fonction('is_html_safe', 'inc', true)) { |
|
| 647 | + return $is_html_safe($texte); |
|
| 648 | + } |
|
| 649 | + |
|
| 650 | + // simplifier les retour ligne pour etre certain de ce que l'on compare |
|
| 651 | + $texte = str_replace("\r\n", "\n", $texte); |
|
| 652 | + // safehtml reduit aussi potentiellement les |
|
| 653 | + $texte = str_replace(' ', ' ', $texte); |
|
| 654 | + // safehtml remplace les entités html |
|
| 655 | + if (str_contains($texte, '&') && str_contains($texte, ';')) { |
|
| 656 | + $texte = html2unicode($texte, true); |
|
| 657 | + } |
|
| 658 | + // safehtml remplace les entités numériques |
|
| 659 | + if (str_contains($texte, '&#')) { |
|
| 660 | + $texte = unicode2charset($texte); |
|
| 661 | + } |
|
| 662 | + |
|
| 663 | + $texte_safe = safehtml($texte); |
|
| 664 | + |
|
| 665 | + // on teste sur strlen car safehtml supprime le contenu dangereux |
|
| 666 | + // mais il peut aussi changer des ' en " sur les attributs html, |
|
| 667 | + // donc un test d'egalite est trop strict |
|
| 668 | + return strlen($texte_safe) === strlen($texte); |
|
| 669 | 669 | } |
| 670 | 670 | |
| 671 | 671 | /** |
@@ -686,13 +686,13 @@ discard block |
||
| 686 | 686 | * texte sans les modèles d'image |
| 687 | 687 | **/ |
| 688 | 688 | function supprime_img($letexte, $message = null) { |
| 689 | - if ($message === null) { |
|
| 690 | - $message = '(' . _T('img_indisponible') . ')'; |
|
| 691 | - } |
|
| 692 | - |
|
| 693 | - return preg_replace( |
|
| 694 | - ',<(img|doc|emb)([0-9]+)(\|([^>]*))?' . '\s*/?' . '>,i', |
|
| 695 | - $message, |
|
| 696 | - $letexte |
|
| 697 | - ); |
|
| 689 | + if ($message === null) { |
|
| 690 | + $message = '(' . _T('img_indisponible') . ')'; |
|
| 691 | + } |
|
| 692 | + |
|
| 693 | + return preg_replace( |
|
| 694 | + ',<(img|doc|emb)([0-9]+)(\|([^>]*))?' . '\s*/?' . '>,i', |
|
| 695 | + $message, |
|
| 696 | + $letexte |
|
| 697 | + ); |
|
| 698 | 698 | } |
@@ -556,8 +556,7 @@ |
||
| 556 | 556 | $collecteurLiens = $collecteurModeles = null; |
| 557 | 557 | if (!empty($options['expanser_liens'])) { |
| 558 | 558 | $texte = expanser_liens($texte, $connect, $env); |
| 559 | - } |
|
| 560 | - else { |
|
| 559 | + } else { |
|
| 561 | 560 | $collecteurLiens = new CollecteurLiens(); |
| 562 | 561 | $texte = $collecteurLiens->echapper($texte, ['sanitize_callback' => 'safehtml']); |
| 563 | 562 | |
@@ -10,53 +10,53 @@ |
||
| 10 | 10 | \***************************************************************************/ |
| 11 | 11 | |
| 12 | 12 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 13 | - return; |
|
| 13 | + return; |
|
| 14 | 14 | } |
| 15 | 15 | include_spip('inc/charsets'); |
| 16 | 16 | include_spip('inc/texte'); |
| 17 | 17 | include_spip('plugins/afficher_plugin'); |
| 18 | 18 | |
| 19 | 19 | function plugins_afficher_nom_plugin_dist( |
| 20 | - $url_page, |
|
| 21 | - $plug_file, |
|
| 22 | - $checked, |
|
| 23 | - $actif, |
|
| 24 | - $expose = false, |
|
| 25 | - $class_li = 'item', |
|
| 26 | - $dir_plugins = _DIR_PLUGINS |
|
| 20 | + $url_page, |
|
| 21 | + $plug_file, |
|
| 22 | + $checked, |
|
| 23 | + $actif, |
|
| 24 | + $expose = false, |
|
| 25 | + $class_li = 'item', |
|
| 26 | + $dir_plugins = _DIR_PLUGINS |
|
| 27 | 27 | ) { |
| 28 | - static $versions = []; |
|
| 29 | - |
|
| 30 | - $erreur = false; |
|
| 31 | - $s = ''; |
|
| 32 | - |
|
| 33 | - $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 34 | - $info = $get_infos($plug_file, false, $dir_plugins); |
|
| 35 | - |
|
| 36 | - // numerotons les occurences d'un meme prefix |
|
| 37 | - $versions[$info['prefix']] ??= 0; |
|
| 38 | - $versions[$info['prefix']]++; |
|
| 39 | - $id = $info['prefix'] . $versions[$info['prefix']]; |
|
| 40 | - |
|
| 41 | - $class = $class_li; |
|
| 42 | - $class .= $actif ? ' actif' : ''; |
|
| 43 | - $class .= $expose ? ' on' : ''; |
|
| 44 | - $erreur = isset($info['erreur']); |
|
| 45 | - if ($erreur) { |
|
| 46 | - $class .= ' error'; |
|
| 47 | - } |
|
| 48 | - $s .= "<li id='$id' class='$class'>"; |
|
| 49 | - |
|
| 50 | - // Cartouche Resume |
|
| 51 | - $s .= "<div class='resume'>"; |
|
| 52 | - $s .= "<strong class='nom'>" . typo($info['nom']) . '</strong>'; |
|
| 53 | - $s .= " <span class='version'>" . $info['version'] . '</span>'; |
|
| 54 | - $s .= " <span class='etat'> - " . plugin_etat_en_clair($info['etat']) . '</span>'; |
|
| 55 | - $s .= '</div>'; |
|
| 56 | - |
|
| 57 | - if ($erreur) { |
|
| 58 | - $s .= "<div class='erreur'>" . implode('<br >', $info['erreur']) . '</div>'; |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - return $s . '</li>'; |
|
| 28 | + static $versions = []; |
|
| 29 | + |
|
| 30 | + $erreur = false; |
|
| 31 | + $s = ''; |
|
| 32 | + |
|
| 33 | + $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 34 | + $info = $get_infos($plug_file, false, $dir_plugins); |
|
| 35 | + |
|
| 36 | + // numerotons les occurences d'un meme prefix |
|
| 37 | + $versions[$info['prefix']] ??= 0; |
|
| 38 | + $versions[$info['prefix']]++; |
|
| 39 | + $id = $info['prefix'] . $versions[$info['prefix']]; |
|
| 40 | + |
|
| 41 | + $class = $class_li; |
|
| 42 | + $class .= $actif ? ' actif' : ''; |
|
| 43 | + $class .= $expose ? ' on' : ''; |
|
| 44 | + $erreur = isset($info['erreur']); |
|
| 45 | + if ($erreur) { |
|
| 46 | + $class .= ' error'; |
|
| 47 | + } |
|
| 48 | + $s .= "<li id='$id' class='$class'>"; |
|
| 49 | + |
|
| 50 | + // Cartouche Resume |
|
| 51 | + $s .= "<div class='resume'>"; |
|
| 52 | + $s .= "<strong class='nom'>" . typo($info['nom']) . '</strong>'; |
|
| 53 | + $s .= " <span class='version'>" . $info['version'] . '</span>'; |
|
| 54 | + $s .= " <span class='etat'> - " . plugin_etat_en_clair($info['etat']) . '</span>'; |
|
| 55 | + $s .= '</div>'; |
|
| 56 | + |
|
| 57 | + if ($erreur) { |
|
| 58 | + $s .= "<div class='erreur'>" . implode('<br >', $info['erreur']) . '</div>'; |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + return $s . '</li>'; |
|
| 62 | 62 | } |
@@ -36,7 +36,7 @@ discard block |
||
| 36 | 36 | // numerotons les occurences d'un meme prefix |
| 37 | 37 | $versions[$info['prefix']] ??= 0; |
| 38 | 38 | $versions[$info['prefix']]++; |
| 39 | - $id = $info['prefix'] . $versions[$info['prefix']]; |
|
| 39 | + $id = $info['prefix'].$versions[$info['prefix']]; |
|
| 40 | 40 | |
| 41 | 41 | $class = $class_li; |
| 42 | 42 | $class .= $actif ? ' actif' : ''; |
@@ -49,14 +49,14 @@ discard block |
||
| 49 | 49 | |
| 50 | 50 | // Cartouche Resume |
| 51 | 51 | $s .= "<div class='resume'>"; |
| 52 | - $s .= "<strong class='nom'>" . typo($info['nom']) . '</strong>'; |
|
| 53 | - $s .= " <span class='version'>" . $info['version'] . '</span>'; |
|
| 54 | - $s .= " <span class='etat'> - " . plugin_etat_en_clair($info['etat']) . '</span>'; |
|
| 52 | + $s .= "<strong class='nom'>".typo($info['nom']).'</strong>'; |
|
| 53 | + $s .= " <span class='version'>".$info['version'].'</span>'; |
|
| 54 | + $s .= " <span class='etat'> - ".plugin_etat_en_clair($info['etat']).'</span>'; |
|
| 55 | 55 | $s .= '</div>'; |
| 56 | 56 | |
| 57 | 57 | if ($erreur) { |
| 58 | - $s .= "<div class='erreur'>" . implode('<br >', $info['erreur']) . '</div>'; |
|
| 58 | + $s .= "<div class='erreur'>".implode('<br >', $info['erreur']).'</div>'; |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - return $s . '</li>'; |
|
| 61 | + return $s.'</li>'; |
|
| 62 | 62 | } |
@@ -16,212 +16,212 @@ discard block |
||
| 16 | 16 | **/ |
| 17 | 17 | |
| 18 | 18 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 19 | - return; |
|
| 19 | + return; |
|
| 20 | 20 | } |
| 21 | 21 | include_spip('inc/charsets'); |
| 22 | 22 | include_spip('inc/texte'); |
| 23 | 23 | include_spip('inc/plugin'); // pour plugin_est_installe |
| 24 | 24 | |
| 25 | 25 | function plugins_afficher_plugin_dist( |
| 26 | - $url_page, |
|
| 27 | - $plug_file, |
|
| 28 | - $checked, |
|
| 29 | - $actif, |
|
| 30 | - $expose = false, |
|
| 31 | - $class_li = 'item', |
|
| 32 | - $dir_plugins = _DIR_PLUGINS |
|
| 26 | + $url_page, |
|
| 27 | + $plug_file, |
|
| 28 | + $checked, |
|
| 29 | + $actif, |
|
| 30 | + $expose = false, |
|
| 31 | + $class_li = 'item', |
|
| 32 | + $dir_plugins = _DIR_PLUGINS |
|
| 33 | 33 | ) { |
| 34 | 34 | |
| 35 | - static $id_input = 0; |
|
| 36 | - static $versions = []; |
|
| 37 | - |
|
| 38 | - $force_reload = (_request('var_mode') == 'recalcul'); |
|
| 39 | - $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 40 | - $info = $get_infos($plug_file, $force_reload, $dir_plugins); |
|
| 41 | - $prefix = $info['prefix']; |
|
| 42 | - $cfg = ''; |
|
| 43 | - $checkable = ($dir_plugins !== _DIR_PLUGINS_DIST); |
|
| 44 | - $nom = plugin_nom($info, $dir_plugins, $plug_file); |
|
| 45 | - $erreur = ''; |
|
| 46 | - |
|
| 47 | - if (!plugin_version_compatible($info['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) { |
|
| 48 | - $info['slogan'] = _T('plugin_info_non_compatible_spip'); |
|
| 49 | - $erreur = http_img_pack( |
|
| 50 | - 'plugin-dis-32.png', |
|
| 51 | - _T('plugin_info_non_compatible_spip'), |
|
| 52 | - " class='picto_err'", |
|
| 53 | - _T('plugin_info_non_compatible_spip') |
|
| 54 | - ); |
|
| 55 | - $class_li .= ' disabled'; |
|
| 56 | - $checkable = false; |
|
| 57 | - } elseif (isset($info['erreur'])) { |
|
| 58 | - $class_li .= ' error'; |
|
| 59 | - $erreur = http_img_pack( |
|
| 60 | - 'plugin-err-32.png', |
|
| 61 | - _T('plugin_info_erreur_xml'), |
|
| 62 | - " class='picto_err'", |
|
| 63 | - _T('plugin_info_erreur_xml') |
|
| 64 | - ) |
|
| 65 | - . "<div class='erreur'>" . join('<br >', $info['erreur']) . '</div>'; |
|
| 66 | - $checkable = false; |
|
| 67 | - } elseif (isset($GLOBALS['erreurs_activation_raw'][$dir_plugins . $plug_file])) { |
|
| 68 | - $class_li .= ' error'; |
|
| 69 | - $erreur = http_img_pack( |
|
| 70 | - 'plugin-err-32.png', |
|
| 71 | - _T('plugin_impossible_activer', ['plugin' => $nom]), |
|
| 72 | - " class='picto_err'", |
|
| 73 | - _T('plugin_impossible_activer', ['plugin' => $nom]) |
|
| 74 | - ) |
|
| 75 | - . "<div class='erreur'>" . implode( |
|
| 76 | - '<br />', |
|
| 77 | - $GLOBALS['erreurs_activation_raw'][$dir_plugins . $plug_file] |
|
| 78 | - ) . '</div>'; |
|
| 79 | - } else { |
|
| 80 | - $cfg = $actif ? plugin_bouton_config($plug_file, $info, $dir_plugins) : ''; |
|
| 81 | - if (defined('_DEV_VERSION_SPIP_COMPAT') && !plugin_version_compatible($info['compatibilite'], $GLOBALS['spip_version_branche'])) { |
|
| 82 | - //$info['slogan'] = _T('plugin_info_non_compatible_spip'); |
|
| 83 | - $erreur = http_img_pack( |
|
| 84 | - 'plugin-dis-32.png', |
|
| 85 | - _T('plugin_info_non_compatible_spip'), |
|
| 86 | - " class='picto_err picto_compat_forcee'", |
|
| 87 | - _L('Version incompatible : compatibilité forcée') |
|
| 88 | - ); |
|
| 89 | - } |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - // numerotons les occurrences d'un meme prefix |
|
| 93 | - $versions[$prefix] = $id = isset($versions[$prefix]) ? intval($versions[$prefix]) + 1 : ''; |
|
| 94 | - |
|
| 95 | - $class_li .= ($actif ? ' actif' : '') . ($expose ? ' on' : ''); |
|
| 96 | - |
|
| 97 | - return "<li id='$prefix$id' class='$class_li'>" |
|
| 98 | - . ((!$checkable && !$checked) |
|
| 99 | - ? '' : plugin_checkbox(++$id_input, $dir_plugins . $plug_file, $checked)) |
|
| 100 | - . plugin_resume($info, $dir_plugins, $plug_file, $url_page) |
|
| 101 | - . $cfg |
|
| 102 | - . $erreur |
|
| 103 | - . (($dir_plugins !== _DIR_PLUGINS_DIST && plugin_est_installe($plug_file)) |
|
| 104 | - ? plugin_desintalle($plug_file, $nom, $dir_plugins) : '') |
|
| 105 | - . "<div class='details'>" // pour l'ajax de exec/info_plugin |
|
| 106 | - . (!$expose ? '' : affiche_bloc_plugin($plug_file, $info, $dir_plugins)) |
|
| 107 | - . '</div>' |
|
| 108 | - . '</li>'; |
|
| 35 | + static $id_input = 0; |
|
| 36 | + static $versions = []; |
|
| 37 | + |
|
| 38 | + $force_reload = (_request('var_mode') == 'recalcul'); |
|
| 39 | + $get_infos = charger_fonction('get_infos', 'plugins'); |
|
| 40 | + $info = $get_infos($plug_file, $force_reload, $dir_plugins); |
|
| 41 | + $prefix = $info['prefix']; |
|
| 42 | + $cfg = ''; |
|
| 43 | + $checkable = ($dir_plugins !== _DIR_PLUGINS_DIST); |
|
| 44 | + $nom = plugin_nom($info, $dir_plugins, $plug_file); |
|
| 45 | + $erreur = ''; |
|
| 46 | + |
|
| 47 | + if (!plugin_version_compatible($info['compatibilite'], $GLOBALS['spip_version_branche'], 'spip')) { |
|
| 48 | + $info['slogan'] = _T('plugin_info_non_compatible_spip'); |
|
| 49 | + $erreur = http_img_pack( |
|
| 50 | + 'plugin-dis-32.png', |
|
| 51 | + _T('plugin_info_non_compatible_spip'), |
|
| 52 | + " class='picto_err'", |
|
| 53 | + _T('plugin_info_non_compatible_spip') |
|
| 54 | + ); |
|
| 55 | + $class_li .= ' disabled'; |
|
| 56 | + $checkable = false; |
|
| 57 | + } elseif (isset($info['erreur'])) { |
|
| 58 | + $class_li .= ' error'; |
|
| 59 | + $erreur = http_img_pack( |
|
| 60 | + 'plugin-err-32.png', |
|
| 61 | + _T('plugin_info_erreur_xml'), |
|
| 62 | + " class='picto_err'", |
|
| 63 | + _T('plugin_info_erreur_xml') |
|
| 64 | + ) |
|
| 65 | + . "<div class='erreur'>" . join('<br >', $info['erreur']) . '</div>'; |
|
| 66 | + $checkable = false; |
|
| 67 | + } elseif (isset($GLOBALS['erreurs_activation_raw'][$dir_plugins . $plug_file])) { |
|
| 68 | + $class_li .= ' error'; |
|
| 69 | + $erreur = http_img_pack( |
|
| 70 | + 'plugin-err-32.png', |
|
| 71 | + _T('plugin_impossible_activer', ['plugin' => $nom]), |
|
| 72 | + " class='picto_err'", |
|
| 73 | + _T('plugin_impossible_activer', ['plugin' => $nom]) |
|
| 74 | + ) |
|
| 75 | + . "<div class='erreur'>" . implode( |
|
| 76 | + '<br />', |
|
| 77 | + $GLOBALS['erreurs_activation_raw'][$dir_plugins . $plug_file] |
|
| 78 | + ) . '</div>'; |
|
| 79 | + } else { |
|
| 80 | + $cfg = $actif ? plugin_bouton_config($plug_file, $info, $dir_plugins) : ''; |
|
| 81 | + if (defined('_DEV_VERSION_SPIP_COMPAT') && !plugin_version_compatible($info['compatibilite'], $GLOBALS['spip_version_branche'])) { |
|
| 82 | + //$info['slogan'] = _T('plugin_info_non_compatible_spip'); |
|
| 83 | + $erreur = http_img_pack( |
|
| 84 | + 'plugin-dis-32.png', |
|
| 85 | + _T('plugin_info_non_compatible_spip'), |
|
| 86 | + " class='picto_err picto_compat_forcee'", |
|
| 87 | + _L('Version incompatible : compatibilité forcée') |
|
| 88 | + ); |
|
| 89 | + } |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + // numerotons les occurrences d'un meme prefix |
|
| 93 | + $versions[$prefix] = $id = isset($versions[$prefix]) ? intval($versions[$prefix]) + 1 : ''; |
|
| 94 | + |
|
| 95 | + $class_li .= ($actif ? ' actif' : '') . ($expose ? ' on' : ''); |
|
| 96 | + |
|
| 97 | + return "<li id='$prefix$id' class='$class_li'>" |
|
| 98 | + . ((!$checkable && !$checked) |
|
| 99 | + ? '' : plugin_checkbox(++$id_input, $dir_plugins . $plug_file, $checked)) |
|
| 100 | + . plugin_resume($info, $dir_plugins, $plug_file, $url_page) |
|
| 101 | + . $cfg |
|
| 102 | + . $erreur |
|
| 103 | + . (($dir_plugins !== _DIR_PLUGINS_DIST && plugin_est_installe($plug_file)) |
|
| 104 | + ? plugin_desintalle($plug_file, $nom, $dir_plugins) : '') |
|
| 105 | + . "<div class='details'>" // pour l'ajax de exec/info_plugin |
|
| 106 | + . (!$expose ? '' : affiche_bloc_plugin($plug_file, $info, $dir_plugins)) |
|
| 107 | + . '</div>' |
|
| 108 | + . '</li>'; |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | 111 | function plugin_bouton_config($nom, $infos, $dir) { |
| 112 | - // la verification se base sur le filesystem |
|
| 113 | - // il faut donc n'utiliser que des minuscules, par convention |
|
| 114 | - $prefix = strtolower($infos['prefix']); |
|
| 115 | - // si paquet.xml fournit un squelette, le prendre |
|
| 116 | - if (isset($infos['config']) && $infos['config']) { |
|
| 117 | - return recuperer_fond( |
|
| 118 | - "$dir$nom/" . $infos['config'], |
|
| 119 | - [ |
|
| 120 | - 'script' => 'configurer_' . $prefix, |
|
| 121 | - 'nom' => $nom |
|
| 122 | - ] |
|
| 123 | - ); |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - // sinon prendre le squelette std sur le nom std |
|
| 127 | - return recuperer_fond( |
|
| 128 | - 'prive/squelettes/inclure/cfg', |
|
| 129 | - [ |
|
| 130 | - 'script' => 'configurer_' . $prefix, |
|
| 131 | - 'nom' => $nom |
|
| 132 | - ] |
|
| 133 | - ); |
|
| 112 | + // la verification se base sur le filesystem |
|
| 113 | + // il faut donc n'utiliser que des minuscules, par convention |
|
| 114 | + $prefix = strtolower($infos['prefix']); |
|
| 115 | + // si paquet.xml fournit un squelette, le prendre |
|
| 116 | + if (isset($infos['config']) && $infos['config']) { |
|
| 117 | + return recuperer_fond( |
|
| 118 | + "$dir$nom/" . $infos['config'], |
|
| 119 | + [ |
|
| 120 | + 'script' => 'configurer_' . $prefix, |
|
| 121 | + 'nom' => $nom |
|
| 122 | + ] |
|
| 123 | + ); |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + // sinon prendre le squelette std sur le nom std |
|
| 127 | + return recuperer_fond( |
|
| 128 | + 'prive/squelettes/inclure/cfg', |
|
| 129 | + [ |
|
| 130 | + 'script' => 'configurer_' . $prefix, |
|
| 131 | + 'nom' => $nom |
|
| 132 | + ] |
|
| 133 | + ); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | // checkbox pour activer ou desactiver |
| 137 | 137 | // si ce n'est pas une extension |
| 138 | 138 | |
| 139 | 139 | function plugin_checkbox($id_input, $file, $actif) { |
| 140 | - $name = substr(md5($file), 0, 16); |
|
| 141 | - |
|
| 142 | - return "<div class='check'>\n" |
|
| 143 | - . "<input type='checkbox' name='s$name' id='label_$id_input'" |
|
| 144 | - . ($actif ? " checked='checked'" : '') |
|
| 145 | - . " class='checkbox' value='O' />" |
|
| 146 | - . "\n<label for='label_$id_input'>" . _T('activer_plugin') . '</label>' |
|
| 147 | - . '</div>'; |
|
| 140 | + $name = substr(md5($file), 0, 16); |
|
| 141 | + |
|
| 142 | + return "<div class='check'>\n" |
|
| 143 | + . "<input type='checkbox' name='s$name' id='label_$id_input'" |
|
| 144 | + . ($actif ? " checked='checked'" : '') |
|
| 145 | + . " class='checkbox' value='O' />" |
|
| 146 | + . "\n<label for='label_$id_input'>" . _T('activer_plugin') . '</label>' |
|
| 147 | + . '</div>'; |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | function plugin_nom($info, $dir_plugins, $plug_file) { |
| 151 | - $prefix = $info['prefix']; |
|
| 152 | - $dir = "$dir_plugins$plug_file"; |
|
| 153 | - // Si dtd paquet, on traite le nom soit par son item de langue soit par sa valeur immediate a l'index "nom" |
|
| 154 | - if ($info['dtd'] == 'paquet') { |
|
| 155 | - $nom = plugin_typo("{$prefix}_nom", "$dir/lang/paquet-$prefix"); |
|
| 156 | - if (!$nom) { |
|
| 157 | - $nom = typo($info['nom']); |
|
| 158 | - } |
|
| 159 | - } else { |
|
| 160 | - $nom = typo(attribut_html($info['nom'])); |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - return trim($nom); |
|
| 151 | + $prefix = $info['prefix']; |
|
| 152 | + $dir = "$dir_plugins$plug_file"; |
|
| 153 | + // Si dtd paquet, on traite le nom soit par son item de langue soit par sa valeur immediate a l'index "nom" |
|
| 154 | + if ($info['dtd'] == 'paquet') { |
|
| 155 | + $nom = plugin_typo("{$prefix}_nom", "$dir/lang/paquet-$prefix"); |
|
| 156 | + if (!$nom) { |
|
| 157 | + $nom = typo($info['nom']); |
|
| 158 | + } |
|
| 159 | + } else { |
|
| 160 | + $nom = typo(attribut_html($info['nom'])); |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + return trim($nom); |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | // Cartouche Resume |
| 167 | 167 | function plugin_resume($info, $dir_plugins, $plug_file, $url_page) { |
| 168 | - $prefix = $info['prefix']; |
|
| 169 | - $dir = "$dir_plugins$plug_file"; |
|
| 170 | - $slogan = PtoBR(plugin_propre($info['slogan'], "$dir/lang/paquet-$prefix")); |
|
| 171 | - // une seule ligne dans le slogan : couper si besoin |
|
| 172 | - if (($p = strpos($slogan, '<br />')) !== false) { |
|
| 173 | - $slogan = substr($slogan, 0, $p); |
|
| 174 | - } |
|
| 175 | - // couper par securite |
|
| 176 | - $slogan = couper($slogan, 80); |
|
| 177 | - |
|
| 178 | - $nom = plugin_nom($info, $dir_plugins, $plug_file); |
|
| 179 | - |
|
| 180 | - $url = parametre_url($url_page, 'plugin', substr($dir, strlen(_DIR_RACINE))); |
|
| 181 | - |
|
| 182 | - $icon_class = 'icon'; |
|
| 183 | - $img = ''; |
|
| 184 | - if (isset($info['logo']) && ($i = trim($info['logo']))) { |
|
| 185 | - $img = http_img_pack("$dir/$i", '', " width='32' height='32'", '', ['variante_svg_si_possible' => true, 'chemin_image' => false]); |
|
| 186 | - if (!extraire_attribut($img, 'src')) { |
|
| 187 | - $img = ''; |
|
| 188 | - } |
|
| 189 | - } |
|
| 190 | - if (!$img) { |
|
| 191 | - $img = http_img_pack('plugin-xx.svg', '', " width='32' height='32'"); |
|
| 192 | - $icon_class .= ' no-logo'; |
|
| 193 | - } |
|
| 194 | - |
|
| 195 | - $i = "<div class='$icon_class'><a href='$url' rel='info'>$img</a></div>"; |
|
| 196 | - |
|
| 197 | - return "<div class='resume'>" |
|
| 198 | - . "<h3><a href='$url' rel='info'>" |
|
| 199 | - . $nom |
|
| 200 | - . '</a></h3>' |
|
| 201 | - . " <span class='version'>" . $info['version'] . '</span>' |
|
| 202 | - . " <span class='etat'> - " |
|
| 203 | - . plugin_etat_en_clair($info['etat']) |
|
| 204 | - . '</span>' |
|
| 205 | - . "<div class='short'>" . $slogan . '</div>' |
|
| 206 | - . $i |
|
| 207 | - . '</div>'; |
|
| 168 | + $prefix = $info['prefix']; |
|
| 169 | + $dir = "$dir_plugins$plug_file"; |
|
| 170 | + $slogan = PtoBR(plugin_propre($info['slogan'], "$dir/lang/paquet-$prefix")); |
|
| 171 | + // une seule ligne dans le slogan : couper si besoin |
|
| 172 | + if (($p = strpos($slogan, '<br />')) !== false) { |
|
| 173 | + $slogan = substr($slogan, 0, $p); |
|
| 174 | + } |
|
| 175 | + // couper par securite |
|
| 176 | + $slogan = couper($slogan, 80); |
|
| 177 | + |
|
| 178 | + $nom = plugin_nom($info, $dir_plugins, $plug_file); |
|
| 179 | + |
|
| 180 | + $url = parametre_url($url_page, 'plugin', substr($dir, strlen(_DIR_RACINE))); |
|
| 181 | + |
|
| 182 | + $icon_class = 'icon'; |
|
| 183 | + $img = ''; |
|
| 184 | + if (isset($info['logo']) && ($i = trim($info['logo']))) { |
|
| 185 | + $img = http_img_pack("$dir/$i", '', " width='32' height='32'", '', ['variante_svg_si_possible' => true, 'chemin_image' => false]); |
|
| 186 | + if (!extraire_attribut($img, 'src')) { |
|
| 187 | + $img = ''; |
|
| 188 | + } |
|
| 189 | + } |
|
| 190 | + if (!$img) { |
|
| 191 | + $img = http_img_pack('plugin-xx.svg', '', " width='32' height='32'"); |
|
| 192 | + $icon_class .= ' no-logo'; |
|
| 193 | + } |
|
| 194 | + |
|
| 195 | + $i = "<div class='$icon_class'><a href='$url' rel='info'>$img</a></div>"; |
|
| 196 | + |
|
| 197 | + return "<div class='resume'>" |
|
| 198 | + . "<h3><a href='$url' rel='info'>" |
|
| 199 | + . $nom |
|
| 200 | + . '</a></h3>' |
|
| 201 | + . " <span class='version'>" . $info['version'] . '</span>' |
|
| 202 | + . " <span class='etat'> - " |
|
| 203 | + . plugin_etat_en_clair($info['etat']) |
|
| 204 | + . '</span>' |
|
| 205 | + . "<div class='short'>" . $slogan . '</div>' |
|
| 206 | + . $i |
|
| 207 | + . '</div>'; |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | 210 | function plugin_desintalle($plug_file, $nom, $dir_plugins = null) { |
| 211 | - if (!$dir_plugins) { |
|
| 212 | - $dir_plugins = _DIR_PLUGINS; |
|
| 213 | - } |
|
| 211 | + if (!$dir_plugins) { |
|
| 212 | + $dir_plugins = _DIR_PLUGINS; |
|
| 213 | + } |
|
| 214 | 214 | |
| 215 | - $action = redirige_action_auteur('desinstaller_plugin', "$dir_plugins::$plug_file", 'admin_plugin'); |
|
| 216 | - $text = _T('bouton_desinstaller'); |
|
| 217 | - $text2 = _T('info_desinstaller_plugin'); |
|
| 218 | - $file = basename($plug_file); |
|
| 215 | + $action = redirige_action_auteur('desinstaller_plugin', "$dir_plugins::$plug_file", 'admin_plugin'); |
|
| 216 | + $text = _T('bouton_desinstaller'); |
|
| 217 | + $text2 = _T('info_desinstaller_plugin'); |
|
| 218 | + $file = basename($plug_file); |
|
| 219 | 219 | |
| 220 | - return "<div class='actions'>[" . |
|
| 221 | - "<a href='$action' |
|
| 220 | + return "<div class='actions'>[" . |
|
| 221 | + "<a href='$action' |
|
| 222 | 222 | onclick='return confirm(\"$text $nom ?\\n$text2\")'>" |
| 223 | - . $text |
|
| 224 | - . '</a>]</div>'; |
|
| 223 | + . $text |
|
| 224 | + . '</a>]</div>'; |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | /** |
@@ -235,143 +235,143 @@ discard block |
||
| 235 | 235 | * Traduction de l'état dans la langue en cours |
| 236 | 236 | **/ |
| 237 | 237 | function plugin_etat_en_clair($etat) { |
| 238 | - if (!in_array($etat, ['stable', 'test', 'experimental'])) { |
|
| 239 | - $etat = 'developpement'; |
|
| 240 | - } |
|
| 238 | + if (!in_array($etat, ['stable', 'test', 'experimental'])) { |
|
| 239 | + $etat = 'developpement'; |
|
| 240 | + } |
|
| 241 | 241 | |
| 242 | - return _T('plugin_etat_' . $etat); |
|
| 242 | + return _T('plugin_etat_' . $etat); |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | function plugin_propre($texte, $module = '', $propre = 'propre') { |
| 246 | - // retirer le retour a la racine du module, car le find_in_path se fait depuis la racine |
|
| 247 | - if (_DIR_RACINE && str_starts_with($module, _DIR_RACINE)) { |
|
| 248 | - $module = substr($module, strlen(_DIR_RACINE)); |
|
| 249 | - } |
|
| 250 | - if (preg_match('|^\w+_[\w_]+$|', $texte)) { |
|
| 251 | - $texte = _T(($module ? "$module:" : '') . $texte, [], ['force' => false]); |
|
| 252 | - } |
|
| 253 | - |
|
| 254 | - return $propre($texte); |
|
| 246 | + // retirer le retour a la racine du module, car le find_in_path se fait depuis la racine |
|
| 247 | + if (_DIR_RACINE && str_starts_with($module, _DIR_RACINE)) { |
|
| 248 | + $module = substr($module, strlen(_DIR_RACINE)); |
|
| 249 | + } |
|
| 250 | + if (preg_match('|^\w+_[\w_]+$|', $texte)) { |
|
| 251 | + $texte = _T(($module ? "$module:" : '') . $texte, [], ['force' => false]); |
|
| 252 | + } |
|
| 253 | + |
|
| 254 | + return $propre($texte); |
|
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | function plugin_typo($texte, $module = '') { |
| 258 | - return plugin_propre($texte, $module, 'typo'); |
|
| 258 | + return plugin_propre($texte, $module, 'typo'); |
|
| 259 | 259 | } |
| 260 | 260 | |
| 261 | 261 | |
| 262 | 262 | function affiche_bloc_plugin($plug_file, $info, $dir_plugins = null) { |
| 263 | - $log = null; |
|
| 264 | - if (!$dir_plugins) { |
|
| 265 | - $dir_plugins = _DIR_PLUGINS; |
|
| 266 | - } |
|
| 267 | - |
|
| 268 | - $prefix = $info['prefix']; |
|
| 269 | - $dir = "$dir_plugins$plug_file/lang/paquet-$prefix"; |
|
| 270 | - |
|
| 271 | - $s = ''; |
|
| 272 | - // TODO: le traiter_multi ici n'est pas beau |
|
| 273 | - // cf. description du plugin/_stable_/ortho/plugin.xml |
|
| 274 | - // concerne les anciens plugin.xml donc on devrait plus en avoir besoin |
|
| 275 | - $description = ''; |
|
| 276 | - if (isset($info['description'])) { |
|
| 277 | - $description = plugin_propre($info['description'], $dir); |
|
| 278 | - } |
|
| 279 | - |
|
| 280 | - if ( |
|
| 281 | - isset($info['documentation']) && ($lien = $info['documentation']) |
|
| 282 | - ) { |
|
| 283 | - $description .= "<p><em class='site'><a href='$lien' class='spip_out'>" . _T('en_savoir_plus') . '</a></em></p>'; |
|
| 284 | - } |
|
| 285 | - $s .= "<dd class='desc'>" . $description . "</dd>\n"; |
|
| 286 | - |
|
| 287 | - if (isset($info['auteur'])) { |
|
| 288 | - if (is_array($info['auteur'])) { |
|
| 289 | - $a = formater_credits($info['auteur'], ', '); |
|
| 290 | - } // pour compat mais ne doit plus arriver |
|
| 291 | - else { |
|
| 292 | - $a = trim($info['auteur']); |
|
| 293 | - } |
|
| 294 | - if ($a) { |
|
| 295 | - $s .= "<dt class='auteurs'>" . _T('public:par_auteur') . "</dt><dd class='auteurs'>" . PtoBR(propre( |
|
| 296 | - $a, |
|
| 297 | - $dir |
|
| 298 | - )) . "</dd>\n"; |
|
| 299 | - } |
|
| 300 | - } |
|
| 301 | - |
|
| 302 | - if (isset($info['credit'])) { |
|
| 303 | - if ($a = formater_credits($info['credit'], ', ')) { |
|
| 304 | - $s .= "<dt class='credits'>" . _T('plugin_info_credit') . "</dt><dd class='credits'>" . PtoBR(propre( |
|
| 305 | - $a, |
|
| 306 | - $dir |
|
| 307 | - )) . "</dd>\n"; |
|
| 308 | - } |
|
| 309 | - } |
|
| 310 | - |
|
| 311 | - if (isset($info['licence'])) { |
|
| 312 | - if (is_array($info['licence'])) { |
|
| 313 | - $a = formater_credits($info['licence'], ', '); |
|
| 314 | - } // pour compat mais ne doit plus arriver |
|
| 315 | - else { |
|
| 316 | - $a = trim($info['licence']); |
|
| 317 | - } |
|
| 318 | - if ($a) { |
|
| 319 | - $s .= "<dt class='licence'>" . _T('intitule_licence') . "</dt><dd class='licence'>" . PtoBR(propre( |
|
| 320 | - $a, |
|
| 321 | - $dir |
|
| 322 | - )) . "</dd>\n"; |
|
| 323 | - } |
|
| 324 | - } |
|
| 325 | - |
|
| 326 | - $s = "<dl class='description'>$s</dl>"; |
|
| 327 | - |
|
| 328 | - // |
|
| 329 | - // Ajouter les infos techniques |
|
| 330 | - // |
|
| 331 | - $infotech = []; |
|
| 332 | - |
|
| 333 | - $version = '<dt>' . _T('version') . '</dt><dd>' . $info['version']; |
|
| 334 | - // Version VCS |
|
| 335 | - if ($vcs = version_vcs_courante($dir_plugins . $plug_file)) { |
|
| 336 | - $version .= ' ' . $vcs; |
|
| 337 | - } |
|
| 338 | - $version .= '</dd>'; |
|
| 339 | - $infotech[] = $version; |
|
| 340 | - $infotech[] = '<dt>' . _T('repertoire_plugins') . '</dt><dd>' . joli_repertoire("$dir_plugins$plug_file") . '</dd>'; |
|
| 341 | - // source zip le cas echeant |
|
| 342 | - $infotech[] = (lire_fichier($dir_plugins . $plug_file . '/install.log', $log) && preg_match(',^source:(.*)$,m', $log, $r)) |
|
| 343 | - ? '<dt>' . _T('plugin_source') . '</dt><dd>' . trim($r[1]) . '</dd>' |
|
| 344 | - : ''; |
|
| 345 | - |
|
| 346 | - $infotech[] = !$info['necessite'] ? '' : |
|
| 347 | - ('<dt>' . _T('plugin_info_necessite') . '</dt><dd>' . join( |
|
| 348 | - ' ', |
|
| 349 | - array_map('array_shift', $info['necessite']) |
|
| 350 | - ) . '</dd>'); |
|
| 351 | - |
|
| 352 | - $s .= "<dl class='tech'>" |
|
| 353 | - . join('', $infotech) |
|
| 354 | - . '</dl>'; |
|
| 355 | - |
|
| 356 | - |
|
| 357 | - return $s; |
|
| 263 | + $log = null; |
|
| 264 | + if (!$dir_plugins) { |
|
| 265 | + $dir_plugins = _DIR_PLUGINS; |
|
| 266 | + } |
|
| 267 | + |
|
| 268 | + $prefix = $info['prefix']; |
|
| 269 | + $dir = "$dir_plugins$plug_file/lang/paquet-$prefix"; |
|
| 270 | + |
|
| 271 | + $s = ''; |
|
| 272 | + // TODO: le traiter_multi ici n'est pas beau |
|
| 273 | + // cf. description du plugin/_stable_/ortho/plugin.xml |
|
| 274 | + // concerne les anciens plugin.xml donc on devrait plus en avoir besoin |
|
| 275 | + $description = ''; |
|
| 276 | + if (isset($info['description'])) { |
|
| 277 | + $description = plugin_propre($info['description'], $dir); |
|
| 278 | + } |
|
| 279 | + |
|
| 280 | + if ( |
|
| 281 | + isset($info['documentation']) && ($lien = $info['documentation']) |
|
| 282 | + ) { |
|
| 283 | + $description .= "<p><em class='site'><a href='$lien' class='spip_out'>" . _T('en_savoir_plus') . '</a></em></p>'; |
|
| 284 | + } |
|
| 285 | + $s .= "<dd class='desc'>" . $description . "</dd>\n"; |
|
| 286 | + |
|
| 287 | + if (isset($info['auteur'])) { |
|
| 288 | + if (is_array($info['auteur'])) { |
|
| 289 | + $a = formater_credits($info['auteur'], ', '); |
|
| 290 | + } // pour compat mais ne doit plus arriver |
|
| 291 | + else { |
|
| 292 | + $a = trim($info['auteur']); |
|
| 293 | + } |
|
| 294 | + if ($a) { |
|
| 295 | + $s .= "<dt class='auteurs'>" . _T('public:par_auteur') . "</dt><dd class='auteurs'>" . PtoBR(propre( |
|
| 296 | + $a, |
|
| 297 | + $dir |
|
| 298 | + )) . "</dd>\n"; |
|
| 299 | + } |
|
| 300 | + } |
|
| 301 | + |
|
| 302 | + if (isset($info['credit'])) { |
|
| 303 | + if ($a = formater_credits($info['credit'], ', ')) { |
|
| 304 | + $s .= "<dt class='credits'>" . _T('plugin_info_credit') . "</dt><dd class='credits'>" . PtoBR(propre( |
|
| 305 | + $a, |
|
| 306 | + $dir |
|
| 307 | + )) . "</dd>\n"; |
|
| 308 | + } |
|
| 309 | + } |
|
| 310 | + |
|
| 311 | + if (isset($info['licence'])) { |
|
| 312 | + if (is_array($info['licence'])) { |
|
| 313 | + $a = formater_credits($info['licence'], ', '); |
|
| 314 | + } // pour compat mais ne doit plus arriver |
|
| 315 | + else { |
|
| 316 | + $a = trim($info['licence']); |
|
| 317 | + } |
|
| 318 | + if ($a) { |
|
| 319 | + $s .= "<dt class='licence'>" . _T('intitule_licence') . "</dt><dd class='licence'>" . PtoBR(propre( |
|
| 320 | + $a, |
|
| 321 | + $dir |
|
| 322 | + )) . "</dd>\n"; |
|
| 323 | + } |
|
| 324 | + } |
|
| 325 | + |
|
| 326 | + $s = "<dl class='description'>$s</dl>"; |
|
| 327 | + |
|
| 328 | + // |
|
| 329 | + // Ajouter les infos techniques |
|
| 330 | + // |
|
| 331 | + $infotech = []; |
|
| 332 | + |
|
| 333 | + $version = '<dt>' . _T('version') . '</dt><dd>' . $info['version']; |
|
| 334 | + // Version VCS |
|
| 335 | + if ($vcs = version_vcs_courante($dir_plugins . $plug_file)) { |
|
| 336 | + $version .= ' ' . $vcs; |
|
| 337 | + } |
|
| 338 | + $version .= '</dd>'; |
|
| 339 | + $infotech[] = $version; |
|
| 340 | + $infotech[] = '<dt>' . _T('repertoire_plugins') . '</dt><dd>' . joli_repertoire("$dir_plugins$plug_file") . '</dd>'; |
|
| 341 | + // source zip le cas echeant |
|
| 342 | + $infotech[] = (lire_fichier($dir_plugins . $plug_file . '/install.log', $log) && preg_match(',^source:(.*)$,m', $log, $r)) |
|
| 343 | + ? '<dt>' . _T('plugin_source') . '</dt><dd>' . trim($r[1]) . '</dd>' |
|
| 344 | + : ''; |
|
| 345 | + |
|
| 346 | + $infotech[] = !$info['necessite'] ? '' : |
|
| 347 | + ('<dt>' . _T('plugin_info_necessite') . '</dt><dd>' . join( |
|
| 348 | + ' ', |
|
| 349 | + array_map('array_shift', $info['necessite']) |
|
| 350 | + ) . '</dd>'); |
|
| 351 | + |
|
| 352 | + $s .= "<dl class='tech'>" |
|
| 353 | + . join('', $infotech) |
|
| 354 | + . '</dl>'; |
|
| 355 | + |
|
| 356 | + |
|
| 357 | + return $s; |
|
| 358 | 358 | } |
| 359 | 359 | |
| 360 | 360 | function formater_credits($infos, $sep = ', ') { |
| 361 | - $texte = ''; |
|
| 362 | - |
|
| 363 | - foreach ($infos as $_credit) { |
|
| 364 | - if ($texte) { |
|
| 365 | - $texte .= $sep; |
|
| 366 | - } |
|
| 367 | - // Si le credit en cours n'est pas un array c'est donc un copyright |
|
| 368 | - $texte .= |
|
| 369 | - (!is_array($_credit)) |
|
| 370 | - ? PtoBR(propre($_credit)) |
|
| 371 | - : ($_credit['url'] ? '<a href="' . $_credit['url'] . '">' : '') . |
|
| 372 | - $_credit['nom'] . |
|
| 373 | - ($_credit['url'] ? '</a>' : ''); |
|
| 374 | - } |
|
| 375 | - |
|
| 376 | - return $texte; |
|
| 361 | + $texte = ''; |
|
| 362 | + |
|
| 363 | + foreach ($infos as $_credit) { |
|
| 364 | + if ($texte) { |
|
| 365 | + $texte .= $sep; |
|
| 366 | + } |
|
| 367 | + // Si le credit en cours n'est pas un array c'est donc un copyright |
|
| 368 | + $texte .= |
|
| 369 | + (!is_array($_credit)) |
|
| 370 | + ? PtoBR(propre($_credit)) |
|
| 371 | + : ($_credit['url'] ? '<a href="' . $_credit['url'] . '">' : '') . |
|
| 372 | + $_credit['nom'] . |
|
| 373 | + ($_credit['url'] ? '</a>' : ''); |
|
| 374 | + } |
|
| 375 | + |
|
| 376 | + return $texte; |
|
| 377 | 377 | } |
@@ -62,9 +62,9 @@ discard block |
||
| 62 | 62 | " class='picto_err'", |
| 63 | 63 | _T('plugin_info_erreur_xml') |
| 64 | 64 | ) |
| 65 | - . "<div class='erreur'>" . join('<br >', $info['erreur']) . '</div>'; |
|
| 65 | + . "<div class='erreur'>".join('<br >', $info['erreur']).'</div>'; |
|
| 66 | 66 | $checkable = false; |
| 67 | - } elseif (isset($GLOBALS['erreurs_activation_raw'][$dir_plugins . $plug_file])) { |
|
| 67 | + } elseif (isset($GLOBALS['erreurs_activation_raw'][$dir_plugins.$plug_file])) { |
|
| 68 | 68 | $class_li .= ' error'; |
| 69 | 69 | $erreur = http_img_pack( |
| 70 | 70 | 'plugin-err-32.png', |
@@ -72,10 +72,10 @@ discard block |
||
| 72 | 72 | " class='picto_err'", |
| 73 | 73 | _T('plugin_impossible_activer', ['plugin' => $nom]) |
| 74 | 74 | ) |
| 75 | - . "<div class='erreur'>" . implode( |
|
| 75 | + . "<div class='erreur'>".implode( |
|
| 76 | 76 | '<br />', |
| 77 | - $GLOBALS['erreurs_activation_raw'][$dir_plugins . $plug_file] |
|
| 78 | - ) . '</div>'; |
|
| 77 | + $GLOBALS['erreurs_activation_raw'][$dir_plugins.$plug_file] |
|
| 78 | + ).'</div>'; |
|
| 79 | 79 | } else { |
| 80 | 80 | $cfg = $actif ? plugin_bouton_config($plug_file, $info, $dir_plugins) : ''; |
| 81 | 81 | if (defined('_DEV_VERSION_SPIP_COMPAT') && !plugin_version_compatible($info['compatibilite'], $GLOBALS['spip_version_branche'])) { |
@@ -92,11 +92,11 @@ discard block |
||
| 92 | 92 | // numerotons les occurrences d'un meme prefix |
| 93 | 93 | $versions[$prefix] = $id = isset($versions[$prefix]) ? intval($versions[$prefix]) + 1 : ''; |
| 94 | 94 | |
| 95 | - $class_li .= ($actif ? ' actif' : '') . ($expose ? ' on' : ''); |
|
| 95 | + $class_li .= ($actif ? ' actif' : '').($expose ? ' on' : ''); |
|
| 96 | 96 | |
| 97 | 97 | return "<li id='$prefix$id' class='$class_li'>" |
| 98 | 98 | . ((!$checkable && !$checked) |
| 99 | - ? '' : plugin_checkbox(++$id_input, $dir_plugins . $plug_file, $checked)) |
|
| 99 | + ? '' : plugin_checkbox(++$id_input, $dir_plugins.$plug_file, $checked)) |
|
| 100 | 100 | . plugin_resume($info, $dir_plugins, $plug_file, $url_page) |
| 101 | 101 | . $cfg |
| 102 | 102 | . $erreur |
@@ -115,9 +115,9 @@ discard block |
||
| 115 | 115 | // si paquet.xml fournit un squelette, le prendre |
| 116 | 116 | if (isset($infos['config']) && $infos['config']) { |
| 117 | 117 | return recuperer_fond( |
| 118 | - "$dir$nom/" . $infos['config'], |
|
| 118 | + "$dir$nom/".$infos['config'], |
|
| 119 | 119 | [ |
| 120 | - 'script' => 'configurer_' . $prefix, |
|
| 120 | + 'script' => 'configurer_'.$prefix, |
|
| 121 | 121 | 'nom' => $nom |
| 122 | 122 | ] |
| 123 | 123 | ); |
@@ -127,7 +127,7 @@ discard block |
||
| 127 | 127 | return recuperer_fond( |
| 128 | 128 | 'prive/squelettes/inclure/cfg', |
| 129 | 129 | [ |
| 130 | - 'script' => 'configurer_' . $prefix, |
|
| 130 | + 'script' => 'configurer_'.$prefix, |
|
| 131 | 131 | 'nom' => $nom |
| 132 | 132 | ] |
| 133 | 133 | ); |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | . "<input type='checkbox' name='s$name' id='label_$id_input'" |
| 144 | 144 | . ($actif ? " checked='checked'" : '') |
| 145 | 145 | . " class='checkbox' value='O' />" |
| 146 | - . "\n<label for='label_$id_input'>" . _T('activer_plugin') . '</label>' |
|
| 146 | + . "\n<label for='label_$id_input'>"._T('activer_plugin').'</label>' |
|
| 147 | 147 | . '</div>'; |
| 148 | 148 | } |
| 149 | 149 | |
@@ -198,11 +198,11 @@ discard block |
||
| 198 | 198 | . "<h3><a href='$url' rel='info'>" |
| 199 | 199 | . $nom |
| 200 | 200 | . '</a></h3>' |
| 201 | - . " <span class='version'>" . $info['version'] . '</span>' |
|
| 201 | + . " <span class='version'>".$info['version'].'</span>' |
|
| 202 | 202 | . " <span class='etat'> - " |
| 203 | 203 | . plugin_etat_en_clair($info['etat']) |
| 204 | 204 | . '</span>' |
| 205 | - . "<div class='short'>" . $slogan . '</div>' |
|
| 205 | + . "<div class='short'>".$slogan.'</div>' |
|
| 206 | 206 | . $i |
| 207 | 207 | . '</div>'; |
| 208 | 208 | } |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | $text2 = _T('info_desinstaller_plugin'); |
| 218 | 218 | $file = basename($plug_file); |
| 219 | 219 | |
| 220 | - return "<div class='actions'>[" . |
|
| 220 | + return "<div class='actions'>[". |
|
| 221 | 221 | "<a href='$action' |
| 222 | 222 | onclick='return confirm(\"$text $nom ?\\n$text2\")'>" |
| 223 | 223 | . $text |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | $etat = 'developpement'; |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | - return _T('plugin_etat_' . $etat); |
|
| 242 | + return _T('plugin_etat_'.$etat); |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | function plugin_propre($texte, $module = '', $propre = 'propre') { |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | $module = substr($module, strlen(_DIR_RACINE)); |
| 249 | 249 | } |
| 250 | 250 | if (preg_match('|^\w+_[\w_]+$|', $texte)) { |
| 251 | - $texte = _T(($module ? "$module:" : '') . $texte, [], ['force' => false]); |
|
| 251 | + $texte = _T(($module ? "$module:" : '').$texte, [], ['force' => false]); |
|
| 252 | 252 | } |
| 253 | 253 | |
| 254 | 254 | return $propre($texte); |
@@ -280,9 +280,9 @@ discard block |
||
| 280 | 280 | if ( |
| 281 | 281 | isset($info['documentation']) && ($lien = $info['documentation']) |
| 282 | 282 | ) { |
| 283 | - $description .= "<p><em class='site'><a href='$lien' class='spip_out'>" . _T('en_savoir_plus') . '</a></em></p>'; |
|
| 283 | + $description .= "<p><em class='site'><a href='$lien' class='spip_out'>"._T('en_savoir_plus').'</a></em></p>'; |
|
| 284 | 284 | } |
| 285 | - $s .= "<dd class='desc'>" . $description . "</dd>\n"; |
|
| 285 | + $s .= "<dd class='desc'>".$description."</dd>\n"; |
|
| 286 | 286 | |
| 287 | 287 | if (isset($info['auteur'])) { |
| 288 | 288 | if (is_array($info['auteur'])) { |
@@ -292,19 +292,19 @@ discard block |
||
| 292 | 292 | $a = trim($info['auteur']); |
| 293 | 293 | } |
| 294 | 294 | if ($a) { |
| 295 | - $s .= "<dt class='auteurs'>" . _T('public:par_auteur') . "</dt><dd class='auteurs'>" . PtoBR(propre( |
|
| 295 | + $s .= "<dt class='auteurs'>"._T('public:par_auteur')."</dt><dd class='auteurs'>".PtoBR(propre( |
|
| 296 | 296 | $a, |
| 297 | 297 | $dir |
| 298 | - )) . "</dd>\n"; |
|
| 298 | + ))."</dd>\n"; |
|
| 299 | 299 | } |
| 300 | 300 | } |
| 301 | 301 | |
| 302 | 302 | if (isset($info['credit'])) { |
| 303 | 303 | if ($a = formater_credits($info['credit'], ', ')) { |
| 304 | - $s .= "<dt class='credits'>" . _T('plugin_info_credit') . "</dt><dd class='credits'>" . PtoBR(propre( |
|
| 304 | + $s .= "<dt class='credits'>"._T('plugin_info_credit')."</dt><dd class='credits'>".PtoBR(propre( |
|
| 305 | 305 | $a, |
| 306 | 306 | $dir |
| 307 | - )) . "</dd>\n"; |
|
| 307 | + ))."</dd>\n"; |
|
| 308 | 308 | } |
| 309 | 309 | } |
| 310 | 310 | |
@@ -316,10 +316,10 @@ discard block |
||
| 316 | 316 | $a = trim($info['licence']); |
| 317 | 317 | } |
| 318 | 318 | if ($a) { |
| 319 | - $s .= "<dt class='licence'>" . _T('intitule_licence') . "</dt><dd class='licence'>" . PtoBR(propre( |
|
| 319 | + $s .= "<dt class='licence'>"._T('intitule_licence')."</dt><dd class='licence'>".PtoBR(propre( |
|
| 320 | 320 | $a, |
| 321 | 321 | $dir |
| 322 | - )) . "</dd>\n"; |
|
| 322 | + ))."</dd>\n"; |
|
| 323 | 323 | } |
| 324 | 324 | } |
| 325 | 325 | |
@@ -330,24 +330,23 @@ discard block |
||
| 330 | 330 | // |
| 331 | 331 | $infotech = []; |
| 332 | 332 | |
| 333 | - $version = '<dt>' . _T('version') . '</dt><dd>' . $info['version']; |
|
| 333 | + $version = '<dt>'._T('version').'</dt><dd>'.$info['version']; |
|
| 334 | 334 | // Version VCS |
| 335 | - if ($vcs = version_vcs_courante($dir_plugins . $plug_file)) { |
|
| 336 | - $version .= ' ' . $vcs; |
|
| 335 | + if ($vcs = version_vcs_courante($dir_plugins.$plug_file)) { |
|
| 336 | + $version .= ' '.$vcs; |
|
| 337 | 337 | } |
| 338 | 338 | $version .= '</dd>'; |
| 339 | 339 | $infotech[] = $version; |
| 340 | - $infotech[] = '<dt>' . _T('repertoire_plugins') . '</dt><dd>' . joli_repertoire("$dir_plugins$plug_file") . '</dd>'; |
|
| 340 | + $infotech[] = '<dt>'._T('repertoire_plugins').'</dt><dd>'.joli_repertoire("$dir_plugins$plug_file").'</dd>'; |
|
| 341 | 341 | // source zip le cas echeant |
| 342 | - $infotech[] = (lire_fichier($dir_plugins . $plug_file . '/install.log', $log) && preg_match(',^source:(.*)$,m', $log, $r)) |
|
| 343 | - ? '<dt>' . _T('plugin_source') . '</dt><dd>' . trim($r[1]) . '</dd>' |
|
| 342 | + $infotech[] = (lire_fichier($dir_plugins.$plug_file.'/install.log', $log) && preg_match(',^source:(.*)$,m', $log, $r)) |
|
| 343 | + ? '<dt>'._T('plugin_source').'</dt><dd>'.trim($r[1]).'</dd>' |
|
| 344 | 344 | : ''; |
| 345 | 345 | |
| 346 | - $infotech[] = !$info['necessite'] ? '' : |
|
| 347 | - ('<dt>' . _T('plugin_info_necessite') . '</dt><dd>' . join( |
|
| 346 | + $infotech[] = !$info['necessite'] ? '' : ('<dt>'._T('plugin_info_necessite').'</dt><dd>'.join( |
|
| 348 | 347 | ' ', |
| 349 | 348 | array_map('array_shift', $info['necessite']) |
| 350 | - ) . '</dd>'); |
|
| 349 | + ).'</dd>'); |
|
| 351 | 350 | |
| 352 | 351 | $s .= "<dl class='tech'>" |
| 353 | 352 | . join('', $infotech) |
@@ -368,8 +367,8 @@ discard block |
||
| 368 | 367 | $texte .= |
| 369 | 368 | (!is_array($_credit)) |
| 370 | 369 | ? PtoBR(propre($_credit)) |
| 371 | - : ($_credit['url'] ? '<a href="' . $_credit['url'] . '">' : '') . |
|
| 372 | - $_credit['nom'] . |
|
| 370 | + : ($_credit['url'] ? '<a href="'.$_credit['url'].'">' : ''). |
|
| 371 | + $_credit['nom']. |
|
| 373 | 372 | ($_credit['url'] ? '</a>' : ''); |
| 374 | 373 | } |
| 375 | 374 | |
@@ -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 | /** |
@@ -36,45 +36,45 @@ discard block |
||
| 36 | 36 | */ |
| 37 | 37 | function install_etape_1_dist() { |
| 38 | 38 | |
| 39 | - $minipage = new Installation(); |
|
| 40 | - echo $minipage->installDebutPage(); |
|
| 39 | + $minipage = new Installation(); |
|
| 40 | + echo $minipage->installDebutPage(); |
|
| 41 | 41 | |
| 42 | - // stopper en cas de grosse incompatibilite de l'hebergement |
|
| 43 | - tester_compatibilite_hebergement(); |
|
| 42 | + // stopper en cas de grosse incompatibilite de l'hebergement |
|
| 43 | + tester_compatibilite_hebergement(); |
|
| 44 | 44 | |
| 45 | - // Recuperer les anciennes donnees pour plus de facilite (si presentes) |
|
| 46 | - $s = @is_readable(_FILE_CONNECT_TMP) ? analyse_fichier_connection(_FILE_CONNECT_TMP) : ''; |
|
| 45 | + // Recuperer les anciennes donnees pour plus de facilite (si presentes) |
|
| 46 | + $s = @is_readable(_FILE_CONNECT_TMP) ? analyse_fichier_connection(_FILE_CONNECT_TMP) : ''; |
|
| 47 | 47 | |
| 48 | - [$adresse_db, $login_db] = $s ?: ['localhost', '']; |
|
| 48 | + [$adresse_db, $login_db] = $s ?: ['localhost', '']; |
|
| 49 | 49 | |
| 50 | - $chmod = (isset($_GET['chmod']) && preg_match(',^\d+$,', (string) $_GET['chmod'])) ? |
|
| 51 | - sprintf('%04o', $_GET['chmod']) : '0777'; |
|
| 50 | + $chmod = (isset($_GET['chmod']) && preg_match(',^\d+$,', (string) $_GET['chmod'])) ? |
|
| 51 | + sprintf('%04o', $_GET['chmod']) : '0777'; |
|
| 52 | 52 | |
| 53 | - if (@is_readable(_FILE_CHMOD_TMP)) { |
|
| 54 | - $s = @implode('', @file(_FILE_CHMOD_TMP)); |
|
| 55 | - if (preg_match("#define\('_SPIP_CHMOD', (.*)\)#", $s, $regs)) { |
|
| 56 | - $chmod = $regs[1]; |
|
| 57 | - } |
|
| 58 | - } |
|
| 53 | + if (@is_readable(_FILE_CHMOD_TMP)) { |
|
| 54 | + $s = @implode('', @file(_FILE_CHMOD_TMP)); |
|
| 55 | + if (preg_match("#define\('_SPIP_CHMOD', (.*)\)#", $s, $regs)) { |
|
| 56 | + $chmod = $regs[1]; |
|
| 57 | + } |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | 60 | |
| 61 | - $db = [$adresse_db, _T('entree_base_donnee_2')]; |
|
| 62 | - $login = [$login_db, _T('entree_login_connexion_2')]; |
|
| 63 | - $pass = ['', _T('entree_mot_passe_2')]; |
|
| 61 | + $db = [$adresse_db, _T('entree_base_donnee_2')]; |
|
| 62 | + $login = [$login_db, _T('entree_login_connexion_2')]; |
|
| 63 | + $pass = ['', _T('entree_mot_passe_2')]; |
|
| 64 | 64 | |
| 65 | - $predef = [ |
|
| 66 | - defined('_INSTALL_SERVER_DB') ? _INSTALL_SERVER_DB : '', |
|
| 67 | - defined('_INSTALL_HOST_DB'), |
|
| 68 | - defined('_INSTALL_USER_DB'), |
|
| 69 | - defined('_INSTALL_PASS_DB') |
|
| 70 | - ]; |
|
| 65 | + $predef = [ |
|
| 66 | + defined('_INSTALL_SERVER_DB') ? _INSTALL_SERVER_DB : '', |
|
| 67 | + defined('_INSTALL_HOST_DB'), |
|
| 68 | + defined('_INSTALL_USER_DB'), |
|
| 69 | + defined('_INSTALL_PASS_DB') |
|
| 70 | + ]; |
|
| 71 | 71 | |
| 72 | 72 | |
| 73 | - echo info_progression_etape(1, 'etape_', 'install/'); |
|
| 73 | + echo info_progression_etape(1, 'etape_', 'install/'); |
|
| 74 | 74 | |
| 75 | - // ces deux chaines de langues doivent etre reecrites |
|
| 75 | + // ces deux chaines de langues doivent etre reecrites |
|
| 76 | 76 | # echo info_etape(_T('info_connexion_mysql'), _T('texte_connexion_mysql').aide ("install1", true)); |
| 77 | - echo info_etape(_T('info_connexion_base_donnee')); |
|
| 78 | - echo install_connexion_form($db, $login, $pass, $predef, "\n<input type='hidden' name='chmod' value='$chmod' />", 2); |
|
| 79 | - echo $minipage->installFinPage(); |
|
| 77 | + echo info_etape(_T('info_connexion_base_donnee')); |
|
| 78 | + echo install_connexion_form($db, $login, $pass, $predef, "\n<input type='hidden' name='chmod' value='$chmod' />", 2); |
|
| 79 | + echo $minipage->installFinPage(); |
|
| 80 | 80 | } |
@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | \***************************************************************************/ |
| 13 | 13 | |
| 14 | 14 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 15 | - return; |
|
| 15 | + return; |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | include_spip('inc/headers'); |
@@ -21,61 +21,61 @@ discard block |
||
| 21 | 21 | // Mise en place des fichiers de configuration si ce n'est fait |
| 22 | 22 | |
| 23 | 23 | function install_etape_fin_dist() { |
| 24 | - ecrire_acces(); |
|
| 24 | + ecrire_acces(); |
|
| 25 | 25 | |
| 26 | - $f = str_replace(_FILE_TMP_SUFFIX, '.php', (string) _FILE_CHMOD_TMP); |
|
| 27 | - if (file_exists(_FILE_CHMOD_TMP) && !@rename(_FILE_CHMOD_TMP, $f) && @copy(_FILE_CHMOD_TMP, $f)) { |
|
| 28 | - spip_unlink(_FILE_CHMOD_TMP); |
|
| 29 | - } |
|
| 26 | + $f = str_replace(_FILE_TMP_SUFFIX, '.php', (string) _FILE_CHMOD_TMP); |
|
| 27 | + if (file_exists(_FILE_CHMOD_TMP) && !@rename(_FILE_CHMOD_TMP, $f) && @copy(_FILE_CHMOD_TMP, $f)) { |
|
| 28 | + spip_unlink(_FILE_CHMOD_TMP); |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - $f = str_replace(_FILE_TMP_SUFFIX, '.php', (string) _FILE_CONNECT_TMP); |
|
| 32 | - if (file_exists(_FILE_CONNECT_TMP)) { |
|
| 33 | - spip_log("renomme $f"); |
|
| 34 | - if (!@rename(_FILE_CONNECT_TMP, $f) && @copy(_FILE_CONNECT_TMP, $f)) { |
|
| 35 | - @spip_unlink(_FILE_CONNECT_TMP); |
|
| 36 | - } |
|
| 37 | - } |
|
| 31 | + $f = str_replace(_FILE_TMP_SUFFIX, '.php', (string) _FILE_CONNECT_TMP); |
|
| 32 | + if (file_exists(_FILE_CONNECT_TMP)) { |
|
| 33 | + spip_log("renomme $f"); |
|
| 34 | + if (!@rename(_FILE_CONNECT_TMP, $f) && @copy(_FILE_CONNECT_TMP, $f)) { |
|
| 35 | + @spip_unlink(_FILE_CONNECT_TMP); |
|
| 36 | + } |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - // creer le repertoire cache, qui sert partout ! |
|
| 40 | - // deja fait en etape 4 en principe, on garde au cas ou |
|
| 41 | - if (!@file_exists(_DIR_CACHE)) { |
|
| 42 | - $rep = preg_replace(',' . _DIR_TMP . ',', '', (string) _DIR_CACHE); |
|
| 43 | - $rep = sous_repertoire(_DIR_TMP, $rep, true, true); |
|
| 44 | - } |
|
| 39 | + // creer le repertoire cache, qui sert partout ! |
|
| 40 | + // deja fait en etape 4 en principe, on garde au cas ou |
|
| 41 | + if (!@file_exists(_DIR_CACHE)) { |
|
| 42 | + $rep = preg_replace(',' . _DIR_TMP . ',', '', (string) _DIR_CACHE); |
|
| 43 | + $rep = sous_repertoire(_DIR_TMP, $rep, true, true); |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - // Verifier la securite des htaccess |
|
| 47 | - // Si elle ne fonctionne pas, prevenir |
|
| 48 | - $msg = install_verifier_htaccess(); |
|
| 49 | - if ($msg) { |
|
| 50 | - $cible = _T('public:accueil_site'); |
|
| 51 | - $cible = generer_form_ecrire('accueil', '', '', $cible); |
|
| 52 | - $minipage = new Installation(); |
|
| 53 | - echo $minipage->page($msg . $cible); |
|
| 54 | - // ok, deboucher dans l'espace prive |
|
| 55 | - } else { |
|
| 56 | - redirige_url_ecrire('accueil'); |
|
| 57 | - } |
|
| 46 | + // Verifier la securite des htaccess |
|
| 47 | + // Si elle ne fonctionne pas, prevenir |
|
| 48 | + $msg = install_verifier_htaccess(); |
|
| 49 | + if ($msg) { |
|
| 50 | + $cible = _T('public:accueil_site'); |
|
| 51 | + $cible = generer_form_ecrire('accueil', '', '', $cible); |
|
| 52 | + $minipage = new Installation(); |
|
| 53 | + echo $minipage->page($msg . $cible); |
|
| 54 | + // ok, deboucher dans l'espace prive |
|
| 55 | + } else { |
|
| 56 | + redirige_url_ecrire('accueil'); |
|
| 57 | + } |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | function install_verifier_htaccess() { |
| 61 | - if ( |
|
| 62 | - verifier_htaccess(_DIR_TMP, true) |
|
| 63 | - && verifier_htaccess(_DIR_CONNECT, true) |
|
| 64 | - && verifier_htaccess(_DIR_VENDOR, true) |
|
| 65 | - ) { |
|
| 66 | - return ''; |
|
| 67 | - } |
|
| 61 | + if ( |
|
| 62 | + verifier_htaccess(_DIR_TMP, true) |
|
| 63 | + && verifier_htaccess(_DIR_CONNECT, true) |
|
| 64 | + && verifier_htaccess(_DIR_VENDOR, true) |
|
| 65 | + ) { |
|
| 66 | + return ''; |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - $titre = _T('htaccess_inoperant'); |
|
| 69 | + $titre = _T('htaccess_inoperant'); |
|
| 70 | 70 | |
| 71 | - $averti = _T( |
|
| 72 | - 'htaccess_a_simuler', |
|
| 73 | - [ |
|
| 74 | - 'htaccess' => '<tt>' . _ACCESS_FILE_NAME . '</tt>', |
|
| 75 | - 'constantes' => '<tt>_DIR_TMP & _DIR_CONNECT</tt>', |
|
| 76 | - 'document_root' => '<tt>' . $_SERVER['DOCUMENT_ROOT'] . '</tt>' |
|
| 77 | - ] |
|
| 78 | - ); |
|
| 71 | + $averti = _T( |
|
| 72 | + 'htaccess_a_simuler', |
|
| 73 | + [ |
|
| 74 | + 'htaccess' => '<tt>' . _ACCESS_FILE_NAME . '</tt>', |
|
| 75 | + 'constantes' => '<tt>_DIR_TMP & _DIR_CONNECT</tt>', |
|
| 76 | + 'document_root' => '<tt>' . $_SERVER['DOCUMENT_ROOT'] . '</tt>' |
|
| 77 | + ] |
|
| 78 | + ); |
|
| 79 | 79 | |
| 80 | - return "<div class='error'><h3>$titre</h3><p>$averti</p></div>"; |
|
| 80 | + return "<div class='error'><h3>$titre</h3><p>$averti</p></div>"; |
|
| 81 | 81 | } |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | // creer le repertoire cache, qui sert partout ! |
| 40 | 40 | // deja fait en etape 4 en principe, on garde au cas ou |
| 41 | 41 | if (!@file_exists(_DIR_CACHE)) { |
| 42 | - $rep = preg_replace(',' . _DIR_TMP . ',', '', (string) _DIR_CACHE); |
|
| 42 | + $rep = preg_replace(','._DIR_TMP.',', '', (string) _DIR_CACHE); |
|
| 43 | 43 | $rep = sous_repertoire(_DIR_TMP, $rep, true, true); |
| 44 | 44 | } |
| 45 | 45 | |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | $cible = _T('public:accueil_site'); |
| 51 | 51 | $cible = generer_form_ecrire('accueil', '', '', $cible); |
| 52 | 52 | $minipage = new Installation(); |
| 53 | - echo $minipage->page($msg . $cible); |
|
| 53 | + echo $minipage->page($msg.$cible); |
|
| 54 | 54 | // ok, deboucher dans l'espace prive |
| 55 | 55 | } else { |
| 56 | 56 | redirige_url_ecrire('accueil'); |
@@ -71,9 +71,9 @@ discard block |
||
| 71 | 71 | $averti = _T( |
| 72 | 72 | 'htaccess_a_simuler', |
| 73 | 73 | [ |
| 74 | - 'htaccess' => '<tt>' . _ACCESS_FILE_NAME . '</tt>', |
|
| 74 | + 'htaccess' => '<tt>'._ACCESS_FILE_NAME.'</tt>', |
|
| 75 | 75 | 'constantes' => '<tt>_DIR_TMP & _DIR_CONNECT</tt>', |
| 76 | - 'document_root' => '<tt>' . $_SERVER['DOCUMENT_ROOT'] . '</tt>' |
|
| 76 | + 'document_root' => '<tt>'.$_SERVER['DOCUMENT_ROOT'].'</tt>' |
|
| 77 | 77 | ] |
| 78 | 78 | ); |
| 79 | 79 | |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | */ |
| 19 | 19 | |
| 20 | 20 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 21 | - return; |
|
| 21 | + return; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | /** |
@@ -27,20 +27,20 @@ discard block |
||
| 27 | 27 | * @uses info_copyright() |
| 28 | 28 | **/ |
| 29 | 29 | function install_etape__dist() { |
| 30 | - utiliser_langue_visiteur(); |
|
| 31 | - $menu_langues = menu_langues('var_lang_ecrire'); |
|
| 32 | - if (!$menu_langues) { |
|
| 33 | - redirige_url_ecrire('install', 'etape=chmod'); |
|
| 34 | - } else { |
|
| 35 | - include_spip('inc/presentation'); // pour info_copyright |
|
| 30 | + utiliser_langue_visiteur(); |
|
| 31 | + $menu_langues = menu_langues('var_lang_ecrire'); |
|
| 32 | + if (!$menu_langues) { |
|
| 33 | + redirige_url_ecrire('install', 'etape=chmod'); |
|
| 34 | + } else { |
|
| 35 | + include_spip('inc/presentation'); // pour info_copyright |
|
| 36 | 36 | |
| 37 | - $res = "<div class='petit-centre'><img alt='SPIP' class='logo' src='" . chemin_image('logo-spip.png') . "' />\n" . |
|
| 38 | - "<p class='small'>" . info_copyright() . "</p></div>\n" . |
|
| 39 | - '<p>' . _T('install_select_langue') . '</p>' . |
|
| 40 | - '<div>' . $menu_langues . "</div>\n" . |
|
| 41 | - generer_form_ecrire('install', "<input type='hidden' name='etape' value='chmod' />" . bouton_suivant()); |
|
| 37 | + $res = "<div class='petit-centre'><img alt='SPIP' class='logo' src='" . chemin_image('logo-spip.png') . "' />\n" . |
|
| 38 | + "<p class='small'>" . info_copyright() . "</p></div>\n" . |
|
| 39 | + '<p>' . _T('install_select_langue') . '</p>' . |
|
| 40 | + '<div>' . $menu_langues . "</div>\n" . |
|
| 41 | + generer_form_ecrire('install', "<input type='hidden' name='etape' value='chmod' />" . bouton_suivant()); |
|
| 42 | 42 | |
| 43 | - $minipage = new Installation(); |
|
| 44 | - echo $minipage->page($res); |
|
| 45 | - } |
|
| 43 | + $minipage = new Installation(); |
|
| 44 | + echo $minipage->page($res); |
|
| 45 | + } |
|
| 46 | 46 | } |
@@ -34,11 +34,11 @@ |
||
| 34 | 34 | } else { |
| 35 | 35 | include_spip('inc/presentation'); // pour info_copyright |
| 36 | 36 | |
| 37 | - $res = "<div class='petit-centre'><img alt='SPIP' class='logo' src='" . chemin_image('logo-spip.png') . "' />\n" . |
|
| 38 | - "<p class='small'>" . info_copyright() . "</p></div>\n" . |
|
| 39 | - '<p>' . _T('install_select_langue') . '</p>' . |
|
| 40 | - '<div>' . $menu_langues . "</div>\n" . |
|
| 41 | - generer_form_ecrire('install', "<input type='hidden' name='etape' value='chmod' />" . bouton_suivant()); |
|
| 37 | + $res = "<div class='petit-centre'><img alt='SPIP' class='logo' src='".chemin_image('logo-spip.png')."' />\n". |
|
| 38 | + "<p class='small'>".info_copyright()."</p></div>\n". |
|
| 39 | + '<p>'._T('install_select_langue').'</p>'. |
|
| 40 | + '<div>'.$menu_langues."</div>\n". |
|
| 41 | + generer_form_ecrire('install', "<input type='hidden' name='etape' value='chmod' />".bouton_suivant()); |
|
| 42 | 42 | |
| 43 | 43 | $minipage = new Installation(); |
| 44 | 44 | echo $minipage->page($res); |
@@ -12,167 +12,167 @@ |
||
| 12 | 12 | \***************************************************************************/ |
| 13 | 13 | |
| 14 | 14 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 15 | - return; |
|
| 15 | + return; |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | include_spip('base/abstract_sql'); |
| 19 | 19 | |
| 20 | 20 | function install_etape_2_dist() { |
| 21 | - $adresse_db = defined('_INSTALL_HOST_DB') |
|
| 22 | - ? _INSTALL_HOST_DB |
|
| 23 | - : _request('adresse_db'); |
|
| 21 | + $adresse_db = defined('_INSTALL_HOST_DB') |
|
| 22 | + ? _INSTALL_HOST_DB |
|
| 23 | + : _request('adresse_db'); |
|
| 24 | 24 | |
| 25 | - if (preg_match(',(.*):(.*),', (string) $adresse_db, $r)) { |
|
| 26 | - [, $adresse_db, $port] = $r; |
|
| 27 | - } else { |
|
| 28 | - $port = ''; |
|
| 29 | - } |
|
| 25 | + if (preg_match(',(.*):(.*),', (string) $adresse_db, $r)) { |
|
| 26 | + [, $adresse_db, $port] = $r; |
|
| 27 | + } else { |
|
| 28 | + $port = ''; |
|
| 29 | + } |
|
| 30 | 30 | |
| 31 | - $login_db = defined('_INSTALL_USER_DB') |
|
| 32 | - ? _INSTALL_USER_DB |
|
| 33 | - : _request('login_db'); |
|
| 31 | + $login_db = defined('_INSTALL_USER_DB') |
|
| 32 | + ? _INSTALL_USER_DB |
|
| 33 | + : _request('login_db'); |
|
| 34 | 34 | |
| 35 | - $pass_db = defined('_INSTALL_PASS_DB') |
|
| 36 | - ? _INSTALL_PASS_DB |
|
| 37 | - : _request('pass_db'); |
|
| 35 | + $pass_db = defined('_INSTALL_PASS_DB') |
|
| 36 | + ? _INSTALL_PASS_DB |
|
| 37 | + : _request('pass_db'); |
|
| 38 | 38 | |
| 39 | - $server_db = defined('_INSTALL_SERVER_DB') |
|
| 40 | - ? _INSTALL_SERVER_DB |
|
| 41 | - : _request('server_db'); |
|
| 39 | + $server_db = defined('_INSTALL_SERVER_DB') |
|
| 40 | + ? _INSTALL_SERVER_DB |
|
| 41 | + : _request('server_db'); |
|
| 42 | 42 | |
| 43 | - $name_db = defined('_INSTALL_NAME_DB') |
|
| 44 | - ? _INSTALL_NAME_DB |
|
| 45 | - : ''; |
|
| 43 | + $name_db = defined('_INSTALL_NAME_DB') |
|
| 44 | + ? _INSTALL_NAME_DB |
|
| 45 | + : ''; |
|
| 46 | 46 | |
| 47 | - $chmod = _request('chmod'); |
|
| 47 | + $chmod = _request('chmod'); |
|
| 48 | 48 | |
| 49 | - $link = spip_connect_db($adresse_db, $port, $login_db, $pass_db, $name_db, $server_db); |
|
| 50 | - $GLOBALS['connexions'][$server_db] = $link; |
|
| 49 | + $link = spip_connect_db($adresse_db, $port, $login_db, $pass_db, $name_db, $server_db); |
|
| 50 | + $GLOBALS['connexions'][$server_db] = $link; |
|
| 51 | 51 | |
| 52 | - $GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']] |
|
| 53 | - = $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 52 | + $GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']] |
|
| 53 | + = $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 54 | 54 | |
| 55 | - $minipage = new Installation(); |
|
| 56 | - echo $minipage->installDebutPage(); |
|
| 55 | + $minipage = new Installation(); |
|
| 56 | + echo $minipage->installDebutPage(); |
|
| 57 | 57 | |
| 58 | 58 | |
| 59 | 59 | // prenons toutes les dispositions possibles pour que rien ne s'affiche ! |
| 60 | 60 | |
| 61 | - /* |
|
| 61 | + /* |
|
| 62 | 62 | * /!\ sqlite3/PDO : erreur sur join(', ', $link) |
| 63 | 63 | * L'objet PDO ne peut pas etre transformee en chaine |
| 64 | 64 | * Un echo $link ne fonctionne pas non plus |
| 65 | 65 | * Il faut utiliser par exemple print_r($link) |
| 66 | 66 | */ |
| 67 | - //echo "\n<!--\n", join(', ', $link), " $login_db "; |
|
| 68 | - $db_connect = 0; // revoirfunction_exists($ferrno) ? $ferrno() : 0; |
|
| 69 | - //echo join(', ', $GLOBALS['connexions'][$server_db]); |
|
| 70 | - //echo "\n-->\n"; |
|
| 67 | + //echo "\n<!--\n", join(', ', $link), " $login_db "; |
|
| 68 | + $db_connect = 0; // revoirfunction_exists($ferrno) ? $ferrno() : 0; |
|
| 69 | + //echo join(', ', $GLOBALS['connexions'][$server_db]); |
|
| 70 | + //echo "\n-->\n"; |
|
| 71 | 71 | |
| 72 | - if (($db_connect == '0') && $link) { |
|
| 73 | - echo "<div class='success'><b>" . _T('info_connexion_ok') . '</b></div>'; |
|
| 74 | - echo info_progression_etape(2, 'etape_', 'install/'); |
|
| 72 | + if (($db_connect == '0') && $link) { |
|
| 73 | + echo "<div class='success'><b>" . _T('info_connexion_ok') . '</b></div>'; |
|
| 74 | + echo info_progression_etape(2, 'etape_', 'install/'); |
|
| 75 | 75 | |
| 76 | - echo info_etape(_T('menu_aide_installation_choix_base') . aider('install2', true)); |
|
| 76 | + echo info_etape(_T('menu_aide_installation_choix_base') . aider('install2', true)); |
|
| 77 | 77 | |
| 78 | - echo "\n", '<!-- ', sql_version($server_db), ' -->'; |
|
| 79 | - [$checked, $res] = install_etape_2_bases($login_db, $server_db); |
|
| 78 | + echo "\n", '<!-- ', sql_version($server_db), ' -->'; |
|
| 79 | + [$checked, $res] = install_etape_2_bases($login_db, $server_db); |
|
| 80 | 80 | |
| 81 | - $hidden = (defined('_SPIP_CHMOD') |
|
| 82 | - ? '' |
|
| 83 | - : ("\n<input type='hidden' name='chmod' value='" . spip_htmlspecialchars($chmod) . "' />")) |
|
| 84 | - . predef_ou_cache($adresse_db . ($port ? ':' . $port : ''), $login_db, $pass_db, $server_db); |
|
| 81 | + $hidden = (defined('_SPIP_CHMOD') |
|
| 82 | + ? '' |
|
| 83 | + : ("\n<input type='hidden' name='chmod' value='" . spip_htmlspecialchars($chmod) . "' />")) |
|
| 84 | + . predef_ou_cache($adresse_db . ($port ? ':' . $port : ''), $login_db, $pass_db, $server_db); |
|
| 85 | 85 | |
| 86 | - echo install_etape_2_form($hidden, $checked, $res, 3); |
|
| 87 | - } else { |
|
| 88 | - echo info_progression_etape(1, 'etape_', 'install/', true); |
|
| 86 | + echo install_etape_2_form($hidden, $checked, $res, 3); |
|
| 87 | + } else { |
|
| 88 | + echo info_progression_etape(1, 'etape_', 'install/', true); |
|
| 89 | 89 | |
| 90 | - echo "<div class='error'>"; |
|
| 91 | - echo info_etape(_T('info_connexion_base')); |
|
| 92 | - echo '<h3>' . _T('avis_connexion_echec_1') . '</h3>'; |
|
| 93 | - echo '<p>' . _T('avis_connexion_echec_2') . '</p>'; |
|
| 90 | + echo "<div class='error'>"; |
|
| 91 | + echo info_etape(_T('info_connexion_base')); |
|
| 92 | + echo '<h3>' . _T('avis_connexion_echec_1') . '</h3>'; |
|
| 93 | + echo '<p>' . _T('avis_connexion_echec_2') . '</p>'; |
|
| 94 | 94 | |
| 95 | - echo "<p style='font-size: small;'>", |
|
| 96 | - _T('avis_connexion_echec_3'), |
|
| 97 | - '</p></div>'; |
|
| 98 | - } |
|
| 95 | + echo "<p style='font-size: small;'>", |
|
| 96 | + _T('avis_connexion_echec_3'), |
|
| 97 | + '</p></div>'; |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | - echo $minipage->installFinPage(); |
|
| 100 | + echo $minipage->installFinPage(); |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | // Liste les bases accessibles, |
| 104 | 104 | // avec une heuristique pour preselectionner la plus probable |
| 105 | 105 | |
| 106 | 106 | function install_etape_2_bases($login_db, $server_db) { |
| 107 | - $res = install_etape_liste_bases($server_db, $login_db); |
|
| 108 | - if ($res) { |
|
| 109 | - [$checked, $bases] = $res; |
|
| 110 | - |
|
| 111 | - return [ |
|
| 112 | - $checked, |
|
| 113 | - "<label for='choix_db'><b>" |
|
| 114 | - . _T('texte_choix_base_2') |
|
| 115 | - . '</b><br />' |
|
| 116 | - . _T('texte_choix_base_3') |
|
| 117 | - . '</label>' |
|
| 118 | - . "<ul>\n<li>" |
|
| 119 | - . implode("</li>\n<li>", $bases) |
|
| 120 | - . "</li>\n</ul><p>" |
|
| 121 | - . _T('info_ou') |
|
| 122 | - . ' ' |
|
| 123 | - ]; |
|
| 124 | - } |
|
| 125 | - $res = '<b>' . _T('avis_lecture_noms_bases_1') . '</b> |
|
| 107 | + $res = install_etape_liste_bases($server_db, $login_db); |
|
| 108 | + if ($res) { |
|
| 109 | + [$checked, $bases] = $res; |
|
| 110 | + |
|
| 111 | + return [ |
|
| 112 | + $checked, |
|
| 113 | + "<label for='choix_db'><b>" |
|
| 114 | + . _T('texte_choix_base_2') |
|
| 115 | + . '</b><br />' |
|
| 116 | + . _T('texte_choix_base_3') |
|
| 117 | + . '</label>' |
|
| 118 | + . "<ul>\n<li>" |
|
| 119 | + . implode("</li>\n<li>", $bases) |
|
| 120 | + . "</li>\n</ul><p>" |
|
| 121 | + . _T('info_ou') |
|
| 122 | + . ' ' |
|
| 123 | + ]; |
|
| 124 | + } |
|
| 125 | + $res = '<b>' . _T('avis_lecture_noms_bases_1') . '</b> |
|
| 126 | 126 | ' . _T('avis_lecture_noms_bases_2') . '<p>'; |
| 127 | 127 | |
| 128 | - $checked = false; |
|
| 129 | - if ($login_db) { |
|
| 130 | - // Si un login comporte un point, le nom de la base est plus |
|
| 131 | - // probablement le login sans le point -- testons pour savoir |
|
| 132 | - $test_base = $login_db; |
|
| 133 | - $ok = sql_selectdb($test_base, $server_db); |
|
| 134 | - $test_base2 = str_replace('.', '_', (string) $test_base); |
|
| 135 | - if (sql_selectdb($test_base2, $server_db)) { |
|
| 136 | - $test_base = $test_base2; |
|
| 137 | - $ok = true; |
|
| 138 | - } |
|
| 139 | - |
|
| 140 | - if ($ok) { |
|
| 141 | - $res .= _T('avis_lecture_noms_bases_3') |
|
| 142 | - . '<ul>' |
|
| 143 | - . '<li><input name="choix_db" value="' . $test_base . "\" type='radio' id='stand' checked='checked' />" |
|
| 144 | - . "<label for='stand'>" . $test_base . "</label></li>\n" |
|
| 145 | - . '</ul>' |
|
| 146 | - . '<p>' . _T('info_ou') . ' '; |
|
| 147 | - $checked = true; |
|
| 148 | - } |
|
| 149 | - } |
|
| 150 | - |
|
| 151 | - return [$checked, $res]; |
|
| 128 | + $checked = false; |
|
| 129 | + if ($login_db) { |
|
| 130 | + // Si un login comporte un point, le nom de la base est plus |
|
| 131 | + // probablement le login sans le point -- testons pour savoir |
|
| 132 | + $test_base = $login_db; |
|
| 133 | + $ok = sql_selectdb($test_base, $server_db); |
|
| 134 | + $test_base2 = str_replace('.', '_', (string) $test_base); |
|
| 135 | + if (sql_selectdb($test_base2, $server_db)) { |
|
| 136 | + $test_base = $test_base2; |
|
| 137 | + $ok = true; |
|
| 138 | + } |
|
| 139 | + |
|
| 140 | + if ($ok) { |
|
| 141 | + $res .= _T('avis_lecture_noms_bases_3') |
|
| 142 | + . '<ul>' |
|
| 143 | + . '<li><input name="choix_db" value="' . $test_base . "\" type='radio' id='stand' checked='checked' />" |
|
| 144 | + . "<label for='stand'>" . $test_base . "</label></li>\n" |
|
| 145 | + . '</ul>' |
|
| 146 | + . '<p>' . _T('info_ou') . ' '; |
|
| 147 | + $checked = true; |
|
| 148 | + } |
|
| 149 | + } |
|
| 150 | + |
|
| 151 | + return [$checked, $res]; |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | function install_etape_2_form($hidden, $checked, $res, $etape) { |
| 155 | - return generer_form_ecrire('install', ( |
|
| 156 | - "\n<input type='hidden' name='etape' value='$etape' />" |
|
| 157 | - . $hidden |
|
| 158 | - . (defined('_INSTALL_NAME_DB') |
|
| 159 | - ? '<h3>' . _T('install_nom_base_hebergeur') . ' <tt>' . _INSTALL_NAME_DB . '</tt>' . '</h3>' |
|
| 160 | - : "\n<fieldset><legend>" . _T('texte_choix_base_1') . "</legend>\n" |
|
| 161 | - . $res |
|
| 162 | - . "\n<input name=\"choix_db\" value=\"new_spip\" type='radio' id='nou'" |
|
| 163 | - . ($checked ? '' : " checked='checked'") |
|
| 164 | - . " />\n<label for='nou'>" . _T('info_creer_base') . "</label></p>\n<p>" |
|
| 165 | - . "\n<input type='text' name='table_new' class='text' value=\"spip\" size='20' /></p></fieldset>\n" |
|
| 166 | - ) |
|
| 167 | - |
|
| 168 | - . ((defined('_INSTALL_TABLE_PREFIX') || $GLOBALS['table_prefix'] != 'spip') |
|
| 169 | - ? '<h3>' . _T('install_table_prefix_hebergeur') . ' <tt>' . $GLOBALS['table_prefix'] . '</tt>' . '</h3>' |
|
| 170 | - : '<fieldset><legend>' . _T('texte_choix_table_prefix') . "</legend>\n" |
|
| 171 | - . "<p><label for='table_prefix'>" . _T('info_table_prefix') . '</label></p><p>' |
|
| 172 | - . "\n<input type='text' id='tprefix' name='tprefix' class='text' value='" |
|
| 173 | - . 'spip' # valeur par defaut |
|
| 174 | - . "' size='20' /></p></fieldset>" |
|
| 175 | - ) |
|
| 176 | - |
|
| 177 | - . bouton_suivant())); |
|
| 155 | + return generer_form_ecrire('install', ( |
|
| 156 | + "\n<input type='hidden' name='etape' value='$etape' />" |
|
| 157 | + . $hidden |
|
| 158 | + . (defined('_INSTALL_NAME_DB') |
|
| 159 | + ? '<h3>' . _T('install_nom_base_hebergeur') . ' <tt>' . _INSTALL_NAME_DB . '</tt>' . '</h3>' |
|
| 160 | + : "\n<fieldset><legend>" . _T('texte_choix_base_1') . "</legend>\n" |
|
| 161 | + . $res |
|
| 162 | + . "\n<input name=\"choix_db\" value=\"new_spip\" type='radio' id='nou'" |
|
| 163 | + . ($checked ? '' : " checked='checked'") |
|
| 164 | + . " />\n<label for='nou'>" . _T('info_creer_base') . "</label></p>\n<p>" |
|
| 165 | + . "\n<input type='text' name='table_new' class='text' value=\"spip\" size='20' /></p></fieldset>\n" |
|
| 166 | + ) |
|
| 167 | + |
|
| 168 | + . ((defined('_INSTALL_TABLE_PREFIX') || $GLOBALS['table_prefix'] != 'spip') |
|
| 169 | + ? '<h3>' . _T('install_table_prefix_hebergeur') . ' <tt>' . $GLOBALS['table_prefix'] . '</tt>' . '</h3>' |
|
| 170 | + : '<fieldset><legend>' . _T('texte_choix_table_prefix') . "</legend>\n" |
|
| 171 | + . "<p><label for='table_prefix'>" . _T('info_table_prefix') . '</label></p><p>' |
|
| 172 | + . "\n<input type='text' id='tprefix' name='tprefix' class='text' value='" |
|
| 173 | + . 'spip' # valeur par defaut |
|
| 174 | + . "' size='20' /></p></fieldset>" |
|
| 175 | + ) |
|
| 176 | + |
|
| 177 | + . bouton_suivant())); |
|
| 178 | 178 | } |
@@ -50,7 +50,7 @@ discard block |
||
| 50 | 50 | $GLOBALS['connexions'][$server_db] = $link; |
| 51 | 51 | |
| 52 | 52 | $GLOBALS['connexions'][$server_db][$GLOBALS['spip_sql_version']] |
| 53 | - = $GLOBALS['spip_' . $server_db . '_functions_' . $GLOBALS['spip_sql_version']]; |
|
| 53 | + = $GLOBALS['spip_'.$server_db.'_functions_'.$GLOBALS['spip_sql_version']]; |
|
| 54 | 54 | |
| 55 | 55 | $minipage = new Installation(); |
| 56 | 56 | echo $minipage->installDebutPage(); |
@@ -70,18 +70,18 @@ discard block |
||
| 70 | 70 | //echo "\n-->\n"; |
| 71 | 71 | |
| 72 | 72 | if (($db_connect == '0') && $link) { |
| 73 | - echo "<div class='success'><b>" . _T('info_connexion_ok') . '</b></div>'; |
|
| 73 | + echo "<div class='success'><b>"._T('info_connexion_ok').'</b></div>'; |
|
| 74 | 74 | echo info_progression_etape(2, 'etape_', 'install/'); |
| 75 | 75 | |
| 76 | - echo info_etape(_T('menu_aide_installation_choix_base') . aider('install2', true)); |
|
| 76 | + echo info_etape(_T('menu_aide_installation_choix_base').aider('install2', true)); |
|
| 77 | 77 | |
| 78 | 78 | echo "\n", '<!-- ', sql_version($server_db), ' -->'; |
| 79 | 79 | [$checked, $res] = install_etape_2_bases($login_db, $server_db); |
| 80 | 80 | |
| 81 | 81 | $hidden = (defined('_SPIP_CHMOD') |
| 82 | 82 | ? '' |
| 83 | - : ("\n<input type='hidden' name='chmod' value='" . spip_htmlspecialchars($chmod) . "' />")) |
|
| 84 | - . predef_ou_cache($adresse_db . ($port ? ':' . $port : ''), $login_db, $pass_db, $server_db); |
|
| 83 | + : ("\n<input type='hidden' name='chmod' value='".spip_htmlspecialchars($chmod)."' />")) |
|
| 84 | + . predef_ou_cache($adresse_db.($port ? ':'.$port : ''), $login_db, $pass_db, $server_db); |
|
| 85 | 85 | |
| 86 | 86 | echo install_etape_2_form($hidden, $checked, $res, 3); |
| 87 | 87 | } else { |
@@ -89,8 +89,8 @@ discard block |
||
| 89 | 89 | |
| 90 | 90 | echo "<div class='error'>"; |
| 91 | 91 | echo info_etape(_T('info_connexion_base')); |
| 92 | - echo '<h3>' . _T('avis_connexion_echec_1') . '</h3>'; |
|
| 93 | - echo '<p>' . _T('avis_connexion_echec_2') . '</p>'; |
|
| 92 | + echo '<h3>'._T('avis_connexion_echec_1').'</h3>'; |
|
| 93 | + echo '<p>'._T('avis_connexion_echec_2').'</p>'; |
|
| 94 | 94 | |
| 95 | 95 | echo "<p style='font-size: small;'>", |
| 96 | 96 | _T('avis_connexion_echec_3'), |
@@ -122,8 +122,8 @@ discard block |
||
| 122 | 122 | . ' ' |
| 123 | 123 | ]; |
| 124 | 124 | } |
| 125 | - $res = '<b>' . _T('avis_lecture_noms_bases_1') . '</b> |
|
| 126 | - ' . _T('avis_lecture_noms_bases_2') . '<p>'; |
|
| 125 | + $res = '<b>'._T('avis_lecture_noms_bases_1').'</b> |
|
| 126 | + ' . _T('avis_lecture_noms_bases_2').'<p>'; |
|
| 127 | 127 | |
| 128 | 128 | $checked = false; |
| 129 | 129 | if ($login_db) { |
@@ -140,10 +140,10 @@ discard block |
||
| 140 | 140 | if ($ok) { |
| 141 | 141 | $res .= _T('avis_lecture_noms_bases_3') |
| 142 | 142 | . '<ul>' |
| 143 | - . '<li><input name="choix_db" value="' . $test_base . "\" type='radio' id='stand' checked='checked' />" |
|
| 144 | - . "<label for='stand'>" . $test_base . "</label></li>\n" |
|
| 143 | + . '<li><input name="choix_db" value="'.$test_base."\" type='radio' id='stand' checked='checked' />" |
|
| 144 | + . "<label for='stand'>".$test_base."</label></li>\n" |
|
| 145 | 145 | . '</ul>' |
| 146 | - . '<p>' . _T('info_ou') . ' '; |
|
| 146 | + . '<p>'._T('info_ou').' '; |
|
| 147 | 147 | $checked = true; |
| 148 | 148 | } |
| 149 | 149 | } |
@@ -156,19 +156,19 @@ discard block |
||
| 156 | 156 | "\n<input type='hidden' name='etape' value='$etape' />" |
| 157 | 157 | . $hidden |
| 158 | 158 | . (defined('_INSTALL_NAME_DB') |
| 159 | - ? '<h3>' . _T('install_nom_base_hebergeur') . ' <tt>' . _INSTALL_NAME_DB . '</tt>' . '</h3>' |
|
| 160 | - : "\n<fieldset><legend>" . _T('texte_choix_base_1') . "</legend>\n" |
|
| 159 | + ? '<h3>'._T('install_nom_base_hebergeur').' <tt>'._INSTALL_NAME_DB.'</tt>'.'</h3>' |
|
| 160 | + : "\n<fieldset><legend>"._T('texte_choix_base_1')."</legend>\n" |
|
| 161 | 161 | . $res |
| 162 | 162 | . "\n<input name=\"choix_db\" value=\"new_spip\" type='radio' id='nou'" |
| 163 | 163 | . ($checked ? '' : " checked='checked'") |
| 164 | - . " />\n<label for='nou'>" . _T('info_creer_base') . "</label></p>\n<p>" |
|
| 164 | + . " />\n<label for='nou'>"._T('info_creer_base')."</label></p>\n<p>" |
|
| 165 | 165 | . "\n<input type='text' name='table_new' class='text' value=\"spip\" size='20' /></p></fieldset>\n" |
| 166 | 166 | ) |
| 167 | 167 | |
| 168 | 168 | . ((defined('_INSTALL_TABLE_PREFIX') || $GLOBALS['table_prefix'] != 'spip') |
| 169 | - ? '<h3>' . _T('install_table_prefix_hebergeur') . ' <tt>' . $GLOBALS['table_prefix'] . '</tt>' . '</h3>' |
|
| 170 | - : '<fieldset><legend>' . _T('texte_choix_table_prefix') . "</legend>\n" |
|
| 171 | - . "<p><label for='table_prefix'>" . _T('info_table_prefix') . '</label></p><p>' |
|
| 169 | + ? '<h3>'._T('install_table_prefix_hebergeur').' <tt>'.$GLOBALS['table_prefix'].'</tt>'.'</h3>' |
|
| 170 | + : '<fieldset><legend>'._T('texte_choix_table_prefix')."</legend>\n" |
|
| 171 | + . "<p><label for='table_prefix'>"._T('info_table_prefix').'</label></p><p>' |
|
| 172 | 172 | . "\n<input type='text' id='tprefix' name='tprefix' class='text' value='" |
| 173 | 173 | . 'spip' # valeur par defaut |
| 174 | 174 | . "' size='20' /></p></fieldset>" |
@@ -13,169 +13,169 @@ |
||
| 13 | 13 | |
| 14 | 14 | /** Gestion des clés d’authentification / chiffrement de SPIP */ |
| 15 | 15 | final class SpipCles { |
| 16 | - private static array $instances = []; |
|
| 17 | - |
|
| 18 | - private string $file = _DIR_ETC . 'cles.php'; |
|
| 19 | - private readonly Cles $cles; |
|
| 20 | - |
|
| 21 | - public static function instance(string $file = ''): self { |
|
| 22 | - if (empty(self::$instances[$file])) { |
|
| 23 | - self::$instances[$file] = new self($file); |
|
| 24 | - } |
|
| 25 | - return self::$instances[$file]; |
|
| 26 | - } |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * Retourne le secret du site (shorthand) |
|
| 30 | - * @uses self::getSecretSite() |
|
| 31 | - */ |
|
| 32 | - public static function secret_du_site(): ?string { |
|
| 33 | - return (self::instance())->getSecretSite(); |
|
| 34 | - } |
|
| 35 | - |
|
| 36 | - private function __construct(string $file = '') { |
|
| 37 | - if ($file) { |
|
| 38 | - $this->file = $file; |
|
| 39 | - } |
|
| 40 | - $this->cles = new Cles($this->read()); |
|
| 41 | - } |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * Renvoyer le secret du site |
|
| 45 | - * |
|
| 46 | - * Le secret du site doit rester aussi secret que possible, et est eternel |
|
| 47 | - * On ne doit pas l'exporter |
|
| 48 | - * |
|
| 49 | - * Le secret est partagé entre une clé disque et une clé bdd |
|
| 50 | - * |
|
| 51 | - * @return string |
|
| 52 | - */ |
|
| 53 | - public function getSecretSite(bool $autoInit = true): ?string { |
|
| 54 | - $key = $this->getKey('secret_du_site', $autoInit); |
|
| 55 | - $meta = $this->getMetaKey('secret_du_site', $autoInit); |
|
| 56 | - // conserve la même longeur. |
|
| 57 | - return $key ^ $meta; |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - /** Renvoyer le secret des authentifications */ |
|
| 61 | - public function getSecretAuth(bool $autoInit = false): ?string { |
|
| 62 | - return $this->getKey('secret_des_auth', $autoInit); |
|
| 63 | - } |
|
| 64 | - public function save(): bool { |
|
| 65 | - return ecrire_fichier_securise($this->file, $this->cles->toJson()); |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - /** |
|
| 69 | - * Fournir une sauvegarde chiffree des cles (a l'aide d'une autre clé, comme le pass d'un auteur) |
|
| 70 | - * |
|
| 71 | - * @param string $withKey Clé de chiffrage de la sauvegarde |
|
| 72 | - * @return string Contenu de la sauvegarde chiffrée générée |
|
| 73 | - */ |
|
| 74 | - public function backup( |
|
| 75 | - #[\SensitiveParameter] |
|
| 76 | - string $withKey |
|
| 77 | - ): string { |
|
| 78 | - if (count($this->cles)) { |
|
| 79 | - return Chiffrement::chiffrer($this->cles->toJson(), $withKey); |
|
| 80 | - } |
|
| 81 | - return ''; |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - /** |
|
| 85 | - * Restaurer les cles manquantes depuis une sauvegarde chiffree des cles |
|
| 86 | - * (si la sauvegarde est bien valide) |
|
| 87 | - */ |
|
| 88 | - public function restore( |
|
| 89 | - /** Sauvegarde chiffrée (générée par backup()) */ |
|
| 90 | - string $backup, |
|
| 91 | - #[\SensitiveParameter] |
|
| 92 | - string $password_clair, |
|
| 93 | - #[\SensitiveParameter] |
|
| 94 | - string $password_hash, |
|
| 95 | - int $id_auteur |
|
| 96 | - ): bool { |
|
| 97 | - if (empty($backup)) { |
|
| 98 | - return false; |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - $sauvegarde = Chiffrement::dechiffrer($backup, $password_clair); |
|
| 102 | - $json = json_decode($sauvegarde, true, 512, JSON_THROW_ON_ERROR); |
|
| 103 | - if (!$json) { |
|
| 104 | - return false; |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - // cela semble une sauvegarde valide |
|
| 108 | - $cles_potentielles = array_map('base64_decode', $json); |
|
| 109 | - |
|
| 110 | - // il faut faire une double verif sur secret_des_auth |
|
| 111 | - // pour s'assurer qu'elle permet bien de decrypter le pass de l'auteur qui fournit la sauvegarde |
|
| 112 | - // et par extension tous les passwords |
|
| 113 | - if ( |
|
| 114 | - !empty($cles_potentielles['secret_des_auth']) |
|
| 115 | - && !Password::verifier($password_clair, $password_hash, $cles_potentielles['secret_des_auth']) |
|
| 116 | - ) { |
|
| 117 | - spip_log("Restauration de la cle `secret_des_auth` par id_auteur $id_auteur erronnee, on ignore", 'chiffrer' . _LOG_INFO_IMPORTANTE); |
|
| 118 | - unset($cles_potentielles['secret_des_auth']); |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - // on merge les cles pour recuperer les cles manquantes |
|
| 122 | - $restauration = false; |
|
| 123 | - foreach ($cles_potentielles as $name => $key) { |
|
| 124 | - if (!$this->cles->has($name)) { |
|
| 125 | - $this->cles->set($name, $key); |
|
| 126 | - spip_log("Restauration de la cle $name par id_auteur $id_auteur", 'chiffrer' . _LOG_INFO_IMPORTANTE); |
|
| 127 | - $restauration = true; |
|
| 128 | - } |
|
| 129 | - } |
|
| 130 | - return $restauration; |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - private function getKey(string $name, bool $autoInit): ?string { |
|
| 134 | - if ($this->cles->has($name)) { |
|
| 135 | - return $this->cles->get($name); |
|
| 136 | - } |
|
| 137 | - if ($autoInit) { |
|
| 138 | - $this->cles->generate($name); |
|
| 139 | - // si l'ecriture de fichier a bien marche on peut utiliser la cle |
|
| 140 | - if ($this->save()) { |
|
| 141 | - return $this->cles->get($name); |
|
| 142 | - } |
|
| 143 | - // sinon loger et annule la cle generee car il ne faut pas l'utiliser |
|
| 144 | - spip_log('Echec ecriture du fichier cle ' . $this->file . " ; impossible de generer une cle $name", 'chiffrer' . _LOG_ERREUR); |
|
| 145 | - $this->cles->delete($name); |
|
| 146 | - } |
|
| 147 | - return null; |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - private function getMetaKey(string $name, bool $autoInit = true): ?string { |
|
| 151 | - if (!isset($GLOBALS['meta'][$name])) { |
|
| 152 | - include_spip('base/abstract_sql'); |
|
| 153 | - $GLOBALS['meta'][$name] = sql_getfetsel('valeur', 'spip_meta', 'nom = ' . sql_quote($name, '', 'string')); |
|
| 154 | - } |
|
| 155 | - $key = base64_decode($GLOBALS['meta'][$name] ?? ''); |
|
| 156 | - if (strlen($key) === \SODIUM_CRYPTO_SECRETBOX_KEYBYTES) { |
|
| 157 | - return $key; |
|
| 158 | - } |
|
| 159 | - if (!$autoInit) { |
|
| 160 | - return null; |
|
| 161 | - } |
|
| 162 | - $key = Chiffrement::keygen(); |
|
| 163 | - ecrire_meta($name, base64_encode($key), 'non'); |
|
| 164 | - lire_metas(); // au cas ou ecrire_meta() ne fonctionne pas |
|
| 165 | - |
|
| 166 | - return $key; |
|
| 167 | - } |
|
| 168 | - |
|
| 169 | - private function read(): array { |
|
| 170 | - $json = null; |
|
| 171 | - lire_fichier_securise($this->file, $json); |
|
| 172 | - if ( |
|
| 173 | - $json |
|
| 174 | - && ($json = \json_decode($json, true, 512, JSON_THROW_ON_ERROR)) |
|
| 175 | - && is_array($json) |
|
| 176 | - ) { |
|
| 177 | - return array_map('base64_decode', $json); |
|
| 178 | - } |
|
| 179 | - return []; |
|
| 180 | - } |
|
| 16 | + private static array $instances = []; |
|
| 17 | + |
|
| 18 | + private string $file = _DIR_ETC . 'cles.php'; |
|
| 19 | + private readonly Cles $cles; |
|
| 20 | + |
|
| 21 | + public static function instance(string $file = ''): self { |
|
| 22 | + if (empty(self::$instances[$file])) { |
|
| 23 | + self::$instances[$file] = new self($file); |
|
| 24 | + } |
|
| 25 | + return self::$instances[$file]; |
|
| 26 | + } |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * Retourne le secret du site (shorthand) |
|
| 30 | + * @uses self::getSecretSite() |
|
| 31 | + */ |
|
| 32 | + public static function secret_du_site(): ?string { |
|
| 33 | + return (self::instance())->getSecretSite(); |
|
| 34 | + } |
|
| 35 | + |
|
| 36 | + private function __construct(string $file = '') { |
|
| 37 | + if ($file) { |
|
| 38 | + $this->file = $file; |
|
| 39 | + } |
|
| 40 | + $this->cles = new Cles($this->read()); |
|
| 41 | + } |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * Renvoyer le secret du site |
|
| 45 | + * |
|
| 46 | + * Le secret du site doit rester aussi secret que possible, et est eternel |
|
| 47 | + * On ne doit pas l'exporter |
|
| 48 | + * |
|
| 49 | + * Le secret est partagé entre une clé disque et une clé bdd |
|
| 50 | + * |
|
| 51 | + * @return string |
|
| 52 | + */ |
|
| 53 | + public function getSecretSite(bool $autoInit = true): ?string { |
|
| 54 | + $key = $this->getKey('secret_du_site', $autoInit); |
|
| 55 | + $meta = $this->getMetaKey('secret_du_site', $autoInit); |
|
| 56 | + // conserve la même longeur. |
|
| 57 | + return $key ^ $meta; |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + /** Renvoyer le secret des authentifications */ |
|
| 61 | + public function getSecretAuth(bool $autoInit = false): ?string { |
|
| 62 | + return $this->getKey('secret_des_auth', $autoInit); |
|
| 63 | + } |
|
| 64 | + public function save(): bool { |
|
| 65 | + return ecrire_fichier_securise($this->file, $this->cles->toJson()); |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + /** |
|
| 69 | + * Fournir une sauvegarde chiffree des cles (a l'aide d'une autre clé, comme le pass d'un auteur) |
|
| 70 | + * |
|
| 71 | + * @param string $withKey Clé de chiffrage de la sauvegarde |
|
| 72 | + * @return string Contenu de la sauvegarde chiffrée générée |
|
| 73 | + */ |
|
| 74 | + public function backup( |
|
| 75 | + #[\SensitiveParameter] |
|
| 76 | + string $withKey |
|
| 77 | + ): string { |
|
| 78 | + if (count($this->cles)) { |
|
| 79 | + return Chiffrement::chiffrer($this->cles->toJson(), $withKey); |
|
| 80 | + } |
|
| 81 | + return ''; |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + /** |
|
| 85 | + * Restaurer les cles manquantes depuis une sauvegarde chiffree des cles |
|
| 86 | + * (si la sauvegarde est bien valide) |
|
| 87 | + */ |
|
| 88 | + public function restore( |
|
| 89 | + /** Sauvegarde chiffrée (générée par backup()) */ |
|
| 90 | + string $backup, |
|
| 91 | + #[\SensitiveParameter] |
|
| 92 | + string $password_clair, |
|
| 93 | + #[\SensitiveParameter] |
|
| 94 | + string $password_hash, |
|
| 95 | + int $id_auteur |
|
| 96 | + ): bool { |
|
| 97 | + if (empty($backup)) { |
|
| 98 | + return false; |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + $sauvegarde = Chiffrement::dechiffrer($backup, $password_clair); |
|
| 102 | + $json = json_decode($sauvegarde, true, 512, JSON_THROW_ON_ERROR); |
|
| 103 | + if (!$json) { |
|
| 104 | + return false; |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + // cela semble une sauvegarde valide |
|
| 108 | + $cles_potentielles = array_map('base64_decode', $json); |
|
| 109 | + |
|
| 110 | + // il faut faire une double verif sur secret_des_auth |
|
| 111 | + // pour s'assurer qu'elle permet bien de decrypter le pass de l'auteur qui fournit la sauvegarde |
|
| 112 | + // et par extension tous les passwords |
|
| 113 | + if ( |
|
| 114 | + !empty($cles_potentielles['secret_des_auth']) |
|
| 115 | + && !Password::verifier($password_clair, $password_hash, $cles_potentielles['secret_des_auth']) |
|
| 116 | + ) { |
|
| 117 | + spip_log("Restauration de la cle `secret_des_auth` par id_auteur $id_auteur erronnee, on ignore", 'chiffrer' . _LOG_INFO_IMPORTANTE); |
|
| 118 | + unset($cles_potentielles['secret_des_auth']); |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + // on merge les cles pour recuperer les cles manquantes |
|
| 122 | + $restauration = false; |
|
| 123 | + foreach ($cles_potentielles as $name => $key) { |
|
| 124 | + if (!$this->cles->has($name)) { |
|
| 125 | + $this->cles->set($name, $key); |
|
| 126 | + spip_log("Restauration de la cle $name par id_auteur $id_auteur", 'chiffrer' . _LOG_INFO_IMPORTANTE); |
|
| 127 | + $restauration = true; |
|
| 128 | + } |
|
| 129 | + } |
|
| 130 | + return $restauration; |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + private function getKey(string $name, bool $autoInit): ?string { |
|
| 134 | + if ($this->cles->has($name)) { |
|
| 135 | + return $this->cles->get($name); |
|
| 136 | + } |
|
| 137 | + if ($autoInit) { |
|
| 138 | + $this->cles->generate($name); |
|
| 139 | + // si l'ecriture de fichier a bien marche on peut utiliser la cle |
|
| 140 | + if ($this->save()) { |
|
| 141 | + return $this->cles->get($name); |
|
| 142 | + } |
|
| 143 | + // sinon loger et annule la cle generee car il ne faut pas l'utiliser |
|
| 144 | + spip_log('Echec ecriture du fichier cle ' . $this->file . " ; impossible de generer une cle $name", 'chiffrer' . _LOG_ERREUR); |
|
| 145 | + $this->cles->delete($name); |
|
| 146 | + } |
|
| 147 | + return null; |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + private function getMetaKey(string $name, bool $autoInit = true): ?string { |
|
| 151 | + if (!isset($GLOBALS['meta'][$name])) { |
|
| 152 | + include_spip('base/abstract_sql'); |
|
| 153 | + $GLOBALS['meta'][$name] = sql_getfetsel('valeur', 'spip_meta', 'nom = ' . sql_quote($name, '', 'string')); |
|
| 154 | + } |
|
| 155 | + $key = base64_decode($GLOBALS['meta'][$name] ?? ''); |
|
| 156 | + if (strlen($key) === \SODIUM_CRYPTO_SECRETBOX_KEYBYTES) { |
|
| 157 | + return $key; |
|
| 158 | + } |
|
| 159 | + if (!$autoInit) { |
|
| 160 | + return null; |
|
| 161 | + } |
|
| 162 | + $key = Chiffrement::keygen(); |
|
| 163 | + ecrire_meta($name, base64_encode($key), 'non'); |
|
| 164 | + lire_metas(); // au cas ou ecrire_meta() ne fonctionne pas |
|
| 165 | + |
|
| 166 | + return $key; |
|
| 167 | + } |
|
| 168 | + |
|
| 169 | + private function read(): array { |
|
| 170 | + $json = null; |
|
| 171 | + lire_fichier_securise($this->file, $json); |
|
| 172 | + if ( |
|
| 173 | + $json |
|
| 174 | + && ($json = \json_decode($json, true, 512, JSON_THROW_ON_ERROR)) |
|
| 175 | + && is_array($json) |
|
| 176 | + ) { |
|
| 177 | + return array_map('base64_decode', $json); |
|
| 178 | + } |
|
| 179 | + return []; |
|
| 180 | + } |
|
| 181 | 181 | } |
@@ -15,7 +15,7 @@ discard block |
||
| 15 | 15 | final class SpipCles { |
| 16 | 16 | private static array $instances = []; |
| 17 | 17 | |
| 18 | - private string $file = _DIR_ETC . 'cles.php'; |
|
| 18 | + private string $file = _DIR_ETC.'cles.php'; |
|
| 19 | 19 | private readonly Cles $cles; |
| 20 | 20 | |
| 21 | 21 | public static function instance(string $file = ''): self { |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | !empty($cles_potentielles['secret_des_auth']) |
| 115 | 115 | && !Password::verifier($password_clair, $password_hash, $cles_potentielles['secret_des_auth']) |
| 116 | 116 | ) { |
| 117 | - spip_log("Restauration de la cle `secret_des_auth` par id_auteur $id_auteur erronnee, on ignore", 'chiffrer' . _LOG_INFO_IMPORTANTE); |
|
| 117 | + spip_log("Restauration de la cle `secret_des_auth` par id_auteur $id_auteur erronnee, on ignore", 'chiffrer'._LOG_INFO_IMPORTANTE); |
|
| 118 | 118 | unset($cles_potentielles['secret_des_auth']); |
| 119 | 119 | } |
| 120 | 120 | |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | foreach ($cles_potentielles as $name => $key) { |
| 124 | 124 | if (!$this->cles->has($name)) { |
| 125 | 125 | $this->cles->set($name, $key); |
| 126 | - spip_log("Restauration de la cle $name par id_auteur $id_auteur", 'chiffrer' . _LOG_INFO_IMPORTANTE); |
|
| 126 | + spip_log("Restauration de la cle $name par id_auteur $id_auteur", 'chiffrer'._LOG_INFO_IMPORTANTE); |
|
| 127 | 127 | $restauration = true; |
| 128 | 128 | } |
| 129 | 129 | } |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | return $this->cles->get($name); |
| 142 | 142 | } |
| 143 | 143 | // sinon loger et annule la cle generee car il ne faut pas l'utiliser |
| 144 | - spip_log('Echec ecriture du fichier cle ' . $this->file . " ; impossible de generer une cle $name", 'chiffrer' . _LOG_ERREUR); |
|
| 144 | + spip_log('Echec ecriture du fichier cle '.$this->file." ; impossible de generer une cle $name", 'chiffrer'._LOG_ERREUR); |
|
| 145 | 145 | $this->cles->delete($name); |
| 146 | 146 | } |
| 147 | 147 | return null; |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | private function getMetaKey(string $name, bool $autoInit = true): ?string { |
| 151 | 151 | if (!isset($GLOBALS['meta'][$name])) { |
| 152 | 152 | include_spip('base/abstract_sql'); |
| 153 | - $GLOBALS['meta'][$name] = sql_getfetsel('valeur', 'spip_meta', 'nom = ' . sql_quote($name, '', 'string')); |
|
| 153 | + $GLOBALS['meta'][$name] = sql_getfetsel('valeur', 'spip_meta', 'nom = '.sql_quote($name, '', 'string')); |
|
| 154 | 154 | } |
| 155 | 155 | $key = base64_decode($GLOBALS['meta'][$name] ?? ''); |
| 156 | 156 | if (strlen($key) === \SODIUM_CRYPTO_SECRETBOX_KEYBYTES) { |
@@ -7,33 +7,33 @@ |
||
| 7 | 7 | * @internal |
| 8 | 8 | */ |
| 9 | 9 | final class ErrorHandler { |
| 10 | - static bool $done = false; |
|
| 10 | + static bool $done = false; |
|
| 11 | 11 | |
| 12 | - public static function setup(?int $error_level = null): void { |
|
| 13 | - if (!self::$done) { |
|
| 14 | - self::$done = true; |
|
| 15 | - error_reporting($error_level); |
|
| 16 | - set_error_handler(self::user_deprecated(...), E_USER_DEPRECATED); |
|
| 17 | - } |
|
| 18 | - } |
|
| 12 | + public static function setup(?int $error_level = null): void { |
|
| 13 | + if (!self::$done) { |
|
| 14 | + self::$done = true; |
|
| 15 | + error_reporting($error_level); |
|
| 16 | + set_error_handler(self::user_deprecated(...), E_USER_DEPRECATED); |
|
| 17 | + } |
|
| 18 | + } |
|
| 19 | 19 | |
| 20 | - /** Loger les `trigger_deprecated()` */ |
|
| 21 | - private static function user_deprecated(int $errno, string $errstr, string $errfile, int $errline): bool { |
|
| 22 | - if (!(\E_USER_DEPRECATED & $errno)) { |
|
| 23 | - return false; |
|
| 24 | - } |
|
| 20 | + /** Loger les `trigger_deprecated()` */ |
|
| 21 | + private static function user_deprecated(int $errno, string $errstr, string $errfile, int $errline): bool { |
|
| 22 | + if (!(\E_USER_DEPRECATED & $errno)) { |
|
| 23 | + return false; |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | - $backtrace = debug_backtrace(); |
|
| 27 | - array_shift($backtrace); |
|
| 28 | - do { |
|
| 29 | - $t = array_shift($backtrace); |
|
| 30 | - $fqdn = ($t['class'] ?? '') . ($t['type'] ?? '') . ($t['function'] ?? ''); |
|
| 31 | - } while (in_array($fqdn, ['trigger_error', 'trigger_deprecation'])); |
|
| 26 | + $backtrace = debug_backtrace(); |
|
| 27 | + array_shift($backtrace); |
|
| 28 | + do { |
|
| 29 | + $t = array_shift($backtrace); |
|
| 30 | + $fqdn = ($t['class'] ?? '') . ($t['type'] ?? '') . ($t['function'] ?? ''); |
|
| 31 | + } while (in_array($fqdn, ['trigger_error', 'trigger_deprecation'])); |
|
| 32 | 32 | |
| 33 | - $errfile = $t['file']; |
|
| 34 | - $errline = $t['line']; |
|
| 33 | + $errfile = $t['file']; |
|
| 34 | + $errline = $t['line']; |
|
| 35 | 35 | |
| 36 | - spip_log(sprintf('%s in %s on line %s', $errstr, $errfile, $errline), 'deprecated.' . _LOG_INFO); |
|
| 37 | - return false; |
|
| 38 | - } |
|
| 36 | + spip_log(sprintf('%s in %s on line %s', $errstr, $errfile, $errline), 'deprecated.' . _LOG_INFO); |
|
| 37 | + return false; |
|
| 38 | + } |
|
| 39 | 39 | } |
@@ -27,13 +27,13 @@ |
||
| 27 | 27 | array_shift($backtrace); |
| 28 | 28 | do { |
| 29 | 29 | $t = array_shift($backtrace); |
| 30 | - $fqdn = ($t['class'] ?? '') . ($t['type'] ?? '') . ($t['function'] ?? ''); |
|
| 30 | + $fqdn = ($t['class'] ?? '').($t['type'] ?? '').($t['function'] ?? ''); |
|
| 31 | 31 | } while (in_array($fqdn, ['trigger_error', 'trigger_deprecation'])); |
| 32 | 32 | |
| 33 | 33 | $errfile = $t['file']; |
| 34 | 34 | $errline = $t['line']; |
| 35 | 35 | |
| 36 | - spip_log(sprintf('%s in %s on line %s', $errstr, $errfile, $errline), 'deprecated.' . _LOG_INFO); |
|
| 36 | + spip_log(sprintf('%s in %s on line %s', $errstr, $errfile, $errline), 'deprecated.'._LOG_INFO); |
|
| 37 | 37 | return false; |
| 38 | 38 | } |
| 39 | 39 | } |