Completed
Push — spip-3.0 ( 484b62...e817f1 )
by cam
34:33
created
ecrire/inc/filtres_boites.php 1 patch
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -22,17 +22,17 @@  discard block
 block discarded – undo
22 22
  * @return <type>
23 23
  */
24 24
 function balise_BOITE_OUVRIR_dist($p) {
25
-	$_titre = interprete_argument_balise(1,$p);
26
-	$_class = interprete_argument_balise(2,$p);
27
-	$_head_class = interprete_argument_balise(3,$p);
28
-	$_titre = ($_titre?$_titre:"''");
29
-	$_class = ($_class?", $_class":", 'simple'");
30
-	$_head_class = ($_head_class?", $_head_class":"");
31
-
32
-	$f = chercher_filtre('boite_ouvrir');
33
-	$p->code = "$f($_titre$_class$_head_class)";
34
-	$p->interdire_scripts = false;
35
-	return $p;
25
+    $_titre = interprete_argument_balise(1,$p);
26
+    $_class = interprete_argument_balise(2,$p);
27
+    $_head_class = interprete_argument_balise(3,$p);
28
+    $_titre = ($_titre?$_titre:"''");
29
+    $_class = ($_class?", $_class":", 'simple'");
30
+    $_head_class = ($_head_class?", $_head_class":"");
31
+
32
+    $f = chercher_filtre('boite_ouvrir');
33
+    $p->code = "$f($_titre$_class$_head_class)";
34
+    $p->interdire_scripts = false;
35
+    return $p;
36 36
 }
37 37
 
38 38
 /**
@@ -43,13 +43,13 @@  discard block
 block discarded – undo
43 43
  * @return <type>
44 44
  */
45 45
 function balise_BOITE_PIED_dist($p) {
46
-	$_class = interprete_argument_balise(1,$p);
47
-	$_class = ($_class?"$_class":"");
46
+    $_class = interprete_argument_balise(1,$p);
47
+    $_class = ($_class?"$_class":"");
48 48
 
49
-	$f = chercher_filtre('boite_pied');
50
-	$p->code = "$f($_class)";
51
-	$p->interdire_scripts = false;
52
-	return $p;
49
+    $f = chercher_filtre('boite_pied');
50
+    $p->code = "$f($_class)";
51
+    $p->interdire_scripts = false;
52
+    return $p;
53 53
 }
54 54
 
55 55
 /**
@@ -60,10 +60,10 @@  discard block
 block discarded – undo
60 60
  * @return <type>
61 61
  */
62 62
 function balise_BOITE_FERMER_dist($p) {
63
-	$f = chercher_filtre('boite_fermer');
64
-	$p->code = "$f()";
65
-	$p->interdire_scripts = false;
66
-	return $p;
63
+    $f = chercher_filtre('boite_fermer');
64
+    $p->code = "$f()";
65
+    $p->interdire_scripts = false;
66
+    return $p;
67 67
 }
68 68
 
69 69
 /**
@@ -75,16 +75,16 @@  discard block
 block discarded – undo
75 75
  * @return <type>
76 76
  */
77 77
 function boite_ouvrir($titre, $class='', $head_class='', $id=""){
78
-	$class = "box $class";
79
-	$head_class = "hd $head_class";
80
-	// dans l'espace prive, titrer en h3 si pas de balise <hn>
81
-	if (test_espace_prive() AND strlen($titre) AND strpos($titre,'<h')===false)
82
-		$titre = "<h3>$titre</h3>";
83
-	return '<div class="'.$class.($id?"\" id=\"$id":"").'">'
84
-	.'<b class="top"><b class="tl"></b><b class="tr"></b></b>'
85
-	.'<div class="inner">'
86
-	.($titre?'<div class="'.$head_class.'">'.$titre.'<div class="nettoyeur"></div><!--/hd--></div>':'')
87
-	.'<div class="bd">';
78
+    $class = "box $class";
79
+    $head_class = "hd $head_class";
80
+    // dans l'espace prive, titrer en h3 si pas de balise <hn>
81
+    if (test_espace_prive() AND strlen($titre) AND strpos($titre,'<h')===false)
82
+        $titre = "<h3>$titre</h3>";
83
+    return '<div class="'.$class.($id?"\" id=\"$id":"").'">'
84
+    .'<b class="top"><b class="tl"></b><b class="tr"></b></b>'
85
+    .'<div class="inner">'
86
+    .($titre?'<div class="'.$head_class.'">'.$titre.'<div class="nettoyeur"></div><!--/hd--></div>':'')
87
+    .'<div class="bd">';
88 88
 }
89 89
 
90 90
 /**
@@ -95,9 +95,9 @@  discard block
 block discarded – undo
95 95
  * @return <type>
96 96
  */
97 97
 function boite_pied($class='act'){
98
-	$class = "ft $class";
99
-	return 	'<div class="nettoyeur"></div></div>'
100
-	.'<div class="'.$class.'">';
98
+    $class = "ft $class";
99
+    return 	'<div class="nettoyeur"></div></div>'
100
+    .'<div class="'.$class.'">';
101 101
 }
102 102
 
103 103
 /**
@@ -107,9 +107,9 @@  discard block
 block discarded – undo
107 107
  * @return <type>
108 108
  */
109 109
 function boite_fermer(){
110
-	return '<div class="nettoyeur"></div></div></div>'
111
-	.'<b class="bottom"><b class="bl"></b><b class="br"></b></b>'
112
-	.'</div>';
110
+    return '<div class="nettoyeur"></div></div></div>'
111
+    .'<b class="bottom"><b class="bl"></b><b class="br"></b></b>'
112
+    .'</div>';
113 113
 }
114 114
 
115 115
 
Please login to merge, or discard this patch.
ecrire/inc/headers.php 1 patch
Indentation   +128 added lines, -128 removed lines patch added patch discarded remove patch
@@ -18,160 +18,160 @@
 block discarded – undo
18 18
 
19 19
 // http://doc.spip.org/@redirige_par_entete
20 20
 function redirige_par_entete($url, $equiv='', $status = 302) {
21
-	if (!in_array($status,array(301,302)))
22
-		$status = 302;
23
-
24
-	$url = trim(strtr($url, "\n\r", "  "));
25
-	# en theorie on devrait faire ca tout le temps, mais quand la chaine
26
-	# commence par ? c'est imperatif, sinon l'url finale n'est pas la bonne
27
-	if ($url[0]=='?')
28
-		$url = url_de_base().$url;
29
-	if ($url[0]=='#')
30
-		$url = self('&').$url;
31
-	# si profondeur non nulle et url relative, il faut la passer en absolue
32
-	if ($GLOBALS['profondeur_url']>(_DIR_RESTREINT?1:2)
33
-		AND !preg_match(",^(\w+:)?//,",$url)){
34
-		include_spip("inc/filtres_mini");
35
-		$url = url_absolue($url);
36
-	}
37
-
38
-	if ($x = _request('transformer_xml'))
39
-		$url = parametre_url($url, 'transformer_xml', $x, '&');
40
-
41
-	if (defined('_AJAX') AND _AJAX)
42
-		$url = parametre_url($url, 'var_ajax_redir', 1, '&');
21
+    if (!in_array($status,array(301,302)))
22
+        $status = 302;
23
+
24
+    $url = trim(strtr($url, "\n\r", "  "));
25
+    # en theorie on devrait faire ca tout le temps, mais quand la chaine
26
+    # commence par ? c'est imperatif, sinon l'url finale n'est pas la bonne
27
+    if ($url[0]=='?')
28
+        $url = url_de_base().$url;
29
+    if ($url[0]=='#')
30
+        $url = self('&').$url;
31
+    # si profondeur non nulle et url relative, il faut la passer en absolue
32
+    if ($GLOBALS['profondeur_url']>(_DIR_RESTREINT?1:2)
33
+        AND !preg_match(",^(\w+:)?//,",$url)){
34
+        include_spip("inc/filtres_mini");
35
+        $url = url_absolue($url);
36
+    }
37
+
38
+    if ($x = _request('transformer_xml'))
39
+        $url = parametre_url($url, 'transformer_xml', $x, '&');
40
+
41
+    if (defined('_AJAX') AND _AJAX)
42
+        $url = parametre_url($url, 'var_ajax_redir', 1, '&');
43 43
 		
44
-	// ne pas laisser passer n'importe quoi dans l'url
45
-	$url = str_replace(array('<','"'),array('&lt;','&quot;'),$url);
46
-	// interdire les url inline avec des pseudo-protocoles :
47
-	if (
48
-		(preg_match(",data:,i",$url) AND preg_match("/base64\s*,/i",$url))
49
-		OR preg_match(",(javascript|mailto):,i",$url)
50
-		)
51
-		$url ="./";
52
-
53
-	// Il n'y a que sous Apache que setcookie puis redirection fonctionne
54
-  include_spip('inc/cookie');
55
-	if ((!$equiv AND !spip_cookie_envoye()) OR ((strncmp("Apache", $_SERVER['SERVER_SOFTWARE'],6)==0) OR defined('_SERVER_APACHE'))) {
56
-		@header("Location: " . $url);
57
-		$equiv="";
58
-	} else {
59
-		@header("Refresh: 0; url=" . $url);
60
-		$equiv = "<meta http-equiv='Refresh' content='0; url=$url'>";
61
-	}
62
-	include_spip('inc/lang');
63
-	if ($status!=302)
64
-		http_status($status);
65
-	echo '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">',"\n",
66
-	  html_lang_attributes(),'
44
+    // ne pas laisser passer n'importe quoi dans l'url
45
+    $url = str_replace(array('<','"'),array('&lt;','&quot;'),$url);
46
+    // interdire les url inline avec des pseudo-protocoles :
47
+    if (
48
+        (preg_match(",data:,i",$url) AND preg_match("/base64\s*,/i",$url))
49
+        OR preg_match(",(javascript|mailto):,i",$url)
50
+        )
51
+        $url ="./";
52
+
53
+    // Il n'y a que sous Apache que setcookie puis redirection fonctionne
54
+    include_spip('inc/cookie');
55
+    if ((!$equiv AND !spip_cookie_envoye()) OR ((strncmp("Apache", $_SERVER['SERVER_SOFTWARE'],6)==0) OR defined('_SERVER_APACHE'))) {
56
+        @header("Location: " . $url);
57
+        $equiv="";
58
+    } else {
59
+        @header("Refresh: 0; url=" . $url);
60
+        $equiv = "<meta http-equiv='Refresh' content='0; url=$url'>";
61
+    }
62
+    include_spip('inc/lang');
63
+    if ($status!=302)
64
+        http_status($status);
65
+    echo '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">',"\n",
66
+        html_lang_attributes(),'
67 67
 <head>',
68
-	  $equiv,'
68
+        $equiv,'
69 69
 <title>HTTP '.$status.'</title>
70 70
 </head>
71 71
 <body>
72 72
 <h1>HTTP '.$status.'</h1>
73 73
 <a href="',
74
-	  quote_amp($url),
75
-	  '">',
76
-	  _T('navigateur_pas_redirige'),
77
-	  '</a></body></html>';
74
+        quote_amp($url),
75
+        '">',
76
+        _T('navigateur_pas_redirige'),
77
+        '</a></body></html>';
78 78
 
79
-	spip_log("redirige $status: $url");
79
+    spip_log("redirige $status: $url");
80 80
 
81
-	exit;
81
+    exit;
82 82
 }
83 83
 
84 84
 // http://doc.spip.org/@redirige_formulaire
85 85
 function redirige_formulaire($url, $equiv = '', $format='message') {
86
-	if (!_AJAX
87
-	AND !headers_sent()
88
-	AND !_request('var_ajax')) {
89
-		redirige_par_entete(str_replace('&amp;','&',$url), $equiv);
90
-	}
91
-	// si c'est une ancre, fixer simplement le window.location.hash
92
-	elseif($format=='ajaxform' AND preg_match(',^#[0-9a-z\-_]+$,i',$url)) {
93
-		return array(
94
-		// on renvoie un lien masque qui sera traite par ajaxCallback.js
95
-		"<a href='$url' name='ajax_ancre' style='display:none;'>anchor</a>",
96
-		// et rien dans le message ok
97
-		'');
98
-	}
99
-	else {
100
-		// ne pas laisser passer n'importe quoi dans l'url
101
-		$url = str_replace(array('<','"'),array('&lt;','&quot;'),$url);
102
-
103
-		$url = strtr($url, "\n\r", "  ");
104
-		# en theorie on devrait faire ca tout le temps, mais quand la chaine
105
-		# commence par ? c'est imperatif, sinon l'url finale n'est pas la bonne
106
-		if ($url[0]=='?')
107
-			$url = url_de_base().$url;
108
-		$url = str_replace('&amp;','&',$url);
109
-		spip_log("redirige formulaire ajax: $url");
110
-		include_spip('inc/filtres');
111
-		if ($format=='ajaxform')
112
-			return array(
113
-			// on renvoie un lien masque qui sera traite par ajaxCallback.js
114
-			'<a href="'.quote_amp($url).'" name="ajax_redirect"  style="display:none;">'._T('navigateur_pas_redirige').'</a>',
115
-			// et un message au cas ou
116
-			'<br /><a href="'.quote_amp($url).'">'._T('navigateur_pas_redirige').'</a>'
117
-			);
118
-		else // format message texte, tout en js inline
119
-			return
120
-		// ie poste les formulaires dans une iframe, il faut donc rediriger son parent
121
-		"<script type='text/javascript'>if (parent.window){parent.window.document.location.replace(\"$url\");} else {document.location.replace(\"$url\");}</script>"
122
-		. http_img_pack('searching.gif','')
123
-		. '<br />'
124
-		. '<a href="'.quote_amp($url).'">'._T('navigateur_pas_redirige').'</a>';
125
-	}
86
+    if (!_AJAX
87
+    AND !headers_sent()
88
+    AND !_request('var_ajax')) {
89
+        redirige_par_entete(str_replace('&amp;','&',$url), $equiv);
90
+    }
91
+    // si c'est une ancre, fixer simplement le window.location.hash
92
+    elseif($format=='ajaxform' AND preg_match(',^#[0-9a-z\-_]+$,i',$url)) {
93
+        return array(
94
+        // on renvoie un lien masque qui sera traite par ajaxCallback.js
95
+        "<a href='$url' name='ajax_ancre' style='display:none;'>anchor</a>",
96
+        // et rien dans le message ok
97
+        '');
98
+    }
99
+    else {
100
+        // ne pas laisser passer n'importe quoi dans l'url
101
+        $url = str_replace(array('<','"'),array('&lt;','&quot;'),$url);
102
+
103
+        $url = strtr($url, "\n\r", "  ");
104
+        # en theorie on devrait faire ca tout le temps, mais quand la chaine
105
+        # commence par ? c'est imperatif, sinon l'url finale n'est pas la bonne
106
+        if ($url[0]=='?')
107
+            $url = url_de_base().$url;
108
+        $url = str_replace('&amp;','&',$url);
109
+        spip_log("redirige formulaire ajax: $url");
110
+        include_spip('inc/filtres');
111
+        if ($format=='ajaxform')
112
+            return array(
113
+            // on renvoie un lien masque qui sera traite par ajaxCallback.js
114
+            '<a href="'.quote_amp($url).'" name="ajax_redirect"  style="display:none;">'._T('navigateur_pas_redirige').'</a>',
115
+            // et un message au cas ou
116
+            '<br /><a href="'.quote_amp($url).'">'._T('navigateur_pas_redirige').'</a>'
117
+            );
118
+        else // format message texte, tout en js inline
119
+            return
120
+        // ie poste les formulaires dans une iframe, il faut donc rediriger son parent
121
+        "<script type='text/javascript'>if (parent.window){parent.window.document.location.replace(\"$url\");} else {document.location.replace(\"$url\");}</script>"
122
+        . http_img_pack('searching.gif','')
123
+        . '<br />'
124
+        . '<a href="'.quote_amp($url).'">'._T('navigateur_pas_redirige').'</a>';
125
+    }
126 126
 }
127 127
 
128 128
 // http://doc.spip.org/@redirige_url_ecrire
129 129
 function redirige_url_ecrire($script='', $args='', $equiv='') {
130
-	return redirige_par_entete(generer_url_ecrire($script, $args, true), $equiv);
130
+    return redirige_par_entete(generer_url_ecrire($script, $args, true), $equiv);
131 131
 }
132 132
 
133 133
 // http://doc.spip.org/@http_status
134 134
 function http_status($status) {
135
-	global $REDIRECT_STATUS, $flag_sapi_name;
136
-	static $status_string = array(
137
-		200 => '200 OK',
138
-		204 => '204 No Content',
139
-		301 => '301 Moved Permanently',
140
-		302 => '302 Found',
141
-		304 => '304 Not Modified',
142
-		401 => '401 Unauthorized',
143
-		403 => '403 Forbidden',
144
-		404 => '404 Not Found',
145
-		503 => '503 Service Unavailable'
146
-	);
147
-
148
-	if ($REDIRECT_STATUS && $REDIRECT_STATUS == $status) return;
149
-
150
-	$php_cgi = ($flag_sapi_name AND preg_match(",cgi,i", @php_sapi_name()));
151
-	if ($php_cgi)
152
-		header("Status: ".$status_string[$status]);
153
-	else
154
-		header("HTTP/1.0 ".$status_string[$status]);
135
+    global $REDIRECT_STATUS, $flag_sapi_name;
136
+    static $status_string = array(
137
+        200 => '200 OK',
138
+        204 => '204 No Content',
139
+        301 => '301 Moved Permanently',
140
+        302 => '302 Found',
141
+        304 => '304 Not Modified',
142
+        401 => '401 Unauthorized',
143
+        403 => '403 Forbidden',
144
+        404 => '404 Not Found',
145
+        503 => '503 Service Unavailable'
146
+    );
147
+
148
+    if ($REDIRECT_STATUS && $REDIRECT_STATUS == $status) return;
149
+
150
+    $php_cgi = ($flag_sapi_name AND preg_match(",cgi,i", @php_sapi_name()));
151
+    if ($php_cgi)
152
+        header("Status: ".$status_string[$status]);
153
+    else
154
+        header("HTTP/1.0 ".$status_string[$status]);
155 155
 }
156 156
 
157 157
 // Retourne ce qui va bien pour que le navigateur ne mette pas la page en cache
158 158
 // http://doc.spip.org/@http_no_cache
159 159
 function http_no_cache() {
160
-	if (headers_sent())
161
-		{ spip_log("http_no_cache arrive trop tard"); return;}
162
-	$charset = empty($GLOBALS['meta']['charset']) ? 'utf-8' : $GLOBALS['meta']['charset'];
163
-
164
-	// selon http://developer.apple.com/internet/safari/faq.html#anchor5
165
-	// il faudrait aussi pour Safari
166
-	// header("Cache-Control: post-check=0, pre-check=0", false)
167
-	// mais ca ne respecte pas
168
-	// http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9
169
-
170
-	header("Content-Type: text/html; charset=$charset");
171
-	header("Expires: 0");
172
-	header("Last-Modified: " .gmdate("D, d M Y H:i:s"). " GMT");
173
-	header("Cache-Control: no-cache, must-revalidate");
174
-	header("Pragma: no-cache");
160
+    if (headers_sent())
161
+        { spip_log("http_no_cache arrive trop tard"); return;}
162
+    $charset = empty($GLOBALS['meta']['charset']) ? 'utf-8' : $GLOBALS['meta']['charset'];
163
+
164
+    // selon http://developer.apple.com/internet/safari/faq.html#anchor5
165
+    // il faudrait aussi pour Safari
166
+    // header("Cache-Control: post-check=0, pre-check=0", false)
167
+    // mais ca ne respecte pas
168
+    // http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.9
169
+
170
+    header("Content-Type: text/html; charset=$charset");
171
+    header("Expires: 0");
172
+    header("Last-Modified: " .gmdate("D, d M Y H:i:s"). " GMT");
173
+    header("Cache-Control: no-cache, must-revalidate");
174
+    header("Pragma: no-cache");
175 175
 }
176 176
 
177 177
 ?>
Please login to merge, or discard this patch.
ecrire/inc/journal.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -22,11 +22,11 @@
 block discarded – undo
22 22
  * @param array $opt
23 23
  */
24 24
 function inc_journal_dist($phrase, $opt = array()) {
25
-	if (!strlen($phrase))
26
-		return;
27
-	if ($opt)
28
-		$phrase .= " :: ".str_replace("\n", ' ', join(', ',$opt));
29
-	spip_log($phrase, 'journal');
25
+    if (!strlen($phrase))
26
+        return;
27
+    if ($opt)
28
+        $phrase .= " :: ".str_replace("\n", ' ', join(', ',$opt));
29
+    spip_log($phrase, 'journal');
30 30
 }
31 31
 
32 32
 ?>
Please login to merge, or discard this patch.
ecrire/inc/admin.php 1 patch
Indentation   +119 added lines, -119 removed lines patch added patch discarded remove patch
@@ -19,22 +19,22 @@  discard block
 block discarded – undo
19 19
 // http://doc.spip.org/@inc_admin_dist
20 20
 function inc_admin_dist($script, $titre, $comment='', $anonymous=false)
21 21
 {
22
-	$reprise = true;
23
-	if (!isset($GLOBALS['meta'][$script])
24
-	OR  !isset($GLOBALS['meta']['admin'])) {
25
-		$reprise = false;
26
-		$res = debut_admin($script, $titre, $comment); 
27
-		if ($res) return $res;
28
-		spip_log("meta: $script " . join(',', $_POST));
29
-		ecrire_meta($script, serialize($_POST));
30
-	} 
31
-
32
-	$res = admin_verifie_session($script,$anonymous);
33
-	if ($res) return $res;
34
-	$base = charger_fonction($script, 'base');
35
-	$base($titre,$reprise);
36
-	fin_admin($script);
37
-	return '';
22
+    $reprise = true;
23
+    if (!isset($GLOBALS['meta'][$script])
24
+    OR  !isset($GLOBALS['meta']['admin'])) {
25
+        $reprise = false;
26
+        $res = debut_admin($script, $titre, $comment); 
27
+        if ($res) return $res;
28
+        spip_log("meta: $script " . join(',', $_POST));
29
+        ecrire_meta($script, serialize($_POST));
30
+    } 
31
+
32
+    $res = admin_verifie_session($script,$anonymous);
33
+    if ($res) return $res;
34
+    $base = charger_fonction($script, 'base');
35
+    $base($titre,$reprise);
36
+    fin_admin($script);
37
+    return '';
38 38
 }
39 39
 
40 40
 // Gestion dans la meta "admin" du script d'administation demande,
@@ -55,46 +55,46 @@  discard block
 block discarded – undo
55 55
 // http://doc.spip.org/@admin_verifie_session
56 56
 function admin_verifie_session($script, $anonymous=false) {
57 57
 
58
-	include_spip('base/abstract_sql');
59
-	$pref = sprintf("_%d_",$GLOBALS['visiteur_session']['id_auteur']);
60
-	$signal = fichier_admin($script, "$script$pref");
61
-	$valeur = sql_getfetsel('valeur', 'spip_meta', "nom='admin'");
62
-	if ($valeur === NULL) {
63
-		ecrire_meta('admin', $signal, 'non');
64
-	} else {
65
-		if (!$anonymous AND ($valeur != $signal)) {
66
-			if (!preg_match('/^(.*)_(\d+)_/', $GLOBALS['meta']["admin"], $l)
67
-				OR intval($l[2])!=$GLOBALS['visiteur_session']['id_auteur']) {
68
-				include_spip('inc/minipres');
69
-				spip_log("refus de lancer $script, priorite a $valeur");
70
-				return minipres(_T('info_travaux_texte'));
71
-			}
72
-		}
73
-	}
74
-	$journal = "spip";
75
-	if (autoriser('configurer')) // c'est une action webmestre, soit par ftp soit par statut webmestre
76
-		$journal = 'webmestre';
77
-	// on pourrait statuer automatiquement les webmestres a l'init d'une action auth par ftp ... ?
78
-
79
-	spip_log("admin $pref" . ($valeur ? " (reprise)" : ' (init)'),$journal);
80
-	return '';
58
+    include_spip('base/abstract_sql');
59
+    $pref = sprintf("_%d_",$GLOBALS['visiteur_session']['id_auteur']);
60
+    $signal = fichier_admin($script, "$script$pref");
61
+    $valeur = sql_getfetsel('valeur', 'spip_meta', "nom='admin'");
62
+    if ($valeur === NULL) {
63
+        ecrire_meta('admin', $signal, 'non');
64
+    } else {
65
+        if (!$anonymous AND ($valeur != $signal)) {
66
+            if (!preg_match('/^(.*)_(\d+)_/', $GLOBALS['meta']["admin"], $l)
67
+                OR intval($l[2])!=$GLOBALS['visiteur_session']['id_auteur']) {
68
+                include_spip('inc/minipres');
69
+                spip_log("refus de lancer $script, priorite a $valeur");
70
+                return minipres(_T('info_travaux_texte'));
71
+            }
72
+        }
73
+    }
74
+    $journal = "spip";
75
+    if (autoriser('configurer')) // c'est une action webmestre, soit par ftp soit par statut webmestre
76
+        $journal = 'webmestre';
77
+    // on pourrait statuer automatiquement les webmestres a l'init d'une action auth par ftp ... ?
78
+
79
+    spip_log("admin $pref" . ($valeur ? " (reprise)" : ' (init)'),$journal);
80
+    return '';
81 81
 }
82 82
 
83 83
 // http://doc.spip.org/@dir_admin
84 84
 function dir_admin()
85 85
 {
86
-	if (autoriser('configurer')) {
87
-		return _DIR_TMP;
88
-	} else {
89
-		return  _DIR_TRANSFERT . $GLOBALS['visiteur_session']['login'] . '/';
90
-	}
86
+    if (autoriser('configurer')) {
87
+        return _DIR_TMP;
88
+    } else {
89
+        return  _DIR_TRANSFERT . $GLOBALS['visiteur_session']['login'] . '/';
90
+    }
91 91
 }
92 92
 
93 93
 // http://doc.spip.org/@fichier_admin
94 94
 function fichier_admin($action, $pref='admin_') {
95 95
 
96
-	return $pref . 
97
-	  substr(md5($action.(time() & ~2047).$GLOBALS['visiteur_session']['login']), 0, 10);
96
+    return $pref . 
97
+        substr(md5($action.(time() & ~2047).$GLOBALS['visiteur_session']['login']), 0, 10);
98 98
 }
99 99
 
100 100
 // demande la creation d'un repertoire et sort
@@ -103,89 +103,89 @@  discard block
 block discarded – undo
103 103
 // http://doc.spip.org/@debut_admin
104 104
 function debut_admin($script, $action='', $corps='') {
105 105
 
106
-	if ((!$action) || !(autoriser('webmestre') OR autoriser('chargerftp'))) {
107
-		include_spip('inc/minipres');
108
-		return minipres();
109
-	} else {
110
-		$dir = dir_admin();
111
-		$signal = fichier_admin($script);
112
-		if (@file_exists($dir . $signal)) {
113
-			spip_log ("Action admin: $action");
114
-			return '';
115
-		}
116
-		include_spip('inc/minipres');
117
-
118
-	// Si on est un super-admin, un bouton de validation suffit
119
-	// sauf dans les cas destroy
120
-		if ((autoriser('webmestre') OR $script === 'repair')
121
-		AND $script != 'delete_all') {
122
-			if (_request('validation_admin') == $signal) {
123
-				spip_log ("Action super-admin: $action");
124
-				return '';
125
-			}
126
-			$corps .= '<input type="hidden" name="validation_admin" value="'.$signal.'" />';
127
-			$suivant = _T('bouton_valider');
128
-			$js = '';
129
-		} else {
130
-			// cet appel permet d'assurer un copier-coller du nom du repertoire a creer dans tmp (esj)
131
-			// l'insertion du script a cet endroit n'est pas xhtml licite mais evite de l'embarquer dans toutes les pages minipres
132
-			$corps .= http_script('',  "spip_barre.js");
133
-
134
-			$corps .= "<fieldset><legend>"
135
-			. _T('info_authentification_ftp')
136
-			. aide("ftp_auth")
137
-			. "</legend>\n<label for='fichier'>"
138
-			. _T('info_creer_repertoire')
139
-			. "</label>\n"
106
+    if ((!$action) || !(autoriser('webmestre') OR autoriser('chargerftp'))) {
107
+        include_spip('inc/minipres');
108
+        return minipres();
109
+    } else {
110
+        $dir = dir_admin();
111
+        $signal = fichier_admin($script);
112
+        if (@file_exists($dir . $signal)) {
113
+            spip_log ("Action admin: $action");
114
+            return '';
115
+        }
116
+        include_spip('inc/minipres');
117
+
118
+    // Si on est un super-admin, un bouton de validation suffit
119
+    // sauf dans les cas destroy
120
+        if ((autoriser('webmestre') OR $script === 'repair')
121
+        AND $script != 'delete_all') {
122
+            if (_request('validation_admin') == $signal) {
123
+                spip_log ("Action super-admin: $action");
124
+                return '';
125
+            }
126
+            $corps .= '<input type="hidden" name="validation_admin" value="'.$signal.'" />';
127
+            $suivant = _T('bouton_valider');
128
+            $js = '';
129
+        } else {
130
+            // cet appel permet d'assurer un copier-coller du nom du repertoire a creer dans tmp (esj)
131
+            // l'insertion du script a cet endroit n'est pas xhtml licite mais evite de l'embarquer dans toutes les pages minipres
132
+            $corps .= http_script('',  "spip_barre.js");
133
+
134
+            $corps .= "<fieldset><legend>"
135
+            . _T('info_authentification_ftp')
136
+            . aide("ftp_auth")
137
+            . "</legend>\n<label for='fichier'>"
138
+            . _T('info_creer_repertoire')
139
+            . "</label>\n"
140 140
             . "<span id='signal' class='formo'>".$signal."</span>"
141 141
             . "<input type='hidden' id='fichier' name='fichier' value='" 
142
-			. $signal
143
-			. "' />"
144
-			. _T('info_creer_repertoire_2', array('repertoire' => joli_repertoire($dir)))
145
-			. "</fieldset>";
146
-
147
-			$suivant = _T('bouton_recharger_page');
148
-
149
-			// code volontairement tordu:
150
-			// provoquer la copie dans le presse papier du nom du repertoire
151
-			// en remettant a vide le champ pour que ca marche aussi en cas
152
-			// de JavaScript inactif.
153
-			$js = " onload='var range=document.createRange(); var signal = document.getElementById(\"signal\"); var userSelection = window.getSelection(); range.setStart(signal,0); range.setEnd(signal,1); userSelection.addRange(range);'";
154
-
155
-		}
156
-
157
-		// admin/xxx correspond
158
-		// a exec/base_xxx de preference
159
-		// et exec/xxx sinon (compat)
160
-		if (tester_url_ecrire("base_$script"))
161
-			$script = "base_$script";
162
-		$form = copy_request($script, $corps, $suivant);
163
-		$info_action = _T('info_action', array('action' => "$action"));
164
-		return minipres($info_action, $form, $js);
165
-	}
142
+            . $signal
143
+            . "' />"
144
+            . _T('info_creer_repertoire_2', array('repertoire' => joli_repertoire($dir)))
145
+            . "</fieldset>";
146
+
147
+            $suivant = _T('bouton_recharger_page');
148
+
149
+            // code volontairement tordu:
150
+            // provoquer la copie dans le presse papier du nom du repertoire
151
+            // en remettant a vide le champ pour que ca marche aussi en cas
152
+            // de JavaScript inactif.
153
+            $js = " onload='var range=document.createRange(); var signal = document.getElementById(\"signal\"); var userSelection = window.getSelection(); range.setStart(signal,0); range.setEnd(signal,1); userSelection.addRange(range);'";
154
+
155
+        }
156
+
157
+        // admin/xxx correspond
158
+        // a exec/base_xxx de preference
159
+        // et exec/xxx sinon (compat)
160
+        if (tester_url_ecrire("base_$script"))
161
+            $script = "base_$script";
162
+        $form = copy_request($script, $corps, $suivant);
163
+        $info_action = _T('info_action', array('action' => "$action"));
164
+        return minipres($info_action, $form, $js);
165
+    }
166 166
 }
167 167
 
168 168
 // http://doc.spip.org/@fin_admin
169 169
 function fin_admin($action) {
170
-	$signal = dir_admin() . fichier_admin($action);
171
-	spip_unlink($signal);
172
-	if ($action != 'delete_all') {
173
-		effacer_meta($action);
174
-		effacer_meta('admin');
175
-		spip_log("efface les meta admin et $action ");
176
-	}
170
+    $signal = dir_admin() . fichier_admin($action);
171
+    spip_unlink($signal);
172
+    if ($action != 'delete_all') {
173
+        effacer_meta($action);
174
+        effacer_meta('admin');
175
+        spip_log("efface les meta admin et $action ");
176
+    }
177 177
 }
178 178
 
179 179
 // http://doc.spip.org/@copy_request
180 180
 function copy_request($script, $suite, $submit='')
181 181
 {
182
-	include_spip('inc/filtres');
183
-	foreach(array_merge($_POST,$_GET) as $n => $c) {
184
-		if (!in_array($n,array('fichier','exec','validation_admin')) AND !is_array($c))
185
-		$suite .= "\n<input type='hidden' name='".spip_htmlspecialchars($n)."' value='" .
186
-			entites_html($c) .
187
-			"'  />";
188
-	}
189
-	return  generer_form_ecrire($script, $suite, '', $submit);
182
+    include_spip('inc/filtres');
183
+    foreach(array_merge($_POST,$_GET) as $n => $c) {
184
+        if (!in_array($n,array('fichier','exec','validation_admin')) AND !is_array($c))
185
+        $suite .= "\n<input type='hidden' name='".spip_htmlspecialchars($n)."' value='" .
186
+            entites_html($c) .
187
+            "'  />";
188
+    }
189
+    return  generer_form_ecrire($script, $suite, '', $submit);
190 190
 }
191 191
 ?>
Please login to merge, or discard this patch.
ecrire/inc/surligne.php 1 patch
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -21,39 +21,39 @@  discard block
 block discarded – undo
21 21
 
22 22
 // http://doc.spip.org/@surligner_mots
23 23
 function surligner_mots($page, $surcharge_surligne = '') {
24
-	$surlignejs_engines = array(
25
-		array(",".str_replace(array("/", "."), array("\/", "\."), $GLOBALS['meta']['adresse_site']).",i", ",recherche=([^&]+),i"), //SPIP
26
-		array(",^http://(www\.)?google\.,i", ",q=([^&]+),i"), // Google
27
-		array(",^http://(www\.)?search\.yahoo\.,i", ",p=([^&]+),i"), // Yahoo
28
-		array(",^http://(www\.)?search\.msn\.,i", ",q=([^&]+),i"), // MSN
29
-		array(",^http://(www\.)?search\.live\.,i", ",query=([^&]+),i"), // MSN Live
30
-		array(",^http://(www\.)?search\.aol\.,i", ",userQuery=([^&]+),i"), // AOL
31
-		array(",^http://(www\.)?ask\.com,i", ",q=([^&]+),i"), // Ask.com
32
-		array(",^http://(www\.)?altavista\.,i", ",q=([^&]+),i"), // AltaVista
33
-		array(",^http://(www\.)?feedster\.,i", ",q=([^&]+),i"), // Feedster
34
-		array(",^http://(www\.)?search\.lycos\.,i", ",q=([^&]+),i"), // Lycos
35
-		array(",^http://(www\.)?alltheweb\.,i", ",q=([^&]+),i"), // AllTheWeb
36
-		array(",^http://(www\.)?technorati\.com,i", ",([^\?\/]+)(?:\?.*)$,i"), // Technorati
37
-	);
24
+    $surlignejs_engines = array(
25
+        array(",".str_replace(array("/", "."), array("\/", "\."), $GLOBALS['meta']['adresse_site']).",i", ",recherche=([^&]+),i"), //SPIP
26
+        array(",^http://(www\.)?google\.,i", ",q=([^&]+),i"), // Google
27
+        array(",^http://(www\.)?search\.yahoo\.,i", ",p=([^&]+),i"), // Yahoo
28
+        array(",^http://(www\.)?search\.msn\.,i", ",q=([^&]+),i"), // MSN
29
+        array(",^http://(www\.)?search\.live\.,i", ",query=([^&]+),i"), // MSN Live
30
+        array(",^http://(www\.)?search\.aol\.,i", ",userQuery=([^&]+),i"), // AOL
31
+        array(",^http://(www\.)?ask\.com,i", ",q=([^&]+),i"), // Ask.com
32
+        array(",^http://(www\.)?altavista\.,i", ",q=([^&]+),i"), // AltaVista
33
+        array(",^http://(www\.)?feedster\.,i", ",q=([^&]+),i"), // Feedster
34
+        array(",^http://(www\.)?search\.lycos\.,i", ",q=([^&]+),i"), // Lycos
35
+        array(",^http://(www\.)?alltheweb\.,i", ",q=([^&]+),i"), // AllTheWeb
36
+        array(",^http://(www\.)?technorati\.com,i", ",([^\?\/]+)(?:\?.*)$,i"), // Technorati
37
+    );
38 38
 
39 39
 
40
-	$ref = $_SERVER['HTTP_REFERER'];
41
-	//avoid a js injection
42
-	if ($surcharge_surligne){
43
-		$surcharge_surligne = preg_replace(",(?<!\\\\)((?:(?>\\\\){2})*)('),", "$1\\\\$2", $surcharge_surligne);
44
-		$surcharge_surligne = str_replace("\\", "\\\\", $surcharge_surligne);
45
-		if ($GLOBALS['meta']['charset']=='utf-8'){
46
-			include_spip('inc/charsets');
47
-			if (!is_utf8($surcharge_surligne)) $surcharge_surligne = utf8_encode($surcharge_surligne);
48
-		}
49
-		$surcharge_surligne = preg_replace(',\*$,', '', trim($surcharge_surligne)); # supprimer un * final
50
-	}
51
-	foreach ($surlignejs_engines as $engine)
52
-		if ($surcharge_surligne || (preg_match($engine[0], $ref) && preg_match($engine[1], $ref))){
40
+    $ref = $_SERVER['HTTP_REFERER'];
41
+    //avoid a js injection
42
+    if ($surcharge_surligne){
43
+        $surcharge_surligne = preg_replace(",(?<!\\\\)((?:(?>\\\\){2})*)('),", "$1\\\\$2", $surcharge_surligne);
44
+        $surcharge_surligne = str_replace("\\", "\\\\", $surcharge_surligne);
45
+        if ($GLOBALS['meta']['charset']=='utf-8'){
46
+            include_spip('inc/charsets');
47
+            if (!is_utf8($surcharge_surligne)) $surcharge_surligne = utf8_encode($surcharge_surligne);
48
+        }
49
+        $surcharge_surligne = preg_replace(',\*$,', '', trim($surcharge_surligne)); # supprimer un * final
50
+    }
51
+    foreach ($surlignejs_engines as $engine)
52
+        if ($surcharge_surligne || (preg_match($engine[0], $ref) && preg_match($engine[1], $ref))){
53 53
 
54
-			//good referrer found or var_recherche is not null
55
-			include_spip('inc/filtres');
56
-			$script = "
54
+            //good referrer found or var_recherche is not null
55
+            include_spip('inc/filtres');
56
+            $script = "
57 57
       <script type='text/javascript' src='".url_absolue(find_in_path('javascript/SearchHighlight.js'))."'></script>
58 58
       <script type='text/javascript'>/*<![CDATA[*/
59 59
       if (window.jQuery)
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
             engines:[/^".str_replace(array("/", "."), array("\/", "\."), $GLOBALS['meta']['adresse_site'])."/i,/recherche=([^&]+)/i],
67 67
             highlight:'.surlignable',
68 68
             nohighlight:'.pas_surlignable'".
69
-			          ($surcharge_surligne ? ",
69
+                        ($surcharge_surligne ? ",
70 70
             keys:'$surcharge_surligne'" : "").",
71 71
             min_length: 3
72 72
           })
@@ -74,13 +74,13 @@  discard block
 block discarded – undo
74 74
       })(jQuery);
75 75
       /*]]>*/</script>
76 76
       ";
77
-			// on l'insere juste avant </head>, sinon tout en bas
78
-			if (is_null($l = strpos($page, '</head>')))
79
-				$l = strlen($page);
80
-			$page = substr_replace($page, $script, $l, 0);
81
-			break;
82
-		}
83
-	return $page;
77
+            // on l'insere juste avant </head>, sinon tout en bas
78
+            if (is_null($l = strpos($page, '</head>')))
79
+                $l = strlen($page);
80
+            $page = substr_replace($page, $script, $l, 0);
81
+            break;
82
+        }
83
+    return $page;
84 84
 }
85 85
 
86 86
 ?>
Please login to merge, or discard this patch.
ecrire/inc/envoyer_mail.php 1 patch
Indentation   +126 added lines, -126 removed lines patch added patch discarded remove patch
@@ -17,27 +17,27 @@  discard block
 block discarded – undo
17 17
 
18 18
 // http://doc.spip.org/@nettoyer_titre_email
19 19
 function nettoyer_titre_email($titre) {
20
-	return str_replace("\n", ' ', textebrut(corriger_typo($titre)));
20
+    return str_replace("\n", ' ', textebrut(corriger_typo($titre)));
21 21
 }
22 22
 
23 23
 // http://doc.spip.org/@nettoyer_caracteres_mail
24 24
 function nettoyer_caracteres_mail($t) {
25 25
 
26
-	$t = filtrer_entites($t);
26
+    $t = filtrer_entites($t);
27 27
 
28
-	if ($GLOBALS['meta']['charset'] <> 'utf-8') {
29
-		$t = str_replace(
30
-			array("&#8217;","&#8220;","&#8221;"),
31
-			array("'",      '"',      '"'),
32
-		$t);
33
-	}
28
+    if ($GLOBALS['meta']['charset'] <> 'utf-8') {
29
+        $t = str_replace(
30
+            array("&#8217;","&#8220;","&#8221;"),
31
+            array("'",      '"',      '"'),
32
+        $t);
33
+    }
34 34
 
35
-	$t = str_replace(
36
-		array("&mdash;", "&endash;"),
37
-		array("--","-" ),
38
-	$t);
35
+    $t = str_replace(
36
+        array("&mdash;", "&endash;"),
37
+        array("--","-" ),
38
+    $t);
39 39
 
40
-	return $t;
40
+    return $t;
41 41
 }
42 42
 
43 43
 /**
@@ -71,122 +71,122 @@  discard block
 block discarded – undo
71 71
  */
72 72
 function inc_envoyer_mail_dist($destinataire, $sujet, $corps, $from = "", $headers = "") {
73 73
 
74
-	if (!email_valide($destinataire)) return false;
75
-	if ($destinataire == _T('info_mail_fournisseur')) return false; // tres fort
76
-
77
-	// Fournir si possible un Message-Id: conforme au RFC1036,
78
-	// sinon SpamAssassin denoncera un MSGID_FROM_MTA_HEADER
79
-
80
-	$email_envoi = $GLOBALS['meta']["email_envoi"];
81
-	if (!email_valide($email_envoi)) {
82
-		spip_log("Meta email_envoi invalide. Le mail sera probablement vu comme spam.");
83
-		$email_envoi = $destinataire;
84
-	}
85
-
86
-	if (is_array($corps)){
87
-		$texte = $corps['texte'];
88
-		$from = (isset($corps['from'])?$corps['from']:$from);
89
-		$headers = (isset($corps['headers'])?$corps['headers']:$headers);
90
-		if (is_array($headers))
91
-			$headers = implode("\n",$headers);
92
-		$parts = "";
93
-		if ($corps['pieces_jointes'] AND function_exists('mail_embarquer_pieces_jointes'))
94
-			$parts = mail_embarquer_pieces_jointes($corps['pieces_jointes']);
95
-	} else
96
-		$texte = $corps;
97
-
98
-	if (!$from) $from = $email_envoi;
99
-
100
-	// ceci est la RegExp NO_REAL_NAME faisant hurler SpamAssassin
101
-	if (preg_match('/^["\s]*\<?\S+\@\S+\>?\s*$/', $from))
102
-		$from .= ' (' . str_replace(')','', translitteration(str_replace('@', ' at ', $from))) . ')';
103
-
104
-	// nettoyer les &eacute; &#8217, &emdash; etc...
105
-	// les 'cliquer ici' etc sont a eviter;  voir:
106
-	// http://mta.org.ua/spamassassin-2.55/stuff/wiki.CustomRulesets/20050914/rules/french_rules.cf
107
-	$texte = nettoyer_caracteres_mail($texte);
108
-	$sujet = nettoyer_caracteres_mail($sujet);
109
-
110
-	// encoder le sujet si possible selon la RFC
111
-	if (init_mb_string()) {
112
-		# un bug de mb_string casse mb_encode_mimeheader si l'encoding interne
113
-		# est UTF-8 et le charset iso-8859-1 (constate php5-mac ; php4.3-debian)
114
-		$charset = $GLOBALS['meta']['charset'];
115
-		mb_internal_encoding($charset);
116
-		$sujet = mb_encode_mimeheader($sujet, $charset, 'Q', "\n");
117
-		mb_internal_encoding('utf-8');
118
-	}
119
-
120
-	if (function_exists('wordwrap') && (preg_match(',multipart/mixed,',$headers) == 0))
121
-		$texte = wordwrap($texte);
122
-
123
-	list($headers, $texte) = mail_normaliser_headers($headers, $from, $destinataire, $texte, $parts);
124
-
125
-	if (_OS_SERVEUR == 'windows') {
126
-		$texte = preg_replace ("@\r*\n@","\r\n", $texte);
127
-		$headers = preg_replace ("@\r*\n@","\r\n", $headers);
128
-		$sujet = preg_replace ("@\r*\n@","\r\n", $sujet);
129
-	}
130
-
131
-	spip_log("mail $destinataire\n$sujet\n$headers",'mails');
132
-	// mode TEST : forcer l'email
133
-	if (defined('_TEST_EMAIL_DEST')) {
134
-		if (!_TEST_EMAIL_DEST)
135
-			return false;
136
-		else {
137
-			$texte = "Dest : $destinataire\r\n" . $texte;
138
-			$destinataire = _TEST_EMAIL_DEST;
139
-		}
140
-	}
141
-
142
-	return @mail($destinataire, $sujet, $texte, $headers);
74
+    if (!email_valide($destinataire)) return false;
75
+    if ($destinataire == _T('info_mail_fournisseur')) return false; // tres fort
76
+
77
+    // Fournir si possible un Message-Id: conforme au RFC1036,
78
+    // sinon SpamAssassin denoncera un MSGID_FROM_MTA_HEADER
79
+
80
+    $email_envoi = $GLOBALS['meta']["email_envoi"];
81
+    if (!email_valide($email_envoi)) {
82
+        spip_log("Meta email_envoi invalide. Le mail sera probablement vu comme spam.");
83
+        $email_envoi = $destinataire;
84
+    }
85
+
86
+    if (is_array($corps)){
87
+        $texte = $corps['texte'];
88
+        $from = (isset($corps['from'])?$corps['from']:$from);
89
+        $headers = (isset($corps['headers'])?$corps['headers']:$headers);
90
+        if (is_array($headers))
91
+            $headers = implode("\n",$headers);
92
+        $parts = "";
93
+        if ($corps['pieces_jointes'] AND function_exists('mail_embarquer_pieces_jointes'))
94
+            $parts = mail_embarquer_pieces_jointes($corps['pieces_jointes']);
95
+    } else
96
+        $texte = $corps;
97
+
98
+    if (!$from) $from = $email_envoi;
99
+
100
+    // ceci est la RegExp NO_REAL_NAME faisant hurler SpamAssassin
101
+    if (preg_match('/^["\s]*\<?\S+\@\S+\>?\s*$/', $from))
102
+        $from .= ' (' . str_replace(')','', translitteration(str_replace('@', ' at ', $from))) . ')';
103
+
104
+    // nettoyer les &eacute; &#8217, &emdash; etc...
105
+    // les 'cliquer ici' etc sont a eviter;  voir:
106
+    // http://mta.org.ua/spamassassin-2.55/stuff/wiki.CustomRulesets/20050914/rules/french_rules.cf
107
+    $texte = nettoyer_caracteres_mail($texte);
108
+    $sujet = nettoyer_caracteres_mail($sujet);
109
+
110
+    // encoder le sujet si possible selon la RFC
111
+    if (init_mb_string()) {
112
+        # un bug de mb_string casse mb_encode_mimeheader si l'encoding interne
113
+        # est UTF-8 et le charset iso-8859-1 (constate php5-mac ; php4.3-debian)
114
+        $charset = $GLOBALS['meta']['charset'];
115
+        mb_internal_encoding($charset);
116
+        $sujet = mb_encode_mimeheader($sujet, $charset, 'Q', "\n");
117
+        mb_internal_encoding('utf-8');
118
+    }
119
+
120
+    if (function_exists('wordwrap') && (preg_match(',multipart/mixed,',$headers) == 0))
121
+        $texte = wordwrap($texte);
122
+
123
+    list($headers, $texte) = mail_normaliser_headers($headers, $from, $destinataire, $texte, $parts);
124
+
125
+    if (_OS_SERVEUR == 'windows') {
126
+        $texte = preg_replace ("@\r*\n@","\r\n", $texte);
127
+        $headers = preg_replace ("@\r*\n@","\r\n", $headers);
128
+        $sujet = preg_replace ("@\r*\n@","\r\n", $sujet);
129
+    }
130
+
131
+    spip_log("mail $destinataire\n$sujet\n$headers",'mails');
132
+    // mode TEST : forcer l'email
133
+    if (defined('_TEST_EMAIL_DEST')) {
134
+        if (!_TEST_EMAIL_DEST)
135
+            return false;
136
+        else {
137
+            $texte = "Dest : $destinataire\r\n" . $texte;
138
+            $destinataire = _TEST_EMAIL_DEST;
139
+        }
140
+    }
141
+
142
+    return @mail($destinataire, $sujet, $texte, $headers);
143 143
 }
144 144
 
145 145
 function mail_normaliser_headers($headers, $from, $to, $texte, $parts="")
146 146
 {
147
-	$charset = $GLOBALS['meta']['charset'];
148
-
149
-	// Ajouter le Content-Type et consort s'il n'y est pas deja
150
-	if (strpos($headers, "Content-Type: ") === false)
151
-		$type =
152
-		"Content-Type: text/plain;charset=\"$charset\";\n".
153
-		"Content-Transfer-Encoding: 8bit\n";
154
-	else $type = '';
155
-
156
-	// calculer un identifiant unique
157
-	preg_match('/@\S+/', $from, $domain);
158
-	$uniq = rand() . '_' . md5($to . $texte) . $domain[0];
159
-
160
-	// Si multi-part, s'en servir comme borne ...
161
-	if ($parts) {
162
-		$texte = "--$uniq\n$type\n" . $texte ."\n";
163
-		foreach ($parts as $part) {
164
-			$n = strlen($part[1]) . ($part[0] ? "\n" : '');
165
-			$e = join("\n", $part[0]);
166
-			$texte .= "\n--$uniq\nContent-Length: $n$e\n\n" . $part[1];
167
-		}
168
-		$texte .= "\n\n--$uniq--\n";
169
-		// Si boundary n'est pas entre guillemets,
170
-		// elle est comprise mais le charset est ignoree !
171
-		$type = "Content-Type: multipart/mixed; boundary=\"$uniq\"\n";
172
-	}
173
-
174
-	// .. et s'en servir pour plaire a SpamAssassin
175
-
176
-	$mid = 'Message-Id: <' . $uniq . ">";
177
-
178
-	// indispensable pour les sites qui collent d'office From: serveur-http
179
-	// sauf si deja mis par l'envoyeur
180
-	$rep = (strpos($headers,"Reply-To:")!==FALSE) ? '' : "Reply-To: $from\n";
181
-
182
-	// Nettoyer les en-tetes envoyees
183
-	// Ajouter le \n final
184
-	if (strlen($headers = trim($headers))) $headers .= "\n";
185
-
186
-	// Et mentionner l'indeboulonable nomenclature ratee 
187
-
188
-	$headers .= "From: $from\n$type$rep$mid\nMIME-Version: 1.0\n";
189
-
190
-	return array($headers, $texte);
147
+    $charset = $GLOBALS['meta']['charset'];
148
+
149
+    // Ajouter le Content-Type et consort s'il n'y est pas deja
150
+    if (strpos($headers, "Content-Type: ") === false)
151
+        $type =
152
+        "Content-Type: text/plain;charset=\"$charset\";\n".
153
+        "Content-Transfer-Encoding: 8bit\n";
154
+    else $type = '';
155
+
156
+    // calculer un identifiant unique
157
+    preg_match('/@\S+/', $from, $domain);
158
+    $uniq = rand() . '_' . md5($to . $texte) . $domain[0];
159
+
160
+    // Si multi-part, s'en servir comme borne ...
161
+    if ($parts) {
162
+        $texte = "--$uniq\n$type\n" . $texte ."\n";
163
+        foreach ($parts as $part) {
164
+            $n = strlen($part[1]) . ($part[0] ? "\n" : '');
165
+            $e = join("\n", $part[0]);
166
+            $texte .= "\n--$uniq\nContent-Length: $n$e\n\n" . $part[1];
167
+        }
168
+        $texte .= "\n\n--$uniq--\n";
169
+        // Si boundary n'est pas entre guillemets,
170
+        // elle est comprise mais le charset est ignoree !
171
+        $type = "Content-Type: multipart/mixed; boundary=\"$uniq\"\n";
172
+    }
173
+
174
+    // .. et s'en servir pour plaire a SpamAssassin
175
+
176
+    $mid = 'Message-Id: <' . $uniq . ">";
177
+
178
+    // indispensable pour les sites qui collent d'office From: serveur-http
179
+    // sauf si deja mis par l'envoyeur
180
+    $rep = (strpos($headers,"Reply-To:")!==FALSE) ? '' : "Reply-To: $from\n";
181
+
182
+    // Nettoyer les en-tetes envoyees
183
+    // Ajouter le \n final
184
+    if (strlen($headers = trim($headers))) $headers .= "\n";
185
+
186
+    // Et mentionner l'indeboulonable nomenclature ratee 
187
+
188
+    $headers .= "From: $from\n$type$rep$mid\nMIME-Version: 1.0\n";
189
+
190
+    return array($headers, $texte);
191 191
 }
192 192
 ?>
Please login to merge, or discard this patch.
ecrire/inc/cvt_autosave.php 1 patch
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
  * @return string
19 19
  */
20 20
 function autosave_clean_value($val){
21
-	return stripslashes(urldecode($val));
21
+    return stripslashes(urldecode($val));
22 22
 }
23 23
 
24 24
 /**
@@ -29,37 +29,37 @@  discard block
 block discarded – undo
29 29
  * @return array
30 30
  */
31 31
 function cvtautosave_formulaire_charger($flux){
32
-	if (is_array($flux['data'])
33
-	  AND isset($flux['data']['_autosave_id'])
34
-	  AND $cle_autosave = $flux['data']['_autosave_id']){
32
+    if (is_array($flux['data'])
33
+      AND isset($flux['data']['_autosave_id'])
34
+      AND $cle_autosave = $flux['data']['_autosave_id']){
35 35
 
36
-		$form = $flux['args']['form'];
37
-		$je_suis_poste = $flux['args']['je_suis_poste'];
36
+        $form = $flux['args']['form'];
37
+        $je_suis_poste = $flux['args']['je_suis_poste'];
38 38
 
39
-		$cle_autosave = serialize($cle_autosave);
40
-		$cle_autosave = $form."_".md5($cle_autosave);
39
+        $cle_autosave = serialize($cle_autosave);
40
+        $cle_autosave = $form."_".md5($cle_autosave);
41 41
 
42
-		// si on a un backup en session et qu'on est au premier chargement, non poste
43
-		// on restitue les donnees
44
-		if (isset($GLOBALS['visiteur_session']['session_autosave_'.$cle_autosave])
45
-		  AND !$je_suis_poste) {
46
-			parse_str($GLOBALS['visiteur_session']['session_autosave_'.$cle_autosave], $vars);
47
-			foreach ($vars as $key=>$val) {
48
-				if (isset($flux['data'][$key]))
49
-					$flux['data'][$key] = (is_string($val)?autosave_clean_value($val):array_map('autosave_clean_value',$val));
50
-			}
51
-		}
42
+        // si on a un backup en session et qu'on est au premier chargement, non poste
43
+        // on restitue les donnees
44
+        if (isset($GLOBALS['visiteur_session']['session_autosave_'.$cle_autosave])
45
+          AND !$je_suis_poste) {
46
+            parse_str($GLOBALS['visiteur_session']['session_autosave_'.$cle_autosave], $vars);
47
+            foreach ($vars as $key=>$val) {
48
+                if (isset($flux['data'][$key]))
49
+                    $flux['data'][$key] = (is_string($val)?autosave_clean_value($val):array_map('autosave_clean_value',$val));
50
+            }
51
+        }
52 52
 
53
-		/**
54
-		 * Envoyer le input hidden et le bout de js qui l'utilisera
55
-		 */
56
-		$flux['data']['_hidden'] .= "<input type='hidden' name='autosave' class='autosaveactive' value='$cle_autosave' />"
57
-		  .'<script type="text/javascript">/*<![CDATA[*/if (window.jQuery) jQuery(function(){
53
+        /**
54
+         * Envoyer le input hidden et le bout de js qui l'utilisera
55
+         */
56
+        $flux['data']['_hidden'] .= "<input type='hidden' name='autosave' class='autosaveactive' value='$cle_autosave' />"
57
+            .'<script type="text/javascript">/*<![CDATA[*/if (window.jQuery) jQuery(function(){
58 58
 		  $("input.autosaveactive").closest("form:not(.autosaveon)").autosave({url:"'.$GLOBALS['meta']['adresse_site'].'/"}).addClass("autosaveon");
59 59
 			});/*]]>*/</script>';
60 60
 
61
-	}
62
-	return $flux;
61
+    }
62
+    return $flux;
63 63
 }
64 64
 
65 65
 /**
@@ -70,32 +70,32 @@  discard block
 block discarded – undo
70 70
  * @return
71 71
  */
72 72
 function cvtautosave_formulaire_traiter($flux){
73
-	// si on poste 'autosave' c'est qu'on n'a plus besoin de sauvegarder :
74
-	// on elimine les donnees de la session
75
-	if ($cle_autosave = _request('autosave')){
76
-		include_spip('inc/session');
77
-		session_set('session_autosave_'.$cle_autosave, null);
78
-	}
73
+    // si on poste 'autosave' c'est qu'on n'a plus besoin de sauvegarder :
74
+    // on elimine les donnees de la session
75
+    if ($cle_autosave = _request('autosave')){
76
+        include_spip('inc/session');
77
+        session_set('session_autosave_'.$cle_autosave, null);
78
+    }
79 79
 
80
-	if (isset($GLOBALS['visiteur_session']) AND $GLOBALS['visiteur_session']){
81
-		// delai par defaut avant purge d'un backup de form : 72H
82
-		if (!defined('_AUTOSAVE_GB_DELAY')) define('_AUTOSAVE_GB_DELAY',72*3600);
83
-		$time_too_old = time() - _AUTOSAVE_GB_DELAY;
84
-		// purger aussi toutes les vieilles autosave
85
-		$session = $GLOBALS['visiteur_session'];
86
-		foreach($session as $k=>$v){
87
-			if (strncmp($k,'session_autosave_',17)==0){
88
-				$timestamp = 0;
89
-				if (preg_match(",&__timestamp=(\d+)$,",$v,$m)){
90
-					$timestamp = intval($m[1]);
91
-				}
92
-				if ($timestamp<$time_too_old)
93
-					session_set($k, null);
94
-			}
95
-		}
96
-	}
80
+    if (isset($GLOBALS['visiteur_session']) AND $GLOBALS['visiteur_session']){
81
+        // delai par defaut avant purge d'un backup de form : 72H
82
+        if (!defined('_AUTOSAVE_GB_DELAY')) define('_AUTOSAVE_GB_DELAY',72*3600);
83
+        $time_too_old = time() - _AUTOSAVE_GB_DELAY;
84
+        // purger aussi toutes les vieilles autosave
85
+        $session = $GLOBALS['visiteur_session'];
86
+        foreach($session as $k=>$v){
87
+            if (strncmp($k,'session_autosave_',17)==0){
88
+                $timestamp = 0;
89
+                if (preg_match(",&__timestamp=(\d+)$,",$v,$m)){
90
+                    $timestamp = intval($m[1]);
91
+                }
92
+                if ($timestamp<$time_too_old)
93
+                    session_set($k, null);
94
+            }
95
+        }
96
+    }
97 97
 	
98
-	return $flux;
98
+    return $flux;
99 99
 }
100 100
 
101 101
 
Please login to merge, or discard this patch.
ecrire/inc/math.php 1 patch
Indentation   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -20,56 +20,56 @@  discard block
 block discarded – undo
20 20
 
21 21
 // http://doc.spip.org/@image_math
22 22
 function produire_image_math($tex) {
23
-	global $traiter_math;
24
-	switch ($traiter_math) {
25
-		// Attention: mathml desactiv'e pour l'instant
26
-		case 'mathml':
27
-			$ext = '.xhtml';
28
-			$server = $GLOBALS['mathml_server'];
29
-			break;
30
-		case 'tex':
31
-			$ext = '.png';
32
-			$server = $GLOBALS['tex_server'];
33
-			break;
34
-		default:
35
-			return $tex;
36
-	}
37
-
38
-	// Regarder dans le repertoire local des images TeX et blocs MathML
39
-	if (!@is_dir($dir_tex = _DIR_VAR.'cache-TeX/'))
40
-		@mkdir ($dir_tex, _SPIP_CHMOD);
41
-	$fichier = $dir_tex .md5(trim($tex)).$ext;
23
+    global $traiter_math;
24
+    switch ($traiter_math) {
25
+        // Attention: mathml desactiv'e pour l'instant
26
+        case 'mathml':
27
+            $ext = '.xhtml';
28
+            $server = $GLOBALS['mathml_server'];
29
+            break;
30
+        case 'tex':
31
+            $ext = '.png';
32
+            $server = $GLOBALS['tex_server'];
33
+            break;
34
+        default:
35
+            return $tex;
36
+    }
37
+
38
+    // Regarder dans le repertoire local des images TeX et blocs MathML
39
+    if (!@is_dir($dir_tex = _DIR_VAR.'cache-TeX/'))
40
+        @mkdir ($dir_tex, _SPIP_CHMOD);
41
+    $fichier = $dir_tex .md5(trim($tex)).$ext;
42 42
 	
43 43
 
44
-	if (!@file_exists($fichier)) {
45
-		// Aller chercher l'image sur le serveur
46
-		if ($server) {
47
-			spip_log($url = $server.'?'.rawurlencode($tex));
48
-			include_spip('inc/distant');
49
-			recuperer_page($url,$fichier);
50
-		}
51
-	}
44
+    if (!@file_exists($fichier)) {
45
+        // Aller chercher l'image sur le serveur
46
+        if ($server) {
47
+            spip_log($url = $server.'?'.rawurlencode($tex));
48
+            include_spip('inc/distant');
49
+            recuperer_page($url,$fichier);
50
+        }
51
+    }
52 52
 
53 53
 
54
-	// Composer la reponse selon presence ou non de l'image
55
-	$tex = entites_html($tex);
56
-	if (@file_exists($fichier)) {
54
+    // Composer la reponse selon presence ou non de l'image
55
+    $tex = entites_html($tex);
56
+    if (@file_exists($fichier)) {
57 57
 
58
-		// MathML
59
-		if ($traiter_math == 'mathml') {
60
-			return join(file("$fichier"),"");
61
-		}
58
+        // MathML
59
+        if ($traiter_math == 'mathml') {
60
+            return join(file("$fichier"),"");
61
+        }
62 62
 
63
-		// TeX
64
-		else {
65
-			list(,,,$size) = @getimagesize($fichier);
66
-			$alt = "alt=\"$tex\" title=\"$tex\""; 
67
-			return "<img src=\"$fichier\" style=\"vertical-align:middle;\" $size $alt />";
68
-		}
63
+        // TeX
64
+        else {
65
+            list(,,,$size) = @getimagesize($fichier);
66
+            $alt = "alt=\"$tex\" title=\"$tex\""; 
67
+            return "<img src=\"$fichier\" style=\"vertical-align:middle;\" $size $alt />";
68
+        }
69 69
 
70
-	}
71
-	else // pas de fichier
72
-		return "<tt><span class='spip_code' dir='ltr'>$tex</span></tt>";
70
+    }
71
+    else // pas de fichier
72
+        return "<tt><span class='spip_code' dir='ltr'>$tex</span></tt>";
73 73
 
74 74
 }
75 75
 
@@ -78,39 +78,39 @@  discard block
 block discarded – undo
78 78
 // http://doc.spip.org/@traiter_math
79 79
 function traiter_math($letexte, $source='') {
80 80
 
81
-	$texte_a_voir = $letexte;
82
-	while (($debut = strpos($texte_a_voir, "<math>")) !== false) {
83
-		if (!$fin = strpos($texte_a_voir,"</math>"))
84
-			$fin = strlen($texte_a_voir);
85
-
86
-		$texte_debut = substr($texte_a_voir, 0, $debut);
87
-		$texte_milieu = substr($texte_a_voir,
88
-			$debut+strlen("<math>"), $fin-$debut-strlen("<math>"));
89
-		$texte_fin = substr($texte_a_voir,
90
-			$fin+strlen("</math>"), strlen($texte_a_voir));
91
-
92
-		// Les doubles $$x^2$$ en mode 'div'
93
-		while((preg_match(",[$][$]([^$]+)[$][$],",$texte_milieu, $regs))) {
94
-			$echap = "\n<p class=\"spip\" style=\"text-align: center;\">".produire_image_math($regs[1])."</p>\n";
95
-			$pos = strpos($texte_milieu, $regs[0]);
96
-			$texte_milieu = substr($texte_milieu,0,$pos)
97
-				. code_echappement($echap, $source)
98
-				. substr($texte_milieu,$pos+strlen($regs[0]));
99
-		}
100
-
101
-		// Les simples $x^2$ en mode 'span'
102
-		while((preg_match(",[$]([^$]+)[$],",$texte_milieu, $regs))) {
103
-			$echap = produire_image_math($regs[1]);
104
-			$pos = strpos($texte_milieu, $regs[0]);
105
-			$texte_milieu = substr($texte_milieu,0,$pos)
106
-				. code_echappement($echap, $source)
107
-				. substr($texte_milieu,$pos+strlen($regs[0]));
108
-		}
109
-
110
-		$texte_a_voir = $texte_debut.$texte_milieu.$texte_fin;
111
-	}
112
-
113
-	return $texte_a_voir;
81
+    $texte_a_voir = $letexte;
82
+    while (($debut = strpos($texte_a_voir, "<math>")) !== false) {
83
+        if (!$fin = strpos($texte_a_voir,"</math>"))
84
+            $fin = strlen($texte_a_voir);
85
+
86
+        $texte_debut = substr($texte_a_voir, 0, $debut);
87
+        $texte_milieu = substr($texte_a_voir,
88
+            $debut+strlen("<math>"), $fin-$debut-strlen("<math>"));
89
+        $texte_fin = substr($texte_a_voir,
90
+            $fin+strlen("</math>"), strlen($texte_a_voir));
91
+
92
+        // Les doubles $$x^2$$ en mode 'div'
93
+        while((preg_match(",[$][$]([^$]+)[$][$],",$texte_milieu, $regs))) {
94
+            $echap = "\n<p class=\"spip\" style=\"text-align: center;\">".produire_image_math($regs[1])."</p>\n";
95
+            $pos = strpos($texte_milieu, $regs[0]);
96
+            $texte_milieu = substr($texte_milieu,0,$pos)
97
+                . code_echappement($echap, $source)
98
+                . substr($texte_milieu,$pos+strlen($regs[0]));
99
+        }
100
+
101
+        // Les simples $x^2$ en mode 'span'
102
+        while((preg_match(",[$]([^$]+)[$],",$texte_milieu, $regs))) {
103
+            $echap = produire_image_math($regs[1]);
104
+            $pos = strpos($texte_milieu, $regs[0]);
105
+            $texte_milieu = substr($texte_milieu,0,$pos)
106
+                . code_echappement($echap, $source)
107
+                . substr($texte_milieu,$pos+strlen($regs[0]));
108
+        }
109
+
110
+        $texte_a_voir = $texte_debut.$texte_milieu.$texte_fin;
111
+    }
112
+
113
+    return $texte_a_voir;
114 114
 }
115 115
 
116 116
 ?>
Please login to merge, or discard this patch.
ecrire/inc/chercher_logo.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -14,35 +14,35 @@
 block discarded – undo
14 14
 
15 15
 // http://doc.spip.org/@inc_chercher_logo_dist
16 16
 function inc_chercher_logo_dist($id, $_id_objet, $mode='on') {
17
-	global $formats_logos;
18
-	# attention au cas $id = '0' pour LOGO_SITE_SPIP : utiliser intval()
19
-
20
-	$type = type_du_logo($_id_objet);
21
-	$nom = $type . $mode . intval($id);
22
-
23
-	foreach ($formats_logos as $format) {
24
-		if (@file_exists($d = (_DIR_LOGOS . $nom . '.' . $format))) {
25
-			return array($d, _DIR_LOGOS, $nom, $format, @filemtime($d));
26
-		}
27
-	}
28
-	# coherence de type pour servir comme filtre (formulaire_login)
29
-	return array();
17
+    global $formats_logos;
18
+    # attention au cas $id = '0' pour LOGO_SITE_SPIP : utiliser intval()
19
+
20
+    $type = type_du_logo($_id_objet);
21
+    $nom = $type . $mode . intval($id);
22
+
23
+    foreach ($formats_logos as $format) {
24
+        if (@file_exists($d = (_DIR_LOGOS . $nom . '.' . $format))) {
25
+            return array($d, _DIR_LOGOS, $nom, $format, @filemtime($d));
26
+        }
27
+    }
28
+    # coherence de type pour servir comme filtre (formulaire_login)
29
+    return array();
30 30
 }
31 31
 
32 32
 // http://doc.spip.org/@type_du_logo
33 33
 function type_du_logo($_id_objet) {
34
-	return isset($GLOBALS['table_logos'][$_id_objet])
35
-		? $GLOBALS['table_logos'][$_id_objet]
36
-		: objet_type(preg_replace(',^id_,','',$_id_objet));
34
+    return isset($GLOBALS['table_logos'][$_id_objet])
35
+        ? $GLOBALS['table_logos'][$_id_objet]
36
+        : objet_type(preg_replace(',^id_,','',$_id_objet));
37 37
 }
38 38
 
39 39
 // Exceptions standards (historique)
40 40
 global $table_logos;
41 41
 $table_logos = array( 
42
-	'id_article' => 'art', 
43
-	'id_auteur' => 'aut', 
44
-	'id_rubrique' => 'rub',
45
-	'id_groupe' => 'groupe',
42
+    'id_article' => 'art', 
43
+    'id_auteur' => 'aut', 
44
+    'id_rubrique' => 'rub',
45
+    'id_groupe' => 'groupe',
46 46
 );
47 47
 
48 48
 ?>
Please login to merge, or discard this patch.