@@ -11,58 +11,58 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | include_spip('xml/interfaces'); |
| 18 | 18 | |
| 19 | 19 | // https://code.spip.net/@charger_dtd |
| 20 | 20 | function charger_dtd($grammaire, $avail, $rotlvl) { |
| 21 | - static $dtd = []; # cache bien utile pour le validateur en boucle |
|
| 22 | - |
|
| 23 | - if (isset($dtd[$grammaire])) { |
|
| 24 | - return $dtd[$grammaire]; |
|
| 25 | - } |
|
| 26 | - |
|
| 27 | - if ($avail == 'SYSTEM') { |
|
| 28 | - $grammaire = find_in_path($grammaire); |
|
| 29 | - } |
|
| 30 | - |
|
| 31 | - $file = _DIR_CACHE_XML . preg_replace('/[^\w.]/', '_', $rotlvl) . '.gz'; |
|
| 32 | - |
|
| 33 | - if (lire_fichier($file, $r)) { |
|
| 34 | - if (!$grammaire) { |
|
| 35 | - return []; |
|
| 36 | - } |
|
| 37 | - if (($avail == 'SYSTEM') and filemtime($file) < filemtime($grammaire)) { |
|
| 38 | - $r = false; |
|
| 39 | - } |
|
| 40 | - } |
|
| 41 | - |
|
| 42 | - if ($r) { |
|
| 43 | - $dtc = unserialize($r); |
|
| 44 | - } else { |
|
| 45 | - spip_timer('dtd'); |
|
| 46 | - $dtc = new DTC(); |
|
| 47 | - // L'analyseur retourne un booleen de reussite et modifie $dtc. |
|
| 48 | - // Retourner vide en cas d'echec |
|
| 49 | - if (!analyser_dtd($grammaire, $avail, $dtc)) { |
|
| 50 | - $dtc = []; |
|
| 51 | - } else { |
|
| 52 | - // tri final pour presenter les suggestions de corrections |
|
| 53 | - foreach ($dtc->peres as $k => $v) { |
|
| 54 | - asort($v); |
|
| 55 | - $dtc->peres[$k] = $v; |
|
| 56 | - } |
|
| 57 | - |
|
| 58 | - spip_log("Analyser DTD $avail $grammaire (" . spip_timer('dtd') . ') ' . count($dtc->macros) . ' macros, ' . count($dtc->elements) . ' elements, ' . count($dtc->attributs) . " listes d'attributs, " . count($dtc->entites) . ' entites'); |
|
| 59 | - # $r = $dtc->regles; ksort($r);foreach($r as $l => $v) {$t=array_keys($dtc->attributs[$l]);echo "<b>$l</b> '$v' ", count($t), " attributs: ", join (', ',$t);$t=$dtc->peres[$l];echo "<br />",count($t), " peres: ", @join (', ',$t), "<br />\n";}exit; |
|
| 60 | - ecrire_fichier($file, serialize($dtc), true); |
|
| 61 | - } |
|
| 62 | - } |
|
| 63 | - $dtd[$grammaire] = $dtc; |
|
| 64 | - |
|
| 65 | - return $dtc; |
|
| 21 | + static $dtd = []; # cache bien utile pour le validateur en boucle |
|
| 22 | + |
|
| 23 | + if (isset($dtd[$grammaire])) { |
|
| 24 | + return $dtd[$grammaire]; |
|
| 25 | + } |
|
| 26 | + |
|
| 27 | + if ($avail == 'SYSTEM') { |
|
| 28 | + $grammaire = find_in_path($grammaire); |
|
| 29 | + } |
|
| 30 | + |
|
| 31 | + $file = _DIR_CACHE_XML . preg_replace('/[^\w.]/', '_', $rotlvl) . '.gz'; |
|
| 32 | + |
|
| 33 | + if (lire_fichier($file, $r)) { |
|
| 34 | + if (!$grammaire) { |
|
| 35 | + return []; |
|
| 36 | + } |
|
| 37 | + if (($avail == 'SYSTEM') and filemtime($file) < filemtime($grammaire)) { |
|
| 38 | + $r = false; |
|
| 39 | + } |
|
| 40 | + } |
|
| 41 | + |
|
| 42 | + if ($r) { |
|
| 43 | + $dtc = unserialize($r); |
|
| 44 | + } else { |
|
| 45 | + spip_timer('dtd'); |
|
| 46 | + $dtc = new DTC(); |
|
| 47 | + // L'analyseur retourne un booleen de reussite et modifie $dtc. |
|
| 48 | + // Retourner vide en cas d'echec |
|
| 49 | + if (!analyser_dtd($grammaire, $avail, $dtc)) { |
|
| 50 | + $dtc = []; |
|
| 51 | + } else { |
|
| 52 | + // tri final pour presenter les suggestions de corrections |
|
| 53 | + foreach ($dtc->peres as $k => $v) { |
|
| 54 | + asort($v); |
|
| 55 | + $dtc->peres[$k] = $v; |
|
| 56 | + } |
|
| 57 | + |
|
| 58 | + spip_log("Analyser DTD $avail $grammaire (" . spip_timer('dtd') . ') ' . count($dtc->macros) . ' macros, ' . count($dtc->elements) . ' elements, ' . count($dtc->attributs) . " listes d'attributs, " . count($dtc->entites) . ' entites'); |
|
| 59 | + # $r = $dtc->regles; ksort($r);foreach($r as $l => $v) {$t=array_keys($dtc->attributs[$l]);echo "<b>$l</b> '$v' ", count($t), " attributs: ", join (', ',$t);$t=$dtc->peres[$l];echo "<br />",count($t), " peres: ", @join (', ',$t), "<br />\n";}exit; |
|
| 60 | + ecrire_fichier($file, serialize($dtc), true); |
|
| 61 | + } |
|
| 62 | + } |
|
| 63 | + $dtd[$grammaire] = $dtc; |
|
| 64 | + |
|
| 65 | + return $dtc; |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | // Compiler une regle de production en une Regexp qu'on appliquera sur la |
@@ -75,157 +75,157 @@ discard block |
||
| 75 | 75 | |
| 76 | 76 | // https://code.spip.net/@compilerRegle |
| 77 | 77 | function compilerRegle($val) { |
| 78 | - $x = str_replace( |
|
| 79 | - '()', |
|
| 80 | - '', |
|
| 81 | - preg_replace( |
|
| 82 | - '/\s*,\s*/', |
|
| 83 | - '', |
|
| 84 | - preg_replace( |
|
| 85 | - '/(\w+)\s*/', |
|
| 86 | - '(?:\1 )', |
|
| 87 | - preg_replace( |
|
| 88 | - '/\s*\)/', |
|
| 89 | - ')', |
|
| 90 | - preg_replace( |
|
| 91 | - '/\s*([(+*|?])\s*/', |
|
| 92 | - '\1', |
|
| 93 | - preg_replace('/\s*#\w+\s*[,|]?\s*/', '', $val) |
|
| 94 | - ) |
|
| 95 | - ) |
|
| 96 | - ) |
|
| 97 | - ) |
|
| 98 | - ); |
|
| 99 | - |
|
| 100 | - return $x; |
|
| 78 | + $x = str_replace( |
|
| 79 | + '()', |
|
| 80 | + '', |
|
| 81 | + preg_replace( |
|
| 82 | + '/\s*,\s*/', |
|
| 83 | + '', |
|
| 84 | + preg_replace( |
|
| 85 | + '/(\w+)\s*/', |
|
| 86 | + '(?:\1 )', |
|
| 87 | + preg_replace( |
|
| 88 | + '/\s*\)/', |
|
| 89 | + ')', |
|
| 90 | + preg_replace( |
|
| 91 | + '/\s*([(+*|?])\s*/', |
|
| 92 | + '\1', |
|
| 93 | + preg_replace('/\s*#\w+\s*[,|]?\s*/', '', $val) |
|
| 94 | + ) |
|
| 95 | + ) |
|
| 96 | + ) |
|
| 97 | + ) |
|
| 98 | + ); |
|
| 99 | + |
|
| 100 | + return $x; |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | |
| 104 | 104 | // https://code.spip.net/@analyser_dtd |
| 105 | 105 | function analyser_dtd($loc, $avail, &$dtc) { |
| 106 | - // creer le repertoire de cache si ce n'est fait |
|
| 107 | - // (utile aussi pour le resultat de la compil) |
|
| 108 | - $file = sous_repertoire(_DIR_CACHE_XML); |
|
| 109 | - // si DTD locale, ignorer ce repertoire pour le moment |
|
| 110 | - if ($avail == 'SYSTEM') { |
|
| 111 | - $file = $loc; |
|
| 112 | - if (_DIR_RACINE and strncmp($file, _DIR_RACINE, strlen(_DIR_RACINE)) == 0) { |
|
| 113 | - $file = substr($file, strlen(_DIR_RACINE)); |
|
| 114 | - } |
|
| 115 | - $file = find_in_path($file); |
|
| 116 | - } else { |
|
| 117 | - $file .= preg_replace('/[^\w.]/', '_', $loc); |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - $dtd = ''; |
|
| 121 | - if (@is_readable($file)) { |
|
| 122 | - lire_fichier($file, $dtd); |
|
| 123 | - } else { |
|
| 124 | - if ($avail == 'PUBLIC') { |
|
| 125 | - include_spip('inc/distant'); |
|
| 126 | - $dtd = recuperer_url($loc); |
|
| 127 | - $dtd = trim($dtd['page'] ?? ''); |
|
| 128 | - if ($dtd) { |
|
| 129 | - ecrire_fichier($file, $dtd, true); |
|
| 130 | - } |
|
| 131 | - } |
|
| 132 | - } |
|
| 133 | - |
|
| 134 | - $dtd = ltrim($dtd); |
|
| 135 | - if (!$dtd) { |
|
| 136 | - spip_log("DTD '$loc' ($file) inaccessible"); |
|
| 137 | - |
|
| 138 | - return false; |
|
| 139 | - } else { |
|
| 140 | - spip_log("analyse de la DTD $loc "); |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - while ($dtd) { |
|
| 144 | - if ($dtd[0] != '<') { |
|
| 145 | - $r = analyser_dtd_lexeme($dtd, $dtc, $loc); |
|
| 146 | - } elseif ($dtd[1] != '!') { |
|
| 147 | - $r = analyser_dtd_pi($dtd, $dtc, $loc); |
|
| 148 | - } elseif ($dtd[2] == '[') { |
|
| 149 | - $r = analyser_dtd_data($dtd, $dtc, $loc); |
|
| 150 | - } else { |
|
| 151 | - switch ($dtd[3]) { |
|
| 152 | - case '%': |
|
| 153 | - $r = analyser_dtd_data($dtd, $dtc, $loc); |
|
| 154 | - break; |
|
| 155 | - case 'T': |
|
| 156 | - $r = analyser_dtd_attlist($dtd, $dtc, $loc); |
|
| 157 | - break; |
|
| 158 | - case 'L': |
|
| 159 | - $r = analyser_dtd_element($dtd, $dtc, $loc); |
|
| 160 | - break; |
|
| 161 | - case 'N': |
|
| 162 | - $r = analyser_dtd_entity($dtd, $dtc, $loc); |
|
| 163 | - break; |
|
| 164 | - case 'O': |
|
| 165 | - $r = analyser_dtd_notation($dtd, $dtc, $loc); |
|
| 166 | - break; |
|
| 167 | - case '-': |
|
| 168 | - $r = analyser_dtd_comment($dtd, $dtc, $loc); |
|
| 169 | - break; |
|
| 170 | - default: |
|
| 171 | - $r = -1; |
|
| 172 | - } |
|
| 173 | - } |
|
| 174 | - if (!is_string($r)) { |
|
| 175 | - spip_log("erreur $r dans la DTD " . substr($dtd, 0, 80) . '.....'); |
|
| 176 | - |
|
| 177 | - return false; |
|
| 178 | - } |
|
| 179 | - $dtd = $r; |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - return true; |
|
| 106 | + // creer le repertoire de cache si ce n'est fait |
|
| 107 | + // (utile aussi pour le resultat de la compil) |
|
| 108 | + $file = sous_repertoire(_DIR_CACHE_XML); |
|
| 109 | + // si DTD locale, ignorer ce repertoire pour le moment |
|
| 110 | + if ($avail == 'SYSTEM') { |
|
| 111 | + $file = $loc; |
|
| 112 | + if (_DIR_RACINE and strncmp($file, _DIR_RACINE, strlen(_DIR_RACINE)) == 0) { |
|
| 113 | + $file = substr($file, strlen(_DIR_RACINE)); |
|
| 114 | + } |
|
| 115 | + $file = find_in_path($file); |
|
| 116 | + } else { |
|
| 117 | + $file .= preg_replace('/[^\w.]/', '_', $loc); |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + $dtd = ''; |
|
| 121 | + if (@is_readable($file)) { |
|
| 122 | + lire_fichier($file, $dtd); |
|
| 123 | + } else { |
|
| 124 | + if ($avail == 'PUBLIC') { |
|
| 125 | + include_spip('inc/distant'); |
|
| 126 | + $dtd = recuperer_url($loc); |
|
| 127 | + $dtd = trim($dtd['page'] ?? ''); |
|
| 128 | + if ($dtd) { |
|
| 129 | + ecrire_fichier($file, $dtd, true); |
|
| 130 | + } |
|
| 131 | + } |
|
| 132 | + } |
|
| 133 | + |
|
| 134 | + $dtd = ltrim($dtd); |
|
| 135 | + if (!$dtd) { |
|
| 136 | + spip_log("DTD '$loc' ($file) inaccessible"); |
|
| 137 | + |
|
| 138 | + return false; |
|
| 139 | + } else { |
|
| 140 | + spip_log("analyse de la DTD $loc "); |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + while ($dtd) { |
|
| 144 | + if ($dtd[0] != '<') { |
|
| 145 | + $r = analyser_dtd_lexeme($dtd, $dtc, $loc); |
|
| 146 | + } elseif ($dtd[1] != '!') { |
|
| 147 | + $r = analyser_dtd_pi($dtd, $dtc, $loc); |
|
| 148 | + } elseif ($dtd[2] == '[') { |
|
| 149 | + $r = analyser_dtd_data($dtd, $dtc, $loc); |
|
| 150 | + } else { |
|
| 151 | + switch ($dtd[3]) { |
|
| 152 | + case '%': |
|
| 153 | + $r = analyser_dtd_data($dtd, $dtc, $loc); |
|
| 154 | + break; |
|
| 155 | + case 'T': |
|
| 156 | + $r = analyser_dtd_attlist($dtd, $dtc, $loc); |
|
| 157 | + break; |
|
| 158 | + case 'L': |
|
| 159 | + $r = analyser_dtd_element($dtd, $dtc, $loc); |
|
| 160 | + break; |
|
| 161 | + case 'N': |
|
| 162 | + $r = analyser_dtd_entity($dtd, $dtc, $loc); |
|
| 163 | + break; |
|
| 164 | + case 'O': |
|
| 165 | + $r = analyser_dtd_notation($dtd, $dtc, $loc); |
|
| 166 | + break; |
|
| 167 | + case '-': |
|
| 168 | + $r = analyser_dtd_comment($dtd, $dtc, $loc); |
|
| 169 | + break; |
|
| 170 | + default: |
|
| 171 | + $r = -1; |
|
| 172 | + } |
|
| 173 | + } |
|
| 174 | + if (!is_string($r)) { |
|
| 175 | + spip_log("erreur $r dans la DTD " . substr($dtd, 0, 80) . '.....'); |
|
| 176 | + |
|
| 177 | + return false; |
|
| 178 | + } |
|
| 179 | + $dtd = $r; |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + return true; |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | // https://code.spip.net/@analyser_dtd_comment |
| 186 | 186 | function analyser_dtd_comment($dtd, &$dtc, $grammaire) { |
| 187 | - // ejecter les commentaires, surtout quand ils contiennent du code. |
|
| 188 | - // Option /s car sur plusieurs lignes parfois |
|
| 187 | + // ejecter les commentaires, surtout quand ils contiennent du code. |
|
| 188 | + // Option /s car sur plusieurs lignes parfois |
|
| 189 | 189 | |
| 190 | - if (!preg_match('/^<!--.*?-->\s*(.*)$/s', $dtd, $m)) { |
|
| 191 | - return -6; |
|
| 192 | - } |
|
| 190 | + if (!preg_match('/^<!--.*?-->\s*(.*)$/s', $dtd, $m)) { |
|
| 191 | + return -6; |
|
| 192 | + } |
|
| 193 | 193 | |
| 194 | - return $m[1]; |
|
| 194 | + return $m[1]; |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | // https://code.spip.net/@analyser_dtd_pi |
| 198 | 198 | function analyser_dtd_pi($dtd, &$dtc, $grammaire) { |
| 199 | - if (!preg_match('/^<\?.*?>\s*(.*)$/s', $dtd, $m)) { |
|
| 200 | - return -10; |
|
| 201 | - } |
|
| 199 | + if (!preg_match('/^<\?.*?>\s*(.*)$/s', $dtd, $m)) { |
|
| 200 | + return -10; |
|
| 201 | + } |
|
| 202 | 202 | |
| 203 | - return $m[1]; |
|
| 203 | + return $m[1]; |
|
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | // https://code.spip.net/@analyser_dtd_lexeme |
| 207 | 207 | function analyser_dtd_lexeme($dtd, &$dtc, $grammaire) { |
| 208 | 208 | |
| 209 | - if (!preg_match(_REGEXP_ENTITY_DEF, $dtd, $m)) { |
|
| 210 | - return -9; |
|
| 211 | - } |
|
| 212 | - |
|
| 213 | - list(, $s) = $m; |
|
| 214 | - $n = $dtc->macros[$s]; |
|
| 215 | - |
|
| 216 | - if (is_array($n)) { |
|
| 217 | - // en cas d'inclusion, l'espace de nom est le meme |
|
| 218 | - // mais gaffe aux DTD dont l'URL est relative a l'engloblante |
|
| 219 | - if ( |
|
| 220 | - ($n[0] == 'PUBLIC') |
|
| 221 | - and !tester_url_absolue($n[1]) |
|
| 222 | - ) { |
|
| 223 | - $n[1] = substr($grammaire, 0, strrpos($grammaire, '/') + 1) . $n[1]; |
|
| 224 | - } |
|
| 225 | - analyser_dtd($n[1], $n[0], $dtc); |
|
| 226 | - } |
|
| 227 | - |
|
| 228 | - return ltrim(substr($dtd, strlen($m[0]))); |
|
| 209 | + if (!preg_match(_REGEXP_ENTITY_DEF, $dtd, $m)) { |
|
| 210 | + return -9; |
|
| 211 | + } |
|
| 212 | + |
|
| 213 | + list(, $s) = $m; |
|
| 214 | + $n = $dtc->macros[$s]; |
|
| 215 | + |
|
| 216 | + if (is_array($n)) { |
|
| 217 | + // en cas d'inclusion, l'espace de nom est le meme |
|
| 218 | + // mais gaffe aux DTD dont l'URL est relative a l'engloblante |
|
| 219 | + if ( |
|
| 220 | + ($n[0] == 'PUBLIC') |
|
| 221 | + and !tester_url_absolue($n[1]) |
|
| 222 | + ) { |
|
| 223 | + $n[1] = substr($grammaire, 0, strrpos($grammaire, '/') + 1) . $n[1]; |
|
| 224 | + } |
|
| 225 | + analyser_dtd($n[1], $n[0], $dtc); |
|
| 226 | + } |
|
| 227 | + |
|
| 228 | + return ltrim(substr($dtd, strlen($m[0]))); |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | // il faudrait gerer plus proprement les niveaux d'inclusion: |
@@ -234,85 +234,85 @@ discard block |
||
| 234 | 234 | // https://code.spip.net/@analyser_dtd_data |
| 235 | 235 | function analyser_dtd_data($dtd, &$dtc, $grammaire) { |
| 236 | 236 | |
| 237 | - if (!preg_match(_REGEXP_INCLUDE_USE, $dtd, $m)) { |
|
| 238 | - return -11; |
|
| 239 | - } |
|
| 240 | - if ( |
|
| 241 | - !preg_match( |
|
| 242 | - '/^((\s*<!(\[\s*%\s*[^;]*;\s*\[([^]<]*<[^>]*>)*[^]<]*\]\]>)|([^]>]*>))*[^]<]*)\]\]>\s*/s', |
|
| 243 | - $m[2], |
|
| 244 | - $r |
|
| 245 | - ) |
|
| 246 | - ) { |
|
| 247 | - return -12; |
|
| 248 | - } |
|
| 249 | - |
|
| 250 | - if ($dtc->macros[$m[1]] == 'INCLUDE') { |
|
| 251 | - $retour = $r[1] . substr($m[2], strlen($r[0])); |
|
| 252 | - } else { |
|
| 253 | - $retour = substr($m[2], strlen($r[0])); |
|
| 254 | - } |
|
| 255 | - |
|
| 256 | - return $retour; |
|
| 237 | + if (!preg_match(_REGEXP_INCLUDE_USE, $dtd, $m)) { |
|
| 238 | + return -11; |
|
| 239 | + } |
|
| 240 | + if ( |
|
| 241 | + !preg_match( |
|
| 242 | + '/^((\s*<!(\[\s*%\s*[^;]*;\s*\[([^]<]*<[^>]*>)*[^]<]*\]\]>)|([^]>]*>))*[^]<]*)\]\]>\s*/s', |
|
| 243 | + $m[2], |
|
| 244 | + $r |
|
| 245 | + ) |
|
| 246 | + ) { |
|
| 247 | + return -12; |
|
| 248 | + } |
|
| 249 | + |
|
| 250 | + if ($dtc->macros[$m[1]] == 'INCLUDE') { |
|
| 251 | + $retour = $r[1] . substr($m[2], strlen($r[0])); |
|
| 252 | + } else { |
|
| 253 | + $retour = substr($m[2], strlen($r[0])); |
|
| 254 | + } |
|
| 255 | + |
|
| 256 | + return $retour; |
|
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | // https://code.spip.net/@analyser_dtd_notation |
| 260 | 260 | function analyser_dtd_notation($dtd, &$dtc, $grammaire) { |
| 261 | - if (!preg_match('/^<!NOTATION.*?>\s*(.*)$/s', $dtd, $m)) { |
|
| 262 | - return -8; |
|
| 263 | - } |
|
| 264 | - spip_log('analyser_dtd_notation a ecrire'); |
|
| 261 | + if (!preg_match('/^<!NOTATION.*?>\s*(.*)$/s', $dtd, $m)) { |
|
| 262 | + return -8; |
|
| 263 | + } |
|
| 264 | + spip_log('analyser_dtd_notation a ecrire'); |
|
| 265 | 265 | |
| 266 | - return $m[1]; |
|
| 266 | + return $m[1]; |
|
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | // https://code.spip.net/@analyser_dtd_entity |
| 270 | 270 | function analyser_dtd_entity($dtd, &$dtc, $grammaire) { |
| 271 | - if (!preg_match(_REGEXP_ENTITY_DECL, $dtd, $m)) { |
|
| 272 | - return -2; |
|
| 273 | - } |
|
| 274 | - |
|
| 275 | - list($t, $term, $nom, $type, $k1, $k2, $k3, $k4, $k5, $k6, $c, $q, $alt, $dtd) = $m; |
|
| 276 | - |
|
| 277 | - if (isset($dtc->macros[$nom]) and $dtc->macros[$nom]) { |
|
| 278 | - return $dtd; |
|
| 279 | - } |
|
| 280 | - if (isset($dtc->entites[$nom])) { |
|
| 281 | - spip_log("redefinition de l'entite $nom"); |
|
| 282 | - } |
|
| 283 | - if ($k6) { |
|
| 284 | - return $k6 . $dtd; |
|
| 285 | - } // cas du synonyme complet |
|
| 286 | - $val = expanserEntite(($k2 ? $k3 : ($k4 ? $k5 : $k6)), $dtc->macros); |
|
| 287 | - |
|
| 288 | - // cas particulier double evaluation: 'PUBLIC "..." "...."' |
|
| 289 | - if (preg_match('/(PUBLIC|SYSTEM)\s+"([^"]*)"\s*("([^"]*)")?\s*$/s', $val, $r)) { |
|
| 290 | - list($t, $type, $val, $q, $alt) = $r; |
|
| 291 | - } |
|
| 292 | - |
|
| 293 | - if (!$term) { |
|
| 294 | - $dtc->entites[$nom] = $val; |
|
| 295 | - } elseif (!$type) { |
|
| 296 | - $dtc->macros[$nom] = $val; |
|
| 297 | - } else { |
|
| 298 | - if (($type == 'SYSTEM') and !$alt) { |
|
| 299 | - $alt = $val; |
|
| 300 | - } |
|
| 301 | - if (!$alt) { |
|
| 302 | - $dtc->macros[$nom] = $val; |
|
| 303 | - } else { |
|
| 304 | - if ( |
|
| 305 | - ($type == 'PUBLIC') |
|
| 306 | - and (strpos($alt, '/') === false) |
|
| 307 | - ) { |
|
| 308 | - $alt = preg_replace(',/[^/]+$,', '/', $grammaire) |
|
| 309 | - . $alt; |
|
| 310 | - } |
|
| 311 | - $dtc->macros[$nom] = [$type, $alt]; |
|
| 312 | - } |
|
| 313 | - } |
|
| 314 | - |
|
| 315 | - return $dtd; |
|
| 271 | + if (!preg_match(_REGEXP_ENTITY_DECL, $dtd, $m)) { |
|
| 272 | + return -2; |
|
| 273 | + } |
|
| 274 | + |
|
| 275 | + list($t, $term, $nom, $type, $k1, $k2, $k3, $k4, $k5, $k6, $c, $q, $alt, $dtd) = $m; |
|
| 276 | + |
|
| 277 | + if (isset($dtc->macros[$nom]) and $dtc->macros[$nom]) { |
|
| 278 | + return $dtd; |
|
| 279 | + } |
|
| 280 | + if (isset($dtc->entites[$nom])) { |
|
| 281 | + spip_log("redefinition de l'entite $nom"); |
|
| 282 | + } |
|
| 283 | + if ($k6) { |
|
| 284 | + return $k6 . $dtd; |
|
| 285 | + } // cas du synonyme complet |
|
| 286 | + $val = expanserEntite(($k2 ? $k3 : ($k4 ? $k5 : $k6)), $dtc->macros); |
|
| 287 | + |
|
| 288 | + // cas particulier double evaluation: 'PUBLIC "..." "...."' |
|
| 289 | + if (preg_match('/(PUBLIC|SYSTEM)\s+"([^"]*)"\s*("([^"]*)")?\s*$/s', $val, $r)) { |
|
| 290 | + list($t, $type, $val, $q, $alt) = $r; |
|
| 291 | + } |
|
| 292 | + |
|
| 293 | + if (!$term) { |
|
| 294 | + $dtc->entites[$nom] = $val; |
|
| 295 | + } elseif (!$type) { |
|
| 296 | + $dtc->macros[$nom] = $val; |
|
| 297 | + } else { |
|
| 298 | + if (($type == 'SYSTEM') and !$alt) { |
|
| 299 | + $alt = $val; |
|
| 300 | + } |
|
| 301 | + if (!$alt) { |
|
| 302 | + $dtc->macros[$nom] = $val; |
|
| 303 | + } else { |
|
| 304 | + if ( |
|
| 305 | + ($type == 'PUBLIC') |
|
| 306 | + and (strpos($alt, '/') === false) |
|
| 307 | + ) { |
|
| 308 | + $alt = preg_replace(',/[^/]+$,', '/', $grammaire) |
|
| 309 | + . $alt; |
|
| 310 | + } |
|
| 311 | + $dtc->macros[$nom] = [$type, $alt]; |
|
| 312 | + } |
|
| 313 | + } |
|
| 314 | + |
|
| 315 | + return $dtd; |
|
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | // Dresser le tableau des filles potentielles de l'element |
@@ -326,77 +326,77 @@ discard block |
||
| 326 | 326 | |
| 327 | 327 | // https://code.spip.net/@analyser_dtd_element |
| 328 | 328 | function analyser_dtd_element($dtd, &$dtc, $grammaire) { |
| 329 | - if (!preg_match('/^<!ELEMENT\s+([^>\s]+)([^>]*)>\s*(.*)$/s', $dtd, $m)) { |
|
| 330 | - return -3; |
|
| 331 | - } |
|
| 332 | - |
|
| 333 | - list(, $nom, $contenu, $dtd) = $m; |
|
| 334 | - $nom = expanserEntite($nom, $dtc->macros); |
|
| 335 | - |
|
| 336 | - if (isset($dtc->elements[$nom])) { |
|
| 337 | - spip_log("redefinition de l'element $nom dans la DTD"); |
|
| 338 | - |
|
| 339 | - return -4; |
|
| 340 | - } |
|
| 341 | - $filles = []; |
|
| 342 | - $contenu = expanserEntite($contenu, $dtc->macros); |
|
| 343 | - $val = $contenu ? compilerRegle($contenu) : '(?:EMPTY )'; |
|
| 344 | - if ($val == '(?:EMPTY )') { |
|
| 345 | - $dtc->regles[$nom] = 'EMPTY'; |
|
| 346 | - } elseif ($val == '(?:ANY )') { |
|
| 347 | - $dtc->regles[$nom] = 'ANY'; |
|
| 348 | - } else { |
|
| 349 | - $last = substr($val, -1); |
|
| 350 | - if ( |
|
| 351 | - preg_match('/ \w/', $val) |
|
| 352 | - or (!empty($last) and strpos('*+?', $last) === false) |
|
| 353 | - ) { |
|
| 354 | - $dtc->regles[$nom] = "/^$val$/"; |
|
| 355 | - } else { |
|
| 356 | - $dtc->regles[$nom] = $last; |
|
| 357 | - } |
|
| 358 | - $filles = array_values(preg_split('/\W+/', $val, -1, PREG_SPLIT_NO_EMPTY)); |
|
| 359 | - |
|
| 360 | - foreach ($filles as $k) { |
|
| 361 | - if (!isset($dtc->peres[$k])) { |
|
| 362 | - $dtc->peres[$k] = []; |
|
| 363 | - } |
|
| 364 | - if (!in_array($nom, $dtc->peres[$k])) { |
|
| 365 | - $dtc->peres[$k][] = $nom; |
|
| 366 | - } |
|
| 367 | - } |
|
| 368 | - } |
|
| 369 | - $dtc->pcdata[$nom] = (strpos($contenu, '#PCDATA') === false); |
|
| 370 | - $dtc->elements[$nom] = $filles; |
|
| 371 | - |
|
| 372 | - return $dtd; |
|
| 329 | + if (!preg_match('/^<!ELEMENT\s+([^>\s]+)([^>]*)>\s*(.*)$/s', $dtd, $m)) { |
|
| 330 | + return -3; |
|
| 331 | + } |
|
| 332 | + |
|
| 333 | + list(, $nom, $contenu, $dtd) = $m; |
|
| 334 | + $nom = expanserEntite($nom, $dtc->macros); |
|
| 335 | + |
|
| 336 | + if (isset($dtc->elements[$nom])) { |
|
| 337 | + spip_log("redefinition de l'element $nom dans la DTD"); |
|
| 338 | + |
|
| 339 | + return -4; |
|
| 340 | + } |
|
| 341 | + $filles = []; |
|
| 342 | + $contenu = expanserEntite($contenu, $dtc->macros); |
|
| 343 | + $val = $contenu ? compilerRegle($contenu) : '(?:EMPTY )'; |
|
| 344 | + if ($val == '(?:EMPTY )') { |
|
| 345 | + $dtc->regles[$nom] = 'EMPTY'; |
|
| 346 | + } elseif ($val == '(?:ANY )') { |
|
| 347 | + $dtc->regles[$nom] = 'ANY'; |
|
| 348 | + } else { |
|
| 349 | + $last = substr($val, -1); |
|
| 350 | + if ( |
|
| 351 | + preg_match('/ \w/', $val) |
|
| 352 | + or (!empty($last) and strpos('*+?', $last) === false) |
|
| 353 | + ) { |
|
| 354 | + $dtc->regles[$nom] = "/^$val$/"; |
|
| 355 | + } else { |
|
| 356 | + $dtc->regles[$nom] = $last; |
|
| 357 | + } |
|
| 358 | + $filles = array_values(preg_split('/\W+/', $val, -1, PREG_SPLIT_NO_EMPTY)); |
|
| 359 | + |
|
| 360 | + foreach ($filles as $k) { |
|
| 361 | + if (!isset($dtc->peres[$k])) { |
|
| 362 | + $dtc->peres[$k] = []; |
|
| 363 | + } |
|
| 364 | + if (!in_array($nom, $dtc->peres[$k])) { |
|
| 365 | + $dtc->peres[$k][] = $nom; |
|
| 366 | + } |
|
| 367 | + } |
|
| 368 | + } |
|
| 369 | + $dtc->pcdata[$nom] = (strpos($contenu, '#PCDATA') === false); |
|
| 370 | + $dtc->elements[$nom] = $filles; |
|
| 371 | + |
|
| 372 | + return $dtd; |
|
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | |
| 376 | 376 | // https://code.spip.net/@analyser_dtd_attlist |
| 377 | 377 | function analyser_dtd_attlist($dtd, &$dtc, $grammaire) { |
| 378 | - if (!preg_match('/^<!ATTLIST\s+(\S+)\s+([^>]*)>\s*(.*)/s', $dtd, $m)) { |
|
| 379 | - return -5; |
|
| 380 | - } |
|
| 381 | - |
|
| 382 | - list(, $nom, $val, $dtd) = $m; |
|
| 383 | - $nom = expanserEntite($nom, $dtc->macros); |
|
| 384 | - $val = expanserEntite($val, $dtc->macros); |
|
| 385 | - if (!isset($dtc->attributs[$nom])) { |
|
| 386 | - $dtc->attributs[$nom] = []; |
|
| 387 | - } |
|
| 388 | - |
|
| 389 | - if (preg_match_all("/\s*(\S+)\s+(([(][^)]*[)])|(\S+))\s+([^\s']*)(\s*'[^']*')?/", $val, $r2, PREG_SET_ORDER)) { |
|
| 390 | - foreach ($r2 as $m2) { |
|
| 391 | - $v = preg_match('/^\w+$/', $m2[2]) ? $m2[2] |
|
| 392 | - : ('/^' . preg_replace('/\s+/', '', $m2[2]) . '$/'); |
|
| 393 | - $m21 = expanserEntite($m2[1], $dtc->macros); |
|
| 394 | - $m25 = expanserEntite($m2[5], $dtc->macros); |
|
| 395 | - $dtc->attributs[$nom][$m21] = [$v, $m25]; |
|
| 396 | - } |
|
| 397 | - } |
|
| 398 | - |
|
| 399 | - return $dtd; |
|
| 378 | + if (!preg_match('/^<!ATTLIST\s+(\S+)\s+([^>]*)>\s*(.*)/s', $dtd, $m)) { |
|
| 379 | + return -5; |
|
| 380 | + } |
|
| 381 | + |
|
| 382 | + list(, $nom, $val, $dtd) = $m; |
|
| 383 | + $nom = expanserEntite($nom, $dtc->macros); |
|
| 384 | + $val = expanserEntite($val, $dtc->macros); |
|
| 385 | + if (!isset($dtc->attributs[$nom])) { |
|
| 386 | + $dtc->attributs[$nom] = []; |
|
| 387 | + } |
|
| 388 | + |
|
| 389 | + if (preg_match_all("/\s*(\S+)\s+(([(][^)]*[)])|(\S+))\s+([^\s']*)(\s*'[^']*')?/", $val, $r2, PREG_SET_ORDER)) { |
|
| 390 | + foreach ($r2 as $m2) { |
|
| 391 | + $v = preg_match('/^\w+$/', $m2[2]) ? $m2[2] |
|
| 392 | + : ('/^' . preg_replace('/\s+/', '', $m2[2]) . '$/'); |
|
| 393 | + $m21 = expanserEntite($m2[1], $dtc->macros); |
|
| 394 | + $m25 = expanserEntite($m2[5], $dtc->macros); |
|
| 395 | + $dtc->attributs[$nom][$m21] = [$v, $m25]; |
|
| 396 | + } |
|
| 397 | + } |
|
| 398 | + |
|
| 399 | + return $dtd; |
|
| 400 | 400 | } |
| 401 | 401 | |
| 402 | 402 | |
@@ -412,26 +412,26 @@ discard block |
||
| 412 | 412 | * @return string|array |
| 413 | 413 | **/ |
| 414 | 414 | function expanserEntite($val, $macros = []) { |
| 415 | - static $vu = []; |
|
| 416 | - if (!is_string($val)) { |
|
| 417 | - return $vu; |
|
| 418 | - } |
|
| 419 | - |
|
| 420 | - if (preg_match_all(_REGEXP_ENTITY_USE, $val, $r, PREG_SET_ORDER)) { |
|
| 421 | - foreach ($r as $m) { |
|
| 422 | - $ent = $m[1]; |
|
| 423 | - // il peut valoir "" |
|
| 424 | - if (!isset($macros[$ent])) { |
|
| 425 | - spip_log("Entite $ent inconnu"); |
|
| 426 | - } else { |
|
| 427 | - if (!isset($vu[$ent])) { |
|
| 428 | - $vu[$ent] = 0; |
|
| 429 | - } |
|
| 430 | - ++$vu[$ent]; |
|
| 431 | - $val = str_replace($m[0], $macros[$ent], $val); |
|
| 432 | - } |
|
| 433 | - } |
|
| 434 | - } |
|
| 435 | - |
|
| 436 | - return trim(preg_replace('/\s+/', ' ', $val)); |
|
| 415 | + static $vu = []; |
|
| 416 | + if (!is_string($val)) { |
|
| 417 | + return $vu; |
|
| 418 | + } |
|
| 419 | + |
|
| 420 | + if (preg_match_all(_REGEXP_ENTITY_USE, $val, $r, PREG_SET_ORDER)) { |
|
| 421 | + foreach ($r as $m) { |
|
| 422 | + $ent = $m[1]; |
|
| 423 | + // il peut valoir "" |
|
| 424 | + if (!isset($macros[$ent])) { |
|
| 425 | + spip_log("Entite $ent inconnu"); |
|
| 426 | + } else { |
|
| 427 | + if (!isset($vu[$ent])) { |
|
| 428 | + $vu[$ent] = 0; |
|
| 429 | + } |
|
| 430 | + ++$vu[$ent]; |
|
| 431 | + $val = str_replace($m[0], $macros[$ent], $val); |
|
| 432 | + } |
|
| 433 | + } |
|
| 434 | + } |
|
| 435 | + |
|
| 436 | + return trim(preg_replace('/\s+/', ' ', $val)); |
|
| 437 | 437 | } |
@@ -11,61 +11,61 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | class IndenteurXML { |
| 18 | 18 | |
| 19 | - // https://code.spip.net/@debutElement |
|
| 20 | - public function debutElement($phraseur, $name, $attrs) { |
|
| 21 | - xml_debutElement($this, $name, $attrs); |
|
| 22 | - } |
|
| 19 | + // https://code.spip.net/@debutElement |
|
| 20 | + public function debutElement($phraseur, $name, $attrs) { |
|
| 21 | + xml_debutElement($this, $name, $attrs); |
|
| 22 | + } |
|
| 23 | 23 | |
| 24 | - // https://code.spip.net/@finElement |
|
| 25 | - public function finElement($phraseur, $name) { |
|
| 26 | - xml_finElement($this, $name); |
|
| 27 | - } |
|
| 24 | + // https://code.spip.net/@finElement |
|
| 25 | + public function finElement($phraseur, $name) { |
|
| 26 | + xml_finElement($this, $name); |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - // https://code.spip.net/@textElement |
|
| 30 | - public function textElement($phraseur, $data) { |
|
| 31 | - xml_textElement($this, $data); |
|
| 32 | - } |
|
| 29 | + // https://code.spip.net/@textElement |
|
| 30 | + public function textElement($phraseur, $data) { |
|
| 31 | + xml_textElement($this, $data); |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - public function piElement($phraseur, $target, $data) { |
|
| 35 | - xml_PiElement($this, $target, $data); |
|
| 36 | - } |
|
| 34 | + public function piElement($phraseur, $target, $data) { |
|
| 35 | + xml_PiElement($this, $target, $data); |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - // https://code.spip.net/@defautElement |
|
| 39 | - public function defaultElement($phraseur, $data) { |
|
| 40 | - xml_defaultElement($this, $data); |
|
| 41 | - } |
|
| 38 | + // https://code.spip.net/@defautElement |
|
| 39 | + public function defaultElement($phraseur, $data) { |
|
| 40 | + xml_defaultElement($this, $data); |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - // https://code.spip.net/@phraserTout |
|
| 44 | - public function phraserTout($phraseur, $data) { |
|
| 45 | - xml_parsestring($this, $data); |
|
| 46 | - } |
|
| 43 | + // https://code.spip.net/@phraserTout |
|
| 44 | + public function phraserTout($phraseur, $data) { |
|
| 45 | + xml_parsestring($this, $data); |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - public $depth = ''; |
|
| 49 | - public $res = ''; |
|
| 50 | - public $err = []; |
|
| 51 | - public $contenu = []; |
|
| 52 | - public $ouvrant = []; |
|
| 53 | - public $reperes = []; |
|
| 54 | - public $entete = ''; |
|
| 55 | - public $page = ''; |
|
| 56 | - public $dtc = null; |
|
| 57 | - public $sax = null; |
|
| 48 | + public $depth = ''; |
|
| 49 | + public $res = ''; |
|
| 50 | + public $err = []; |
|
| 51 | + public $contenu = []; |
|
| 52 | + public $ouvrant = []; |
|
| 53 | + public $reperes = []; |
|
| 54 | + public $entete = ''; |
|
| 55 | + public $page = ''; |
|
| 56 | + public $dtc = null; |
|
| 57 | + public $sax = null; |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | // https://code.spip.net/@xml_indenter_dist |
| 61 | 61 | function xml_indenter_dist($page, $apply = false) { |
| 62 | - $sax = charger_fonction('sax', 'xml'); |
|
| 63 | - $f = new IndenteurXML(); |
|
| 64 | - $sax($page, $apply, $f); |
|
| 65 | - if (!$f->err) { |
|
| 66 | - return $f->entete . $f->res; |
|
| 67 | - } |
|
| 68 | - spip_log('indentation impossible ' . count($f->err) . ' erreurs de validation'); |
|
| 62 | + $sax = charger_fonction('sax', 'xml'); |
|
| 63 | + $f = new IndenteurXML(); |
|
| 64 | + $sax($page, $apply, $f); |
|
| 65 | + if (!$f->err) { |
|
| 66 | + return $f->entete . $f->res; |
|
| 67 | + } |
|
| 68 | + spip_log('indentation impossible ' . count($f->err) . ' erreurs de validation'); |
|
| 69 | 69 | |
| 70 | - return $f->entete . $f->page; |
|
| 70 | + return $f->entete . $f->page; |
|
| 71 | 71 | } |
@@ -11,12 +11,12 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | define( |
| 18 | - '_REGEXP_DOCTYPE', |
|
| 19 | - '/^((?:<\001?[?][^>]*>\s*)*(?:<!--.*?-->\s*)*)*<!DOCTYPE\s+(\w+)\s+(\w+)\s*([^>]*)>\s*/s' |
|
| 18 | + '_REGEXP_DOCTYPE', |
|
| 19 | + '/^((?:<\001?[?][^>]*>\s*)*(?:<!--.*?-->\s*)*)*<!DOCTYPE\s+(\w+)\s+(\w+)\s*([^>]*)>\s*/s' |
|
| 20 | 20 | ); |
| 21 | 21 | |
| 22 | 22 | define('_REGEXP_XML', '/^(\s*(?:<[?][^x>][^>]*>\s*)?(?:<[?]xml[^>]*>)?\s*(?:<!--.*?-->\s*)*)<(\w+)/s'); |
@@ -35,14 +35,14 @@ discard block |
||
| 35 | 35 | define('_REGEXP_ENTITY_DEF', '/^%(' . _SUB_REGEXP_SYMBOL . '+);/'); |
| 36 | 36 | define('_REGEXP_TYPE_XML', 'PUBLIC|SYSTEM|INCLUDE|IGNORE|CDATA'); |
| 37 | 37 | define('_REGEXP_ENTITY_DECL', '/^<!ENTITY\s+(%?)\s*(' . |
| 38 | - _SUB_REGEXP_SYMBOL . |
|
| 39 | - '+;?)\s+(' . |
|
| 40 | - _REGEXP_TYPE_XML . |
|
| 41 | - ')?\s*(' . |
|
| 42 | - "('([^']*)')" . |
|
| 43 | - '|("([^"]*)")' . |
|
| 44 | - '|\s*(%' . _SUB_REGEXP_SYMBOL . '+;)\s*' . |
|
| 45 | - ')\s*(--.*?--)?("([^"]*)")?\s*>\s*(.*)$/s'); |
|
| 38 | + _SUB_REGEXP_SYMBOL . |
|
| 39 | + '+;?)\s+(' . |
|
| 40 | + _REGEXP_TYPE_XML . |
|
| 41 | + ')?\s*(' . |
|
| 42 | + "('([^']*)')" . |
|
| 43 | + '|("([^"]*)")' . |
|
| 44 | + '|\s*(%' . _SUB_REGEXP_SYMBOL . '+;)\s*' . |
|
| 45 | + ')\s*(--.*?--)?("([^"]*)")?\s*>\s*(.*)$/s'); |
|
| 46 | 46 | |
| 47 | 47 | define('_REGEXP_INCLUDE_USE', '/^<!\[\s*%\s*([^;]*);\s*\[\s*(.*)$/s'); |
| 48 | 48 | |
@@ -52,11 +52,11 @@ discard block |
||
| 52 | 52 | * Document Type Compilation |
| 53 | 53 | **/ |
| 54 | 54 | class DTC { |
| 55 | - public $macros = []; |
|
| 56 | - public $elements = []; |
|
| 57 | - public $peres = []; |
|
| 58 | - public $attributs = []; |
|
| 59 | - public $entites = []; |
|
| 60 | - public $regles = []; |
|
| 61 | - public $pcdata = []; |
|
| 55 | + public $macros = []; |
|
| 56 | + public $elements = []; |
|
| 57 | + public $peres = []; |
|
| 58 | + public $attributs = []; |
|
| 59 | + public $entites = []; |
|
| 60 | + public $regles = []; |
|
| 61 | + public $pcdata = []; |
|
| 62 | 62 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | include_spip('inc/charsets'); |
@@ -24,229 +24,229 @@ discard block |
||
| 24 | 24 | * @return string |
| 25 | 25 | */ |
| 26 | 26 | function xml_entites_html($texte) { |
| 27 | - if ( |
|
| 28 | - !is_string($texte) or !$texte |
|
| 29 | - or strpbrk($texte, "&\"'<>") == false |
|
| 30 | - ) { |
|
| 31 | - return $texte; |
|
| 32 | - } |
|
| 33 | - |
|
| 34 | - if (!function_exists('spip_htmlspecialchars')) { |
|
| 35 | - include_spip('inc/filtres_mini'); |
|
| 36 | - } |
|
| 37 | - $texte = spip_htmlspecialchars($texte, ENT_QUOTES); |
|
| 38 | - |
|
| 39 | - return $texte; |
|
| 27 | + if ( |
|
| 28 | + !is_string($texte) or !$texte |
|
| 29 | + or strpbrk($texte, "&\"'<>") == false |
|
| 30 | + ) { |
|
| 31 | + return $texte; |
|
| 32 | + } |
|
| 33 | + |
|
| 34 | + if (!function_exists('spip_htmlspecialchars')) { |
|
| 35 | + include_spip('inc/filtres_mini'); |
|
| 36 | + } |
|
| 37 | + $texte = spip_htmlspecialchars($texte, ENT_QUOTES); |
|
| 38 | + |
|
| 39 | + return $texte; |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | // https://code.spip.net/@xml_debutElement |
| 43 | 43 | function xml_debutElement($phraseur, $name, $attrs) { |
| 44 | - $depth = $phraseur->depth; |
|
| 45 | - |
|
| 46 | - $t = isset($phraseur->ouvrant[$depth]) ? $phraseur->ouvrant[$depth] : ' '; |
|
| 47 | - // espace initial signifie: deja integree au resultat |
|
| 48 | - if ($t[0] != ' ') { |
|
| 49 | - $phraseur->res .= '<' . $t . '>'; |
|
| 50 | - $phraseur->ouvrant[$depth] = ' ' . $t; |
|
| 51 | - } |
|
| 52 | - $t = $phraseur->contenu[$depth]; |
|
| 53 | - // n'indenter que s'il y a un separateur avant |
|
| 54 | - $phraseur->res .= preg_replace("/[\n\t ]+$/", "\n$depth", $t); |
|
| 55 | - $phraseur->contenu[$depth] = ''; |
|
| 56 | - $att = ''; |
|
| 57 | - $sep = ' '; |
|
| 58 | - foreach ($attrs as $k => $v) { |
|
| 59 | - $delim = strpos($v, "'") === false ? "'" : '"'; |
|
| 60 | - $val = xml_entites_html($v); |
|
| 61 | - $att .= $sep . $k . '=' . $delim |
|
| 62 | - . ($delim !== '"' ? str_replace('"', '"', $val) : $val) |
|
| 63 | - . $delim; |
|
| 64 | - $sep = "\n $depth"; |
|
| 65 | - } |
|
| 66 | - $phraseur->depth .= ' '; |
|
| 67 | - $phraseur->contenu[$phraseur->depth] = ''; |
|
| 68 | - $phraseur->ouvrant[$phraseur->depth] = $name . $att; |
|
| 69 | - $phraseur->reperes[$phraseur->depth] = xml_get_current_line_number($phraseur->sax); |
|
| 44 | + $depth = $phraseur->depth; |
|
| 45 | + |
|
| 46 | + $t = isset($phraseur->ouvrant[$depth]) ? $phraseur->ouvrant[$depth] : ' '; |
|
| 47 | + // espace initial signifie: deja integree au resultat |
|
| 48 | + if ($t[0] != ' ') { |
|
| 49 | + $phraseur->res .= '<' . $t . '>'; |
|
| 50 | + $phraseur->ouvrant[$depth] = ' ' . $t; |
|
| 51 | + } |
|
| 52 | + $t = $phraseur->contenu[$depth]; |
|
| 53 | + // n'indenter que s'il y a un separateur avant |
|
| 54 | + $phraseur->res .= preg_replace("/[\n\t ]+$/", "\n$depth", $t); |
|
| 55 | + $phraseur->contenu[$depth] = ''; |
|
| 56 | + $att = ''; |
|
| 57 | + $sep = ' '; |
|
| 58 | + foreach ($attrs as $k => $v) { |
|
| 59 | + $delim = strpos($v, "'") === false ? "'" : '"'; |
|
| 60 | + $val = xml_entites_html($v); |
|
| 61 | + $att .= $sep . $k . '=' . $delim |
|
| 62 | + . ($delim !== '"' ? str_replace('"', '"', $val) : $val) |
|
| 63 | + . $delim; |
|
| 64 | + $sep = "\n $depth"; |
|
| 65 | + } |
|
| 66 | + $phraseur->depth .= ' '; |
|
| 67 | + $phraseur->contenu[$phraseur->depth] = ''; |
|
| 68 | + $phraseur->ouvrant[$phraseur->depth] = $name . $att; |
|
| 69 | + $phraseur->reperes[$phraseur->depth] = xml_get_current_line_number($phraseur->sax); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | // https://code.spip.net/@xml_finElement |
| 73 | 73 | function xml_finElement($phraseur, $name, $fusion_bal = false) { |
| 74 | - $ouv = $phraseur->ouvrant[$phraseur->depth]; |
|
| 75 | - |
|
| 76 | - if ($ouv[0] != ' ') { |
|
| 77 | - $phraseur->ouvrant[$phraseur->depth] = ' ' . $ouv; |
|
| 78 | - } else { |
|
| 79 | - $ouv = ''; |
|
| 80 | - } |
|
| 81 | - $t = $phraseur->contenu[$phraseur->depth]; |
|
| 82 | - $phraseur->depth = substr($phraseur->depth, 2); |
|
| 83 | - $t = preg_replace("/[\n\t ]+$/", "\n" . $phraseur->depth, $t); |
|
| 84 | - |
|
| 85 | - // fusion <balise></balise> en <balise />. |
|
| 86 | - // ATTENTION, certains clients http croient que fusion ==> pas d'atttributs |
|
| 87 | - // en particulier pour les balises Script et A. |
|
| 88 | - // en presence d'attributs ne le faire que si la DTD est dispo et d'accord |
|
| 89 | - // (param fusion_bal) |
|
| 90 | - |
|
| 91 | - if ($t || (($ouv != $name) and !$fusion_bal)) { |
|
| 92 | - $phraseur->res .= ($ouv ? ('<' . $ouv . '>') : '') . $t . '</' . $name . '>'; |
|
| 93 | - } else { |
|
| 94 | - $phraseur->res .= ($ouv ? ('<' . $ouv . ' />') : ('</' . $name . '>')); |
|
| 95 | - } |
|
| 74 | + $ouv = $phraseur->ouvrant[$phraseur->depth]; |
|
| 75 | + |
|
| 76 | + if ($ouv[0] != ' ') { |
|
| 77 | + $phraseur->ouvrant[$phraseur->depth] = ' ' . $ouv; |
|
| 78 | + } else { |
|
| 79 | + $ouv = ''; |
|
| 80 | + } |
|
| 81 | + $t = $phraseur->contenu[$phraseur->depth]; |
|
| 82 | + $phraseur->depth = substr($phraseur->depth, 2); |
|
| 83 | + $t = preg_replace("/[\n\t ]+$/", "\n" . $phraseur->depth, $t); |
|
| 84 | + |
|
| 85 | + // fusion <balise></balise> en <balise />. |
|
| 86 | + // ATTENTION, certains clients http croient que fusion ==> pas d'atttributs |
|
| 87 | + // en particulier pour les balises Script et A. |
|
| 88 | + // en presence d'attributs ne le faire que si la DTD est dispo et d'accord |
|
| 89 | + // (param fusion_bal) |
|
| 90 | + |
|
| 91 | + if ($t || (($ouv != $name) and !$fusion_bal)) { |
|
| 92 | + $phraseur->res .= ($ouv ? ('<' . $ouv . '>') : '') . $t . '</' . $name . '>'; |
|
| 93 | + } else { |
|
| 94 | + $phraseur->res .= ($ouv ? ('<' . $ouv . ' />') : ('</' . $name . '>')); |
|
| 95 | + } |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | // https://code.spip.net/@xml_textElement |
| 99 | 99 | function xml_textElement($phraseur, $data) { |
| 100 | - $depth = $phraseur->depth; |
|
| 101 | - $phraseur->contenu[$depth] .= preg_match('/^script/', $phraseur->ouvrant[$depth]) |
|
| 102 | - ? $data |
|
| 103 | - : xml_entites_html($data); |
|
| 100 | + $depth = $phraseur->depth; |
|
| 101 | + $phraseur->contenu[$depth] .= preg_match('/^script/', $phraseur->ouvrant[$depth]) |
|
| 102 | + ? $data |
|
| 103 | + : xml_entites_html($data); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | function xml_piElement($phraseur, $target, $data) { |
| 107 | - $depth = $phraseur->depth; |
|
| 108 | - |
|
| 109 | - if (strtolower($target) != 'php') { |
|
| 110 | - $phraseur->contenu[$depth] .= $data; |
|
| 111 | - } else { |
|
| 112 | - ob_start(); |
|
| 113 | - eval($data); |
|
| 114 | - $data = ob_get_contents(); |
|
| 115 | - ob_end_clean(); |
|
| 116 | - $phraseur->contenu[$depth] .= $data; |
|
| 117 | - } |
|
| 107 | + $depth = $phraseur->depth; |
|
| 108 | + |
|
| 109 | + if (strtolower($target) != 'php') { |
|
| 110 | + $phraseur->contenu[$depth] .= $data; |
|
| 111 | + } else { |
|
| 112 | + ob_start(); |
|
| 113 | + eval($data); |
|
| 114 | + $data = ob_get_contents(); |
|
| 115 | + ob_end_clean(); |
|
| 116 | + $phraseur->contenu[$depth] .= $data; |
|
| 117 | + } |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | |
| 121 | 121 | // https://code.spip.net/@xml_defautElement |
| 122 | 122 | function xml_defaultElement($phraseur, $data) { |
| 123 | - $depth = $phraseur->depth; |
|
| 123 | + $depth = $phraseur->depth; |
|
| 124 | 124 | |
| 125 | - if (!isset($phraseur->contenu[$depth])) { |
|
| 126 | - $phraseur->contenu[$depth] = ''; |
|
| 127 | - } |
|
| 128 | - $phraseur->contenu[$depth] .= $data; |
|
| 125 | + if (!isset($phraseur->contenu[$depth])) { |
|
| 126 | + $phraseur->contenu[$depth] = ''; |
|
| 127 | + } |
|
| 128 | + $phraseur->contenu[$depth] .= $data; |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | // https://code.spip.net/@xml_parsestring |
| 132 | 132 | function xml_parsestring($phraseur, $data) { |
| 133 | - $phraseur->contenu[$phraseur->depth] = ''; |
|
| 134 | - |
|
| 135 | - if (!xml_parse($phraseur->sax, $data, true)) { |
|
| 136 | - coordonnees_erreur( |
|
| 137 | - $phraseur, |
|
| 138 | - xml_error_string(xml_get_error_code($phraseur->sax)) |
|
| 139 | - . "<br />\n" . |
|
| 140 | - (!$phraseur->depth ? '' : |
|
| 141 | - ('(' . |
|
| 142 | - _T('erreur_balise_non_fermee') . |
|
| 143 | - ' <tt>' . |
|
| 144 | - $phraseur->ouvrant[$phraseur->depth] . |
|
| 145 | - '</tt> ' . |
|
| 146 | - _T('ligne') . |
|
| 147 | - ' ' . |
|
| 148 | - $phraseur->reperes[$phraseur->depth] . |
|
| 149 | - ") <br />\n")) |
|
| 150 | - ); |
|
| 151 | - } |
|
| 133 | + $phraseur->contenu[$phraseur->depth] = ''; |
|
| 134 | + |
|
| 135 | + if (!xml_parse($phraseur->sax, $data, true)) { |
|
| 136 | + coordonnees_erreur( |
|
| 137 | + $phraseur, |
|
| 138 | + xml_error_string(xml_get_error_code($phraseur->sax)) |
|
| 139 | + . "<br />\n" . |
|
| 140 | + (!$phraseur->depth ? '' : |
|
| 141 | + ('(' . |
|
| 142 | + _T('erreur_balise_non_fermee') . |
|
| 143 | + ' <tt>' . |
|
| 144 | + $phraseur->ouvrant[$phraseur->depth] . |
|
| 145 | + '</tt> ' . |
|
| 146 | + _T('ligne') . |
|
| 147 | + ' ' . |
|
| 148 | + $phraseur->reperes[$phraseur->depth] . |
|
| 149 | + ") <br />\n")) |
|
| 150 | + ); |
|
| 151 | + } |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | // https://code.spip.net/@coordonnees_erreur |
| 155 | 155 | function coordonnees_erreur($phraseur, $msg) { |
| 156 | - $entete_length = substr_count($phraseur->entete, "\n"); |
|
| 157 | - $phraseur->err[] = [ |
|
| 158 | - $msg, |
|
| 159 | - xml_get_current_line_number($phraseur->sax) + $entete_length, |
|
| 160 | - xml_get_current_column_number($phraseur->sax) |
|
| 161 | - ]; |
|
| 156 | + $entete_length = substr_count($phraseur->entete, "\n"); |
|
| 157 | + $phraseur->err[] = [ |
|
| 158 | + $msg, |
|
| 159 | + xml_get_current_line_number($phraseur->sax) + $entete_length, |
|
| 160 | + xml_get_current_column_number($phraseur->sax) |
|
| 161 | + ]; |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | // https://code.spip.net/@xml_sax_dist |
| 165 | 165 | function xml_sax_dist($page, $apply = false, $phraseur = null, $doctype = '', $charset = null) { |
| 166 | - if (is_null($charset)) { |
|
| 167 | - $charset = $GLOBALS['meta']['charset']; |
|
| 168 | - } |
|
| 169 | - if ($apply) { |
|
| 170 | - ob_start(); |
|
| 171 | - if (is_array($apply)) { |
|
| 172 | - $r = call_user_func_array($page, $apply); |
|
| 173 | - } else { |
|
| 174 | - $r = $page(); |
|
| 175 | - } |
|
| 176 | - $page = ob_get_contents(); |
|
| 177 | - ob_end_clean(); |
|
| 178 | - // fonction sans aucun "echo", ca doit etre le resultat |
|
| 179 | - if (!$page) { |
|
| 180 | - $page = $r; |
|
| 181 | - } |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - if (!$page) { |
|
| 185 | - return ''; |
|
| 186 | - } |
|
| 187 | - // charger la DTD et transcoder les entites, |
|
| 188 | - // et escamoter le doctype que sax mange en php5 mais pas en php4 |
|
| 189 | - if (!$doctype) { |
|
| 190 | - if (!$r = analyser_doctype($page)) { |
|
| 191 | - $page = _MESSAGE_DOCTYPE . _DOCTYPE_ECRIRE |
|
| 192 | - . preg_replace(_REGEXP_DOCTYPE, '', $page); |
|
| 193 | - $r = analyser_doctype($page); |
|
| 194 | - } |
|
| 195 | - list($entete, $avail, $grammaire, $rotlvl) = array_pad($r, 4, null); |
|
| 196 | - $page = substr($page, strlen($entete)); |
|
| 197 | - } else { |
|
| 198 | - $avail = 'SYSTEM'; |
|
| 199 | - $grammaire = $doctype; |
|
| 200 | - $rotlvl = basename($grammaire); |
|
| 201 | - } |
|
| 202 | - |
|
| 203 | - include_spip('xml/analyser_dtd'); |
|
| 204 | - $dtc = charger_dtd($grammaire, $avail, $rotlvl); |
|
| 205 | - $page = sax_bug($page, $dtc, $charset); |
|
| 206 | - |
|
| 207 | - // compatibilite Tidy espace public |
|
| 208 | - if (!$phraseur) { |
|
| 209 | - $indenter_xml = charger_fonction('indenter', 'xml'); |
|
| 210 | - |
|
| 211 | - return $indenter_xml($page, $apply); |
|
| 212 | - } |
|
| 213 | - |
|
| 214 | - $xml_parser = xml_parser_create($charset); |
|
| 215 | - |
|
| 216 | - xml_set_element_handler( |
|
| 217 | - $xml_parser, |
|
| 218 | - [$phraseur, 'debutElement'], |
|
| 219 | - [$phraseur, 'finElement'] |
|
| 220 | - ); |
|
| 221 | - |
|
| 222 | - xml_set_character_data_handler( |
|
| 223 | - $xml_parser, |
|
| 224 | - [$phraseur, 'textElement'] |
|
| 225 | - ); |
|
| 226 | - |
|
| 227 | - xml_set_processing_instruction_handler( |
|
| 228 | - $xml_parser, |
|
| 229 | - [$phraseur, 'piElement'] |
|
| 230 | - ); |
|
| 231 | - |
|
| 232 | - xml_set_default_handler( |
|
| 233 | - $xml_parser, |
|
| 234 | - [$phraseur, 'defaultElement'] |
|
| 235 | - ); |
|
| 236 | - |
|
| 237 | - xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, false); |
|
| 238 | - |
|
| 239 | - $phraseur->sax = $xml_parser; |
|
| 240 | - if (isset($entete)) { |
|
| 241 | - $phraseur->entete = $entete; |
|
| 242 | - } |
|
| 243 | - $phraseur->page = $page; |
|
| 244 | - $phraseur->dtc = $dtc; |
|
| 245 | - $phraseur->phraserTout($xml_parser, $page); |
|
| 246 | - xml_parser_free($xml_parser); |
|
| 247 | - $phraseur->sax = ''; |
|
| 248 | - |
|
| 249 | - return $phraseur; |
|
| 166 | + if (is_null($charset)) { |
|
| 167 | + $charset = $GLOBALS['meta']['charset']; |
|
| 168 | + } |
|
| 169 | + if ($apply) { |
|
| 170 | + ob_start(); |
|
| 171 | + if (is_array($apply)) { |
|
| 172 | + $r = call_user_func_array($page, $apply); |
|
| 173 | + } else { |
|
| 174 | + $r = $page(); |
|
| 175 | + } |
|
| 176 | + $page = ob_get_contents(); |
|
| 177 | + ob_end_clean(); |
|
| 178 | + // fonction sans aucun "echo", ca doit etre le resultat |
|
| 179 | + if (!$page) { |
|
| 180 | + $page = $r; |
|
| 181 | + } |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + if (!$page) { |
|
| 185 | + return ''; |
|
| 186 | + } |
|
| 187 | + // charger la DTD et transcoder les entites, |
|
| 188 | + // et escamoter le doctype que sax mange en php5 mais pas en php4 |
|
| 189 | + if (!$doctype) { |
|
| 190 | + if (!$r = analyser_doctype($page)) { |
|
| 191 | + $page = _MESSAGE_DOCTYPE . _DOCTYPE_ECRIRE |
|
| 192 | + . preg_replace(_REGEXP_DOCTYPE, '', $page); |
|
| 193 | + $r = analyser_doctype($page); |
|
| 194 | + } |
|
| 195 | + list($entete, $avail, $grammaire, $rotlvl) = array_pad($r, 4, null); |
|
| 196 | + $page = substr($page, strlen($entete)); |
|
| 197 | + } else { |
|
| 198 | + $avail = 'SYSTEM'; |
|
| 199 | + $grammaire = $doctype; |
|
| 200 | + $rotlvl = basename($grammaire); |
|
| 201 | + } |
|
| 202 | + |
|
| 203 | + include_spip('xml/analyser_dtd'); |
|
| 204 | + $dtc = charger_dtd($grammaire, $avail, $rotlvl); |
|
| 205 | + $page = sax_bug($page, $dtc, $charset); |
|
| 206 | + |
|
| 207 | + // compatibilite Tidy espace public |
|
| 208 | + if (!$phraseur) { |
|
| 209 | + $indenter_xml = charger_fonction('indenter', 'xml'); |
|
| 210 | + |
|
| 211 | + return $indenter_xml($page, $apply); |
|
| 212 | + } |
|
| 213 | + |
|
| 214 | + $xml_parser = xml_parser_create($charset); |
|
| 215 | + |
|
| 216 | + xml_set_element_handler( |
|
| 217 | + $xml_parser, |
|
| 218 | + [$phraseur, 'debutElement'], |
|
| 219 | + [$phraseur, 'finElement'] |
|
| 220 | + ); |
|
| 221 | + |
|
| 222 | + xml_set_character_data_handler( |
|
| 223 | + $xml_parser, |
|
| 224 | + [$phraseur, 'textElement'] |
|
| 225 | + ); |
|
| 226 | + |
|
| 227 | + xml_set_processing_instruction_handler( |
|
| 228 | + $xml_parser, |
|
| 229 | + [$phraseur, 'piElement'] |
|
| 230 | + ); |
|
| 231 | + |
|
| 232 | + xml_set_default_handler( |
|
| 233 | + $xml_parser, |
|
| 234 | + [$phraseur, 'defaultElement'] |
|
| 235 | + ); |
|
| 236 | + |
|
| 237 | + xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, false); |
|
| 238 | + |
|
| 239 | + $phraseur->sax = $xml_parser; |
|
| 240 | + if (isset($entete)) { |
|
| 241 | + $phraseur->entete = $entete; |
|
| 242 | + } |
|
| 243 | + $phraseur->page = $page; |
|
| 244 | + $phraseur->dtc = $dtc; |
|
| 245 | + $phraseur->phraserTout($xml_parser, $page); |
|
| 246 | + xml_parser_free($xml_parser); |
|
| 247 | + $phraseur->sax = ''; |
|
| 248 | + |
|
| 249 | + return $phraseur; |
|
| 250 | 250 | } |
| 251 | 251 | |
| 252 | 252 | // SAX ne dit pas si une Entite est dans un attribut ou non. |
@@ -258,24 +258,24 @@ discard block |
||
| 258 | 258 | |
| 259 | 259 | // https://code.spip.net/@sax_bug |
| 260 | 260 | function sax_bug($data, $dtc, $charset = null) { |
| 261 | - if (is_null($charset)) { |
|
| 262 | - $charset = $GLOBALS['meta']['charset']; |
|
| 263 | - } |
|
| 264 | - |
|
| 265 | - if ($dtc) { |
|
| 266 | - $trans = []; |
|
| 267 | - |
|
| 268 | - foreach ($dtc->entites as $k => $v) { |
|
| 269 | - if (!strpos(' amp lt gt quot ', $k)) { |
|
| 270 | - $trans["&$k;"] = $v; |
|
| 271 | - } |
|
| 272 | - } |
|
| 273 | - $data = strtr($data, $trans); |
|
| 274 | - } else { |
|
| 275 | - $data = html2unicode($data, true); |
|
| 276 | - } |
|
| 277 | - |
|
| 278 | - return unicode2charset($data, $charset); |
|
| 261 | + if (is_null($charset)) { |
|
| 262 | + $charset = $GLOBALS['meta']['charset']; |
|
| 263 | + } |
|
| 264 | + |
|
| 265 | + if ($dtc) { |
|
| 266 | + $trans = []; |
|
| 267 | + |
|
| 268 | + foreach ($dtc->entites as $k => $v) { |
|
| 269 | + if (!strpos(' amp lt gt quot ', $k)) { |
|
| 270 | + $trans["&$k;"] = $v; |
|
| 271 | + } |
|
| 272 | + } |
|
| 273 | + $data = strtr($data, $trans); |
|
| 274 | + } else { |
|
| 275 | + $data = html2unicode($data, true); |
|
| 276 | + } |
|
| 277 | + |
|
| 278 | + return unicode2charset($data, $charset); |
|
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | // Retirer < ? xml... ? > et autre PI, ainsi que les commentaires en debut |
@@ -286,52 +286,52 @@ discard block |
||
| 286 | 286 | // mais un XML Schema que SPIP ne fait pas encore lire. |
| 287 | 287 | // https://code.spip.net/@analyser_doctype |
| 288 | 288 | function analyser_doctype($data) { |
| 289 | - if (!preg_match(_REGEXP_DOCTYPE, $data, $page)) { |
|
| 290 | - if (preg_match(_REGEXP_XML, $data, $page)) { |
|
| 291 | - list(, $entete, $topelement) = $page; |
|
| 292 | - if ($topelement == 'rss') { |
|
| 293 | - return [ |
|
| 294 | - $entete, |
|
| 295 | - 'PUBLIC', |
|
| 296 | - _DOCTYPE_RSS, |
|
| 297 | - 'rss-0.91.dtd' |
|
| 298 | - ]; |
|
| 299 | - } else { |
|
| 300 | - $dtd = $topelement . '.dtd'; |
|
| 301 | - $f = find_in_path($dtd); |
|
| 302 | - if (file_exists($f)) { |
|
| 303 | - return [$entete, 'SYSTEM', $f, $dtd]; |
|
| 304 | - } |
|
| 305 | - } |
|
| 306 | - } |
|
| 307 | - spip_log('Dtd pas vu pour ' . substr($data, 0, 100)); |
|
| 308 | - |
|
| 309 | - return []; |
|
| 310 | - } |
|
| 311 | - list($entete, , $topelement, $avail, $suite) = $page; |
|
| 312 | - |
|
| 313 | - if (!preg_match('/^"([^"]*)"\s*(.*)$/', $suite, $r)) { |
|
| 314 | - if (!preg_match("/^'([^']*)'\s*(.*)$/", $suite, $r)) { |
|
| 315 | - return []; |
|
| 316 | - } |
|
| 317 | - } |
|
| 318 | - list(, $rotlvl, $suite) = $r; |
|
| 319 | - |
|
| 320 | - if (!$suite) { |
|
| 321 | - if ($avail != 'SYSTEM') { |
|
| 322 | - return []; |
|
| 323 | - } |
|
| 324 | - $grammaire = $rotlvl; |
|
| 325 | - $rotlvl = ''; |
|
| 326 | - } else { |
|
| 327 | - if (!preg_match('/^"([^"]*)"\s*$/', $suite, $r)) { |
|
| 328 | - if (!preg_match("/^'([^']*)'\s*$/", $suite, $r)) { |
|
| 329 | - return []; |
|
| 330 | - } |
|
| 331 | - } |
|
| 332 | - |
|
| 333 | - $grammaire = $r[1]; |
|
| 334 | - } |
|
| 335 | - |
|
| 336 | - return [$entete, $avail, $grammaire, $rotlvl]; |
|
| 289 | + if (!preg_match(_REGEXP_DOCTYPE, $data, $page)) { |
|
| 290 | + if (preg_match(_REGEXP_XML, $data, $page)) { |
|
| 291 | + list(, $entete, $topelement) = $page; |
|
| 292 | + if ($topelement == 'rss') { |
|
| 293 | + return [ |
|
| 294 | + $entete, |
|
| 295 | + 'PUBLIC', |
|
| 296 | + _DOCTYPE_RSS, |
|
| 297 | + 'rss-0.91.dtd' |
|
| 298 | + ]; |
|
| 299 | + } else { |
|
| 300 | + $dtd = $topelement . '.dtd'; |
|
| 301 | + $f = find_in_path($dtd); |
|
| 302 | + if (file_exists($f)) { |
|
| 303 | + return [$entete, 'SYSTEM', $f, $dtd]; |
|
| 304 | + } |
|
| 305 | + } |
|
| 306 | + } |
|
| 307 | + spip_log('Dtd pas vu pour ' . substr($data, 0, 100)); |
|
| 308 | + |
|
| 309 | + return []; |
|
| 310 | + } |
|
| 311 | + list($entete, , $topelement, $avail, $suite) = $page; |
|
| 312 | + |
|
| 313 | + if (!preg_match('/^"([^"]*)"\s*(.*)$/', $suite, $r)) { |
|
| 314 | + if (!preg_match("/^'([^']*)'\s*(.*)$/", $suite, $r)) { |
|
| 315 | + return []; |
|
| 316 | + } |
|
| 317 | + } |
|
| 318 | + list(, $rotlvl, $suite) = $r; |
|
| 319 | + |
|
| 320 | + if (!$suite) { |
|
| 321 | + if ($avail != 'SYSTEM') { |
|
| 322 | + return []; |
|
| 323 | + } |
|
| 324 | + $grammaire = $rotlvl; |
|
| 325 | + $rotlvl = ''; |
|
| 326 | + } else { |
|
| 327 | + if (!preg_match('/^"([^"]*)"\s*$/', $suite, $r)) { |
|
| 328 | + if (!preg_match("/^'([^']*)'\s*$/", $suite, $r)) { |
|
| 329 | + return []; |
|
| 330 | + } |
|
| 331 | + } |
|
| 332 | + |
|
| 333 | + $grammaire = $r[1]; |
|
| 334 | + } |
|
| 335 | + |
|
| 336 | + return [$entete, $avail, $grammaire, $rotlvl]; |
|
| 337 | 337 | } |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | define('URLS_PAGE_EXEMPLE', 'spip.php?article12'); |
@@ -30,74 +30,74 @@ discard block |
||
| 30 | 30 | // https://code.spip.net/@_generer_url_page |
| 31 | 31 | function _generer_url_page($type, $id, $args = '', $ancre = '') { |
| 32 | 32 | |
| 33 | - if ($generer_url_externe = charger_fonction("generer_url_$type", 'urls', true)) { |
|
| 34 | - $url = $generer_url_externe($id, $args, $ancre); |
|
| 35 | - if (null != $url) { |
|
| 36 | - return $url; |
|
| 37 | - } |
|
| 38 | - } |
|
| 33 | + if ($generer_url_externe = charger_fonction("generer_url_$type", 'urls', true)) { |
|
| 34 | + $url = $generer_url_externe($id, $args, $ancre); |
|
| 35 | + if (null != $url) { |
|
| 36 | + return $url; |
|
| 37 | + } |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - $url = _debut_urls_page . $type . _separateur_urls_page |
|
| 41 | - . $id . _terminaison_urls_page; |
|
| 40 | + $url = _debut_urls_page . $type . _separateur_urls_page |
|
| 41 | + . $id . _terminaison_urls_page; |
|
| 42 | 42 | |
| 43 | - if ($args) { |
|
| 44 | - $args = strpos($url, '?') ? "&$args" : "?$args"; |
|
| 45 | - } |
|
| 43 | + if ($args) { |
|
| 44 | + $args = strpos($url, '?') ? "&$args" : "?$args"; |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - return _DIR_RACINE . $url . $args . ($ancre ? "#$ancre" : ''); |
|
| 47 | + return _DIR_RACINE . $url . $args . ($ancre ? "#$ancre" : ''); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | // retrouve le fond et les parametres d'une URL abregee |
| 51 | 51 | // le contexte deja existant est fourni dans args sous forme de tableau ou query string |
| 52 | 52 | // https://code.spip.net/@urls_page_dist |
| 53 | 53 | function urls_page_dist($i, &$entite, $args = '', $ancre = '') { |
| 54 | - if (is_numeric($i)) { |
|
| 55 | - return _generer_url_page($entite, $i, $args, $ancre); |
|
| 56 | - } |
|
| 54 | + if (is_numeric($i)) { |
|
| 55 | + return _generer_url_page($entite, $i, $args, $ancre); |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - // traiter les injections du type domaine.org/spip.php/cestnimportequoi/ou/encore/plus/rubrique23 |
|
| 59 | - if ($GLOBALS['profondeur_url'] > 0 and $entite == 'sommaire') { |
|
| 60 | - return [[], '404']; |
|
| 61 | - } |
|
| 58 | + // traiter les injections du type domaine.org/spip.php/cestnimportequoi/ou/encore/plus/rubrique23 |
|
| 59 | + if ($GLOBALS['profondeur_url'] > 0 and $entite == 'sommaire') { |
|
| 60 | + return [[], '404']; |
|
| 61 | + } |
|
| 62 | 62 | |
| 63 | - // voir s'il faut recuperer le id_* implicite et les &debut_xx; |
|
| 64 | - if (is_array($args)) { |
|
| 65 | - $contexte = $args; |
|
| 66 | - } else { |
|
| 67 | - parse_str($args, $contexte); |
|
| 68 | - } |
|
| 69 | - include_spip('inc/urls'); |
|
| 70 | - $r = nettoyer_url_page($i, $contexte); |
|
| 71 | - if ($r) { |
|
| 72 | - array_pop($r); // nettoyer_url_page renvoie un argument de plus inutile ici |
|
| 73 | - return $r; |
|
| 74 | - } |
|
| 63 | + // voir s'il faut recuperer le id_* implicite et les &debut_xx; |
|
| 64 | + if (is_array($args)) { |
|
| 65 | + $contexte = $args; |
|
| 66 | + } else { |
|
| 67 | + parse_str($args, $contexte); |
|
| 68 | + } |
|
| 69 | + include_spip('inc/urls'); |
|
| 70 | + $r = nettoyer_url_page($i, $contexte); |
|
| 71 | + if ($r) { |
|
| 72 | + array_pop($r); // nettoyer_url_page renvoie un argument de plus inutile ici |
|
| 73 | + return $r; |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - /* |
|
| 76 | + /* |
|
| 77 | 77 | * Le bloc qui suit sert a faciliter les transitions depuis |
| 78 | 78 | * le mode 'urls-propres' vers les modes 'urls-standard' et 'url-html' |
| 79 | 79 | * Il est inutile de le recopier si vous personnalisez vos URLs |
| 80 | 80 | * et votre .htaccess |
| 81 | 81 | */ |
| 82 | - // Si on est revenu en mode html, mais c'est une ancienne url_propre |
|
| 83 | - // on ne redirige pas, on assume le nouveau contexte (si possible) |
|
| 84 | - $url = $i; |
|
| 85 | - $url_propre = isset($url) |
|
| 86 | - ? $url |
|
| 87 | - : (isset($_SERVER['REDIRECT_url_propre']) |
|
| 88 | - ? $_SERVER['REDIRECT_url_propre'] |
|
| 89 | - : (isset($_ENV['url_propre']) |
|
| 90 | - ? $_ENV['url_propre'] |
|
| 91 | - : '' |
|
| 92 | - )); |
|
| 93 | - if ($url_propre) { |
|
| 94 | - if ($GLOBALS['profondeur_url'] <= 0) { |
|
| 95 | - $urls_anciennes = charger_fonction('propres', 'urls', true); |
|
| 96 | - } else { |
|
| 97 | - $urls_anciennes = charger_fonction('arbo', 'urls', true); |
|
| 98 | - } |
|
| 82 | + // Si on est revenu en mode html, mais c'est une ancienne url_propre |
|
| 83 | + // on ne redirige pas, on assume le nouveau contexte (si possible) |
|
| 84 | + $url = $i; |
|
| 85 | + $url_propre = isset($url) |
|
| 86 | + ? $url |
|
| 87 | + : (isset($_SERVER['REDIRECT_url_propre']) |
|
| 88 | + ? $_SERVER['REDIRECT_url_propre'] |
|
| 89 | + : (isset($_ENV['url_propre']) |
|
| 90 | + ? $_ENV['url_propre'] |
|
| 91 | + : '' |
|
| 92 | + )); |
|
| 93 | + if ($url_propre) { |
|
| 94 | + if ($GLOBALS['profondeur_url'] <= 0) { |
|
| 95 | + $urls_anciennes = charger_fonction('propres', 'urls', true); |
|
| 96 | + } else { |
|
| 97 | + $urls_anciennes = charger_fonction('arbo', 'urls', true); |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | - return $urls_anciennes ? $urls_anciennes($url_propre, $entite, $contexte) : ''; |
|
| 101 | - } |
|
| 102 | - /* Fin du bloc compatibilite url-propres */ |
|
| 100 | + return $urls_anciennes ? $urls_anciennes($url_propre, $entite, $contexte) : ''; |
|
| 101 | + } |
|
| 102 | + /* Fin du bloc compatibilite url-propres */ |
|
| 103 | 103 | } |
@@ -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 | |
@@ -36,22 +36,22 @@ discard block |
||
| 36 | 36 | * Description de la boucle complétée des champs |
| 37 | 37 | */ |
| 38 | 38 | function iterateur_php_dist($b, $iteratorName) { |
| 39 | - $b->iterateur = $iteratorName; # designe la classe d'iterateur |
|
| 40 | - $b->show = [ |
|
| 41 | - 'field' => [ |
|
| 42 | - 'cle' => 'STRING', |
|
| 43 | - 'valeur' => 'STRING', |
|
| 44 | - ] |
|
| 45 | - ]; |
|
| 46 | - foreach (get_class_methods($iteratorName) as $method) { |
|
| 47 | - $b->show['field'][strtolower($method)] = 'METHOD'; |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - /* |
|
| 39 | + $b->iterateur = $iteratorName; # designe la classe d'iterateur |
|
| 40 | + $b->show = [ |
|
| 41 | + 'field' => [ |
|
| 42 | + 'cle' => 'STRING', |
|
| 43 | + 'valeur' => 'STRING', |
|
| 44 | + ] |
|
| 45 | + ]; |
|
| 46 | + foreach (get_class_methods($iteratorName) as $method) { |
|
| 47 | + $b->show['field'][strtolower($method)] = 'METHOD'; |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + /* |
|
| 51 | 51 | foreach (get_class_vars($iteratorName) as $property) { |
| 52 | 52 | $b->show['field'][ strtolower($property) ] = 'PROPERTY'; |
| 53 | 53 | } |
| 54 | 54 | */ |
| 55 | 55 | |
| 56 | - return $b; |
|
| 56 | + return $b; |
|
| 57 | 57 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | include_spip('iterateur/data'); |
@@ -39,13 +39,13 @@ discard block |
||
| 39 | 39 | * Description de la boucle complétée des champs |
| 40 | 40 | */ |
| 41 | 41 | function iterateur_POUR_dist($b) { |
| 42 | - $b->iterateur = 'DATA'; # designe la classe d'iterateur |
|
| 43 | - $b->show = [ |
|
| 44 | - 'field' => [ |
|
| 45 | - 'cle' => 'STRING', |
|
| 46 | - 'valeur' => 'STRING', |
|
| 47 | - ] |
|
| 48 | - ]; |
|
| 42 | + $b->iterateur = 'DATA'; # designe la classe d'iterateur |
|
| 43 | + $b->show = [ |
|
| 44 | + 'field' => [ |
|
| 45 | + 'cle' => 'STRING', |
|
| 46 | + 'valeur' => 'STRING', |
|
| 47 | + ] |
|
| 48 | + ]; |
|
| 49 | 49 | |
| 50 | - return $b; |
|
| 50 | + return $b; |
|
| 51 | 51 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | **/ |
| 18 | 18 | |
| 19 | 19 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 20 | - return; |
|
| 20 | + return; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | include_spip('iterateur/data'); |
@@ -35,12 +35,12 @@ discard block |
||
| 35 | 35 | * Description de la boucle complétée des champs |
| 36 | 36 | */ |
| 37 | 37 | function iterateur_CONDITION_dist($b) { |
| 38 | - $b->iterateur = 'CONDITION'; # designe la classe d'iterateur |
|
| 39 | - $b->show = [ |
|
| 40 | - 'field' => [] |
|
| 41 | - ]; |
|
| 38 | + $b->iterateur = 'CONDITION'; # designe la classe d'iterateur |
|
| 39 | + $b->show = [ |
|
| 40 | + 'field' => [] |
|
| 41 | + ]; |
|
| 42 | 42 | |
| 43 | - return $b; |
|
| 43 | + return $b; |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | /** |
@@ -49,12 +49,12 @@ discard block |
||
| 49 | 49 | * La boucle condition n'a toujours qu'un seul élément. |
| 50 | 50 | */ |
| 51 | 51 | class IterateurCONDITION extends IterateurData { |
| 52 | - /** |
|
| 53 | - * Obtenir les données de la boucle CONDITION |
|
| 54 | - * |
|
| 55 | - * @param array $command |
|
| 56 | - **/ |
|
| 57 | - protected function select($command) { |
|
| 58 | - $this->tableau = [0 => 1]; |
|
| 59 | - } |
|
| 52 | + /** |
|
| 53 | + * Obtenir les données de la boucle CONDITION |
|
| 54 | + * |
|
| 55 | + * @param array $command |
|
| 56 | + **/ |
|
| 57 | + protected function select($command) { |
|
| 58 | + $this->tableau = [0 => 1]; |
|
| 59 | + } |
|
| 60 | 60 | } |
@@ -11,77 +11,77 @@ |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | if (!defined('_ECRIRE_INC_VERSION')) { |
| 14 | - return; |
|
| 14 | + return; |
|
| 15 | 15 | } |
| 16 | 16 | |
| 17 | 17 | // https://code.spip.net/@install_etape_ldap2_dist |
| 18 | 18 | function install_etape_ldap2_dist() { |
| 19 | - echo install_debut_html('AUTO', ' onload="document.getElementById(\'suivant\').focus();return false;"'); |
|
| 19 | + echo install_debut_html('AUTO', ' onload="document.getElementById(\'suivant\').focus();return false;"'); |
|
| 20 | 20 | |
| 21 | - $adresse_ldap = _request('adresse_ldap'); |
|
| 21 | + $adresse_ldap = _request('adresse_ldap'); |
|
| 22 | 22 | |
| 23 | - $port_ldap = _request('port_ldap'); |
|
| 23 | + $port_ldap = _request('port_ldap'); |
|
| 24 | 24 | |
| 25 | - $tls_ldap = _request('tls_ldap'); |
|
| 25 | + $tls_ldap = _request('tls_ldap'); |
|
| 26 | 26 | |
| 27 | - $protocole_ldap = _request('protocole_ldap'); |
|
| 27 | + $protocole_ldap = _request('protocole_ldap'); |
|
| 28 | 28 | |
| 29 | - $login_ldap = _request('login_ldap'); |
|
| 29 | + $login_ldap = _request('login_ldap'); |
|
| 30 | 30 | |
| 31 | - $pass_ldap = _request('pass_ldap'); |
|
| 31 | + $pass_ldap = _request('pass_ldap'); |
|
| 32 | 32 | |
| 33 | - $port_ldap = intval($port_ldap); |
|
| 33 | + $port_ldap = intval($port_ldap); |
|
| 34 | 34 | |
| 35 | - $tls = false; |
|
| 35 | + $tls = false; |
|
| 36 | 36 | |
| 37 | - if ($tls_ldap == 'oui') { |
|
| 38 | - if ($port_ldap == 636) { |
|
| 39 | - $adresse_ldap = "ldaps://$adresse_ldap"; |
|
| 40 | - } else { |
|
| 41 | - $tls = true; |
|
| 42 | - } |
|
| 43 | - } |
|
| 44 | - $ldap_link = ldap_connect($adresse_ldap, $port_ldap); |
|
| 45 | - $erreur = "ldap_connect($adresse_ldap, $port_ldap)"; |
|
| 37 | + if ($tls_ldap == 'oui') { |
|
| 38 | + if ($port_ldap == 636) { |
|
| 39 | + $adresse_ldap = "ldaps://$adresse_ldap"; |
|
| 40 | + } else { |
|
| 41 | + $tls = true; |
|
| 42 | + } |
|
| 43 | + } |
|
| 44 | + $ldap_link = ldap_connect($adresse_ldap, $port_ldap); |
|
| 45 | + $erreur = "ldap_connect($adresse_ldap, $port_ldap)"; |
|
| 46 | 46 | |
| 47 | - if ($ldap_link) { |
|
| 48 | - if (!ldap_set_option($ldap_link, LDAP_OPT_PROTOCOL_VERSION, $protocole_ldap)) { |
|
| 49 | - $protocole_ldap = 2; |
|
| 50 | - ldap_set_option($ldap_link, LDAP_OPT_PROTOCOL_VERSION, $protocole_ldap); |
|
| 51 | - } |
|
| 52 | - if ($tls === true) { |
|
| 53 | - if (!ldap_start_tls($ldap_link)) { |
|
| 54 | - $erreur = "ldap_start_tls($ldap_link) $adresse_ldap, $port_ldap"; |
|
| 55 | - $ldap_link = false; |
|
| 56 | - } |
|
| 57 | - } |
|
| 58 | - if ($ldap_link) { |
|
| 59 | - $ldap_link = ldap_bind($ldap_link, $login_ldap, $pass_ldap); |
|
| 60 | - $erreur = "ldap_bind('$ldap_link', '$login_ldap', '$pass_ldap'): $adresse_ldap, $port_ldap"; |
|
| 61 | - } |
|
| 62 | - } |
|
| 47 | + if ($ldap_link) { |
|
| 48 | + if (!ldap_set_option($ldap_link, LDAP_OPT_PROTOCOL_VERSION, $protocole_ldap)) { |
|
| 49 | + $protocole_ldap = 2; |
|
| 50 | + ldap_set_option($ldap_link, LDAP_OPT_PROTOCOL_VERSION, $protocole_ldap); |
|
| 51 | + } |
|
| 52 | + if ($tls === true) { |
|
| 53 | + if (!ldap_start_tls($ldap_link)) { |
|
| 54 | + $erreur = "ldap_start_tls($ldap_link) $adresse_ldap, $port_ldap"; |
|
| 55 | + $ldap_link = false; |
|
| 56 | + } |
|
| 57 | + } |
|
| 58 | + if ($ldap_link) { |
|
| 59 | + $ldap_link = ldap_bind($ldap_link, $login_ldap, $pass_ldap); |
|
| 60 | + $erreur = "ldap_bind('$ldap_link', '$login_ldap', '$pass_ldap'): $adresse_ldap, $port_ldap"; |
|
| 61 | + } |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - if ($ldap_link) { |
|
| 65 | - echo info_etape( |
|
| 66 | - _T('titre_connexion_ldap'), |
|
| 67 | - info_progression_etape(2, 'etape_ldap', 'install/') |
|
| 68 | - ), _T('info_connexion_ldap_ok'); |
|
| 69 | - echo generer_form_ecrire('install', ( |
|
| 70 | - "\n<input type='hidden' name='etape' value='ldap3' />" |
|
| 71 | - . "\n<input type='hidden' name='adresse_ldap' value=\"$adresse_ldap\" />" |
|
| 72 | - . "\n<input type='hidden' name='port_ldap' value=\"$port_ldap\" />" |
|
| 73 | - . "\n<input type='hidden' name='login_ldap' value=\"$login_ldap\" />" |
|
| 74 | - . "\n<input type='hidden' name='pass_ldap' value=\"$pass_ldap\" />" |
|
| 75 | - . "\n<input type='hidden' name='protocole_ldap' value=\"$protocole_ldap\" />" |
|
| 76 | - . "\n<input type='hidden' name='tls_ldap' value=\"$tls_ldap\" />" |
|
| 77 | - . bouton_suivant())); |
|
| 78 | - } else { |
|
| 79 | - echo info_etape(_T('titre_connexion_ldap')), info_progression_etape(1, 'etape_ldap', 'install/', true), |
|
| 80 | - "<div class='error'><p>" . _T('avis_connexion_ldap_echec_1') . '</p>', |
|
| 81 | - '<p>' . _T('avis_connexion_ldap_echec_2') . |
|
| 82 | - "<br />\n" . _T('avis_connexion_ldap_echec_3') . |
|
| 83 | - '<br /><br />' . $erreur . '<b> ?</b></p></div>'; |
|
| 84 | - } |
|
| 64 | + if ($ldap_link) { |
|
| 65 | + echo info_etape( |
|
| 66 | + _T('titre_connexion_ldap'), |
|
| 67 | + info_progression_etape(2, 'etape_ldap', 'install/') |
|
| 68 | + ), _T('info_connexion_ldap_ok'); |
|
| 69 | + echo generer_form_ecrire('install', ( |
|
| 70 | + "\n<input type='hidden' name='etape' value='ldap3' />" |
|
| 71 | + . "\n<input type='hidden' name='adresse_ldap' value=\"$adresse_ldap\" />" |
|
| 72 | + . "\n<input type='hidden' name='port_ldap' value=\"$port_ldap\" />" |
|
| 73 | + . "\n<input type='hidden' name='login_ldap' value=\"$login_ldap\" />" |
|
| 74 | + . "\n<input type='hidden' name='pass_ldap' value=\"$pass_ldap\" />" |
|
| 75 | + . "\n<input type='hidden' name='protocole_ldap' value=\"$protocole_ldap\" />" |
|
| 76 | + . "\n<input type='hidden' name='tls_ldap' value=\"$tls_ldap\" />" |
|
| 77 | + . bouton_suivant())); |
|
| 78 | + } else { |
|
| 79 | + echo info_etape(_T('titre_connexion_ldap')), info_progression_etape(1, 'etape_ldap', 'install/', true), |
|
| 80 | + "<div class='error'><p>" . _T('avis_connexion_ldap_echec_1') . '</p>', |
|
| 81 | + '<p>' . _T('avis_connexion_ldap_echec_2') . |
|
| 82 | + "<br />\n" . _T('avis_connexion_ldap_echec_3') . |
|
| 83 | + '<br /><br />' . $erreur . '<b> ?</b></p></div>'; |
|
| 84 | + } |
|
| 85 | 85 | |
| 86 | - echo install_fin_html(); |
|
| 86 | + echo install_fin_html(); |
|
| 87 | 87 | } |