Subversion Repositories Sites.tela-botanica.org

Rev

Rev 267 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 267 Rev 271
1
<?php
1
<?php
2
/*vim: set expandtab tabstop=4 shiftwidth=4: */
2
/*vim: set expandtab tabstop=4 shiftwidth=4: */
3
// +------------------------------------------------------------------------------------------------------+
3
// +------------------------------------------------------------------------------------------------------+
4
// | PHP version 5.1                                                                                      |
4
// | PHP version 5.1                                                                                      |
5
// +------------------------------------------------------------------------------------------------------+
5
// +------------------------------------------------------------------------------------------------------+
6
// | Copyright (C) 1999-2006 Tela Botanica (accueil@tela-botanica.org)                                    |
6
// | Copyright (C) 1999-2006 Tela Botanica (accueil@tela-botanica.org)                                    |
7
// +------------------------------------------------------------------------------------------------------+
7
// +------------------------------------------------------------------------------------------------------+
8
// | This file is part of tela_botanica_v4.                                                                         |
8
// | This file is part of tela_botanica_v4.                                                                         |
9
// |                                                                                                      |
9
// |                                                                                                      |
10
// | Foobar is free software; you can redistribute it and/or modify                                       |
10
// | Foobar is free software; you can redistribute it and/or modify                                       |
11
// | it under the terms of the GNU General Public License as published by                                 |
11
// | it under the terms of the GNU General Public License as published by                                 |
12
// | the Free Software Foundation; either version 2 of the License, or                                    |
12
// | the Free Software Foundation; either version 2 of the License, or                                    |
13
// | (at your option) any later version.                                                                  |
13
// | (at your option) any later version.                                                                  |
14
// |                                                                                                      |
14
// |                                                                                                      |
15
// | Foobar is distributed in the hope that it will be useful,                                            |
15
// | Foobar is distributed in the hope that it will be useful,                                            |
16
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
16
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
17
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                        |
17
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                        |
18
// | GNU General Public License for more details.                                                         |
18
// | GNU General Public License for more details.                                                         |
19
// |                                                                                                      |
19
// |                                                                                                      |
20
// | You should have received a copy of the GNU General Public License                                    |
20
// | You should have received a copy of the GNU General Public License                                    |
21
// | along with Foobar; if not, write to the Free Software                                                |
21
// | along with Foobar; if not, write to the Free Software                                                |
22
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
22
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
23
// +------------------------------------------------------------------------------------------------------+
23
// +------------------------------------------------------------------------------------------------------+
24
// CVS : $Id$
24
// CVS : $Id$
25
/**
25
/**
26
* tela_botanica_v4 - nettoyage_wikini.php
26
* tela_botanica_v4 - nettoyage_wikini.php
27
*
27
*
28
* Description :
28
* Description :
29
*
29
*
30
*@package tela_botanica_v4
30
*@package tela_botanica_v4
31
//Auteur original :
31
//Auteur original :
32
*@author        Jean-Pascal MILCENT <jpm@tela-botanica.org>
32
*@author        Jean-Pascal MILCENT <jpm@tela-botanica.org>
33
//Autres auteurs :
33
//Autres auteurs :
34
*@author        Aucun
34
*@author        Aucun
35
*@copyright     Tela-Botanica 1999-2007
35
*@copyright     Tela-Botanica 1999-2007
36
*@version       $Revision$ $Date$
36
*@version       $Revision$ $Date$
37
// +------------------------------------------------------------------------------------------------------+
37
// +------------------------------------------------------------------------------------------------------+
38
*/
38
*/
39
 
39
 
40
// +------------------------------------------------------------------------------------------------------+
40
// +------------------------------------------------------------------------------------------------------+
41
// |                                            ENTÊTE du PROGRAMME                                       |
41
// |                                            ENTÊTE du PROGRAMME                                       |
42
// +------------------------------------------------------------------------------------------------------+
42
// +------------------------------------------------------------------------------------------------------+
43
define('CHEMIN_PEAR', '../api/pear/');
43
define('CHEMIN_PEAR', '../api/pear/');
44
$GLOBALS['_NETTOYAGE_']['sites'] = array('http://www.tela-botanica.org', 'http://www.outils-reseaux.org');
44
$GLOBALS['_NETTOYAGE_']['sites'] = array('http://www.tela-botanica.org', 'http://www.outils-reseaux.org');
45
 
45
 
46
// +------------------------------------------------------------------------------------------------------+
46
// +------------------------------------------------------------------------------------------------------+
47
// |                                            CORPS du PROGRAMME                                        |
47
// |                                            CORPS du PROGRAMME                                        |
48
// +------------------------------------------------------------------------------------------------------+
48
// +------------------------------------------------------------------------------------------------------+
-
 
49
echo '<h1>'.'Nettoyage des wikini de tela_prod_wikini'.'</h1>';
49
$Nettoyage = new Nettoyage();
50
$Nettoyage = new Nettoyage();
-
 
51
echo '<pre>';
50
$Nettoyage->nettoyageGlobal();
52
$Nettoyage->nettoyageGlobal();
51
 
53
echo '</pre>';
52
// +------------------------------------------------------------------------------------------------------+
54
// +------------------------------------------------------------------------------------------------------+
53
// |                                           CLASSES du PROGRAMME                                       |
55
// |                                           CLASSES du PROGRAMME                                       |
54
// +------------------------------------------------------------------------------------------------------+
56
// +------------------------------------------------------------------------------------------------------+
55
class Nettoyage {
57
class Nettoyage {
-
 
58
	private $bdd_principale = "tela_prod_wikini";
-
 
59
	private $bdd_options = array('debug' => 3);
-
 
60
	private $bdd_dsn = "mysql://utilisateur:mdp@localhost/tela_prod_wikini";
56
	
61
	
57
	public function __construct()
62
	public function __construct()
58
	{
63
	{
59
		$fichier_ini = 'bdd.ini';
64
//		$fichier_ini = 'bdd.ini';
60
		if (file_exists($fichier_ini)) {
65
//		$ok = $this->parserFichierIni($fichier_ini);
-
 
66
//		if (!$ok) {
61
			$this->parserFichierIni($fichier_ini);
67
//			$e = 'Impossible de parser le fichier : '.$fichier_ini;
-
 
68
//			trigger_error($e, E_USER_ERROR);
-
 
69
//		} else {
62
			require_once CHEMIN_PEAR.'DB.php';
70
			require_once CHEMIN_PEAR.'DB.php';
63
			$this->connexion = DB::connect($this->bdd_dsn, $this->bdd_options);
71
			$this->connexion = DB::connect($this->bdd_dsn, $this->bdd_options);
64
			if (PEAR::isError($this->connexion)) {
72
			if (PEAR::isError($this->connexion)) {
65
				$e = $this->connexion->getMessage();
73
				$e = $this->connexion->getMessage();
66
				trigger_error($e, E_USER_ERROR);
74
				trigger_error($e, E_USER_ERROR);
67
			}
75
			}
68
		}
76
//		}
69
	}
77
	}
70
	
78
	
71
	public function nettoyageGlobal()
79
	public function nettoyageGlobal()
72
	{
80
	{
73
		$res = $this->connexion->query('SHOW TABLES');
81
		$res = $this->connexion->query('SHOW TABLES');
74
		if (PEAR::isError($res)) {
82
		if (PEAR::isError($res)) {
75
			die($res->getMessage());
83
			die($res->getMessage());
76
		}
84
		}
77
		$tab_tables = array();
85
		$tab_tables = array();
78
		$ligne = '';
86
		$ligne = '';
79
		while ($res->fetchInto($ligne)) {
87
		while ($res->fetchInto($ligne)) {
80
			$tab_tables[] = $ligne[0];
88
			$tab_tables[] = $ligne[0];
81
		}
89
		}
82
 
-
 
83
		echo '<pre>';
90
 
84
		foreach ($tab_tables as $table) {
91
		foreach ($tab_tables as $table) {
85
			echo "\n".$table."\n";
92
			echo "\n".$table."\n";
86
 
93
 
87
			// Referrers
94
			// Referrers
88
			if (preg_match('/_referrers$/', $table)) {
95
			if (preg_match('/_referrers$/', $table)) {
89
				$site_nbre = count($GLOBALS['_NETTOYAGE_']['sites']);
96
				$site_nbre = count($GLOBALS['_NETTOYAGE_']['sites']);
90
				$site_0 = $GLOBALS['_NETTOYAGE_']['sites'][0];
97
				$site_0 = $GLOBALS['_NETTOYAGE_']['sites'][0];
91
				$requete = 	'DELETE FROM '.$table.' '.
98
				$requete = 	'DELETE FROM '.$table.' '.
92
							'WHERE referrer NOT LIKE "'.$site_0.'%" ';
99
							'WHERE referrer NOT LIKE "'.$site_0.'%" ';
93
				for ($i = 1; $i < $site_nbre; $i++) {
100
				for ($i = 1; $i < $site_nbre; $i++) {
94
					$requete .= 'AND referrer NOT LIKE "'.$GLOBALS['_NETTOYAGE_']['sites'][$i].'%" ';
101
					$requete .= 'AND referrer NOT LIKE "'.$GLOBALS['_NETTOYAGE_']['sites'][$i].'%" ';
95
				}
102
				}
96
				echo $requete."\n";
103
				echo $requete."\n";
97
				$res = $this->connexion->query($requete);
104
				$res = $this->connexion->query($requete);
98
				if (PEAR::isError($res)) {
105
				if (PEAR::isError($res)) {
99
					die($res->getMessage());
106
					die($res->getMessage());
100
				}
107
				}
101
			}
108
			}
102
 
109
 
103
			// Pages : commentaires
110
			// Pages : commentaires
104
			if (preg_match('/_pages$/', $table)) {
111
			if (preg_match('/_pages$/', $table)) {
105
				$requete = 	'DELETE FROM '.$table.' '.
112
				$requete = 	'DELETE FROM '.$table.' '.
106
							'WHERE tag LIKE "Comment%" ';
113
							'WHERE tag LIKE "Comment%" ';
107
				echo $requete."\n";
114
				echo $requete."\n";
108
				$res = $this->connexion->query($requete);
115
				$res = $this->connexion->query($requete);
109
				if (PEAR::isError($res)) {
116
				if (PEAR::isError($res)) {
110
					die($res->getMessage());
117
					die($res->getMessage());
111
				}
118
				}
112
			}
119
			}
113
			
120
			
114
			// ACLs : commentaires
121
			// ACLs : commentaires
115
			if (preg_match('/_acls$/', $table)) {
122
			if (preg_match('/_acls$/', $table)) {
116
				$requete = 	'DELETE FROM '.$table.' '.
123
				$requete = 	'DELETE FROM '.$table.' '.
117
							'WHERE page_tag LIKE "Comment%" ';
124
							'WHERE page_tag LIKE "Comment%" ';
118
				echo $requete."\n";
125
				echo $requete."\n";
119
				$res = $this->connexion->query($requete);
126
				$res = $this->connexion->query($requete);
120
				if (PEAR::isError($res)) {
127
				if (PEAR::isError($res)) {
121
					die($res->getMessage());
128
					die($res->getMessage());
122
				}
129
				}
123
				
130
				
124
				$requete = 	'UPDATE '.$table.' '.
131
				$requete = 	'UPDATE '.$table.' '.
125
							'SET list = "+" '.
132
							'SET list = "+" '.
126
							'WHERE privilege = "comment" ';
133
							'WHERE privilege = "comment" ';
127
				echo $requete."\n";
134
				echo $requete."\n";
128
				$res = $this->connexion->query($requete);
135
				$res = $this->connexion->query($requete);
129
				if (PEAR::isError($res)) {
136
				if (PEAR::isError($res)) {
130
					die($res->getMessage());
137
					die($res->getMessage());
131
				}
138
				}
132
			}
139
			}
133
		}
140
		}
134
		echo '</pre>';
-
 
135
	}
141
	}
136
	
142
	
137
	private function parserFichierIni($fichier_ini)
143
	function parserFichierIni($fichier_ini)
138
	{
144
	{
139
		if (file_exists($fichier_ini)) {
145
		if (file_exists($fichier_ini)) {
140
			$aso_ini = parse_ini_file($fichier_ini);
146
			$aso_ini = parse_ini_file($fichier_ini);
141
	    	foreach ($aso_ini as $cle => $val) {
147
	    	foreach ($aso_ini as $cle => $val) {
142
	    		if (preg_match('/^php:(.+)$/', $val, $correspondances)) {
148
	    		if (preg_match('/^php:(.+)$/', $val, $correspondances)) {
143
					eval('$this->$cle = '.$correspondances[1].';');
149
					eval('$this->$cle = '.$correspondances[1].';');
144
				} else if (preg_match('/^php-static:(.+)$/', $val, $correspondances)) {
150
				} else if (preg_match('/^php-static:(.+)$/', $val, $correspondances)) {
145
					eval('self::$'.$cle.' = '.$correspondances[1].';');
151
					eval('self::$'.$cle.' = '.$correspondances[1].';');
146
				} else {
152
				} else {
147
					$this->$cle = $val;
153
					$this->$cle = $val;
148
				}
154
				}
149
		   	}
155
		   	}
150
		} else {
156
		} else {
151
			return false;
157
			return false;
152
		}
158
		}
153
	}
159
	}
154
}
160
}
155
/* +--Fin du code ----------------------------------------------------------------------------------------+
161
/* +--Fin du code ----------------------------------------------------------------------------------------+
156
*
162
*
157
* $Log$
163
* $Log$
158
*
164
*
159
* +-- Fin du code ----------------------------------------------------------------------------------------+
165
* +-- Fin du code ----------------------------------------------------------------------------------------+
160
*/
166
*/
161
?>
167
?>