Completed
Push — spip-3.0 ( 484b62...e817f1 )
by cam
34:33
created
ecrire/action/confirmer_email.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -17,18 +17,18 @@
 block discarded – undo
17 17
 
18 18
 function action_confirmer_email_dist()
19 19
 {
20
-	$securiser_action = charger_fonction('securiser_action', 'inc');
21
-	$arg = $securiser_action();
22
-
23
-	include_spip('inc/filtres');
24
-	if ($GLOBALS['visiteur_session']['id_auteur'] AND email_valide($arg)){
25
-		include_spip('action/editer_auteur');
26
-		auteur_modifier($GLOBALS['visiteur_session']['id_auteur'],array('email'=>$arg));
27
-	}
28
-	// verifier avant de rediriger pour invalider le message de confirmation
29
-	// si ca n'a pas marche
30
-	if ($redirect = _request('redirect') AND !$arg == sql_getfetsel('email', 'spip_auteurs', 'id_auteur='.intval($GLOBALS['visiteur_session'])))
31
-		$GLOBALS['redirect'] = parametre_url($redirect, 'email_modif','');
20
+    $securiser_action = charger_fonction('securiser_action', 'inc');
21
+    $arg = $securiser_action();
22
+
23
+    include_spip('inc/filtres');
24
+    if ($GLOBALS['visiteur_session']['id_auteur'] AND email_valide($arg)){
25
+        include_spip('action/editer_auteur');
26
+        auteur_modifier($GLOBALS['visiteur_session']['id_auteur'],array('email'=>$arg));
27
+    }
28
+    // verifier avant de rediriger pour invalider le message de confirmation
29
+    // si ca n'a pas marche
30
+    if ($redirect = _request('redirect') AND !$arg == sql_getfetsel('email', 'spip_auteurs', 'id_auteur='.intval($GLOBALS['visiteur_session'])))
31
+        $GLOBALS['redirect'] = parametre_url($redirect, 'email_modif','');
32 32
 
33 33
 }
34 34
 
Please login to merge, or discard this patch.
ecrire/action/super_cron.php 1 patch
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -25,26 +25,26 @@
 block discarded – undo
25 25
  * "* * * * * curl  http://www.mondomaine.tld/spip.php?action=super_cron"
26 26
  */
27 27
 function action_super_cron_dist(){
28
-	// Si fsockopen est possible, on lance le cron via un socket
29
-	// en asynchrone
30
-	if(function_exists('fsockopen')){
31
-		$url = generer_url_action('cron');
32
-		$parts=parse_url($url);
33
-		$fp = fsockopen($parts['host'],
34
-	        isset($parts['port'])?$parts['port']:80,
35
-	        $errno, $errstr, 30);
36
-		if ($fp) {
37
-	    	$out = "GET ".$parts['path']."?".$parts['query']." HTTP/1.1\r\n";
38
-    		$out.= "Host: ".$parts['host']."\r\n";
39
-    		$out.= "Connection: Close\r\n\r\n";
40
-			fwrite($fp, $out);
41
-			fclose($fp);
42
-			return;
43
-		}
44
-	}
45
-	// ici lancer le cron par un CURL asynchrone si CURL est présent
46
-	// TBD
28
+    // Si fsockopen est possible, on lance le cron via un socket
29
+    // en asynchrone
30
+    if(function_exists('fsockopen')){
31
+        $url = generer_url_action('cron');
32
+        $parts=parse_url($url);
33
+        $fp = fsockopen($parts['host'],
34
+            isset($parts['port'])?$parts['port']:80,
35
+            $errno, $errstr, 30);
36
+        if ($fp) {
37
+            $out = "GET ".$parts['path']."?".$parts['query']." HTTP/1.1\r\n";
38
+            $out.= "Host: ".$parts['host']."\r\n";
39
+            $out.= "Connection: Close\r\n\r\n";
40
+            fwrite($fp, $out);
41
+            fclose($fp);
42
+            return;
43
+        }
44
+    }
45
+    // ici lancer le cron par un CURL asynchrone si CURL est présent
46
+    // TBD
47 47
 
48
-	return;
48
+    return;
49 49
 }
50 50
 ?>
51 51
\ No newline at end of file
Please login to merge, or discard this patch.
ecrire/action/auth.php 1 patch
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -17,28 +17,28 @@
 block discarded – undo
17 17
  */
18 18
 function action_auth_dist() {
19 19
 	
20
-	$securiser_action = charger_fonction('securiser_action', 'inc');
21
-	$arg = $securiser_action();
22
-
23
-	if (!preg_match(",^(\w+)[/](.+)$,", $arg, $r)) {
24
-		spip_log("action_auth_dist $arg pas compris");
25
-	}
26
-	else {
27
-		$auth_methode = $r[1];
28
-		$login = $r[2];
29
-		include_spip('inc/auth');
30
-		$res = auth_terminer_identifier_login($auth_methode, $login);
31
-
32
-		if (is_string($res)){ // Erreur
33
-			$redirect = _request('redirect');
34
-			$redirect = parametre_url($redirect,'var_erreur',$res,'&');
35
-			include_spip('inc/headers');
36
-			redirige_par_entete($redirect);
37
-		}
38
-
39
-		// sinon on loge l'auteur identifie, et on finit (redirection automatique)
40
-		auth_loger($res);
41
-	}
20
+    $securiser_action = charger_fonction('securiser_action', 'inc');
21
+    $arg = $securiser_action();
22
+
23
+    if (!preg_match(",^(\w+)[/](.+)$,", $arg, $r)) {
24
+        spip_log("action_auth_dist $arg pas compris");
25
+    }
26
+    else {
27
+        $auth_methode = $r[1];
28
+        $login = $r[2];
29
+        include_spip('inc/auth');
30
+        $res = auth_terminer_identifier_login($auth_methode, $login);
31
+
32
+        if (is_string($res)){ // Erreur
33
+            $redirect = _request('redirect');
34
+            $redirect = parametre_url($redirect,'var_erreur',$res,'&');
35
+            include_spip('inc/headers');
36
+            redirige_par_entete($redirect);
37
+        }
38
+
39
+        // sinon on loge l'auteur identifie, et on finit (redirection automatique)
40
+        auth_loger($res);
41
+    }
42 42
 }
43 43
 
44 44
 
Please login to merge, or discard this patch.
ecrire/action/purger.php 1 patch
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -15,56 +15,56 @@
 block discarded – undo
15 15
 // http://doc.spip.org/@action_purger_dist
16 16
 function action_purger_dist($arg=null)
17 17
 {
18
-	if (is_null($arg)) {
19
-		$securiser_action = charger_fonction('securiser_action', 'inc');
20
-		$arg = $securiser_action();
21
-	}
18
+    if (is_null($arg)) {
19
+        $securiser_action = charger_fonction('securiser_action', 'inc');
20
+        $arg = $securiser_action();
21
+    }
22 22
 
23
-	include_spip('inc/invalideur');
23
+    include_spip('inc/invalideur');
24 24
 
25
-	spip_log("purger $arg");
25
+    spip_log("purger $arg");
26 26
 
27
-	switch ($arg) {
28
-		case 'inhibe_cache':
29
-			// inhiber le cache pendant 24h
30
-			ecrire_meta('cache_inhib',$_SERVER['REQUEST_TIME']+24*3600);
31
-			break;
32
-		case 'reactive_cache':
33
-			effacer_meta('cache_inhib');
34
-			break;
27
+    switch ($arg) {
28
+        case 'inhibe_cache':
29
+            // inhiber le cache pendant 24h
30
+            ecrire_meta('cache_inhib',$_SERVER['REQUEST_TIME']+24*3600);
31
+            break;
32
+        case 'reactive_cache':
33
+            effacer_meta('cache_inhib');
34
+            break;
35 35
 
36
-		case 'cache':
37
-			supprime_invalideurs();
38
-			@spip_unlink(_CACHE_RUBRIQUES);
39
-			@spip_unlink(_CACHE_CHEMIN);
40
-			@spip_unlink(_DIR_TMP."plugin_xml_cache.gz");
41
-			// on ne supprime que _CACHE_PLUGINS_OPT qui declenche la reconstruction des 3
42
-			// _CACHE_PIPELINES _CACHE_PLUGINS_PATH et _CACHE_PLUGINS_FCT
43
-			// pour eviter des problemes de concurence
44
-			// cf http://core.spip.org/issues/2989
45
-			//@spip_unlink(_CACHE_PIPELINES);
46
-			//@spip_unlink(_CACHE_PLUGINS_PATH);
47
-			//@spip_unlink(_CACHE_PLUGINS_FCT);
48
-			@spip_unlink(_CACHE_PLUGINS_OPT);
49
-			purger_repertoire(_DIR_CACHE,array('subdir'=>true));
50
-			purger_repertoire(_DIR_AIDE);
51
-			purger_repertoire(_DIR_VAR.'cache-css');
52
-			purger_repertoire(_DIR_VAR.'cache-js');
53
-			break;
36
+        case 'cache':
37
+            supprime_invalideurs();
38
+            @spip_unlink(_CACHE_RUBRIQUES);
39
+            @spip_unlink(_CACHE_CHEMIN);
40
+            @spip_unlink(_DIR_TMP."plugin_xml_cache.gz");
41
+            // on ne supprime que _CACHE_PLUGINS_OPT qui declenche la reconstruction des 3
42
+            // _CACHE_PIPELINES _CACHE_PLUGINS_PATH et _CACHE_PLUGINS_FCT
43
+            // pour eviter des problemes de concurence
44
+            // cf http://core.spip.org/issues/2989
45
+            //@spip_unlink(_CACHE_PIPELINES);
46
+            //@spip_unlink(_CACHE_PLUGINS_PATH);
47
+            //@spip_unlink(_CACHE_PLUGINS_FCT);
48
+            @spip_unlink(_CACHE_PLUGINS_OPT);
49
+            purger_repertoire(_DIR_CACHE,array('subdir'=>true));
50
+            purger_repertoire(_DIR_AIDE);
51
+            purger_repertoire(_DIR_VAR.'cache-css');
52
+            purger_repertoire(_DIR_VAR.'cache-js');
53
+            break;
54 54
 
55
-		case 'squelettes':
56
-			purger_repertoire(_DIR_SKELS);
57
-			break;
55
+        case 'squelettes':
56
+            purger_repertoire(_DIR_SKELS);
57
+            break;
58 58
 
59
-		case 'vignettes':
60
-			purger_repertoire(_DIR_VAR,array('subdir'=>true));
61
-			supprime_invalideurs();
62
-			purger_repertoire(_DIR_CACHE);
63
-			break;
64
-	}
59
+        case 'vignettes':
60
+            purger_repertoire(_DIR_VAR,array('subdir'=>true));
61
+            supprime_invalideurs();
62
+            purger_repertoire(_DIR_CACHE);
63
+            break;
64
+    }
65 65
 
66
-	// le faire savoir aux plugins
67
-	pipeline('trig_purger',$arg);
66
+    // le faire savoir aux plugins
67
+    pipeline('trig_purger',$arg);
68 68
 }
69 69
 
70 70
 ?>
Please login to merge, or discard this patch.
ecrire/action/iconifier.php 1 patch
Indentation   +85 added lines, -85 removed lines patch added patch discarded remove patch
@@ -18,30 +18,30 @@  discard block
 block discarded – undo
18 18
  */
19 19
 function action_iconifier_dist()
20 20
 {
21
-	include_spip('inc/actions');
22
-	$securiser_action = charger_fonction('securiser_action', 'inc');
23
-	$arg = $securiser_action();
24
-	$iframe_redirect = _request('iframe_redirect');
21
+    include_spip('inc/actions');
22
+    $securiser_action = charger_fonction('securiser_action', 'inc');
23
+    $arg = $securiser_action();
24
+    $iframe_redirect = _request('iframe_redirect');
25 25
 
26
-	$arg = rawurldecode($arg);
26
+    $arg = rawurldecode($arg);
27 27
 
28
-	if (!preg_match(',^-?\d*(\D)(.*)$,',$arg, $r))
29
-		spip_log("action iconifier: $arg pas compris");
30
-	elseif ($r[1] == '+')
31
-		action_spip_image_ajouter_dist($r[2], _request('sousaction2'), _request('source'));
32
-	else	action_spip_image_effacer_dist($r[2]);
28
+    if (!preg_match(',^-?\d*(\D)(.*)$,',$arg, $r))
29
+        spip_log("action iconifier: $arg pas compris");
30
+    elseif ($r[1] == '+')
31
+        action_spip_image_ajouter_dist($r[2], _request('sousaction2'), _request('source'));
32
+    else	action_spip_image_effacer_dist($r[2]);
33 33
 	
34
-	if(_request("iframe") == 'iframe') {
35
-		$redirect = urldecode($iframe_redirect)."&iframe=iframe";
36
-		redirige_par_entete(urldecode($redirect));
37
-	}
34
+    if(_request("iframe") == 'iframe') {
35
+        $redirect = urldecode($iframe_redirect)."&iframe=iframe";
36
+        redirige_par_entete(urldecode($redirect));
37
+    }
38 38
 }
39 39
 
40 40
 // http://doc.spip.org/@action_spip_image_effacer_dist
41 41
 function action_spip_image_effacer_dist($arg) {
42 42
 
43
-	if (!strstr($arg, ".."))
44
-		spip_unlink(_DIR_LOGOS . $arg);
43
+    if (!strstr($arg, ".."))
44
+        spip_unlink(_DIR_LOGOS . $arg);
45 45
 }
46 46
 
47 47
 //
@@ -52,80 +52,80 @@  discard block
 block discarded – undo
52 52
 // $dest = arton12.xxx
53 53
 // http://doc.spip.org/@action_spip_image_ajouter_dist
54 54
 function action_spip_image_ajouter_dist($arg,$sousaction2,$source,$return=false) {
55
-	global $formats_logos;
55
+    global $formats_logos;
56 56
 
57
-	include_spip('inc/documents');
58
-	if (!$sousaction2) {
59
-		if (!$_FILES) $_FILES = $GLOBALS['HTTP_POST_FILES'];
60
-		$source = (is_array($_FILES) ? array_pop($_FILES) : "");
61
-	}
62
-	$erreur = "";
63
-	if (!$source)
64
-		spip_log("spip_image_ajouter : source inconnue");
65
-	else {
66
-		$f =_DIR_LOGOS . $arg . '.tmp';
57
+    include_spip('inc/documents');
58
+    if (!$sousaction2) {
59
+        if (!$_FILES) $_FILES = $GLOBALS['HTTP_POST_FILES'];
60
+        $source = (is_array($_FILES) ? array_pop($_FILES) : "");
61
+    }
62
+    $erreur = "";
63
+    if (!$source)
64
+        spip_log("spip_image_ajouter : source inconnue");
65
+    else {
66
+        $f =_DIR_LOGOS . $arg . '.tmp';
67 67
 
68
-		if (!is_array($source)) 
69
-		// fichier dans upload/
70
-	  		$source = @copy(determine_upload() . $source, $f);
71
-		else {
72
-		// Intercepter une erreur a l'envoi
73
-			if ($erreur = check_upload_error($source['error'],"",$return))
74
-				$source ="";
75
-			else
76
-		// analyse le type de l'image (on ne fait pas confiance au nom de
77
-		// fichier envoye par le browser : pour les Macs c'est plus sur)
68
+        if (!is_array($source)) 
69
+        // fichier dans upload/
70
+                $source = @copy(determine_upload() . $source, $f);
71
+        else {
72
+        // Intercepter une erreur a l'envoi
73
+            if ($erreur = check_upload_error($source['error'],"",$return))
74
+                $source ="";
75
+            else
76
+        // analyse le type de l'image (on ne fait pas confiance au nom de
77
+        // fichier envoye par le browser : pour les Macs c'est plus sur)
78 78
 
79
-				$source = deplacer_fichier_upload($source['tmp_name'], $f);
80
-		}
81
-		if (!$source)
82
-			spip_log("pb de copie pour $f");
83
-	}
84
-	if ($source AND $f) {
85
-		$size = @getimagesize($f);
86
-		$type = !$size ? '': ($size[2] > 3 ? '' : $formats_logos[$size[2]-1]);
87
-		if ($type) {
88
-			$poids = filesize($f);
79
+                $source = deplacer_fichier_upload($source['tmp_name'], $f);
80
+        }
81
+        if (!$source)
82
+            spip_log("pb de copie pour $f");
83
+    }
84
+    if ($source AND $f) {
85
+        $size = @getimagesize($f);
86
+        $type = !$size ? '': ($size[2] > 3 ? '' : $formats_logos[$size[2]-1]);
87
+        if ($type) {
88
+            $poids = filesize($f);
89 89
 
90
-			if (_LOGO_MAX_SIZE > 0
91
-			AND $poids > _LOGO_MAX_SIZE*1024) {
92
-				spip_unlink ($f);
93
-				$erreur = _T('info_logo_max_poids',
94
-									array('maxi' => taille_en_octets(_LOGO_MAX_SIZE*1024),
95
-									'actuel' => taille_en_octets($poids)));
96
-			}
90
+            if (_LOGO_MAX_SIZE > 0
91
+            AND $poids > _LOGO_MAX_SIZE*1024) {
92
+                spip_unlink ($f);
93
+                $erreur = _T('info_logo_max_poids',
94
+                                    array('maxi' => taille_en_octets(_LOGO_MAX_SIZE*1024),
95
+                                    'actuel' => taille_en_octets($poids)));
96
+            }
97 97
 
98
-			elseif (_LOGO_MAX_WIDTH * _LOGO_MAX_HEIGHT
99
-			AND ($size[0] > _LOGO_MAX_WIDTH
100
-			OR $size[1] > _LOGO_MAX_HEIGHT)) {
101
-				spip_unlink ($f);
102
-				$erreur = _T('info_logo_max_poids',
103
-									array(
104
-									'maxi' =>
105
-										_T('info_largeur_vignette',
106
-											array('largeur_vignette' => _LOGO_MAX_WIDTH,
107
-											'hauteur_vignette' => _LOGO_MAX_HEIGHT)),
108
-									'actuel' =>
109
-										_T('info_largeur_vignette',
110
-											array('largeur_vignette' => $size[0],
111
-											'hauteur_vignette' => $size[1]))
112
-									));
113
-			}
114
-			else
115
-				@rename ($f, _DIR_LOGOS . $arg . ".$type");
116
-		}
117
-		else {
118
-			spip_unlink ($f);
119
-			$erreur = _T('info_logo_format_interdit',
120
-									array('formats' => join(', ', $formats_logos)));
121
-		}
98
+            elseif (_LOGO_MAX_WIDTH * _LOGO_MAX_HEIGHT
99
+            AND ($size[0] > _LOGO_MAX_WIDTH
100
+            OR $size[1] > _LOGO_MAX_HEIGHT)) {
101
+                spip_unlink ($f);
102
+                $erreur = _T('info_logo_max_poids',
103
+                                    array(
104
+                                    'maxi' =>
105
+                                        _T('info_largeur_vignette',
106
+                                            array('largeur_vignette' => _LOGO_MAX_WIDTH,
107
+                                            'hauteur_vignette' => _LOGO_MAX_HEIGHT)),
108
+                                    'actuel' =>
109
+                                        _T('info_largeur_vignette',
110
+                                            array('largeur_vignette' => $size[0],
111
+                                            'hauteur_vignette' => $size[1]))
112
+                                    ));
113
+            }
114
+            else
115
+                @rename ($f, _DIR_LOGOS . $arg . ".$type");
116
+        }
117
+        else {
118
+            spip_unlink ($f);
119
+            $erreur = _T('info_logo_format_interdit',
120
+                                    array('formats' => join(', ', $formats_logos)));
121
+        }
122 122
 	
123
-	}
124
-	if ($erreur){
125
-		if ($return)
126
-			return $erreur;
127
-		else
128
-			check_upload_error(6,$erreur);
129
-	}
123
+    }
124
+    if ($erreur){
125
+        if ($return)
126
+            return $erreur;
127
+        else
128
+            check_upload_error(6,$erreur);
129
+    }
130 130
 }
131 131
 ?>
Please login to merge, or discard this patch.
ecrire/action/purger_queue.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -17,13 +17,13 @@
 block discarded – undo
17 17
  * @return void
18 18
  */
19 19
 function action_purger_queue_dist(){
20
-	$securiser_action = charger_fonction('securiser_action','inc');
21
-	$securiser_action();
20
+    $securiser_action = charger_fonction('securiser_action','inc');
21
+    $securiser_action();
22 22
 
23
-	if (autoriser('purger','queue')){
24
-		include_spip('inc/queue');
25
-		queue_purger();
26
-	}
23
+    if (autoriser('purger','queue')){
24
+        include_spip('inc/queue');
25
+        queue_purger();
26
+    }
27 27
 
28 28
 }
29 29
 
Please login to merge, or discard this patch.
ecrire/action/calculer_taille_cache.php 1 patch
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -20,44 +20,44 @@  discard block
 block discarded – undo
20 20
  * @param string|null $arg
21 21
  */
22 22
 function action_calculer_taille_cache_dist($arg=null){
23
-	if (is_null($arg)){
24
-		$securiser_action = charger_fonction('securiser_action', 'inc');
25
-		$arg = $securiser_action();
26
-	}
27
-	include_spip('inc/filtres');
23
+    if (is_null($arg)){
24
+        $securiser_action = charger_fonction('securiser_action', 'inc');
25
+        $arg = $securiser_action();
26
+    }
27
+    include_spip('inc/filtres');
28 28
 
29
-	if ($arg=='images'){
30
-		$taille = calculer_taille_dossier(_DIR_VAR);
31
-		$res = _T('ecrire:taille_cache_image',
32
-		array(
33
-			'dir' => joli_repertoire(_DIR_VAR),
34
-			'taille' => "<b>".(taille_en_octets($taille) > 0 ? taille_en_octets($taille) : "0 octet")."</b>"
35
-			)
36
-		);
37
-	}
38
-	else {
39
-		include_spip('inc/invalideur');
40
-		$taille =
41
-			calculer_taille_dossier(_DIR_CACHE_XML)
42
-			+calculer_taille_dossier(_DIR_CACHE.'skel/')
43
-			+calculer_taille_dossier(_DIR_CACHE.'wheels/')
44
-			+calculer_taille_dossier(_DIR_CACHE.'contextes/')
45
-		;
46
-		$taille += intval(taille_du_cache());
47
-		if ($taille<=150000){
48
-			$res = _T('taille_cache_vide');
49
-		}
50
-		elseif ($taille<=1024*1024){
51
-			$res = _T('taille_cache_moins_de',array('octets'=>taille_en_octets(1024*1024)));
52
-		}
53
-		else {
54
-			$res = _T('taille_cache_octets',array('octets'=>taille_en_octets($taille)));
55
-		}
56
-		$res = "<b>$res</b>";
57
-	}
29
+    if ($arg=='images'){
30
+        $taille = calculer_taille_dossier(_DIR_VAR);
31
+        $res = _T('ecrire:taille_cache_image',
32
+        array(
33
+            'dir' => joli_repertoire(_DIR_VAR),
34
+            'taille' => "<b>".(taille_en_octets($taille) > 0 ? taille_en_octets($taille) : "0 octet")."</b>"
35
+            )
36
+        );
37
+    }
38
+    else {
39
+        include_spip('inc/invalideur');
40
+        $taille =
41
+            calculer_taille_dossier(_DIR_CACHE_XML)
42
+            +calculer_taille_dossier(_DIR_CACHE.'skel/')
43
+            +calculer_taille_dossier(_DIR_CACHE.'wheels/')
44
+            +calculer_taille_dossier(_DIR_CACHE.'contextes/')
45
+        ;
46
+        $taille += intval(taille_du_cache());
47
+        if ($taille<=150000){
48
+            $res = _T('taille_cache_vide');
49
+        }
50
+        elseif ($taille<=1024*1024){
51
+            $res = _T('taille_cache_moins_de',array('octets'=>taille_en_octets(1024*1024)));
52
+        }
53
+        else {
54
+            $res = _T('taille_cache_octets',array('octets'=>taille_en_octets($taille)));
55
+        }
56
+        $res = "<b>$res</b>";
57
+    }
58 58
 	
59
-	$res = "<p>$res</p>";
60
-	ajax_retour($res);
59
+    $res = "<p>$res</p>";
60
+    ajax_retour($res);
61 61
 }
62 62
 
63 63
 
@@ -70,20 +70,20 @@  discard block
 block discarded – undo
70 70
  * @return int
71 71
  */
72 72
 function calculer_taille_dossier ($dir) {
73
-	$handle = @opendir($dir);
74
-	if (!$handle) return 0;
75
-	$taille = 0;
76
-	while (($fichier = @readdir($handle)) !== false) {
77
-		// Eviter ".", "..", ".htaccess", etc.
78
-		if ($fichier[0] == '.') continue;
79
-		if (is_file($d = "$dir/$fichier")) {
80
-			$taille += filesize($d);
81
-		}
82
-		else if (is_dir($d))
83
-			$taille += calculer_taille_dossier($d);
84
-	}
85
-	closedir($handle);
86
-	return $taille;
73
+    $handle = @opendir($dir);
74
+    if (!$handle) return 0;
75
+    $taille = 0;
76
+    while (($fichier = @readdir($handle)) !== false) {
77
+        // Eviter ".", "..", ".htaccess", etc.
78
+        if ($fichier[0] == '.') continue;
79
+        if (is_file($d = "$dir/$fichier")) {
80
+            $taille += filesize($d);
81
+        }
82
+        else if (is_dir($d))
83
+            $taille += calculer_taille_dossier($d);
84
+    }
85
+    closedir($handle);
86
+    return $taille;
87 87
 }
88 88
 
89 89
 ?>
90 90
\ No newline at end of file
Please login to merge, or discard this patch.
ecrire/action/annuler_job.php 1 patch
Indentation   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -17,14 +17,14 @@
 block discarded – undo
17 17
  * @return void
18 18
  */
19 19
 function action_annuler_job_dist(){
20
-	$securiser_action = charger_fonction('securiser_action','inc');
21
-	$id_job = $securiser_action();
20
+    $securiser_action = charger_fonction('securiser_action','inc');
21
+    $id_job = $securiser_action();
22 22
 
23
-	if ($id_job = intval($id_job)
24
-		AND autoriser('annuler','job',$id_job)
25
-	){
26
-		job_queue_remove($id_job);
27
-	}
23
+    if ($id_job = intval($id_job)
24
+        AND autoriser('annuler','job',$id_job)
25
+    ){
26
+        job_queue_remove($id_job);
27
+    }
28 28
 }
29 29
 
30 30
 ?>
31 31
\ No newline at end of file
Please login to merge, or discard this patch.
ecrire/action/editer_liens.php 1 patch
Indentation   +309 added lines, -309 removed lines patch added patch discarded remove patch
@@ -32,18 +32,18 @@  discard block
 block discarded – undo
32 32
  *     - array(clé primaire, nom de la table de lien) si associable
33 33
  */
34 34
 function objet_associable($objet){
35
-	$trouver_table = charger_fonction('trouver_table','base');
36
-	$table_sql = table_objet_sql($objet);
37
-
38
-	$l="";
39
-	if ($primary = id_table_objet($objet)
40
-	  AND $trouver_table($l = $table_sql."_liens")
41
-		AND !preg_match(',[^\w],',$primary)
42
-		AND !preg_match(',[^\w],',$l))
43
-		return array($primary,$l);
44
-
45
-	spip_log("Objet $objet non associable : ne dispose pas d'une cle primaire $primary OU d'une table liens $l");
46
-	return false;
35
+    $trouver_table = charger_fonction('trouver_table','base');
36
+    $table_sql = table_objet_sql($objet);
37
+
38
+    $l="";
39
+    if ($primary = id_table_objet($objet)
40
+      AND $trouver_table($l = $table_sql."_liens")
41
+        AND !preg_match(',[^\w],',$primary)
42
+        AND !preg_match(',[^\w],',$l))
43
+        return array($primary,$l);
44
+
45
+    spip_log("Objet $objet non associable : ne dispose pas d'une cle primaire $primary OU d'une table liens $l");
46
+    return false;
47 47
 }
48 48
 
49 49
 /**
@@ -69,12 +69,12 @@  discard block
 block discarded – undo
69 69
  * @return bool|int
70 70
  */
71 71
 function objet_associer($objets_source, $objets_lies, $qualif = null){
72
-	$modifs = objet_traiter_liaisons('lien_insert', $objets_source, $objets_lies);
72
+    $modifs = objet_traiter_liaisons('lien_insert', $objets_source, $objets_lies);
73 73
 
74
-	if ($qualif)
75
-		objet_qualifier_liens($objets_source, $objets_lies, $qualif);
74
+    if ($qualif)
75
+        objet_qualifier_liens($objets_source, $objets_lies, $qualif);
76 76
 
77
-	return $modifs; // pas d'erreur
77
+    return $modifs; // pas d'erreur
78 78
 }
79 79
 
80 80
 
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
  * @return bool|int
99 99
  */
100 100
 function objet_dissocier($objets_source,$objets_lies){
101
-	return objet_traiter_liaisons('lien_delete',$objets_source,$objets_lies);
101
+    return objet_traiter_liaisons('lien_delete',$objets_source,$objets_lies);
102 102
 }
103 103
 
104 104
 
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
  * @return bool|int
125 125
  */
126 126
 function objet_qualifier_liens($objets_source,$objets_lies,$qualif){
127
-	return objet_traiter_liaisons('lien_set',$objets_source,$objets_lies,$qualif);
127
+    return objet_traiter_liaisons('lien_set',$objets_source,$objets_lies,$qualif);
128 128
 }
129 129
 
130 130
 
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
  * @return array
158 158
  */
159 159
 function objet_trouver_liens($objets_source,$objets_lies){
160
-	return objet_traiter_liaisons('lien_find',$objets_source,$objets_lies);
160
+    return objet_traiter_liaisons('lien_find',$objets_source,$objets_lies);
161 161
 }
162 162
 
163 163
 
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
  * @return int
182 182
  */
183 183
 function objet_optimiser_liens($objets_source,$objets_lies){
184
-	return objet_traiter_liaisons('lien_optimise',$objets_source,$objets_lies);
184
+    return objet_traiter_liaisons('lien_optimise',$objets_source,$objets_lies);
185 185
 }
186 186
 
187 187
 
@@ -201,32 +201,32 @@  discard block
 block discarded – undo
201 201
  *     Nombre de liens copiés
202 202
  */
203 203
 function objet_dupliquer_liens($objet,$id_source,$id_cible,$types=null,$exclure_types=null){
204
-	include_spip('base/objets');
205
-	$tables = lister_tables_objets_sql();
206
-	$n = 0;
207
-	foreach($tables as $table_sql => $infos){
208
-		if (
209
-			(is_null($types) OR in_array($infos['type'],$types))
210
-			AND (is_null($exclure_types) OR !in_array($infos['type'],$exclure_types))
211
-			){
212
-			if (objet_associable($infos['type'])){
213
-				$liens = (($infos['type']==$objet)?
214
-						objet_trouver_liens(array($objet=>$id_source),'*')
215
-					:
216
-						objet_trouver_liens(array($infos['type']=>'*'),array($objet=>$id_source)));
217
-				foreach($liens as $lien){
218
-					$n++;
219
-					if ($infos['type']==$objet){
220
-						objet_associer(array($objet=>$id_cible),array($lien['objet']=>$lien[$lien['objet']]),$lien);
221
-					}
222
-					else {
223
-						objet_associer(array($infos['type']=>$lien[$infos['type']]),array($objet=>$id_cible),$lien);
224
-					}
225
-				}
226
-			}
227
-		}
228
-	}
229
-	return $n;
204
+    include_spip('base/objets');
205
+    $tables = lister_tables_objets_sql();
206
+    $n = 0;
207
+    foreach($tables as $table_sql => $infos){
208
+        if (
209
+            (is_null($types) OR in_array($infos['type'],$types))
210
+            AND (is_null($exclure_types) OR !in_array($infos['type'],$exclure_types))
211
+            ){
212
+            if (objet_associable($infos['type'])){
213
+                $liens = (($infos['type']==$objet)?
214
+                        objet_trouver_liens(array($objet=>$id_source),'*')
215
+                    :
216
+                        objet_trouver_liens(array($infos['type']=>'*'),array($objet=>$id_source)));
217
+                foreach($liens as $lien){
218
+                    $n++;
219
+                    if ($infos['type']==$objet){
220
+                        objet_associer(array($objet=>$id_cible),array($lien['objet']=>$lien[$lien['objet']]),$lien);
221
+                    }
222
+                    else {
223
+                        objet_associer(array($infos['type']=>$lien[$infos['type']]),array($objet=>$id_cible),$lien);
224
+                    }
225
+                }
226
+            }
227
+        }
228
+    }
229
+    return $n;
230 230
 }
231 231
 
232 232
 /**
@@ -258,36 +258,36 @@  discard block
 block discarded – undo
258 258
  * @return bool|int|array
259 259
  */
260 260
 function objet_traiter_liaisons($operation,$objets_source,$objets_lies, $set = null){
261
-	// accepter une syntaxe minimale pour supprimer tous les liens
262
-	if ($objets_lies=='*') $objets_lies = array('*'=>'*');
263
-	$modifs = 0; // compter le nombre de modifications
264
-	$echec = null;
265
-	foreach($objets_source as $objet=>$ids){
266
-		if ($a = objet_associable($objet)) {
267
-			list($primary,$l) = $a;
268
-			if (!is_array($ids))
269
-				$ids = array($ids);
270
-			elseif(reset($ids)=="NOT"){
271
-				// si on demande un array('NOT',...) => recuperer la liste d'ids correspondants
272
-				$where = lien_where($primary,$ids,'*','*');
273
-				$ids = sql_allfetsel($primary,$l,$where);
274
-				$ids = array_map('reset',$ids);
275
-			}
276
-			foreach($ids as $id) {
277
-				$res = $operation($objet,$primary,$l,$id,$objets_lies,$set);
278
-				if ($res===false) {
279
-					spip_log("objet_traiter_liaisons [Echec] : $operation sur $objet/$primary/$l/$id",_LOG_ERREUR);
280
-					$echec = true;
281
-				}
282
-				else
283
-					$modifs=($modifs?(is_array($res)?array_merge($modifs,$res):$modifs+$res):$res);
284
-			}
285
-		}
286
-		else
287
-			$echec = true;
288
-	}
289
-
290
-	return ($echec?false:$modifs); // pas d'erreur
261
+    // accepter une syntaxe minimale pour supprimer tous les liens
262
+    if ($objets_lies=='*') $objets_lies = array('*'=>'*');
263
+    $modifs = 0; // compter le nombre de modifications
264
+    $echec = null;
265
+    foreach($objets_source as $objet=>$ids){
266
+        if ($a = objet_associable($objet)) {
267
+            list($primary,$l) = $a;
268
+            if (!is_array($ids))
269
+                $ids = array($ids);
270
+            elseif(reset($ids)=="NOT"){
271
+                // si on demande un array('NOT',...) => recuperer la liste d'ids correspondants
272
+                $where = lien_where($primary,$ids,'*','*');
273
+                $ids = sql_allfetsel($primary,$l,$where);
274
+                $ids = array_map('reset',$ids);
275
+            }
276
+            foreach($ids as $id) {
277
+                $res = $operation($objet,$primary,$l,$id,$objets_lies,$set);
278
+                if ($res===false) {
279
+                    spip_log("objet_traiter_liaisons [Echec] : $operation sur $objet/$primary/$l/$id",_LOG_ERREUR);
280
+                    $echec = true;
281
+                }
282
+                else
283
+                    $modifs=($modifs?(is_array($res)?array_merge($modifs,$res):$modifs+$res):$res);
284
+            }
285
+        }
286
+        else
287
+            $echec = true;
288
+    }
289
+
290
+    return ($echec?false:$modifs); // pas d'erreur
291 291
 }
292 292
 
293 293
 
@@ -310,59 +310,59 @@  discard block
 block discarded – undo
310 310
  * @return bool|int
311 311
  */
312 312
 function lien_insert($objet_source,$primary,$table_lien,$id,$objets) {
313
-	$ins = 0;
314
-	$echec = null;
315
-	foreach($objets as $objet => $id_objets){
316
-		if (!is_array($id_objets)) $id_objets = array($id_objets);
317
-		foreach($id_objets as $id_objet) {
318
-			$objet = ($objet=='*')?$objet:objet_type($objet); # securite
319
-			// Envoyer aux plugins
320
-			$id_objet = pipeline('pre_edition_lien',
321
-				array(
322
-					'args' => array(
323
-						'table_lien' => $table_lien,
324
-						'objet_source' => $objet_source,
325
-						'id_objet_source' => $id,
326
-						'objet' => $objet,
327
-						'id_objet' => $id_objet,
328
-						'action'=>'insert',
329
-					),
330
-					'data' => $id_objet
331
-				)
332
-			);
333
-			if ($id_objet=intval($id_objet)
334
-				AND !sql_getfetsel(
335
-								$primary,
336
-								$table_lien,
337
-								array('id_objet='.intval($id_objet), 'objet='.sql_quote($objet), $primary.'='.intval($id))))
338
-			{
339
-
340
-					$e = sql_insertq($table_lien, array('id_objet' => $id_objet, 'objet'=>$objet, $primary=>$id));
341
-					if ($e!==false) {
342
-						$ins++;
343
-						lien_propage_date_modif($objet,$id_objet);
344
-						lien_propage_date_modif($objet_source,$id);
345
-						// Envoyer aux plugins
346
-						pipeline('post_edition_lien',
347
-							array(
348
-								'args' => array(
349
-									'table_lien' => $table_lien,
350
-									'objet_source' => $objet_source,
351
-									'id_objet_source' => $id,
352
-									'objet' => $objet,
353
-									'id_objet' => $id_objet,
354
-									'action'=>'insert',
355
-								),
356
-								'data' => $id_objet
357
-							)
358
-						);
359
-					}
360
-					else
361
-						$echec = true;
362
-			}
363
-		}
364
-	}
365
-	return ($echec?false:$ins);
313
+    $ins = 0;
314
+    $echec = null;
315
+    foreach($objets as $objet => $id_objets){
316
+        if (!is_array($id_objets)) $id_objets = array($id_objets);
317
+        foreach($id_objets as $id_objet) {
318
+            $objet = ($objet=='*')?$objet:objet_type($objet); # securite
319
+            // Envoyer aux plugins
320
+            $id_objet = pipeline('pre_edition_lien',
321
+                array(
322
+                    'args' => array(
323
+                        'table_lien' => $table_lien,
324
+                        'objet_source' => $objet_source,
325
+                        'id_objet_source' => $id,
326
+                        'objet' => $objet,
327
+                        'id_objet' => $id_objet,
328
+                        'action'=>'insert',
329
+                    ),
330
+                    'data' => $id_objet
331
+                )
332
+            );
333
+            if ($id_objet=intval($id_objet)
334
+                AND !sql_getfetsel(
335
+                                $primary,
336
+                                $table_lien,
337
+                                array('id_objet='.intval($id_objet), 'objet='.sql_quote($objet), $primary.'='.intval($id))))
338
+            {
339
+
340
+                    $e = sql_insertq($table_lien, array('id_objet' => $id_objet, 'objet'=>$objet, $primary=>$id));
341
+                    if ($e!==false) {
342
+                        $ins++;
343
+                        lien_propage_date_modif($objet,$id_objet);
344
+                        lien_propage_date_modif($objet_source,$id);
345
+                        // Envoyer aux plugins
346
+                        pipeline('post_edition_lien',
347
+                            array(
348
+                                'args' => array(
349
+                                    'table_lien' => $table_lien,
350
+                                    'objet_source' => $objet_source,
351
+                                    'id_objet_source' => $id,
352
+                                    'objet' => $objet,
353
+                                    'id_objet' => $id_objet,
354
+                                    'action'=>'insert',
355
+                                ),
356
+                                'data' => $id_objet
357
+                            )
358
+                        );
359
+                    }
360
+                    else
361
+                        $echec = true;
362
+            }
363
+        }
364
+    }
365
+    return ($echec?false:$ins);
366 366
 }
367 367
 
368 368
 /**
@@ -376,36 +376,36 @@  discard block
 block discarded – undo
376 376
  * @return array
377 377
  */
378 378
 function lien_where($primary, $id_source, $objet, $id_objet){
379
-	if ((!is_array($id_source) AND !strlen($id_source))
380
-	  OR !strlen($objet)
381
-	  OR (!is_array($id_objet) AND !strlen($id_objet)))
382
-		return array("0=1"); // securite
383
-
384
-	$not="";
385
-	if (is_array($id_source) AND reset($id_source)=="NOT"){
386
-		$not = array_shift($id_source);
387
-		$id_source = reset($id_source);
388
-	}
389
-	$where = array();
390
-	if ($id_source!=='*')
391
-		$where[] = (is_array($id_source)?sql_in(addslashes($primary),array_map('intval',$id_source),$not):addslashes($primary) . ($not?"<>":"=") . intval($id_source));
392
-	elseif ($not)
393
-		$where[] = "0=1"; // idiot mais quand meme
394
-
395
-	$not="";
396
-	if (is_array($id_objet) AND reset($id_objet)=="NOT"){
397
-		$not = array_shift($id_objet);
398
-		$id_objet = reset($id_objet);
399
-	}
400
-
401
-	if ($objet!=='*')
402
-		$where[] = "objet=".sql_quote($objet);
403
-	if ($id_objet!=='*')
404
-		$where[] = (is_array($id_objet)?sql_in('id_objet',array_map('intval',$id_objet),$not):"id_objet" . ($not?"<>":"=") . intval($id_objet));
405
-	elseif ($not)
406
-		$where[] = "0=1"; // idiot mais quand meme
407
-
408
-	return $where;
379
+    if ((!is_array($id_source) AND !strlen($id_source))
380
+      OR !strlen($objet)
381
+      OR (!is_array($id_objet) AND !strlen($id_objet)))
382
+        return array("0=1"); // securite
383
+
384
+    $not="";
385
+    if (is_array($id_source) AND reset($id_source)=="NOT"){
386
+        $not = array_shift($id_source);
387
+        $id_source = reset($id_source);
388
+    }
389
+    $where = array();
390
+    if ($id_source!=='*')
391
+        $where[] = (is_array($id_source)?sql_in(addslashes($primary),array_map('intval',$id_source),$not):addslashes($primary) . ($not?"<>":"=") . intval($id_source));
392
+    elseif ($not)
393
+        $where[] = "0=1"; // idiot mais quand meme
394
+
395
+    $not="";
396
+    if (is_array($id_objet) AND reset($id_objet)=="NOT"){
397
+        $not = array_shift($id_objet);
398
+        $id_objet = reset($id_objet);
399
+    }
400
+
401
+    if ($objet!=='*')
402
+        $where[] = "objet=".sql_quote($objet);
403
+    if ($id_objet!=='*')
404
+        $where[] = (is_array($id_objet)?sql_in('id_objet',array_map('intval',$id_objet),$not):"id_objet" . ($not?"<>":"=") . intval($id_objet));
405
+    elseif ($not)
406
+        $where[] = "0=1"; // idiot mais quand meme
407
+
408
+    return $where;
409 409
 }
410 410
 
411 411
 /**
@@ -426,65 +426,65 @@  discard block
 block discarded – undo
426 426
  * @return bool|int
427 427
  */
428 428
 function lien_delete($objet_source,$primary,$table_lien,$id,$objets){
429
-	$retire = array();
430
-	$dels = 0;
431
-	$echec = false;
432
-	foreach($objets as $objet => $id_objets){
433
-		$objet = ($objet=='*')?$objet:objet_type($objet); # securite
434
-		if (!is_array($id_objets) OR reset($id_objets)=="NOT") $id_objets = array($id_objets);
435
-		foreach($id_objets as $id_objet) {
436
-			// id_objet peut valoir '*'
437
-			$where = lien_where($primary, $id, $objet, $id_objet);
438
-			// lire les liens existants pour propager la date de modif
439
-			$liens = sql_allfetsel("$primary,id_objet,objet",$table_lien,$where);
440
-			// iterer sur les liens pour permettre aux plugins de gerer
441
-			foreach($liens as $l){
442
-				// Envoyer aux plugins
443
-				$id_o = pipeline('pre_edition_lien',
444
-					array(
445
-						'args' => array(
446
-							'table_lien' => $table_lien,
447
-							'objet_source' => $objet_source,
448
-							'id_objet_source' => $l[$primary],
449
-							'objet' => $l['objet'],
450
-							'id_objet' => $l['id_objet'],
451
-							'action'=>'delete',
452
-						),
453
-						'data' => $l['id_objet']
454
-					)
455
-				);
456
-				if ($id_o=intval($id_o)){
457
-					$where = lien_where($primary, $l[$primary], $l['objet'], $id_o);
458
-					$e = sql_delete($table_lien, $where);
459
-					if ($e!==false){
460
-						$dels+=$e;
461
-						lien_propage_date_modif($l['objet'],$id_o);
462
-						lien_propage_date_modif($objet_source,$l[$primary]);
463
-					}
464
-					else
465
-						$echec = true;
466
-					$retire[] = array('source'=>array($objet_source=>$l[$primary]),'lien'=>array($l['objet']=>$id_o),'type'=>$l['objet'],'id'=>$id_o);
467
-					// Envoyer aux plugins
468
-					pipeline('post_edition_lien',
469
-						array(
470
-							'args' => array(
471
-								'table_lien' => $table_lien,
472
-								'objet_source' => $objet_source,
473
-								'id_objet_source' => $l[$primary],
474
-								'objet' => $l['objet'],
475
-								'id_objet' => $id_o,
476
-								'action'=>'delete',
477
-							),
478
-							'data' => $id_o
479
-						)
480
-					);
481
-				}
482
-			}
483
-		}
484
-	}
485
-	pipeline('trig_supprimer_objets_lies',$retire);
486
-
487
-	return ($echec?false:$dels);
429
+    $retire = array();
430
+    $dels = 0;
431
+    $echec = false;
432
+    foreach($objets as $objet => $id_objets){
433
+        $objet = ($objet=='*')?$objet:objet_type($objet); # securite
434
+        if (!is_array($id_objets) OR reset($id_objets)=="NOT") $id_objets = array($id_objets);
435
+        foreach($id_objets as $id_objet) {
436
+            // id_objet peut valoir '*'
437
+            $where = lien_where($primary, $id, $objet, $id_objet);
438
+            // lire les liens existants pour propager la date de modif
439
+            $liens = sql_allfetsel("$primary,id_objet,objet",$table_lien,$where);
440
+            // iterer sur les liens pour permettre aux plugins de gerer
441
+            foreach($liens as $l){
442
+                // Envoyer aux plugins
443
+                $id_o = pipeline('pre_edition_lien',
444
+                    array(
445
+                        'args' => array(
446
+                            'table_lien' => $table_lien,
447
+                            'objet_source' => $objet_source,
448
+                            'id_objet_source' => $l[$primary],
449
+                            'objet' => $l['objet'],
450
+                            'id_objet' => $l['id_objet'],
451
+                            'action'=>'delete',
452
+                        ),
453
+                        'data' => $l['id_objet']
454
+                    )
455
+                );
456
+                if ($id_o=intval($id_o)){
457
+                    $where = lien_where($primary, $l[$primary], $l['objet'], $id_o);
458
+                    $e = sql_delete($table_lien, $where);
459
+                    if ($e!==false){
460
+                        $dels+=$e;
461
+                        lien_propage_date_modif($l['objet'],$id_o);
462
+                        lien_propage_date_modif($objet_source,$l[$primary]);
463
+                    }
464
+                    else
465
+                        $echec = true;
466
+                    $retire[] = array('source'=>array($objet_source=>$l[$primary]),'lien'=>array($l['objet']=>$id_o),'type'=>$l['objet'],'id'=>$id_o);
467
+                    // Envoyer aux plugins
468
+                    pipeline('post_edition_lien',
469
+                        array(
470
+                            'args' => array(
471
+                                'table_lien' => $table_lien,
472
+                                'objet_source' => $objet_source,
473
+                                'id_objet_source' => $l[$primary],
474
+                                'objet' => $l['objet'],
475
+                                'id_objet' => $id_o,
476
+                                'action'=>'delete',
477
+                            ),
478
+                            'data' => $id_o
479
+                        )
480
+                    );
481
+                }
482
+            }
483
+        }
484
+    }
485
+    pipeline('trig_supprimer_objets_lies',$retire);
486
+
487
+    return ($echec?false:$dels);
488 488
 }
489 489
 
490 490
 
@@ -507,51 +507,51 @@  discard block
 block discarded – undo
507 507
  * @return bool|int
508 508
  */
509 509
 function lien_optimise($objet_source,$primary,$table_lien,$id,$objets){
510
-	include_spip('genie/optimiser');
511
-	$echec = false;
512
-	$dels = 0;
513
-	foreach($objets as $objet => $id_objets){
514
-		$objet = ($objet=='*')?$objet:objet_type($objet); # securite
515
-		if (!is_array($id_objets) OR reset($id_objets)=="NOT") $id_objets = array($id_objets);
516
-		foreach($id_objets as $id_objet) {
517
-			$where = lien_where($primary, $id, $objet, $id_objet);
518
-			# les liens vers un objet inexistant
519
-			$r = sql_select("DISTINCT objet",$table_lien,$where);
520
-			while ($t = sql_fetch($r)){
521
-				$type = $t['objet'];
522
-				$spip_table_objet = table_objet_sql($type);
523
-				$id_table_objet = id_table_objet($type);
524
-				$res = sql_select("L.$primary AS id,L.id_objet",
525
-					// la condition de jointure inclue L.objet='xxx' pour ne joindre que les bonnes lignes
526
-					// du coups toutes les lignes avec un autre objet ont un id_xxx=NULL puisque LEFT JOIN
527
-					// il faut les eliminier en repetant la condition dans le where L.objet='xxx'
528
-								"$table_lien AS L
510
+    include_spip('genie/optimiser');
511
+    $echec = false;
512
+    $dels = 0;
513
+    foreach($objets as $objet => $id_objets){
514
+        $objet = ($objet=='*')?$objet:objet_type($objet); # securite
515
+        if (!is_array($id_objets) OR reset($id_objets)=="NOT") $id_objets = array($id_objets);
516
+        foreach($id_objets as $id_objet) {
517
+            $where = lien_where($primary, $id, $objet, $id_objet);
518
+            # les liens vers un objet inexistant
519
+            $r = sql_select("DISTINCT objet",$table_lien,$where);
520
+            while ($t = sql_fetch($r)){
521
+                $type = $t['objet'];
522
+                $spip_table_objet = table_objet_sql($type);
523
+                $id_table_objet = id_table_objet($type);
524
+                $res = sql_select("L.$primary AS id,L.id_objet",
525
+                    // la condition de jointure inclue L.objet='xxx' pour ne joindre que les bonnes lignes
526
+                    // du coups toutes les lignes avec un autre objet ont un id_xxx=NULL puisque LEFT JOIN
527
+                    // il faut les eliminier en repetant la condition dans le where L.objet='xxx'
528
+                                "$table_lien AS L
529 529
 									LEFT JOIN $spip_table_objet AS O
530 530
 										ON (O.$id_table_objet=L.id_objet AND L.objet=".sql_quote($type).")",
531
-						"L.objet=".sql_quote($type)." AND O.$id_table_objet IS NULL");
532
-				// sur une cle primaire composee, pas d'autres solutions que de virer un a un
533
-				while ($row = sql_fetch($res)){
534
-					$e = sql_delete($table_lien, array("$primary=".$row['id'],"id_objet=".$row['id_objet'],"objet=".sql_quote($type)));
535
-					if ($e!=false){
536
-						$dels+=$e;
537
-						spip_log("Entree ".$row['id']."/".$row['id_objet']."/$type supprimee dans la table $table_lien",_LOG_INFO_IMPORTANTE);
538
-					}
539
-				}
540
-			}
541
-
542
-			# les liens depuis un objet inexistant
543
-			$table_source = table_objet_sql($objet_source);
544
-			// filtrer selon $id, $objet, $id_objet eventuellement fournis
545
-			// (en general '*' pour chaque)
546
-			$where = lien_where("L.$primary", $id, $objet, $id_objet);
547
-			$where[] = "O.$primary IS NULL";
548
-			$res = sql_select("L.$primary AS id",
549
-				      "$table_lien AS L LEFT JOIN $table_source AS O ON L.$primary=O.$primary",
550
-							$where);
551
-			$dels+= optimiser_sansref($table_lien, $primary, $res);
552
-		}
553
-	}
554
-	return ($echec?false:$dels);
531
+                        "L.objet=".sql_quote($type)." AND O.$id_table_objet IS NULL");
532
+                // sur une cle primaire composee, pas d'autres solutions que de virer un a un
533
+                while ($row = sql_fetch($res)){
534
+                    $e = sql_delete($table_lien, array("$primary=".$row['id'],"id_objet=".$row['id_objet'],"objet=".sql_quote($type)));
535
+                    if ($e!=false){
536
+                        $dels+=$e;
537
+                        spip_log("Entree ".$row['id']."/".$row['id_objet']."/$type supprimee dans la table $table_lien",_LOG_INFO_IMPORTANTE);
538
+                    }
539
+                }
540
+            }
541
+
542
+            # les liens depuis un objet inexistant
543
+            $table_source = table_objet_sql($objet_source);
544
+            // filtrer selon $id, $objet, $id_objet eventuellement fournis
545
+            // (en general '*' pour chaque)
546
+            $where = lien_where("L.$primary", $id, $objet, $id_objet);
547
+            $where[] = "O.$primary IS NULL";
548
+            $res = sql_select("L.$primary AS id",
549
+                        "$table_lien AS L LEFT JOIN $table_source AS O ON L.$primary=O.$primary",
550
+                            $where);
551
+            $dels+= optimiser_sansref($table_lien, $primary, $res);
552
+        }
553
+    }
554
+    return ($echec?false:$dels);
555 555
 }
556 556
 
557 557
 
@@ -577,31 +577,31 @@  discard block
 block discarded – undo
577 577
  * @return bool|int
578 578
  */
579 579
 function lien_set($objet_source,$primary,$table_lien,$id,$objets,$qualif){
580
-	$echec = null;
581
-	$ok = 0;
582
-	if (!$qualif)
583
-		return false;
584
-	// nettoyer qualif qui peut venir directement d'un objet_trouver_lien :
585
-	unset($qualif[$primary]);
586
-	unset($qualif[$objet_source]);
587
-	if (isset($qualif['objet'])) {
588
-		unset($qualif[$qualif['objet']]);
589
-	}
590
-	unset($qualif['objet']);
591
-	unset($qualif['id_objet']);
592
-	foreach($objets as $objet => $id_objets){
593
-		$objet = ($objet=='*')?$objet:objet_type($objet); # securite
594
-		if (!is_array($id_objets) OR reset($id_objets)=="NOT") $id_objets = array($id_objets);
595
-		foreach($id_objets as $id_objet) {
596
-			$where = lien_where($primary, $id, $objet, $id_objet);
597
-			$e = sql_updateq($table_lien,$qualif,$where);
598
-			if ($e===false)
599
-				$echec = true;
600
-		  else
601
-			  $ok++;
602
-		}
603
-	}
604
-	return ($echec?false:$ok);
580
+    $echec = null;
581
+    $ok = 0;
582
+    if (!$qualif)
583
+        return false;
584
+    // nettoyer qualif qui peut venir directement d'un objet_trouver_lien :
585
+    unset($qualif[$primary]);
586
+    unset($qualif[$objet_source]);
587
+    if (isset($qualif['objet'])) {
588
+        unset($qualif[$qualif['objet']]);
589
+    }
590
+    unset($qualif['objet']);
591
+    unset($qualif['id_objet']);
592
+    foreach($objets as $objet => $id_objets){
593
+        $objet = ($objet=='*')?$objet:objet_type($objet); # securite
594
+        if (!is_array($id_objets) OR reset($id_objets)=="NOT") $id_objets = array($id_objets);
595
+        foreach($id_objets as $id_objet) {
596
+            $where = lien_where($primary, $id, $objet, $id_objet);
597
+            $e = sql_updateq($table_lien,$qualif,$where);
598
+            if ($e===false)
599
+                $echec = true;
600
+            else
601
+                $ok++;
602
+        }
603
+    }
604
+    return ($echec?false:$ok);
605 605
 }
606 606
 
607 607
 /**
@@ -623,20 +623,20 @@  discard block
 block discarded – undo
623 623
  * @return array
624 624
  */
625 625
 function lien_find($objet_source,$primary,$table_lien,$id,$objets){
626
-	$trouve = array();
627
-	foreach($objets as $objet => $id_objets){
628
-		$objet = ($objet=='*')?$objet:objet_type($objet); # securite
629
-		// lien_where prend en charge les $id_objets sous forme int ou array
630
-		$where = lien_where($primary, $id, $objet, $id_objets);
631
-		$liens = sql_allfetsel('*',$table_lien,$where);
632
-		// ajouter les entrees objet_source et objet cible par convenance
633
-		foreach($liens as $l) {
634
-			$l[$objet_source] = $l[$primary];
635
-			$l[$objet] = $l['id_objet'];
636
-			$trouve[] = $l;
637
-		}
638
-	}
639
-	return $trouve;
626
+    $trouve = array();
627
+    foreach($objets as $objet => $id_objets){
628
+        $objet = ($objet=='*')?$objet:objet_type($objet); # securite
629
+        // lien_where prend en charge les $id_objets sous forme int ou array
630
+        $where = lien_where($primary, $id, $objet, $id_objets);
631
+        $liens = sql_allfetsel('*',$table_lien,$where);
632
+        // ajouter les entrees objet_source et objet cible par convenance
633
+        foreach($liens as $l) {
634
+            $l[$objet_source] = $l[$primary];
635
+            $l[$objet] = $l['id_objet'];
636
+            $trouve[] = $l;
637
+        }
638
+    }
639
+    return $trouve;
640 640
 }
641 641
 
642 642
 /**
@@ -647,14 +647,14 @@  discard block
 block discarded – undo
647 647
  * @param array|int $ids
648 648
  */
649 649
 function lien_propage_date_modif($objet,$ids){
650
-	$trouver_table = charger_fonction('trouver_table','base');
651
-
652
-	$table = table_objet_sql($objet);
653
-	if ($desc = $trouver_table($table)
654
-	 AND isset($desc['field']['date_modif'])){
655
-		$primary = id_table_objet($objet);
656
-		$where = (is_array($ids)?sql_in($primary, array_map('intval',$ids)):"$primary=".intval($ids));
657
-		sql_updateq($table, array('date_modif'=>date('Y-m-d H:i:s')), $where);
658
-	}
650
+    $trouver_table = charger_fonction('trouver_table','base');
651
+
652
+    $table = table_objet_sql($objet);
653
+    if ($desc = $trouver_table($table)
654
+     AND isset($desc['field']['date_modif'])){
655
+        $primary = id_table_objet($objet);
656
+        $where = (is_array($ids)?sql_in($primary, array_map('intval',$ids)):"$primary=".intval($ids));
657
+        sql_updateq($table, array('date_modif'=>date('Y-m-d H:i:s')), $where);
658
+    }
659 659
 }
660 660
 ?>
Please login to merge, or discard this patch.