Completed
Push — master ( 9e6c6c...4f71b3 )
by cam
01:12
created
ecrire/lang/public_fa.php 1 patch
Indentation   +110 added lines, -110 removed lines patch added patch discarded remove patch
@@ -4,118 +4,118 @@
 block discarded – undo
4 4
 // ** ne pas modifier le fichier **
5 5
 
6 6
 if (!defined('_ECRIRE_INC_VERSION')) {
7
-	return;
7
+    return;
8 8
 }
9 9
 
10 10
 $GLOBALS[$GLOBALS['idx_lang']] = array(
11 11
 
12
-	// A
13
-	'accueil_site' => 'پذيرش ',
14
-	'article' => 'مقاله',
15
-	'articles' => 'مقاله‌ها',
16
-	'articles_auteur' => 'مقاله‌هاى اين نويسنده',
17
-	'articles_populaires' => 'محبوب‌‌ ترين مقاله‌ها',
18
-	'articles_rubrique' => 'مقاله‌هاى اين بخش',
19
-	'aucun_article' => 'مقاله‌اى با اين نشانى وجود ندارد',
20
-	'aucun_auteur' => ' نويسنده‌اى با اين نشانى وجود ندارد',
21
-	'aucun_site' => 'سايتى با اين نشانى وجود ندارد',
22
-	'aucune_breve' => 'خبری با اين نشانى وجود ندارد',
23
-	'aucune_rubrique' => 'بخشى با اين نشانى وجود ندارد',
24
-	'auteur' => 'نويسنده',
25
-	'autres' => 'نويسندگان',
26
-	'autres_breves' => 'خبرهای ديگر',
27
-	'autres_groupes_mots_clefs' => 'گروه‌هاى ديگر واژه كليدها',
28
-	'autres_sites' => ' سايت‌هاى ديگر',
29
-
30
-	// B
31
-	'bonjour' => 'سلام',
32
-
33
-	// C
34
-	'commenter_site' => 'اظهار نظر در مورد اين سايت',
35
-	'contact' => 'تماس',
36
-	'copie_document_impossible' => 'روبرداری از اين سند ناممكن است',
37
-
38
-	// D
39
-	'date' => 'تاريخ',
40
-	'dernier_ajout' => 'آخرين افزوده',
41
-	'dernieres_breves' => 'آخرين خبرها',
42
-	'derniers_articles' => 'آخرين مقاله‌ها',
43
-	'derniers_commentaires' => 'آخرين نظرها',
44
-	'derniers_messages_forum' => 'آخرين پيامهاى منتشر شده در سخنگاه‌ها',
45
-
46
-	// E
47
-	'edition_mode_texte' => 'ويرايش با شيوه‌ ی متن',
48
-	'en_reponse' => 'در پاسخ به:',
49
-	'en_resume' => 'خلاصه',
50
-	'envoyer_message' => 'فرستادن پيام',
51
-	'espace_prive' => 'قسمت شخصى',
52
-
53
-	// F
54
-	'formats_acceptes' => 'فرمت‌های مورد قبول:@formats@. ',
55
-
56
-	// H
57
-	'hierarchie_site' => 'سلسله مراتب سايت',
58
-
59
-	// J
60
-	'jours' => 'روزها',
61
-
62
-	// L
63
-	'lien_connecter' => 'اتصال',
64
-
65
-	// M
66
-	'meme_auteur' => 'از همين نويسنده',
67
-	'meme_rubrique' => 'در همان بخش',
68
-	'memes_auteurs' => 'از همين نويسندگان',
69
-	'message' => 'پيام',
70
-	'messages_forum' => 'پيام‌ها',
71
-	'messages_recents' => 'تازه ترين پيامهاى سخنگاه',
72
-	'mots_clef' => 'كليدواژه',
73
-	'mots_clefs' => 'واژه كليدها',
74
-	'mots_clefs_meme_groupe' => 'واژه كليدهاى يك گروه',
75
-
76
-	// N
77
-	'navigation' => 'شبكه نوردى',
78
-	'nom' => 'نام',
79
-	'nouveautes' => 'تازه‌ها',
80
-	'nouveautes_web' => 'تازه‌هاى وب',
81
-	'nouveaux_articles' => 'مقاله‌هاى تازه',
82
-	'nouvelles_breves' => 'خبرهاى تازه',
83
-
84
-	// P
85
-	'page_precedente' => 'صفحه ى پيشين',
86
-	'page_suivante' => 'صفحه‌ى بعدى',
87
-	'par_auteur' => 'بوسيله‌ى',
88
-	'participer_site' => 'مي‌توانيد با ثبت نام در اين سايت و ارايه‌ مقاله‌هايتان در فعاليت‌های اين سايت شركت كنيد. به محض ثبت نام، كد ورود به قسمت شخصی سايت با ايميل برای شما ارسال می شود.',
89
-	'plan_site' => 'نقشه‌ى سايت',
90
-	'popularite' => 'محبوبيت سايت',
91
-	'poster_message' => 'يك پيام بفرستيد',
92
-	'proposer_site' => 'مي‌توانيد در اين بخش يك سايت پيشنهاد كنيد:',
93
-
94
-	// R
95
-	'repondre_article' => 'پاسخ به اين مقاله',
96
-	'repondre_breve' => 'پاسخ به اين خبر',
97
-	'resultats_recherche' => 'نتيجه‌ى جستجو',
98
-	'retour_debut_forums' => 'بازگشت به ابتداى سخنگاه‌ها',
99
-	'rubrique' => 'بخش',
100
-	'rubriques' => 'بخش‌ها',
101
-
102
-	// S
103
-	'signatures_petition' => 'امضاها',
104
-	'site_realise_avec_spip' => 'سايت با اسپيپ درست شده است',
105
-	'sites_web' => 'وب سايت‌ها',
106
-	'sous_rubriques' => 'زيربخش‌ها',
107
-	'spam' => 'اسپم',
108
-	'suite' => 'دنباله',
109
-	'sur_web' => 'در تارنما',
110
-	'syndiquer_rubrique' => 'مشترک سازی اين بخش',
111
-	'syndiquer_site' => 'مشترک سازی تمام سايت',
112
-
113
-	// T
114
-	'texte_lettre_information' => 'نامه‌ى اطلاع رسانى سايت',
115
-	'texte_lettre_information_2' => 'نامه سرشمارى تازه‌هاي منتشر شده از :',
116
-
117
-	// V
118
-	'ver_imprimer' => 'نسخه‌ى چاپى',
119
-	'voir_en_ligne' => 'آنلاين بنگريد',
120
-	'voir_squelette' => 'اسكلت اين صفحه را ببينيد'
12
+    // A
13
+    'accueil_site' => 'پذيرش ',
14
+    'article' => 'مقاله',
15
+    'articles' => 'مقاله‌ها',
16
+    'articles_auteur' => 'مقاله‌هاى اين نويسنده',
17
+    'articles_populaires' => 'محبوب‌‌ ترين مقاله‌ها',
18
+    'articles_rubrique' => 'مقاله‌هاى اين بخش',
19
+    'aucun_article' => 'مقاله‌اى با اين نشانى وجود ندارد',
20
+    'aucun_auteur' => ' نويسنده‌اى با اين نشانى وجود ندارد',
21
+    'aucun_site' => 'سايتى با اين نشانى وجود ندارد',
22
+    'aucune_breve' => 'خبری با اين نشانى وجود ندارد',
23
+    'aucune_rubrique' => 'بخشى با اين نشانى وجود ندارد',
24
+    'auteur' => 'نويسنده',
25
+    'autres' => 'نويسندگان',
26
+    'autres_breves' => 'خبرهای ديگر',
27
+    'autres_groupes_mots_clefs' => 'گروه‌هاى ديگر واژه كليدها',
28
+    'autres_sites' => ' سايت‌هاى ديگر',
29
+
30
+    // B
31
+    'bonjour' => 'سلام',
32
+
33
+    // C
34
+    'commenter_site' => 'اظهار نظر در مورد اين سايت',
35
+    'contact' => 'تماس',
36
+    'copie_document_impossible' => 'روبرداری از اين سند ناممكن است',
37
+
38
+    // D
39
+    'date' => 'تاريخ',
40
+    'dernier_ajout' => 'آخرين افزوده',
41
+    'dernieres_breves' => 'آخرين خبرها',
42
+    'derniers_articles' => 'آخرين مقاله‌ها',
43
+    'derniers_commentaires' => 'آخرين نظرها',
44
+    'derniers_messages_forum' => 'آخرين پيامهاى منتشر شده در سخنگاه‌ها',
45
+
46
+    // E
47
+    'edition_mode_texte' => 'ويرايش با شيوه‌ ی متن',
48
+    'en_reponse' => 'در پاسخ به:',
49
+    'en_resume' => 'خلاصه',
50
+    'envoyer_message' => 'فرستادن پيام',
51
+    'espace_prive' => 'قسمت شخصى',
52
+
53
+    // F
54
+    'formats_acceptes' => 'فرمت‌های مورد قبول:@formats@. ',
55
+
56
+    // H
57
+    'hierarchie_site' => 'سلسله مراتب سايت',
58
+
59
+    // J
60
+    'jours' => 'روزها',
61
+
62
+    // L
63
+    'lien_connecter' => 'اتصال',
64
+
65
+    // M
66
+    'meme_auteur' => 'از همين نويسنده',
67
+    'meme_rubrique' => 'در همان بخش',
68
+    'memes_auteurs' => 'از همين نويسندگان',
69
+    'message' => 'پيام',
70
+    'messages_forum' => 'پيام‌ها',
71
+    'messages_recents' => 'تازه ترين پيامهاى سخنگاه',
72
+    'mots_clef' => 'كليدواژه',
73
+    'mots_clefs' => 'واژه كليدها',
74
+    'mots_clefs_meme_groupe' => 'واژه كليدهاى يك گروه',
75
+
76
+    // N
77
+    'navigation' => 'شبكه نوردى',
78
+    'nom' => 'نام',
79
+    'nouveautes' => 'تازه‌ها',
80
+    'nouveautes_web' => 'تازه‌هاى وب',
81
+    'nouveaux_articles' => 'مقاله‌هاى تازه',
82
+    'nouvelles_breves' => 'خبرهاى تازه',
83
+
84
+    // P
85
+    'page_precedente' => 'صفحه ى پيشين',
86
+    'page_suivante' => 'صفحه‌ى بعدى',
87
+    'par_auteur' => 'بوسيله‌ى',
88
+    'participer_site' => 'مي‌توانيد با ثبت نام در اين سايت و ارايه‌ مقاله‌هايتان در فعاليت‌های اين سايت شركت كنيد. به محض ثبت نام، كد ورود به قسمت شخصی سايت با ايميل برای شما ارسال می شود.',
89
+    'plan_site' => 'نقشه‌ى سايت',
90
+    'popularite' => 'محبوبيت سايت',
91
+    'poster_message' => 'يك پيام بفرستيد',
92
+    'proposer_site' => 'مي‌توانيد در اين بخش يك سايت پيشنهاد كنيد:',
93
+
94
+    // R
95
+    'repondre_article' => 'پاسخ به اين مقاله',
96
+    'repondre_breve' => 'پاسخ به اين خبر',
97
+    'resultats_recherche' => 'نتيجه‌ى جستجو',
98
+    'retour_debut_forums' => 'بازگشت به ابتداى سخنگاه‌ها',
99
+    'rubrique' => 'بخش',
100
+    'rubriques' => 'بخش‌ها',
101
+
102
+    // S
103
+    'signatures_petition' => 'امضاها',
104
+    'site_realise_avec_spip' => 'سايت با اسپيپ درست شده است',
105
+    'sites_web' => 'وب سايت‌ها',
106
+    'sous_rubriques' => 'زيربخش‌ها',
107
+    'spam' => 'اسپم',
108
+    'suite' => 'دنباله',
109
+    'sur_web' => 'در تارنما',
110
+    'syndiquer_rubrique' => 'مشترک سازی اين بخش',
111
+    'syndiquer_site' => 'مشترک سازی تمام سايت',
112
+
113
+    // T
114
+    'texte_lettre_information' => 'نامه‌ى اطلاع رسانى سايت',
115
+    'texte_lettre_information_2' => 'نامه سرشمارى تازه‌هاي منتشر شده از :',
116
+
117
+    // V
118
+    'ver_imprimer' => 'نسخه‌ى چاپى',
119
+    'voir_en_ligne' => 'آنلاين بنگريد',
120
+    'voir_squelette' => 'اسكلت اين صفحه را ببينيد'
121 121
 );
Please login to merge, or discard this patch.
ecrire/inc/bandeau.php 1 patch
Indentation   +148 added lines, -148 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  **/
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 include_spip('inc/boutons');
@@ -37,33 +37,33 @@  discard block
 block discarded – undo
37 37
  *     Contexte
38 38
  **/
39 39
 function definir_barre_contexte($contexte = null) {
40
-	if (is_null($contexte)) {
41
-		$contexte = $_GET;
42
-	} elseif (is_string($contexte)) {
43
-		$contexte = unserialize($contexte);
44
-	}
45
-	if (!isset($contexte['id_rubrique']) and isset($contexte['exec'])) {
46
-		if (!function_exists('trouver_objet_exec')) {
47
-			include_spip('inc/pipelines_ecrire');
48
-		}
49
-		if ($e = trouver_objet_exec($contexte['exec'])) {
50
-			$_id = $e['id_table_objet'];
51
-			if (isset($contexte[$_id]) and $id = intval($contexte[$_id])) {
52
-				$table = $e['table_objet_sql'];
53
-				$row = sql_fetsel('*', $table, "$_id=" . intval($id));
54
-				if (isset($row['id_rubrique'])) {
55
-					$contexte['id_rubrique'] = $row['id_rubrique'];
56
-					if (isset($row['id_secteur'])) {
57
-						$contexte['id_secteur'] = $row['id_secteur'];
58
-					}
59
-				} elseif (isset($row['id_groupe'])) {
60
-					// TODO supprimer ce bloc quand https://core.spip.net/issues/3844 sera réalisé
61
-					$contexte['id_groupe'] = $row['id_groupe'];
62
-				}
63
-			}
64
-		}
65
-	}
66
-	return $contexte;
40
+    if (is_null($contexte)) {
41
+        $contexte = $_GET;
42
+    } elseif (is_string($contexte)) {
43
+        $contexte = unserialize($contexte);
44
+    }
45
+    if (!isset($contexte['id_rubrique']) and isset($contexte['exec'])) {
46
+        if (!function_exists('trouver_objet_exec')) {
47
+            include_spip('inc/pipelines_ecrire');
48
+        }
49
+        if ($e = trouver_objet_exec($contexte['exec'])) {
50
+            $_id = $e['id_table_objet'];
51
+            if (isset($contexte[$_id]) and $id = intval($contexte[$_id])) {
52
+                $table = $e['table_objet_sql'];
53
+                $row = sql_fetsel('*', $table, "$_id=" . intval($id));
54
+                if (isset($row['id_rubrique'])) {
55
+                    $contexte['id_rubrique'] = $row['id_rubrique'];
56
+                    if (isset($row['id_secteur'])) {
57
+                        $contexte['id_secteur'] = $row['id_secteur'];
58
+                    }
59
+                } elseif (isset($row['id_groupe'])) {
60
+                    // TODO supprimer ce bloc quand https://core.spip.net/issues/3844 sera réalisé
61
+                    $contexte['id_groupe'] = $row['id_groupe'];
62
+                }
63
+            }
64
+        }
65
+    }
66
+    return $contexte;
67 67
 }
68 68
 
69 69
 /**
@@ -79,88 +79,88 @@  discard block
 block discarded – undo
79 79
  * @return array
80 80
  */
81 81
 function definir_barre_boutons($contexte = array(), $icones = true, $autorise = true) {
82
-	include_spip('inc/autoriser');
83
-	$boutons_admin = array();
82
+    include_spip('inc/autoriser');
83
+    $boutons_admin = array();
84 84
 
85
-	// les boutons du core, issus de ecrire/paquet.xml
86
-	$liste_boutons = array();
85
+    // les boutons du core, issus de ecrire/paquet.xml
86
+    $liste_boutons = array();
87 87
 
88
-	// ajouter les boutons issus des plugin via paquet.xml
89
-	if (function_exists('boutons_plugins')
90
-		and is_array($liste_boutons_plugins = boutons_plugins())
91
-	) {
92
-		$liste_boutons = &$liste_boutons_plugins;
93
-	}
88
+    // ajouter les boutons issus des plugin via paquet.xml
89
+    if (function_exists('boutons_plugins')
90
+        and is_array($liste_boutons_plugins = boutons_plugins())
91
+    ) {
92
+        $liste_boutons = &$liste_boutons_plugins;
93
+    }
94 94
 
95
-	foreach ($liste_boutons as $id => $infos) {
96
-		$parent = '';
97
-		// les boutons principaux ne sont pas soumis a autorisation
98
-		if (!isset($infos['parent'])
99
-			or !($parent = $infos['parent'])
100
-			or !$autorise
101
-			or autoriser('menu', "_$id", 0, null, array('contexte' => $contexte))
102
-		) {
103
-			if ($parent
104
-				and $parent = preg_replace(',^bando_,', 'menu_', $parent)
105
-				and isset($boutons_admin[$parent])
106
-			) {
107
-				if (!is_array($boutons_admin[$parent]->sousmenu)) {
108
-					$boutons_admin[$parent]->sousmenu = array();
109
-				}
110
-				$position = (isset($infos['position']) and strlen($infos['position'])) ? intval($infos['position']) : count($boutons_admin[$parent]->sousmenu);
111
-				if ($position < 0) {
112
-					$position = count($boutons_admin[$parent]->sousmenu) + 1 + $position;
113
-				}
114
-				$boutons_admin[$parent]->sousmenu = array_slice($boutons_admin[$parent]->sousmenu, 0, $position)
115
-					+ array(
116
-						$id => new Bouton(
117
-							($icones and !empty($infos['icone'])) ? find_in_theme($infos['icone']) : '',  // icone
118
-							$infos['titre'],  // titre
119
-							(isset($infos['action']) and $infos['action']) ? $infos['action'] : null,
120
-							(isset($infos['parametres']) and $infos['parametres']) ? $infos['parametres'] : null
121
-						)
122
-					)
123
-					+ array_slice($boutons_admin[$parent]->sousmenu, $position, 100);
124
-			}
125
-			if (!$parent
126
-				// provisoire, eviter les vieux boutons
127
-				and (!in_array($id, array('forum', 'statistiques_visites')))
128
-				and (!$autorise or autoriser('menugrandeentree', "_$id", 0, null, array('contexte' => $contexte)))
129
-			) {
130
-				$position = (isset($infos['position']) and $infos['position']) ? $infos['position'] : count($boutons_admin);
131
-				$boutons_admin = array_slice($boutons_admin, 0, $position)
132
-					+ array(
133
-						$id => new Bouton(
134
-							($icones and isset($infos['icone']) and $infos['icone']) ? find_in_theme($infos['icone']) : '',  // icone
135
-							$infos['titre'],  // titre
136
-							(isset($infos['action']) and $infos['action']) ? $infos['action'] : null,
137
-							(isset($infos['parametres']) and $infos['parametres']) ? $infos['parametres'] : null
138
-						)
139
-					)
140
-					+ array_slice($boutons_admin, $position, 100);
141
-			}
142
-		}
143
-	}
144
-	$boutons_admin = pipeline('ajouter_menus', $boutons_admin);
95
+    foreach ($liste_boutons as $id => $infos) {
96
+        $parent = '';
97
+        // les boutons principaux ne sont pas soumis a autorisation
98
+        if (!isset($infos['parent'])
99
+            or !($parent = $infos['parent'])
100
+            or !$autorise
101
+            or autoriser('menu', "_$id", 0, null, array('contexte' => $contexte))
102
+        ) {
103
+            if ($parent
104
+                and $parent = preg_replace(',^bando_,', 'menu_', $parent)
105
+                and isset($boutons_admin[$parent])
106
+            ) {
107
+                if (!is_array($boutons_admin[$parent]->sousmenu)) {
108
+                    $boutons_admin[$parent]->sousmenu = array();
109
+                }
110
+                $position = (isset($infos['position']) and strlen($infos['position'])) ? intval($infos['position']) : count($boutons_admin[$parent]->sousmenu);
111
+                if ($position < 0) {
112
+                    $position = count($boutons_admin[$parent]->sousmenu) + 1 + $position;
113
+                }
114
+                $boutons_admin[$parent]->sousmenu = array_slice($boutons_admin[$parent]->sousmenu, 0, $position)
115
+                    + array(
116
+                        $id => new Bouton(
117
+                            ($icones and !empty($infos['icone'])) ? find_in_theme($infos['icone']) : '',  // icone
118
+                            $infos['titre'],  // titre
119
+                            (isset($infos['action']) and $infos['action']) ? $infos['action'] : null,
120
+                            (isset($infos['parametres']) and $infos['parametres']) ? $infos['parametres'] : null
121
+                        )
122
+                    )
123
+                    + array_slice($boutons_admin[$parent]->sousmenu, $position, 100);
124
+            }
125
+            if (!$parent
126
+                // provisoire, eviter les vieux boutons
127
+                and (!in_array($id, array('forum', 'statistiques_visites')))
128
+                and (!$autorise or autoriser('menugrandeentree', "_$id", 0, null, array('contexte' => $contexte)))
129
+            ) {
130
+                $position = (isset($infos['position']) and $infos['position']) ? $infos['position'] : count($boutons_admin);
131
+                $boutons_admin = array_slice($boutons_admin, 0, $position)
132
+                    + array(
133
+                        $id => new Bouton(
134
+                            ($icones and isset($infos['icone']) and $infos['icone']) ? find_in_theme($infos['icone']) : '',  // icone
135
+                            $infos['titre'],  // titre
136
+                            (isset($infos['action']) and $infos['action']) ? $infos['action'] : null,
137
+                            (isset($infos['parametres']) and $infos['parametres']) ? $infos['parametres'] : null
138
+                        )
139
+                    )
140
+                    + array_slice($boutons_admin, $position, 100);
141
+            }
142
+        }
143
+    }
144
+    $boutons_admin = pipeline('ajouter_menus', $boutons_admin);
145 145
 
146
-	// définir les favoris et positions d’origine
147
-	if ($boutons_admin) {
148
-		$menus_favoris = obtenir_menus_favoris();
149
-		$i = 1;
150
-		foreach ($boutons_admin as $key => $menu) {
151
-			$menu->favori = table_valeur($menus_favoris, $key, false);
152
-			$menu->position = $i++;
153
-			if ($menu->sousmenu) {
154
-				$j = 1;
155
-				foreach ($menu->sousmenu as $key => $bouton) {
156
-					$bouton->favori = table_valeur($menus_favoris, $key, false);
157
-					$bouton->position = $j++;
158
-				}
159
-			}
160
-		}
161
-	}
146
+    // définir les favoris et positions d’origine
147
+    if ($boutons_admin) {
148
+        $menus_favoris = obtenir_menus_favoris();
149
+        $i = 1;
150
+        foreach ($boutons_admin as $key => $menu) {
151
+            $menu->favori = table_valeur($menus_favoris, $key, false);
152
+            $menu->position = $i++;
153
+            if ($menu->sousmenu) {
154
+                $j = 1;
155
+                foreach ($menu->sousmenu as $key => $bouton) {
156
+                    $bouton->favori = table_valeur($menus_favoris, $key, false);
157
+                    $bouton->position = $j++;
158
+                }
159
+            }
160
+        }
161
+    }
162 162
 
163
-	return $boutons_admin;
163
+    return $boutons_admin;
164 164
 }
165 165
 
166 166
 /**
@@ -172,22 +172,22 @@  discard block
 block discarded – undo
172 172
  * @return Bouton[]
173 173
  */
174 174
 function trier_boutons_enfants_par_alpha($menus, $avec_favoris = false) {
175
-	foreach ($menus as $menu) {
176
-		if ($menu->sousmenu) {
177
-			$libelles = $isfavoris = $favoris = array();
178
-			foreach ($menu->sousmenu as $key => $item) {
179
-				$libelles[$key] = strtolower(translitteration(_T($item->libelle)));
180
-				$isfavoris[$key] = (bool)$item->favori;
181
-				$favoris[$key] = $item->favori;
182
-			}
183
-			if ($avec_favoris) {
184
-				array_multisort($isfavoris, SORT_DESC, $favoris, SORT_ASC, $libelles, SORT_ASC, $menu->sousmenu);
185
-			} else {
186
-				array_multisort($libelles, SORT_ASC, $menu->sousmenu);
187
-			}
188
-		}
189
-	}
190
-	return $menus;
175
+    foreach ($menus as $menu) {
176
+        if ($menu->sousmenu) {
177
+            $libelles = $isfavoris = $favoris = array();
178
+            foreach ($menu->sousmenu as $key => $item) {
179
+                $libelles[$key] = strtolower(translitteration(_T($item->libelle)));
180
+                $isfavoris[$key] = (bool)$item->favori;
181
+                $favoris[$key] = $item->favori;
182
+            }
183
+            if ($avec_favoris) {
184
+                array_multisort($isfavoris, SORT_DESC, $favoris, SORT_ASC, $libelles, SORT_ASC, $menu->sousmenu);
185
+            } else {
186
+                array_multisort($libelles, SORT_ASC, $menu->sousmenu);
187
+            }
188
+        }
189
+    }
190
+    return $menus;
191 191
 }
192 192
 
193 193
 /**
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
  * @return Bouton[]
199 199
  */
200 200
 function trier_boutons_enfants_par_favoris_alpha($menus) {
201
-	return trier_boutons_enfants_par_alpha($menus, true);
201
+    return trier_boutons_enfants_par_alpha($menus, true);
202 202
 }
203 203
 
204 204
 
@@ -211,23 +211,23 @@  discard block
 block discarded – undo
211 211
  * @return string
212 212
  */
213 213
 function bandeau_creer_url($url, $args = '', $contexte = null) {
214
-	if (!preg_match(',[\/\?],', $url)) {
215
-		$url = generer_url_ecrire($url, $args, true);
216
-		// recuperer les parametres du contexte demande par l'url sous la forme
217
-		// &truc=@machin@
218
-		// @machin@ etant remplace par _request('machin')
219
-		$url = str_replace('&amp;', '&', $url);
220
-		while (preg_match(',[&?]([a-z_]+)=@([a-z_]+)@,i', $url, $matches)) {
221
-			if ($matches[2] == 'id_secteur' and !isset($contexte['id_secteur']) and isset($contexte['id_rubrique'])) {
222
-				$contexte['id_secteur'] = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . intval($contexte['id_rubrique']));
223
-			}
224
-			$val = _request($matches[2], $contexte);
225
-			$url = parametre_url($url, $matches[1], $val ? $val : '', '&');
226
-		}
227
-		$url = str_replace('&', '&amp;', $url);
228
-	}
214
+    if (!preg_match(',[\/\?],', $url)) {
215
+        $url = generer_url_ecrire($url, $args, true);
216
+        // recuperer les parametres du contexte demande par l'url sous la forme
217
+        // &truc=@machin@
218
+        // @machin@ etant remplace par _request('machin')
219
+        $url = str_replace('&amp;', '&', $url);
220
+        while (preg_match(',[&?]([a-z_]+)=@([a-z_]+)@,i', $url, $matches)) {
221
+            if ($matches[2] == 'id_secteur' and !isset($contexte['id_secteur']) and isset($contexte['id_rubrique'])) {
222
+                $contexte['id_secteur'] = sql_getfetsel('id_secteur', 'spip_rubriques', 'id_rubrique=' . intval($contexte['id_rubrique']));
223
+            }
224
+            $val = _request($matches[2], $contexte);
225
+            $url = parametre_url($url, $matches[1], $val ? $val : '', '&');
226
+        }
227
+        $url = str_replace('&', '&amp;', $url);
228
+    }
229 229
 
230
-	return $url;
230
+    return $url;
231 231
 }
232 232
 
233 233
 /**
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
  *     Code HTML du bandeau
238 238
  */
239 239
 function inc_bandeau_dist() {
240
-	return recuperer_fond('prive/squelettes/inclure/barre-nav', $_GET);
240
+    return recuperer_fond('prive/squelettes/inclure/barre-nav', $_GET);
241 241
 }
242 242
 
243 243
 
@@ -246,13 +246,13 @@  discard block
 block discarded – undo
246 246
  * @return array
247 247
  */
248 248
 function obtenir_menus_favoris() {
249
-	if (
250
-		isset($GLOBALS['visiteur_session']['prefs']['menus_favoris'])
251
-		and is_array($GLOBALS['visiteur_session']['prefs']['menus_favoris'])
252
-		and $GLOBALS['visiteur_session']['prefs']['menus_favoris']
253
-	) {
254
-		return $GLOBALS['visiteur_session']['prefs']['menus_favoris'];
255
-	}
256
-	$definir_menus_favoris = charger_fonction('definir_menus_favoris', 'inc');
257
-	return $definir_menus_favoris();
249
+    if (
250
+        isset($GLOBALS['visiteur_session']['prefs']['menus_favoris'])
251
+        and is_array($GLOBALS['visiteur_session']['prefs']['menus_favoris'])
252
+        and $GLOBALS['visiteur_session']['prefs']['menus_favoris']
253
+    ) {
254
+        return $GLOBALS['visiteur_session']['prefs']['menus_favoris'];
255
+    }
256
+    $definir_menus_favoris = charger_fonction('definir_menus_favoris', 'inc');
257
+    return $definir_menus_favoris();
258 258
 }
259 259
\ No newline at end of file
Please login to merge, or discard this patch.
ecrire/inc/documents.php 1 patch
Indentation   +173 added lines, -173 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  */
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 /**
@@ -30,11 +30,11 @@  discard block
 block discarded – undo
30 30
  * @return string
31 31
  */
32 32
 function set_spip_doc($fichier) {
33
-	if (strpos($fichier, _DIR_IMG) === 0) {
34
-		return substr($fichier, strlen(_DIR_IMG));
35
-	} else {
36
-		return $fichier;
37
-	} // ex: fichier distant
33
+    if (strpos($fichier, _DIR_IMG) === 0) {
34
+        return substr($fichier, strlen(_DIR_IMG));
35
+    } else {
36
+        return $fichier;
37
+    } // ex: fichier distant
38 38
 }
39 39
 
40 40
 /**
@@ -46,24 +46,24 @@  discard block
 block discarded – undo
46 46
  * @return bool|string
47 47
  */
48 48
 function get_spip_doc($fichier) {
49
-	// fichier distant
50
-	if (tester_url_absolue($fichier)) {
51
-		return $fichier;
52
-	}
53
-
54
-	// gestion d'erreurs, fichier=''
55
-	if (!strlen($fichier)) {
56
-		return false;
57
-	}
58
-
59
-	$fichier = (
60
-		strncmp($fichier, _DIR_IMG, strlen(_DIR_IMG)) != 0
61
-	)
62
-		? _DIR_IMG . $fichier
63
-		: $fichier;
64
-
65
-	// fichier normal
66
-	return $fichier;
49
+    // fichier distant
50
+    if (tester_url_absolue($fichier)) {
51
+        return $fichier;
52
+    }
53
+
54
+    // gestion d'erreurs, fichier=''
55
+    if (!strlen($fichier)) {
56
+        return false;
57
+    }
58
+
59
+    $fichier = (
60
+        strncmp($fichier, _DIR_IMG, strlen(_DIR_IMG)) != 0
61
+    )
62
+        ? _DIR_IMG . $fichier
63
+        : $fichier;
64
+
65
+    // fichier normal
66
+    return $fichier;
67 67
 }
68 68
 
69 69
 /**
@@ -77,24 +77,24 @@  discard block
 block discarded – undo
77 77
  * @return string
78 78
  */
79 79
 function creer_repertoire_documents($ext) {
80
-	$rep = sous_repertoire(_DIR_IMG, $ext);
81
-
82
-	if (!$ext or !$rep) {
83
-		spip_log("creer_repertoire_documents '$rep' interdit");
84
-		exit;
85
-	}
86
-
87
-	// Cette variable de configuration peut etre posee par un plugin
88
-	// par exemple acces_restreint
89
-	// sauf pour logo/ utilise pour stocker les logoon et logooff
90
-	if (isset($GLOBALS['meta']["creer_htaccess"])
91
-		and $GLOBALS['meta']["creer_htaccess"] == 'oui'
92
-	  and $ext !== 'logo') {
93
-		include_spip('inc/acces');
94
-		verifier_htaccess($rep);
95
-	}
96
-
97
-	return $rep;
80
+    $rep = sous_repertoire(_DIR_IMG, $ext);
81
+
82
+    if (!$ext or !$rep) {
83
+        spip_log("creer_repertoire_documents '$rep' interdit");
84
+        exit;
85
+    }
86
+
87
+    // Cette variable de configuration peut etre posee par un plugin
88
+    // par exemple acces_restreint
89
+    // sauf pour logo/ utilise pour stocker les logoon et logooff
90
+    if (isset($GLOBALS['meta']["creer_htaccess"])
91
+        and $GLOBALS['meta']["creer_htaccess"] == 'oui'
92
+      and $ext !== 'logo') {
93
+        include_spip('inc/acces');
94
+        verifier_htaccess($rep);
95
+    }
96
+
97
+    return $rep;
98 98
 }
99 99
 
100 100
 /**
@@ -103,21 +103,21 @@  discard block
 block discarded – undo
103 103
  * @param string $nom
104 104
  */
105 105
 function effacer_repertoire_temporaire($nom) {
106
-	if ($d = opendir($nom)) {
107
-		while (($f = readdir($d)) !== false) {
108
-			if (is_file("$nom/$f")) {
109
-				spip_unlink("$nom/$f");
110
-			} else {
111
-				if ($f <> '.' and $f <> '..'
112
-					and is_dir("$nom/$f")
113
-				) {
114
-					effacer_repertoire_temporaire("$nom/$f");
115
-				}
116
-			}
117
-		}
118
-	}
119
-	closedir($d);
120
-	@rmdir($nom);
106
+    if ($d = opendir($nom)) {
107
+        while (($f = readdir($d)) !== false) {
108
+            if (is_file("$nom/$f")) {
109
+                spip_unlink("$nom/$f");
110
+            } else {
111
+                if ($f <> '.' and $f <> '..'
112
+                    and is_dir("$nom/$f")
113
+                ) {
114
+                    effacer_repertoire_temporaire("$nom/$f");
115
+                }
116
+            }
117
+        }
118
+    }
119
+    closedir($d);
120
+    @rmdir($nom);
121 121
 }
122 122
 
123 123
 //
@@ -134,28 +134,28 @@  discard block
 block discarded – undo
134 134
  */
135 135
 function copier_document($ext, $orig, $source, $subdir = null) {
136 136
 
137
-	$orig = preg_replace(',\.\.+,', '.', $orig); // pas de .. dans le nom du doc
138
-	$dir = creer_repertoire_documents($subdir ? $subdir : $ext);
139
-	$dest = preg_replace("/[^.=\w-]+/", "_",
140
-		translitteration(preg_replace("/\.([^.]+)$/", "",
141
-			preg_replace("/<[^>]*>/", '', basename($orig)))));
137
+    $orig = preg_replace(',\.\.+,', '.', $orig); // pas de .. dans le nom du doc
138
+    $dir = creer_repertoire_documents($subdir ? $subdir : $ext);
139
+    $dest = preg_replace("/[^.=\w-]+/", "_",
140
+        translitteration(preg_replace("/\.([^.]+)$/", "",
141
+            preg_replace("/<[^>]*>/", '', basename($orig)))));
142 142
 
143
-	// ne pas accepter de noms de la forme -r90.jpg qui sont reserves
144
-	// pour les images transformees par rotation (action/documenter)
145
-	$dest = preg_replace(',-r(90|180|270)$,', '', $dest);
143
+    // ne pas accepter de noms de la forme -r90.jpg qui sont reserves
144
+    // pour les images transformees par rotation (action/documenter)
145
+    $dest = preg_replace(',-r(90|180|270)$,', '', $dest);
146 146
 
147
-	// Si le document "source" est deja au bon endroit, ne rien faire
148
-	if ($source == ($dir . $dest . '.' . $ext)) {
149
-		return $source;
150
-	}
147
+    // Si le document "source" est deja au bon endroit, ne rien faire
148
+    if ($source == ($dir . $dest . '.' . $ext)) {
149
+        return $source;
150
+    }
151 151
 
152
-	// sinon tourner jusqu'a trouver un numero correct
153
-	$n = 0;
154
-	while (@file_exists($newFile = $dir . $dest . ($n++ ? ('-' . $n) : '') . '.' . $ext)) {
155
-		;
156
-	}
152
+    // sinon tourner jusqu'a trouver un numero correct
153
+    $n = 0;
154
+    while (@file_exists($newFile = $dir . $dest . ($n++ ? ('-' . $n) : '') . '.' . $ext)) {
155
+        ;
156
+    }
157 157
 
158
-	return deplacer_fichier_upload($source, $newFile);
158
+    return deplacer_fichier_upload($source, $newFile);
159 159
 }
160 160
 
161 161
 /**
@@ -170,28 +170,28 @@  discard block
 block discarded – undo
170 170
  * @return bool|string
171 171
  */
172 172
 function determine_upload($type = '') {
173
-	if (!function_exists('autoriser')) {
174
-		include_spip('inc/autoriser');
175
-	}
176
-
177
-	if (!autoriser('chargerftp')
178
-		or $type == 'logos'
179
-	) # on ne le permet pas pour les logos
180
-	{
181
-		return false;
182
-	}
183
-
184
-	$repertoire = _DIR_TRANSFERT;
185
-	if (!@is_dir($repertoire)) {
186
-		$repertoire = str_replace(_DIR_TMP, '', $repertoire);
187
-		$repertoire = sous_repertoire(_DIR_TMP, $repertoire);
188
-	}
189
-
190
-	if (!$GLOBALS['visiteur_session']['restreint']) {
191
-		return $repertoire;
192
-	} else {
193
-		return sous_repertoire($repertoire, $GLOBALS['visiteur_session']['login']);
194
-	}
173
+    if (!function_exists('autoriser')) {
174
+        include_spip('inc/autoriser');
175
+    }
176
+
177
+    if (!autoriser('chargerftp')
178
+        or $type == 'logos'
179
+    ) # on ne le permet pas pour les logos
180
+    {
181
+        return false;
182
+    }
183
+
184
+    $repertoire = _DIR_TRANSFERT;
185
+    if (!@is_dir($repertoire)) {
186
+        $repertoire = str_replace(_DIR_TMP, '', $repertoire);
187
+        $repertoire = sous_repertoire(_DIR_TMP, $repertoire);
188
+    }
189
+
190
+    if (!$GLOBALS['visiteur_session']['restreint']) {
191
+        return $repertoire;
192
+    } else {
193
+        return sous_repertoire($repertoire, $GLOBALS['visiteur_session']['login']);
194
+    }
195 195
 }
196 196
 
197 197
 /**
@@ -210,35 +210,35 @@  discard block
 block discarded – undo
210 210
  * @return bool|mixed|string
211 211
  */
212 212
 function deplacer_fichier_upload($source, $dest, $move = false) {
213
-	// Securite
214
-	if (substr($dest, 0, strlen(_DIR_RACINE)) == _DIR_RACINE) {
215
-		$dest = _DIR_RACINE . preg_replace(',\.\.+,', '.', substr($dest, strlen(_DIR_RACINE)));
216
-	} else {
217
-		$dest = preg_replace(',\.\.+,', '.', $dest);
218
-	}
219
-
220
-	if ($move) {
221
-		$ok = @rename($source, $dest);
222
-	} else {
223
-		$ok = @copy($source, $dest);
224
-	}
225
-	if (!$ok) {
226
-		$ok = @move_uploaded_file($source, $dest);
227
-	}
228
-	if ($ok) {
229
-		@chmod($dest, _SPIP_CHMOD & ~0111);
230
-	} else {
231
-		$f = @fopen($dest, 'w');
232
-		if ($f) {
233
-			fclose($f);
234
-		} else {
235
-			include_spip('inc/flock');
236
-			raler_fichier($dest);
237
-		}
238
-		spip_unlink($dest);
239
-	}
240
-
241
-	return $ok ? $dest : false;
213
+    // Securite
214
+    if (substr($dest, 0, strlen(_DIR_RACINE)) == _DIR_RACINE) {
215
+        $dest = _DIR_RACINE . preg_replace(',\.\.+,', '.', substr($dest, strlen(_DIR_RACINE)));
216
+    } else {
217
+        $dest = preg_replace(',\.\.+,', '.', $dest);
218
+    }
219
+
220
+    if ($move) {
221
+        $ok = @rename($source, $dest);
222
+    } else {
223
+        $ok = @copy($source, $dest);
224
+    }
225
+    if (!$ok) {
226
+        $ok = @move_uploaded_file($source, $dest);
227
+    }
228
+    if ($ok) {
229
+        @chmod($dest, _SPIP_CHMOD & ~0111);
230
+    } else {
231
+        $f = @fopen($dest, 'w');
232
+        if ($f) {
233
+            fclose($f);
234
+        } else {
235
+            include_spip('inc/flock');
236
+            raler_fichier($dest);
237
+        }
238
+        spip_unlink($dest);
239
+    }
240
+
241
+    return $ok ? $dest : false;
242 242
 }
243 243
 
244 244
 
@@ -262,51 +262,51 @@  discard block
 block discarded – undo
262 262
  */
263 263
 function check_upload_error($error, $msg = '', $return = false) {
264 264
 
265
-	if (!$error) {
266
-		return false;
267
-	}
268
-
269
-	spip_log("Erreur upload $error -- cf. http://php.net/manual/fr/features.file-upload.errors.php");
270
-
271
-	switch ($error) {
272
-
273
-		case 4: /* UPLOAD_ERR_NO_FILE */
274
-			return true;
275
-
276
-		# on peut affiner les differents messages d'erreur
277
-		case 1: /* UPLOAD_ERR_INI_SIZE */
278
-			$msg = _T('upload_limit',
279
-				array('max' => ini_get('upload_max_filesize')));
280
-			break;
281
-		case 2: /* UPLOAD_ERR_FORM_SIZE */
282
-			$msg = _T('upload_limit',
283
-				array('max' => ini_get('upload_max_filesize')));
284
-			break;
285
-		case 3: /* UPLOAD_ERR_PARTIAL  */
286
-			$msg = _T('upload_limit',
287
-				array('max' => ini_get('upload_max_filesize')));
288
-			break;
289
-
290
-		default: /* autre */
291
-			if (!$msg) {
292
-				$msg = _T('pass_erreur') . ' ' . $error
293
-					. '<br />' . propre("[->http://php.net/manual/fr/features.file-upload.errors.php]");
294
-			}
295
-			break;
296
-	}
297
-
298
-	spip_log("erreur upload $error");
299
-	if ($return) {
300
-		return $msg;
301
-	}
302
-
303
-	if (_request("iframe") == "iframe") {
304
-		echo "<div class='upload_answer upload_error'>$msg</div>";
305
-		exit;
306
-	}
307
-
308
-	include_spip('inc/minipres');
309
-	echo minipres($msg,
310
-		"<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><a href='" . rawurldecode($GLOBALS['redirect']) . "'><button type='button'>" . _T('ecrire:bouton_suivant') . "</button></a></div>");
311
-	exit;
265
+    if (!$error) {
266
+        return false;
267
+    }
268
+
269
+    spip_log("Erreur upload $error -- cf. http://php.net/manual/fr/features.file-upload.errors.php");
270
+
271
+    switch ($error) {
272
+
273
+        case 4: /* UPLOAD_ERR_NO_FILE */
274
+            return true;
275
+
276
+        # on peut affiner les differents messages d'erreur
277
+        case 1: /* UPLOAD_ERR_INI_SIZE */
278
+            $msg = _T('upload_limit',
279
+                array('max' => ini_get('upload_max_filesize')));
280
+            break;
281
+        case 2: /* UPLOAD_ERR_FORM_SIZE */
282
+            $msg = _T('upload_limit',
283
+                array('max' => ini_get('upload_max_filesize')));
284
+            break;
285
+        case 3: /* UPLOAD_ERR_PARTIAL  */
286
+            $msg = _T('upload_limit',
287
+                array('max' => ini_get('upload_max_filesize')));
288
+            break;
289
+
290
+        default: /* autre */
291
+            if (!$msg) {
292
+                $msg = _T('pass_erreur') . ' ' . $error
293
+                    . '<br />' . propre("[->http://php.net/manual/fr/features.file-upload.errors.php]");
294
+            }
295
+            break;
296
+    }
297
+
298
+    spip_log("erreur upload $error");
299
+    if ($return) {
300
+        return $msg;
301
+    }
302
+
303
+    if (_request("iframe") == "iframe") {
304
+        echo "<div class='upload_answer upload_error'>$msg</div>";
305
+        exit;
306
+    }
307
+
308
+    include_spip('inc/minipres');
309
+    echo minipres($msg,
310
+        "<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'><a href='" . rawurldecode($GLOBALS['redirect']) . "'><button type='button'>" . _T('ecrire:bouton_suivant') . "</button></a></div>");
311
+    exit;
312 312
 }
Please login to merge, or discard this patch.
ecrire/public/styliser.php 1 patch
Indentation   +124 added lines, -124 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
  **/
21 21
 
22 22
 if (!defined('_ECRIRE_INC_VERSION')) {
23
-	return;
23
+    return;
24 24
 }
25 25
 
26 26
 // Ce fichier doit imperativement definir la fonction ci-dessous:
@@ -39,59 +39,59 @@  discard block
 block discarded – undo
39 39
  * @return array
40 40
  */
41 41
 function public_styliser_dist($fond, $contexte, $lang = '', $connect = '') {
42
-	static $styliser_par_z;
43
-
44
-	// s'assurer que le fond est licite
45
-	// car il peut etre construit a partir d'une variable d'environnement
46
-	if (strpos($fond, "../") !== false or strncmp($fond, '/', 1) == 0) {
47
-		$fond = "404";
48
-	}
49
-
50
-	if (strncmp($fond, 'modeles/', 8) == 0) {
51
-		$modele = substr($fond, 8);
52
-		$modele = styliser_modele($modele, null, $contexte);
53
-		$fond = "modeles/$modele";
54
-	}
55
-
56
-	// Choisir entre $fond-dist.html, $fond=7.html, etc?
57
-	$id_rubrique = 0;
58
-	// Chercher le fond qui va servir de squelette
59
-	if ($r = quete_rubrique_fond($contexte)) {
60
-		list($id_rubrique, $lang) = $r;
61
-	}
62
-
63
-	// trouver un squelette du nom demande
64
-	// ne rien dire si on ne trouve pas, 
65
-	// c'est l'appelant qui sait comment gerer la situation
66
-	// ou les plugins qui feront mieux dans le pipeline
67
-	$squelette = trouver_fond($fond, "", true);
68
-	$ext = $squelette['extension'];
69
-
70
-	$flux = array(
71
-		'args' => array(
72
-			'id_rubrique' => $id_rubrique,
73
-			'ext' => $ext,
74
-			'fond' => $fond,
75
-			'lang' => $lang,
76
-			'contexte' => $contexte, // le style d'un objet peut dependre de lui meme
77
-			'connect' => $connect
78
-		),
79
-		'data' => $squelette['fond'],
80
-	);
81
-
82
-	if (test_espace_prive() or defined('_ZPIP')) {
83
-		if (!$styliser_par_z) {
84
-			$styliser_par_z = charger_fonction('styliser_par_z', 'public');
85
-		}
86
-		$flux = $styliser_par_z($flux);
87
-	}
88
-
89
-	$flux = styliser_par_objets($flux);
90
-
91
-	// pipeline styliser
92
-	$squelette = pipeline('styliser', $flux);
93
-
94
-	return array($squelette, $ext, $ext, "$squelette.$ext");
42
+    static $styliser_par_z;
43
+
44
+    // s'assurer que le fond est licite
45
+    // car il peut etre construit a partir d'une variable d'environnement
46
+    if (strpos($fond, "../") !== false or strncmp($fond, '/', 1) == 0) {
47
+        $fond = "404";
48
+    }
49
+
50
+    if (strncmp($fond, 'modeles/', 8) == 0) {
51
+        $modele = substr($fond, 8);
52
+        $modele = styliser_modele($modele, null, $contexte);
53
+        $fond = "modeles/$modele";
54
+    }
55
+
56
+    // Choisir entre $fond-dist.html, $fond=7.html, etc?
57
+    $id_rubrique = 0;
58
+    // Chercher le fond qui va servir de squelette
59
+    if ($r = quete_rubrique_fond($contexte)) {
60
+        list($id_rubrique, $lang) = $r;
61
+    }
62
+
63
+    // trouver un squelette du nom demande
64
+    // ne rien dire si on ne trouve pas, 
65
+    // c'est l'appelant qui sait comment gerer la situation
66
+    // ou les plugins qui feront mieux dans le pipeline
67
+    $squelette = trouver_fond($fond, "", true);
68
+    $ext = $squelette['extension'];
69
+
70
+    $flux = array(
71
+        'args' => array(
72
+            'id_rubrique' => $id_rubrique,
73
+            'ext' => $ext,
74
+            'fond' => $fond,
75
+            'lang' => $lang,
76
+            'contexte' => $contexte, // le style d'un objet peut dependre de lui meme
77
+            'connect' => $connect
78
+        ),
79
+        'data' => $squelette['fond'],
80
+    );
81
+
82
+    if (test_espace_prive() or defined('_ZPIP')) {
83
+        if (!$styliser_par_z) {
84
+            $styliser_par_z = charger_fonction('styliser_par_z', 'public');
85
+        }
86
+        $flux = $styliser_par_z($flux);
87
+    }
88
+
89
+    $flux = styliser_par_objets($flux);
90
+
91
+    // pipeline styliser
92
+    $squelette = pipeline('styliser', $flux);
93
+
94
+    return array($squelette, $ext, $ext, "$squelette.$ext");
95 95
 }
96 96
 
97 97
 /**
@@ -110,31 +110,31 @@  discard block
 block discarded – undo
110 110
  *     Données du pipeline styliser
111 111
  **/
112 112
 function styliser_par_objets($flux) {
113
-	if (test_espace_prive()
114
-		and !$squelette = $flux['data']
115
-		and strncmp($flux['args']['fond'], 'prive/objets/', 13) == 0
116
-		and $echafauder = charger_fonction('echafauder', 'prive', true)
117
-	) {
118
-		if (strncmp($flux['args']['fond'], 'prive/objets/liste/', 19) == 0) {
119
-			$table = table_objet(substr($flux['args']['fond'], 19));
120
-			$table_sql = table_objet_sql($table);
121
-			$objets = lister_tables_objets_sql();
122
-			if (isset($objets[$table_sql])) {
123
-				$flux['data'] = $echafauder($table, $table, $table_sql, "prive/objets/liste/objets", $flux['args']['ext']);
124
-			}
125
-		}
126
-		if (strncmp($flux['args']['fond'], 'prive/objets/contenu/', 21) == 0) {
127
-			$type = substr($flux['args']['fond'], 21);
128
-			$table = table_objet($type);
129
-			$table_sql = table_objet_sql($table);
130
-			$objets = lister_tables_objets_sql();
131
-			if (isset($objets[$table_sql])) {
132
-				$flux['data'] = $echafauder($type, $table, $table_sql, "prive/objets/contenu/objet", $flux['args']['ext']);
133
-			}
134
-		}
135
-	}
136
-
137
-	return $flux;
113
+    if (test_espace_prive()
114
+        and !$squelette = $flux['data']
115
+        and strncmp($flux['args']['fond'], 'prive/objets/', 13) == 0
116
+        and $echafauder = charger_fonction('echafauder', 'prive', true)
117
+    ) {
118
+        if (strncmp($flux['args']['fond'], 'prive/objets/liste/', 19) == 0) {
119
+            $table = table_objet(substr($flux['args']['fond'], 19));
120
+            $table_sql = table_objet_sql($table);
121
+            $objets = lister_tables_objets_sql();
122
+            if (isset($objets[$table_sql])) {
123
+                $flux['data'] = $echafauder($table, $table, $table_sql, "prive/objets/liste/objets", $flux['args']['ext']);
124
+            }
125
+        }
126
+        if (strncmp($flux['args']['fond'], 'prive/objets/contenu/', 21) == 0) {
127
+            $type = substr($flux['args']['fond'], 21);
128
+            $table = table_objet($type);
129
+            $table_sql = table_objet_sql($table);
130
+            $objets = lister_tables_objets_sql();
131
+            if (isset($objets[$table_sql])) {
132
+                $flux['data'] = $echafauder($type, $table, $table_sql, "prive/objets/contenu/objet", $flux['args']['ext']);
133
+            }
134
+        }
135
+    }
136
+
137
+    return $flux;
138 138
 }
139 139
 
140 140
 /**
@@ -150,49 +150,49 @@  discard block
 block discarded – undo
150 150
  * @return array
151 151
  */
152 152
 function quete_rubrique_fond($contexte) {
153
-	static $liste_objets = null;
154
-	static $quete = array();
155
-	if (is_null($liste_objets)) {
156
-		$liste_objets = array();
157
-		include_spip('inc/urls');
158
-		include_spip('public/quete');
159
-		$l = urls_liste_objets(false);
160
-		// placer la rubrique en tete des objets
161
-		$l = array_diff($l, array('rubrique'));
162
-		array_unshift($l, 'rubrique');
163
-		foreach ($l as $objet) {
164
-			$id = id_table_objet($objet);
165
-			if (!isset($liste_objets[$id])) {
166
-				$liste_objets[$id] = objet_type($objet, false);
167
-			}
168
-		}
169
-	}
170
-	$c = array_intersect_key($contexte, $liste_objets);
171
-	if (!count($c)) {
172
-		return false;
173
-	}
174
-
175
-	$c = array_map('intval', $c);
176
-	$s = serialize($c);
177
-	if (isset($quete[$s])) {
178
-		return $quete[$s];
179
-	}
180
-
181
-	if (isset($c['id_rubrique']) and $r = $c['id_rubrique']) {
182
-		unset($c['id_rubrique']);
183
-		$c = array('id_rubrique' => $r) + $c;
184
-	}
185
-
186
-	foreach ($c as $_id => $id) {
187
-		if ($id
188
-			and $row = quete_parent_lang(table_objet_sql($liste_objets[$_id]), $id)
189
-		) {
190
-			$lang = isset($row['lang']) ? $row['lang'] : '';
191
-			if ($_id == 'id_rubrique' or (isset($row['id_rubrique']) and $id = $row['id_rubrique'])) {
192
-				return $quete[$s] = array($id, $lang);
193
-			}
194
-		}
195
-	}
196
-
197
-	return $quete[$s] = false;
153
+    static $liste_objets = null;
154
+    static $quete = array();
155
+    if (is_null($liste_objets)) {
156
+        $liste_objets = array();
157
+        include_spip('inc/urls');
158
+        include_spip('public/quete');
159
+        $l = urls_liste_objets(false);
160
+        // placer la rubrique en tete des objets
161
+        $l = array_diff($l, array('rubrique'));
162
+        array_unshift($l, 'rubrique');
163
+        foreach ($l as $objet) {
164
+            $id = id_table_objet($objet);
165
+            if (!isset($liste_objets[$id])) {
166
+                $liste_objets[$id] = objet_type($objet, false);
167
+            }
168
+        }
169
+    }
170
+    $c = array_intersect_key($contexte, $liste_objets);
171
+    if (!count($c)) {
172
+        return false;
173
+    }
174
+
175
+    $c = array_map('intval', $c);
176
+    $s = serialize($c);
177
+    if (isset($quete[$s])) {
178
+        return $quete[$s];
179
+    }
180
+
181
+    if (isset($c['id_rubrique']) and $r = $c['id_rubrique']) {
182
+        unset($c['id_rubrique']);
183
+        $c = array('id_rubrique' => $r) + $c;
184
+    }
185
+
186
+    foreach ($c as $_id => $id) {
187
+        if ($id
188
+            and $row = quete_parent_lang(table_objet_sql($liste_objets[$_id]), $id)
189
+        ) {
190
+            $lang = isset($row['lang']) ? $row['lang'] : '';
191
+            if ($_id == 'id_rubrique' or (isset($row['id_rubrique']) and $id = $row['id_rubrique'])) {
192
+                return $quete[$s] = array($id, $lang);
193
+            }
194
+        }
195
+    }
196
+
197
+    return $quete[$s] = false;
198 198
 }
Please login to merge, or discard this patch.
ecrire/balise/logo_.php 1 patch
Indentation   +95 added lines, -95 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  **/
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 
@@ -54,84 +54,84 @@  discard block
 block discarded – undo
54 54
  */
55 55
 function balise_LOGO__dist($p) {
56 56
 
57
-	preg_match(',^LOGO_([A-Z_]+?)(|_NORMAL|_SURVOL|_RUBRIQUE)$,i', $p->nom_champ, $regs);
58
-	$type = strtolower($regs[1]);
59
-	$suite_logo = $regs[2];
60
-
61
-	// cas de #LOGO_SITE_SPIP
62
-	if ($type == 'site_spip') {
63
-		$type = 'site';
64
-		$_id_objet = "\"'0'\"";
65
-	}
66
-
67
-	$id_objet = id_table_objet($type);
68
-	if (!isset($_id_objet)) {
69
-		$_id_objet = champ_sql($id_objet, $p);
70
-	}
71
-
72
-	$fichier = ($p->etoile === '**') ? -1 : 0;
73
-	$coord = array();
74
-	$align = $lien = '';
75
-	$mode_logo = '';
76
-
77
-	if ($p->param and !$p->param[0][0]) {
78
-		$params = $p->param[0];
79
-		array_shift($params);
80
-		foreach ($params as $a) {
81
-			if ($a[0]->type === 'texte') {
82
-				$n = $a[0]->texte;
83
-				if (is_numeric($n)) {
84
-					$coord[] = $n;
85
-				} elseif (in_array($n, array('top', 'left', 'right', 'center', 'bottom'))) {
86
-					$align = $n;
87
-				} elseif (in_array($n, array('auto', 'icone', 'apercu', 'vignette'))) {
88
-					$mode_logo = $n;
89
-				}
90
-			} else {
91
-				$lien = calculer_liste($a, $p->descr, $p->boucles, $p->id_boucle);
92
-			}
93
-		}
94
-	}
95
-
96
-	$coord_x = !$coord ? 0 : intval(array_shift($coord));
97
-	$coord_y = !$coord ? 0 : intval(array_shift($coord));
98
-
99
-	if ($p->etoile === '*') {
100
-		include_spip('balise/url_');
101
-		$lien = generer_generer_url_arg($type, $p, $_id_objet);
102
-	}
103
-
104
-	$connect = $p->id_boucle ? $p->boucles[$p->id_boucle]->sql_serveur : '';
105
-	if ($type == 'document') {
106
-		$qconnect = _q($connect);
107
-		$doc = "quete_document($_id_objet, $qconnect)";
108
-		if ($fichier) {
109
-			$code = "quete_logo_file($doc, $qconnect)";
110
-		} else {
111
-			$code = "quete_logo_document($doc, " . ($lien ? $lien : "''") . ", '$align', '$mode_logo', $coord_x, $coord_y, $qconnect)";
112
-		}
113
-		// (x=non-faux ? y : '') pour affecter x en retournant y
114
-		if ($p->descr['documents']) {
115
-			$code = '(($doublons["documents"] .= ",". '
116
-				. $_id_objet
117
-				. ") ? $code : '')";
118
-		}
119
-	} elseif ($connect) {
120
-		$code = "''";
121
-		spip_log('Les logos distants ne sont pas prevus');
122
-	} else {
123
-		$code = logo_survol($id_objet, $_id_objet, $type, $align, $fichier, $lien, $p, $suite_logo);
124
-	}
125
-
126
-	// demande de reduction sur logo avec ecriture spip 2.1 : #LOGO_xxx{200, 0}
127
-	if ($coord_x or $coord_y) {
128
-		$code = "filtrer('image_graver',filtrer('image_reduire'," . $code . ", '$coord_x', '$coord_y'))";
129
-	}
130
-
131
-	$p->code = $code;
132
-	$p->interdire_scripts = false;
133
-
134
-	return $p;
57
+    preg_match(',^LOGO_([A-Z_]+?)(|_NORMAL|_SURVOL|_RUBRIQUE)$,i', $p->nom_champ, $regs);
58
+    $type = strtolower($regs[1]);
59
+    $suite_logo = $regs[2];
60
+
61
+    // cas de #LOGO_SITE_SPIP
62
+    if ($type == 'site_spip') {
63
+        $type = 'site';
64
+        $_id_objet = "\"'0'\"";
65
+    }
66
+
67
+    $id_objet = id_table_objet($type);
68
+    if (!isset($_id_objet)) {
69
+        $_id_objet = champ_sql($id_objet, $p);
70
+    }
71
+
72
+    $fichier = ($p->etoile === '**') ? -1 : 0;
73
+    $coord = array();
74
+    $align = $lien = '';
75
+    $mode_logo = '';
76
+
77
+    if ($p->param and !$p->param[0][0]) {
78
+        $params = $p->param[0];
79
+        array_shift($params);
80
+        foreach ($params as $a) {
81
+            if ($a[0]->type === 'texte') {
82
+                $n = $a[0]->texte;
83
+                if (is_numeric($n)) {
84
+                    $coord[] = $n;
85
+                } elseif (in_array($n, array('top', 'left', 'right', 'center', 'bottom'))) {
86
+                    $align = $n;
87
+                } elseif (in_array($n, array('auto', 'icone', 'apercu', 'vignette'))) {
88
+                    $mode_logo = $n;
89
+                }
90
+            } else {
91
+                $lien = calculer_liste($a, $p->descr, $p->boucles, $p->id_boucle);
92
+            }
93
+        }
94
+    }
95
+
96
+    $coord_x = !$coord ? 0 : intval(array_shift($coord));
97
+    $coord_y = !$coord ? 0 : intval(array_shift($coord));
98
+
99
+    if ($p->etoile === '*') {
100
+        include_spip('balise/url_');
101
+        $lien = generer_generer_url_arg($type, $p, $_id_objet);
102
+    }
103
+
104
+    $connect = $p->id_boucle ? $p->boucles[$p->id_boucle]->sql_serveur : '';
105
+    if ($type == 'document') {
106
+        $qconnect = _q($connect);
107
+        $doc = "quete_document($_id_objet, $qconnect)";
108
+        if ($fichier) {
109
+            $code = "quete_logo_file($doc, $qconnect)";
110
+        } else {
111
+            $code = "quete_logo_document($doc, " . ($lien ? $lien : "''") . ", '$align', '$mode_logo', $coord_x, $coord_y, $qconnect)";
112
+        }
113
+        // (x=non-faux ? y : '') pour affecter x en retournant y
114
+        if ($p->descr['documents']) {
115
+            $code = '(($doublons["documents"] .= ",". '
116
+                . $_id_objet
117
+                . ") ? $code : '')";
118
+        }
119
+    } elseif ($connect) {
120
+        $code = "''";
121
+        spip_log('Les logos distants ne sont pas prevus');
122
+    } else {
123
+        $code = logo_survol($id_objet, $_id_objet, $type, $align, $fichier, $lien, $p, $suite_logo);
124
+    }
125
+
126
+    // demande de reduction sur logo avec ecriture spip 2.1 : #LOGO_xxx{200, 0}
127
+    if ($coord_x or $coord_y) {
128
+        $code = "filtrer('image_graver',filtrer('image_reduire'," . $code . ", '$coord_x', '$coord_y'))";
129
+    }
130
+
131
+    $p->code = $code;
132
+    $p->interdire_scripts = false;
133
+
134
+    return $p;
135 135
 }
136 136
 
137 137
 /**
@@ -158,20 +158,20 @@  discard block
 block discarded – undo
158 158
  *     Code compilé retournant le chemin du logo ou le code HTML du logo.
159 159
  **/
160 160
 function logo_survol($id_objet, $_id_objet, $type, $align, $fichier, $_lien, $p, $suite) {
161
-	$code = "quete_logo('$id_objet', '" .
162
-		(($suite == '_SURVOL') ? 'off' :
163
-			(($suite == '_NORMAL') ? 'on' : 'ON')) .
164
-		"', $_id_objet," .
165
-		(($suite == '_RUBRIQUE') ?
166
-			champ_sql('id_rubrique', $p) :
167
-			(($type == 'rubrique') ? "quete_parent($_id_objet)" : "''")) .
168
-		', ' . intval($fichier) . ')';
169
-
170
-	if ($fichier) {
171
-		return $code;
172
-	}
173
-
174
-	$align = preg_replace(",\W,", "", $align);
175
-
176
-	return "quete_html_logo($code, '$align', " .($_lien ? $_lien : "''") .")";
161
+    $code = "quete_logo('$id_objet', '" .
162
+        (($suite == '_SURVOL') ? 'off' :
163
+            (($suite == '_NORMAL') ? 'on' : 'ON')) .
164
+        "', $_id_objet," .
165
+        (($suite == '_RUBRIQUE') ?
166
+            champ_sql('id_rubrique', $p) :
167
+            (($type == 'rubrique') ? "quete_parent($_id_objet)" : "''")) .
168
+        ', ' . intval($fichier) . ')';
169
+
170
+    if ($fichier) {
171
+        return $code;
172
+    }
173
+
174
+    $align = preg_replace(",\W,", "", $align);
175
+
176
+    return "quete_html_logo($code, '$align', " .($_lien ? $_lien : "''") .")";
177 177
 }
Please login to merge, or discard this patch.
ecrire/auth/spip.php 1 patch
Indentation   +260 added lines, -260 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  **/
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 /**
@@ -32,78 +32,78 @@  discard block
 block discarded – undo
32 32
  */
33 33
 function auth_spip_dist($login, $pass, $serveur = '', $phpauth = false) {
34 34
 
35
-	// retrouver le login
36
-	$login = auth_spip_retrouver_login($login);
37
-	// login inconnu, n'allons pas plus loin
38
-	if (!$login) {
39
-		return array();
40
-	}
41
-
42
-	$md5pass = "";
43
-	$shapass = $shanext = "";
44
-
45
-	if (preg_match(",^\{([0-9a-f]{64});([0-9a-f]{64})\}$,i", $pass, $regs)) {
46
-		$shapass = $regs[1];
47
-		$shanext = $regs[2];
48
-	} // compat avec une base mixte md5/sha256 : le js a envoye les 2 hash
49
-	elseif (preg_match(",^\{([0-9a-f]{64});([0-9a-f]{64});([0-9a-f]{32});([0-9a-f]{32})\}$,i", $pass, $regs)) {
50
-		$shapass = $regs[1];
51
-		$shanext = $regs[2];
52
-		$md5pass = $regs[3];
53
-		//$md5next = $regs[4];
54
-	} // si envoi non crypte, crypter maintenant
55
-	elseif ($pass) {
56
-		$row = sql_fetsel("alea_actuel, alea_futur", "spip_auteurs", "login=" . sql_quote($login, $serveur, 'text'), '', '',
57
-			'', '', $serveur);
58
-
59
-		if ($row) {
60
-			include_spip('auth/sha256.inc');
61
-			$shapass = spip_sha256($row['alea_actuel'] . $pass);
62
-			$shanext = spip_sha256($row['alea_futur'] . $pass);
63
-			$md5pass = md5($row['alea_actuel'] . $pass);
64
-		}
65
-	}
66
-
67
-	// login inexistant ou mot de passe vide
68
-	if (!$shapass and !$md5pass) {
69
-		return array();
70
-	}
71
-
72
-	$row = sql_fetsel("*", "spip_auteurs",
73
-		"login=" . sql_quote($login, $serveur, 'text') . " AND pass=" . sql_quote($shapass, $serveur,
74
-			'text') . " AND statut<>'5poubelle'", '', '', '', '', $serveur);
75
-
76
-	// compat avec les anciennes bases en md5
77
-	if (!$row and $md5pass) {
78
-		$row = sql_fetsel("*", "spip_auteurs",
79
-			"login=" . sql_quote($login, $serveur, 'text') . " AND pass=" . sql_quote($md5pass, $serveur,
80
-				'text') . " AND statut<>'5poubelle'", '', '', '', '', $serveur);
81
-	}
82
-
83
-	// login/mot de passe incorrect
84
-	if (!$row) {
85
-		return array();
86
-	}
87
-
88
-	// fait tourner le codage du pass dans la base
89
-	// sauf si phpauth : cela reviendrait a changer l'alea a chaque hit, et aucune action verifiable par securiser_action()
90
-	if ($shanext and !$phpauth) {
91
-
92
-		include_spip('inc/acces'); // pour creer_uniqid
93
-		@sql_update('spip_auteurs', array(
94
-			'alea_actuel' => 'alea_futur',
95
-			'pass' => sql_quote($shanext, $serveur, 'text'),
96
-			'alea_futur' => sql_quote(creer_uniqid(), $serveur, 'text')
97
-		), "id_auteur=" . $row['id_auteur'] . ' AND pass IN (' . sql_quote($shapass, $serveur,
98
-				'text') . ', ' . sql_quote($md5pass, $serveur, 'text') . ')', '', $serveur);
99
-		// En profiter pour verifier la securite de tmp/
100
-		// Si elle ne fonctionne pas a l'installation, prevenir
101
-		if (!verifier_htaccess(_DIR_TMP) and defined('_ECRIRE_INSTALL')) {
102
-			return false;
103
-		}
104
-	}
105
-
106
-	return $row;
35
+    // retrouver le login
36
+    $login = auth_spip_retrouver_login($login);
37
+    // login inconnu, n'allons pas plus loin
38
+    if (!$login) {
39
+        return array();
40
+    }
41
+
42
+    $md5pass = "";
43
+    $shapass = $shanext = "";
44
+
45
+    if (preg_match(",^\{([0-9a-f]{64});([0-9a-f]{64})\}$,i", $pass, $regs)) {
46
+        $shapass = $regs[1];
47
+        $shanext = $regs[2];
48
+    } // compat avec une base mixte md5/sha256 : le js a envoye les 2 hash
49
+    elseif (preg_match(",^\{([0-9a-f]{64});([0-9a-f]{64});([0-9a-f]{32});([0-9a-f]{32})\}$,i", $pass, $regs)) {
50
+        $shapass = $regs[1];
51
+        $shanext = $regs[2];
52
+        $md5pass = $regs[3];
53
+        //$md5next = $regs[4];
54
+    } // si envoi non crypte, crypter maintenant
55
+    elseif ($pass) {
56
+        $row = sql_fetsel("alea_actuel, alea_futur", "spip_auteurs", "login=" . sql_quote($login, $serveur, 'text'), '', '',
57
+            '', '', $serveur);
58
+
59
+        if ($row) {
60
+            include_spip('auth/sha256.inc');
61
+            $shapass = spip_sha256($row['alea_actuel'] . $pass);
62
+            $shanext = spip_sha256($row['alea_futur'] . $pass);
63
+            $md5pass = md5($row['alea_actuel'] . $pass);
64
+        }
65
+    }
66
+
67
+    // login inexistant ou mot de passe vide
68
+    if (!$shapass and !$md5pass) {
69
+        return array();
70
+    }
71
+
72
+    $row = sql_fetsel("*", "spip_auteurs",
73
+        "login=" . sql_quote($login, $serveur, 'text') . " AND pass=" . sql_quote($shapass, $serveur,
74
+            'text') . " AND statut<>'5poubelle'", '', '', '', '', $serveur);
75
+
76
+    // compat avec les anciennes bases en md5
77
+    if (!$row and $md5pass) {
78
+        $row = sql_fetsel("*", "spip_auteurs",
79
+            "login=" . sql_quote($login, $serveur, 'text') . " AND pass=" . sql_quote($md5pass, $serveur,
80
+                'text') . " AND statut<>'5poubelle'", '', '', '', '', $serveur);
81
+    }
82
+
83
+    // login/mot de passe incorrect
84
+    if (!$row) {
85
+        return array();
86
+    }
87
+
88
+    // fait tourner le codage du pass dans la base
89
+    // sauf si phpauth : cela reviendrait a changer l'alea a chaque hit, et aucune action verifiable par securiser_action()
90
+    if ($shanext and !$phpauth) {
91
+
92
+        include_spip('inc/acces'); // pour creer_uniqid
93
+        @sql_update('spip_auteurs', array(
94
+            'alea_actuel' => 'alea_futur',
95
+            'pass' => sql_quote($shanext, $serveur, 'text'),
96
+            'alea_futur' => sql_quote(creer_uniqid(), $serveur, 'text')
97
+        ), "id_auteur=" . $row['id_auteur'] . ' AND pass IN (' . sql_quote($shapass, $serveur,
98
+                'text') . ', ' . sql_quote($md5pass, $serveur, 'text') . ')', '', $serveur);
99
+        // En profiter pour verifier la securite de tmp/
100
+        // Si elle ne fonctionne pas a l'installation, prevenir
101
+        if (!verifier_htaccess(_DIR_TMP) and defined('_ECRIRE_INSTALL')) {
102
+            return false;
103
+        }
104
+    }
105
+
106
+    return $row;
107 107
 }
108 108
 
109 109
 /**
@@ -113,41 +113,41 @@  discard block
 block discarded – undo
113 113
  * @return array
114 114
  */
115 115
 function auth_spip_formulaire_login($flux) {
116
-	// faut il encore envoyer md5 ?
117
-	// on regarde si il reste des pass md5 en base pour des auteurs en statut pas poubelle
118
-	// les hash md5 ont une longueur 32, les sha 64
119
-	// en evitant une requete sql a chaque affichage du formulaire login sans session
120
-	// (perf issue pour les sites qui mettent le formulaire de login sur la home)
121
-	$compat_md5 = false;
122
-	if (!isset($GLOBALS['meta']['sha_256_only']) or _request('var_mode')) {
123
-		$compat_md5 = sql_countsel("spip_auteurs", "length(pass)=32 AND statut<>'poubelle'");
124
-		if ($compat_md5 and isset($GLOBALS['meta']['sha_256_only'])) {
125
-			effacer_meta('sha_256_only');
126
-		}
127
-		if (!$compat_md5) {
128
-			ecrire_meta('sha_256_only', 'oui');
129
-		}
130
-	}
131
-
132
-	// javascript qui gere la securite du login en evitant de faire circuler le pass en clair
133
-	$flux['data'] .=
134
-		($compat_md5 ? '<script type="text/javascript" src="' . _DIR_JAVASCRIPT . 'md5.js"></script>' : '')
135
-		. '<script type="text/javascript" src="' . _DIR_JAVASCRIPT . 'login-sha-min.js"></script>'
136
-		. '<script type="text/javascript">/*<![CDATA[*/'
137
-		. "var login_info={'alea_actuel':'" . $flux['args']['contexte']['_alea_actuel'] . "',"
138
-		. "'alea_futur':'" . $flux['args']['contexte']['_alea_futur'] . "',"
139
-		. "'login':'" . $flux['args']['contexte']['var_login'] . "',"
140
-		. "'page_auteur': '" . generer_url_public('informer_auteur') . "',"
141
-		. "'informe_auteur_en_cours':false,"
142
-		. "'attente_informe':0,"
143
-		. "'compat_md5':" . ($compat_md5 ? "true" : "false") . "};"
144
-		. "jQuery(function(){
116
+    // faut il encore envoyer md5 ?
117
+    // on regarde si il reste des pass md5 en base pour des auteurs en statut pas poubelle
118
+    // les hash md5 ont une longueur 32, les sha 64
119
+    // en evitant une requete sql a chaque affichage du formulaire login sans session
120
+    // (perf issue pour les sites qui mettent le formulaire de login sur la home)
121
+    $compat_md5 = false;
122
+    if (!isset($GLOBALS['meta']['sha_256_only']) or _request('var_mode')) {
123
+        $compat_md5 = sql_countsel("spip_auteurs", "length(pass)=32 AND statut<>'poubelle'");
124
+        if ($compat_md5 and isset($GLOBALS['meta']['sha_256_only'])) {
125
+            effacer_meta('sha_256_only');
126
+        }
127
+        if (!$compat_md5) {
128
+            ecrire_meta('sha_256_only', 'oui');
129
+        }
130
+    }
131
+
132
+    // javascript qui gere la securite du login en evitant de faire circuler le pass en clair
133
+    $flux['data'] .=
134
+        ($compat_md5 ? '<script type="text/javascript" src="' . _DIR_JAVASCRIPT . 'md5.js"></script>' : '')
135
+        . '<script type="text/javascript" src="' . _DIR_JAVASCRIPT . 'login-sha-min.js"></script>'
136
+        . '<script type="text/javascript">/*<![CDATA[*/'
137
+        . "var login_info={'alea_actuel':'" . $flux['args']['contexte']['_alea_actuel'] . "',"
138
+        . "'alea_futur':'" . $flux['args']['contexte']['_alea_futur'] . "',"
139
+        . "'login':'" . $flux['args']['contexte']['var_login'] . "',"
140
+        . "'page_auteur': '" . generer_url_public('informer_auteur') . "',"
141
+        . "'informe_auteur_en_cours':false,"
142
+        . "'attente_informe':0,"
143
+        . "'compat_md5':" . ($compat_md5 ? "true" : "false") . "};"
144
+        . "jQuery(function(){
145 145
 	jQuery('#var_login').change(actualise_auteur);
146 146
 	jQuery('form#formulaire_login').submit(login_submit);
147 147
 });"
148
-		. "/*]]>*/</script>";
148
+        . "/*]]>*/</script>";
149 149
 
150
-	return $flux;
150
+    return $flux;
151 151
 }
152 152
 
153 153
 
@@ -159,10 +159,10 @@  discard block
 block discarded – undo
159 159
  *   toujours true pour un auteur cree dans SPIP
160 160
  */
161 161
 function auth_spip_autoriser_modifier_login($serveur = '') {
162
-	if (strlen($serveur)) {
163
-		return false;
164
-	} // les fonctions d'ecriture sur base distante sont encore incompletes
165
-	return true;
162
+    if (strlen($serveur)) {
163
+        return false;
164
+    } // les fonctions d'ecriture sur base distante sont encore incompletes
165
+    return true;
166 166
 }
167 167
 
168 168
 /**
@@ -176,21 +176,21 @@  discard block
 block discarded – undo
176 176
  *  message d'erreur si login non valide, chaine vide sinon
177 177
  */
178 178
 function auth_spip_verifier_login($new_login, $id_auteur = 0, $serveur = '') {
179
-	// login et mot de passe
180
-	if (strlen($new_login)) {
181
-		if (strlen($new_login) < _LOGIN_TROP_COURT) {
182
-			return _T('info_login_trop_court_car_pluriel', array('nb' => _LOGIN_TROP_COURT));
183
-		} else {
184
-			$n = sql_countsel('spip_auteurs',
185
-				"login=" . sql_quote($new_login) . " AND id_auteur!=" . intval($id_auteur) . " AND statut!='5poubelle'", '', '',
186
-				$serveur);
187
-			if ($n) {
188
-				return _T('info_login_existant');
189
-			}
190
-		}
191
-	}
192
-
193
-	return '';
179
+    // login et mot de passe
180
+    if (strlen($new_login)) {
181
+        if (strlen($new_login) < _LOGIN_TROP_COURT) {
182
+            return _T('info_login_trop_court_car_pluriel', array('nb' => _LOGIN_TROP_COURT));
183
+        } else {
184
+            $n = sql_countsel('spip_auteurs',
185
+                "login=" . sql_quote($new_login) . " AND id_auteur!=" . intval($id_auteur) . " AND statut!='5poubelle'", '', '',
186
+                $serveur);
187
+            if ($n) {
188
+                return _T('info_login_existant');
189
+            }
190
+        }
191
+    }
192
+
193
+    return '';
194 194
 }
195 195
 
196 196
 /**
@@ -202,32 +202,32 @@  discard block
 block discarded – undo
202 202
  * @return bool
203 203
  */
204 204
 function auth_spip_modifier_login($new_login, $id_auteur, $serveur = '') {
205
-	if (is_null($new_login) or auth_spip_verifier_login($new_login, $id_auteur, $serveur) != '') {
206
-		return false;
207
-	}
208
-	if (!$id_auteur = intval($id_auteur)
209
-		or !$auteur = sql_fetsel('login', 'spip_auteurs', 'id_auteur=' . intval($id_auteur), '', '', '', '', $serveur)
210
-	) {
211
-		return false;
212
-	}
213
-	if ($new_login == $auteur['login']) {
214
-		return true;
215
-	} // on a rien fait mais c'est bon !
216
-
217
-	include_spip('action/editer_auteur');
218
-
219
-	// vider le login des auteurs a la poubelle qui avaient ce meme login
220
-	if (strlen($new_login)) {
221
-		$anciens = sql_allfetsel('id_auteur', 'spip_auteurs',
222
-			'login=' . sql_quote($new_login, $serveur, 'text') . " AND statut='5poubelle'", '', '', '', '', $serveur);
223
-		while ($row = array_pop($anciens)) {
224
-			auteur_modifier($row['id_auteur'], array('login' => ''), true); // manque la gestion de $serveur
225
-		}
226
-	}
227
-
228
-	auteur_modifier($id_auteur, array('login' => $new_login), true); // manque la gestion de $serveur
229
-
230
-	return true;
205
+    if (is_null($new_login) or auth_spip_verifier_login($new_login, $id_auteur, $serveur) != '') {
206
+        return false;
207
+    }
208
+    if (!$id_auteur = intval($id_auteur)
209
+        or !$auteur = sql_fetsel('login', 'spip_auteurs', 'id_auteur=' . intval($id_auteur), '', '', '', '', $serveur)
210
+    ) {
211
+        return false;
212
+    }
213
+    if ($new_login == $auteur['login']) {
214
+        return true;
215
+    } // on a rien fait mais c'est bon !
216
+
217
+    include_spip('action/editer_auteur');
218
+
219
+    // vider le login des auteurs a la poubelle qui avaient ce meme login
220
+    if (strlen($new_login)) {
221
+        $anciens = sql_allfetsel('id_auteur', 'spip_auteurs',
222
+            'login=' . sql_quote($new_login, $serveur, 'text') . " AND statut='5poubelle'", '', '', '', '', $serveur);
223
+        while ($row = array_pop($anciens)) {
224
+            auteur_modifier($row['id_auteur'], array('login' => ''), true); // manque la gestion de $serveur
225
+        }
226
+    }
227
+
228
+    auteur_modifier($id_auteur, array('login' => $new_login), true); // manque la gestion de $serveur
229
+
230
+    return true;
231 231
 }
232 232
 
233 233
 /**
@@ -239,27 +239,27 @@  discard block
 block discarded – undo
239 239
  * @return string
240 240
  */
241 241
 function auth_spip_retrouver_login($login, $serveur = '') {
242
-	if (!strlen($login)) {
243
-		return null;
244
-	} // pas la peine de requeter
245
-	$l = sql_quote($login, $serveur, 'text');
246
-	if ($r = sql_getfetsel('login', 'spip_auteurs',
247
-		"statut<>'5poubelle'" .
248
-		" AND (length(pass)>0)" .
249
-		" AND (login=$l)", '', '', '', '', $serveur)
250
-	) {
251
-		return $r;
252
-	}
253
-	// Si pas d'auteur avec ce login
254
-	// regarder s'il a saisi son nom ou son mail.
255
-	// Ne pas fusionner avec la requete precedente
256
-	// car un nom peut etre homonyme d'un autre login
257
-	else {
258
-		return sql_getfetsel('login', 'spip_auteurs',
259
-			"statut<>'5poubelle'" .
260
-			" AND (length(pass)>0)" .
261
-			" AND (login<>'' AND (nom=$l OR email=$l))", '', '', '', '', $serveur);
262
-	}
242
+    if (!strlen($login)) {
243
+        return null;
244
+    } // pas la peine de requeter
245
+    $l = sql_quote($login, $serveur, 'text');
246
+    if ($r = sql_getfetsel('login', 'spip_auteurs',
247
+        "statut<>'5poubelle'" .
248
+        " AND (length(pass)>0)" .
249
+        " AND (login=$l)", '', '', '', '', $serveur)
250
+    ) {
251
+        return $r;
252
+    }
253
+    // Si pas d'auteur avec ce login
254
+    // regarder s'il a saisi son nom ou son mail.
255
+    // Ne pas fusionner avec la requete precedente
256
+    // car un nom peut etre homonyme d'un autre login
257
+    else {
258
+        return sql_getfetsel('login', 'spip_auteurs',
259
+            "statut<>'5poubelle'" .
260
+            " AND (length(pass)>0)" .
261
+            " AND (login<>'' AND (nom=$l OR email=$l))", '', '', '', '', $serveur);
262
+    }
263 263
 }
264 264
 
265 265
 
@@ -277,11 +277,11 @@  discard block
 block discarded – undo
277 277
  */
278 278
 function auth_spip_informer_login($infos, $row, $serveur = '') {
279 279
 
280
-	// pour la methode SPIP on a besoin des alea en plus pour encoder le pass avec
281
-	$infos['alea_actuel'] = $row['alea_actuel'];
282
-	$infos['alea_futur'] = $row['alea_futur'];
280
+    // pour la methode SPIP on a besoin des alea en plus pour encoder le pass avec
281
+    $infos['alea_actuel'] = $row['alea_actuel'];
282
+    $infos['alea_futur'] = $row['alea_futur'];
283 283
 
284
-	return $infos;
284
+    return $infos;
285 285
 }
286 286
 
287 287
 /**
@@ -292,10 +292,10 @@  discard block
 block discarded – undo
292 292
  *  toujours true pour un auteur cree dans SPIP
293 293
  */
294 294
 function auth_spip_autoriser_modifier_pass($serveur = '') {
295
-	if (strlen($serveur)) {
296
-		return false;
297
-	} // les fonctions d'ecriture sur base distante sont encore incompletes
298
-	return true;
295
+    if (strlen($serveur)) {
296
+        return false;
297
+    } // les fonctions d'ecriture sur base distante sont encore incompletes
298
+    return true;
299 299
 }
300 300
 
301 301
 
@@ -316,12 +316,12 @@  discard block
 block discarded – undo
316 316
  *  message d'erreur si login non valide, chaine vide sinon
317 317
  */
318 318
 function auth_spip_verifier_pass($login, $new_pass, $id_auteur = 0, $serveur = '') {
319
-	// login et mot de passe
320
-	if (strlen($new_pass) < _PASS_LONGUEUR_MINI) {
321
-		return _T('info_passe_trop_court_car_pluriel', array('nb' => _PASS_LONGUEUR_MINI));
322
-	}
319
+    // login et mot de passe
320
+    if (strlen($new_pass) < _PASS_LONGUEUR_MINI) {
321
+        return _T('info_passe_trop_court_car_pluriel', array('nb' => _PASS_LONGUEUR_MINI));
322
+    }
323 323
 
324
-	return '';
324
+    return '';
325 325
 }
326 326
 
327 327
 /**
@@ -335,33 +335,33 @@  discard block
 block discarded – undo
335 335
  * @return bool
336 336
  */
337 337
 function auth_spip_modifier_pass($login, $new_pass, $id_auteur, $serveur = '') {
338
-	if (is_null($new_pass) or auth_spip_verifier_pass($login, $new_pass, $id_auteur, $serveur) != '') {
339
-		return false;
340
-	}
341
-
342
-	if (!$id_auteur = intval($id_auteur)
343
-		or !sql_fetsel('login', 'spip_auteurs', 'id_auteur=' . intval($id_auteur), '', '', '', '', $serveur)
344
-	) {
345
-		return false;
346
-	}
347
-
348
-	$c = array();
349
-	include_spip('inc/acces');
350
-	include_spip('auth/sha256.inc');
351
-	$htpass = generer_htpass($new_pass);
352
-	$alea_actuel = creer_uniqid();
353
-	$alea_futur = creer_uniqid();
354
-	$pass = spip_sha256($alea_actuel . $new_pass);
355
-	$c['pass'] = $pass;
356
-	$c['htpass'] = $htpass;
357
-	$c['alea_actuel'] = $alea_actuel;
358
-	$c['alea_futur'] = $alea_futur;
359
-	$c['low_sec'] = '';
360
-
361
-	include_spip('action/editer_auteur');
362
-	auteur_modifier($id_auteur, $c, true); // manque la gestion de $serveur
363
-
364
-	return true; // on a bien modifie le pass
338
+    if (is_null($new_pass) or auth_spip_verifier_pass($login, $new_pass, $id_auteur, $serveur) != '') {
339
+        return false;
340
+    }
341
+
342
+    if (!$id_auteur = intval($id_auteur)
343
+        or !sql_fetsel('login', 'spip_auteurs', 'id_auteur=' . intval($id_auteur), '', '', '', '', $serveur)
344
+    ) {
345
+        return false;
346
+    }
347
+
348
+    $c = array();
349
+    include_spip('inc/acces');
350
+    include_spip('auth/sha256.inc');
351
+    $htpass = generer_htpass($new_pass);
352
+    $alea_actuel = creer_uniqid();
353
+    $alea_futur = creer_uniqid();
354
+    $pass = spip_sha256($alea_actuel . $new_pass);
355
+    $c['pass'] = $pass;
356
+    $c['htpass'] = $htpass;
357
+    $c['alea_actuel'] = $alea_actuel;
358
+    $c['alea_futur'] = $alea_futur;
359
+    $c['low_sec'] = '';
360
+
361
+    include_spip('action/editer_auteur');
362
+    auteur_modifier($id_auteur, $c, true); // manque la gestion de $serveur
363
+
364
+    return true; // on a bien modifie le pass
365 365
 }
366 366
 
367 367
 /**
@@ -375,54 +375,54 @@  discard block
 block discarded – undo
375 375
  * @return void
376 376
  */
377 377
 function auth_spip_synchroniser_distant($id_auteur, $champs, $options = array(), $serveur = '') {
378
-	// ne rien faire pour une base distante : on ne sait pas regenerer les htaccess
379
-	if (strlen($serveur)) {
380
-		return;
381
-	}
382
-	// si un login, pass ou statut a ete modifie
383
-	// regenerer les fichier htpass
384
-	if (isset($champs['login'])
385
-		or isset($champs['pass'])
386
-		or isset($champs['statut'])
387
-		or (isset($options['all']) and $options['all'])
388
-	) {
389
-
390
-		$htaccess = _DIR_RESTREINT . _ACCESS_FILE_NAME;
391
-		$htpasswd = _DIR_TMP . _AUTH_USER_FILE;
392
-
393
-		// Cette variable de configuration peut etre posee par un plugin
394
-		// par exemple acces_restreint ;
395
-		// si .htaccess existe, outrepasser spip_meta
396
-		if ((!isset($GLOBALS['meta']['creer_htpasswd']) or ($GLOBALS['meta']['creer_htpasswd'] != 'oui'))
397
-			and !@file_exists($htaccess)
398
-		) {
399
-			spip_unlink($htpasswd);
400
-			spip_unlink($htpasswd . "-admin");
401
-
402
-			return;
403
-		}
404
-
405
-		# remarque : ici on laisse passer les "nouveau" de maniere a leur permettre
406
-		# de devenir redacteur le cas echeant (auth http)... a nettoyer
407
-		// attention, il faut au prealable se connecter a la base (necessaire car utilise par install)
408
-
409
-		$p1 = ''; // login:htpass pour tous
410
-		$p2 = ''; // login:htpass pour les admins
411
-		$s = sql_select("login, htpass, statut", "spip_auteurs",
412
-			sql_in("statut", array('1comite', '0minirezo', 'nouveau')));
413
-		while ($t = sql_fetch($s)) {
414
-			if (strlen($t['login']) and strlen($t['htpass'])) {
415
-				$p1 .= $t['login'] . ':' . $t['htpass'] . "\n";
416
-				if ($t['statut'] == '0minirezo') {
417
-					$p2 .= $t['login'] . ':' . $t['htpass'] . "\n";
418
-				}
419
-			}
420
-		}
421
-		sql_free($s);
422
-		if ($p1) {
423
-			ecrire_fichier($htpasswd, $p1);
424
-			ecrire_fichier($htpasswd . '-admin', $p2);
425
-			spip_log("Ecriture de $htpasswd et $htpasswd-admin");
426
-		}
427
-	}
378
+    // ne rien faire pour une base distante : on ne sait pas regenerer les htaccess
379
+    if (strlen($serveur)) {
380
+        return;
381
+    }
382
+    // si un login, pass ou statut a ete modifie
383
+    // regenerer les fichier htpass
384
+    if (isset($champs['login'])
385
+        or isset($champs['pass'])
386
+        or isset($champs['statut'])
387
+        or (isset($options['all']) and $options['all'])
388
+    ) {
389
+
390
+        $htaccess = _DIR_RESTREINT . _ACCESS_FILE_NAME;
391
+        $htpasswd = _DIR_TMP . _AUTH_USER_FILE;
392
+
393
+        // Cette variable de configuration peut etre posee par un plugin
394
+        // par exemple acces_restreint ;
395
+        // si .htaccess existe, outrepasser spip_meta
396
+        if ((!isset($GLOBALS['meta']['creer_htpasswd']) or ($GLOBALS['meta']['creer_htpasswd'] != 'oui'))
397
+            and !@file_exists($htaccess)
398
+        ) {
399
+            spip_unlink($htpasswd);
400
+            spip_unlink($htpasswd . "-admin");
401
+
402
+            return;
403
+        }
404
+
405
+        # remarque : ici on laisse passer les "nouveau" de maniere a leur permettre
406
+        # de devenir redacteur le cas echeant (auth http)... a nettoyer
407
+        // attention, il faut au prealable se connecter a la base (necessaire car utilise par install)
408
+
409
+        $p1 = ''; // login:htpass pour tous
410
+        $p2 = ''; // login:htpass pour les admins
411
+        $s = sql_select("login, htpass, statut", "spip_auteurs",
412
+            sql_in("statut", array('1comite', '0minirezo', 'nouveau')));
413
+        while ($t = sql_fetch($s)) {
414
+            if (strlen($t['login']) and strlen($t['htpass'])) {
415
+                $p1 .= $t['login'] . ':' . $t['htpass'] . "\n";
416
+                if ($t['statut'] == '0minirezo') {
417
+                    $p2 .= $t['login'] . ':' . $t['htpass'] . "\n";
418
+                }
419
+            }
420
+        }
421
+        sql_free($s);
422
+        if ($p1) {
423
+            ecrire_fichier($htpasswd, $p1);
424
+            ecrire_fichier($htpasswd . '-admin', $p2);
425
+            spip_log("Ecriture de $htpasswd et $htpasswd-admin");
426
+        }
427
+    }
428 428
 }
Please login to merge, or discard this patch.
ecrire/install/etape_3b.php 1 patch
Indentation   +134 added lines, -134 removed lines patch added patch discarded remove patch
@@ -11,143 +11,143 @@
 block discarded – undo
11 11
 \***************************************************************************/
12 12
 
13 13
 if (!defined('_ECRIRE_INC_VERSION')) {
14
-	return;
14
+    return;
15 15
 }
16 16
 
17 17
 include_spip('inc/headers');
18 18
 
19 19
 function install_etape_3b_dist() {
20
-	$login = _request('login');
21
-	$email = _request('email');
22
-	$nom = _request('nom');
23
-	$pass = _request('pass');
24
-	$pass_verif = _request('pass_verif');
25
-
26
-	$server_db = defined('_INSTALL_SERVER_DB')
27
-		? _INSTALL_SERVER_DB
28
-		: _request('server_db');
29
-
30
-	if (!defined('_PASS_LONGUEUR_MINI')) {
31
-		define('_PASS_LONGUEUR_MINI', 6);
32
-	}
33
-	if (!defined('_LOGIN_TROP_COURT')) {
34
-		define('_LOGIN_TROP_COURT', 4);
35
-	}
36
-	if ($login) {
37
-		$echec = ($pass != $pass_verif) ?
38
-			_T('info_passes_identiques')
39
-			: ((strlen($pass) < _PASS_LONGUEUR_MINI) ?
40
-				_T('info_passe_trop_court_car_pluriel', array('nb' => _PASS_LONGUEUR_MINI))
41
-				: ((strlen($login) < _LOGIN_TROP_COURT) ?
42
-					_T('info_login_trop_court')
43
-					: ''));
44
-		include_spip('inc/filtres');
45
-		if (!$echec and $email and !email_valide($email)) {
46
-			$echec = _T('form_email_non_valide');
47
-		}
48
-		if ($echec) {
49
-			echo minipres(
50
-				'AUTO',
51
-				info_progression_etape(3, 'etape_', 'install/', true) .
52
-				"<div class='error'><h3>$echec</h3>\n" .
53
-				'<p>' . _T('avis_connexion_echec_2') . '</p>' .
54
-				'</div>'
55
-			);
56
-			exit;
57
-		}
58
-	}
59
-
60
-	if (@file_exists(_FILE_CHMOD_TMP)) {
61
-		include(_FILE_CHMOD_TMP);
62
-	} else {
63
-		redirige_url_ecrire('install');
64
-	}
65
-
66
-	if (!@file_exists(_FILE_CONNECT_TMP)) {
67
-		redirige_url_ecrire('install');
68
-	}
69
-
70
-	# maintenant on connait le vrai charset du site s'il est deja configure
71
-	# sinon par defaut lire_meta reglera _DEFAULT_CHARSET
72
-	# (les donnees arrivent de toute facon postees en _DEFAULT_CHARSET)
73
-
74
-	lire_metas();
75
-	if ($login) {
76
-		include_spip('inc/charsets');
77
-
78
-		$nom = (importer_charset($nom, _DEFAULT_CHARSET));
79
-		$login = (importer_charset($login, _DEFAULT_CHARSET));
80
-		$email = (importer_charset($email, _DEFAULT_CHARSET));
81
-		# pour le passwd, bizarrement il faut le convertir comme s'il avait
82
-		# ete tape en iso-8859-1 ; car c'est en fait ce que voit md5.js
83
-		$pass = unicode2charset(utf_8_to_unicode($pass), 'iso-8859-1');
84
-		include_spip('auth/sha256.inc');
85
-		include_spip('inc/acces');
86
-		$htpass = generer_htpass($pass);
87
-		$alea_actuel = creer_uniqid();
88
-		$alea_futur = creer_uniqid();
89
-		$shapass = spip_sha256($alea_actuel . $pass);
90
-		// prelablement, creer le champ webmestre si il n'existe pas (install neuve
91
-		// sur une vieille base
92
-		$t = sql_showtable('spip_auteurs', true);
93
-		if (!isset($t['field']['webmestre'])) {
94
-			@sql_alter("TABLE spip_auteurs ADD webmestre varchar(3)  DEFAULT 'non' NOT NULL");
95
-		}
96
-
97
-		$id_auteur = sql_getfetsel('id_auteur', 'spip_auteurs', 'login=' . sql_quote($login));
98
-		if ($id_auteur !== null) {
99
-			sql_updateq('spip_auteurs', array(
100
-				'nom' => $nom,
101
-				'email' => $email,
102
-				'login' => $login,
103
-				'pass' => $shapass,
104
-				'alea_actuel' => $alea_actuel,
105
-				'alea_futur' => $alea_futur,
106
-				'htpass' => $htpass,
107
-				'statut' => '0minirezo'
108
-			), "id_auteur=$id_auteur");
109
-		} else {
110
-			$id_auteur = sql_insertq('spip_auteurs', array(
111
-				'nom' => $nom,
112
-				'email' => $email,
113
-				'login' => $login,
114
-				'pass' => $shapass,
115
-				'htpass' => $htpass,
116
-				'alea_actuel' => $alea_actuel,
117
-				'alea_futur' => $alea_futur,
118
-				'statut' => '0minirezo'
119
-			));
120
-		}
121
-		// le passer webmestre separrement du reste, au cas ou l'alter n'aurait pas fonctionne
122
-		@sql_updateq('spip_auteurs', array('webmestre' => 'oui'), "id_auteur=$id_auteur");
123
-
124
-		// inserer email comme email webmaster principal
125
-		// (sauf s'il est vide: cas de la re-installation)
126
-		if ($email) {
127
-			ecrire_meta('email_webmaster', $email);
128
-		}
129
-
130
-		// Connecter directement celui qui vient de (re)donner son login
131
-		// mais sans cookie d'admin ni connexion longue
132
-		include_spip('inc/auth');
133
-		if (!$auteur = auth_identifier_login($login, $pass)
134
-			or !auth_loger($auteur, true)
135
-		) {
136
-			spip_log("login automatique impossible $auth_spip $session" . count($row));
137
-		}
138
-	}
139
-
140
-	// installer les metas
141
-	$config = charger_fonction('config', 'inc');
142
-	$config();
143
-
144
-	// activer les plugins
145
-	// leur installation ne peut pas se faire sur le meme hit, il faudra donc
146
-	// poursuivre au hit suivant
147
-	include_spip('inc/plugin');
148
-	actualise_plugins_actifs();
149
-
150
-
151
-	include_spip('inc/distant');
152
-	redirige_par_entete(parametre_url(self(), 'etape', '4', '&'));
20
+    $login = _request('login');
21
+    $email = _request('email');
22
+    $nom = _request('nom');
23
+    $pass = _request('pass');
24
+    $pass_verif = _request('pass_verif');
25
+
26
+    $server_db = defined('_INSTALL_SERVER_DB')
27
+        ? _INSTALL_SERVER_DB
28
+        : _request('server_db');
29
+
30
+    if (!defined('_PASS_LONGUEUR_MINI')) {
31
+        define('_PASS_LONGUEUR_MINI', 6);
32
+    }
33
+    if (!defined('_LOGIN_TROP_COURT')) {
34
+        define('_LOGIN_TROP_COURT', 4);
35
+    }
36
+    if ($login) {
37
+        $echec = ($pass != $pass_verif) ?
38
+            _T('info_passes_identiques')
39
+            : ((strlen($pass) < _PASS_LONGUEUR_MINI) ?
40
+                _T('info_passe_trop_court_car_pluriel', array('nb' => _PASS_LONGUEUR_MINI))
41
+                : ((strlen($login) < _LOGIN_TROP_COURT) ?
42
+                    _T('info_login_trop_court')
43
+                    : ''));
44
+        include_spip('inc/filtres');
45
+        if (!$echec and $email and !email_valide($email)) {
46
+            $echec = _T('form_email_non_valide');
47
+        }
48
+        if ($echec) {
49
+            echo minipres(
50
+                'AUTO',
51
+                info_progression_etape(3, 'etape_', 'install/', true) .
52
+                "<div class='error'><h3>$echec</h3>\n" .
53
+                '<p>' . _T('avis_connexion_echec_2') . '</p>' .
54
+                '</div>'
55
+            );
56
+            exit;
57
+        }
58
+    }
59
+
60
+    if (@file_exists(_FILE_CHMOD_TMP)) {
61
+        include(_FILE_CHMOD_TMP);
62
+    } else {
63
+        redirige_url_ecrire('install');
64
+    }
65
+
66
+    if (!@file_exists(_FILE_CONNECT_TMP)) {
67
+        redirige_url_ecrire('install');
68
+    }
69
+
70
+    # maintenant on connait le vrai charset du site s'il est deja configure
71
+    # sinon par defaut lire_meta reglera _DEFAULT_CHARSET
72
+    # (les donnees arrivent de toute facon postees en _DEFAULT_CHARSET)
73
+
74
+    lire_metas();
75
+    if ($login) {
76
+        include_spip('inc/charsets');
77
+
78
+        $nom = (importer_charset($nom, _DEFAULT_CHARSET));
79
+        $login = (importer_charset($login, _DEFAULT_CHARSET));
80
+        $email = (importer_charset($email, _DEFAULT_CHARSET));
81
+        # pour le passwd, bizarrement il faut le convertir comme s'il avait
82
+        # ete tape en iso-8859-1 ; car c'est en fait ce que voit md5.js
83
+        $pass = unicode2charset(utf_8_to_unicode($pass), 'iso-8859-1');
84
+        include_spip('auth/sha256.inc');
85
+        include_spip('inc/acces');
86
+        $htpass = generer_htpass($pass);
87
+        $alea_actuel = creer_uniqid();
88
+        $alea_futur = creer_uniqid();
89
+        $shapass = spip_sha256($alea_actuel . $pass);
90
+        // prelablement, creer le champ webmestre si il n'existe pas (install neuve
91
+        // sur une vieille base
92
+        $t = sql_showtable('spip_auteurs', true);
93
+        if (!isset($t['field']['webmestre'])) {
94
+            @sql_alter("TABLE spip_auteurs ADD webmestre varchar(3)  DEFAULT 'non' NOT NULL");
95
+        }
96
+
97
+        $id_auteur = sql_getfetsel('id_auteur', 'spip_auteurs', 'login=' . sql_quote($login));
98
+        if ($id_auteur !== null) {
99
+            sql_updateq('spip_auteurs', array(
100
+                'nom' => $nom,
101
+                'email' => $email,
102
+                'login' => $login,
103
+                'pass' => $shapass,
104
+                'alea_actuel' => $alea_actuel,
105
+                'alea_futur' => $alea_futur,
106
+                'htpass' => $htpass,
107
+                'statut' => '0minirezo'
108
+            ), "id_auteur=$id_auteur");
109
+        } else {
110
+            $id_auteur = sql_insertq('spip_auteurs', array(
111
+                'nom' => $nom,
112
+                'email' => $email,
113
+                'login' => $login,
114
+                'pass' => $shapass,
115
+                'htpass' => $htpass,
116
+                'alea_actuel' => $alea_actuel,
117
+                'alea_futur' => $alea_futur,
118
+                'statut' => '0minirezo'
119
+            ));
120
+        }
121
+        // le passer webmestre separrement du reste, au cas ou l'alter n'aurait pas fonctionne
122
+        @sql_updateq('spip_auteurs', array('webmestre' => 'oui'), "id_auteur=$id_auteur");
123
+
124
+        // inserer email comme email webmaster principal
125
+        // (sauf s'il est vide: cas de la re-installation)
126
+        if ($email) {
127
+            ecrire_meta('email_webmaster', $email);
128
+        }
129
+
130
+        // Connecter directement celui qui vient de (re)donner son login
131
+        // mais sans cookie d'admin ni connexion longue
132
+        include_spip('inc/auth');
133
+        if (!$auteur = auth_identifier_login($login, $pass)
134
+            or !auth_loger($auteur, true)
135
+        ) {
136
+            spip_log("login automatique impossible $auth_spip $session" . count($row));
137
+        }
138
+    }
139
+
140
+    // installer les metas
141
+    $config = charger_fonction('config', 'inc');
142
+    $config();
143
+
144
+    // activer les plugins
145
+    // leur installation ne peut pas se faire sur le meme hit, il faudra donc
146
+    // poursuivre au hit suivant
147
+    include_spip('inc/plugin');
148
+    actualise_plugins_actifs();
149
+
150
+
151
+    include_spip('inc/distant');
152
+    redirige_par_entete(parametre_url(self(), 'etape', '4', '&'));
153 153
 }
Please login to merge, or discard this patch.
prive/objets/liste/auteurs_fonctions.php 1 patch
Indentation   +74 added lines, -74 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
  * @package SPIP\Core\Fonctions
17 17
  **/
18 18
 if (!defined('_ECRIRE_INC_VERSION')) {
19
-	return;
19
+    return;
20 20
 }
21 21
 
22 22
 /**
@@ -29,29 +29,29 @@  discard block
 block discarded – undo
29 29
  * @param bool $left
30 30
  */
31 31
 function critere_compteur_articles_filtres_dist($idb, &$boucles, $crit, $left = false) {
32
-	$boucle = &$boucles[$idb];
32
+    $boucle = &$boucles[$idb];
33 33
 
34
-	$_statut = calculer_liste($crit->param[0], array(), $boucles, $boucle->id_parent);
34
+    $_statut = calculer_liste($crit->param[0], array(), $boucles, $boucle->id_parent);
35 35
 
36
-	$not = '';
37
-	if ($crit->not) {
38
-		$not = ", 'NOT'";
39
-	}
40
-	$boucle->from['LAA'] = 'spip_auteurs_liens';
41
-	$boucle->from_type['LAA'] = 'left';
42
-	$boucle->join['LAA'] = array("'auteurs'", "'id_auteur'", "'id_auteur'", "'LAA.objet=\'article\''");
36
+    $not = '';
37
+    if ($crit->not) {
38
+        $not = ", 'NOT'";
39
+    }
40
+    $boucle->from['LAA'] = 'spip_auteurs_liens';
41
+    $boucle->from_type['LAA'] = 'left';
42
+    $boucle->join['LAA'] = array("'auteurs'", "'id_auteur'", "'id_auteur'", "'LAA.objet=\'article\''");
43 43
 
44
-	$boucle->from['articles'] = 'spip_articles';
45
-	$boucle->from_type['articles'] = 'left';
46
-	$boucle->join['articles'] = array(
47
-		"'LAA'",
48
-		"'id_article'",
49
-		"'id_objet'",
50
-		"'(articles.statut IS NULL OR '.sql_in('articles.statut',_q($_statut)$not).')'"
51
-	);
44
+    $boucle->from['articles'] = 'spip_articles';
45
+    $boucle->from_type['articles'] = 'left';
46
+    $boucle->join['articles'] = array(
47
+        "'LAA'",
48
+        "'id_article'",
49
+        "'id_objet'",
50
+        "'(articles.statut IS NULL OR '.sql_in('articles.statut',_q($_statut)$not).')'"
51
+    );
52 52
 
53
-	$boucle->select[] = 'COUNT(articles.id_article) AS compteur_articles';
54
-	$boucle->group[] = 'auteurs.id_auteur';
53
+    $boucle->select[] = 'COUNT(articles.id_article) AS compteur_articles';
54
+    $boucle->group[] = 'auteurs.id_auteur';
55 55
 }
56 56
 
57 57
 /**
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
  *     Pile complétée par le code à générer
70 70
  */
71 71
 function balise_COMPTEUR_ARTICLES_dist($p) {
72
-	return rindex_pile($p, 'compteur_articles', 'compteur_articles_filtres');
72
+    return rindex_pile($p, 'compteur_articles', 'compteur_articles_filtres');
73 73
 }
74 74
 
75 75
 
@@ -85,43 +85,43 @@  discard block
 block discarded – undo
85 85
  * @return string
86 86
  */
87 87
 function afficher_initiale($url, $initiale, $compteur, $debut, $pas) {
88
-	static $memo = null;
89
-	static $res = [];
90
-	$out = '';
91
-	if (!$memo
92
-		or (!$initiale and !$url)
93
-		or ($initiale !== $memo['initiale'])
94
-	) {
95
-		$newcompt = intval(floor(($compteur - 1) / $pas) * $pas);
96
-		// si fin de la pagination et une seule entree, ne pas l'afficher, ca ne sert a rien
97
-		if (!$initiale and !$url and !$memo['compteur']) {
98
-			$memo = null;
99
-		}
100
-		if ($memo) {
101
-			$on = (($memo['compteur'] <= $debut)
102
-				and (
103
-					$newcompt > $debut or ($newcompt == $debut and $newcompt == $memo['compteur'])
104
-				));
105
-			$res[] = lien_ou_expose($memo['url'], $memo['initiale'], $on, 'lien_pagination');
106
-		}
107
-		if ($initiale) {
108
-			$memo = array(
109
-				'entree' => isset($memo['entree']) ? $memo['entree'] + 1 : 0,
110
-				'initiale' => $initiale,
111
-				'url' => parametre_url($url, 'i', $initiale),
112
-				'compteur' => $newcompt
113
-			);
114
-		}
115
-	}
116
-	if (!$initiale and !$url) {
117
-		if (count($res) > 1) {
118
-			$out = implode(' ', $res);
119
-		}
120
-		$memo = null;
121
-		$res = [];
122
-	}
88
+    static $memo = null;
89
+    static $res = [];
90
+    $out = '';
91
+    if (!$memo
92
+        or (!$initiale and !$url)
93
+        or ($initiale !== $memo['initiale'])
94
+    ) {
95
+        $newcompt = intval(floor(($compteur - 1) / $pas) * $pas);
96
+        // si fin de la pagination et une seule entree, ne pas l'afficher, ca ne sert a rien
97
+        if (!$initiale and !$url and !$memo['compteur']) {
98
+            $memo = null;
99
+        }
100
+        if ($memo) {
101
+            $on = (($memo['compteur'] <= $debut)
102
+                and (
103
+                    $newcompt > $debut or ($newcompt == $debut and $newcompt == $memo['compteur'])
104
+                ));
105
+            $res[] = lien_ou_expose($memo['url'], $memo['initiale'], $on, 'lien_pagination');
106
+        }
107
+        if ($initiale) {
108
+            $memo = array(
109
+                'entree' => isset($memo['entree']) ? $memo['entree'] + 1 : 0,
110
+                'initiale' => $initiale,
111
+                'url' => parametre_url($url, 'i', $initiale),
112
+                'compteur' => $newcompt
113
+            );
114
+        }
115
+    }
116
+    if (!$initiale and !$url) {
117
+        if (count($res) > 1) {
118
+            $out = implode(' ', $res);
119
+        }
120
+        $memo = null;
121
+        $res = [];
122
+    }
123 123
 
124
-	return $out;
124
+    return $out;
125 125
 }
126 126
 
127 127
 /**
@@ -140,23 +140,23 @@  discard block
 block discarded – undo
140 140
  * @return string
141 141
  */
142 142
 function auteur_lien_messagerie($id_auteur, $en_ligne, $statut, $imessage, $email = '') {
143
-	static $time = null;
144
-	if (!in_array($statut, array('0minirezo', '1comite'))) {
145
-		return '';
146
-	}
143
+    static $time = null;
144
+    if (!in_array($statut, array('0minirezo', '1comite'))) {
145
+        return '';
146
+    }
147 147
 
148
-	if (is_null($time)) {
149
-		$time = time();
150
-	}
151
-	$parti = (($time - strtotime($en_ligne)) > 15 * 60);
148
+    if (is_null($time)) {
149
+        $time = time();
150
+    }
151
+    $parti = (($time - strtotime($en_ligne)) > 15 * 60);
152 152
 
153
-	if ($imessage != 'non' and !$parti // historique : est-ce que ca a encore un sens de limiter vu qu'on a la notification par email ?
154
-		and $GLOBALS['meta']['messagerie_agenda'] != 'non'
155
-	) {
156
-		return parametre_url(parametre_url(generer_url_ecrire('message_edit', 'new=oui'), 'to', $id_auteur), 'redirect', self());
157
-	} elseif (strlen($email) and autoriser('voir', 'auteur', $id_auteur)) {
158
-		return 'mailto:' . $email;
159
-	} else {
160
-		return '';
161
-	}
153
+    if ($imessage != 'non' and !$parti // historique : est-ce que ca a encore un sens de limiter vu qu'on a la notification par email ?
154
+        and $GLOBALS['meta']['messagerie_agenda'] != 'non'
155
+    ) {
156
+        return parametre_url(parametre_url(generer_url_ecrire('message_edit', 'new=oui'), 'to', $id_auteur), 'redirect', self());
157
+    } elseif (strlen($email) and autoriser('voir', 'auteur', $id_auteur)) {
158
+        return 'mailto:' . $email;
159
+    } else {
160
+        return '';
161
+    }
162 162
 }
Please login to merge, or discard this patch.
ecrire/inc/filtres_mini.php 1 patch
Indentation   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
  **/
18 18
 
19 19
 if (!defined('_ECRIRE_INC_VERSION')) {
20
-	return;
20
+    return;
21 21
 }
22 22
 
23 23
 
@@ -35,19 +35,19 @@  discard block
 block discarded – undo
35 35
  * @return string URL nettoyée
36 36
  **/
37 37
 function resolve_path($url) {
38
-	list($url, $query) = array_pad(explode('?', $url, 2), 2, null);
39
-	while (preg_match(',/\.?/,', $url, $regs)    # supprime // et /./
40
-		or preg_match(',/[^/]*/\.\./,S', $url, $regs)  # supprime /toto/../
41
-		or preg_match(',^/\.\./,S', $url, $regs) # supprime les /../ du haut
42
-	) {
43
-		$url = str_replace($regs[0], '/', $url);
44
-	}
38
+    list($url, $query) = array_pad(explode('?', $url, 2), 2, null);
39
+    while (preg_match(',/\.?/,', $url, $regs)    # supprime // et /./
40
+        or preg_match(',/[^/]*/\.\./,S', $url, $regs)  # supprime /toto/../
41
+        or preg_match(',^/\.\./,S', $url, $regs) # supprime les /../ du haut
42
+    ) {
43
+        $url = str_replace($regs[0], '/', $url);
44
+    }
45 45
 
46
-	if ($query) {
47
-		$url .= '?' . $query;
48
-	}
46
+    if ($query) {
47
+        $url .= '?' . $query;
48
+    }
49 49
 
50
-	return '/' . preg_replace(',^/,S', '', $url);
50
+    return '/' . preg_replace(',^/,S', '', $url);
51 51
 }
52 52
 
53 53
 
@@ -68,41 +68,41 @@  discard block
 block discarded – undo
68 68
  **/
69 69
 function suivre_lien($url, $lien) {
70 70
 
71
-	if (preg_match(',^(mailto|javascript|data|tel|callto|file|ftp):,iS', $lien)) {
72
-		return $lien;
73
-	}
74
-	if (preg_match(';^((?:[a-z]{3,33}:)?//.*?)(/.*)?$;iS', $lien, $r)) {
75
-		$r = array_pad($r, 3, null);
71
+    if (preg_match(',^(mailto|javascript|data|tel|callto|file|ftp):,iS', $lien)) {
72
+        return $lien;
73
+    }
74
+    if (preg_match(';^((?:[a-z]{3,33}:)?//.*?)(/.*)?$;iS', $lien, $r)) {
75
+        $r = array_pad($r, 3, null);
76 76
 
77
-		return $r[1] . resolve_path($r[2]);
78
-	}
77
+        return $r[1] . resolve_path($r[2]);
78
+    }
79 79
 
80
-	# L'url site spip est un lien absolu aussi
81
-	if (isset($GLOBALS['meta']['adresse_site']) and $lien == $GLOBALS['meta']['adresse_site']) {
82
-		return $lien;
83
-	}
80
+    # L'url site spip est un lien absolu aussi
81
+    if (isset($GLOBALS['meta']['adresse_site']) and $lien == $GLOBALS['meta']['adresse_site']) {
82
+        return $lien;
83
+    }
84 84
 
85
-	# lien relatif, il faut verifier l'url de base
86
-	# commencer par virer la chaine de get de l'url de base
87
-	$dir = '/';
88
-	$debut = '';
89
-	if (preg_match(';^((?:[a-z]{3,7}:)?//[^/]+)(/.*?/?)?([^/#?]*)([?][^#]*)?(#.*)?$;S', $url, $regs)) {
90
-		$debut = $regs[1];
91
-		$dir = !strlen($regs[2]) ? '/' : $regs[2];
92
-		$mot = $regs[3];
93
-		$get = isset($regs[4]) ? $regs[4] : '';
94
-		$hash = isset($regs[5]) ? $regs[5] : '';
95
-	}
96
-	switch (substr($lien, 0, 1)) {
97
-		case '/':
98
-			return $debut . resolve_path($lien);
99
-		case '#':
100
-			return $debut . resolve_path($dir . $mot . $get . $lien);
101
-		case '':
102
-			return $debut . resolve_path($dir . $mot . $get . $hash);
103
-		default:
104
-			return $debut . resolve_path($dir . $lien);
105
-	}
85
+    # lien relatif, il faut verifier l'url de base
86
+    # commencer par virer la chaine de get de l'url de base
87
+    $dir = '/';
88
+    $debut = '';
89
+    if (preg_match(';^((?:[a-z]{3,7}:)?//[^/]+)(/.*?/?)?([^/#?]*)([?][^#]*)?(#.*)?$;S', $url, $regs)) {
90
+        $debut = $regs[1];
91
+        $dir = !strlen($regs[2]) ? '/' : $regs[2];
92
+        $mot = $regs[3];
93
+        $get = isset($regs[4]) ? $regs[4] : '';
94
+        $hash = isset($regs[5]) ? $regs[5] : '';
95
+    }
96
+    switch (substr($lien, 0, 1)) {
97
+        case '/':
98
+            return $debut . resolve_path($lien);
99
+        case '#':
100
+            return $debut . resolve_path($dir . $mot . $get . $lien);
101
+        case '':
102
+            return $debut . resolve_path($dir . $mot . $get . $hash);
103
+        default:
104
+            return $debut . resolve_path($dir . $lien);
105
+    }
106 106
 }
107 107
 
108 108
 
@@ -125,14 +125,14 @@  discard block
 block discarded – undo
125 125
  * @return string Texte ou URL (en absolus)
126 126
  **/
127 127
 function url_absolue($url, $base = '') {
128
-	if (strlen($url = trim($url)) == 0) {
129
-		return '';
130
-	}
131
-	if (!$base) {
132
-		$base = url_de_base() . (_DIR_RACINE ? _DIR_RESTREINT_ABS : '');
133
-	}
128
+    if (strlen($url = trim($url)) == 0) {
129
+        return '';
130
+    }
131
+    if (!$base) {
132
+        $base = url_de_base() . (_DIR_RACINE ? _DIR_RESTREINT_ABS : '');
133
+    }
134 134
 
135
-	return suivre_lien($base, $url);
135
+    return suivre_lien($base, $url);
136 136
 }
137 137
 
138 138
 /**
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
  * @return string
144 144
  */
145 145
 function protocole_implicite($url_absolue) {
146
-	return preg_replace(';^[a-z]{3,7}://;i', '//', $url_absolue);
146
+    return preg_replace(';^[a-z]{3,7}://;i', '//', $url_absolue);
147 147
 }
148 148
 
149 149
 /**
@@ -154,14 +154,14 @@  discard block
 block discarded – undo
154 154
  */
155 155
 function protocole_verifier($url_absolue, $protocoles_autorises = array('http','https')) {
156 156
 
157
-	if (preg_match(';^([a-z]{3,7})://;i', $url_absolue, $m)) {
158
-		$protocole = $m[1];
159
-		if (in_array($protocole, $protocoles_autorises)
160
-		  or in_array(strtolower($protocole), array_map('strtolower', $protocoles_autorises))) {
161
-			return true;
162
-		}
163
-	}
164
-	return false;
157
+    if (preg_match(';^([a-z]{3,7})://;i', $url_absolue, $m)) {
158
+        $protocole = $m[1];
159
+        if (in_array($protocole, $protocoles_autorises)
160
+          or in_array(strtolower($protocole), array_map('strtolower', $protocoles_autorises))) {
161
+            return true;
162
+        }
163
+    }
164
+    return false;
165 165
 }
166 166
 
167 167
 /**
@@ -178,27 +178,27 @@  discard block
 block discarded – undo
178 178
  * @return string Texte avec des URLs absolues
179 179
  **/
180 180
 function liens_absolus($texte, $base = '') {
181
-	if (preg_match_all(',(<(a|link|image|img|script)\s[^<>]*(href|src)=[^<>]*>),imsS', $texte, $liens, PREG_SET_ORDER)) {
182
-		if (!function_exists('extraire_attribut')) {
183
-			include_spip('inc/filtres');
184
-		}
185
-		foreach ($liens as $lien) {
186
-			foreach (array('href', 'src') as $attr) {
187
-				$href = extraire_attribut($lien[0], $attr);
188
-				if (strlen($href) > 0) {
189
-					if (!preg_match(';^((?:[a-z]{3,7}:)?//);iS', $href)) {
190
-						$abs = url_absolue($href, $base);
191
-						if (rtrim($href, '/') !== rtrim($abs, '/') and !preg_match('/^#/', $href)) {
192
-							$texte_lien = inserer_attribut($lien[0], $attr, $abs);
193
-							$texte = str_replace($lien[0], $texte_lien, $texte);
194
-						}
195
-					}
196
-				}
197
-			}
198
-		}
199
-	}
181
+    if (preg_match_all(',(<(a|link|image|img|script)\s[^<>]*(href|src)=[^<>]*>),imsS', $texte, $liens, PREG_SET_ORDER)) {
182
+        if (!function_exists('extraire_attribut')) {
183
+            include_spip('inc/filtres');
184
+        }
185
+        foreach ($liens as $lien) {
186
+            foreach (array('href', 'src') as $attr) {
187
+                $href = extraire_attribut($lien[0], $attr);
188
+                if (strlen($href) > 0) {
189
+                    if (!preg_match(';^((?:[a-z]{3,7}:)?//);iS', $href)) {
190
+                        $abs = url_absolue($href, $base);
191
+                        if (rtrim($href, '/') !== rtrim($abs, '/') and !preg_match('/^#/', $href)) {
192
+                            $texte_lien = inserer_attribut($lien[0], $attr, $abs);
193
+                            $texte = str_replace($lien[0], $texte_lien, $texte);
194
+                        }
195
+                    }
196
+                }
197
+            }
198
+        }
199
+    }
200 200
 
201
-	return $texte;
201
+    return $texte;
202 202
 }
203 203
 
204 204
 
@@ -214,11 +214,11 @@  discard block
 block discarded – undo
214 214
  * @return string Texte ou URL (en absolus)
215 215
  **/
216 216
 function abs_url($texte, $base = '') {
217
-	if ($GLOBALS['mode_abs_url'] == 'url') {
218
-		return url_absolue($texte, $base);
219
-	} else {
220
-		return liens_absolus($texte, $base);
221
-	}
217
+    if ($GLOBALS['mode_abs_url'] == 'url') {
218
+        return url_absolue($texte, $base);
219
+    } else {
220
+        return liens_absolus($texte, $base);
221
+    }
222 222
 }
223 223
 
224 224
 /**
@@ -231,11 +231,11 @@  discard block
 block discarded – undo
231 231
  * @return string
232 232
  */
233 233
 function spip_htmlspecialchars($string, $flags = null, $encoding = 'UTF-8', $double_encode = true) {
234
-	if (is_null($flags)) {
235
-		$flags = ENT_COMPAT|ENT_HTML401;
236
-	}
234
+    if (is_null($flags)) {
235
+        $flags = ENT_COMPAT|ENT_HTML401;
236
+    }
237 237
 
238
-	return htmlspecialchars($string, $flags, $encoding, $double_encode);
238
+    return htmlspecialchars($string, $flags, $encoding, $double_encode);
239 239
 }
240 240
 
241 241
 /**
@@ -248,9 +248,9 @@  discard block
 block discarded – undo
248 248
  * @return string
249 249
  */
250 250
 function spip_htmlentities($string, $flags = null, $encoding = 'UTF-8', $double_encode = true) {
251
-	if (is_null($flags)) {
252
-		$flags = ENT_COMPAT|ENT_HTML401;
253
-	}
251
+    if (is_null($flags)) {
252
+        $flags = ENT_COMPAT|ENT_HTML401;
253
+    }
254 254
 
255
-	return htmlentities($string, $flags, $encoding, $double_encode);
255
+    return htmlentities($string, $flags, $encoding, $double_encode);
256 256
 }
Please login to merge, or discard this patch.