@@ -135,15 +135,41 @@ discard block |
||
| 135 | 135 | return (int)$x >> (int)$n; |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | + /** |
|
| 139 | + * @param integer $n |
|
| 140 | + */ |
|
| 138 | 141 | function ROTR($x, $n) { return (int)(($this->SHR($x, $n) | ($x << (32-$n)) & 0xFFFFFFFF)); } |
| 142 | + |
|
| 143 | + /** |
|
| 144 | + * @param integer $x |
|
| 145 | + * @param integer $y |
|
| 146 | + * @param integer $z |
|
| 147 | + */ |
|
| 139 | 148 | function Ch($x, $y, $z) { return ($x & $y) ^ ((~$x) & $z); } |
| 149 | + |
|
| 150 | + /** |
|
| 151 | + * @param integer $x |
|
| 152 | + * @param integer $y |
|
| 153 | + * @param integer $z |
|
| 154 | + */ |
|
| 140 | 155 | function Maj($x, $y, $z) { return ($x & $y) ^ ($x & $z) ^ ($y & $z); } |
| 156 | + |
|
| 157 | + /** |
|
| 158 | + * @param integer $x |
|
| 159 | + */ |
|
| 141 | 160 | function Sigma0($x) { return (int) ($this->ROTR($x, 2)^$this->ROTR($x, 13)^$this->ROTR($x, 22)); } |
| 161 | + |
|
| 162 | + /** |
|
| 163 | + * @param integer $x |
|
| 164 | + */ |
|
| 142 | 165 | function Sigma1($x) { return (int) ($this->ROTR($x, 6)^$this->ROTR($x, 11)^$this->ROTR($x, 25)); } |
| 143 | 166 | function sigma_0($x) { return (int) ($this->ROTR($x, 7)^$this->ROTR($x, 18)^$this->SHR($x, 3)); } |
| 144 | 167 | function sigma_1($x) { return (int) ($this->ROTR($x, 17)^$this->ROTR($x, 19)^$this->SHR($x, 10)); } |
| 145 | 168 | |
| 146 | 169 | |
| 170 | + /** |
|
| 171 | + * @param integer $byteSize |
|
| 172 | + */ |
|
| 147 | 173 | function string2ordUTF8($s,&$byteSize){ |
| 148 | 174 | $chars = array(); |
| 149 | 175 | // par defaut sur 8bits |
@@ -219,6 +245,9 @@ discard block |
||
| 219 | 245 | return $bin; |
| 220 | 246 | } |
| 221 | 247 | |
| 248 | + /** |
|
| 249 | + * @param integer $n |
|
| 250 | + */ |
|
| 222 | 251 | function array_split($a, $n) { |
| 223 | 252 | $split = array(); |
| 224 | 253 | while (count($a)>$n) { |
@@ -434,6 +463,10 @@ discard block |
||
| 434 | 463 | if (!function_exists('hash')) |
| 435 | 464 | { |
| 436 | 465 | define('_NO_HASH_DEFINED',true); |
| 466 | + |
|
| 467 | + /** |
|
| 468 | + * @param string $algo |
|
| 469 | + */ |
|
| 437 | 470 | function hash($algo, $data) |
| 438 | 471 | { |
| 439 | 472 | if (empty($algo) || !is_string($algo) || !is_string($data)) { |
@@ -155,7 +155,9 @@ discard block |
||
| 155 | 155 | // mais si un char necessite 16bits, on passe tout sur 16 |
| 156 | 156 | // sinon on ne concorde pas avec le lecture de la chaine en js |
| 157 | 157 | // et le sha256 js |
| 158 | - if ($bytes>1) $byteSize = 16; |
|
| 158 | + if ($bytes>1) { |
|
| 159 | + $byteSize = 16; |
|
| 160 | + } |
|
| 159 | 161 | } |
| 160 | 162 | return $chars; |
| 161 | 163 | } |
@@ -165,36 +167,32 @@ discard block |
||
| 165 | 167 | $len = strlen($c); |
| 166 | 168 | $bytes = 0; |
| 167 | 169 | |
| 168 | - if ($index >= $len) |
|
| 169 | - return false; |
|
| 170 | + if ($index >= $len) { |
|
| 171 | + return false; |
|
| 172 | + } |
|
| 170 | 173 | |
| 171 | 174 | $h = ord($c{$index}); |
| 172 | 175 | |
| 173 | 176 | if ($h <= 0x7F) { |
| 174 | 177 | $bytes = 1; |
| 175 | 178 | return $h; |
| 176 | - } |
|
| 177 | - else if ($h < 0xC2){ |
|
| 179 | + } else if ($h < 0xC2){ |
|
| 178 | 180 | // pas utf mais renvoyer quand meme ce qu'on a |
| 179 | 181 | $bytes = 1; |
| 180 | 182 | return $h; |
| 181 | - } |
|
| 182 | - else if ($h <= 0xDF && $index < $len - 1) { |
|
| 183 | + } else if ($h <= 0xDF && $index < $len - 1) { |
|
| 183 | 184 | $bytes = 2; |
| 184 | 185 | return ($h & 0x1F) << 6 | (ord($c{$index + 1}) & 0x3F); |
| 185 | - } |
|
| 186 | - else if ($h <= 0xEF && $index < $len - 2) { |
|
| 186 | + } else if ($h <= 0xEF && $index < $len - 2) { |
|
| 187 | 187 | $bytes = 3; |
| 188 | 188 | return ($h & 0x0F) << 12 | (ord($c{$index + 1}) & 0x3F) << 6 |
| 189 | 189 | | (ord($c{$index + 2}) & 0x3F); |
| 190 | - } |
|
| 191 | - else if ($h <= 0xF4 && $index < $len - 3) { |
|
| 190 | + } else if ($h <= 0xF4 && $index < $len - 3) { |
|
| 192 | 191 | $bytes = 4; |
| 193 | 192 | return ($h & 0x0F) << 18 | (ord($c{$index + 1}) & 0x3F) << 12 |
| 194 | 193 | | (ord($c{$index + 2}) & 0x3F) << 6 |
| 195 | 194 | | (ord($c{$index + 3}) & 0x3F); |
| 196 | - } |
|
| 197 | - else { |
|
| 195 | + } else { |
|
| 198 | 196 | // pas utf mais renvoyer quand meme ce qu'on a |
| 199 | 197 | $bytes = 1; |
| 200 | 198 | return $h; |
@@ -222,8 +220,9 @@ discard block |
||
| 222 | 220 | $split = array(); |
| 223 | 221 | while (count($a)>$n) { |
| 224 | 222 | $s = array(); |
| 225 | - for($i = 0;$i<$n;$i++) |
|
| 226 | - $s[] = array_shift($a); |
|
| 223 | + for($i = 0;$i<$n;$i++) { |
|
| 224 | + $s[] = array_shift($a); |
|
| 225 | + } |
|
| 227 | 226 | $split[] = $s; |
| 228 | 227 | } |
| 229 | 228 | if (count($a)){ |
@@ -96,6 +96,13 @@ |
||
| 96 | 96 | return $p; |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | +/** |
|
| 100 | + * @param string $id_objet |
|
| 101 | + * @param string $_id_objet |
|
| 102 | + * @param string $type |
|
| 103 | + * @param integer $fichier |
|
| 104 | + * @param string $suite |
|
| 105 | + */ |
|
| 99 | 106 | function logo_survol($id_objet, $_id_objet, $type, $align, $fichier, $lien, $p, $suite) |
| 100 | 107 | { |
| 101 | 108 | $code = "quete_logo('$id_objet', '" . |
@@ -10,7 +10,9 @@ discard block |
||
| 10 | 10 | * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * |
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | -if (!defined('_ECRIRE_INC_VERSION')) return; |
|
| 13 | +if (!defined('_ECRIRE_INC_VERSION')) { |
|
| 14 | + return; |
|
| 15 | +} |
|
| 14 | 16 | |
| 15 | 17 | // |
| 16 | 18 | // Fonction des balises #LOGO_XXXX |
@@ -31,8 +33,9 @@ discard block |
||
| 31 | 33 | } |
| 32 | 34 | |
| 33 | 35 | $id_objet = id_table_objet($type); |
| 34 | - if (!isset($_id_objet) OR !$_id_objet) |
|
| 35 | - $_id_objet = champ_sql($id_objet, $p); |
|
| 36 | + if (!isset($_id_objet) OR !$_id_objet) { |
|
| 37 | + $_id_objet = champ_sql($id_objet, $p); |
|
| 38 | + } |
|
| 36 | 39 | |
| 37 | 40 | $fichier = ($p->etoile === '**') ? -1 : 0; |
| 38 | 41 | $coord = array(); |
@@ -45,14 +48,16 @@ discard block |
||
| 45 | 48 | foreach($params as $a) { |
| 46 | 49 | if ($a[0]->type === 'texte') { |
| 47 | 50 | $n = $a[0]->texte; |
| 48 | - if (is_numeric($n)) |
|
| 49 | - $coord[]= $n; |
|
| 50 | - elseif (in_array($n,array('top','left','right','center','bottom'))) |
|
| 51 | - $align = $n; |
|
| 52 | - elseif (in_array($n,array('auto','icone','apercu','vignette'))) |
|
| 53 | - $mode_logo = $n; |
|
| 51 | + if (is_numeric($n)) { |
|
| 52 | + $coord[]= $n; |
|
| 53 | + } elseif (in_array($n,array('top','left','right','center','bottom'))) { |
|
| 54 | + $align = $n; |
|
| 55 | + } elseif (in_array($n,array('auto','icone','apercu','vignette'))) { |
|
| 56 | + $mode_logo = $n; |
|
| 57 | + } |
|
| 58 | + } else { |
|
| 59 | + $lien = calculer_liste($a, $p->descr, $p->boucles, $p->id_boucle); |
|
| 54 | 60 | } |
| 55 | - else $lien = calculer_liste($a, $p->descr, $p->boucles, $p->id_boucle); |
|
| 56 | 61 | |
| 57 | 62 | } |
| 58 | 63 | } |
@@ -69,16 +74,18 @@ discard block |
||
| 69 | 74 | if ($type == 'document') { |
| 70 | 75 | $qconnect = _q($connect); |
| 71 | 76 | $doc = "quete_document($_id_objet, $qconnect)"; |
| 72 | - if ($fichier) |
|
| 73 | - $code = "quete_logo_file($doc, $qconnect)"; |
|
| 74 | - else $code = "quete_logo_document($doc, " . ($lien ? $lien : "''") . ", '$align', '$mode_logo', $coord_x, $coord_y, $qconnect)"; |
|
| 77 | + if ($fichier) { |
|
| 78 | + $code = "quete_logo_file($doc, $qconnect)"; |
|
| 79 | + } else { |
|
| 80 | + $code = "quete_logo_document($doc, " . ($lien ? $lien : "''") . ", '$align', '$mode_logo', $coord_x, $coord_y, $qconnect)"; |
|
| 81 | + } |
|
| 75 | 82 | // (x=non-faux ? y : '') pour affecter x en retournant y |
| 76 | - if ($p->descr['documents']) |
|
| 77 | - $code = '(($doublons["documents"] .= ",". ' |
|
| 83 | + if ($p->descr['documents']) { |
|
| 84 | + $code = '(($doublons["documents"] .= ",". ' |
|
| 78 | 85 | . $_id_objet |
| 79 | 86 | . ") ? $code : '')"; |
| 80 | - } |
|
| 81 | - elseif ($connect) { |
|
| 87 | + } |
|
| 88 | + } elseif ($connect) { |
|
| 82 | 89 | $code = "''"; |
| 83 | 90 | spip_log("Les logos distants ne sont pas prevus"); |
| 84 | 91 | } else { |
@@ -106,14 +113,18 @@ discard block |
||
| 106 | 113 | (($type == 'rubrique') ? "quete_parent($_id_objet)" : "''")) . |
| 107 | 114 | ", " . intval($fichier) . ")"; |
| 108 | 115 | |
| 109 | - if ($fichier) return $code; |
|
| 116 | + if ($fichier) { |
|
| 117 | + return $code; |
|
| 118 | + } |
|
| 110 | 119 | |
| 111 | 120 | $code = "\n((!is_array(\$l = $code)) ? '':\n (" . |
| 112 | 121 | '"<img class=\"spip_logos\" alt=\"\"' . |
| 113 | 122 | ($align ? " align=\\\"$align\\\"" : '') |
| 114 | 123 | . ' src=\"$l[0]\"" . $l[2] . ($l[1] ? " onmouseover=\"this.src=\'$l[1]\'\" onmouseout=\"this.src=\'$l[0]\'\"" : "") . \' />\'))'; |
| 115 | 124 | |
| 116 | - if (!$lien) return $code; |
|
| 125 | + if (!$lien) { |
|
| 126 | + return $code; |
|
| 127 | + } |
|
| 117 | 128 | |
| 118 | 129 | return ('(strlen($logo='.$code.')?\'<a href="\' .' . $lien . ' . \'">\' . $logo . \'</a>\':\'\')'); |
| 119 | 130 | |
@@ -37,6 +37,9 @@ |
||
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | // http://doc.spip.org/@menu_lang_pour_tous |
| 40 | +/** |
|
| 41 | + * @param string $nom |
|
| 42 | + */ |
|
| 40 | 43 | function menu_lang_pour_tous($nom, $default) { |
| 41 | 44 | include_spip('inc/lang'); |
| 42 | 45 | |
@@ -231,6 +231,9 @@ |
||
| 231 | 231 | |
| 232 | 232 | // pour versions <= 1.926 |
| 233 | 233 | // http://doc.spip.org/@upgrade_vers |
| 234 | +/** |
|
| 235 | + * @param double $version |
|
| 236 | + */ |
|
| 234 | 237 | function upgrade_vers($version, $version_installee, $version_cible = 0){ |
| 235 | 238 | return ($version_installee<$version |
| 236 | 239 | AND (($version_cible>=$version) OR ($version_cible==0)) |
@@ -10,7 +10,9 @@ discard block |
||
| 10 | 10 | * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * |
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | -if (!defined('_ECRIRE_INC_VERSION')) return; |
|
| 13 | +if (!defined('_ECRIRE_INC_VERSION')) { |
|
| 14 | + return; |
|
| 15 | +} |
|
| 14 | 16 | |
| 15 | 17 | /** |
| 16 | 18 | * Programme de mise a jour des tables SQL lors d'un chgt de version. |
@@ -30,7 +32,10 @@ discard block |
||
| 30 | 32 | */ |
| 31 | 33 | function base_upgrade_dist($titre='', $reprise='') |
| 32 | 34 | { |
| 33 | - if (!$titre) return; // anti-testeur automatique |
|
| 35 | + if (!$titre) { |
|
| 36 | + return; |
|
| 37 | + } |
|
| 38 | + // anti-testeur automatique |
|
| 34 | 39 | if ($GLOBALS['spip_version_base']!=$GLOBALS['meta']['version_installee']) { |
| 35 | 40 | if (!is_numeric(_request('reinstall'))) { |
| 36 | 41 | include_spip('base/create'); |
@@ -93,7 +98,9 @@ discard block |
||
| 93 | 98 | 'impt' => 'non')); |
| 94 | 99 | return false; |
| 95 | 100 | } |
| 96 | - if (!upgrade_test()) return true; |
|
| 101 | + if (!upgrade_test()) { |
|
| 102 | + return true; |
|
| 103 | + } |
|
| 97 | 104 | |
| 98 | 105 | $cible = ($version_cible ? $version_cible : $spip_version_base); |
| 99 | 106 | |
@@ -105,27 +112,31 @@ discard block |
||
| 105 | 112 | if ($f) { |
| 106 | 113 | spip_log( "$f repercute les modifications de la version " . ($n/10),"maj."._LOG_INFO_IMPORTANTE); |
| 107 | 114 | $f($version_installee, $spip_version_base); |
| 108 | - } else spip_log( "pas de fonction pour la maj $n $nom","maj."._LOG_INFO_IMPORTANTE); |
|
| 115 | + } else { |
|
| 116 | + spip_log( "pas de fonction pour la maj $n $nom","maj."._LOG_INFO_IMPORTANTE); |
|
| 117 | + } |
|
| 109 | 118 | $n++; |
| 110 | 119 | } |
| 111 | 120 | include_spip('maj/v019_pre193'); |
| 112 | 121 | v019_pre193($version_installee, $version_cible); |
| 113 | 122 | } |
| 114 | 123 | if ($version_installee < 2000) { |
| 115 | - if ($version_installee < 2) |
|
| 116 | - $version_installee = $version_installee*1000; |
|
| 124 | + if ($version_installee < 2) { |
|
| 125 | + $version_installee = $version_installee*1000; |
|
| 126 | + } |
|
| 117 | 127 | include_spip('maj/v019'); |
| 118 | 128 | } |
| 119 | - if ($cible < 2) |
|
| 120 | - $cible = $cible*1000; |
|
| 129 | + if ($cible < 2) { |
|
| 130 | + $cible = $cible*1000; |
|
| 131 | + } |
|
| 121 | 132 | |
| 122 | 133 | include_spip('maj/svn10000'); |
| 123 | 134 | ksort($GLOBALS['maj']); |
| 124 | 135 | $res = maj_while($version_installee, $cible, $GLOBALS['maj'], 'version_installee','meta', $redirect, true); |
| 125 | 136 | if ($res) { |
| 126 | - if (!is_array($res)) |
|
| 127 | - spip_log("Pb d'acces SQL a la mise a jour","maj."._LOG_INFO_ERREUR); |
|
| 128 | - else { |
|
| 137 | + if (!is_array($res)) { |
|
| 138 | + spip_log("Pb d'acces SQL a la mise a jour","maj."._LOG_INFO_ERREUR); |
|
| 139 | + } else { |
|
| 129 | 140 | echo _T('avis_operation_echec') . ' ' . join(' ', $res); |
| 130 | 141 | echo install_fin_html(); |
| 131 | 142 | } |
@@ -166,8 +177,9 @@ discard block |
||
| 166 | 177 | */ |
| 167 | 178 | function maj_plugin($nom_meta_base_version, $version_cible, $maj, $table_meta='meta'){ |
| 168 | 179 | |
| 169 | - if ($table_meta!=='meta') |
|
| 170 | - lire_metas($table_meta); |
|
| 180 | + if ($table_meta!=='meta') { |
|
| 181 | + lire_metas($table_meta); |
|
| 182 | + } |
|
| 171 | 183 | if ( (!isset($GLOBALS[$table_meta][$nom_meta_base_version]) ) |
| 172 | 184 | || (!spip_version_compare($current_version = $GLOBALS[$table_meta][$nom_meta_base_version],$version_cible,'='))){ |
| 173 | 185 | |
@@ -201,9 +213,9 @@ discard block |
||
| 201 | 213 | |
| 202 | 214 | $res = maj_while($current_version, $version_cible, $maj, $nom_meta_base_version, $table_meta, $redirect); |
| 203 | 215 | if ($res) { |
| 204 | - if (!is_array($res)) |
|
| 205 | - spip_log("Pb d'acces SQL a la mise a jour","maj."._LOG_INFO_ERREUR); |
|
| 206 | - else { |
|
| 216 | + if (!is_array($res)) { |
|
| 217 | + spip_log("Pb d'acces SQL a la mise a jour","maj."._LOG_INFO_ERREUR); |
|
| 218 | + } else { |
|
| 207 | 219 | echo "<p>"._T('avis_operation_echec') . ' ' . join(' ', $res)."</p>"; |
| 208 | 220 | } |
| 209 | 221 | } |
@@ -245,7 +257,9 @@ discard block |
||
| 245 | 257 | */ |
| 246 | 258 | function maj_debut_page($installee,$meta,$table){ |
| 247 | 259 | static $done = false; |
| 248 | - if ($done) return; |
|
| 260 | + if ($done) { |
|
| 261 | + return; |
|
| 262 | + } |
|
| 249 | 263 | include_spip('inc/minipres'); |
| 250 | 264 | @ini_set("zlib.output_compression","0"); // pour permettre l'affichage au fur et a mesure |
| 251 | 265 | $timeout = _UPGRADE_TIME_OUT*2; |
@@ -315,17 +329,22 @@ discard block |
||
| 315 | 329 | if ($v=='init' OR |
| 316 | 330 | (spip_version_compare($v,$installee,'>') |
| 317 | 331 | AND spip_version_compare($v,$cible,'<='))) { |
| 318 | - if ($debut_page) |
|
| 319 | - maj_debut_page($v,$meta,$table); |
|
| 332 | + if ($debut_page) { |
|
| 333 | + maj_debut_page($v,$meta,$table); |
|
| 334 | + } |
|
| 320 | 335 | echo "MAJ $v"; |
| 321 | 336 | $etape = serie_alter($v, $maj[$v], $meta, $table, $redirect); |
| 322 | 337 | $trouver_table(''); // vider le cache des descriptions de table |
| 323 | 338 | # echec sur une etape en cours ? |
| 324 | 339 | # on sort |
| 325 | - if ($etape) return array($v, $etape); |
|
| 340 | + if ($etape) { |
|
| 341 | + return array($v, $etape); |
|
| 342 | + } |
|
| 326 | 343 | $n = time() - $time; |
| 327 | 344 | spip_log( "$table $meta: $v en $n secondes",'maj.'._LOG_INFO_IMPORTANTE); |
| 328 | - if ($meta) ecrire_meta($meta, $installee=$v,'oui', $table); |
|
| 345 | + if ($meta) { |
|
| 346 | + ecrire_meta($meta, $installee=$v,'oui', $table); |
|
| 347 | + } |
|
| 329 | 348 | echo "<br />"; |
| 330 | 349 | } |
| 331 | 350 | if (time() >= _TIME_OUT) { |
@@ -335,7 +354,9 @@ discard block |
||
| 335 | 354 | $trouver_table(''); // vider le cache des descriptions de table |
| 336 | 355 | // indispensable pour les chgt de versions qui n'ecrivent pas en base |
| 337 | 356 | // tant pis pour la redondance eventuelle avec ci-dessus |
| 338 | - if ($meta) ecrire_meta($meta, $cible,'oui',$table); |
|
| 357 | + if ($meta) { |
|
| 358 | + ecrire_meta($meta, $cible,'oui',$table); |
|
| 359 | + } |
|
| 339 | 360 | spip_log( "MAJ terminee. $meta: $installee",'maj.'._LOG_INFO_IMPORTANTE); |
| 340 | 361 | return array(); |
| 341 | 362 | } |
@@ -373,8 +394,9 @@ discard block |
||
| 373 | 394 | // mais pour les fonctions complexes, |
| 374 | 395 | // il faut les rejouer jusqu'a achevement. |
| 375 | 396 | // C'est a elle d'assurer qu'elles progressent a chaque rappel |
| 376 | - if (strncmp($f,"sql_",4)==0) |
|
| 377 | - ecrire_meta($meta2, $i+1, 'non', $table); |
|
| 397 | + if (strncmp($f,"sql_",4)==0) { |
|
| 398 | + ecrire_meta($meta2, $i+1, 'non', $table); |
|
| 399 | + } |
|
| 378 | 400 | echo " <span title='$i'>.</span>"; |
| 379 | 401 | call_user_func_array($f, $r); |
| 380 | 402 | // si temps imparti depasse, on relance sans ecrire en meta |
@@ -384,12 +406,12 @@ discard block |
||
| 384 | 406 | } |
| 385 | 407 | ecrire_meta($meta2, $i+1, 'non', $table); |
| 386 | 408 | spip_log( "$meta2: ok", 'maj.'._LOG_INFO_IMPORTANTE); |
| 387 | - } |
|
| 388 | - else { |
|
| 389 | - if (!is_array($r)) |
|
| 390 | - spip_log("maj $i format incorrect","maj."._LOG_ERREUR); |
|
| 391 | - else |
|
| 392 | - spip_log("maj $i fonction $f non definie","maj."._LOG_ERREUR); |
|
| 409 | + } else { |
|
| 410 | + if (!is_array($r)) { |
|
| 411 | + spip_log("maj $i format incorrect","maj."._LOG_ERREUR); |
|
| 412 | + } else { |
|
| 413 | + spip_log("maj $i fonction $f non definie","maj."._LOG_ERREUR); |
|
| 414 | + } |
|
| 393 | 415 | // en cas d'erreur serieuse, on s'arrete |
| 394 | 416 | // mais on permet de passer par dessus en rechargeant la page. |
| 395 | 417 | return $i+1; |
@@ -408,9 +430,10 @@ discard block |
||
| 408 | 430 | // http://doc.spip.org/@upgrade_types_documents |
| 409 | 431 | function upgrade_types_documents() { |
| 410 | 432 | if (include_spip('base/medias') |
| 411 | - AND function_exists('creer_base_types_doc')) |
|
| 412 | - creer_base_types_doc(); |
|
| 413 | -} |
|
| 433 | + AND function_exists('creer_base_types_doc')) { |
|
| 434 | + creer_base_types_doc(); |
|
| 435 | + } |
|
| 436 | + } |
|
| 414 | 437 | |
| 415 | 438 | // http://doc.spip.org/@upgrade_test |
| 416 | 439 | function upgrade_test() { |
@@ -431,9 +454,9 @@ discard block |
||
| 431 | 454 | // http://doc.spip.org/@maj_version |
| 432 | 455 | function maj_version ($version, $test = true) { |
| 433 | 456 | if ($test) { |
| 434 | - if ($version>=1.922) |
|
| 435 | - ecrire_meta('version_installee', $version, 'oui'); |
|
| 436 | - else { |
|
| 457 | + if ($version>=1.922) { |
|
| 458 | + ecrire_meta('version_installee', $version, 'oui'); |
|
| 459 | + } else { |
|
| 437 | 460 | // on le fait manuellement, car ecrire_meta utilise le champs impt qui est absent sur les vieilles versions |
| 438 | 461 | $GLOBALS['meta']['version_installee'] = $version; |
| 439 | 462 | sql_updateq('spip_meta', array('valeur' => $version), "nom=" . sql_quote('version_installee') ); |
@@ -34,6 +34,10 @@ discard block |
||
| 34 | 34 | define('_VERSIONS_SERVEUR', 'http://files.spip.org/'); |
| 35 | 35 | define('_VERSIONS_LISTE', 'archives.xml'); |
| 36 | 36 | |
| 37 | +/** |
|
| 38 | + * @param string $dir |
|
| 39 | + * @param string $file |
|
| 40 | + */ |
|
| 37 | 41 | function info_maj ($dir, $file, $version){ |
| 38 | 42 | include_spip('inc/plugin'); |
| 39 | 43 | |
@@ -67,6 +71,11 @@ discard block |
||
| 67 | 71 | // on teste la nouveaute par If-Modified-Since, |
| 68 | 72 | // et seulement quand celui-ci a change' pour limiter les acces HTTP |
| 69 | 73 | |
| 74 | +/** |
|
| 75 | + * @param string $nom |
|
| 76 | + * |
|
| 77 | + * @return string |
|
| 78 | + */ |
|
| 70 | 79 | function info_maj_cache($nom, $dir, $page='') |
| 71 | 80 | { |
| 72 | 81 | $re = '<archives id="a' . $GLOBALS['meta']["alea_ephemere"] . '">'; |
@@ -10,7 +10,9 @@ discard block |
||
| 10 | 10 | * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * |
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | -if (!defined('_ECRIRE_INC_VERSION')) return; |
|
| 13 | +if (!defined('_ECRIRE_INC_VERSION')) { |
|
| 14 | + return; |
|
| 15 | +} |
|
| 14 | 16 | |
| 15 | 17 | /** |
| 16 | 18 | * Verifier si une mise a jour est disponible |
@@ -53,11 +55,14 @@ discard block |
||
| 53 | 55 | list(, $maj2, $min2,, $rev2) = $v; |
| 54 | 56 | $version_maj = $maj2 . '.' . $min2 . '.' . $rev2; |
| 55 | 57 | if ((spip_version_compare($version, $version_maj, '<')) |
| 56 | - AND (spip_version_compare($page, $version_maj, '<'))) |
|
| 57 | - $page = $version_maj; |
|
| 58 | + AND (spip_version_compare($page, $version_maj, '<'))) { |
|
| 59 | + $page = $version_maj; |
|
| 60 | + } |
|
| 58 | 61 | } |
| 59 | 62 | |
| 60 | - if (!$page) return ""; |
|
| 63 | + if (!$page) { |
|
| 64 | + return ""; |
|
| 65 | + } |
|
| 61 | 66 | return "<a class='info_maj_spip' href='"._VERSIONS_SERVEUR."$dir' title='$page'>" . |
| 62 | 67 | _T('nouvelle_version_spip',array('version'=>$page)) . |
| 63 | 68 | '</a>'; |
@@ -71,14 +76,18 @@ discard block |
||
| 71 | 76 | function info_maj_cache($nom, $dir, $page='') |
| 72 | 77 | { |
| 73 | 78 | $re = '<archives id="a' . $GLOBALS['meta']["alea_ephemere"] . '">'; |
| 74 | - if (preg_match("/$re/", $page)) return $page; |
|
| 79 | + if (preg_match("/$re/", $page)) { |
|
| 80 | + return $page; |
|
| 81 | + } |
|
| 75 | 82 | |
| 76 | 83 | $url = _VERSIONS_SERVEUR . $dir . '/' . _VERSIONS_LISTE; |
| 77 | 84 | $a = file_exists($nom) ? filemtime($nom) : ''; |
| 78 | 85 | include_spip('inc/distant'); |
| 79 | 86 | $res = recuperer_lapage($url, false, 'GET', _COPIE_LOCALE_MAX_SIZE, '',false, $a); |
| 80 | 87 | // Si rien de neuf (ou inaccessible), garder l'ancienne |
| 81 | - if ($res) list(, $page) = $res; |
|
| 88 | + if ($res) { |
|
| 89 | + list(, $page) = $res; |
|
| 90 | + } |
|
| 82 | 91 | // Placer l'indicateur de fraicheur |
| 83 | 92 | $page = preg_replace('/^<archives.*?>/', $re, $page); |
| 84 | 93 | sous_repertoire(_DIR_CACHE_XML); |
@@ -14,6 +14,9 @@ |
||
| 14 | 14 | include_spip('inc/filtres_images_lib_mini'); // par precaution |
| 15 | 15 | |
| 16 | 16 | // http://doc.spip.org/@couleur_html_to_hex |
| 17 | +/** |
|
| 18 | + * @param string $couleur |
|
| 19 | + */ |
|
| 17 | 20 | function couleur_html_to_hex($couleur){ |
| 18 | 21 | $couleurs_html=array( |
| 19 | 22 | 'aqua'=>'00FFFF','black'=>'000000','blue'=>'0000FF','fuchsia'=>'FF00FF','gray'=>'808080','green'=>'008000','lime'=>'00FF00','maroon'=>'800000', |
@@ -10,7 +10,9 @@ discard block |
||
| 10 | 10 | * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * |
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | -if (!defined('_ECRIRE_INC_VERSION')) return; |
|
| 13 | +if (!defined('_ECRIRE_INC_VERSION')) { |
|
| 14 | + return; |
|
| 15 | +} |
|
| 14 | 16 | include_spip('inc/filtres_images_lib_mini'); // par precaution |
| 15 | 17 | |
| 16 | 18 | // http://doc.spip.org/@couleur_html_to_hex |
@@ -18,8 +20,9 @@ discard block |
||
| 18 | 20 | $couleurs_html=array( |
| 19 | 21 | 'aqua'=>'00FFFF','black'=>'000000','blue'=>'0000FF','fuchsia'=>'FF00FF','gray'=>'808080','green'=>'008000','lime'=>'00FF00','maroon'=>'800000', |
| 20 | 22 | 'navy'=>'000080','olive'=>'808000','purple'=>'800080','red'=>'FF0000','silver'=>'C0C0C0','teal'=>'008080','white'=>'FFFFFF','yellow'=>'FFFF00'); |
| 21 | - if (isset($couleurs_html[$lc=strtolower($couleur)])) |
|
| 22 | - return $couleurs_html[$lc]; |
|
| 23 | + if (isset($couleurs_html[$lc=strtolower($couleur)])) { |
|
| 24 | + return $couleurs_html[$lc]; |
|
| 25 | + } |
|
| 23 | 26 | return $couleur; |
| 24 | 27 | } |
| 25 | 28 | |
@@ -55,11 +58,14 @@ discard block |
||
| 55 | 58 | // dans la fonction image_filtrer |
| 56 | 59 | // http://doc.spip.org/@image_select |
| 57 | 60 | function image_select($img,$width_min=0, $height_min=0, $width_max=10000, $height_max=1000){ |
| 58 | - if (!$img) return $img; |
|
| 61 | + if (!$img) { |
|
| 62 | + return $img; |
|
| 63 | + } |
|
| 59 | 64 | list ($h,$l) = taille_image($img); |
| 60 | 65 | $select = true; |
| 61 | - if ($l<$width_min OR $l>$width_max OR $h<$height_min OR $h>$height_max) |
|
| 62 | - $select = false; |
|
| 66 | + if ($l<$width_min OR $l>$width_max OR $h<$height_min OR $h>$height_max) { |
|
| 67 | + $select = false; |
|
| 68 | + } |
|
| 63 | 69 | |
| 64 | 70 | $class = extraire_attribut($img,'class'); |
| 65 | 71 | $p = strpos($class,'no_image_filtrer'); |
@@ -77,19 +83,28 @@ discard block |
||
| 77 | 83 | |
| 78 | 84 | // http://doc.spip.org/@image_passe_partout |
| 79 | 85 | function image_passe_partout($img,$taille_x = -1, $taille_y = -1,$force = false,$cherche_image=false,$process='AUTO'){ |
| 80 | - if (!$img) return ''; |
|
| 86 | + if (!$img) { |
|
| 87 | + return ''; |
|
| 88 | + } |
|
| 81 | 89 | list ($hauteur,$largeur) = taille_image($img); |
| 82 | - if ($taille_x == -1) |
|
| 83 | - $taille_x = isset($GLOBALS['meta']['taille_preview'])?$GLOBALS['meta']['taille_preview']:150; |
|
| 84 | - if ($taille_y == -1) |
|
| 85 | - $taille_y = $taille_x; |
|
| 86 | - |
|
| 87 | - if ($taille_x == 0 AND $taille_y > 0) |
|
| 88 | - $taille_x = 1; # {0,300} -> c'est 300 qui compte |
|
| 89 | - elseif ($taille_x > 0 AND $taille_y == 0) |
|
| 90 | - $taille_y = 1; # {300,0} -> c'est 300 qui compte |
|
| 91 | - elseif ($taille_x == 0 AND $taille_y == 0) |
|
| 92 | - return ''; |
|
| 90 | + if ($taille_x == -1) { |
|
| 91 | + $taille_x = isset($GLOBALS['meta']['taille_preview'])?$GLOBALS['meta']['taille_preview']:150; |
|
| 92 | + } |
|
| 93 | + if ($taille_y == -1) { |
|
| 94 | + $taille_y = $taille_x; |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + if ($taille_x == 0 AND $taille_y > 0) { |
|
| 98 | + $taille_x = 1; |
|
| 99 | + } |
|
| 100 | + # {0,300} -> c'est 300 qui compte |
|
| 101 | + elseif ($taille_x > 0 AND $taille_y == 0) { |
|
| 102 | + $taille_y = 1; |
|
| 103 | + } |
|
| 104 | + # {300,0} -> c'est 300 qui compte |
|
| 105 | + elseif ($taille_x == 0 AND $taille_y == 0) { |
|
| 106 | + return ''; |
|
| 107 | + } |
|
| 93 | 108 | |
| 94 | 109 | list($destWidth,$destHeight,$ratio) = ratio_passe_partout($largeur,$hauteur,$taille_x,$taille_y); |
| 95 | 110 | $fonction = array('image_passe_partout', func_get_args()); |
@@ -100,17 +115,24 @@ discard block |
||
| 100 | 115 | function image_reduire($img, $taille = -1, $taille_y = -1, $force=false, $cherche_image=false, $process='AUTO') { |
| 101 | 116 | // Determiner la taille x,y maxi |
| 102 | 117 | // prendre le reglage de previsu par defaut |
| 103 | - if ($taille == -1) |
|
| 104 | - $taille = (isset($GLOBALS['meta']['taille_preview']) AND intval($GLOBALS['meta']['taille_preview']))?intval($GLOBALS['meta']['taille_preview']):150; |
|
| 105 | - if ($taille_y == -1) |
|
| 106 | - $taille_y = $taille; |
|
| 107 | - |
|
| 108 | - if ($taille == 0 AND $taille_y > 0) |
|
| 109 | - $taille = 10000; # {0,300} -> c'est 300 qui compte |
|
| 110 | - elseif ($taille > 0 AND $taille_y == 0) |
|
| 111 | - $taille_y = 10000; # {300,0} -> c'est 300 qui compte |
|
| 112 | - elseif ($taille == 0 AND $taille_y == 0) |
|
| 113 | - return ''; |
|
| 118 | + if ($taille == -1) { |
|
| 119 | + $taille = (isset($GLOBALS['meta']['taille_preview']) AND intval($GLOBALS['meta']['taille_preview']))?intval($GLOBALS['meta']['taille_preview']):150; |
|
| 120 | + } |
|
| 121 | + if ($taille_y == -1) { |
|
| 122 | + $taille_y = $taille; |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + if ($taille == 0 AND $taille_y > 0) { |
|
| 126 | + $taille = 10000; |
|
| 127 | + } |
|
| 128 | + # {0,300} -> c'est 300 qui compte |
|
| 129 | + elseif ($taille > 0 AND $taille_y == 0) { |
|
| 130 | + $taille_y = 10000; |
|
| 131 | + } |
|
| 132 | + # {300,0} -> c'est 300 qui compte |
|
| 133 | + elseif ($taille == 0 AND $taille_y == 0) { |
|
| 134 | + return ''; |
|
| 135 | + } |
|
| 114 | 136 | |
| 115 | 137 | $fonction = array('image_reduire', func_get_args()); |
| 116 | 138 | return process_image_reduire($fonction,$img,$taille,$taille_y,$force,$cherche_image,$process); |
@@ -124,8 +146,11 @@ discard block |
||
| 124 | 146 | $l = round($largeur/$val); |
| 125 | 147 | $h = round($hauteur/$val); |
| 126 | 148 | |
| 127 | - if ($l > $h) $h = 0; |
|
| 128 | - else $l = 0; |
|
| 149 | + if ($l > $h) { |
|
| 150 | + $h = 0; |
|
| 151 | + } else { |
|
| 152 | + $l = 0; |
|
| 153 | + } |
|
| 129 | 154 | |
| 130 | 155 | $img = image_reduire($img, $l, $h, $force); |
| 131 | 156 | |
@@ -125,6 +125,9 @@ |
||
| 125 | 125 | } |
| 126 | 126 | |
| 127 | 127 | // http://doc.spip.org/@http_status |
| 128 | +/** |
|
| 129 | + * @param integer $status |
|
| 130 | + */ |
|
| 128 | 131 | function http_status($status) { |
| 129 | 132 | global $REDIRECT_STATUS, $flag_sapi_name; |
| 130 | 133 | static $status_string = array( |
@@ -11,23 +11,28 @@ discard block |
||
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | 13 | |
| 14 | -if (!defined('_ECRIRE_INC_VERSION')) return; |
|
| 14 | +if (!defined('_ECRIRE_INC_VERSION')) { |
|
| 15 | + return; |
|
| 16 | +} |
|
| 15 | 17 | |
| 16 | 18 | // envoyer le navigateur sur une nouvelle adresse |
| 17 | 19 | // en evitant les attaques par la redirection (souvent indique par 1 $_GET) |
| 18 | 20 | |
| 19 | 21 | // http://doc.spip.org/@redirige_par_entete |
| 20 | 22 | function redirige_par_entete($url, $equiv='', $status = 302) { |
| 21 | - if (!in_array($status,array(301,302))) |
|
| 22 | - $status = 302; |
|
| 23 | + if (!in_array($status,array(301,302))) { |
|
| 24 | + $status = 302; |
|
| 25 | + } |
|
| 23 | 26 | |
| 24 | 27 | $url = trim(strtr($url, "\n\r", " ")); |
| 25 | 28 | # en theorie on devrait faire ca tout le temps, mais quand la chaine |
| 26 | 29 | # commence par ? c'est imperatif, sinon l'url finale n'est pas la bonne |
| 27 | - if ($url[0]=='?') |
|
| 28 | - $url = url_de_base().$url; |
|
| 29 | - if ($url[0]=='#') |
|
| 30 | - $url = self('&').$url; |
|
| 30 | + if ($url[0]=='?') { |
|
| 31 | + $url = url_de_base().$url; |
|
| 32 | + } |
|
| 33 | + if ($url[0]=='#') { |
|
| 34 | + $url = self('&').$url; |
|
| 35 | + } |
|
| 31 | 36 | # si profondeur non nulle et url relative, il faut la passer en absolue |
| 32 | 37 | if ($GLOBALS['profondeur_url']>(_DIR_RESTREINT?1:2) |
| 33 | 38 | AND !preg_match(",^(\w+:)?//,",$url)){ |
@@ -35,11 +40,13 @@ discard block |
||
| 35 | 40 | $url = url_absolue($url); |
| 36 | 41 | } |
| 37 | 42 | |
| 38 | - if ($x = _request('transformer_xml')) |
|
| 39 | - $url = parametre_url($url, 'transformer_xml', $x, '&'); |
|
| 43 | + if ($x = _request('transformer_xml')) { |
|
| 44 | + $url = parametre_url($url, 'transformer_xml', $x, '&'); |
|
| 45 | + } |
|
| 40 | 46 | |
| 41 | - if (defined('_AJAX') AND _AJAX) |
|
| 42 | - $url = parametre_url($url, 'var_ajax_redir', 1, '&'); |
|
| 47 | + if (defined('_AJAX') AND _AJAX) { |
|
| 48 | + $url = parametre_url($url, 'var_ajax_redir', 1, '&'); |
|
| 49 | + } |
|
| 43 | 50 | |
| 44 | 51 | // ne pas laisser passer n'importe quoi dans l'url |
| 45 | 52 | $url = str_replace(array('<','"'),array('<','"'),$url); |
@@ -47,8 +54,9 @@ discard block |
||
| 47 | 54 | if ( |
| 48 | 55 | (preg_match(",data:,i",$url) AND preg_match("/base64\s*,/i",$url)) |
| 49 | 56 | OR preg_match(",(javascript|mailto):,i",$url) |
| 50 | - ) |
|
| 51 | - $url ="./"; |
|
| 57 | + ) { |
|
| 58 | + $url ="./"; |
|
| 59 | + } |
|
| 52 | 60 | |
| 53 | 61 | // Il n'y a que sous Apache que setcookie puis redirection fonctionne |
| 54 | 62 | include_spip('inc/cookie'); |
@@ -60,8 +68,9 @@ discard block |
||
| 60 | 68 | $equiv = "<meta http-equiv='Refresh' content='0; url=$url'>"; |
| 61 | 69 | } |
| 62 | 70 | include_spip('inc/lang'); |
| 63 | - if ($status!=302) |
|
| 64 | - http_status($status); |
|
| 71 | + if ($status!=302) { |
|
| 72 | + http_status($status); |
|
| 73 | + } |
|
| 65 | 74 | echo '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">',"\n", |
| 66 | 75 | html_lang_attributes(),' |
| 67 | 76 | <head>', |
@@ -95,33 +104,35 @@ discard block |
||
| 95 | 104 | "<a href='$url' name='ajax_ancre' style='display:none;'>anchor</a>", |
| 96 | 105 | // et rien dans le message ok |
| 97 | 106 | ''); |
| 98 | - } |
|
| 99 | - else { |
|
| 107 | + } else { |
|
| 100 | 108 | // ne pas laisser passer n'importe quoi dans l'url |
| 101 | 109 | $url = str_replace(array('<','"'),array('<','"'),$url); |
| 102 | 110 | |
| 103 | 111 | $url = strtr($url, "\n\r", " "); |
| 104 | 112 | # en theorie on devrait faire ca tout le temps, mais quand la chaine |
| 105 | 113 | # commence par ? c'est imperatif, sinon l'url finale n'est pas la bonne |
| 106 | - if ($url[0]=='?') |
|
| 107 | - $url = url_de_base().$url; |
|
| 114 | + if ($url[0]=='?') { |
|
| 115 | + $url = url_de_base().$url; |
|
| 116 | + } |
|
| 108 | 117 | $url = str_replace('&','&',$url); |
| 109 | 118 | spip_log("redirige formulaire ajax: $url"); |
| 110 | 119 | include_spip('inc/filtres'); |
| 111 | - if ($format=='ajaxform') |
|
| 112 | - return array( |
|
| 120 | + if ($format=='ajaxform') { |
|
| 121 | + return array( |
|
| 113 | 122 | // on renvoie un lien masque qui sera traite par ajaxCallback.js |
| 114 | 123 | '<a href="'.quote_amp($url).'" name="ajax_redirect" style="display:none;">'._T('navigateur_pas_redirige').'</a>', |
| 115 | 124 | // et un message au cas ou |
| 116 | 125 | '<br /><a href="'.quote_amp($url).'">'._T('navigateur_pas_redirige').'</a>' |
| 117 | 126 | ); |
| 118 | - else // format message texte, tout en js inline |
|
| 127 | + } else { |
|
| 128 | + // format message texte, tout en js inline |
|
| 119 | 129 | return |
| 120 | 130 | // ie poste les formulaires dans une iframe, il faut donc rediriger son parent |
| 121 | 131 | "<script type='text/javascript'>if (parent.window){parent.window.document.location.replace(\"$url\");} else {document.location.replace(\"$url\");}</script>" |
| 122 | 132 | . http_img_pack('searching.gif','') |
| 123 | 133 | . '<br />' |
| 124 | 134 | . '<a href="'.quote_amp($url).'">'._T('navigateur_pas_redirige').'</a>'; |
| 135 | + } |
|
| 125 | 136 | } |
| 126 | 137 | } |
| 127 | 138 | |
@@ -145,14 +156,17 @@ discard block |
||
| 145 | 156 | 503 => '503 Service Unavailable' |
| 146 | 157 | ); |
| 147 | 158 | |
| 148 | - if ($REDIRECT_STATUS && $REDIRECT_STATUS == $status) return; |
|
| 159 | + if ($REDIRECT_STATUS && $REDIRECT_STATUS == $status) { |
|
| 160 | + return; |
|
| 161 | + } |
|
| 149 | 162 | |
| 150 | 163 | $php_cgi = ($flag_sapi_name AND preg_match(",cgi,i", @php_sapi_name())); |
| 151 | - if ($php_cgi) |
|
| 152 | - header("Status: ".$status_string[$status]); |
|
| 153 | - else |
|
| 154 | - header("HTTP/1.0 ".$status_string[$status]); |
|
| 155 | -} |
|
| 164 | + if ($php_cgi) { |
|
| 165 | + header("Status: ".$status_string[$status]); |
|
| 166 | + } else { |
|
| 167 | + header("HTTP/1.0 ".$status_string[$status]); |
|
| 168 | + } |
|
| 169 | + } |
|
| 156 | 170 | |
| 157 | 171 | // Retourne ce qui va bien pour que le navigateur ne mette pas la page en cache |
| 158 | 172 | // http://doc.spip.org/@http_no_cache |
@@ -107,6 +107,9 @@ |
||
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | // http://doc.spip.org/@ecrire_meta |
| 110 | +/** |
|
| 111 | + * @param string $importable |
|
| 112 | + */ |
|
| 110 | 113 | function ecrire_meta($nom, $valeur, $importable = NULL, $table='meta') { |
| 111 | 114 | |
| 112 | 115 | static $touch = array(); |
@@ -10,7 +10,9 @@ discard block |
||
| 10 | 10 | * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * |
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | -if (!defined('_ECRIRE_INC_VERSION')) return; |
|
| 13 | +if (!defined('_ECRIRE_INC_VERSION')) { |
|
| 14 | + return; |
|
| 15 | +} |
|
| 14 | 16 | |
| 15 | 17 | // Les parametres generaux du site sont dans une table SQL; |
| 16 | 18 | // Recopie dans le tableau PHP global meta, car on en a souvent besoin |
@@ -28,14 +30,18 @@ discard block |
||
| 28 | 30 | if ((_request('exec')!=='install' OR !test_espace_prive()) |
| 29 | 31 | AND $new = jeune_fichier($cache, _META_CACHE_TIME) |
| 30 | 32 | AND lire_fichier_securise($cache, $meta) |
| 31 | - AND $meta = @unserialize($meta)) |
|
| 32 | - $GLOBALS[$table] = $meta; |
|
| 33 | + AND $meta = @unserialize($meta)) { |
|
| 34 | + $GLOBALS[$table] = $meta; |
|
| 35 | + } |
|
| 33 | 36 | |
| 34 | 37 | if (isset($GLOBALS[$table]['touch']) |
| 35 | - AND ($GLOBALS[$table]['touch']<time()-_META_CACHE_TIME)) |
|
| 36 | - $GLOBALS[$table] = array(); |
|
| 38 | + AND ($GLOBALS[$table]['touch']<time()-_META_CACHE_TIME)) { |
|
| 39 | + $GLOBALS[$table] = array(); |
|
| 40 | + } |
|
| 37 | 41 | // sinon lire en base |
| 38 | - if (!$GLOBALS[$table]) $new = !lire_metas($table); |
|
| 42 | + if (!$GLOBALS[$table]) { |
|
| 43 | + $new = !lire_metas($table); |
|
| 44 | + } |
|
| 39 | 45 | |
| 40 | 46 | // renouveller l'alea general si trop vieux ou sur demande explicite |
| 41 | 47 | if ((test_espace_prive() || isset($_GET['renouvelle_alea'])) |
@@ -47,11 +53,15 @@ discard block |
||
| 47 | 53 | include_spip('inc/acces'); |
| 48 | 54 | renouvelle_alea(); |
| 49 | 55 | $new = false; |
| 50 | - } else spip_log("impossible d'ecrire dans " . $cache); |
|
| 56 | + } else { |
|
| 57 | + spip_log("impossible d'ecrire dans " . $cache); |
|
| 58 | + } |
|
| 51 | 59 | } |
| 52 | 60 | // et refaire le cache si on a du lire en base |
| 53 | - if (!$new) touch_meta(false, $table); |
|
| 54 | -} |
|
| 61 | + if (!$new) { |
|
| 62 | + touch_meta(false, $table); |
|
| 63 | + } |
|
| 64 | + } |
|
| 55 | 65 | |
| 56 | 66 | // fonctions aussi appelees a l'install ==> spip_query en premiere requete |
| 57 | 67 | // pour eviter l'erreur fatale (serveur non encore configure) |
@@ -62,20 +72,23 @@ discard block |
||
| 62 | 72 | if ($result = spip_query("SELECT nom,valeur FROM spip_$table")) { |
| 63 | 73 | include_spip('base/abstract_sql'); |
| 64 | 74 | $GLOBALS[$table] = array(); |
| 65 | - while ($row = sql_fetch($result)) |
|
| 66 | - $GLOBALS[$table][$row['nom']] = $row['valeur']; |
|
| 75 | + while ($row = sql_fetch($result)) { |
|
| 76 | + $GLOBALS[$table][$row['nom']] = $row['valeur']; |
|
| 77 | + } |
|
| 67 | 78 | sql_free($result); |
| 68 | 79 | |
| 69 | 80 | if (!$GLOBALS[$table]['charset'] |
| 70 | 81 | OR $GLOBALS[$table]['charset']=='_DEFAULT_CHARSET' // hum, correction d'un bug ayant abime quelques install |
| 71 | - ) |
|
| 72 | - ecrire_meta('charset', _DEFAULT_CHARSET, NULL, $table); |
|
| 82 | + ) { |
|
| 83 | + ecrire_meta('charset', _DEFAULT_CHARSET, NULL, $table); |
|
| 84 | + } |
|
| 73 | 85 | |
| 74 | 86 | // noter cette table de configuration dans les meta de SPIP |
| 75 | 87 | if ($table!=='meta') { |
| 76 | 88 | $liste = unserialize($GLOBALS['meta']['tables_config']); |
| 77 | - if (!$liste) |
|
| 78 | - $liste = array(); |
|
| 89 | + if (!$liste) { |
|
| 90 | + $liste = array(); |
|
| 91 | + } |
|
| 79 | 92 | if (!in_array($table, $liste)) { |
| 80 | 93 | $liste[] = $table; |
| 81 | 94 | ecrire_meta('tables_config', serialize($liste)); |
@@ -98,7 +111,9 @@ discard block |
||
| 98 | 111 | // mais le sortir deu cache meta implique une requete sql des qu'on a un form dynamique |
| 99 | 112 | // meme si son squelette est en cache |
| 100 | 113 | //unset($r['secret_du_site']); |
| 101 | - if ($antidate) $r['touch']= $antidate; |
|
| 114 | + if ($antidate) { |
|
| 115 | + $r['touch']= $antidate; |
|
| 116 | + } |
|
| 102 | 117 | ecrire_fichier_securise($file, serialize($r)); |
| 103 | 118 | } |
| 104 | 119 | } |
@@ -121,7 +136,9 @@ discard block |
||
| 121 | 136 | function ecrire_meta($nom, $valeur, $importable = NULL, $table='meta') { |
| 122 | 137 | |
| 123 | 138 | static $touch = array(); |
| 124 | - if (!$nom) return; |
|
| 139 | + if (!$nom) { |
|
| 140 | + return; |
|
| 141 | + } |
|
| 125 | 142 | include_spip('base/abstract_sql'); |
| 126 | 143 | $res = sql_select("*",'spip_' . $table,"nom=" . sql_quote($nom),'','','','','','continue'); |
| 127 | 144 | // table pas encore installee, travailler en php seulement |
@@ -134,7 +151,9 @@ discard block |
||
| 134 | 151 | |
| 135 | 152 | // ne pas invalider le cache si affectation a l'identique |
| 136 | 153 | // (tant pis si impt aurait du changer) |
| 137 | - if ($row AND $valeur == $row['valeur'] AND $GLOBALS[$table][$nom] == $valeur) return; |
|
| 154 | + if ($row AND $valeur == $row['valeur'] AND $GLOBALS[$table][$nom] == $valeur) { |
|
| 155 | + return; |
|
| 156 | + } |
|
| 138 | 157 | |
| 139 | 158 | $GLOBALS[$table][$nom] = $valeur; |
| 140 | 159 | // cf effacer pour comprendre le double touch |
@@ -142,7 +161,9 @@ discard block |
||
| 142 | 161 | if (!isset($touch[$table])) {touch_meta($antidate, $table);} |
| 143 | 162 | $r = array('nom' => $nom, 'valeur' => $valeur); |
| 144 | 163 | // Gaffe aux tables sans impt (vieilles versions de SPIP notamment) |
| 145 | - if ($importable AND isset($row['impt'])) $r['impt'] = $importable; |
|
| 164 | + if ($importable AND isset($row['impt'])) { |
|
| 165 | + $r['impt'] = $importable; |
|
| 166 | + } |
|
| 146 | 167 | if ($row) { |
| 147 | 168 | sql_updateq('spip_' . $table, $r,"nom=" . sql_quote($nom)); |
| 148 | 169 | } else { |
@@ -179,7 +200,10 @@ discard block |
||
| 179 | 200 | * @param bool $force |
| 180 | 201 | */ |
| 181 | 202 | function supprimer_table_meta($table, $force=false) { |
| 182 | - if ($table=='meta') return; // interdit ! |
|
| 203 | + if ($table=='meta') { |
|
| 204 | + return; |
|
| 205 | + } |
|
| 206 | + // interdit ! |
|
| 183 | 207 | |
| 184 | 208 | if ($force OR !sql_countsel("spip_$table")) { |
| 185 | 209 | unset($GLOBALS[$table]); |
@@ -58,6 +58,12 @@ |
||
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | // http://doc.spip.org/@construire_selectionner_hierarchie |
| 61 | +/** |
|
| 62 | + * @param string $idom |
|
| 63 | + * @param string|boolean $racine |
|
| 64 | + * @param string $url |
|
| 65 | + * @param string $name |
|
| 66 | + */ |
|
| 61 | 67 | function construire_selectionner_hierarchie($idom, $liste, $racine, $url, $name, $url_init='') |
| 62 | 68 | { |
| 63 | 69 | global $spip_lang_right; |
@@ -10,7 +10,9 @@ discard block |
||
| 10 | 10 | * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * |
| 11 | 11 | \***************************************************************************/ |
| 12 | 12 | |
| 13 | -if (!defined('_ECRIRE_INC_VERSION')) return; |
|
| 13 | +if (!defined('_ECRIRE_INC_VERSION')) { |
|
| 14 | + return; |
|
| 15 | +} |
|
| 14 | 16 | |
| 15 | 17 | include_spip('inc/filtres'); |
| 16 | 18 | |
@@ -21,7 +23,11 @@ discard block |
||
| 21 | 23 | // http://doc.spip.org/@inc_selectionner_dist |
| 22 | 24 | function inc_selectionner_dist ($sel, $idom="", $exclus=0, $aff_racine=false, $recur=true, $do='aff') { |
| 23 | 25 | |
| 24 | - if ($recur) $recur = mini_hier($sel); else $sel = 0; |
|
| 26 | + if ($recur) { |
|
| 27 | + $recur = mini_hier($sel); |
|
| 28 | + } else { |
|
| 29 | + $sel = 0; |
|
| 30 | + } |
|
| 25 | 31 | |
| 26 | 32 | if ($aff_racine) { |
| 27 | 33 | $info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id="); |
@@ -118,8 +124,9 @@ discard block |
||
| 118 | 124 | |
| 119 | 125 | $liste = $id_rubrique; |
| 120 | 126 | $id_rubrique = intval($id_rubrique); |
| 121 | - while ($id_rubrique = sql_getfetsel("id_parent", "spip_rubriques", "id_rubrique = " . $id_rubrique)) |
|
| 122 | - $liste = $id_rubrique . ",$liste"; |
|
| 127 | + while ($id_rubrique = sql_getfetsel("id_parent", "spip_rubriques", "id_rubrique = " . $id_rubrique)) { |
|
| 128 | + $liste = $id_rubrique . ",$liste"; |
|
| 129 | + } |
|
| 123 | 130 | return explode(',',"0,$liste"); |
| 124 | 131 | } |
| 125 | 132 | |