Completed
Push — master ( db1666...a9bd83 )
by cam
01:35
created
ecrire/public/normaliser.php 1 patch
Indentation   +159 added lines, -159 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 // Les fonctions de ce fichier sont appelees en certains points
@@ -25,193 +25,193 @@  discard block
 block discarded – undo
25 25
 // -> https://www.spip.net/fr_article901.html
26 26
 
27 27
 function phraser_vieux_logos(&$p) {
28
-	if ($p->param[0][0]) {
29
-		$args = [''];
30
-	} else {
31
-		$args = array_shift($p->param);
32
-	}
33
-
34
-	foreach ($p->param as $couple) {
35
-		$nom = trim($couple[0]);
36
-		if ($nom == '') {
37
-			array_shift($p->param);
38
-			break;
39
-		}
40
-		$r = phraser_logo_faux_filtres($nom);
41
-		if ($r === 0) {
42
-			$c = new Texte();
43
-			$c->texte = $nom;
44
-			$args[] = [$c];
45
-			array_shift($p->param);
46
-			spip_log("filtre de logo obsolete $nom", 'vieilles_defs');
47
-		} elseif ($r === 2) {
48
-			$p->etoile = '**';
49
-			array_shift($p->param);
50
-			spip_log("filtre de logo obsolete $nom", 'vieilles_defs');
51
-		} elseif ($r === 1) {
52
-			array_shift($p->param);
53
-			$p->etoile = '*';
54
-			spip_log("filtre de logo obsolete $nom", 'vieilles_defs');
55
-		} elseif (preg_match('/^' . NOM_DE_CHAMP . '(.*)$/sS', $nom, $m)) {
56
-			$champ = new Champ();
57
-			$champ->nom_boucle = $m[2];
58
-			$champ->nom_champ = $m[3];
59
-			$champ->etoile = $m[5];
60
-			$champ = [$champ];
61
-			if ($m[6]) {
62
-				$r = new Texte();
63
-				$r->texte = $m[6];
64
-				$champ[] = $r;
65
-			}
66
-			$args[] = $champ;
67
-			array_shift($p->param);
68
-			spip_log("filtre de logo obsolete $nom", 'vieilles_defs');
69
-		} // le cas else est la seule incompatibilite
70
-	}
71
-	array_unshift($p->param, $args);
28
+    if ($p->param[0][0]) {
29
+        $args = [''];
30
+    } else {
31
+        $args = array_shift($p->param);
32
+    }
33
+
34
+    foreach ($p->param as $couple) {
35
+        $nom = trim($couple[0]);
36
+        if ($nom == '') {
37
+            array_shift($p->param);
38
+            break;
39
+        }
40
+        $r = phraser_logo_faux_filtres($nom);
41
+        if ($r === 0) {
42
+            $c = new Texte();
43
+            $c->texte = $nom;
44
+            $args[] = [$c];
45
+            array_shift($p->param);
46
+            spip_log("filtre de logo obsolete $nom", 'vieilles_defs');
47
+        } elseif ($r === 2) {
48
+            $p->etoile = '**';
49
+            array_shift($p->param);
50
+            spip_log("filtre de logo obsolete $nom", 'vieilles_defs');
51
+        } elseif ($r === 1) {
52
+            array_shift($p->param);
53
+            $p->etoile = '*';
54
+            spip_log("filtre de logo obsolete $nom", 'vieilles_defs');
55
+        } elseif (preg_match('/^' . NOM_DE_CHAMP . '(.*)$/sS', $nom, $m)) {
56
+            $champ = new Champ();
57
+            $champ->nom_boucle = $m[2];
58
+            $champ->nom_champ = $m[3];
59
+            $champ->etoile = $m[5];
60
+            $champ = [$champ];
61
+            if ($m[6]) {
62
+                $r = new Texte();
63
+                $r->texte = $m[6];
64
+                $champ[] = $r;
65
+            }
66
+            $args[] = $champ;
67
+            array_shift($p->param);
68
+            spip_log("filtre de logo obsolete $nom", 'vieilles_defs');
69
+        } // le cas else est la seule incompatibilite
70
+    }
71
+    array_unshift($p->param, $args);
72 72
 }
73 73
 
74 74
 
75 75
 function phraser_logo_faux_filtres($nom) {
76
-	switch ($nom) {
77
-		case 'top':
78
-		case 'left':
79
-		case 'right':
80
-		case 'center':
81
-		case 'bottom':
82
-			return 0;
83
-		case 'lien':
84
-			return 1;
85
-		case 'fichier':
86
-			return 2;
87
-		default:
88
-			return $nom;
89
-	}
76
+    switch ($nom) {
77
+        case 'top':
78
+        case 'left':
79
+        case 'right':
80
+        case 'center':
81
+        case 'bottom':
82
+            return 0;
83
+        case 'lien':
84
+            return 1;
85
+        case 'fichier':
86
+            return 2;
87
+        default:
88
+            return $nom;
89
+    }
90 90
 }
91 91
 
92 92
 
93 93
 // La balise embed_document est a present le modele emb
94 94
 
95 95
 function phraser_vieux_emb(&$p) {
96
-	if (!is_array($p->param)) {
97
-		$p->param = [];
98
-	}
99
-
100
-	// Produire le premier argument {emb}
101
-	$texte = new Texte();
102
-	$texte->texte = 'emb';
103
-	$param = ['', [$texte]];
104
-
105
-	// Transformer les filtres en arguments
106
-	for ($i = 0; $i < (is_countable($p->param) ? count($p->param) : 0); $i++) {
107
-		if ($p->param[$i][0]) {
108
-			if (!strstr($p->param[$i][0], '=')) {
109
-				break;
110
-			}# on a rencontre un vrai filtre, c'est fini
111
-			$texte = new Texte();
112
-			$texte->texte = $p->param[$i][0];
113
-			$param[] = [$texte];
114
-		}
115
-		array_shift($p->param);
116
-	}
117
-	array_unshift($p->param, $param);
118
-	spip_log('balise EMBED_DOCUMENT obsolete', 'vieilles_defs');
119
-	$p->nom_champ = 'MODELE';
96
+    if (!is_array($p->param)) {
97
+        $p->param = [];
98
+    }
99
+
100
+    // Produire le premier argument {emb}
101
+    $texte = new Texte();
102
+    $texte->texte = 'emb';
103
+    $param = ['', [$texte]];
104
+
105
+    // Transformer les filtres en arguments
106
+    for ($i = 0; $i < (is_countable($p->param) ? count($p->param) : 0); $i++) {
107
+        if ($p->param[$i][0]) {
108
+            if (!strstr($p->param[$i][0], '=')) {
109
+                break;
110
+            }# on a rencontre un vrai filtre, c'est fini
111
+            $texte = new Texte();
112
+            $texte->texte = $p->param[$i][0];
113
+            $param[] = [$texte];
114
+        }
115
+        array_shift($p->param);
116
+    }
117
+    array_unshift($p->param, $param);
118
+    spip_log('balise EMBED_DOCUMENT obsolete', 'vieilles_defs');
119
+    $p->nom_champ = 'MODELE';
120 120
 }
121 121
 
122 122
 // Vieux formulaire de recherch
123 123
 
124 124
 function phraser_vieux_recherche($p) {
125
-	if ($p->param[0][0]) {
126
-		$c = new Texte();
127
-		$c->texte = $p->param[0][0];
128
-		$p->param[0][1] = [$c];
129
-		$p->param[0][0] = '';
130
-		$p->fonctions = [];
131
-		spip_log('FORMULAIRE_RECHERCHE avec filtre ' . $c->texte, 'vieilles_defs');
132
-	}
125
+    if ($p->param[0][0]) {
126
+        $c = new Texte();
127
+        $c->texte = $p->param[0][0];
128
+        $p->param[0][1] = [$c];
129
+        $p->param[0][0] = '';
130
+        $p->fonctions = [];
131
+        spip_log('FORMULAIRE_RECHERCHE avec filtre ' . $c->texte, 'vieilles_defs');
132
+    }
133 133
 }
134 134
 
135 135
 // Gerer la notation [(#EXPOSER|on,off)]
136 136
 function phraser_vieux_exposer($p) {
137
-	if ($a = $p->fonctions) {
138
-		preg_match('#([^,]*)(,(.*))?#', $a[0][0], $regs);
139
-		$args = [];
140
-		if ($regs[1]) {
141
-			$a = new Texte();
142
-			$a->texte = $regs[1];
143
-			$args = ['', [$a]];
144
-			if ($regs[3]) {
145
-				$a = new Texte();
146
-				$a->texte = $regs[3];
147
-				$args[] = [$a];
148
-			}
149
-		}
150
-		$p->param[0] = $args;
151
-		$p->fonctions = [];
152
-		$p->nom_champ = 'EXPOSE';
153
-	}
137
+    if ($a = $p->fonctions) {
138
+        preg_match('#([^,]*)(,(.*))?#', $a[0][0], $regs);
139
+        $args = [];
140
+        if ($regs[1]) {
141
+            $a = new Texte();
142
+            $a->texte = $regs[1];
143
+            $args = ['', [$a]];
144
+            if ($regs[3]) {
145
+                $a = new Texte();
146
+                $a->texte = $regs[3];
147
+                $args[] = [$a];
148
+            }
149
+        }
150
+        $p->param[0] = $args;
151
+        $p->fonctions = [];
152
+        $p->nom_champ = 'EXPOSE';
153
+    }
154 154
 }
155 155
 
156 156
 function phraser_vieux_modele($p) {
157
- normaliser_args_inclumodel($p);
157
+    normaliser_args_inclumodel($p);
158 158
 }
159 159
 
160 160
 function phraser_vieux_inclu($p) {
161
- normaliser_args_inclumodel($p);
161
+    normaliser_args_inclumodel($p);
162 162
 }
163 163
 
164 164
 function normaliser_args_inclumodel($p) {
165
-	$params = $p->param;
166
-	if (!$params) {
167
-		return;
168
-	}
169
-	$args = $params[0];
170
-	if ($args[0]) {
171
-		return;
172
-	} // filtre immediat
173
-	array_shift($p->param);
174
-	foreach ($p->param as $l) {
175
-		if (!array_shift($l)) {
176
-			$args = array_merge($args, $l);
177
-			array_shift($p->param);
178
-		} else {
179
-			break;
180
-		} // filtre
181
-	}
182
-	array_unshift($p->param, $args);
165
+    $params = $p->param;
166
+    if (!$params) {
167
+        return;
168
+    }
169
+    $args = $params[0];
170
+    if ($args[0]) {
171
+        return;
172
+    } // filtre immediat
173
+    array_shift($p->param);
174
+    foreach ($p->param as $l) {
175
+        if (!array_shift($l)) {
176
+            $args = array_merge($args, $l);
177
+            array_shift($p->param);
178
+        } else {
179
+            break;
180
+        } // filtre
181
+    }
182
+    array_unshift($p->param, $args);
183 183
 }
184 184
 
185 185
 function normaliser_inclure($champ) {
186
-	normaliser_args_inclumodel($champ);
187
-	$l = $champ->param[0];
188
-	if (is_array($l) and !$l[0]) {
189
-		foreach ($l as $k => $p) {
190
-			if ($p and $p[0]->type == 'texte' and !strpos($p[0]->texte, '=')) {
191
-				$p[0]->texte = trim($p[0]->texte);
192
-			}
193
-		}
194
-		foreach ($l as $k => $p) {
195
-			if (
196
-				!$p or $p[0]->type != 'texte' or
197
-				!preg_match('/^fond\s*=\s*(.*)$/', $p[0]->texte, $r)
198
-			) {
199
-				continue;
200
-			}
201
-
202
-			if ($r[1]) {
203
-				$p[0]->texte = $r[1];
204
-			} else {
205
-				unset($p[0]);
206
-			}
207
-			$champ->texte = $p;
208
-			unset($champ->param[0][$k]);
209
-			if ((is_countable($champ->param[0]) ? count($champ->param[0]) : 0) == 1) {
210
-				array_shift($champ->param);
211
-			}
212
-
213
-			return;
214
-		}
215
-	}
216
-	spip_log('inclure sans fond ni fichier');
186
+    normaliser_args_inclumodel($champ);
187
+    $l = $champ->param[0];
188
+    if (is_array($l) and !$l[0]) {
189
+        foreach ($l as $k => $p) {
190
+            if ($p and $p[0]->type == 'texte' and !strpos($p[0]->texte, '=')) {
191
+                $p[0]->texte = trim($p[0]->texte);
192
+            }
193
+        }
194
+        foreach ($l as $k => $p) {
195
+            if (
196
+                !$p or $p[0]->type != 'texte' or
197
+                !preg_match('/^fond\s*=\s*(.*)$/', $p[0]->texte, $r)
198
+            ) {
199
+                continue;
200
+            }
201
+
202
+            if ($r[1]) {
203
+                $p[0]->texte = $r[1];
204
+            } else {
205
+                unset($p[0]);
206
+            }
207
+            $champ->texte = $p;
208
+            unset($champ->param[0][$k]);
209
+            if ((is_countable($champ->param[0]) ? count($champ->param[0]) : 0) == 1) {
210
+                array_shift($champ->param);
211
+            }
212
+
213
+            return;
214
+        }
215
+    }
216
+    spip_log('inclure sans fond ni fichier');
217 217
 }
Please login to merge, or discard this patch.
ecrire/inc_version.php 1 patch
Indentation   +213 added lines, -213 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  **/
18 18
 
19 19
 if (defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 /**
@@ -36,15 +36,15 @@  discard block
 block discarded – undo
36 36
 define('_PHP_MIN', '7.4.0');
37 37
 
38 38
 if (!defined('_DIR_RESTREINT_ABS')) {
39
-	/** le nom du repertoire ecrire/ */
40
-	define('_DIR_RESTREINT_ABS', 'ecrire/');
39
+    /** le nom du repertoire ecrire/ */
40
+    define('_DIR_RESTREINT_ABS', 'ecrire/');
41 41
 }
42 42
 
43 43
 /** Chemin relatif pour aller dans ecrire
44 44
  *  vide si on est dans ecrire, 'ecrire/' sinon */
45 45
 define(
46
-	'_DIR_RESTREINT',
47
-	(!is_dir(_DIR_RESTREINT_ABS) ? '' : _DIR_RESTREINT_ABS)
46
+    '_DIR_RESTREINT',
47
+    (!is_dir(_DIR_RESTREINT_ABS) ? '' : _DIR_RESTREINT_ABS)
48 48
 );
49 49
 
50 50
 /** Chemin relatif pour aller à la racine */
@@ -59,8 +59,8 @@  discard block
 block discarded – undo
59 59
 
60 60
 // Icones
61 61
 if (!defined('_NOM_IMG_PACK')) {
62
-	/** Nom du dossier images */
63
-	define('_NOM_IMG_PACK', 'images/');
62
+    /** Nom du dossier images */
63
+    define('_NOM_IMG_PACK', 'images/');
64 64
 }
65 65
 /** le chemin http (relatif) vers les images standard */
66 66
 define('_DIR_IMG_PACK', (_DIR_RACINE . 'prive/' . _NOM_IMG_PACK));
@@ -69,8 +69,8 @@  discard block
 block discarded – undo
69 69
 define('_ROOT_IMG_PACK', dirname(__DIR__) . '/prive/' . _NOM_IMG_PACK);
70 70
 
71 71
 if (!defined('_JAVASCRIPT')) {
72
-	/** Nom du repertoire des  bibliotheques JavaScript */
73
-	define('_JAVASCRIPT', 'javascript/');
72
+    /** Nom du repertoire des  bibliotheques JavaScript */
73
+    define('_JAVASCRIPT', 'javascript/');
74 74
 } // utilisable avec #CHEMIN et find_in_path
75 75
 /** le nom du repertoire des  bibliotheques JavaScript du prive */
76 76
 define('_DIR_JAVASCRIPT', (_DIR_RACINE . 'prive/' . _JAVASCRIPT));
@@ -80,47 +80,47 @@  discard block
 block discarded – undo
80 80
 # mais on peut les mettre ailleurs et changer completement les noms
81 81
 
82 82
 if (!defined('_NOM_TEMPORAIRES_INACCESSIBLES')) {
83
-	/** Nom du repertoire des fichiers Temporaires Inaccessibles par http:// */
84
-	define('_NOM_TEMPORAIRES_INACCESSIBLES', 'tmp/');
83
+    /** Nom du repertoire des fichiers Temporaires Inaccessibles par http:// */
84
+    define('_NOM_TEMPORAIRES_INACCESSIBLES', 'tmp/');
85 85
 }
86 86
 if (!defined('_NOM_TEMPORAIRES_ACCESSIBLES')) {
87
-	/** Nom du repertoire des fichiers Temporaires Accessibles par http:// */
88
-	define('_NOM_TEMPORAIRES_ACCESSIBLES', 'local/');
87
+    /** Nom du repertoire des fichiers Temporaires Accessibles par http:// */
88
+    define('_NOM_TEMPORAIRES_ACCESSIBLES', 'local/');
89 89
 }
90 90
 if (!defined('_NOM_PERMANENTS_INACCESSIBLES')) {
91
-	/** Nom du repertoire des fichiers Permanents Inaccessibles par http:// */
92
-	define('_NOM_PERMANENTS_INACCESSIBLES', 'config/');
91
+    /** Nom du repertoire des fichiers Permanents Inaccessibles par http:// */
92
+    define('_NOM_PERMANENTS_INACCESSIBLES', 'config/');
93 93
 }
94 94
 if (!defined('_NOM_PERMANENTS_ACCESSIBLES')) {
95
-	/** Nom du repertoire des fichiers Permanents Accessibles par http:// */
96
-	define('_NOM_PERMANENTS_ACCESSIBLES', 'IMG/');
95
+    /** Nom du repertoire des fichiers Permanents Accessibles par http:// */
96
+    define('_NOM_PERMANENTS_ACCESSIBLES', 'IMG/');
97 97
 }
98 98
 
99 99
 
100 100
 /** Le nom du fichier de personnalisation */
101 101
 if (!defined('_NOM_CONFIG')) {
102
-	define('_NOM_CONFIG', 'mes_options');
102
+    define('_NOM_CONFIG', 'mes_options');
103 103
 }
104 104
 
105 105
 // Son emplacement absolu si on le trouve
106 106
 if (
107
-	@file_exists($f = _ROOT_RACINE . _NOM_PERMANENTS_INACCESSIBLES . _NOM_CONFIG . '.php')
108
-	or (@file_exists($f = _ROOT_RESTREINT . _NOM_CONFIG . '.php'))
107
+    @file_exists($f = _ROOT_RACINE . _NOM_PERMANENTS_INACCESSIBLES . _NOM_CONFIG . '.php')
108
+    or (@file_exists($f = _ROOT_RESTREINT . _NOM_CONFIG . '.php'))
109 109
 ) {
110
-	/** Emplacement absolu du fichier d'option */
111
-	define('_FILE_OPTIONS', $f);
110
+    /** Emplacement absolu du fichier d'option */
111
+    define('_FILE_OPTIONS', $f);
112 112
 } else {
113
-	define('_FILE_OPTIONS', '');
113
+    define('_FILE_OPTIONS', '');
114 114
 }
115 115
 
116 116
 if (!defined('MODULES_IDIOMES')) {
117
-	/**
118
-	 * Modules par défaut pour la traduction.
119
-	 *
120
-	 * Constante utilisée par le compilateur et le décompilateur
121
-	 * sa valeur etant traitée par inc_traduire_dist
122
-	 */
123
-	define('MODULES_IDIOMES', 'public|spip|ecrire');
117
+    /**
118
+     * Modules par défaut pour la traduction.
119
+     *
120
+     * Constante utilisée par le compilateur et le décompilateur
121
+     * sa valeur etant traitée par inc_traduire_dist
122
+     */
123
+    define('MODULES_IDIOMES', 'public|spip|ecrire');
124 124
 }
125 125
 
126 126
 // *** Fin des define *** //
@@ -128,10 +128,10 @@  discard block
 block discarded – undo
128 128
 
129 129
 // Inclure l'ecran de securite
130 130
 if (
131
-	!defined('_ECRAN_SECURITE')
132
-	and @file_exists($f = _ROOT_RACINE . _NOM_PERMANENTS_INACCESSIBLES . 'ecran_securite.php')
131
+    !defined('_ECRAN_SECURITE')
132
+    and @file_exists($f = _ROOT_RACINE . _NOM_PERMANENTS_INACCESSIBLES . 'ecran_securite.php')
133 133
 ) {
134
-	include $f;
134
+    include $f;
135 135
 }
136 136
 
137 137
 
@@ -139,30 +139,30 @@  discard block
 block discarded – undo
139 139
  * Détecteur de robot d'indexation
140 140
  */
141 141
 if (!defined('_IS_BOT')) {
142
-	define(
143
-		'_IS_BOT',
144
-		isset($_SERVER['HTTP_USER_AGENT'])
145
-		and preg_match(
146
-			// mots generiques
147
-			',bot|slurp|crawler|spider|webvac|yandex|'
148
-			// MSIE 6.0 est un botnet 99,9% du temps, on traite donc ce USER_AGENT comme un bot
149
-			. 'MSIE 6\.0|'
150
-			// UA plus cibles
151
-			. '80legs|accoona|AltaVista|ASPSeek|Baidu|Charlotte|EC2LinkFinder|eStyle|facebook|flipboard|hootsuite|FunWebProducts|Google|Genieo|INA dlweb|InfegyAtlas|Java VM|LiteFinder|Lycos|MetaURI|Moreover|Rambler|Scooter|ScrubbyBloglines|Yahoo|Yeti'
152
-			. ',i',
153
-			(string)$_SERVER['HTTP_USER_AGENT']
154
-		)
155
-	);
142
+    define(
143
+        '_IS_BOT',
144
+        isset($_SERVER['HTTP_USER_AGENT'])
145
+        and preg_match(
146
+            // mots generiques
147
+            ',bot|slurp|crawler|spider|webvac|yandex|'
148
+            // MSIE 6.0 est un botnet 99,9% du temps, on traite donc ce USER_AGENT comme un bot
149
+            . 'MSIE 6\.0|'
150
+            // UA plus cibles
151
+            . '80legs|accoona|AltaVista|ASPSeek|Baidu|Charlotte|EC2LinkFinder|eStyle|facebook|flipboard|hootsuite|FunWebProducts|Google|Genieo|INA dlweb|InfegyAtlas|Java VM|LiteFinder|Lycos|MetaURI|Moreover|Rambler|Scooter|ScrubbyBloglines|Yahoo|Yeti'
152
+            . ',i',
153
+            (string)$_SERVER['HTTP_USER_AGENT']
154
+        )
155
+    );
156 156
 }
157 157
 
158 158
 if (!defined('_IS_CLI')) {
159
-	define(
160
-		'_IS_CLI',
161
-		!isset($_SERVER['HTTP_HOST'])
162
-		and !strlen($_SERVER['DOCUMENT_ROOT'])
163
-		and !empty($_SERVER['argv'])
164
-		and empty($_SERVER['REQUEST_METHOD'])
165
-	);
159
+    define(
160
+        '_IS_CLI',
161
+        !isset($_SERVER['HTTP_HOST'])
162
+        and !strlen($_SERVER['DOCUMENT_ROOT'])
163
+        and !empty($_SERVER['argv'])
164
+        and empty($_SERVER['REQUEST_METHOD'])
165
+    );
166 166
 }
167 167
 
168 168
 // *** Parametrage par defaut de SPIP ***
@@ -174,61 +174,61 @@  discard block
 block discarded – undo
174 174
 // Ne pas les rendre indefinies.
175 175
 
176 176
 global
177
-	$nombre_de_logs,
178
-	$taille_des_logs,
179
-	$table_prefix,
180
-	$cookie_prefix,
181
-	$dossier_squelettes,
182
-	$filtrer_javascript,
183
-	$type_urls,
184
-	$debut_date_publication,
185
-	$ip,
186
-	$mysql_rappel_connexion,
187
-	$mysql_rappel_nom_base,
188
-	$test_i18n,
189
-	$ignore_auth_http,
190
-	$ignore_remote_user,
191
-	$derniere_modif_invalide,
192
-	$home_server,
193
-	$help_server,
194
-	$url_glossaire_externe,
195
-	$tex_server,
196
-	$traiter_math,
197
-	$xhtml,
198
-	$xml_indent,
199
-	$source_vignettes,
200
-	$formats_logos,
201
-	$controler_dates_rss,
202
-	$spip_pipeline,
203
-	$spip_matrice,
204
-	$plugins,
205
-	$surcharges,
206
-	$exceptions_des_tables,
207
-	$tables_principales,
208
-	$table_des_tables,
209
-	$tables_auxiliaires,
210
-	$table_primary,
211
-	$table_date,
212
-	$table_titre,
213
-	$tables_jointures,
214
-	$liste_des_statuts,
215
-	$liste_des_etats,
216
-	$liste_des_authentifications,
217
-	$spip_version_branche,
218
-	$spip_version_code,
219
-	$spip_version_base,
220
-	$spip_sql_version,
221
-	$spip_version_affichee,
222
-	$visiteur_session,
223
-	$auteur_session,
224
-	$connect_statut,
225
-	$connect_toutes_rubriques,
226
-	$hash_recherche,
227
-	$hash_recherche_strict,
228
-	$ldap_present,
229
-	$meta,
230
-	$connect_id_rubrique,
231
-	$puce;
177
+    $nombre_de_logs,
178
+    $taille_des_logs,
179
+    $table_prefix,
180
+    $cookie_prefix,
181
+    $dossier_squelettes,
182
+    $filtrer_javascript,
183
+    $type_urls,
184
+    $debut_date_publication,
185
+    $ip,
186
+    $mysql_rappel_connexion,
187
+    $mysql_rappel_nom_base,
188
+    $test_i18n,
189
+    $ignore_auth_http,
190
+    $ignore_remote_user,
191
+    $derniere_modif_invalide,
192
+    $home_server,
193
+    $help_server,
194
+    $url_glossaire_externe,
195
+    $tex_server,
196
+    $traiter_math,
197
+    $xhtml,
198
+    $xml_indent,
199
+    $source_vignettes,
200
+    $formats_logos,
201
+    $controler_dates_rss,
202
+    $spip_pipeline,
203
+    $spip_matrice,
204
+    $plugins,
205
+    $surcharges,
206
+    $exceptions_des_tables,
207
+    $tables_principales,
208
+    $table_des_tables,
209
+    $tables_auxiliaires,
210
+    $table_primary,
211
+    $table_date,
212
+    $table_titre,
213
+    $tables_jointures,
214
+    $liste_des_statuts,
215
+    $liste_des_etats,
216
+    $liste_des_authentifications,
217
+    $spip_version_branche,
218
+    $spip_version_code,
219
+    $spip_version_base,
220
+    $spip_sql_version,
221
+    $spip_version_affichee,
222
+    $visiteur_session,
223
+    $auteur_session,
224
+    $connect_statut,
225
+    $connect_toutes_rubriques,
226
+    $hash_recherche,
227
+    $hash_recherche_strict,
228
+    $ldap_present,
229
+    $meta,
230
+    $connect_id_rubrique,
231
+    $puce;
232 232
 
233 233
 # comment on logge, defaut 4 tmp/spip.log de 100k, 0 ou 0 suppriment le log
234 234
 $nombre_de_logs = 4;
@@ -283,48 +283,48 @@  discard block
 block discarded – undo
283 283
 // Prendre en compte les entetes HTTP_X_FORWARDED_XX
284 284
 //
285 285
 if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) and $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
286
-	if (empty($_SERVER['HTTP_X_FORWARDED_HOST'])) {
287
-		$_SERVER['HTTP_X_FORWARDED_HOST'] = $_SERVER['HTTP_HOST'];
288
-	}
289
-	if (empty($_SERVER['HTTP_X_FORWARDED_PORT'])) {
290
-		$_SERVER['HTTP_X_FORWARDED_PORT'] = 443;
291
-	}
286
+    if (empty($_SERVER['HTTP_X_FORWARDED_HOST'])) {
287
+        $_SERVER['HTTP_X_FORWARDED_HOST'] = $_SERVER['HTTP_HOST'];
288
+    }
289
+    if (empty($_SERVER['HTTP_X_FORWARDED_PORT'])) {
290
+        $_SERVER['HTTP_X_FORWARDED_PORT'] = 443;
291
+    }
292 292
 }
293 293
 if (isset($_SERVER['HTTP_X_FORWARDED_HOST'])) {
294
-	if (isset($_SERVER['HTTP_X_FORWARDED_PORT']) and is_numeric($_SERVER['HTTP_X_FORWARDED_PORT'])) {
295
-		$_SERVER['SERVER_PORT'] = $_SERVER['HTTP_X_FORWARDED_PORT'];
296
-		if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) and $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
297
-			$_SERVER['HTTPS'] = 'on';
298
-			if (isset($_SERVER['REQUEST_SCHEME'])) {
299
-				$_SERVER['REQUEST_SCHEME'] = 'https';
300
-			}
301
-		}
302
-	}
303
-	$host = $_SERVER['HTTP_X_FORWARDED_HOST'];
304
-	if (strpos($host, ',') !== false) {
305
-		$h = explode(',', $host);
306
-		$host = trim(reset($h));
307
-	}
308
-	// securite sur le contenu de l'entete
309
-	$host = strtr($host, "<>?\"\{\}\$'` \r\n", '____________');
310
-	$_SERVER['HTTP_HOST'] = $host;
294
+    if (isset($_SERVER['HTTP_X_FORWARDED_PORT']) and is_numeric($_SERVER['HTTP_X_FORWARDED_PORT'])) {
295
+        $_SERVER['SERVER_PORT'] = $_SERVER['HTTP_X_FORWARDED_PORT'];
296
+        if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) and $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
297
+            $_SERVER['HTTPS'] = 'on';
298
+            if (isset($_SERVER['REQUEST_SCHEME'])) {
299
+                $_SERVER['REQUEST_SCHEME'] = 'https';
300
+            }
301
+        }
302
+    }
303
+    $host = $_SERVER['HTTP_X_FORWARDED_HOST'];
304
+    if (strpos($host, ',') !== false) {
305
+        $h = explode(',', $host);
306
+        $host = trim(reset($h));
307
+    }
308
+    // securite sur le contenu de l'entete
309
+    $host = strtr($host, "<>?\"\{\}\$'` \r\n", '____________');
310
+    $_SERVER['HTTP_HOST'] = $host;
311 311
 }
312 312
 //
313 313
 // On note le numero IP du client dans la variable $ip
314 314
 //
315 315
 if (isset($_SERVER['HTTP_X_FORWARDED_FOR'])) {
316
-	$ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
317
-	if (strpos($ip, ',') !== false) {
318
-		$ip = explode(',', $ip);
319
-		$ip = reset($ip);
320
-	}
321
-	// ecraser $_SERVER['REMOTE_ADDR'] si elle est en localhost
322
-	if (isset($_SERVER['REMOTE_ADDR']) and $_SERVER['REMOTE_ADDR'] === '127.0.0.1') {
323
-		$_SERVER['REMOTE_ADDR'] = $ip;
324
-	}
316
+    $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
317
+    if (strpos($ip, ',') !== false) {
318
+        $ip = explode(',', $ip);
319
+        $ip = reset($ip);
320
+    }
321
+    // ecraser $_SERVER['REMOTE_ADDR'] si elle est en localhost
322
+    if (isset($_SERVER['REMOTE_ADDR']) and $_SERVER['REMOTE_ADDR'] === '127.0.0.1') {
323
+        $_SERVER['REMOTE_ADDR'] = $ip;
324
+    }
325 325
 }
326 326
 if (isset($_SERVER['REMOTE_ADDR'])) {
327
-	$ip = $_SERVER['REMOTE_ADDR'];
327
+    $ip = $_SERVER['REMOTE_ADDR'];
328 328
 }
329 329
 
330 330
 // Pour renforcer la privacy, decommentez la ligne ci-dessous (ou recopiez-la
@@ -409,24 +409,24 @@  discard block
 block discarded – undo
409 409
 
410 410
 // Liste des statuts.
411 411
 $liste_des_statuts = [
412
-	'info_administrateurs' => '0minirezo',
413
-	'info_redacteurs' => '1comite',
414
-	'info_visiteurs' => '6forum',
415
-	'texte_statut_poubelle' => '5poubelle'
412
+    'info_administrateurs' => '0minirezo',
413
+    'info_redacteurs' => '1comite',
414
+    'info_visiteurs' => '6forum',
415
+    'texte_statut_poubelle' => '5poubelle'
416 416
 ];
417 417
 
418 418
 $liste_des_etats = [
419
-	'texte_statut_en_cours_redaction' => 'prepa',
420
-	'texte_statut_propose_evaluation' => 'prop',
421
-	'texte_statut_publie' => 'publie',
422
-	'texte_statut_poubelle' => 'poubelle',
423
-	'texte_statut_refuse' => 'refuse'
419
+    'texte_statut_en_cours_redaction' => 'prepa',
420
+    'texte_statut_propose_evaluation' => 'prop',
421
+    'texte_statut_publie' => 'publie',
422
+    'texte_statut_poubelle' => 'poubelle',
423
+    'texte_statut_refuse' => 'refuse'
424 424
 ];
425 425
 
426 426
 // liste des methodes d'authentifications
427 427
 $liste_des_authentifications = [
428
-	'spip' => 'spip',
429
-	'ldap' => 'ldap'
428
+    'spip' => 'spip',
429
+    'ldap' => 'ldap'
430 430
 ];
431 431
 
432 432
 // Experimental : pour supprimer systematiquement l'affichage des numeros
@@ -476,12 +476,12 @@  discard block
 block discarded – undo
476 476
 // Definition personnelles eventuelles
477 477
 
478 478
 if (_FILE_OPTIONS) {
479
-	include_once _FILE_OPTIONS;
479
+    include_once _FILE_OPTIONS;
480 480
 }
481 481
 
482 482
 if (!defined('SPIP_ERREUR_REPORT')) {
483
-	/** Masquer les warning */
484
-	define('SPIP_ERREUR_REPORT', E_ALL ^ E_NOTICE ^ E_DEPRECATED);
483
+    /** Masquer les warning */
484
+    define('SPIP_ERREUR_REPORT', E_ALL ^ E_NOTICE ^ E_DEPRECATED);
485 485
 }
486 486
 error_reporting(SPIP_ERREUR_REPORT);
487 487
 
@@ -494,10 +494,10 @@  discard block
 block discarded – undo
494 494
 // ===> on execute en neutralisant les messages d'erreur
495 495
 
496 496
 spip_initialisation_core(
497
-	(_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES),
498
-	(_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES),
499
-	(_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES),
500
-	(_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES)
497
+    (_DIR_RACINE . _NOM_PERMANENTS_INACCESSIBLES),
498
+    (_DIR_RACINE . _NOM_PERMANENTS_ACCESSIBLES),
499
+    (_DIR_RACINE . _NOM_TEMPORAIRES_INACCESSIBLES),
500
+    (_DIR_RACINE . _NOM_TEMPORAIRES_ACCESSIBLES)
501 501
 );
502 502
 
503 503
 
@@ -507,70 +507,70 @@  discard block
 block discarded – undo
507 507
 // donc il faut avoir tout fini ici avant de charger les plugins
508 508
 
509 509
 if (@is_readable(_CACHE_PLUGINS_OPT) and @is_readable(_CACHE_PLUGINS_PATH)) {
510
-	// chargement optimise precompile
511
-	include_once(_CACHE_PLUGINS_OPT);
510
+    // chargement optimise precompile
511
+    include_once(_CACHE_PLUGINS_OPT);
512 512
 } else {
513
-	spip_initialisation_suite();
514
-	include_spip('inc/plugin');
515
-	// generer les fichiers php precompiles
516
-	// de chargement des plugins et des pipelines
517
-	actualise_plugins_actifs();
513
+    spip_initialisation_suite();
514
+    include_spip('inc/plugin');
515
+    // generer les fichiers php precompiles
516
+    // de chargement des plugins et des pipelines
517
+    actualise_plugins_actifs();
518 518
 }
519 519
 
520 520
 // Initialisations non critiques surchargeables par les plugins
521 521
 spip_initialisation_suite();
522 522
 
523 523
 if (!defined('_LOG_FILTRE_GRAVITE')) {
524
-	/** niveau maxi d'enregistrement des logs */
525
-	define('_LOG_FILTRE_GRAVITE', _LOG_INFO_IMPORTANTE);
524
+    /** niveau maxi d'enregistrement des logs */
525
+    define('_LOG_FILTRE_GRAVITE', _LOG_INFO_IMPORTANTE);
526 526
 }
527 527
 
528 528
 if (!defined('_OUTILS_DEVELOPPEURS')) {
529
-	/** Activer des outils pour développeurs ? */
530
-	define('_OUTILS_DEVELOPPEURS', false);
529
+    /** Activer des outils pour développeurs ? */
530
+    define('_OUTILS_DEVELOPPEURS', false);
531 531
 }
532 532
 
533 533
 // charger systematiquement inc/autoriser dans l'espace restreint
534 534
 if (test_espace_prive()) {
535
-	include_spip('inc/autoriser');
535
+    include_spip('inc/autoriser');
536 536
 }
537 537
 //
538 538
 // Installer Spip si pas installe... sauf si justement on est en train
539 539
 //
540 540
 if (
541
-	!(_FILE_CONNECT
542
-	or autoriser_sans_cookie(_request('exec'))
543
-	or _request('action') == 'cookie'
544
-	or _request('action') == 'converser'
545
-	or _request('action') == 'test_dirs')
541
+    !(_FILE_CONNECT
542
+    or autoriser_sans_cookie(_request('exec'))
543
+    or _request('action') == 'cookie'
544
+    or _request('action') == 'converser'
545
+    or _request('action') == 'test_dirs')
546 546
 ) {
547
-	// Si on peut installer, on lance illico
548
-	if (test_espace_prive()) {
549
-		include_spip('inc/headers');
550
-		redirige_url_ecrire('install');
551
-	} else {
552
-		// Si on est dans le site public, dire que qq s'en occupe
553
-		include_spip('inc/minipres');
554
-		utiliser_langue_visiteur();
555
-		echo minipres(_T('info_travaux_titre'), "<p style='text-align: center;'>" . _T('info_travaux_texte') . '</p>', ['status' => 503]);
556
-		exit;
557
-	}
558
-	// autrement c'est une install ad hoc (spikini...), on sait pas faire
547
+    // Si on peut installer, on lance illico
548
+    if (test_espace_prive()) {
549
+        include_spip('inc/headers');
550
+        redirige_url_ecrire('install');
551
+    } else {
552
+        // Si on est dans le site public, dire que qq s'en occupe
553
+        include_spip('inc/minipres');
554
+        utiliser_langue_visiteur();
555
+        echo minipres(_T('info_travaux_titre'), "<p style='text-align: center;'>" . _T('info_travaux_texte') . '</p>', ['status' => 503]);
556
+        exit;
557
+    }
558
+    // autrement c'est une install ad hoc (spikini...), on sait pas faire
559 559
 }
560 560
 
561 561
 // memoriser un tri sessionne eventuel
562 562
 if (
563
-	isset($_REQUEST['var_memotri'])
564
-	and $t = $_REQUEST['var_memotri']
565
-	and (strncmp($t, 'trisession', 10) == 0 or strncmp($t, 'senssession', 11) == 0)
563
+    isset($_REQUEST['var_memotri'])
564
+    and $t = $_REQUEST['var_memotri']
565
+    and (strncmp($t, 'trisession', 10) == 0 or strncmp($t, 'senssession', 11) == 0)
566 566
 ) {
567
-	if (!function_exists('session_set')) {
568
-		include_spip('inc/session');
569
-	}
570
-	$t = preg_replace(',\W,', '_', $t);
571
-	if ($v = _request($t)) {
572
-		session_set($t, $v);
573
-	}
567
+    if (!function_exists('session_set')) {
568
+        include_spip('inc/session');
569
+    }
570
+    $t = preg_replace(',\W,', '_', $t);
571
+    if ($v = _request($t)) {
572
+        session_set($t, $v);
573
+    }
574 574
 }
575 575
 
576 576
 /**
@@ -580,22 +580,22 @@  discard block
 block discarded – undo
580 580
  * La globale $spip_header_silencieux permet de rendre le header minimal pour raisons de securite
581 581
  */
582 582
 if (!defined('_HEADER_COMPOSED_BY')) {
583
-	define('_HEADER_COMPOSED_BY', 'Composed-By: SPIP');
583
+    define('_HEADER_COMPOSED_BY', 'Composed-By: SPIP');
584 584
 }
585 585
 if (!headers_sent() and _HEADER_COMPOSED_BY) {
586
-	if (!defined('_HEADER_VARY')) {
587
-		define('_HEADER_VARY', 'Vary: Cookie, Accept-Encoding');
588
-	}
589
-	if (_HEADER_VARY) {
590
-		header(_HEADER_VARY);
591
-	}
592
-	if (!isset($GLOBALS['spip_header_silencieux']) or !$GLOBALS['spip_header_silencieux']) {
593
-		include_spip('inc/filtres_mini');
594
-		header(_HEADER_COMPOSED_BY . " $spip_version_affichee @ www.spip.net + " . url_absolue(_DIR_VAR . 'config.txt'));
595
-	} else {
596
-		// header minimal
597
-		header(_HEADER_COMPOSED_BY . ' @ www.spip.net');
598
-	}
586
+    if (!defined('_HEADER_VARY')) {
587
+        define('_HEADER_VARY', 'Vary: Cookie, Accept-Encoding');
588
+    }
589
+    if (_HEADER_VARY) {
590
+        header(_HEADER_VARY);
591
+    }
592
+    if (!isset($GLOBALS['spip_header_silencieux']) or !$GLOBALS['spip_header_silencieux']) {
593
+        include_spip('inc/filtres_mini');
594
+        header(_HEADER_COMPOSED_BY . " $spip_version_affichee @ www.spip.net + " . url_absolue(_DIR_VAR . 'config.txt'));
595
+    } else {
596
+        // header minimal
597
+        header(_HEADER_COMPOSED_BY . ' @ www.spip.net');
598
+    }
599 599
 }
600 600
 
601 601
 $methode = ($_SERVER['REQUEST_METHOD'] ?? ((php_sapi_name() == 'cli') ? 'cli' : ''));
Please login to merge, or discard this patch.
ecrire/auth/ldap.php 1 patch
Indentation   +176 added lines, -176 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  **/
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 // Authentifie via LDAP et retourne la ligne SQL decrivant l'utilisateur si ok
@@ -25,12 +25,12 @@  discard block
 block discarded – undo
25 25
 // Attributs LDAP correspondants a ceux de SPIP, notamment pour le login
26 26
 // ne pas ecraser une definition perso dans mes_options
27 27
 if (!isset($GLOBALS['ldap_attributes']) or !is_array($GLOBALS['ldap_attributes'])) {
28
-	$GLOBALS['ldap_attributes'] = [
29
-		'login' => ['sAMAccountName', 'uid', 'login', 'userid', 'cn', 'sn'],
30
-		'nom' => 'cn',
31
-		'email' => 'mail',
32
-		'bio' => 'description'
33
-	];
28
+    $GLOBALS['ldap_attributes'] = [
29
+        'login' => ['sAMAccountName', 'uid', 'login', 'userid', 'cn', 'sn'],
30
+        'nom' => 'cn',
31
+        'email' => 'mail',
32
+        'bio' => 'description'
33
+    ];
34 34
 }
35 35
 
36 36
 /**
@@ -56,50 +56,50 @@  discard block
 block discarded – undo
56 56
  */
57 57
 function auth_ldap_dist($login, $pass, $serveur = '', $phpauth = false) {
58 58
 
59
-	#spip_log("ldap $login " . ($pass ? "mdp fourni" : "mdp absent"));
60
-
61
-	// Utilisateur connu ?
62
-	// si http auth, inutile de reauthentifier: cela
63
-	// ne marchera pas avec auth http autre que basic.
64
-	$checkpass = isset($_SERVER['REMOTE_USER']) ? false : true;
65
-	if (!($dn = auth_ldap_search($login, $pass, $checkpass, $serveur))) {
66
-		return [];
67
-	}
68
-	$credentials_ldap = ['ldap_dn' => $dn, 'ldap_password' => $pass];
69
-
70
-	// Si l'utilisateur figure deja dans la base, y recuperer les infos
71
-	$r = sql_fetsel('*', 'spip_auteurs', 'login=' . sql_quote($login) . " AND source='ldap'", '', '', '', '', $serveur);
72
-
73
-	if ($r) {
74
-		return array_merge($r, $credentials_ldap);
75
-	}
76
-
77
-	// sinon importer les infos depuis LDAP,
78
-
79
-	if (
80
-		$GLOBALS['meta']['ldap_statut_import']
81
-		and $desc = auth_ldap_retrouver($dn, [], $serveur)
82
-	) {
83
-		// rajouter le statut indique  a l'install
84
-		$desc['statut'] = $GLOBALS['meta']['ldap_statut_import'];
85
-		$desc['login'] = $login;
86
-		$desc['source'] = 'ldap';
87
-		$desc['pass'] = '';
88
-
89
-		$r = sql_insertq('spip_auteurs', $desc, '', $serveur);
90
-	}
91
-
92
-	if ($r) {
93
-		return array_merge(
94
-			$credentials_ldap,
95
-			sql_fetsel('*', 'spip_auteurs', 'id_auteur=' . intval($r), '', '', '', '', $serveur)
96
-		);
97
-	}
98
-
99
-	// sinon echec
100
-	spip_log("Creation de l'auteur '$login' impossible");
101
-
102
-	return [];
59
+    #spip_log("ldap $login " . ($pass ? "mdp fourni" : "mdp absent"));
60
+
61
+    // Utilisateur connu ?
62
+    // si http auth, inutile de reauthentifier: cela
63
+    // ne marchera pas avec auth http autre que basic.
64
+    $checkpass = isset($_SERVER['REMOTE_USER']) ? false : true;
65
+    if (!($dn = auth_ldap_search($login, $pass, $checkpass, $serveur))) {
66
+        return [];
67
+    }
68
+    $credentials_ldap = ['ldap_dn' => $dn, 'ldap_password' => $pass];
69
+
70
+    // Si l'utilisateur figure deja dans la base, y recuperer les infos
71
+    $r = sql_fetsel('*', 'spip_auteurs', 'login=' . sql_quote($login) . " AND source='ldap'", '', '', '', '', $serveur);
72
+
73
+    if ($r) {
74
+        return array_merge($r, $credentials_ldap);
75
+    }
76
+
77
+    // sinon importer les infos depuis LDAP,
78
+
79
+    if (
80
+        $GLOBALS['meta']['ldap_statut_import']
81
+        and $desc = auth_ldap_retrouver($dn, [], $serveur)
82
+    ) {
83
+        // rajouter le statut indique  a l'install
84
+        $desc['statut'] = $GLOBALS['meta']['ldap_statut_import'];
85
+        $desc['login'] = $login;
86
+        $desc['source'] = 'ldap';
87
+        $desc['pass'] = '';
88
+
89
+        $r = sql_insertq('spip_auteurs', $desc, '', $serveur);
90
+    }
91
+
92
+    if ($r) {
93
+        return array_merge(
94
+            $credentials_ldap,
95
+            sql_fetsel('*', 'spip_auteurs', 'id_auteur=' . intval($r), '', '', '', '', $serveur)
96
+        );
97
+    }
98
+
99
+    // sinon echec
100
+    spip_log("Creation de l'auteur '$login' impossible");
101
+
102
+    return [];
103 103
 }
104 104
 
105 105
 /**
@@ -113,36 +113,36 @@  discard block
 block discarded – undo
113 113
  * @return array
114 114
  */
115 115
 function auth_ldap_connect($serveur = '') {
116
-	include_spip('base/connect_sql');
117
-	static $connexions_ldap = [];
118
-	if (isset($connexions_ldap[$serveur])) {
119
-		return $connexions_ldap[$serveur];
120
-	}
121
-	$connexion = spip_connect($serveur);
122
-	if (!is_array($connexion['ldap'])) {
123
-		if ($connexion['authentification']['ldap']) {
124
-			$f = _DIR_CONNECT . $connexion['authentification']['ldap'];
125
-			unset($GLOBALS['ldap_link']);
126
-			if (is_readable($f)) {
127
-				include_once($f);
128
-			};
129
-			if (isset($GLOBALS['ldap_link'])) {
130
-				$connexion['ldap'] = [
131
-					'link' => $GLOBALS['ldap_link'],
132
-					'base' => $GLOBALS['ldap_base']
133
-				];
134
-			} else {
135
-				spip_log("connection LDAP $serveur mal definie dans $f");
136
-			}
137
-			if (isset($GLOBALS['ldap_champs'])) {
138
-				$connexion['ldap']['attributes'] = $GLOBALS['ldap_champs'];
139
-			}
140
-		} else {
141
-			spip_log("connection LDAP $serveur inconnue");
142
-		}
143
-	}
144
-
145
-	return $connexions_ldap[$serveur] = $connexion['ldap'];
116
+    include_spip('base/connect_sql');
117
+    static $connexions_ldap = [];
118
+    if (isset($connexions_ldap[$serveur])) {
119
+        return $connexions_ldap[$serveur];
120
+    }
121
+    $connexion = spip_connect($serveur);
122
+    if (!is_array($connexion['ldap'])) {
123
+        if ($connexion['authentification']['ldap']) {
124
+            $f = _DIR_CONNECT . $connexion['authentification']['ldap'];
125
+            unset($GLOBALS['ldap_link']);
126
+            if (is_readable($f)) {
127
+                include_once($f);
128
+            };
129
+            if (isset($GLOBALS['ldap_link'])) {
130
+                $connexion['ldap'] = [
131
+                    'link' => $GLOBALS['ldap_link'],
132
+                    'base' => $GLOBALS['ldap_base']
133
+                ];
134
+            } else {
135
+                spip_log("connection LDAP $serveur mal definie dans $f");
136
+            }
137
+            if (isset($GLOBALS['ldap_champs'])) {
138
+                $connexion['ldap']['attributes'] = $GLOBALS['ldap_champs'];
139
+            }
140
+        } else {
141
+            spip_log("connection LDAP $serveur inconnue");
142
+        }
143
+    }
144
+
145
+    return $connexions_ldap[$serveur] = $connexion['ldap'];
146 146
 }
147 147
 
148 148
 /**
@@ -156,52 +156,52 @@  discard block
 block discarded – undo
156 156
  *    Le login trouvé ou chaine vide si non trouvé
157 157
  */
158 158
 function auth_ldap_search($login, $pass, $checkpass = true, $serveur = '') {
159
-	// Securite anti-injection et contre un serveur LDAP laxiste
160
-	$login_search = preg_replace('/[^-@._\s\d\w]/', '', $login);
161
-	if (!strlen($login_search) or ($checkpass and !strlen($pass))) {
162
-		return '';
163
-	}
164
-
165
-	// verifier la connexion
166
-	if (!$ldap = auth_ldap_connect($serveur)) {
167
-		return '';
168
-	}
169
-
170
-	$ldap_link = $ldap['link'] ?? null;
171
-	$ldap_base = $ldap['base'] ?? null;
172
-	$desc = !empty($ldap['attributes']) ? $ldap['attributes'] : $GLOBALS['ldap_attributes'];
173
-
174
-	$logins = is_array($desc['login']) ? $desc['login'] : [$desc['login']];
175
-
176
-	// Tenter une recherche pour essayer de retrouver le DN
177
-	foreach ($logins as $att) {
178
-		$result = @ldap_search($ldap_link, $ldap_base, "$att=$login_search", ['dn']);
179
-		$info = @ldap_get_entries($ldap_link, $result);
180
-		// Ne pas accepter les resultats si plus d'une entree
181
-		// (on veut un attribut unique)
182
-
183
-		if (is_array($info) and $info['count'] == 1) {
184
-			$dn = $info[0]['dn'];
185
-			if (!$checkpass) {
186
-				return $dn;
187
-			}
188
-			if (@ldap_bind($ldap_link, $dn, $pass)) {
189
-				return $dn;
190
-			}
191
-		}
192
-	}
193
-
194
-	if ($checkpass and !isset($dn)) {
195
-		// Si echec, essayer de deviner le DN
196
-		foreach ($logins as $att) {
197
-			$dn = "$att=$login_search, $ldap_base";
198
-			if (@ldap_bind($ldap_link, $dn, $pass)) {
199
-				return "$att=$login_search, $ldap_base";
200
-			}
201
-		}
202
-	}
203
-
204
-	return '';
159
+    // Securite anti-injection et contre un serveur LDAP laxiste
160
+    $login_search = preg_replace('/[^-@._\s\d\w]/', '', $login);
161
+    if (!strlen($login_search) or ($checkpass and !strlen($pass))) {
162
+        return '';
163
+    }
164
+
165
+    // verifier la connexion
166
+    if (!$ldap = auth_ldap_connect($serveur)) {
167
+        return '';
168
+    }
169
+
170
+    $ldap_link = $ldap['link'] ?? null;
171
+    $ldap_base = $ldap['base'] ?? null;
172
+    $desc = !empty($ldap['attributes']) ? $ldap['attributes'] : $GLOBALS['ldap_attributes'];
173
+
174
+    $logins = is_array($desc['login']) ? $desc['login'] : [$desc['login']];
175
+
176
+    // Tenter une recherche pour essayer de retrouver le DN
177
+    foreach ($logins as $att) {
178
+        $result = @ldap_search($ldap_link, $ldap_base, "$att=$login_search", ['dn']);
179
+        $info = @ldap_get_entries($ldap_link, $result);
180
+        // Ne pas accepter les resultats si plus d'une entree
181
+        // (on veut un attribut unique)
182
+
183
+        if (is_array($info) and $info['count'] == 1) {
184
+            $dn = $info[0]['dn'];
185
+            if (!$checkpass) {
186
+                return $dn;
187
+            }
188
+            if (@ldap_bind($ldap_link, $dn, $pass)) {
189
+                return $dn;
190
+            }
191
+        }
192
+    }
193
+
194
+    if ($checkpass and !isset($dn)) {
195
+        // Si echec, essayer de deviner le DN
196
+        foreach ($logins as $att) {
197
+            $dn = "$att=$login_search, $ldap_base";
198
+            if (@ldap_bind($ldap_link, $dn, $pass)) {
199
+                return "$att=$login_search, $ldap_base";
200
+            }
201
+        }
202
+    }
203
+
204
+    return '';
205 205
 }
206 206
 
207 207
 /**
@@ -213,40 +213,40 @@  discard block
 block discarded – undo
213 213
  * @return array
214 214
  */
215 215
 function auth_ldap_retrouver($dn, $desc = [], $serveur = '') {
216
-	// Lire les infos sur l'utilisateur a partir de son DN depuis LDAP
216
+    // Lire les infos sur l'utilisateur a partir de son DN depuis LDAP
217 217
 
218
-	if (!$ldap = spip_connect_ldap($serveur)) {
219
-		spip_log("ldap $serveur injoignable");
218
+    if (!$ldap = spip_connect_ldap($serveur)) {
219
+        spip_log("ldap $serveur injoignable");
220 220
 
221
-		return [];
222
-	}
221
+        return [];
222
+    }
223 223
 
224
-	$ldap_link = $ldap['link'];
225
-	if (!$desc) {
226
-		$desc = $ldap['attributes'] ?: $GLOBALS['ldap_attributes'];
227
-		unset($desc['login']);
228
-	}
229
-	$result = @ldap_read($ldap_link, $dn, 'objectClass=*', array_values($desc));
224
+    $ldap_link = $ldap['link'];
225
+    if (!$desc) {
226
+        $desc = $ldap['attributes'] ?: $GLOBALS['ldap_attributes'];
227
+        unset($desc['login']);
228
+    }
229
+    $result = @ldap_read($ldap_link, $dn, 'objectClass=*', array_values($desc));
230 230
 
231
-	if (!$result) {
232
-		return [];
233
-	}
231
+    if (!$result) {
232
+        return [];
233
+    }
234 234
 
235
-	// Recuperer les donnees du premier (unique?) compte de l'auteur
236
-	$val = @ldap_get_entries($ldap_link, $result);
237
-	if (!is_array($val) or !is_array($val[0])) {
238
-		return [];
239
-	}
240
-	$val = $val[0];
235
+    // Recuperer les donnees du premier (unique?) compte de l'auteur
236
+    $val = @ldap_get_entries($ldap_link, $result);
237
+    if (!is_array($val) or !is_array($val[0])) {
238
+        return [];
239
+    }
240
+    $val = $val[0];
241 241
 
242
-	// Convertir depuis UTF-8 (jeu de caracteres par defaut)
243
-	include_spip('inc/charsets');
242
+    // Convertir depuis UTF-8 (jeu de caracteres par defaut)
243
+    include_spip('inc/charsets');
244 244
 
245
-	foreach ($desc as $k => $v) {
246
-		$desc[$k] = importer_charset($val[strtolower($v)][0], 'utf-8');
247
-	}
245
+    foreach ($desc as $k => $v) {
246
+        $desc[$k] = importer_charset($val[strtolower($v)][0], 'utf-8');
247
+    }
248 248
 
249
-	return $desc;
249
+    return $desc;
250 250
 }
251 251
 
252 252
 
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
  * @return string
259 259
  */
260 260
 function auth_ldap_retrouver_login($login, $serveur = '') {
261
-	return auth_ldap_search($login, '', false, $serveur) ? $login : '';
261
+    return auth_ldap_search($login, '', false, $serveur) ? $login : '';
262 262
 }
263 263
 
264 264
 /**
@@ -278,9 +278,9 @@  discard block
 block discarded – undo
278 278
  *   Message d'erreur si login non valide, chaîne vide sinon
279 279
  */
280 280
 function auth_ldap_verifier_pass($login, $new_pass, $id_auteur = 0, $serveur = '') {
281
-	include_spip('auth/spip');
281
+    include_spip('auth/spip');
282 282
 
283
-	return auth_spip_verifier_pass($login, $new_pass, $id_auteur, $serveur);
283
+    return auth_spip_verifier_pass($login, $new_pass, $id_auteur, $serveur);
284 284
 }
285 285
 
286 286
 /**
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
  *   ```
302 302
  */
303 303
 function auth_ldap_autoriser_modifier_pass($serveur = '') {
304
-	return true;
304
+    return true;
305 305
 }
306 306
 
307 307
 /**
@@ -319,23 +319,23 @@  discard block
 block discarded – undo
319 319
  *    Informe du succès ou de l'echec du changement du mot de passe
320 320
  */
321 321
 function auth_ldap_modifier_pass($login, $new_pass, $id_auteur, $serveur = '') {
322
-	if (is_null($new_pass) or auth_ldap_verifier_pass($login, $new_pass, $id_auteur, $serveur) != '') {
323
-		return false;
324
-	}
325
-	if (!$ldap = auth_ldap_connect($serveur)) {
326
-		return '';
327
-	}
328
-	$link = $ldap['link'];
329
-	include_spip('inc/session');
330
-	$dn = session_get('ldap_dn');
331
-	if ('' == $dn) {
332
-		return false;
333
-	}
334
-	if (!ldap_bind($link, $dn, session_get('ldap_password'))) {
335
-		return false;
336
-	}
337
-	$encoded_pass = '{MD5}' . base64_encode(pack('H*', md5($new_pass)));
338
-	$success = ldap_mod_replace($link, $dn, ['userPassword' => $encoded_pass]);
339
-
340
-	return $success;
322
+    if (is_null($new_pass) or auth_ldap_verifier_pass($login, $new_pass, $id_auteur, $serveur) != '') {
323
+        return false;
324
+    }
325
+    if (!$ldap = auth_ldap_connect($serveur)) {
326
+        return '';
327
+    }
328
+    $link = $ldap['link'];
329
+    include_spip('inc/session');
330
+    $dn = session_get('ldap_dn');
331
+    if ('' == $dn) {
332
+        return false;
333
+    }
334
+    if (!ldap_bind($link, $dn, session_get('ldap_password'))) {
335
+        return false;
336
+    }
337
+    $encoded_pass = '{MD5}' . base64_encode(pack('H*', md5($new_pass)));
338
+    $success = ldap_mod_replace($link, $dn, ['userPassword' => $encoded_pass]);
339
+
340
+    return $success;
341 341
 }
Please login to merge, or discard this patch.
ecrire/exec/base_repair.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
  */
24 24
 
25 25
 if (!defined('_ECRIRE_INC_VERSION')) {
26
-	return;
26
+    return;
27 27
 }
28 28
 
29 29
 
@@ -31,25 +31,25 @@  discard block
 block discarded – undo
31 31
  * Réparer la base de données
32 32
  */
33 33
 function exec_base_repair_dist() {
34
-	$action = null;
35
-	$ok = false;
36
-	if (!spip_connect()) {
37
-		$message = _T('titre_probleme_technique');
38
-	} else {
39
-		$version_sql = sql_version();
40
-		if (!$version_sql) {
41
-			$message = _T('avis_erreur_connexion_mysql');
42
-		} else {
43
-			$message = _T('texte_requetes_echouent');
44
-			$ok = true;
45
-		}
46
-		$action = _T('texte_tenter_reparation');
47
-	}
48
-	if ($ok) {
49
-		$admin = charger_fonction('admin', 'inc');
50
-		echo $admin('repair', $action, $message, true);
51
-	} else {
52
-		include_spip('inc/minipres');
53
-		echo minipres(_T('titre_reparation'), "<p>$message</p>");
54
-	}
34
+    $action = null;
35
+    $ok = false;
36
+    if (!spip_connect()) {
37
+        $message = _T('titre_probleme_technique');
38
+    } else {
39
+        $version_sql = sql_version();
40
+        if (!$version_sql) {
41
+            $message = _T('avis_erreur_connexion_mysql');
42
+        } else {
43
+            $message = _T('texte_requetes_echouent');
44
+            $ok = true;
45
+        }
46
+        $action = _T('texte_tenter_reparation');
47
+    }
48
+    if ($ok) {
49
+        $admin = charger_fonction('admin', 'inc');
50
+        echo $admin('repair', $action, $message, true);
51
+    } else {
52
+        include_spip('inc/minipres');
53
+        echo minipres(_T('titre_reparation'), "<p>$message</p>");
54
+    }
55 55
 }
Please login to merge, or discard this patch.
ecrire/exec/admin_plugin.php 1 patch
Indentation   +203 added lines, -203 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  */
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 include_spip('inc/config');
@@ -37,26 +37,26 @@  discard block
 block discarded – undo
37 37
  */
38 38
 function exec_admin_plugin_dist($retour = '') {
39 39
 
40
-	if (!autoriser('configurer', '_plugins')) {
41
-		include_spip('inc/minipres');
42
-		echo minipres();
43
-	} else {
44
-		// on fait la verif du path avant tout,
45
-		// et l'installation des qu'on est dans la colonne principale
46
-		// si jamais la liste des plugins actifs change, il faut faire un refresh du hit
47
-		// pour etre sur que les bons fichiers seront charges lors de l'install
48
-		$new = actualise_plugins_actifs();
49
-		if ($new and _request('actualise') < 2) {
50
-			include_spip('inc/headers');
51
-			if (isset($GLOBALS['fichier_php_compile_recent'])) {
52
-				// attendre eventuellement l'invalidation du cache opcode
53
-				spip_attend_invalidation_opcode_cache($GLOBALS['fichier_php_compile_recent']);
54
-			}
55
-			redirige_par_entete(parametre_url(self(), 'actualise', _request('actualise') + 1, '&'));
56
-		} else {
57
-			admin_plug_args(_request('voir'), _request('erreur'), _request('format'));
58
-		}
59
-	}
40
+    if (!autoriser('configurer', '_plugins')) {
41
+        include_spip('inc/minipres');
42
+        echo minipres();
43
+    } else {
44
+        // on fait la verif du path avant tout,
45
+        // et l'installation des qu'on est dans la colonne principale
46
+        // si jamais la liste des plugins actifs change, il faut faire un refresh du hit
47
+        // pour etre sur que les bons fichiers seront charges lors de l'install
48
+        $new = actualise_plugins_actifs();
49
+        if ($new and _request('actualise') < 2) {
50
+            include_spip('inc/headers');
51
+            if (isset($GLOBALS['fichier_php_compile_recent'])) {
52
+                // attendre eventuellement l'invalidation du cache opcode
53
+                spip_attend_invalidation_opcode_cache($GLOBALS['fichier_php_compile_recent']);
54
+            }
55
+            redirige_par_entete(parametre_url(self(), 'actualise', _request('actualise') + 1, '&'));
56
+        } else {
57
+            admin_plug_args(_request('voir'), _request('erreur'), _request('format'));
58
+        }
59
+    }
60 60
 }
61 61
 
62 62
 /**
@@ -81,132 +81,132 @@  discard block
 block discarded – undo
81 81
  *     Format d'affichage (liste ou arborescence)
82 82
  **/
83 83
 function admin_plug_args($quoi, $erreur, $format) {
84
-	$lpf = null;
85
-	$lcpas = null;
86
-	$lcpaffichesup = null;
87
-	if (!$quoi) {
88
-		$quoi = 'actifs';
89
-	}
90
-	// empecher l'affichage des erreurs dans le bandeau, on le donne ensuite
91
-	// format brut par plugin
92
-	$GLOBALS['erreurs_activation_raw'] = plugin_donne_erreurs(true, false);
93
-	// format resume mis en forme
94
-	$erreur_activation = plugin_donne_erreurs();
95
-	$commencer_page = charger_fonction('commencer_page', 'inc');
96
-	echo $commencer_page(_T('icone_admin_plugin'), 'configuration', 'plugin');
97
-
98
-	echo debut_gauche();
99
-	echo recuperer_fond('prive/squelettes/navigation/configurer', ['exec' => 'admin_plugin']);
100
-
101
-	echo pipeline(
102
-		'affiche_gauche',
103
-		[
104
-			'args' => ['exec' => 'admin_plugin'],
105
-			'data' => afficher_librairies()
106
-		]
107
-	);
108
-
109
-	echo debut_droite();
110
-	echo gros_titre(_T('icone_admin_plugin'), '');
111
-
112
-	// Barre d'onglets de premier niveau
113
-	echo barre_onglets('plugins', 'plugins_actifs');
114
-	// Barre d'onglets de second niveau
115
-	$onglet2 = $quoi == 'actifs' ? 'plugins_actifs' : 'admin_plugin';
116
-	echo debut_onglet('onglets_simple second');
117
-	echo onglet(_T('plugins_tous_liste'), generer_url_ecrire('admin_plugin', 'voir=tous'), 'admin_plugin', $onglet2);
118
-	echo onglet(_T('plugins_actifs_liste'), generer_url_ecrire('admin_plugin'), 'plugins_actifs', $onglet2);
119
-	echo fin_onglet();
120
-
121
-	// message d'erreur au retour d'une operation
122
-	if ($erreur) {
123
-		echo "<div class='error'>$erreur</div>";
124
-	}
125
-	if ($erreur_activation) {
126
-		echo "<div class='error'>$erreur_activation</div>";
127
-	}
128
-
129
-	// la mise a jour de cette meta a ete faite par ecrire_plugin_actifs
130
-	$actifs = unserialize($GLOBALS['meta']['plugin']);
131
-	$lcpa = $actifs + unserialize($GLOBALS['meta']['plugin_attente']);
132
-
133
-	// Les affichages se basent sur le repertoire, pas sur le nom
134
-	$actifs = liste_chemin_plugin($actifs, '');
135
-	if (defined('_DIR_PLUGINS_SUPPL')) {
136
-		$lcpas = liste_chemin_plugin($lcpa, _DIR_PLUGINS_SUPPL);
137
-	}
138
-	$lcpa = liste_chemin_plugin($lcpa);
139
-
140
-	// on installe les plugins maintenant,
141
-	// cela permet aux scripts d'install de faire des affichages (moches...)
142
-	plugin_installes_meta();
143
-
144
-	echo "<div class='liste-plugins formulaire_spip'>";
145
-	echo debut_cadre_trait_couleur('plugin-24.png', true, '', _T('plugins_liste'), 'plugins');
146
-
147
-	if ($quoi !== 'actifs') {
148
-		$lpf = liste_plugin_files();
149
-		if ($lpf) {
150
-			echo '<p>' . _T('texte_presente_plugin') . '</p>';
151
-		} else {
152
-			if (!@is_dir(_DIR_PLUGINS)) {
153
-				echo '<p>' . _T('plugin_info_automatique_ftp', ['rep' => joli_repertoire(_DIR_PLUGINS)])
154
-					. ' &mdash; ' . _T('plugin_info_automatique_creer') . '</p>';
155
-			}
156
-		}
157
-		$lcpaffiche = $lpf;
158
-		if (defined('_DIR_PLUGINS_SUPPL')) {
159
-			$lcpaffichesup = liste_plugin_files(_DIR_PLUGINS_SUPPL);
160
-		}
161
-	} else {
162
-		// la liste
163
-		// $quoi=='actifs'
164
-		$lcpaffiche = $lcpa;
165
-		if (defined('_DIR_PLUGINS_SUPPL')) {
166
-			$lcpaffichesup = $lcpas;
167
-		}
168
-	}
169
-
170
-	if ($quoi == 'actifs' or $lpf) {
171
-		$nb = is_countable($lcpa) ? count($lcpa) : 0;
172
-		if (defined('_DIR_PLUGINS_SUPPL')) {
173
-			$nb += is_countable($lcpas) ? count($lcpas) : 0;
174
-		}
175
-		echo '<h3>' . sinon(
176
-			singulier_ou_pluriel($nb, 'plugins_actif_un', 'plugins_actifs', 'count'),
177
-			_T('plugins_actif_aucun')
178
-		) . '</h3>';
179
-	}
180
-
181
-	if (empty($format)) {
182
-		$format = 'liste';
183
-	} elseif (!in_array($format, ['liste', 'repertoires'])) {
184
-		$format = 'repertoires';
185
-	}
186
-
187
-	$afficher = charger_fonction("afficher_$format", 'plugins');
188
-	$corps = $afficher(self(), $lcpaffiche, $lcpa, $actifs);
189
-	if (defined('_DIR_PLUGINS_SUPPL')) {
190
-		$corps .= $afficher(self(), $lcpaffichesup, $lcpas, $actifs, _DIR_PLUGINS_SUPPL);
191
-	}
192
-
193
-	if ($corps) {
194
-		$corps .= "\n<div class='boutons' style='display:none;'>"
195
-			. "<input type='submit' class='submit save' value='" . _T('bouton_enregistrer')
196
-			. "' />"
197
-			. '</div>';
198
-	}
199
-
200
-	echo redirige_action_post('activer_plugins', 'activer', 'admin_plugin', '', $corps);
201
-
202
-	echo fin_cadre_trait_couleur();
203
-
204
-	if ($quoi == 'actifs') {
205
-		echo affiche_les_plugins_verrouilles($actifs);
206
-	}
207
-	echo '</div>';
208
-
209
-	echo http_script("
84
+    $lpf = null;
85
+    $lcpas = null;
86
+    $lcpaffichesup = null;
87
+    if (!$quoi) {
88
+        $quoi = 'actifs';
89
+    }
90
+    // empecher l'affichage des erreurs dans le bandeau, on le donne ensuite
91
+    // format brut par plugin
92
+    $GLOBALS['erreurs_activation_raw'] = plugin_donne_erreurs(true, false);
93
+    // format resume mis en forme
94
+    $erreur_activation = plugin_donne_erreurs();
95
+    $commencer_page = charger_fonction('commencer_page', 'inc');
96
+    echo $commencer_page(_T('icone_admin_plugin'), 'configuration', 'plugin');
97
+
98
+    echo debut_gauche();
99
+    echo recuperer_fond('prive/squelettes/navigation/configurer', ['exec' => 'admin_plugin']);
100
+
101
+    echo pipeline(
102
+        'affiche_gauche',
103
+        [
104
+            'args' => ['exec' => 'admin_plugin'],
105
+            'data' => afficher_librairies()
106
+        ]
107
+    );
108
+
109
+    echo debut_droite();
110
+    echo gros_titre(_T('icone_admin_plugin'), '');
111
+
112
+    // Barre d'onglets de premier niveau
113
+    echo barre_onglets('plugins', 'plugins_actifs');
114
+    // Barre d'onglets de second niveau
115
+    $onglet2 = $quoi == 'actifs' ? 'plugins_actifs' : 'admin_plugin';
116
+    echo debut_onglet('onglets_simple second');
117
+    echo onglet(_T('plugins_tous_liste'), generer_url_ecrire('admin_plugin', 'voir=tous'), 'admin_plugin', $onglet2);
118
+    echo onglet(_T('plugins_actifs_liste'), generer_url_ecrire('admin_plugin'), 'plugins_actifs', $onglet2);
119
+    echo fin_onglet();
120
+
121
+    // message d'erreur au retour d'une operation
122
+    if ($erreur) {
123
+        echo "<div class='error'>$erreur</div>";
124
+    }
125
+    if ($erreur_activation) {
126
+        echo "<div class='error'>$erreur_activation</div>";
127
+    }
128
+
129
+    // la mise a jour de cette meta a ete faite par ecrire_plugin_actifs
130
+    $actifs = unserialize($GLOBALS['meta']['plugin']);
131
+    $lcpa = $actifs + unserialize($GLOBALS['meta']['plugin_attente']);
132
+
133
+    // Les affichages se basent sur le repertoire, pas sur le nom
134
+    $actifs = liste_chemin_plugin($actifs, '');
135
+    if (defined('_DIR_PLUGINS_SUPPL')) {
136
+        $lcpas = liste_chemin_plugin($lcpa, _DIR_PLUGINS_SUPPL);
137
+    }
138
+    $lcpa = liste_chemin_plugin($lcpa);
139
+
140
+    // on installe les plugins maintenant,
141
+    // cela permet aux scripts d'install de faire des affichages (moches...)
142
+    plugin_installes_meta();
143
+
144
+    echo "<div class='liste-plugins formulaire_spip'>";
145
+    echo debut_cadre_trait_couleur('plugin-24.png', true, '', _T('plugins_liste'), 'plugins');
146
+
147
+    if ($quoi !== 'actifs') {
148
+        $lpf = liste_plugin_files();
149
+        if ($lpf) {
150
+            echo '<p>' . _T('texte_presente_plugin') . '</p>';
151
+        } else {
152
+            if (!@is_dir(_DIR_PLUGINS)) {
153
+                echo '<p>' . _T('plugin_info_automatique_ftp', ['rep' => joli_repertoire(_DIR_PLUGINS)])
154
+                    . ' &mdash; ' . _T('plugin_info_automatique_creer') . '</p>';
155
+            }
156
+        }
157
+        $lcpaffiche = $lpf;
158
+        if (defined('_DIR_PLUGINS_SUPPL')) {
159
+            $lcpaffichesup = liste_plugin_files(_DIR_PLUGINS_SUPPL);
160
+        }
161
+    } else {
162
+        // la liste
163
+        // $quoi=='actifs'
164
+        $lcpaffiche = $lcpa;
165
+        if (defined('_DIR_PLUGINS_SUPPL')) {
166
+            $lcpaffichesup = $lcpas;
167
+        }
168
+    }
169
+
170
+    if ($quoi == 'actifs' or $lpf) {
171
+        $nb = is_countable($lcpa) ? count($lcpa) : 0;
172
+        if (defined('_DIR_PLUGINS_SUPPL')) {
173
+            $nb += is_countable($lcpas) ? count($lcpas) : 0;
174
+        }
175
+        echo '<h3>' . sinon(
176
+            singulier_ou_pluriel($nb, 'plugins_actif_un', 'plugins_actifs', 'count'),
177
+            _T('plugins_actif_aucun')
178
+        ) . '</h3>';
179
+    }
180
+
181
+    if (empty($format)) {
182
+        $format = 'liste';
183
+    } elseif (!in_array($format, ['liste', 'repertoires'])) {
184
+        $format = 'repertoires';
185
+    }
186
+
187
+    $afficher = charger_fonction("afficher_$format", 'plugins');
188
+    $corps = $afficher(self(), $lcpaffiche, $lcpa, $actifs);
189
+    if (defined('_DIR_PLUGINS_SUPPL')) {
190
+        $corps .= $afficher(self(), $lcpaffichesup, $lcpas, $actifs, _DIR_PLUGINS_SUPPL);
191
+    }
192
+
193
+    if ($corps) {
194
+        $corps .= "\n<div class='boutons' style='display:none;'>"
195
+            . "<input type='submit' class='submit save' value='" . _T('bouton_enregistrer')
196
+            . "' />"
197
+            . '</div>';
198
+    }
199
+
200
+    echo redirige_action_post('activer_plugins', 'activer', 'admin_plugin', '', $corps);
201
+
202
+    echo fin_cadre_trait_couleur();
203
+
204
+    if ($quoi == 'actifs') {
205
+        echo affiche_les_plugins_verrouilles($actifs);
206
+    }
207
+    echo '</div>';
208
+
209
+    echo http_script("
210 210
 	jQuery(function(){
211 211
 		jQuery('.plugins li.item a[rel=info]').click(function(){
212 212
 			var li = jQuery(this).parents('li').eq(0);
@@ -232,15 +232,15 @@  discard block
 block discarded – undo
232 232
 	});
233 233
 	");
234 234
 
235
-	echo pipeline(
236
-		'affiche_milieu',
237
-		[
238
-			'args' => ['exec' => 'admin_plugin'],
239
-			'data' => ''
240
-		]
241
-	);
235
+    echo pipeline(
236
+        'affiche_milieu',
237
+        [
238
+            'args' => ['exec' => 'admin_plugin'],
239
+            'data' => ''
240
+        ]
241
+    );
242 242
 
243
-	echo fin_gauche(), fin_page();
243
+    echo fin_gauche(), fin_page();
244 244
 }
245 245
 
246 246
 /**
@@ -254,23 +254,23 @@  discard block
 block discarded – undo
254 254
  *     Code HTML
255 255
  **/
256 256
 function affiche_les_plugins_verrouilles($actifs) {
257
-	if ((!$liste = liste_plugin_files(_DIR_PLUGINS_DIST))) {
258
-		return '';
259
-	}
260
-
261
-	$afficher = charger_fonction('afficher_liste', 'plugins');
262
-	$liste = $afficher(self(), $liste, [], $actifs, _DIR_PLUGINS_DIST);
263
-
264
-	return
265
-		"<div id='plugins_dist'>"
266
-		. debut_cadre_trait_couleur('', true, '', _T('plugins_liste_dist'), 'liste_plugins_dist')
267
-		. '<p>'
268
-		. _T('plugin_info_plugins_dist_1', ['plugins_dist' => joli_repertoire(_DIR_PLUGINS_DIST)])
269
-		. '<br />' . _T('plugin_info_plugins_dist_2')
270
-		. '</p>'
271
-		. $liste
272
-		. fin_cadre_trait_couleur()
273
-		. "</div>\n";
257
+    if ((!$liste = liste_plugin_files(_DIR_PLUGINS_DIST))) {
258
+        return '';
259
+    }
260
+
261
+    $afficher = charger_fonction('afficher_liste', 'plugins');
262
+    $liste = $afficher(self(), $liste, [], $actifs, _DIR_PLUGINS_DIST);
263
+
264
+    return
265
+        "<div id='plugins_dist'>"
266
+        . debut_cadre_trait_couleur('', true, '', _T('plugins_liste_dist'), 'liste_plugins_dist')
267
+        . '<p>'
268
+        . _T('plugin_info_plugins_dist_1', ['plugins_dist' => joli_repertoire(_DIR_PLUGINS_DIST)])
269
+        . '<br />' . _T('plugin_info_plugins_dist_2')
270
+        . '</p>'
271
+        . $liste
272
+        . fin_cadre_trait_couleur()
273
+        . "</div>\n";
274 274
 }
275 275
 
276 276
 /**
@@ -282,19 +282,19 @@  discard block
 block discarded – undo
282 282
  */
283 283
 function afficher_librairies() {
284 284
 
285
-	if (!$libs = liste_librairies()) {
286
-		return '';
287
-	}
288
-	ksort($libs);
289
-	$res = debut_cadre_enfonce('', true, '', _T('plugin_librairies_installees'));
290
-	$res .= '<dl>';
291
-	foreach ($libs as $lib => $rep) {
292
-		$res .= "<dt>$lib</dt><dd>" . joli_repertoire($rep) . "</dd>\n";
293
-	}
294
-	$res .= '</dl>';
295
-	$res .= fin_cadre_enfonce();
296
-
297
-	return $res;
285
+    if (!$libs = liste_librairies()) {
286
+        return '';
287
+    }
288
+    ksort($libs);
289
+    $res = debut_cadre_enfonce('', true, '', _T('plugin_librairies_installees'));
290
+    $res .= '<dl>';
291
+    foreach ($libs as $lib => $rep) {
292
+        $res .= "<dt>$lib</dt><dd>" . joli_repertoire($rep) . "</dd>\n";
293
+    }
294
+    $res .= '</dl>';
295
+    $res .= fin_cadre_enfonce();
296
+
297
+    return $res;
298 298
 }
299 299
 
300 300
 
@@ -305,22 +305,22 @@  discard block
 block discarded – undo
305 305
  *     Tableau (nom de la lib => repertoire , ...)
306 306
  */
307 307
 function liste_librairies() {
308
-	$libs = [];
309
-	foreach (array_reverse(creer_chemin()) as $d) {
310
-		if (
311
-			is_dir($dir = $d . 'lib/')
312
-			and $t = opendir($dir)
313
-		) {
314
-			while (($f = readdir($t)) !== false) {
315
-				if (
316
-					$f[0] != '.'
317
-					and is_dir("$dir/$f")
318
-				) {
319
-					$libs[$f] = $dir;
320
-				}
321
-			}
322
-		}
323
-	}
324
-
325
-	return $libs;
308
+    $libs = [];
309
+    foreach (array_reverse(creer_chemin()) as $d) {
310
+        if (
311
+            is_dir($dir = $d . 'lib/')
312
+            and $t = opendir($dir)
313
+        ) {
314
+            while (($f = readdir($t)) !== false) {
315
+                if (
316
+                    $f[0] != '.'
317
+                    and is_dir("$dir/$f")
318
+                ) {
319
+                    $libs[$f] = $dir;
320
+                }
321
+            }
322
+        }
323
+    }
324
+
325
+    return $libs;
326 326
 }
Please login to merge, or discard this patch.
ecrire/exec/demande_mise_a_jour.php 1 patch
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
  */
21 21
 
22 22
 if (!defined('_ECRIRE_INC_VERSION')) {
23
-	return;
23
+    return;
24 24
 }
25 25
 
26 26
 
@@ -28,29 +28,29 @@  discard block
 block discarded – undo
28 28
  * Demander à mettre à jour la base de données
29 29
  */
30 30
 function exec_demande_mise_a_jour_dist() {
31
-	// on fait la verif du path avant tout,
32
-	// et l'installation des qu'on est dans la colonne principale
33
-	// si jamais la liste des plugins actifs change, il faut faire un refresh du hit
34
-	// pour etre sur que les bons fichiers seront charges lors de l'install
35
-	include_spip('inc/plugin');
36
-	if (actualise_plugins_actifs()) {
37
-		include_spip('inc/headers');
38
-		redirige_par_entete(self());
39
-	}
31
+    // on fait la verif du path avant tout,
32
+    // et l'installation des qu'on est dans la colonne principale
33
+    // si jamais la liste des plugins actifs change, il faut faire un refresh du hit
34
+    // pour etre sur que les bons fichiers seront charges lors de l'install
35
+    include_spip('inc/plugin');
36
+    if (actualise_plugins_actifs()) {
37
+        include_spip('inc/headers');
38
+        redirige_par_entete(self());
39
+    }
40 40
 
41
-	include_spip('inc/presentation');
42
-	include_spip('inc/filtres_boites');
43
-	$commencer_page = charger_fonction('commencer_page', 'inc');
44
-	echo $commencer_page('', '', '', '', true, false, false);
41
+    include_spip('inc/presentation');
42
+    include_spip('inc/filtres_boites');
43
+    $commencer_page = charger_fonction('commencer_page', 'inc');
44
+    echo $commencer_page('', '', '', '', true, false, false);
45 45
 
46
-	echo debut_grand_cadre();
47
-	echo boite_ouvrir(_T('info_message_technique'), 'notice');
48
-	echo '<p>' . _T('info_procedure_maj_version') . '</p>',
49
-		'<p>' . _T('info_administrateur_site_01') . '</p>';
50
-	echo bouton_action(_T('bouton_mettre_a_jour_base'), generer_url_ecrire('upgrade', 'reinstall=non'));
51
-	echo boite_fermer();
52
-	// masquer les erreurs sql sur cette page car proviennent de la base pas a jour !
53
-	echo '<style type="text/css">#debug-nav {display: none;}</style>';
54
-	echo fin_grand_cadre();
55
-	echo fin_page();
46
+    echo debut_grand_cadre();
47
+    echo boite_ouvrir(_T('info_message_technique'), 'notice');
48
+    echo '<p>' . _T('info_procedure_maj_version') . '</p>',
49
+        '<p>' . _T('info_administrateur_site_01') . '</p>';
50
+    echo bouton_action(_T('bouton_mettre_a_jour_base'), generer_url_ecrire('upgrade', 'reinstall=non'));
51
+    echo boite_fermer();
52
+    // masquer les erreurs sql sur cette page car proviennent de la base pas a jour !
53
+    echo '<style type="text/css">#debug-nav {display: none;}</style>';
54
+    echo fin_grand_cadre();
55
+    echo fin_page();
56 56
 }
Please login to merge, or discard this patch.
ecrire/exec/404.php 1 patch
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  */
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 /**
@@ -25,25 +25,25 @@  discard block
 block discarded – undo
25 25
  */
26 26
 function exec_404_dist() {
27 27
 
28
-	$exec = _request('exec');
28
+    $exec = _request('exec');
29 29
 
30
-	$titre = "exec_$exec";
31
-	$navigation = '';
32
-	$extra = '';
30
+    $titre = "exec_$exec";
31
+    $navigation = '';
32
+    $extra = '';
33 33
 
34
-	include_spip('inc/presentation'); // alleger les inclusions avec un inc/presentation_mini
35
-	$commencer_page = charger_fonction('commencer_page', 'inc');
36
-	echo $commencer_page($titre);
34
+    include_spip('inc/presentation'); // alleger les inclusions avec un inc/presentation_mini
35
+    $commencer_page = charger_fonction('commencer_page', 'inc');
36
+    echo $commencer_page($titre);
37 37
 
38
-	echo debut_gauche();
39
-	echo pipeline('affiche_gauche', ['args' => ['exec' => '404', 'exec_erreur' => $exec], 'data' => '']);
38
+    echo debut_gauche();
39
+    echo pipeline('affiche_gauche', ['args' => ['exec' => '404', 'exec_erreur' => $exec], 'data' => '']);
40 40
 
41
-	echo creer_colonne_droite();
42
-	echo pipeline('affiche_droite', ['args' => ['exec' => '404', 'exec_erreur' => $exec], 'data' => '']);
41
+    echo creer_colonne_droite();
42
+    echo pipeline('affiche_droite', ['args' => ['exec' => '404', 'exec_erreur' => $exec], 'data' => '']);
43 43
 
44
-	echo debut_droite();
45
-	echo "<h1 class='grostitre'>" . _T('fichier_introuvable', ['fichier' => $exec]) . '</h1>';
46
-	echo pipeline('affiche_milieu', ['args' => ['exec' => '404', 'exec_erreur' => $exec], 'data' => '']);
44
+    echo debut_droite();
45
+    echo "<h1 class='grostitre'>" . _T('fichier_introuvable', ['fichier' => $exec]) . '</h1>';
46
+    echo pipeline('affiche_milieu', ['args' => ['exec' => '404', 'exec_erreur' => $exec], 'data' => '']);
47 47
 
48
-	echo fin_gauche(), fin_page();
48
+    echo fin_gauche(), fin_page();
49 49
 }
Please login to merge, or discard this patch.
ecrire/exec/403.php 1 patch
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  */
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 /**
@@ -27,40 +27,40 @@  discard block
 block discarded – undo
27 27
  */
28 28
 function exec_403_dist($message = '') {
29 29
 
30
-	$exec = _request('exec');
30
+    $exec = _request('exec');
31 31
 
32
-	$titre = "exec_$exec";
33
-	$navigation = '';
34
-	$extra = '';
32
+    $titre = "exec_$exec";
33
+    $navigation = '';
34
+    $extra = '';
35 35
 
36
-	if (!$message) {
37
-		$message = _T('avis_acces_interdit_prive', ['exec' => _request('exec')]);
38
-	}
36
+    if (!$message) {
37
+        $message = _T('avis_acces_interdit_prive', ['exec' => _request('exec')]);
38
+    }
39 39
 
40
-	$contenu = "<h1 class='grostitre'>" . _T('info_acces_interdit') . '</h1>' . $message;
40
+    $contenu = "<h1 class='grostitre'>" . _T('info_acces_interdit') . '</h1>' . $message;
41 41
 
42
-	if (_request('var_zajax')) {
43
-		include_spip('inc/actions');
44
-		ajax_retour($contenu);
45
-	} else {
46
-		include_spip('inc/presentation'); // alleger les inclusions avec un inc/presentation_mini
42
+    if (_request('var_zajax')) {
43
+        include_spip('inc/actions');
44
+        ajax_retour($contenu);
45
+    } else {
46
+        include_spip('inc/presentation'); // alleger les inclusions avec un inc/presentation_mini
47 47
 
48
-		$commencer_page = charger_fonction('commencer_page', 'inc');
49
-		echo $commencer_page($titre);
48
+        $commencer_page = charger_fonction('commencer_page', 'inc');
49
+        echo $commencer_page($titre);
50 50
 
51
-		echo debut_gauche();
52
-		echo recuperer_fond('prive/squelettes/navigation/dist', []);
53
-		echo pipeline('affiche_gauche', ['args' => ['exec' => '403', 'exec_erreur' => $exec], 'data' => '']);
51
+        echo debut_gauche();
52
+        echo recuperer_fond('prive/squelettes/navigation/dist', []);
53
+        echo pipeline('affiche_gauche', ['args' => ['exec' => '403', 'exec_erreur' => $exec], 'data' => '']);
54 54
 
55
-		echo creer_colonne_droite();
56
-		echo pipeline('affiche_droite', ['args' => ['exec' => '403', 'exec_erreur' => $exec], 'data' => '']);
55
+        echo creer_colonne_droite();
56
+        echo pipeline('affiche_droite', ['args' => ['exec' => '403', 'exec_erreur' => $exec], 'data' => '']);
57 57
 
58
-		echo debut_droite();
59
-		echo pipeline(
60
-			'affiche_milieu',
61
-			['args' => ['exec' => '403', 'exec_erreur' => $exec], 'data' => $contenu]
62
-		);
58
+        echo debut_droite();
59
+        echo pipeline(
60
+            'affiche_milieu',
61
+            ['args' => ['exec' => '403', 'exec_erreur' => $exec], 'data' => $contenu]
62
+        );
63 63
 
64
-		echo fin_gauche(), fin_page();
65
-	}
64
+        echo fin_gauche(), fin_page();
65
+    }
66 66
 }
Please login to merge, or discard this patch.
ecrire/inc/nfslock.php 1 patch
Indentation   +92 added lines, -92 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  **/
8 8
 
9 9
 if (!defined('_ECRIRE_INC_VERSION')) {
10
-	return;
10
+    return;
11 11
 }
12 12
 
13 13
 include_spip('inc/acces');
@@ -101,93 +101,93 @@  discard block
 block discarded – undo
101 101
  * @return int|bool Timestamp du verrou, false si erreur
102 102
  */
103 103
 function spip_nfslock($fichier, $max_age = 0) {
104
-	$tries = 0;
104
+    $tries = 0;
105 105
 
106
-	if (!$max_age) {
107
-		$max_age = _DEFAULT_LOCKTIME;
108
-	}
109
-	$lock_file = _DIR_TMP . _NAME_LOCK . '-' . substr(md5($fichier), 0, 8);
106
+    if (!$max_age) {
107
+        $max_age = _DEFAULT_LOCKTIME;
108
+    }
109
+    $lock_file = _DIR_TMP . _NAME_LOCK . '-' . substr(md5($fichier), 0, 8);
110 110
 
111 111
 
112
-	/*
112
+    /*
113 113
 	 * 1. create a tmp file with a psuedo random file name. we also make
114 114
 	 *    tpath which is a buffer to store the full pathname of the tmp file.
115 115
 	 */
116 116
 
117
-	$id = creer_uniqid();
118
-	$tpath = _DIR_TMP . "slock.$id";
119
-	$tmpfd = @fopen($tpath, 'w'); // hum, le 'x' necessite php4,3,2 ...
120
-	if (!$tmpfd) {  /* open failed */
121
-		@fclose($tmpfd);
122
-		spip_unlink($tpath);
117
+    $id = creer_uniqid();
118
+    $tpath = _DIR_TMP . "slock.$id";
119
+    $tmpfd = @fopen($tpath, 'w'); // hum, le 'x' necessite php4,3,2 ...
120
+    if (!$tmpfd) {  /* open failed */
121
+        @fclose($tmpfd);
122
+        spip_unlink($tpath);
123 123
 
124
-		return false; //NFSL_SYSF
125
-	}
124
+        return false; //NFSL_SYSF
125
+    }
126 126
 
127
-	/*
127
+    /*
128 128
 	 * 2. make fullpath, a buffer for the full pathname of the lock file.
129 129
 	 *    then start looping trying to lock it
130 130
 	 */
131 131
 
132
-	while ($tries < 10) {
133
-		/*
132
+    while ($tries < 10) {
133
+        /*
134 134
 		 * 3. link tmp file to lock file.  if it goes, we win and we clean
135 135
 		 *    up and return the st_ctime of the lock file.
136 136
 		 */
137 137
 
138
-		if (link($tpath, $lock_file) == 1) {
139
-			spip_unlink($tpath); /* got it! */
140
-			@fclose($tmpfd);
141
-			if (($our_tmp = lstat($lock_file)) == false) {  /* stat failed... shouldn't happen */
142
-				spip_unlink($lock_file);
138
+        if (link($tpath, $lock_file) == 1) {
139
+            spip_unlink($tpath); /* got it! */
140
+            @fclose($tmpfd);
141
+            if (($our_tmp = lstat($lock_file)) == false) {  /* stat failed... shouldn't happen */
142
+                spip_unlink($lock_file);
143 143
 
144
-				return false; // (NFSL_SYSF);
145
-			}
144
+                return false; // (NFSL_SYSF);
145
+            }
146 146
 
147
-			return ($our_tmp['ctime']);
148
-		}
147
+            return ($our_tmp['ctime']);
148
+        }
149 149
 
150
-		/*
150
+        /*
151 151
 		 * 4. the lock failed.  check for a stale lock file, being mindful
152 152
 		 *    of NFS and the fact the time is set from the NFS server.  we
153 153
 		 *    do a write on the tmp file to update its time to the server's
154 154
 		 *    idea of "now."
155 155
 		 */
156 156
 
157
-		$old_stat = lstat($lock_file);
158
-		if (@fputs($tmpfd, 'zz', 2) != 2 || !$our_tmp = fstat($tmpfd)) {
159
-			break;
160
-		} /* something bogus is going on */
157
+        $old_stat = lstat($lock_file);
158
+        if (@fputs($tmpfd, 'zz', 2) != 2 || !$our_tmp = fstat($tmpfd)) {
159
+            break;
160
+        } /* something bogus is going on */
161 161
 
162 162
 
163
-		if ($old_stat != false && (($old_stat['ctime'] + $max_age) < $our_tmp['ctime'])) {
164
-			spip_unlink($lock_file); /* break the stale lock */
165
-			$tries++;
166
-			/* It is CRITICAL that we sleep after breaking
163
+        if ($old_stat != false && (($old_stat['ctime'] + $max_age) < $our_tmp['ctime'])) {
164
+            spip_unlink($lock_file); /* break the stale lock */
165
+            $tries++;
166
+            /* It is CRITICAL that we sleep after breaking
167 167
 			 * the lock. Otherwise, we could race with
168 168
 			 * another process and unlink it's newly-
169 169
 			 * created file.
170 170
 			 */
171
-			sleep(1 + random_int(0, 4));
172
-			continue;
173
-		}
171
+            sleep(1 + random_int(0, 4));
172
+            continue;
173
+        }
174 174
 
175
-		/*
175
+        /*
176 176
 		 * 5. try again
177 177
 		 */
178 178
 
179
-		$tries++;
180
-		sleep(1 + random_int(0, 4));
181
-	}
179
+        $tries++;
180
+        sleep(1 + random_int(0, 4));
181
+    }
182 182
 
183
-	/*
183
+    /*
184 184
 	 * 6. give up, failure.
185 185
 	 */
186 186
 
187
-	spip_unlink($tpath);
188
-	@fclose($tmpfd);
187
+    spip_unlink($tpath);
188
+    @fclose($tmpfd);
189 189
 
190
-	return false; //(NFSL_LOCKED);
190
+    return false; //(NFSL_LOCKED);
191 191
 }
192 192
 
193 193
 /**
@@ -231,75 +231,75 @@  discard block
 block discarded – undo
231 231
  * return bool true si déverrouillé, false sinon
232 232
  */
233 233
 function spip_nfsunlock($fichier, $birth, $max_age = 0, $test = false) {
234
-	$id = creer_uniqid();
235
-	if (!$max_age) {
236
-		$max_age = _DEFAULT_LOCKTIME;
237
-	}
234
+    $id = creer_uniqid();
235
+    if (!$max_age) {
236
+        $max_age = _DEFAULT_LOCKTIME;
237
+    }
238 238
 
239
-	/*
239
+    /*
240 240
 	 * 1. Build a temp file and stat that to get an idea of what the server
241 241
 	 *    thinks the current time is (our_tmp.st_ctime)..
242 242
 	 */
243 243
 
244
-	$tpath = _DIR_TMP . "stime.$id";
245
-	$tmpfd = @fopen($tpath, 'w');
246
-	if (
247
-		(!$tmpfd)
248
-		or (@fputs($tmpfd, 'zz', 2) != 2)
249
-		or !($our_tmp = fstat($tmpfd))
250
-	) {
251
-		/* The open failed, or we can't write the file, or we can't stat it */
252
-		@fclose($tmpfd);
253
-		spip_unlink($tpath);
244
+    $tpath = _DIR_TMP . "stime.$id";
245
+    $tmpfd = @fopen($tpath, 'w');
246
+    if (
247
+        (!$tmpfd)
248
+        or (@fputs($tmpfd, 'zz', 2) != 2)
249
+        or !($our_tmp = fstat($tmpfd))
250
+    ) {
251
+        /* The open failed, or we can't write the file, or we can't stat it */
252
+        @fclose($tmpfd);
253
+        spip_unlink($tpath);
254 254
 
255
-		return false; //(NFSL_SYSF);
256
-	}
255
+        return false; //(NFSL_SYSF);
256
+    }
257 257
 
258
-	@fclose($tmpfd);    /* We don't need this once we have our_tmp.st_ctime. */
259
-	spip_unlink($tpath);
258
+    @fclose($tmpfd);    /* We don't need this once we have our_tmp.st_ctime. */
259
+    spip_unlink($tpath);
260 260
 
261
-	/*
261
+    /*
262 262
 	 * 2. make fullpath, a buffer for the full pathname of the lock file
263 263
 	 */
264 264
 
265
-	$lock_file = _DIR_TMP . _NAME_LOCK . '-' . substr(md5($fichier), 0, 8);
265
+    $lock_file = _DIR_TMP . _NAME_LOCK . '-' . substr(md5($fichier), 0, 8);
266 266
 
267
-	/*
267
+    /*
268 268
 	 * 3. If the ctime hasn't been modified, unlink the file and return. If the
269 269
 	 *    lock has expired, sleep the usual random interval before returning.
270 270
 	 *    If we didn't sleep, there could be a race if the caller immediately
271 271
 	 *    tries to relock the file.
272 272
 	 */
273 273
 
274
-	if (
275
-		($old_stat = @lstat($lock_file))  /* stat succeeds so file is there */
276
-		&& ($old_stat['ctime'] == $birth)
277
-	) {  /* hasn't been modified since birth */
278
-		if (!$test) {
279
-			spip_unlink($lock_file);
280
-		}      /* so the lock is ours to remove */
281
-		if ($our_tmp['ctime'] >= $birth + $max_age) {  /* the lock has expired */
282
-			if (!$test) {
283
-				return false;
284
-			} //(NFSL_LOST);
285
-			sleep(1 + (random_int(0, 4)));    /* so sleep a bit */
286
-		}
287
-
288
-		return true;//(NFSL_OK);			/* success */
289
-	}
290
-
291
-	/*
274
+    if (
275
+        ($old_stat = @lstat($lock_file))  /* stat succeeds so file is there */
276
+        && ($old_stat['ctime'] == $birth)
277
+    ) {  /* hasn't been modified since birth */
278
+        if (!$test) {
279
+            spip_unlink($lock_file);
280
+        }      /* so the lock is ours to remove */
281
+        if ($our_tmp['ctime'] >= $birth + $max_age) {  /* the lock has expired */
282
+            if (!$test) {
283
+                return false;
284
+            } //(NFSL_LOST);
285
+            sleep(1 + (random_int(0, 4)));    /* so sleep a bit */
286
+        }
287
+
288
+        return true;//(NFSL_OK);			/* success */
289
+    }
290
+
291
+    /*
292 292
 	 * 4. Either ctime has been modified, or the entire lock file is missing.
293 293
 	 *    If the lock should still be ours, based on the ctime of the temp
294 294
 	 *    file, return with NFSL_STOLEN. If not, then our lock is expired and
295 295
 	 *    someone else has grabbed the file, so return NFSL_LOST.
296 296
 	 */
297 297
 
298
-	if ($our_tmp['ctime'] < $birth + $max_age) { /* lock was stolen */
299
-		return false;
300
-	} //(NFSL_STOLEN);
298
+    if ($our_tmp['ctime'] < $birth + $max_age) { /* lock was stolen */
299
+        return false;
300
+    } //(NFSL_STOLEN);
301 301
 
302
-	return false; //(NFSL_LOST);	/* The lock must have expired first. */
302
+    return false; //(NFSL_LOST);	/* The lock must have expired first. */
303 303
 }
304 304
 
305 305
 
@@ -323,5 +323,5 @@  discard block
 block discarded – undo
323 323
  * return bool true si déverrouillé, false sinon
324 324
  */
325 325
 function spip_nfslock_test($fichier, $birth, $max_age = 0) {
326
-	return spip_nfsunlock($fichier, $birth, $max_age, true);
326
+    return spip_nfsunlock($fichier, $birth, $max_age, true);
327 327
 }
Please login to merge, or discard this patch.