Completed
Push — master ( 66b8cb...2e2223 )
by cam
01:00
created
ecrire/inc/autoriser.php 1 patch
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
 // mais apres la fonction autoriser()
121 121
 if ($f = find_in_path('mes_fonctions.php')) {
122 122
 	global $dossier_squelettes;
123
-	include_once(_ROOT_CWD . $f);
123
+	include_once(_ROOT_CWD.$f);
124 124
 }
125 125
 
126 126
 
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 		$qui = $GLOBALS['visiteur_session'] ?: [];
163 163
 		$qui = array_merge(['statut' => '', 'id_auteur' => 0, 'webmestre' => 'non'], $qui);
164 164
 	} elseif (is_numeric($qui)) {
165
-		$qui = sql_fetsel('*', 'spip_auteurs', 'id_auteur=' . $qui);
165
+		$qui = sql_fetsel('*', 'spip_auteurs', 'id_auteur='.$qui);
166 166
 	}
167 167
 
168 168
 	// Admins restreints, on construit ici (pas generique mais...)
@@ -172,8 +172,8 @@  discard block
 block discarded – undo
172 172
 	}
173 173
 
174 174
 	spip_log(
175
-		"autoriser $faire $type $id (" . ($qui['nom'] ?? '') . ') ?',
176
-		'autoriser' . _LOG_DEBUG
175
+		"autoriser $faire $type $id (".($qui['nom'] ?? '').') ?',
176
+		'autoriser'._LOG_DEBUG
177 177
 	);
178 178
 
179 179
 	// passer par objet_type pour avoir les alias
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 		(isset($GLOBALS['autoriser_exception'][$faire][$type][$id]) and autoriser_exception($faire, $type, $id, 'verifier'))
190 190
 		or (isset($GLOBALS['autoriser_exception'][$faire][$type]['*']) and autoriser_exception($faire, $type, '*', 'verifier'))
191 191
 	) {
192
-		spip_log("autoriser ($faire, $type, $id, " . ($qui['nom'] ?? '') . ') : OK Exception', 'autoriser' . _LOG_DEBUG);
192
+		spip_log("autoriser ($faire, $type, $id, ".($qui['nom'] ?? '').') : OK Exception', 'autoriser'._LOG_DEBUG);
193 193
 		return true;
194 194
 	}
195 195
 
@@ -198,18 +198,18 @@  discard block
 block discarded – undo
198 198
 	// autoriser_faire[_dist], autoriser_defaut[_dist]
199 199
 	$fonctions = $type
200 200
 		? [
201
-			'autoriser_' . $type . '_' . $faire,
202
-			'autoriser_' . $type . '_' . $faire . '_dist',
203
-			'autoriser_' . $type,
204
-			'autoriser_' . $type . '_dist',
205
-			'autoriser_' . $faire,
206
-			'autoriser_' . $faire . '_dist',
201
+			'autoriser_'.$type.'_'.$faire,
202
+			'autoriser_'.$type.'_'.$faire.'_dist',
203
+			'autoriser_'.$type,
204
+			'autoriser_'.$type.'_dist',
205
+			'autoriser_'.$faire,
206
+			'autoriser_'.$faire.'_dist',
207 207
 			'autoriser_defaut',
208 208
 			'autoriser_defaut_dist'
209 209
 		]
210 210
 		: [
211
-			'autoriser_' . $faire,
212
-			'autoriser_' . $faire . '_dist',
211
+			'autoriser_'.$faire,
212
+			'autoriser_'.$faire.'_dist',
213 213
 			'autoriser_defaut',
214 214
 			'autoriser_defaut_dist'
215 215
 		];
@@ -222,8 +222,8 @@  discard block
 block discarded – undo
222 222
 	}
223 223
 
224 224
 	spip_log(
225
-		"$f($faire, $type, $id, " . ($qui['nom'] ?? '') . ') : ' . ($a ? 'OK' : 'niet'),
226
-		'autoriser' . _LOG_DEBUG
225
+		"$f($faire, $type, $id, ".($qui['nom'] ?? '').') : '.($a ? 'OK' : 'niet'),
226
+		'autoriser'._LOG_DEBUG
227 227
 	);
228 228
 
229 229
 	return $a;
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
 function autoriser_previsualiser_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
373 373
 
374 374
 	// Le visiteur a-t-il un statut prevu par la config ?
375
-	if (strpos($GLOBALS['meta']['preview'], ',' . $qui['statut'] . ',') !== false) {
375
+	if (strpos($GLOBALS['meta']['preview'], ','.$qui['statut'].',') !== false) {
376 376
 		return test_previsualiser_objet_champ($type, $id, $qui, $opt);
377 377
 	}
378 378
 
@@ -430,7 +430,7 @@  discard block
 block discarded – undo
430 430
 				} // pas de champ passe a la demande => NIET
431 431
 				$previsu = explode(',', $c['previsu']);
432 432
 				// regarder si ce statut est autorise pour l'auteur
433
-				if (in_array($opt[$champ] . '/auteur', $previsu)) {
433
+				if (in_array($opt[$champ].'/auteur', $previsu)) {
434 434
 					// retrouver l’id_auteur qui a filé un lien de prévisu éventuellement,
435 435
 					// sinon l’auteur en session
436 436
 					include_spip('inc/securiser_action');
@@ -444,12 +444,12 @@  discard block
 block discarded – undo
444 444
 
445 445
 					if (!$id_auteur) {
446 446
 						return false;
447
-					} elseif (autoriser('previsualiser' . $opt[$champ], $type, 0, $id_auteur)) {
447
+					} elseif (autoriser('previsualiser'.$opt[$champ], $type, 0, $id_auteur)) {
448 448
 						// dans ce cas (admin en general), pas de filtrage sur ce statut
449 449
 					} elseif (
450 450
 						!sql_countsel(
451 451
 							'spip_auteurs_liens',
452
-							'id_auteur=' . intval($id_auteur) . ' AND objet=' . sql_quote($type) . ' AND id_objet=' . intval($id)
452
+							'id_auteur='.intval($id_auteur).' AND objet='.sql_quote($type).' AND id_objet='.intval($id)
453 453
 						)
454 454
 					) {
455 455
 						return false;
@@ -494,16 +494,16 @@  discard block
 block discarded – undo
494 494
 			// multilinguisme par secteur et objet rattaché à une rubrique
495 495
 			$primary = id_table_objet($type);
496 496
 			if ($table != 'spip_rubriques') {
497
-				$id_rubrique = sql_getfetsel('id_rubrique', "$table", "$primary=" . intval($id));
497
+				$id_rubrique = sql_getfetsel('id_rubrique', "$table", "$primary=".intval($id));
498 498
 			} else {
499 499
 				$id_rubrique = $id;
500 500
 			}
501
-			$id_secteur = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . intval($id_rubrique));
501
+			$id_secteur = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique='.intval($id_rubrique));
502 502
 			if (!$id_secteur > 0) {
503 503
 				$id_secteur = $id_rubrique;
504 504
 			}
505
-			$langue_secteur = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique=' . intval($id_secteur));
506
-			$langue_objet = sql_getfetsel('lang', "$table", "$primary=" . intval($id));
505
+			$langue_secteur = sql_getfetsel('lang', 'spip_rubriques', 'id_rubrique='.intval($id_secteur));
506
+			$langue_objet = sql_getfetsel('lang', "$table", "$primary=".intval($id));
507 507
 			if ($langue_secteur != $langue_objet) {
508 508
 				// configuration incohérente, on laisse l'utilisateur corriger la situation
509 509
 				return true;
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
 			if ($table != 'spip_rubriques') { // le choix de la langue se fait seulement sur les rubriques
512 512
 				return false;
513 513
 			} else {
514
-				$id_parent = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique=' . intval($id));
514
+				$id_parent = sql_getfetsel('id_parent', 'spip_rubriques', 'id_rubrique='.intval($id));
515 515
 				if ($id_parent != 0) {
516 516
 					// sous-rubriques : pas de choix de langue
517 517
 					return false;
@@ -563,7 +563,7 @@  discard block
 block discarded – undo
563 563
 
564 564
 	if (!isset($opt['statut'])) {
565 565
 		if (isset($desc['field']['statut'])) {
566
-			$statut = sql_getfetsel('statut', $desc['table'], id_table_objet($type) . '=' . intval($id));
566
+			$statut = sql_getfetsel('statut', $desc['table'], id_table_objet($type).'='.intval($id));
567 567
 		} else {
568 568
 			$statut = 'publie';
569 569
 		} // pas de statut => publie
@@ -737,11 +737,11 @@  discard block
 block discarded – undo
737 737
 		return false;
738 738
 	}
739 739
 
740
-	if (sql_countsel('spip_rubriques', 'id_parent=' . intval($id))) {
740
+	if (sql_countsel('spip_rubriques', 'id_parent='.intval($id))) {
741 741
 		return false;
742 742
 	}
743 743
 
744
-	if (sql_countsel('spip_articles', 'id_rubrique=' . intval($id) . " AND (statut<>'poubelle')")) {
744
+	if (sql_countsel('spip_articles', 'id_rubrique='.intval($id)." AND (statut<>'poubelle')")) {
745 745
 		return false;
746 746
 	}
747 747
 
@@ -778,7 +778,7 @@  discard block
 block discarded – undo
778 778
 	if (!$id) {
779 779
 		return false;
780 780
 	}
781
-	$r = sql_fetsel('id_rubrique,statut', 'spip_articles', 'id_article=' . sql_quote($id));
781
+	$r = sql_fetsel('id_rubrique,statut', 'spip_articles', 'id_article='.sql_quote($id));
782 782
 
783 783
 	return
784 784
 		$r
@@ -789,7 +789,7 @@  discard block
 block discarded – undo
789 789
 				(!isset($opt['statut']) or !in_array($opt['statut'], ['publie', 'refuse'], true))
790 790
 				and in_array($qui['statut'], ['0minirezo', '1comite'])
791 791
 				and in_array($r['statut'], ['prop', 'prepa', 'poubelle'])
792
-				and auteurs_objet('article', $id, 'id_auteur=' . $qui['id_auteur'])
792
+				and auteurs_objet('article', $id, 'id_auteur='.$qui['id_auteur'])
793 793
 			)
794 794
 		);
795 795
 }
@@ -847,7 +847,7 @@  discard block
 block discarded – undo
847 847
 		if (!$id) {
848 848
 			return false;
849 849
 		}
850
-		$statut = sql_getfetsel('statut', 'spip_articles', 'id_article=' . intval($id));
850
+		$statut = sql_getfetsel('statut', 'spip_articles', 'id_article='.intval($id));
851 851
 	}
852 852
 
853 853
 	return
@@ -858,7 +858,7 @@  discard block
 block discarded – undo
858 858
 		or
859 859
 		($id
860 860
 			and $qui['id_auteur']
861
-			and auteurs_objet('article', $id, 'id_auteur=' . $qui['id_auteur']));
861
+			and auteurs_objet('article', $id, 'id_auteur='.$qui['id_auteur']));
862 862
 }
863 863
 
864 864
 
@@ -879,8 +879,8 @@  discard block
 block discarded – undo
879 879
 function autoriser_voir_dist(string $faire, string $type, $id, array $qui, array $opt): bool {
880 880
 	# securite, mais on aurait pas du arriver ici !
881 881
 	if (
882
-		function_exists($f = 'autoriser_' . $type . '_voir')
883
-		or function_exists($f = 'autoriser_' . $type . '_voir_dist')
882
+		function_exists($f = 'autoriser_'.$type.'_voir')
883
+		or function_exists($f = 'autoriser_'.$type.'_voir_dist')
884 884
 	) {
885 885
 		return $f($faire, $type, $id, $qui, $opt);
886 886
 	}
@@ -1011,7 +1011,7 @@  discard block
 block discarded – undo
1011 1011
 	$n = sql_fetsel(
1012 1012
 		'A.id_article',
1013 1013
 		'spip_auteurs_liens AS L LEFT JOIN spip_articles AS A ON (L.objet=\'article\' AND L.id_objet=A.id_article)',
1014
-		"A.statut='publie' AND L.id_auteur=" . sql_quote($id)
1014
+		"A.statut='publie' AND L.id_auteur=".sql_quote($id)
1015 1015
 	);
1016 1016
 
1017 1017
 	return $n ? true : false;
@@ -1223,7 +1223,7 @@  discard block
 block discarded – undo
1223 1223
 		and $r = sql_allfetsel(
1224 1224
 			'id_objet',
1225 1225
 			'spip_auteurs_liens',
1226
-			'id_auteur=' . intval($id_auteur) . " AND objet='rubrique' AND id_objet!=0"
1226
+			'id_auteur='.intval($id_auteur)." AND objet='rubrique' AND id_objet!=0"
1227 1227
 		)
1228 1228
 		and is_countable($r) ? count($r) : 0
1229 1229
 	) {
@@ -1908,8 +1908,8 @@  discard block
 block discarded – undo
1908 1908
 function auteurs_objet($objet, $id_objet, $cond = '') {
1909 1909
 	$objet = objet_type($objet);
1910 1910
 	$where = [
1911
-		'objet=' . sql_quote($objet),
1912
-		'id_objet=' . intval($id_objet)
1911
+		'objet='.sql_quote($objet),
1912
+		'id_objet='.intval($id_objet)
1913 1913
 	];
1914 1914
 	if (!empty($cond)) {
1915 1915
 		if (is_array($cond)) {
@@ -1944,7 +1944,7 @@  discard block
 block discarded – undo
1944 1944
 	return sql_allfetsel(
1945 1945
 		'id_auteur',
1946 1946
 		'spip_auteurs_liens',
1947
-		"objet='article' AND id_objet=" . intval($id_article) . ($cond ? " AND $cond" : '')
1947
+		"objet='article' AND id_objet=".intval($id_article).($cond ? " AND $cond" : '')
1948 1948
 	);
1949 1949
 }
1950 1950
 
Please login to merge, or discard this patch.
ecrire/inc/livrer_fichier.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 	];
44 44
 	$options = array_merge($defaut, $options);
45 45
 	if (is_numeric($options['expires']) and $options['expires'] > 0) {
46
-		$options['expires'] = gmdate('D, d M Y H:i:s', time() + $options['expires']) . ' GMT';
46
+		$options['expires'] = gmdate('D, d M Y H:i:s', time() + $options['expires']).' GMT';
47 47
 	}
48 48
 
49 49
 	if (is_null($options) and isset($_SERVER['HTTP_RANGE'])) {
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 function spip_livrer_fichier_entetes($fichier, $content_type = 'application/octet-stream', $attachment = false, $expires = 0) {
73 73
 	// toujours envoyer un content type, meme vide !
74 74
 	header('Accept-Ranges: bytes');
75
-	header('Content-Type: ' . $content_type);
75
+	header('Content-Type: '.$content_type);
76 76
 
77 77
 	if ($attachment) {
78 78
 		$f = basename($fichier);
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 	else {
91 91
 		$f = basename($fichier);
92 92
 		header("Content-Disposition: inline; filename=\"$f\";");
93
-		header('Expires: ' . $expires); // set expiration time
93
+		header('Expires: '.$expires); // set expiration time
94 94
 	}
95 95
 }
96 96
 
@@ -142,12 +142,12 @@  discard block
 block discarded – undo
142 142
 	// Parse Content-Range header for byte offsets, looks like "bytes=11525-" OR "bytes=11525-12451"
143 143
 	if ($range and preg_match('%bytes=(\d+)-(\d+)?%i', $range, $match)) {
144 144
 		### Offset signifies where we should begin to read the file
145
-		$byteOffset = (int)$match[1];
145
+		$byteOffset = (int) $match[1];
146 146
 
147 147
 
148 148
 		### Length is for how long we should read the file according to the browser, and can never go beyond the file size
149 149
 		if (isset($match[2])) {
150
-			$finishBytes = (int)$match[2];
150
+			$finishBytes = (int) $match[2];
151 151
 			$byteLength = $finishBytes + 1;
152 152
 		} else {
153 153
 			$finishBytes = $fileSize - 1;
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
 
169 169
 	// partial content
170 170
 	header('HTTP/1.1 206 Partial content');
171
-	header($cr_header);  ### Decrease by 1 on byte-length since this definition is zero-based index of bytes being sent
171
+	header($cr_header); ### Decrease by 1 on byte-length since this definition is zero-based index of bytes being sent
172 172
 
173 173
 
174 174
 	$byteRange = $byteLength - $byteOffset;
Please login to merge, or discard this patch.
ecrire/action/editer_logo.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
 	if ($logo) {
41 41
 		# TODO : deprecated, a supprimer -> anciens logos IMG/artonxx.png pas en base
42 42
 		if ((is_countable($logo) ? count($logo) : 0) < 6) {
43
-			spip_log("Supprimer ancien logo " . json_encode($logo, JSON_THROW_ON_ERROR), 'logo');
43
+			spip_log("Supprimer ancien logo ".json_encode($logo, JSON_THROW_ON_ERROR), 'logo');
44 44
 			spip_unlink($logo[0]);
45 45
 		}
46 46
 		elseif (
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 		return $erreur;
90 90
 	}
91 91
 	// chercher dans la base
92
-	$mode_document = 'logo' . $mode;
92
+	$mode_document = 'logo'.$mode;
93 93
 
94 94
 	include_spip('inc/documents');
95 95
 	$erreur = '';
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 		$tmp_name = false;
107 107
 		if (file_exists($source)) {
108 108
 			$tmp_name = $source;
109
-		} elseif (file_exists($f = determine_upload() . $source)) {
109
+		} elseif (file_exists($f = determine_upload().$source)) {
110 110
 			$tmp_name = $f;
111 111
 		}
112 112
 		if (!$tmp_name) {
@@ -142,7 +142,7 @@  discard block
 block discarded – undo
142 142
 
143 143
 	if (!is_numeric($id_document)) {
144 144
 		$erreur = ($id_document ?: 'Erreur inconnue');
145
-		spip_log("Erreur ajout logo : $erreur pour source=" . json_encode($source, JSON_THROW_ON_ERROR), 'logo');
145
+		spip_log("Erreur ajout logo : $erreur pour source=".json_encode($source, JSON_THROW_ON_ERROR), 'logo');
146 146
 		return $erreur;
147 147
 	}
148 148
 
@@ -175,23 +175,23 @@  discard block
 block discarded – undo
175 175
 	$GLOBALS['meta']['articles_modif'] = 'non';
176 176
 
177 177
 	foreach (['on', 'off'] as $mode) {
178
-		$nom_base = $type . $mode;
178
+		$nom_base = $type.$mode;
179 179
 		$dir = (defined('_DIR_LOGOS') ? _DIR_LOGOS : _DIR_IMG);
180 180
 
181
-		$files = glob($dir . $nom_base . '*');
181
+		$files = glob($dir.$nom_base.'*');
182 182
 		// est-ce que c'est une nouvelle tentative de migration ?
183 183
 		// dans ce cas les logos sont deja dans IMG/logo/
184 184
 		if (!(is_countable($files) ? count($files) : 0)) {
185
-			$files = glob($dir_logos . $nom_base . '*');
185
+			$files = glob($dir_logos.$nom_base.'*');
186 186
 			if (is_countable($files) ? count($files) : 0) {
187 187
 				// mais il faut verifier si ils ont pas deja ete migres pour tout ou partie
188 188
 				$filescheck = [];
189 189
 				foreach ($files as $file) {
190
-					$short = basename(dirname($file)) . DIRECTORY_SEPARATOR . basename($file);
190
+					$short = basename(dirname($file)).DIRECTORY_SEPARATOR.basename($file);
191 191
 					$filescheck[$short] = $file;
192 192
 				}
193 193
 				// trouver ceux deja migres
194
-				$deja = sql_allfetsel('fichier', 'spip_documents', sql_in('fichier', array_keys($filescheck)) . " AND mode LIKE 'logo%'");
194
+				$deja = sql_allfetsel('fichier', 'spip_documents', sql_in('fichier', array_keys($filescheck))." AND mode LIKE 'logo%'");
195 195
 				if (is_countable($deja) ? count($deja) : 0) {
196 196
 					$deja = array_column($deja, 'fichier');
197 197
 					$restant = array_diff(array_keys($filescheck), $deja);
@@ -210,11 +210,11 @@  discard block
 block discarded – undo
210 210
 			}
211 211
 		}
212 212
 
213
-		spip_log("logo_migrer_en_base $objet $mode : " . (is_countable($files) ? count($files) : 0) . ' logos restant', 'maj' . _LOG_INFO_IMPORTANTE);
213
+		spip_log("logo_migrer_en_base $objet $mode : ".(is_countable($files) ? count($files) : 0).' logos restant', 'maj'._LOG_INFO_IMPORTANTE);
214 214
 
215 215
 		$deja = [];
216 216
 		foreach ($files as $file) {
217
-			$logo = substr($file, strlen($dir . $nom_base));
217
+			$logo = substr($file, strlen($dir.$nom_base));
218 218
 			$logo = explode('.', $logo);
219 219
 			if (
220 220
 				is_numeric($logo[0])
@@ -225,16 +225,16 @@  discard block
 block discarded – undo
225 225
 					// if no logo in base
226 226
 					if (!$logo or (is_countable($logo) ? count($logo) : 0) < 6) {
227 227
 						foreach ($formats_logos as $format) {
228
-							if (@file_exists($d = ($dir . ($nom = $nom_base . intval($id_objet) . '.' . $format)))) {
228
+							if (@file_exists($d = ($dir.($nom = $nom_base.intval($id_objet).'.'.$format)))) {
229 229
 								if (isset($desc['field']['date_modif'])) {
230 230
 									$date_modif = sql_getfetsel('date_modif', $table, "$_id_objet=$id_objet");
231 231
 								} else {
232 232
 									$date_modif = null;
233 233
 								}
234 234
 								// logo_modifier commence par supprimer le logo existant, donc on le deplace pour pas le perdre
235
-								@rename($d, $dir_logos . $nom);
235
+								@rename($d, $dir_logos.$nom);
236 236
 								// et on le declare comme nouveau logo
237
-								logo_modifier($objet, $id_objet, $mode, $dir_logos . $nom);
237
+								logo_modifier($objet, $id_objet, $mode, $dir_logos.$nom);
238 238
 								if ($date_modif) {
239 239
 									sql_updateq($table, ['date_modif' => $date_modif], "$_id_objet=$id_objet");
240 240
 								}
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 			// si le fichier est encore la on le move : rien a faire ici
249 249
 			// (sauf si c'est une re-migration : il est deja dans logo/ donc il bouge pas)
250 250
 			if ($dir !== $dir_logos and file_exists($file)) {
251
-				@rename($file, $dir_logos_erreurs . basename($file));
251
+				@rename($file, $dir_logos_erreurs.basename($file));
252 252
 			}
253 253
 
254 254
 			if ($time_limit and time() > $time_limit) {
Please login to merge, or discard this patch.