Completed
Push — spip-3.0 ( 0bbd73...b24c06 )
by cam
06:45
created
ecrire/inc/simplexml_to_array.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
  * @param bool $utiliser_namespace
22 22
  * @return array
23 23
  */
24
-function inc_simplexml_to_array_dist($u, $utiliser_namespace=false){
24
+function inc_simplexml_to_array_dist($u, $utiliser_namespace = false) {
25 25
 	// decoder la chaine en SimpleXML si pas deja fait
26 26
 	if (is_string($u))
27 27
 		$u = simplexml_load_string($u);
@@ -38,14 +38,14 @@  discard block
 block discarded – undo
38 38
  * @param bool $utiliser_namespace
39 39
  * @return array
40 40
 **/
41
-function xmlObjToArr($obj, $utiliser_namespace=false) {
41
+function xmlObjToArr($obj, $utiliser_namespace = false) {
42 42
 
43 43
 	$tableau = array();
44 44
 
45 45
 	// Cette fonction getDocNamespaces() est longue sur de gros xml. On permet donc
46 46
 	// de l'activer ou pas suivant le contenu supposé du XML
47 47
 	if (is_object($obj)) {
48
-		if (is_array($utiliser_namespace)){
48
+		if (is_array($utiliser_namespace)) {
49 49
 			$namespace = $utiliser_namespace;
50 50
 		}
51 51
 		else {
@@ -54,8 +54,8 @@  discard block
 block discarded – undo
54 54
 			$namespace[NULL] = NULL;
55 55
 		}
56 56
 
57
-		$name = strtolower((string)$obj->getName());
58
-		$text = trim((string)$obj);
57
+		$name = strtolower((string) $obj->getName());
58
+		$text = trim((string) $obj);
59 59
 		if (strlen($text) <= 0) {
60 60
 			$text = NULL;
61 61
 		}
@@ -64,23 +64,23 @@  discard block
 block discarded – undo
64 64
 		$attributes = array();
65 65
 
66 66
 		// get info for all namespaces
67
-		foreach( $namespace as $ns=>$nsUrl ) {
67
+		foreach ($namespace as $ns=>$nsUrl) {
68 68
 			// attributes
69 69
 			$objAttributes = $obj->attributes($ns, true);
70
-			foreach( $objAttributes as $attributeName => $attributeValue ) {
71
-				$attribName = strtolower(trim((string)$attributeName));
72
-				$attribVal = trim((string)$attributeValue);
70
+			foreach ($objAttributes as $attributeName => $attributeValue) {
71
+				$attribName = strtolower(trim((string) $attributeName));
72
+				$attribVal = trim((string) $attributeValue);
73 73
 				if (!empty($ns)) {
74
-					$attribName = $ns . ':' . $attribName;
74
+					$attribName = $ns.':'.$attribName;
75 75
 				}
76 76
 				$attributes[$attribName] = $attribVal;
77 77
 			}
78 78
 
79 79
 			// children
80 80
 			$objChildren = $obj->children($ns, true);
81
-			foreach( $objChildren as $childName=>$child ) {
82
-				$childName = strtolower((string)$childName);
83
-				if( !empty($ns) ) {
81
+			foreach ($objChildren as $childName=>$child) {
82
+				$childName = strtolower((string) $childName);
83
+				if (!empty($ns)) {
84 84
 					$childName = $ns.':'.$childName;
85 85
 				}
86 86
 				$children[$childName][] = xmlObjToArr($child, $namespace);
Please login to merge, or discard this patch.
ecrire/inc/couleurs.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -20,74 +20,74 @@  discard block
 block discarded – undo
20 20
 // a true, elle complete le tableau par celui donne en premier argument.
21 21
 
22 22
 // http://doc.spip.org/@inc_couleurs_dist
23
-function inc_couleurs_dist($choix=NULL, $ajouter=false)
23
+function inc_couleurs_dist($choix = NULL, $ajouter = false)
24 24
 {
25 25
 	static $couleurs_spip = array(
26 26
 // Vert
27
-1 => array (
27
+1 => array(
28 28
 		"couleur_foncee" => "#9DBA00",
29 29
 		"couleur_claire" => "#C5E41C",
30 30
 		"couleur_lien" => "#657701",
31 31
 		"couleur_lien_off" => "#A6C113"
32 32
 		),
33 33
 // Violet clair
34
-2 => array (
34
+2 => array(
35 35
 		"couleur_foncee" => "#eb68b3",
36 36
 		"couleur_claire" => "#ffa9e6",
37 37
 		"couleur_lien" => "#8F004D",
38 38
 		"couleur_lien_off" => "#BE6B97"
39 39
 		),
40 40
 // Orange
41
-3 => array (
41
+3 => array(
42 42
 		"couleur_foncee" => "#fa9a00",
43 43
 		"couleur_claire" => "#ffc000",
44 44
 		"couleur_lien" => "#FF5B00",
45 45
 		"couleur_lien_off" => "#B49280"
46 46
 		),
47 47
 // Saumon
48
-4 => array (
48
+4 => array(
49 49
 		"couleur_foncee" => "#CDA261",
50 50
 		"couleur_claire" => "#FFDDAA",
51 51
 		"couleur_lien" => "#AA6A09",
52 52
 		"couleur_lien_off" => "#B79562"
53 53
 		),
54 54
 //  Bleu pastel
55
-5 => array (
55
+5 => array(
56 56
 		"couleur_foncee" => "#5da7c5",
57 57
 		"couleur_claire" => "#97d2e1",
58 58
 		"couleur_lien" => "#116587",
59 59
 		"couleur_lien_off" => "#81B7CD"
60 60
 		),
61 61
 //  Gris
62
-6 => array (
62
+6 => array(
63 63
 		"couleur_foncee" => "#85909A",
64 64
 		"couleur_claire" => "#C0CAD4",
65 65
 		"couleur_lien" => "#3B5063",
66 66
 		"couleur_lien_off" => "#6D8499"
67 67
 		),
68 68
 // Vert de gris
69
-7 => array (
69
+7 => array(
70 70
 		"couleur_foncee" => "#999966",
71 71
 		"couleur_claire" => "#CCCC99",
72 72
 		"couleur_lien" => "#666633",
73 73
 		"couleur_lien_off" => "#999966"
74 74
 		),
75 75
 // Rose vieux
76
-8 => array (
76
+8 => array(
77 77
 		"couleur_foncee" => "#EB68B3",
78 78
 		"couleur_claire" => "#E4A7C5",
79 79
 		"couleur_lien" => "#8F004D",
80 80
 		"couleur_lien_off" => "#BE6B97"
81 81
 		),
82 82
 // Violet
83
-9 => array (
83
+9 => array(
84 84
 		"couleur_foncee" => "#8F8FBD",
85 85
 		"couleur_claire" => "#C4C4DD",
86 86
 		"couleur_lien" => "#6071A5",
87 87
 		"couleur_lien_off" => "#5C5C8C"
88 88
 		),
89 89
 //  Gris
90
-10 => array (
90
+10 => array(
91 91
 		"couleur_foncee" => "#909090",
92 92
 		"couleur_claire" => "#D3D3D3",
93 93
 		"couleur_lien" => "#808080",
@@ -103,14 +103,14 @@  discard block
 block discarded – undo
103 103
 		$GLOBALS["couleur_lien_off"] = $couleurs_spip[$choix]['couleur_lien_off'];
104 104
 		
105 105
 	  return
106
-	    "couleur_claire=" .
107
-	    substr($couleurs_spip[$choix]['couleur_claire'],1).
108
-	    '&couleur_foncee=' .
109
-	    substr($couleurs_spip[$choix]['couleur_foncee'],1);
106
+	    "couleur_claire=".
107
+	    substr($couleurs_spip[$choix]['couleur_claire'], 1).
108
+	    '&couleur_foncee='.
109
+	    substr($couleurs_spip[$choix]['couleur_foncee'], 1);
110 110
 	} else {
111 111
 		if (is_array($choix)) {
112 112
 			if ($ajouter) {
113
-				foreach($choix as $c)
113
+				foreach ($choix as $c)
114 114
 					$couleurs_spip[] = $c;
115 115
 				return $couleurs_spip;
116 116
 			} else {
Please login to merge, or discard this patch.
ecrire/inc/preselectionner_parent_nouvel_objet.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 
14 14
 if (!defined('_ECRIRE_INC_VERSION')) return;
15 15
 if (!defined('_AUTO_SELECTION_RUBRIQUE'))
16
-	define('_AUTO_SELECTION_RUBRIQUE',false);
16
+	define('_AUTO_SELECTION_RUBRIQUE', false);
17 17
 
18 18
 
19 19
 /**
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  * @param array $row
26 26
  * @return string
27 27
  */
28
-function inc_preselectionner_parent_nouvel_objet_dist($objet, $row){
28
+function inc_preselectionner_parent_nouvel_objet_dist($objet, $row) {
29 29
 	if (!_AUTO_SELECTION_RUBRIQUE)
30 30
 		return '';
31 31
 
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 		return '';
34 34
 
35 35
 	$id_rubrique = '';
36
-	if ($GLOBALS['connect_id_rubrique']){
36
+	if ($GLOBALS['connect_id_rubrique']) {
37 37
 		// si admin restreint : sa rubrique
38 38
 		$id_rubrique = $GLOBALS['connect_id_rubrique'][0];
39 39
 	}
@@ -43,12 +43,12 @@  discard block
 block discarded – undo
43 43
 		$id_rubrique = $row_rub['id_rubrique'];
44 44
 	}
45 45
 	// si le choix ne convient pas, on cherche dans un secteur
46
-	if (!autoriser('creer'.$objet.'dans','rubrique',$id_rubrique)){
46
+	if (!autoriser('creer'.$objet.'dans', 'rubrique', $id_rubrique)) {
47 47
 		$id_rubrique = '';
48 48
 		// manque de chance, la rubrique n'est pas autorisee, on cherche un des secteurs autorises
49 49
 		$res = sql_select("id_rubrique", "spip_rubriques", "id_parent=0");
50
-		while (!$id_rubrique AND $row_rub = sql_fetch($res)){
51
-			if (autoriser('creer'.$objet.'dans','rubrique',$row_rub['id_rubrique']))
50
+		while (!$id_rubrique AND $row_rub = sql_fetch($res)) {
51
+			if (autoriser('creer'.$objet.'dans', 'rubrique', $row_rub['id_rubrique']))
52 52
 				$id_rubrique = $row_rub['id_rubrique'];
53 53
 		}
54 54
 	}
Please login to merge, or discard this patch.
ecrire/inc/acces.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 
70 70
 // http://doc.spip.org/@renouvelle_alea
71 71
 function renouvelle_alea() {
72
-	if (!isset($GLOBALS['meta']['alea_ephemere'])){
72
+	if (!isset($GLOBALS['meta']['alea_ephemere'])) {
73 73
 		include_spip('base/abstract_sql');
74 74
 		$GLOBALS['meta']['alea_ephemere'] = sql_getfetsel('valeur', 'spip_meta', "nom='alea_ephemere'");
75 75
 	}
@@ -105,15 +105,15 @@  discard block
 block discarded – undo
105 105
 // Inclure les arguments significatifs pour le hachage
106 106
 // cas particulier du statut pour compatibilite ancien rss/suivi_revisions
107 107
 
108
-function param_low_sec($op, $args=array(), $lang='', $mime='rss')
108
+function param_low_sec($op, $args = array(), $lang = '', $mime = 'rss')
109 109
 {
110 110
 	$a = $b = '';
111 111
 	foreach ($args as $val => $var)
112 112
 		if ($var) {
113
-			if ($val<>'statut') $a .= ':' . $val.'-'.$var;
114
-			$b .= $val.'='.$var . '&';
113
+			if ($val <> 'statut') $a .= ':'.$val.'-'.$var;
114
+			$b .= $val.'='.$var.'&';
115 115
 		}
116
-	$a = substr($a,1);
116
+	$a = substr($a, 1);
117 117
 	$id = intval(@$GLOBALS['connect_id_auteur']);
118 118
 	return $b
119 119
 	  . "op="
@@ -127,12 +127,12 @@  discard block
 block discarded – undo
127 127
 }
128 128
 
129 129
 // http://doc.spip.org/@afficher_low_sec
130
-function afficher_low_sec ($id_auteur, $action='') {
131
-	return substr(md5($action.low_sec($id_auteur)),0,8);
130
+function afficher_low_sec($id_auteur, $action = '') {
131
+	return substr(md5($action.low_sec($id_auteur)), 0, 8);
132 132
 }
133 133
 
134 134
 // http://doc.spip.org/@verifier_low_sec
135
-function verifier_low_sec ($id_auteur, $cle, $action='') {
135
+function verifier_low_sec($id_auteur, $cle, $action = '') {
136 136
 	return ($cle == afficher_low_sec($id_auteur, $action));
137 137
 }
138 138
 
@@ -154,8 +154,8 @@  discard block
 block discarded – undo
154 154
 // Voir le plugin "acces restreint"
155 155
 // http://doc.spip.org/@ecrire_acces
156 156
 function ecrire_acces() {
157
-	$htaccess = _DIR_RESTREINT . _ACCESS_FILE_NAME;
158
-	$htpasswd = _DIR_TMP . _AUTH_USER_FILE;
157
+	$htaccess = _DIR_RESTREINT._ACCESS_FILE_NAME;
158
+	$htpasswd = _DIR_TMP._AUTH_USER_FILE;
159 159
 
160 160
 	// Cette variable de configuration peut etre posee par un plugin
161 161
 	// par exemple acces_restreint ;
@@ -175,7 +175,7 @@  discard block
 block discarded – undo
175 175
 	if (spip_connect_ldap()) return;
176 176
 	$p1 = ''; // login:htpass pour tous
177 177
 	$p2 = ''; // login:htpass pour les admins
178
-	$s = sql_select("login, htpass, statut", "spip_auteurs", sql_in("statut",  array('1comite','0minirezo','nouveau')));
178
+	$s = sql_select("login, htpass, statut", "spip_auteurs", sql_in("statut", array('1comite', '0minirezo', 'nouveau')));
179 179
 	while ($t = sql_fetch($s)) {
180 180
 		if (strlen($t['login']) AND strlen($t['htpass'])) {
181 181
 			$p1 .= $t['login'].':'.$t['htpass']."\n";
@@ -202,27 +202,27 @@  discard block
 block discarded – undo
202 202
 // Installe ou verifie un .htaccess, y compris sa prise en compte par Apache
203 203
 //
204 204
 // http://doc.spip.org/@verifier_htaccess
205
-function verifier_htaccess($rep, $force=false) {
206
-	$htaccess = rtrim($rep,"/") . "/" . _ACCESS_FILE_NAME;
205
+function verifier_htaccess($rep, $force = false) {
206
+	$htaccess = rtrim($rep, "/")."/"._ACCESS_FILE_NAME;
207 207
 	if (((@file_exists($htaccess)) OR defined('_TEST_DIRS')) AND !$force)
208 208
 		return true;
209 209
 	if ($ht = @fopen($htaccess, "w")) {
210 210
 		fputs($ht, "deny from all\n");
211 211
 		fclose($ht);
212 212
 		@chmod($htaccess, _SPIP_CHMOD & 0666);
213
-		$t = rtrim($rep,"/") . "/.ok";
213
+		$t = rtrim($rep, "/")."/.ok";
214 214
 		if ($ht = @fopen($t, "w")) {
215 215
 			@fclose($ht);
216 216
 			include_spip('inc/distant');
217
-			$t = substr($t,strlen(_DIR_RACINE));
218
-			$t = url_de_base() . $t;
217
+			$t = substr($t, strlen(_DIR_RACINE));
218
+			$t = url_de_base().$t;
219 219
 			$ht = recuperer_lapage($t, false, 'HEAD', 0);
220 220
 			// htaccess inoperant si on a recupere des entetes HTTP
221 221
 			// (ignorer la reussite si connexion par fopen)
222 222
 			$ht = !(isset($ht[0]) AND $ht[0]);
223 223
 		}
224 224
 	}
225
-	spip_log("Creation de $htaccess " . ($ht ? " reussie" : " manquee"));
225
+	spip_log("Creation de $htaccess ".($ht ? " reussie" : " manquee"));
226 226
 	return $ht;
227 227
 }	
228 228
 
@@ -235,11 +235,11 @@  discard block
 block discarded – undo
235 235
 	$f = ($GLOBALS['meta']['creer_htaccess'] === 'oui');
236 236
 	$dirs = sql_allfetsel('extension', 'spip_types_documents');
237 237
 	$dirs[] = array('extension' => 'distant');
238
-	foreach($dirs as $e) {
239
-		if (is_dir($dir = _DIR_IMG . $e['extension'])) {
238
+	foreach ($dirs as $e) {
239
+		if (is_dir($dir = _DIR_IMG.$e['extension'])) {
240 240
 			if ($f)
241 241
 				verifier_htaccess($dir);
242
-			else spip_unlink($dir . '/' . _ACCESS_FILE_NAME);
242
+			else spip_unlink($dir.'/'._ACCESS_FILE_NAME);
243 243
 		}
244 244
 	}
245 245
 	return $GLOBALS['meta']['creer_htaccess'];
Please login to merge, or discard this patch.
ecrire/inc/auth.php 1 patch
Spacing   +66 added lines, -67 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
  */
33 33
 function inc_auth_dist() {
34 34
 
35
-	global $connect_login ;
35
+	global $connect_login;
36 36
 
37 37
 	$row = auth_mode();
38 38
 
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 			'site' => generer_url_public('', "action=logout&amp;logout=prive"));
52 52
 
53 53
 	$n = intval(sql_errno());
54
-	spip_log("Erreur base de donnees $n " . sql_error());
54
+	spip_log("Erreur base de donnees $n ".sql_error());
55 55
 	return $n ? $n : 1;
56 56
 }
57 57
 
@@ -75,11 +75,11 @@  discard block
 block discarded – undo
75 75
 		$raison = redirige_formulaire($raison);
76 76
 	} elseif (is_int($raison)) {
77 77
 		// erreur SQL a afficher
78
-		$raison = minipres(_T('info_travaux_titre'), _T('titre_probleme_technique'). "<p><tt>".sql_errno()." ".sql_error()."</tt></p>");
78
+		$raison = minipres(_T('info_travaux_titre'), _T('titre_probleme_technique')."<p><tt>".sql_errno()." ".sql_error()."</tt></p>");
79 79
 	} elseif (@$raison['statut']) {
80 80
 		// un simple visiteur n'a pas acces a l'espace prive
81
-		spip_log("connexion refusee a " . @$raison['id_auteur']);
82
-		$raison = minipres(_T('avis_erreur_connexion'),_T('avis_erreur_visiteur'));
81
+		spip_log("connexion refusee a ".@$raison['id_auteur']);
82
+		$raison = minipres(_T('avis_erreur_connexion'), _T('avis_erreur_visiteur'));
83 83
 	} else {
84 84
 		// auteur en fin de droits ...
85 85
 		$h = $raison['site'];
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
 function auth_mode()
105 105
 {
106 106
 	global $auth_can_disconnect, $ignore_auth_http, $ignore_remote_user;
107
-	global $connect_login ;
107
+	global $connect_login;
108 108
 
109 109
 	//
110 110
 	// Initialiser variables (eviter hacks par URL)
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 	if (isset($_COOKIE['spip_session'])) {
123 123
 		$session = charger_fonction('session', 'inc');
124 124
 		if ($id_auteur = $session()
125
-		OR $id_auteur===0 // reprise sur restauration
125
+		OR $id_auteur === 0 // reprise sur restauration
126 126
 		) {
127 127
 			$auth_can_disconnect = true;
128 128
 			$connect_login = $GLOBALS['visiteur_session']['login'];
@@ -166,8 +166,7 @@  discard block
 block discarded – undo
166 166
 	$where = (is_numeric($id_auteur)
167 167
 	/*AND $id_auteur>0*/ // reprise lors des restaurations
168 168
 	) ?
169
-	  "id_auteur=$id_auteur" :
170
-	  (!strlen($connect_login) ? '' : "login=" . sql_quote($connect_login,'','text'));
169
+	  "id_auteur=$id_auteur" : (!strlen($connect_login) ? '' : "login=".sql_quote($connect_login, '', 'text'));
171 170
 
172 171
 	if (!$where) return '';
173 172
 
@@ -192,7 +191,7 @@  discard block
 block discarded – undo
192 191
 {
193 192
 	global $connect_statut, $connect_toutes_rubriques, $connect_id_rubrique, $connect_login, $connect_id_auteur;
194 193
 
195
-	if ($row['statut']=='nouveau'){
194
+	if ($row['statut'] == 'nouveau') {
196 195
 		include_spip('action/inscrire_auteur');
197 196
 		$row = confirmer_statut_inscription($row);
198 197
 	}
@@ -201,7 +200,7 @@  discard block
 block discarded – undo
201 200
 	$connect_login = $row['login'];
202 201
 	$connect_statut = $row['statut'];
203 202
 
204
-	$GLOBALS['visiteur_session'] = array_merge((array)$GLOBALS['visiteur_session'], $row);
203
+	$GLOBALS['visiteur_session'] = array_merge((array) $GLOBALS['visiteur_session'], $row);
205 204
 
206 205
 	// au cas ou : ne pas memoriser les champs sensibles
207 206
 	unset($GLOBALS['visiteur_session']['pass']);
@@ -220,14 +219,14 @@  discard block
 block discarded – undo
220 219
 	$r = @unserialize($row['prefs']);
221 220
 	$GLOBALS['visiteur_session']['prefs'] = ($r ? $r : array());
222 221
 	// si prefs pas definies, les definir par defaut
223
-	if (!isset($GLOBALS['visiteur_session']['prefs']['couleur'])){
222
+	if (!isset($GLOBALS['visiteur_session']['prefs']['couleur'])) {
224 223
 		$GLOBALS['visiteur_session']['prefs']['couleur'] = 1;
225 224
 		$GLOBALS['visiteur_session']['prefs']['display'] = 2;
226 225
 		$GLOBALS['visiteur_session']['prefs']["display_navigation"] = "navigation_avec_icones";
227 226
 		$GLOBALS['visiteur_session']['prefs']["display_outils"] = "oui";
228 227
 	}
229 228
 
230
-	$GLOBALS['visiteur_session'] = pipeline('preparer_visiteur_session',array('args'=>array('row'=>$row),'data'=>$GLOBALS['visiteur_session']));
229
+	$GLOBALS['visiteur_session'] = pipeline('preparer_visiteur_session', array('args'=>array('row'=>$row), 'data'=>$GLOBALS['visiteur_session']));
231 230
 
232 231
 	// Etablir les droits selon le codage attendu
233 232
 	// dans ecrire/index.php ecrire/prive.php
@@ -267,7 +266,7 @@  discard block
 block discarded – undo
267 266
 function auth_a_loger()
268 267
 {
269 268
 	$redirect = generer_url_public('login',
270
-	"url=" . rawurlencode(self('&',true)), '&');
269
+	"url=".rawurlencode(self('&', true)), '&');
271 270
 
272 271
 	// un echec au "bonjour" (login initial) quand le statut est
273 272
 	// inconnu signale sans doute un probleme de cookies
@@ -290,7 +289,7 @@  discard block
 block discarded – undo
290 289
  * @param array $row
291 290
  * @param null|string $date
292 291
  */
293
-function auth_trace($row, $date=null)
292
+function auth_trace($row, $date = null)
294 293
 {
295 294
 	// Indiquer la connexion. A la minute pres ca suffit.
296 295
 	if (!is_numeric($connect_quand = $row['quand']))
@@ -299,12 +298,12 @@  discard block
 block discarded – undo
299 298
 	if (is_null($date))
300 299
 		$date = date('Y-m-d H:i:s');
301 300
 
302
-	if (abs(strtotime($date) - $connect_quand)  >= 60) {
303
-		sql_updateq("spip_auteurs", array("en_ligne" => $date), "id_auteur=" .$row['id_auteur']);
301
+	if (abs(strtotime($date) - $connect_quand) >= 60) {
302
+		sql_updateq("spip_auteurs", array("en_ligne" => $date), "id_auteur=".$row['id_auteur']);
304 303
 		$row['en_ligne'] = $date;
305 304
 	}
306 305
 
307
-	pipeline('trig_auth_trace',array('args'=>array('row'=>$row,'date'=>$date)));
306
+	pipeline('trig_auth_trace', array('args'=>array('row'=>$row, 'date'=>$date)));
308 307
 }
309 308
 
310 309
 
@@ -319,16 +318,16 @@  discard block
 block discarded – undo
319 318
  * @param mixed $defaut
320 319
  * @return mixed
321 320
  */
322
-function auth_administrer($fonction,$args,$defaut=false){
321
+function auth_administrer($fonction, $args, $defaut = false) {
323 322
 	$auth_methode = array_shift($args);
324 323
 	$auth_methode = $auth_methode ? $auth_methode : 'spip'; // valeur par defaut au cas ou
325
-	if ($auth = charger_fonction($auth_methode,'auth',true)
326
-		AND function_exists($f="auth_{$auth_methode}_$fonction")
324
+	if ($auth = charger_fonction($auth_methode, 'auth', true)
325
+		AND function_exists($f = "auth_{$auth_methode}_$fonction")
327 326
 	)
328 327
 		$res = call_user_func_array($f, $args);
329 328
 	else
330 329
 		$res = $defaut;
331
-	$res = pipeline('auth_administrer',array(
330
+	$res = pipeline('auth_administrer', array(
332 331
 		'args' => array(
333 332
 			'fonction' => $fonction,
334 333
 			'methode' => $auth_methode,
@@ -345,9 +344,9 @@  discard block
 block discarded – undo
345 344
  * @param array $flux
346 345
  * @return array
347 346
  */
348
-function auth_formulaire_login($flux){
347
+function auth_formulaire_login($flux) {
349 348
 	foreach ($GLOBALS['liste_des_authentifications'] as $methode)
350
-		$flux = auth_administrer('formulaire_login',array($methode,$flux),$flux);
349
+		$flux = auth_administrer('formulaire_login', array($methode, $flux), $flux);
351 350
 	return $flux;
352 351
 }
353 352
 
@@ -362,7 +361,7 @@  discard block
 block discarded – undo
362 361
  * @param string $serveur
363 362
  * @return string/bool
364 363
  */
365
-function auth_retrouver_login($login, $serveur=''){
364
+function auth_retrouver_login($login, $serveur = '') {
366 365
 	if (!spip_connect($serveur)) {
367 366
 		include_spip('inc/minipres');
368 367
 		echo minipres(_T('info_travaux_titre'),
@@ -371,7 +370,7 @@  discard block
 block discarded – undo
371 370
 	}
372 371
 
373 372
 	foreach ($GLOBALS['liste_des_authentifications'] as $methode) {
374
-		if ($auteur = auth_administrer('retrouver_login',array($methode, $login, $serveur))) {
373
+		if ($auteur = auth_administrer('retrouver_login', array($methode, $login, $serveur))) {
375 374
 			return $auteur;
376 375
 		}
377 376
 	}
@@ -390,10 +389,10 @@  discard block
 block discarded – undo
390 389
  * @param string $serveur
391 390
  * @return array
392 391
  */
393
-function auth_informer_login($login, $serveur=''){
392
+function auth_informer_login($login, $serveur = '') {
394 393
 	if (!$login
395 394
 		OR !$login = auth_retrouver_login($login, $serveur)
396
-		OR !$row = sql_fetsel('*','spip_auteurs','login='.sql_quote($login,$serveur,'text'),'','','','',$serveur)
395
+		OR !$row = sql_fetsel('*', 'spip_auteurs', 'login='.sql_quote($login, $serveur, 'text'), '', '', '', '', $serveur)
397 396
 		)
398 397
 		return array();
399 398
 
@@ -406,13 +405,13 @@  discard block
 block discarded – undo
406 405
 	);
407 406
 
408 407
 	// desactiver le hash md5 si pas auteur spip ?
409
-	if ($row['source']!=='spip'){
410
-		$row['alea_actuel']= '';
411
-		$row['alea_futur']= '';
408
+	if ($row['source'] !== 'spip') {
409
+		$row['alea_actuel'] = '';
410
+		$row['alea_futur'] = '';
412 411
 	}
413 412
 	verifier_visiteur();
414 413
 
415
-	return auth_administrer('informer_login',array($row['source'],$infos, $row, $serveur),$infos);
414
+	return auth_administrer('informer_login', array($row['source'], $infos, $row, $serveur), $infos);
416 415
 }
417 416
 
418 417
 
@@ -425,10 +424,10 @@  discard block
 block discarded – undo
425 424
  * @param string $serveur
426 425
  * @return mixed
427 426
  */
428
-function auth_identifier_login($login, $password, $serveur=''){
427
+function auth_identifier_login($login, $password, $serveur = '') {
429 428
 	$erreur = "";
430 429
 	foreach ($GLOBALS['liste_des_authentifications'] as $methode) {
431
-		if ($auth = charger_fonction($methode, 'auth',true)){
430
+		if ($auth = charger_fonction($methode, 'auth', true)) {
432 431
 			$auteur = $auth($login, $password, $serveur);
433 432
 			if (is_array($auteur) AND count($auteur)) {
434 433
 				spip_log("connexion de $login par methode $methode");
@@ -452,14 +451,14 @@  discard block
 block discarded – undo
452 451
  * @param string $serveur
453 452
  * @return string
454 453
  */
455
-function auth_url_retour_login($auth_methode, $login, $redirect='', $serveur=''){
456
-	$securiser_action = charger_fonction('securiser_action','inc');
454
+function auth_url_retour_login($auth_methode, $login, $redirect = '', $serveur = '') {
455
+	$securiser_action = charger_fonction('securiser_action', 'inc');
457 456
 	return $securiser_action('auth', "$auth_methode/$login", $redirect, true);
458 457
 }
459 458
 
460
-function auth_terminer_identifier_login($auth_methode, $login, $serveur=''){
459
+function auth_terminer_identifier_login($auth_methode, $login, $serveur = '') {
461 460
 	$args = func_get_args();
462
-	$auteur = auth_administrer('terminer_identifier_login',$args);
461
+	$auteur = auth_administrer('terminer_identifier_login', $args);
463 462
 	return $auteur;
464 463
 }
465 464
 
@@ -469,7 +468,7 @@  discard block
 block discarded – undo
469 468
  * @param array $auteur
470 469
  * @return bool
471 470
  */
472
-function auth_loger($auteur){
471
+function auth_loger($auteur) {
473 472
 	if (!is_array($auteur) OR !count($auteur))
474 473
 		return false;
475 474
 
@@ -483,7 +482,7 @@  discard block
 block discarded – undo
483 482
 
484 483
 	sql_updateq('spip_auteurs',
485 484
 	            array('prefs' => serialize($p)),
486
-	            "id_auteur=" . $auteur['id_auteur']);
485
+	            "id_auteur=".$auteur['id_auteur']);
487 486
 
488 487
 	// Si on est admin, poser le cookie de correspondance
489 488
 	include_spip('inc/cookie');
@@ -493,7 +492,7 @@  discard block
 block discarded – undo
493 492
 	}
494 493
 	// sinon le supprimer ...
495 494
 	else {
496
-		spip_setcookie('spip_admin', '',1);
495
+		spip_setcookie('spip_admin', '', 1);
497 496
 	}
498 497
 
499 498
 	//  bloquer ici le visiteur qui tente d'abuser de ses droits
@@ -502,8 +501,8 @@  discard block
 block discarded – undo
502 501
 }
503 502
 
504 503
 
505
-function auth_deloger(){
506
-	$logout = charger_fonction('logout','action');
504
+function auth_deloger() {
505
+	$logout = charger_fonction('logout', 'action');
507 506
 	$logout();
508 507
 }
509 508
 
@@ -515,9 +514,9 @@  discard block
 block discarded – undo
515 514
  * @param string $serveur
516 515
  * @return bool
517 516
  */
518
-function auth_autoriser_modifier_login($auth_methode, $serveur=''){
517
+function auth_autoriser_modifier_login($auth_methode, $serveur = '') {
519 518
 	$args = func_get_args();
520
-	return auth_administrer('autoriser_modifier_login',$args);
519
+	return auth_administrer('autoriser_modifier_login', $args);
521 520
 }
522 521
 
523 522
 /**
@@ -531,9 +530,9 @@  discard block
 block discarded – undo
531 530
  * @return string
532 531
  *  message d'erreur ou chaine vide si pas d'erreur
533 532
  */
534
-function auth_verifier_login($auth_methode, $new_login, $id_auteur=0, $serveur=''){
533
+function auth_verifier_login($auth_methode, $new_login, $id_auteur = 0, $serveur = '') {
535 534
 	$args = func_get_args();
536
-	return auth_administrer('verifier_login',$args,'');
535
+	return auth_administrer('verifier_login', $args, '');
537 536
 }
538 537
 
539 538
 /**
@@ -545,9 +544,9 @@  discard block
 block discarded – undo
545 544
  * @param string $serveur
546 545
  * @return bool
547 546
  */
548
-function auth_modifier_login($auth_methode, $new_login, $id_auteur, $serveur=''){
547
+function auth_modifier_login($auth_methode, $new_login, $id_auteur, $serveur = '') {
549 548
 	$args = func_get_args();
550
-	return auth_administrer('modifier_login',$args);
549
+	return auth_administrer('modifier_login', $args);
551 550
 }
552 551
 
553 552
 /**
@@ -559,9 +558,9 @@  discard block
 block discarded – undo
559 558
  * @return bool
560 559
  *	succes ou echec
561 560
  */
562
-function auth_autoriser_modifier_pass($auth_methode, $serveur=''){
561
+function auth_autoriser_modifier_pass($auth_methode, $serveur = '') {
563 562
 	$args = func_get_args();
564
-	return auth_administrer('autoriser_modifier_pass',$args);
563
+	return auth_administrer('autoriser_modifier_pass', $args);
565 564
 }
566 565
 
567 566
 /**
@@ -576,9 +575,9 @@  discard block
 block discarded – undo
576 575
  * @return string
577 576
  *	message d'erreur ou chaine vide si pas d'erreur
578 577
  */
579
-function auth_verifier_pass($auth_methode, $login, $new_pass, $id_auteur=0, $serveur=''){
578
+function auth_verifier_pass($auth_methode, $login, $new_pass, $id_auteur = 0, $serveur = '') {
580 579
 	$args = func_get_args();
581
-	return auth_administrer('verifier_pass',$args,'');
580
+	return auth_administrer('verifier_pass', $args, '');
582 581
 }
583 582
 
584 583
 /**
@@ -593,9 +592,9 @@  discard block
 block discarded – undo
593 592
  * @return bool
594 593
  *	succes ou echec
595 594
  */
596
-function auth_modifier_pass($auth_methode, $login, $new_pass, $id_auteur, $serveur=''){
595
+function auth_modifier_pass($auth_methode, $login, $new_pass, $id_auteur, $serveur = '') {
597 596
 	$args = func_get_args();
598
-	return auth_administrer('modifier_pass',$args);
597
+	return auth_administrer('modifier_pass', $args);
599 598
 }
600 599
 
601 600
 /**
@@ -610,19 +609,19 @@  discard block
 block discarded – undo
610 609
  * @param string $serveur
611 610
  * @return void
612 611
  */
613
-function auth_synchroniser_distant($auth_methode=true, $id_auteur=0, $champs=array(), $options = array(), $serveur=''){
612
+function auth_synchroniser_distant($auth_methode = true, $id_auteur = 0, $champs = array(), $options = array(), $serveur = '') {
614 613
 	$args = func_get_args();
615
-	if ($auth_methode===true OR (isset($options['all']) AND $options['all']==true)){
614
+	if ($auth_methode === true OR (isset($options['all']) AND $options['all'] == true)) {
616 615
 		$options['all'] = true; // ajouter une option all=>true pour chaque auth
617 616
 		$args = array(true, $id_auteur, $champs, $options, $serveur);
618 617
 		foreach ($GLOBALS['liste_des_authentifications'] as $methode) {
619 618
 			array_shift($args);
620
-			array_unshift($args,$methode);
621
-			auth_administrer('synchroniser_distant',$args);
619
+			array_unshift($args, $methode);
620
+			auth_administrer('synchroniser_distant', $args);
622 621
 		}
623 622
 	}
624 623
 	else
625
-		auth_administrer('synchroniser_distant',$args);
624
+		auth_administrer('synchroniser_distant', $args);
626 625
 }
627 626
 
628 627
 
@@ -633,9 +632,9 @@  discard block
 block discarded – undo
633 632
  * @param string $serveur
634 633
  * @return array
635 634
  */
636
-function lire_php_auth($login, $pw, $serveur=''){
635
+function lire_php_auth($login, $pw, $serveur = '') {
637 636
 
638
-	$row = sql_fetsel('*', 'spip_auteurs', 'login=' . sql_quote($login,$serveur,'text'),'','','','',$serveur);
637
+	$row = sql_fetsel('*', 'spip_auteurs', 'login='.sql_quote($login, $serveur, 'text'), '', '', '', '', $serveur);
639 638
 
640 639
 	if (!$row) {
641 640
 		if (spip_connect_ldap($serveur)
@@ -649,7 +648,7 @@  discard block
 block discarded – undo
649 648
 		OR !$auth = charger_fonction($auth_methode, 'auth', true))
650 649
 		$auth = charger_fonction('spip', 'auth', true);
651 650
 
652
-	$auteur='';
651
+	$auteur = '';
653 652
 	if ($auth)
654 653
 		$auteur = $auth($login, $pw, $serveur, true);
655 654
 	// verifier que ce n'est pas un message d'erreur
@@ -668,22 +667,22 @@  discard block
 block discarded – undo
668 667
  * @param string $re
669 668
  * @param string $lien
670 669
  */
671
-function ask_php_auth($pb, $raison, $retour='', $url='', $re='', $lien='') {
670
+function ask_php_auth($pb, $raison, $retour = '', $url = '', $re = '', $lien = '') {
672 671
 	@Header("WWW-Authenticate: Basic realm=\"espace prive\"");
673 672
 	@Header("HTTP/1.0 401 Unauthorized");
674 673
 	$corps = "";
675 674
 	$public = generer_url_public();
676 675
 	$ecrire = generer_url_ecrire();
677
-	$retour = $retour?$retour:_T('icone_retour');
676
+	$retour = $retour ? $retour : _T('icone_retour');
678 677
 	$corps .= "<p>$raison</p>[<a href='$public'>$retour</a>] ";
679 678
 	if ($url) {
680
-		$corps .= "[<a href='" . generer_url_action('cookie',"essai_auth_http=oui&$url") . "'>$re</a>]";
679
+		$corps .= "[<a href='".generer_url_action('cookie', "essai_auth_http=oui&$url")."'>$re</a>]";
681 680
 	}
682 681
 
683 682
 	if ($lien)
684 683
 		$corps .= " [<a href='$ecrire'>"._T('login_espace_prive')."</a>]";
685 684
 	include_spip('inc/minipres');
686
-	echo minipres($pb,$corps);
685
+	echo minipres($pb, $corps);
687 686
 	exit;
688 687
 }
689 688
 ?>
Please login to merge, or discard this patch.
ecrire/inc/drapeau_edition.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -29,12 +29,12 @@  discard block
 block discarded – undo
29 29
 
30 30
 
31 31
 // http://doc.spip.org/@lire_tableau_edition
32
-function lire_tableau_edition () {
32
+function lire_tableau_edition() {
33 33
 	$edition = @unserialize($GLOBALS['meta']['drapeau_edition']);
34 34
 	if (!$edition) return array();
35 35
 	$changed = false;
36 36
 
37
-	$bon_pour_le_service = time()-3600;
37
+	$bon_pour_le_service = time() - 3600;
38 38
 	// parcourir le tableau et virer les vieux
39 39
 	foreach ($edition as $objet => $data) {
40 40
 		if (!is_array($data))
@@ -78,10 +78,10 @@  discard block
 block discarded – undo
78 78
  * @param string $type
79 79
  * @return mixed
80 80
  */
81
-function signale_edition ($id, $auteur, $type='article') {
81
+function signale_edition($id, $auteur, $type = 'article') {
82 82
 	include_spip('base/objets');
83 83
 	include_spip('inc/filtres');
84
-	if (objet_info($type,'editable')!=='oui')
84
+	if (objet_info($type, 'editable') !== 'oui')
85 85
 		return;
86 86
 
87 87
 	$edition = lire_tableau_edition();
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
 
98 98
 // Qui edite mon objet ?
99 99
 // http://doc.spip.org/@qui_edite
100
-function qui_edite ($id, $type='article') {
100
+function qui_edite($id, $type = 'article') {
101 101
 
102 102
 	$edition = lire_tableau_edition();
103 103
 
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
 }
106 106
 
107 107
 // http://doc.spip.org/@mention_qui_edite
108
-function mention_qui_edite ($id, $type='article') {
108
+function mention_qui_edite($id, $type = 'article') {
109 109
 	$modif = qui_edite($id, $type);
110 110
 	unset($modif[$GLOBALS['visiteur_session']['id_auteur']]);
111 111
 
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 		// format lie a la chaine de langue 'avis_article_modifie'
119 119
 		return array(
120 120
 			'nom_auteur_modif' => join(' | ', $auteurs),
121
-			'date_diff' => ceil((time()-$quand) / 60)
121
+			'date_diff' => ceil((time() - $quand) / 60)
122 122
 		);
123 123
 	}
124 124
 }
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
  * @param $id_auteur
132 132
  * @return array
133 133
  */
134
-function liste_drapeau_edition ($id_auteur) {
134
+function liste_drapeau_edition($id_auteur) {
135 135
 	$edition = lire_tableau_edition();
136 136
 	$objets_ouverts = array();
137 137
 
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
 		{
141 141
 			if (isset($auteurs[$id_auteur])
142 142
 			AND is_array($auteurs[$id_auteur]) // precaution
143
-			AND (array_pop($auteurs[$id_auteur]) > time()-3600)) {
143
+			AND (array_pop($auteurs[$id_auteur]) > time() - 3600)) {
144 144
 				$objets_ouverts[] = array(
145 145
 					'objet'=>$objet,
146 146
 					'id_objet' => $id,
@@ -167,10 +167,10 @@  discard block
 block discarded – undo
167 167
 
168 168
 // quand l'auteur libere un objet precis
169 169
 // http://doc.spip.org/@debloquer_edition
170
-function debloquer_edition($id_auteur, $id_objet, $type='article') {
170
+function debloquer_edition($id_auteur, $id_objet, $type = 'article') {
171 171
 	$edition = lire_tableau_edition();
172 172
 
173
-	foreach ($edition as $objet => $data){
173
+	foreach ($edition as $objet => $data) {
174 174
 		if ($objet == $type) {
175 175
 			foreach ($data as $id => $auteurs)
176 176
 			{
Please login to merge, or discard this patch.
ecrire/inc/idna_convert.class.php 1 patch
Spacing   +43 added lines, -46 removed lines patch added patch discarded remove patch
@@ -73,16 +73,16 @@  discard block
 block discarded – undo
73 73
     protected $_lcount = 19;
74 74
     protected $_vcount = 21;
75 75
     protected $_tcount = 28;
76
-    protected $_ncount = 588;   // _vcount * _tcount
76
+    protected $_ncount = 588; // _vcount * _tcount
77 77
     protected $_scount = 11172; // _lcount * _tcount * _vcount
78 78
     protected $_error = false;
79 79
     protected static $_mb_string_overload = null;
80 80
     // See {@link set_paramter()} for details of how to change the following
81 81
     // settings from within your script / application
82
-    protected $_api_encoding = 'utf8';   // Default input charset is UTF-8
83
-    protected $_allow_overlong = false;  // Overlong UTF-8 encodings are forbidden
84
-    protected $_strict_mode = false;     // Behave strict or not
85
-    protected $_idn_version = 2003;      // Can be either 2003 (old, default) or 2008
82
+    protected $_api_encoding = 'utf8'; // Default input charset is UTF-8
83
+    protected $_allow_overlong = false; // Overlong UTF-8 encodings are forbidden
84
+    protected $_strict_mode = false; // Behave strict or not
85
+    protected $_idn_version = 2003; // Can be either 2003 (old, default) or 2008
86 86
 
87 87
     /**
88 88
      * the constructor
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
                             $this->_api_encoding = $v;
141 141
                             break;
142 142
                         default:
143
-                            $this->_error('Set Parameter: Unknown parameter ' . $v . ' for option ' . $k);
143
+                            $this->_error('Set Parameter: Unknown parameter '.$v.' for option '.$k);
144 144
                             return false;
145 145
                     }
146 146
                     break;
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
                     if (in_array($v, array('2003', '2008'))) {
155 155
                         $this->_idn_version = $v;
156 156
                     } else {
157
-                        $this->_error('Set Parameter: Unknown parameter ' . $v . ' for option ' . $k);
157
+                        $this->_error('Set Parameter: Unknown parameter '.$v.' for option '.$k);
158 158
                     }
159 159
                     break;
160 160
                 case 'encode_german_sz': // Deprecated
@@ -165,7 +165,7 @@  discard block
 block discarded – undo
165 165
                     }
166 166
                     break;
167 167
                 default:
168
-                    $this->_error('Set Parameter: Unknown option ' . $k);
168
+                    $this->_error('Set Parameter: Unknown option '.$k);
169 169
                     return false;
170 170
             }
171 171
         }
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
                 case 'ucs4_array':
189 189
                     break;
190 190
                 default:
191
-                    $this->_error('Unknown encoding ' . $one_time_encoding);
191
+                    $this->_error('Unknown encoding '.$one_time_encoding);
192 192
                     return false;
193 193
             }
194 194
         }
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
             list ($email_pref, $input) = explode('@', $input, 2);
207 207
             $arr = explode('.', $input);
208 208
             foreach ($arr as $k => $v) {
209
-                if (preg_match('!^' . preg_quote($this->_punycode_prefix, '!') . '!', $v)) {
209
+                if (preg_match('!^'.preg_quote($this->_punycode_prefix, '!').'!', $v)) {
210 210
                     $conv = $this->_decode($v);
211 211
                     if ($conv) {
212 212
                         $arr[$k] = $conv;
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
             $input = join('.', $arr);
217 217
             $arr = explode('.', $email_pref);
218 218
             foreach ($arr as $k => $v) {
219
-                if (preg_match('!^' . preg_quote($this->_punycode_prefix, '!') . '!', $v)) {
219
+                if (preg_match('!^'.preg_quote($this->_punycode_prefix, '!').'!', $v)) {
220 220
                     $conv = $this->_decode($v);
221 221
                     if ($conv) {
222 222
                         $arr[$k] = $conv;
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
                 }
225 225
             }
226 226
             $email_pref = join('.', $arr);
227
-            $return = $email_pref . '@' . $input;
227
+            $return = $email_pref.'@'.$input;
228 228
         } elseif (preg_match('![:\./]!', $input)) { // Or a complete domain name (with or without paths / parameters)
229 229
             // No no in strict mode
230 230
             if ($this->_strict_mode) {
@@ -241,13 +241,13 @@  discard block
 block discarded – undo
241 241
                     }
242 242
                 }
243 243
                 $parsed['host'] = join('.', $arr);
244
-                $return = (empty($parsed['scheme']) ? '' : $parsed['scheme'] . (strtolower($parsed['scheme']) == 'mailto' ? ':' : '://')).
245
-                        (empty($parsed['user']) ? '' : $parsed['user'] . (empty($parsed['pass']) ? '' : ':' . $parsed['pass']) . '@').
244
+                $return = (empty($parsed['scheme']) ? '' : $parsed['scheme'].(strtolower($parsed['scheme']) == 'mailto' ? ':' : '://')).
245
+                        (empty($parsed['user']) ? '' : $parsed['user'].(empty($parsed['pass']) ? '' : ':'.$parsed['pass']).'@').
246 246
                         $parsed['host'].
247
-                        (empty($parsed['port']) ? '' : ':' . $parsed['port']).
247
+                        (empty($parsed['port']) ? '' : ':'.$parsed['port']).
248 248
                         (empty($parsed['path']) ? '' : $parsed['path']).
249
-                        (empty($parsed['query']) ? '' : '?' . $parsed['query']).
250
-                        (empty($parsed['fragment']) ? '' : '#' . $parsed['fragment']);
249
+                        (empty($parsed['query']) ? '' : '?'.$parsed['query']).
250
+                        (empty($parsed['fragment']) ? '' : '#'.$parsed['fragment']);
251 251
             } else { // parse_url seems to have failed, try without it
252 252
                 $arr = explode('.', $input);
253 253
                 foreach ($arr as $k => $v) {
@@ -265,8 +265,8 @@  discard block
 block discarded – undo
265 265
         // The output is UTF-8 by default, other output formats need conversion here
266 266
         // If one time encoding is given, use this, else the objects property
267 267
         switch (($one_time_encoding) ? $one_time_encoding : $this->_api_encoding) {
268
-            case 'utf8':        return $return; // break;
269
-            case 'ucs4_string': return $this->_ucs4_to_ucs4_string($this->_utf8_to_ucs4($return));  // break;
268
+            case 'utf8' : return $return; // break;
269
+            case 'ucs4_string': return $this->_ucs4_to_ucs4_string($this->_utf8_to_ucs4($return)); // break;
270 270
             case 'ucs4_array':  return $this->_utf8_to_ucs4($return); // break;
271 271
             default:            $this->_error('Unsupported output format'); return false;
272 272
         }
@@ -283,15 +283,14 @@  discard block
 block discarded – undo
283 283
         // Forcing conversion of input to UCS4 array
284 284
         // If one time encoding is given, use this, else the objects property
285 285
         switch ($one_time_encoding ? $one_time_encoding : $this->_api_encoding) {
286
-            case 'utf8':
287
-                $decoded = $this->_utf8_to_ucs4($decoded);
286
+            case 'utf8' : $decoded = $this->_utf8_to_ucs4($decoded);
288 287
                 break;
289 288
             case 'ucs4_string':
290 289
                 $decoded = $this->_ucs4_string_to_ucs4($decoded);
291 290
             case 'ucs4_array':
292 291
                 break;
293 292
             default:
294
-                $this->_error('Unsupported input format: ' . ($one_time_encoding ? $one_time_encoding : $this->_api_encoding));
293
+                $this->_error('Unsupported input format: '.($one_time_encoding ? $one_time_encoding : $this->_api_encoding));
295 294
                 return false;
296 295
         }
297 296
 
@@ -380,13 +379,13 @@  discard block
 block discarded – undo
380 379
             }
381 380
         }
382 381
         $parsed['host'] = join('.', $arr);
383
-        $return = (empty($parsed['scheme']) ? '' : $parsed['scheme'] . (strtolower($parsed['scheme']) == 'mailto' ? ':' : '://')).
384
-                (empty($parsed['user']) ? '' : $parsed['user'] . (empty($parsed['pass']) ? '' : ':' . $parsed['pass']) . '@').
382
+        $return = (empty($parsed['scheme']) ? '' : $parsed['scheme'].(strtolower($parsed['scheme']) == 'mailto' ? ':' : '://')).
383
+                (empty($parsed['user']) ? '' : $parsed['user'].(empty($parsed['pass']) ? '' : ':'.$parsed['pass']).'@').
385 384
                 $parsed['host'].
386
-                (empty($parsed['port']) ? '' : ':' . $parsed['port']).
385
+                (empty($parsed['port']) ? '' : ':'.$parsed['port']).
387 386
                 (empty($parsed['path']) ? '' : $parsed['path']).
388
-                (empty($parsed['query']) ? '' : '?' . $parsed['query']).
389
-                (empty($parsed['fragment']) ? '' : '#' . $parsed['fragment']);
387
+                (empty($parsed['query']) ? '' : '?'.$parsed['query']).
388
+                (empty($parsed['fragment']) ? '' : '#'.$parsed['fragment']);
390 389
         return $return;
391 390
     }
392 391
 
@@ -409,11 +408,11 @@  discard block
 block discarded – undo
409 408
     {
410 409
         $decoded = array();
411 410
         // find the Punycode prefix
412
-        if (!preg_match('!^' . preg_quote($this->_punycode_prefix, '!') . '!', $encoded)) {
411
+        if (!preg_match('!^'.preg_quote($this->_punycode_prefix, '!').'!', $encoded)) {
413 412
             $this->_error('This is not a punycode string');
414 413
             return false;
415 414
         }
416
-        $encode_test = preg_replace('!^' . preg_quote($this->_punycode_prefix, '!') . '!', '', $encoded);
415
+        $encode_test = preg_replace('!^'.preg_quote($this->_punycode_prefix, '!').'!', '', $encoded);
417 416
         // If nothing left after removing the prefix, it is hopeless
418 417
         if (!$encode_test) {
419 418
             $this->_error('The given encoded string was empty');
@@ -439,8 +438,7 @@  discard block
 block discarded – undo
439 438
             for ($old_idx = $idx, $w = 1, $k = $this->_base; 1; $k += $this->_base) {
440 439
                 $digit = $this->_decode_digit($encoded{$enco_idx++});
441 440
                 $idx += $digit * $w;
442
-                $t = ($k <= $bias) ? $this->_tmin :
443
-                        (($k >= $bias + $this->_tmax) ? $this->_tmax : ($k - $bias));
441
+                $t = ($k <= $bias) ? $this->_tmin : (($k >= $bias + $this->_tmax) ? $this->_tmax : ($k - $bias));
444 442
                 if ($digit < $t) {
445 443
                     break;
446 444
                 }
@@ -513,7 +511,7 @@  discard block
 block discarded – undo
513 511
             return $encoded; // All codepoints were basic ones
514 512
         }
515 513
         // Start with the prefix; copy it to output
516
-        $encoded = $this->_punycode_prefix . $encoded;
514
+        $encoded = $this->_punycode_prefix.$encoded;
517 515
         // If we have basic code points in output, add an hyphen to the end
518 516
         if ($codecount) {
519 517
             $encoded .= '-';
@@ -540,8 +538,7 @@  discard block
 block discarded – undo
540 538
                     $delta++;
541 539
                 } elseif ($decoded[$i] == $cur_code) {
542 540
                     for ($q = $delta, $k = $this->_base; 1; $k += $this->_base) {
543
-                        $t = ($k <= $bias) ? $this->_tmin :
544
-                                (($k >= $bias + $this->_tmax) ? $this->_tmax : $k - $bias);
541
+                        $t = ($k <= $bias) ? $this->_tmin : (($k >= $bias + $this->_tmax) ? $this->_tmax : $k - $bias);
545 542
                         if ($q < $t) {
546 543
                             break;
547 544
                         }
@@ -628,12 +625,12 @@  discard block
 block discarded – undo
628 625
             }
629 626
             // Try to find prohibited input
630 627
             if (in_array($v, self::$NP['prohibit']) || in_array($v, self::$NP['general_prohibited'])) {
631
-                $this->_error('NAMEPREP: Prohibited input U+' . sprintf('%08X', $v));
628
+                $this->_error('NAMEPREP: Prohibited input U+'.sprintf('%08X', $v));
632 629
                 return false;
633 630
             }
634 631
             foreach (self::$NP['prohibit_ranges'] as $range) {
635 632
                 if ($range[0] <= $v && $v <= $range[1]) {
636
-                    $this->_error('NAMEPREP: Prohibited input U+' . sprintf('%08X', $v));
633
+                    $this->_error('NAMEPREP: Prohibited input U+'.sprintf('%08X', $v));
637 634
                     return false;
638 635
                 }
639 636
             }
@@ -869,7 +866,7 @@  discard block
 block discarded – undo
869 866
                 $output[$out_len] = $v;
870 867
                 ++$out_len;
871 868
                 if ('add' == $mode) {
872
-                    $this->_error('Conversion from UTF-8 to UCS-4 failed: malformed input at byte ' . $k);
869
+                    $this->_error('Conversion from UTF-8 to UCS-4 failed: malformed input at byte '.$k);
873 870
                     return false;
874 871
                 }
875 872
                 continue;
@@ -894,7 +891,7 @@  discard block
 block discarded – undo
894 891
                     $next_byte = 4;
895 892
                     $v = ($v - 252) << 30;
896 893
                 } else {
897
-                    $this->_error('This might be UTF-8, but I don\'t understand it at byte ' . $k);
894
+                    $this->_error('This might be UTF-8, but I don\'t understand it at byte '.$k);
898 895
                     return false;
899 896
                 }
900 897
                 if ('add' == $mode) {
@@ -907,7 +904,7 @@  discard block
 block discarded – undo
907 904
                 if (!$this->_allow_overlong && $test == 'range') {
908 905
                     $test = 'none';
909 906
                     if (($v < 0xA0 && $start_byte == 0xE0) || ($v < 0x90 && $start_byte == 0xF0) || ($v > 0x8F && $start_byte == 0xF4)) {
910
-                        $this->_error('Bogus UTF-8 character detected (out of legal range) at byte ' . $k);
907
+                        $this->_error('Bogus UTF-8 character detected (out of legal range) at byte '.$k);
911 908
                         return false;
912 909
                     }
913 910
                 }
@@ -916,7 +913,7 @@  discard block
 block discarded – undo
916 913
                     $output[($out_len - 1)] += $v;
917 914
                     --$next_byte;
918 915
                 } else {
919
-                    $this->_error('Conversion from UTF-8 to UCS-4 failed: malformed input at byte ' . $k);
916
+                    $this->_error('Conversion from UTF-8 to UCS-4 failed: malformed input at byte '.$k);
920 917
                     return false;
921 918
                 }
922 919
                 if ($next_byte < 0) {
@@ -940,13 +937,13 @@  discard block
 block discarded – undo
940 937
             if ($v < 128) { // 7bit are transferred literally
941 938
                 $output .= chr($v);
942 939
             } elseif ($v < (1 << 11)) { // 2 bytes
943
-                $output .= chr(192 + ($v >> 6)) . chr(128 + ($v & 63));
940
+                $output .= chr(192 + ($v >> 6)).chr(128 + ($v & 63));
944 941
             } elseif ($v < (1 << 16)) { // 3 bytes
945
-                $output .= chr(224 + ($v >> 12)) . chr(128 + (($v >> 6) & 63)) . chr(128 + ($v & 63));
942
+                $output .= chr(224 + ($v >> 12)).chr(128 + (($v >> 6) & 63)).chr(128 + ($v & 63));
946 943
             } elseif ($v < (1 << 21)) { // 4 bytes
947
-                $output .= chr(240 + ($v >> 18)) . chr(128 + (($v >> 12) & 63)) . chr(128 + (($v >> 6) & 63)) . chr(128 + ($v & 63));
944
+                $output .= chr(240 + ($v >> 18)).chr(128 + (($v >> 12) & 63)).chr(128 + (($v >> 6) & 63)).chr(128 + ($v & 63));
948 945
             } else {
949
-                $this->_error('Conversion from UCS-4 to UTF-8 failed: malformed input at byte ' . $k);
946
+                $this->_error('Conversion from UCS-4 to UTF-8 failed: malformed input at byte '.$k);
950 947
                 return false;
951 948
             }
952 949
         }
@@ -965,7 +962,7 @@  discard block
 block discarded – undo
965 962
         // Take array values and split output to 4 bytes per value
966 963
         // The bit mask is 255, which reads &11111111
967 964
         foreach ($input as $v) {
968
-            $output .= chr(($v >> 24) & 255) . chr(($v >> 16) & 255) . chr(($v >> 8) & 255) . chr($v & 255);
965
+            $output .= chr(($v >> 24) & 255).chr(($v >> 16) & 255).chr(($v >> 8) & 255).chr($v & 255);
969 966
         }
970 967
         return $output;
971 968
     }
@@ -995,7 +992,7 @@  discard block
 block discarded – undo
995 992
                 $out_len++;
996 993
                 $output[$out_len] = 0;
997 994
             }
998
-            $output[$out_len] += ord($input{$i}) << (8 * (3 - ($i % 4) ) );
995
+            $output[$out_len] += ord($input{$i}) << (8 * (3 - ($i % 4)));
999 996
         }
1000 997
         return $output;
1001 998
     }
Please login to merge, or discard this patch.
ecrire/inc/nfslock.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -87,15 +87,15 @@  discard block
 block discarded – undo
87 87
 if (!defined('_ECRIRE_INC_VERSION')) return;
88 88
 
89 89
 include_spip('inc/acces');
90
-define('_DEFAULT_LOCKTIME',60);
91
-define('_NAME_LOCK','spip_nfs_lock');
90
+define('_DEFAULT_LOCKTIME', 60);
91
+define('_NAME_LOCK', 'spip_nfs_lock');
92 92
 
93 93
 // http://doc.spip.org/@spip_nfslock
94
-function spip_nfslock($fichier,$max_age=0) {
94
+function spip_nfslock($fichier, $max_age = 0) {
95 95
 	$tries = 0;
96 96
 		
97 97
 	if (!$max_age) $max_age = _DEFAULT_LOCKTIME;
98
-	$lock_file = _DIR_TMP . _NAME_LOCK . "-" . substr(md5($fichier),0,8);
98
+	$lock_file = _DIR_TMP._NAME_LOCK."-".substr(md5($fichier), 0, 8);
99 99
 
100 100
   
101 101
 	/*
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 		if (link($tpath, $lock_file) == 1) {
127 127
 			spip_unlink($tpath); /* got it! */
128 128
 			@fclose($tmpfd);
129
-			if (($our_tmp = lstat($lock_file))==false) {	/* stat failed... shouldn't happen */
129
+			if (($our_tmp = lstat($lock_file)) == false) {	/* stat failed... shouldn't happen */
130 130
 				spip_unlink($lock_file);
131 131
 				return false; // (NFSL_SYSF);
132 132
 			}
@@ -141,11 +141,11 @@  discard block
 block discarded – undo
141 141
 		 */
142 142
 
143 143
 		$old_stat = lstat($lock_file);
144
-		if (@fputs($tmpfd, "zz", 2)!=2 || !$our_tmp=fstat($tmpfd))
144
+		if (@fputs($tmpfd, "zz", 2) != 2 || !$our_tmp = fstat($tmpfd))
145 145
 			break; /* something bogus is going on */
146 146
 
147 147
 
148
-		if ($old_stat!=false && (($old_stat['ctime'] + $max_age) < $our_tmp['ctime'])) {
148
+		if ($old_stat != false && (($old_stat['ctime'] + $max_age) < $our_tmp['ctime'])) {
149 149
 			spip_unlink($lock_file); /* break the stale lock */
150 150
 			$tries++;
151 151
 			/* It is CRITICAL that we sleep after breaking
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 			 * another process and unlink it's newly-
154 154
 			 * created file.
155 155
 			 */
156
-			sleep(1+rand(0,4));
156
+			sleep(1 + rand(0, 4));
157 157
 			continue;
158 158
 		}
159 159
 
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 		 */
163 163
 
164 164
     $tries++;
165
-		sleep(1+rand(0,4));
165
+		sleep(1 + rand(0, 4));
166 166
   }
167 167
 
168 168
 	/*
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
  */
212 212
 
213 213
 // http://doc.spip.org/@spip_nfsunlock
214
-function spip_nfsunlock($fichier, $birth, $max_age=0, $test = false) {
214
+function spip_nfsunlock($fichier, $birth, $max_age = 0, $test = false) {
215 215
 	$id = creer_uniqid();
216 216
 	if (!$max_age) $max_age = _DEFAULT_LOCKTIME;
217 217
 
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 	 */
222 222
 
223 223
 	$tpath = _DIR_TMP."stime.$id";
224
-  $tmpfd = @fopen($tpath,'w');
224
+  $tmpfd = @fopen($tpath, 'w');
225 225
   if ((!$tmpfd)
226 226
     OR (@fputs($tmpfd, "zz", 2) != 2)
227 227
 		OR !($our_tmp = fstat($tmpfd))) {
@@ -231,14 +231,14 @@  discard block
 block discarded – undo
231 231
 		return false; //(NFSL_SYSF);
232 232
 	}
233 233
 
234
-	@fclose($tmpfd);		/* We don't need this once we have our_tmp.st_ctime. */
234
+	@fclose($tmpfd); /* We don't need this once we have our_tmp.st_ctime. */
235 235
 	spip_unlink($tpath);
236 236
 
237 237
 	/*
238 238
 	 * 2. make fullpath, a buffer for the full pathname of the lock file
239 239
 	 */
240 240
 
241
-	$lock_file = _DIR_TMP . _NAME_LOCK . "-" . substr(md5($fichier),0,8);
241
+	$lock_file = _DIR_TMP._NAME_LOCK."-".substr(md5($fichier), 0, 8);
242 242
 
243 243
 	/*
244 244
 	 * 3. If the ctime hasn't been modified, unlink the file and return. If the
@@ -247,15 +247,15 @@  discard block
 block discarded – undo
247 247
 	 *    tries to relock the file.
248 248
 	 */
249 249
 
250
-  if ( ($old_stat=@lstat($lock_file))	/* stat succeeds so file is there */
250
+  if (($old_stat = @lstat($lock_file))	/* stat succeeds so file is there */
251 251
 	  && ($old_stat['ctime'] == $birth)) {	/* hasn't been modified since birth */
252 252
 	  if (!$test)
253
-    	spip_unlink($lock_file);			/* so the lock is ours to remove */
254
-    if ($our_tmp['ctime'] >= $birth + $max_age){	/* the lock has expired */
253
+    	spip_unlink($lock_file); /* so the lock is ours to remove */
254
+    if ($our_tmp['ctime'] >= $birth + $max_age) {	/* the lock has expired */
255 255
     	if (!$test) return false; //(NFSL_LOST);
256
-      sleep(1+(random(0,4)));		/* so sleep a bit */
256
+      sleep(1 + (random(0, 4))); /* so sleep a bit */
257 257
     }
258
-		return true;//(NFSL_OK);			/* success */
258
+		return true; //(NFSL_OK);			/* success */
259 259
   }
260 260
 
261 261
 	/*
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
  */
291 291
 
292 292
 // http://doc.spip.org/@spip_nfslock_test
293
-function spip_nfslock_test($fichier, $birth, $max_age=0) {
293
+function spip_nfslock_test($fichier, $birth, $max_age = 0) {
294 294
 	return spip_nfsunlock($fichier, $birth, $max_age, true);
295 295
 }
296 296
 
Please login to merge, or discard this patch.
ecrire/inc/plonger.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -15,10 +15,10 @@  discard block
 block discarded – undo
15 15
 include_spip('inc/texte');
16 16
 
17 17
 // http://doc.spip.org/@inc_plonger_dist
18
-function inc_plonger_dist($id_rubrique, $idom="", $list=array(), $col = 1, $exclu=0, $do='aff') {
18
+function inc_plonger_dist($id_rubrique, $idom = "", $list = array(), $col = 1, $exclu = 0, $do = 'aff') {
19 19
 	global  $spip_lang_left;
20 20
 	
21
-	if ($list) $id_rubrique = $list[$col-1];
21
+	if ($list) $id_rubrique = $list[$col - 1];
22 22
 	
23 23
 	$ret = '';
24 24
 
@@ -33,24 +33,24 @@  discard block
 block discarded – undo
33 33
 			  "spip_rubriques AS rub1 LEFT JOIN spip_rubriques AS rub2 ON (rub1.id_rubrique = rub2.id_parent)",
34 34
 			  "rub1.id_parent = ".sql_quote($id_rubrique)."
35 35
 			AND rub1.id_rubrique!=".sql_quote($exclu)."
36
-			AND (rub2.id_rubrique IS NULL OR rub2.id_rubrique!=".sql_quote($exclu).")",  "", "0+rub1.titre,rub1.titre");
36
+			AND (rub2.id_rubrique IS NULL OR rub2.id_rubrique!=".sql_quote($exclu).")", "", "0+rub1.titre,rub1.titre");
37 37
 
38 38
 	while ($row = sql_fetch($res)) {
39
-		if (autoriser('voir','rubrique',$row['id_rubrique'])){
39
+		if (autoriser('voir', 'rubrique', $row['id_rubrique'])) {
40 40
 			$rub[$row['id_rubrique']]['enfants'] = $row['id_enfant'];
41 41
 			if ($row['id_parent'] == $id_rubrique) {
42 42
 				$t = trim(typo(supprimer_numero($row['titre'])));
43 43
 				if ($row['langue_choisie'] != 'oui')
44 44
 					$t .= ' <small title="'
45 45
 						.traduire_nom_langue($row['lang'])
46
-						.'">[' . $row['lang'] . ']</small>';
46
+						.'">['.$row['lang'].']</small>';
47 47
 					$ordre[$row['id_rubrique']] = $t;
48 48
 			}
49 49
 		}
50 50
 	}
51 51
 	$next = isset($list[$col]) ? $list[$col] : 0;
52 52
 	if ($ordre) {
53
-		$rec = generer_url_ecrire('plonger',"rac=$idom&exclus=$exclu&do=$do&col=".($col+1));
53
+		$rec = generer_url_ecrire('plonger', "rac=$idom&exclus=$exclu&do=$do&col=".($col + 1));
54 54
 		$info = generer_url_ecrire('informer', "type=rubrique&rac=$idom&do=$do&id=");
55 55
 		$args = "'$idom',this,$col,'$spip_lang_left','$info',event";
56 56
 		while (list($id, $titrebrut) = each($ordre)) {
@@ -60,10 +60,10 @@  discard block
 block discarded – undo
60 60
 			$classe1 = $id_rubrique ? 'petite-rubrique' : "petit-secteur";
61 61
 			if (isset($rub[$id]["enfants"])) {
62 62
 				$classe2 = " class='rub-ouverte'";
63
-				$url = "\nhref='$rec&amp;id=$id'" ;
64
-			} else {  $url = $classe2 = '' ; }
63
+				$url = "\nhref='$rec&amp;id=$id'";
64
+			} else {  $url = $classe2 = ''; }
65 65
 
66
-			$js_func = $do . '_selection_titre';
66
+			$js_func = $do.'_selection_titre';
67 67
 			$click = "\nonclick=\"changerhighlight(this.parentNode.parentNode.parentNode);\nreturn "
68 68
 			. (!is_array($list) ? ' false' 
69 69
 			   : "aff_selection_provisoire($id,$args)")
@@ -90,19 +90,19 @@  discard block
 block discarded – undo
90 90
 		}
91 91
 	}
92 92
 
93
-	$idom2 = $idom . "_col_".($col+1);
94
-	$left = ($col*150);
93
+	$idom2 = $idom."_col_".($col + 1);
94
+	$left = ($col * 150);
95 95
 
96 96
 	return http_img_pack("searching.gif", "*", "style='visibility: hidden; position: absolute; $spip_lang_left: "
97
-	. ($left-30)
97
+	. ($left - 30)
98 98
 	. "px; top: 2px; z-index: 2;' id='img_$idom2'")
99 99
 	. "<div style='width: 150px; height: 100%; overflow: auto; position: absolute; top: 0px; $spip_lang_left: "
100
-	.($left-150)
100
+	.($left - 150)
101 101
 	."px;'>"
102 102
 	. $ret
103 103
 	. "\n</div>\n<div id='$idom2'>"
104 104
 	. ($next
105
-	   ? inc_plonger_dist($id_rubrique, $idom, $list, $col+1, $exclu)
105
+	   ? inc_plonger_dist($id_rubrique, $idom, $list, $col + 1, $exclu)
106 106
 	   : "")
107 107
 	. "\n</div>";
108 108
 }
Please login to merge, or discard this patch.