Completed
Push — master ( 47be08...0b670a )
by cam
01:02
created
ecrire/inc/cookie.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 
106 106
 	// in fine renommer le prefixe si besoin
107 107
 	if (strpos($name, 'spip_') === 0) {
108
-		$name = $GLOBALS['cookie_prefix'] . '_' . substr($name, 5);
108
+		$name = $GLOBALS['cookie_prefix'].'_'.substr($name, 5);
109 109
 	}
110 110
 
111 111
 	#spip_log("cookie('$name', '$value', " . json_encode($options, true) . ")", "cookies");
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 	}
164 164
 	foreach ($_COOKIE as $name => $value) {
165 165
 		if (substr($name, 0, $prefix_long) == $cookie_prefix) {
166
-			$spipname = preg_replace('/^' . $cookie_prefix . '_/', 'spip_', $name);
166
+			$spipname = preg_replace('/^'.$cookie_prefix.'_/', 'spip_', $name);
167 167
 			$_COOKIE[$spipname] = $value;
168 168
 			$GLOBALS[$spipname] = $value;
169 169
 		}
Please login to merge, or discard this patch.
ecrire/inc/distant.php 1 patch
Spacing   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 	define('_INC_DISTANT_CONTENT_ENCODING', 'gzip');
27 27
 }
28 28
 if (!defined('_INC_DISTANT_USER_AGENT')) {
29
-	define('_INC_DISTANT_USER_AGENT', 'SPIP-' . $GLOBALS['spip_version_affichee'] . ' (' . $GLOBALS['home_server'] . ')');
29
+	define('_INC_DISTANT_USER_AGENT', 'SPIP-'.$GLOBALS['spip_version_affichee'].' ('.$GLOBALS['home_server'].')');
30 30
 }
31 31
 if (!defined('_INC_DISTANT_MAX_SIZE')) {
32 32
 	define('_INC_DISTANT_MAX_SIZE', 2_097_152);
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	define('_INC_DISTANT_CONNECT_TIMEOUT', 10);
36 36
 }
37 37
 
38
-define('_REGEXP_COPIE_LOCALE', ',' 	.
38
+define('_REGEXP_COPIE_LOCALE', ','.
39 39
 	preg_replace(
40 40
 		'@^https?:@',
41 41
 		'https?:',
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 
73 73
 	// si c'est la protection de soi-meme, retourner le path
74 74
 	if ($mode !== 'force' and preg_match(_REGEXP_COPIE_LOCALE, $source, $match)) {
75
-		$source = substr(_DIR_IMG, strlen(_DIR_RACINE)) . urldecode($match[1]);
75
+		$source = substr(_DIR_IMG, strlen(_DIR_RACINE)).urldecode($match[1]);
76 76
 
77 77
 		return @file_exists($source) ? $source : false;
78 78
 	}
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 		return false;
93 93
 	}
94 94
 
95
-	$localrac = _DIR_RACINE . $local;
95
+	$localrac = _DIR_RACINE.$local;
96 96
 	$t = ($mode === 'force') ? false : @file_exists($localrac);
97 97
 
98 98
 	// test d'existence du fichier
@@ -112,18 +112,18 @@  discard block
 block discarded – undo
112 112
 		if (!$taille_max) {
113 113
 			$taille_max = _COPIE_LOCALE_MAX_SIZE;
114 114
 		}
115
-		$localrac_tmp = $localrac . '.tmp';
115
+		$localrac_tmp = $localrac.'.tmp';
116 116
 		$res = recuperer_url(
117 117
 			$source,
118 118
 			['file' => $localrac_tmp, 'taille_max' => $taille_max, 'if_modified_since' => $t ? filemtime($localrac) : '']
119 119
 		);
120 120
 
121 121
 		if (!$res or (!$res['length'] and $res['status'] != 304)) {
122
-			spip_log("copie_locale : Echec recuperation $source sur $localrac_tmp status : " . ($res ? $res['status'] : '-'), 'distant' . _LOG_INFO_IMPORTANTE);
122
+			spip_log("copie_locale : Echec recuperation $source sur $localrac_tmp status : ".($res ? $res['status'] : '-'), 'distant'._LOG_INFO_IMPORTANTE);
123 123
 			@unlink($localrac_tmp);
124 124
 		}
125 125
 		else {
126
-			spip_log("copie_locale : recuperation $source sur $localrac_tmp OK | taille " . $res['length'] . ' status ' . $res['status'], 'distant');
126
+			spip_log("copie_locale : recuperation $source sur $localrac_tmp OK | taille ".$res['length'].' status '.$res['status'], 'distant');
127 127
 		}
128 128
 		if (!$res or !$res['length']) {
129 129
 			// si $t c'est sans doute juste un not-modified-since
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
 		if ($callback_valider_url
135 135
 		  and is_callable($callback_valider_url)
136 136
 		  and !$callback_valider_url($res['url'])) {
137
-			spip_log("copie_locale : url finale ".$res['url']." non valide, on refuse le fichier $localrac_tmp", 'distant' . _LOG_INFO_IMPORTANTE);
137
+			spip_log("copie_locale : url finale ".$res['url']." non valide, on refuse le fichier $localrac_tmp", 'distant'._LOG_INFO_IMPORTANTE);
138 138
 			@unlink($localrac_tmp);
139 139
 			return $t ? $local : false;
140 140
 		}
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 
226 226
 	if (!$is_known_host) {
227 227
 		$host = trim($parsed_url['host'], '.');
228
-		if (! $ip = filter_var($host, FILTER_VALIDATE_IP)) {
228
+		if (!$ip = filter_var($host, FILTER_VALIDATE_IP)) {
229 229
 			$ip = gethostbyname($host);
230 230
 			if ($ip === $host) {
231 231
 				// Error condition for gethostbyname()
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 			}
247 247
 		}
248 248
 		if ($ip) {
249
-			if (! filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) {
249
+			if (!filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE)) {
250 250
 				return false;
251 251
 			}
252 252
 		}
@@ -257,7 +257,7 @@  discard block
 block discarded – undo
257 257
 	}
258 258
 
259 259
 	$port = $parsed_url['port'];
260
-	if ($port === 80  or $port === 443  or $port === 8080) {
260
+	if ($port === 80 or $port === 443 or $port === 8080) {
261 261
 		return $url;
262 262
 	}
263 263
 
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
 				}
328 328
 			}
329 329
 			if ($taille > 500) {
330
-				$boundary = substr(md5(random_int(0, mt_getrandmax()) . 'spip'), 0, 8);
330
+				$boundary = substr(md5(random_int(0, mt_getrandmax()).'spip'), 0, 8);
331 331
 			}
332 332
 		}
333 333
 
@@ -355,16 +355,16 @@  discard block
 block discarded – undo
355 355
 			}
356 356
 		} else {
357 357
 			// fabrique une chaine HTTP simple pour un POST
358
-			$entete = 'Content-Type: application/x-www-form-urlencoded' . "\r\n";
358
+			$entete = 'Content-Type: application/x-www-form-urlencoded'."\r\n";
359 359
 			$chaine = [];
360 360
 			if (is_array($donnees)) {
361 361
 				foreach ($donnees as $cle => $valeur) {
362 362
 					if (is_array($valeur)) {
363 363
 						foreach ($valeur as $val2) {
364
-							$chaine[] = rawurlencode($cle) . '[]=' . rawurlencode($val2);
364
+							$chaine[] = rawurlencode($cle).'[]='.rawurlencode($val2);
365 365
 						}
366 366
 					} else {
367
-						$chaine[] = rawurlencode($cle) . '=' . rawurlencode($valeur);
367
+						$chaine[] = rawurlencode($cle).'='.rawurlencode($valeur);
368 368
 					}
369 369
 				}
370 370
 				$chaine = implode('&', $chaine);
@@ -469,13 +469,13 @@  discard block
 block discarded – undo
469 469
 		$options['taille_max'] = $copy ? _COPIE_LOCALE_MAX_SIZE : _INC_DISTANT_MAX_SIZE;
470 470
 	}
471 471
 
472
-	spip_log('recuperer_url ' . $options['methode'] . " sur $url", 'distant' . _LOG_DEBUG);
472
+	spip_log('recuperer_url '.$options['methode']." sur $url", 'distant'._LOG_DEBUG);
473 473
 
474 474
 	// Ajout des en-têtes spécifiques si besoin
475 475
 	$formatted_data = '';
476 476
 	if (!empty($options['headers'])) {
477 477
 		foreach ($options['headers'] as $champ => $valeur) {
478
-			$formatted_data .= $champ . ': ' . $valeur . "\r\n";
478
+			$formatted_data .= $champ.': '.$valeur."\r\n";
479 479
 		}
480 480
 	}
481 481
 
@@ -483,9 +483,9 @@  discard block
 block discarded – undo
483 483
 		[$head, $postdata] = prepare_donnees_post($options['datas'], $options['boundary']);
484 484
 		$head .= $formatted_data;
485 485
 		if (stripos($head, 'Content-Length:') === false) {
486
-			$head .= 'Content-Length: ' . strlen($postdata) . "\r\n";
486
+			$head .= 'Content-Length: '.strlen($postdata)."\r\n";
487 487
 		}
488
-		$formatted_data = $head . "\r\n" . $postdata;
488
+		$formatted_data = $head."\r\n".$postdata;
489 489
 		if (
490 490
 			strlen($postdata)
491 491
 			and !$methode_demandee
@@ -499,9 +499,9 @@  discard block
 block discarded – undo
499 499
 	// Accepter les URLs au format feed:// ou qui ont oublie le http:// ou les urls relatives au protocole
500 500
 	$url = preg_replace(',^feed://,i', 'http://', $url);
501 501
 	if (!tester_url_absolue($url)) {
502
-		$url = 'http://' . $url;
502
+		$url = 'http://'.$url;
503 503
 	} elseif (strncmp($url, '//', 2) == 0) {
504
-		$url = 'http:' . $url;
504
+		$url = 'http:'.$url;
505 505
 	}
506 506
 
507 507
 	$url = url_to_ascii($url);
@@ -530,7 +530,7 @@  discard block
 block discarded – undo
530 530
 		$options['if_modified_since']
531 531
 	);
532 532
 	if (!$handle) {
533
-		spip_log("ECHEC init_http $url", 'distant' . _LOG_ERREUR);
533
+		spip_log("ECHEC init_http $url", 'distant'._LOG_ERREUR);
534 534
 
535 535
 		return false;
536 536
 	}
@@ -560,7 +560,7 @@  discard block
 block discarded – undo
560 560
 					'status' => 200,
561 561
 				];
562 562
 			} else {
563
-				spip_log("ECHEC chinoiserie $url", 'distant' . _LOG_ERREUR);
563
+				spip_log("ECHEC chinoiserie $url", 'distant'._LOG_ERREUR);
564 564
 				return false;
565 565
 			}
566 566
 		} elseif ($res['location'] and $options['follow_location']) {
@@ -576,11 +576,11 @@  discard block
 block discarded – undo
576 576
 					$options['datas'] = '';
577 577
 				}
578 578
 			}
579
-			spip_log('recuperer_url recommence ' . $options['methode'] . " sur $url", 'distant' . _LOG_DEBUG);
579
+			spip_log('recuperer_url recommence '.$options['methode']." sur $url", 'distant'._LOG_DEBUG);
580 580
 
581 581
 			return recuperer_url($url, $options);
582 582
 		} elseif ($res['status'] !== 200) {
583
-			spip_log('HTTP status ' . $res['status'] . " pour $url", 'distant');
583
+			spip_log('HTTP status '.$res['status']." pour $url", 'distant');
584 584
 		}
585 585
 		$result['status'] = $res['status'];
586 586
 		if (isset($res['headers'])) {
@@ -596,7 +596,7 @@  discard block
 block discarded – undo
596 596
 
597 597
 	// on ne veut que les entetes
598 598
 	if (!$options['taille_max'] or $options['methode'] == 'HEAD' or $result['status'] == '304') {
599
-		spip_log('RESULTAT recuperer_url ' . $options['methode'] . " sur $url : " . json_encode($result), 'distant' . _LOG_DEBUG);
599
+		spip_log('RESULTAT recuperer_url '.$options['methode']." sur $url : ".json_encode($result), 'distant'._LOG_DEBUG);
600 600
 		return $result;
601 601
 	}
602 602
 
@@ -606,7 +606,7 @@  discard block
 block discarded – undo
606 606
 
607 607
 	$gz = false;
608 608
 	if (preg_match(",\bContent-Encoding: .*gzip,is", $result['headers'])) {
609
-		$gz = (_DIR_TMP . md5(uniqid(random_int(0, mt_getrandmax()))) . '.tmp.gz');
609
+		$gz = (_DIR_TMP.md5(uniqid(random_int(0, mt_getrandmax()))).'.tmp.gz');
610 610
 	}
611 611
 
612 612
 	// si on a pas deja recuperer le contenu par une methode detournee
@@ -642,7 +642,7 @@  discard block
 block discarded – undo
642 642
 
643 643
 	$trace = json_decode(json_encode($result), true);
644 644
 	$trace['page'] = '...';
645
-	spip_log('RESULTAT recuperer_url ' . $options['methode'] . " sur $url : " . json_encode($trace), 'distant' . _LOG_DEBUG);
645
+	spip_log('RESULTAT recuperer_url '.$options['methode']." sur $url : ".json_encode($trace), 'distant'._LOG_DEBUG);
646 646
 
647 647
 	return $result;
648 648
 }
@@ -696,7 +696,7 @@  discard block
 block discarded – undo
696 696
 	$sig['url'] = $url;
697 697
 
698 698
 	$dir = sous_repertoire(_DIR_CACHE, 'curl');
699
-	$cache = md5(serialize($sig)) . '-' . substr(preg_replace(',\W+,', '_', $url), 0, 80);
699
+	$cache = md5(serialize($sig)).'-'.substr(preg_replace(',\W+,', '_', $url), 0, 80);
700 700
 	$sub = sous_repertoire($dir, substr($cache, 0, 2));
701 701
 	$cache = "$sub$cache";
702 702
 
@@ -750,7 +750,7 @@  discard block
 block discarded – undo
750 750
 	$fp = false;
751 751
 	if ($fichier) {
752 752
 		include_spip('inc/acces');
753
-		$tmpfile = "$fichier." . creer_uniqid() . '.tmp';
753
+		$tmpfile = "$fichier.".creer_uniqid().'.tmp';
754 754
 		$fp = spip_fopen_lock($tmpfile, 'w', LOCK_EX);
755 755
 		if (!$fp and file_exists($fichier)) {
756 756
 			return filesize($fichier);
@@ -809,7 +809,7 @@  discard block
 block discarded – undo
809 809
 	}
810 810
 	$result['status'] = intval($r[1]);
811 811
 	while ($s = trim(fgets($handle, 16384))) {
812
-		$result['headers'][] = $s . "\n";
812
+		$result['headers'][] = $s."\n";
813 813
 		preg_match(',^([^:]*): *(.*)$,i', $s, $r);
814 814
 		[, $d, $v] = $r;
815 815
 		if (strtolower(trim($d)) == 'location' and $result['status'] >= 300 and $result['status'] < 400) {
@@ -858,13 +858,13 @@  discard block
 block discarded – undo
858 858
 
859 859
 	// on se place tout le temps comme si on etait a la racine
860 860
 	if (_DIR_RACINE) {
861
-		$d = preg_replace(',^' . preg_quote(_DIR_RACINE) . ',', '', $d);
861
+		$d = preg_replace(',^'.preg_quote(_DIR_RACINE).',', '', $d);
862 862
 	}
863 863
 
864 864
 	$m = md5($source);
865 865
 
866 866
 	return $d
867
-	. substr(preg_replace(',[^\w-],', '', basename($source)) . '-' . $m, 0, 12)
867
+	. substr(preg_replace(',[^\w-],', '', basename($source)).'-'.$m, 0, 12)
868 868
 	. substr($m, 0, 4)
869 869
 	. ".$extension";
870 870
 }
@@ -887,7 +887,7 @@  discard block
 block discarded – undo
887 887
 	// Si c'est deja local pas de souci
888 888
 	if (!tester_url_absolue($source)) {
889 889
 		if (_DIR_RACINE) {
890
-			$source = preg_replace(',^' . preg_quote(_DIR_RACINE) . ',', '', $source);
890
+			$source = preg_replace(',^'.preg_quote(_DIR_RACINE).',', '', $source);
891 891
 		}
892 892
 
893 893
 		return $source;
@@ -905,7 +905,7 @@  discard block
 block discarded – undo
905 905
 		$ext
906 906
 		and preg_match(',^\w+$,', $ext) // pas de php?truc=1&...
907 907
 		and $f = nom_fichier_copie_locale($source, $ext)
908
-		and file_exists(_DIR_RACINE . $f)
908
+		and file_exists(_DIR_RACINE.$f)
909 909
 	) {
910 910
 		return $f;
911 911
 	}
@@ -913,7 +913,7 @@  discard block
 block discarded – undo
913 913
 
914 914
 	// Si c'est deja dans la table des documents,
915 915
 	// ramener le nom de sa copie potentielle
916
-	$ext = sql_getfetsel('extension', 'spip_documents', 'fichier=' . sql_quote($source) . " AND distant='oui' AND extension <> ''");
916
+	$ext = sql_getfetsel('extension', 'spip_documents', 'fichier='.sql_quote($source)." AND distant='oui' AND extension <> ''");
917 917
 
918 918
 	if ($ext) {
919 919
 		return nom_fichier_copie_locale($source, $ext);
@@ -924,9 +924,9 @@  discard block
 block discarded – undo
924 924
 
925 925
 	$ext = $path_parts ? $path_parts['extension'] : '';
926 926
 
927
-	if ($ext and sql_getfetsel('extension', 'spip_types_documents', 'extension=' . sql_quote($ext))) {
927
+	if ($ext and sql_getfetsel('extension', 'spip_types_documents', 'extension='.sql_quote($ext))) {
928 928
 		$f = nom_fichier_copie_locale($source, $ext);
929
-		if (file_exists(_DIR_RACINE . $f)) {
929
+		if (file_exists(_DIR_RACINE.$f)) {
930 930
 			return $f;
931 931
 		}
932 932
 	}
@@ -934,7 +934,7 @@  discard block
 block discarded – undo
934 934
 	// Ping  pour voir si son extension est connue et autorisee
935 935
 	// avec mise en cache du resultat du ping
936 936
 
937
-	$cache = sous_repertoire(_DIR_CACHE, 'rid') . md5($source);
937
+	$cache = sous_repertoire(_DIR_CACHE, 'rid').md5($source);
938 938
 	if (
939 939
 		!@file_exists($cache)
940 940
 		or !$path_parts = @unserialize(spip_file_get_contents($cache))
@@ -944,10 +944,10 @@  discard block
 block discarded – undo
944 944
 		ecrire_fichier($cache, serialize($path_parts));
945 945
 	}
946 946
 	$ext = !empty($path_parts['extension']) ? $path_parts['extension'] : '';
947
-	if ($ext and sql_getfetsel('extension', 'spip_types_documents', 'extension=' . sql_quote($ext))) {
947
+	if ($ext and sql_getfetsel('extension', 'spip_types_documents', 'extension='.sql_quote($ext))) {
948 948
 		return nom_fichier_copie_locale($source, $ext);
949 949
 	}
950
-	spip_log("pas de copie locale pour $source", 'distant' . _LOG_ERREUR);
950
+	spip_log("pas de copie locale pour $source", 'distant'._LOG_ERREUR);
951 951
 }
952 952
 
953 953
 
@@ -1043,7 +1043,7 @@  discard block
 block discarded – undo
1043 1043
 		} else {
1044 1044
 			if ($a['body']) {
1045 1045
 				$a['extension'] = $extension;
1046
-				$a['fichier'] = _DIR_RACINE . nom_fichier_copie_locale($source, $extension);
1046
+				$a['fichier'] = _DIR_RACINE.nom_fichier_copie_locale($source, $extension);
1047 1047
 				ecrire_fichier($a['fichier'], $a['body']);
1048 1048
 				$size_image = @spip_getimagesize($a['fichier']);
1049 1049
 				$a['largeur'] = intval($size_image[0]);
@@ -1111,20 +1111,20 @@  discard block
 block discarded – undo
1111 1111
 			!$t
1112 1112
 			and preg_match(',\.([a-z0-9]+)(\?.*)?$,i', $source, $rext)
1113 1113
 		) {
1114
-			$t = sql_fetsel('extension', 'spip_types_documents', 'extension=' . sql_quote(corriger_extension($rext[1]), '', 'text'));
1114
+			$t = sql_fetsel('extension', 'spip_types_documents', 'extension='.sql_quote(corriger_extension($rext[1]), '', 'text'));
1115 1115
 		}
1116 1116
 		if (
1117 1117
 			!$t
1118 1118
 			and preg_match(',^Content-Disposition:\s*attachment;\s*filename=(.*)$,Uims', $headers, $m)
1119 1119
 			and preg_match(',\.([a-z0-9]+)(\?.*)?$,i', $m[1], $rext)
1120 1120
 		) {
1121
-			$t = sql_fetsel('extension', 'spip_types_documents', 'extension=' . sql_quote(corriger_extension($rext[1]), '', 'text'));
1121
+			$t = sql_fetsel('extension', 'spip_types_documents', 'extension='.sql_quote(corriger_extension($rext[1]), '', 'text'));
1122 1122
 		}
1123 1123
 	}
1124 1124
 
1125 1125
 	// Autre mime/type (ou text/plain avec fichier d'extension inconnue)
1126 1126
 	if (!$t) {
1127
-		$t = sql_fetsel('extension', 'spip_types_documents', 'mime_type=' . sql_quote($mime_type));
1127
+		$t = sql_fetsel('extension', 'spip_types_documents', 'mime_type='.sql_quote($mime_type));
1128 1128
 	}
1129 1129
 
1130 1130
 	// Toujours rien ? (ex: audio/x-ogg au lieu de application/ogg)
@@ -1135,11 +1135,11 @@  discard block
 block discarded – undo
1135 1135
 		and preg_match(',\.([a-z0-9]+)(\?.*)?$,i', $source, $rext)
1136 1136
 	) {
1137 1137
 		# eviter xxx.3 => 3gp (> SPIP 3)
1138
-		$t = sql_fetsel('extension', 'spip_types_documents', 'extension=' . sql_quote(corriger_extension($rext[1]), '', 'text'));
1138
+		$t = sql_fetsel('extension', 'spip_types_documents', 'extension='.sql_quote(corriger_extension($rext[1]), '', 'text'));
1139 1139
 	}
1140 1140
 
1141 1141
 	if ($t) {
1142
-		spip_log("mime-type $mime_type ok, extension " . $t['extension'], 'distant');
1142
+		spip_log("mime-type $mime_type ok, extension ".$t['extension'], 'distant');
1143 1143
 		return $t['extension'];
1144 1144
 	} else {
1145 1145
 		# par defaut on retombe sur '.bin' si c'est autorise
@@ -1242,7 +1242,7 @@  discard block
 block discarded – undo
1242 1242
 		}
1243 1243
 	} else {
1244 1244
 		$scheme = $t['scheme'];
1245
-		$noproxy = $scheme . '://';
1245
+		$noproxy = $scheme.'://';
1246 1246
 	}
1247 1247
 	if (isset($t['user'])) {
1248 1248
 		$user = [$t['user'], $t['pass']];
@@ -1256,7 +1256,7 @@  discard block
 block discarded – undo
1256 1256
 	}
1257 1257
 
1258 1258
 	if (!empty($t['query'])) {
1259
-		$path .= '?' . $t['query'];
1259
+		$path .= '?'.$t['query'];
1260 1260
 	}
1261 1261
 
1262 1262
 	$f = lance_requete($method, $scheme, $user, $host, $path, $port, $noproxy, $refuse_gz, $referer, $datas, $vers, $date);
@@ -1330,29 +1330,29 @@  discard block
 block discarded – undo
1330 1330
 	$proxy_user = '';
1331 1331
 	$http_proxy = need_proxy($host);
1332 1332
 	if ($user) {
1333
-		$user = urlencode($user[0]) . ':' . urlencode($user[1]);
1333
+		$user = urlencode($user[0]).':'.urlencode($user[1]);
1334 1334
 	}
1335 1335
 
1336 1336
 	$connect = '';
1337 1337
 	if ($http_proxy) {
1338
-		if (!defined('_PROXY_HTTPS_NOT_VIA_CONNECT') and in_array($scheme, ['tls','ssl'])) {
1339
-			$path_host = (!$user ? '' : "$user@") . $host . (($port != 80) ? ":$port" : '');
1340
-			$connect = 'CONNECT ' . $path_host . " $vers\r\n"
1338
+		if (!defined('_PROXY_HTTPS_NOT_VIA_CONNECT') and in_array($scheme, ['tls', 'ssl'])) {
1339
+			$path_host = (!$user ? '' : "$user@").$host.(($port != 80) ? ":$port" : '');
1340
+			$connect = 'CONNECT '.$path_host." $vers\r\n"
1341 1341
 				. "Host: $path_host\r\n"
1342 1342
 				. "Proxy-Connection: Keep-Alive\r\n";
1343 1343
 		} else {
1344
-			$path = (in_array($scheme, ['tls','ssl']) ? 'https://' : "$scheme://")
1344
+			$path = (in_array($scheme, ['tls', 'ssl']) ? 'https://' : "$scheme://")
1345 1345
 				. (!$user ? '' : "$user@")
1346
-				. "$host" . (($port != 80) ? ":$port" : '') . $path;
1346
+				. "$host".(($port != 80) ? ":$port" : '').$path;
1347 1347
 		}
1348 1348
 		$t2 = @parse_url($http_proxy);
1349 1349
 		$first_host = $t2['host'];
1350 1350
 		$port = ($t2['port'] ?? null) ?: 80;
1351 1351
 		if ($t2['user'] ?? null) {
1352
-			$proxy_user = base64_encode($t2['user'] . ':' . $t2['pass']);
1352
+			$proxy_user = base64_encode($t2['user'].':'.$t2['pass']);
1353 1353
 		}
1354 1354
 	} else {
1355
-		$first_host = $noproxy . $host;
1355
+		$first_host = $noproxy.$host;
1356 1356
 	}
1357 1357
 
1358 1358
 	if ($connect) {
@@ -1374,7 +1374,7 @@  discard block
 block discarded – undo
1374 1374
 		);
1375 1375
 		spip_log("Recuperer $path sur $first_host:$port par $f (via CONNECT)", 'connect');
1376 1376
 		if (!$f) {
1377
-			spip_log("Erreur connexion $errno $errstr", 'distant' . _LOG_ERREUR);
1377
+			spip_log("Erreur connexion $errno $errstr", 'distant'._LOG_ERREUR);
1378 1378
 			return $errno;
1379 1379
 		}
1380 1380
 		stream_set_timeout($f, _INC_DISTANT_CONNECT_TIMEOUT);
@@ -1387,7 +1387,7 @@  discard block
 block discarded – undo
1387 1387
 			or !count($res = explode(' ', $res))
1388 1388
 			or $res[1] !== '200'
1389 1389
 		) {
1390
-			spip_log("Echec CONNECT sur $first_host:$port", 'connect' . _LOG_INFO_IMPORTANTE);
1390
+			spip_log("Echec CONNECT sur $first_host:$port", 'connect'._LOG_INFO_IMPORTANTE);
1391 1391
 			fclose($f);
1392 1392
 
1393 1393
 			return false;
@@ -1404,7 +1404,7 @@  discard block
 block discarded – undo
1404 1404
 		} while (!$f and $ntry-- and $errno !== 110 and sleep(1));
1405 1405
 		spip_log("Recuperer $path sur $first_host:$port par $f");
1406 1406
 		if (!$f) {
1407
-			spip_log("Erreur connexion $errno $errstr", 'distant' . _LOG_ERREUR);
1407
+			spip_log("Erreur connexion $errno $errstr", 'distant'._LOG_ERREUR);
1408 1408
 
1409 1409
 			return $errno;
1410 1410
 		}
@@ -1414,16 +1414,16 @@  discard block
 block discarded – undo
1414 1414
 	$site = $GLOBALS['meta']['adresse_site'] ?? '';
1415 1415
 
1416 1416
 	$host_port = $host;
1417
-	if ($port != (in_array($scheme, ['tls','ssl']) ? 443 : 80)) {
1417
+	if ($port != (in_array($scheme, ['tls', 'ssl']) ? 443 : 80)) {
1418 1418
 		$host_port .= ":$port";
1419 1419
 	}
1420 1420
 	$req = "$method $path $vers\r\n"
1421 1421
 		. "Host: $host_port\r\n"
1422
-		. 'User-Agent: ' . _INC_DISTANT_USER_AGENT . "\r\n"
1423
-		. ($refuse_gz ? '' : ('Accept-Encoding: ' . _INC_DISTANT_CONTENT_ENCODING . "\r\n"))
1422
+		. 'User-Agent: '._INC_DISTANT_USER_AGENT."\r\n"
1423
+		. ($refuse_gz ? '' : ('Accept-Encoding: '._INC_DISTANT_CONTENT_ENCODING."\r\n"))
1424 1424
 		. (!$site ? '' : "Referer: $site/$referer\r\n")
1425
-		. (!$date ? '' : 'If-Modified-Since: ' . (gmdate('D, d M Y H:i:s', $date) . " GMT\r\n"))
1426
-		. (!$user ? '' : ('Authorization: Basic ' . base64_encode($user) . "\r\n"))
1425
+		. (!$date ? '' : 'If-Modified-Since: '.(gmdate('D, d M Y H:i:s', $date)." GMT\r\n"))
1426
+		. (!$user ? '' : ('Authorization: Basic '.base64_encode($user)."\r\n"))
1427 1427
 		. (!$proxy_user ? '' : "Proxy-Authorization: Basic $proxy_user\r\n")
1428 1428
 		. (!strpos($vers, '1.1') ? '' : "Keep-Alive: 300\r\nConnection: keep-alive\r\n");
1429 1429
 
Please login to merge, or discard this patch.
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.