| Line 19... |
Line 19... |
| 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: adwi_wikini.fonct.php,v 1.10 2006-10-05 08:56:12 florian Exp $
|
24 |
// CVS : $Id: adwi_wikini.fonct.php,v 1.11 2007-04-06 08:40:13 neiluj Exp $
|
| 25 |
/**
|
25 |
/**
|
| 26 |
* Contient les fonctions de l'application gestion des Wikini
|
26 |
* Contient les fonctions de l'application gestion des Wikini
|
| 27 |
*
|
27 |
*
|
| 28 |
*
|
28 |
*
|
| 29 |
*
|
29 |
*
|
| Line 33... |
Line 33... |
| 33 |
//Auteur original :
|
33 |
//Auteur original :
|
| 34 |
*@author David Delon <david.delon@tela-botanica.org>
|
34 |
*@author David Delon <david.delon@tela-botanica.org>
|
| 35 |
//Autres auteurs :
|
35 |
//Autres auteurs :
|
| 36 |
*@author Aucun
|
36 |
*@author Aucun
|
| 37 |
*@copyright Tela-Botanica 2000-2004
|
37 |
*@copyright Tela-Botanica 2000-2004
|
| 38 |
*@version $Revision: 1.10 $
|
38 |
*@version $Revision: 1.11 $
|
| 39 |
// +------------------------------------------------------------------------------------------------------+
|
39 |
// +------------------------------------------------------------------------------------------------------+
|
| 40 |
*/
|
40 |
*/
|
| Line 41... |
Line 41... |
| 41 |
|
41 |
|
| 42 |
// +------------------------------------------------------------------------------------------------------+
|
42 |
// +------------------------------------------------------------------------------------------------------+
|
| Line 75... |
Line 75... |
| 75 |
if (GEN_FTP_UTILISE) {
|
75 |
if (GEN_FTP_UTILISE) {
|
| 76 |
/** Inclusion bibliothèque de PEAR gérant le FTP.*/
|
76 |
/** Inclusion bibliothèque de PEAR gérant le FTP.*/
|
| 77 |
require_once ADWI_CHEMIN_BIBLIOTHEQUE_PEAR.'Net/FTP.php';
|
77 |
require_once ADWI_CHEMIN_BIBLIOTHEQUE_PEAR.'Net/FTP.php';
|
| Line 78... |
Line 78... |
| 78 |
|
78 |
|
| 79 |
// création de l'objet pear ftp
|
79 |
// création de l'objet pear ftp
|
| - |
|
80 |
$objet_pear_ftp = new Net_FTP(PAP_FTP_SERVEUR, PAP_FTP_PORT) or die("Impossible de se connecter par FTP !");
|
| 80 |
$objet_pear_ftp = new Net_FTP(PAP_FTP_SERVEUR, PAP_FTP_PORT);
|
81 |
|
| 81 |
// création de la connexion
|
82 |
// création de la connexion
|
| 82 |
$ftp_conn = $objet_pear_ftp->connect(PAP_FTP_SERVEUR, PAP_FTP_PORT);
|
83 |
$ftp_conn = $objet_pear_ftp->connect(PAP_FTP_SERVEUR, PAP_FTP_PORT) or die("Impossible de se connecter par FTP !");
|
| 83 |
// identification
|
84 |
// identification
|
| Line 84... |
Line 85... |
| 84 |
$ftp_login_result = $objet_pear_ftp->login(PAP_FTP_UTILISATEUR, PAP_FTP_MOT_DE_PASSE);
|
85 |
$ftp_login_result = $objet_pear_ftp->login(PAP_FTP_UTILISATEUR, PAP_FTP_MOT_DE_PASSE);
|
| 85 |
|
86 |
|
| Line 137... |
Line 138... |
| 137 |
$GLOBALS['_GEN_commun']['debogage_erreur']->gererErreur(E_USER_WARNING, "Echec de la requete : $requete<br />".$resultat->getMessage(),
|
138 |
$GLOBALS['_GEN_commun']['debogage_erreur']->gererErreur(E_USER_WARNING, "Echec de la requete : $requete<br />".$resultat->getMessage(),
|
| 138 |
__FILE__, __LINE__, 'admin_wikini') ;
|
139 |
__FILE__, __LINE__, 'admin_wikini') ;
|
| 139 |
return ;
|
140 |
return ;
|
| 140 |
}
|
141 |
}
|
| Line 141... |
Line -... |
| 141 |
|
- |
|
| 142 |
|
142 |
|
| 143 |
$ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ;
|
143 |
$ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ;
|
| 144 |
$resultat->free();
|
144 |
$resultat->free();
|
| 145 |
unset ($requete, $resultat);
|
145 |
unset ($requete, $resultat);
|
| Line 173... |
Line 173... |
| 173 |
|
173 |
|
| 174 |
unset ($requete, $resultat);
|
174 |
unset ($requete, $resultat);
|
| 175 |
return $tableau_retour ;
|
175 |
return $tableau_retour ;
|
| Line -... |
Line 176... |
| - |
|
176 |
}
|
| - |
|
177 |
|
| - |
|
178 |
// merci PHP 5 ...
|
| - |
|
179 |
function mb_str_split($str, $length = 1) {
|
| - |
|
180 |
if ($length < 1) return FALSE;
|
| - |
|
181 |
|
| - |
|
182 |
$result = array();
|
| - |
|
183 |
|
| - |
|
184 |
for ($i = 0; $i < strlen($str); $i += $length) {
|
| - |
|
185 |
$result[] = substr($str, $i, $length);
|
| - |
|
186 |
}
|
| - |
|
187 |
|
| - |
|
188 |
return $result;
|
| - |
|
189 |
}
|
| - |
|
190 |
//
|
| - |
|
191 |
function remove_accents( $string )
|
| - |
|
192 |
{
|
| - |
|
193 |
$string = htmlentities($string);
|
| - |
|
194 |
return preg_replace("/&([a-z])[a-z]+;/i","$1",$string);
|
| - |
|
195 |
}
|
| - |
|
196 |
|
| - |
|
197 |
function genere_nom_wiki($nom, $spaces = FALSE)
|
| - |
|
198 |
{
|
| - |
|
199 |
// traitement des accents
|
| - |
|
200 |
$nom = remove_accents($nom);
|
| - |
|
201 |
|
| - |
|
202 |
$temp = mb_str_split($nom);
|
| - |
|
203 |
|
| - |
|
204 |
$count = 0;
|
| - |
|
205 |
$final = NULL;
|
| - |
|
206 |
foreach($temp as $letter)
|
| - |
|
207 |
{
|
| - |
|
208 |
if(preg_match('/([[:space:]]|[[:punct:]])/', $letter))
|
| - |
|
209 |
{
|
| - |
|
210 |
$final .= ($spaces ? '_' : '');
|
| - |
|
211 |
} elseif(preg_match ('/[a-zA-Z0-9]/', $letter)) {
|
| - |
|
212 |
$final .= (($count == 0 || $count == (strlen($nom) - 1)) ? strtoupper($letter) : strtolower($letter));
|
| - |
|
213 |
}
|
| - |
|
214 |
$count++;
|
| - |
|
215 |
}
|
| - |
|
216 |
|
| - |
|
217 |
// vérifions que le retour n'est pas uniquement un underscore
|
| - |
|
218 |
if(preg_match('/^[[:punct:]]+$/', $final)) return FALSE;
|
| - |
|
219 |
|
| - |
|
220 |
// sinon retour du nom formaté
|
| - |
|
221 |
return($final);
|
| 176 |
}
|
222 |
}
|
| 177 |
|
223 |
|
| 178 |
/**
|
224 |
/**
|
| 179 |
*
|
225 |
*
|
| 180 |
* C du CRUD
|
226 |
* C du CRUD
|
| Line 181... |
Line 227... |
| 181 |
* @return int id_wikini_bdd
|
227 |
* @return int id_wikini_bdd
|
| - |
|
228 |
*/
|
| - |
|
229 |
|
| - |
|
230 |
|
| - |
|
231 |
function insertion ($valeur, &$db) {
|
| - |
|
232 |
|
| 182 |
*/
|
233 |
// --julien pour noms wiki
|
| 183 |
|
234 |
$valeur['code_alpha_wikini'] = genere_nom_wiki($valeur['code_alpha_wikini'], TRUE);
|
| 184 |
|
235 |
|
| 185 |
function insertion ($valeur, &$db) {
|
236 |
|
| 186 |
// Calcul dernier identifiant
|
237 |
// Calcul dernier identifiant
|
| Line 196... |
Line 247... |
| 196 |
if (GEN_FTP_UTILISE) {
|
247 |
if (GEN_FTP_UTILISE) {
|
| 197 |
/** Inclusion bibliothèque de PEAR gérant le FTP.*/
|
248 |
/** Inclusion bibliothèque de PEAR gérant le FTP.*/
|
| 198 |
require_once ADWI_CHEMIN_BIBLIOTHEQUE_PEAR.'Net/FTP.php';
|
249 |
require_once ADWI_CHEMIN_BIBLIOTHEQUE_PEAR.'Net/FTP.php';
|
| Line 199... |
Line 250... |
| 199 |
|
250 |
|
| 200 |
// création de l'objet pear ftp
|
251 |
// création de l'objet pear ftp
|
| 201 |
$objet_pear_ftp = new Net_FTP(PAP_FTP_SERVEUR, PAP_FTP_PORT);
|
252 |
$objet_pear_ftp = new Net_FTP(PAP_FTP_SERVEUR, PAP_FTP_PORT) or die("Connexion FTP Impossible !");
|
| 202 |
// création de la connexion
|
253 |
// création de la connexion
|
| 203 |
$ftp_conn = $objet_pear_ftp->connect(PAP_FTP_SERVEUR, PAP_FTP_PORT);
|
254 |
$ftp_conn = $objet_pear_ftp->connect(PAP_FTP_SERVEUR, PAP_FTP_PORT) or die("Connexion FTP Impossible !");
|
| 204 |
// identification
|
255 |
// identification
|
| Line 205... |
Line 256... |
| 205 |
$ftp_login_result = $objet_pear_ftp->login(PAP_FTP_UTILISATEUR, PAP_FTP_MOT_DE_PASSE);
|
256 |
$ftp_login_result = $objet_pear_ftp->login(PAP_FTP_UTILISATEUR, PAP_FTP_MOT_DE_PASSE);
|
| 206 |
|
257 |
|
| 207 |
// Gestion des erreurs ftp
|
258 |
// Gestion des erreurs ftp
|
| 208 |
if ((PEAR::isError($ftp_conn) || PEAR::isError($ftp_login_result))) {
|
259 |
if ((PEAR::isError($ftp_conn) || PEAR::isError($ftp_login_result))) {
|
| 209 |
$message = '<p class="pap_erreur"> ERREUR Papyrus admin : impossible de se connecter par ftp.<br />'.
|
260 |
$message = '<p class="pap_erreur"> ERREUR Papyrus admin : impossible de se connecter par ftp.<br />'.
|
| 210 |
'Serveur : '. PAP_FTP_SERVEUR .'<br />'.
|
261 |
'Serveur : '. PAP_FTP_SERVEUR .'<br />'.
|
| 211 |
'Utilisateur : '. PAP_FTP_UTILISATEUR .'<br />'.
|
262 |
'Utilisateur : '. PAP_FTP_UTILISATEUR .'<br />'.
|
| 212 |
'Erreur connexion : '.$ftp_conn->getMessage().'<br />'.
|
263 |
// 'Erreur connexion : '.$ftp_conn->getMessage().'<br />'.
|
| 213 |
'Erreur login : '.$ftp_login_result->getMessage().'<br />'.
|
264 |
'Erreur login : '.$ftp_login_result->getMessage().'<br />'.
|
| 214 |
'Ligne n° : '. __LINE__ .'<br />'.
|
265 |
'Ligne n° : '. __LINE__ .'<br />'.
|
| 215 |
'Fichier n° : '. __FILE__ .'<br /><p>';
|
266 |
'Fichier n° : '. __FILE__ .'<br /><p>';
|
| 216 |
print $message;
|
267 |
print $message;
|
| Line 217... |
Line 268... |
| 217 |
}
|
268 |
}
|
| 218 |
$objet_pear_ftp->mkdir(PAP_FTP_RACINE.ADWI_CHEMIN_WIKINI.$valeur['code_alpha_wikini']) ;
|
269 |
$objet_pear_ftp->mkdir(PAP_FTP_RACINE.ADWI_CHEMIN_WIKINI) ;
|
| Line 219... |
Line 270... |
| 219 |
|
270 |
|
| 220 |
$chemin_wikini_bibliotheque = ADWI_CHEMIN_BIBLIOTHEQUE_WIKINI;
|
271 |
$chemin_wikini_bibliotheque = ADWI_CHEMIN_BIBLIOTHEQUE_WIKINI;
|
| Line 221... |
Line 272... |
| 221 |
$chemin_wikini = PAP_FTP_RACINE.ADWI_CHEMIN_WIKINI.$valeur['code_alpha_wikini'].GEN_SEP;
|
272 |
$chemin_wikini = PAP_FTP_RACINE.ADWI_CHEMIN_WIKINI.genere_nom_wiki($valeur['code_alpha_wikini'], TRUE).GEN_SEP;
|
| Line 248... |
Line 299... |
| 248 |
|
299 |
|
| 249 |
|
300 |
|
| 250 |
if ((!isset($valeur['table_prefix'])) || (empty($config_wikini['$valeur']))) {
|
301 |
if ((!isset($valeur['table_prefix'])) || (empty($config_wikini['$valeur']))) {
|
| 251 |
$valeur['table_prefix'] = $valeur['code_alpha_wikini'];
|
302 |
$valeur['table_prefix'] = $valeur['code_alpha_wikini'];
|
| Line 252... |
Line 303... |
| 252 |
}
|
303 |
}
|
| Line 253... |
Line 304... |
| 253 |
$g_wikini->creation_tables($valeur['table_prefix']);
|
304 |
$g_wikini->creation_tables($valeur['table_prefix'], $valeur['page']);
|
| Line 269... |
Line 320... |
| 269 |
'mysql_host' => $config_wikini['bdd_hote'],
|
320 |
'mysql_host' => $config_wikini['bdd_hote'],
|
| 270 |
'mysql_database' => $config_wikini['bdd_nom'],
|
321 |
'mysql_database' => $config_wikini['bdd_nom'],
|
| 271 |
'mysql_user' => $config_wikini['bdd_utilisateur'],
|
322 |
'mysql_user' => $config_wikini['bdd_utilisateur'],
|
| 272 |
'mysql_password' => $config_wikini['bdd_mdp'],
|
323 |
'mysql_password' => $config_wikini['bdd_mdp'],
|
| 273 |
'table_prefix' => $config_wikini['table_prefix'],
|
324 |
'table_prefix' => $config_wikini['table_prefix'],
|
| 274 |
'root_page' => $config_wikini['page'],
|
325 |
'root_page' => $valeur['page'],
|
| 275 |
'wakka_name' => $config_wikini['code_alpha_wikini'],
|
326 |
'wakka_name' => str_replace("_", " ", $valeur['code_alpha_wikini']),
|
| 276 |
'base_url' => $config_base_url,
|
327 |
'base_url' => $config_base_url,
|
| 277 |
'rewrite_mode' => '0',
|
328 |
'rewrite_mode' => '0',
|
| 278 |
'meta_keywords' => '',
|
329 |
'meta_keywords' => '',
|
| 279 |
'meta_description' => '',
|
330 |
'meta_description' => '',
|
| 280 |
'action_path' => 'actions',
|
331 |
'action_path' => 'actions',
|
| Line 306... |
Line 357... |
| 306 |
fwrite($temp, $configCode);
|
357 |
fwrite($temp, $configCode);
|
| 307 |
fclose($temp);
|
358 |
fclose($temp);
|
| Line 308... |
Line 359... |
| 308 |
|
359 |
|
| 309 |
|
360 |
|
| Line 310... |
Line 361... |
| 310 |
$fichier_config_source = $tempfn;
|
361 |
$fichier_config_source = $tempfn;
|
| Line 311... |
Line 362... |
| 311 |
$fichier_config_cible = PAP_FTP_RACINE.ADWI_CHEMIN_WIKINI.$valeur['code_alpha_wikini'].GEN_SEP."wakka.config.php";
|
362 |
$fichier_config_cible = PAP_FTP_RACINE.ADWI_CHEMIN_WIKINI.genere_nom_wiki($valeur['code_alpha_wikini'], TRUE).GEN_SEP."wakka.config.php";
|
| 312 |
|
363 |
|
| Line 350... |
Line 401... |
| 350 |
*
|
401 |
*
|
| 351 |
* @return string un morceau de code SQL
|
402 |
* @return string un morceau de code SQL
|
| 352 |
*/
|
403 |
*/
|
| Line 353... |
Line 404... |
| 353 |
|
404 |
|
| 354 |
function requete_wikini (&$valeur) {
|
405 |
function requete_wikini (&$valeur) {
|
| 355 |
return 'gewi_code_alpha_wikini ="'.$valeur['code_alpha_wikini'].'", '
|
406 |
return 'gewi_code_alpha_wikini ="'.genere_nom_wiki($valeur['code_alpha_wikini'], TRUE).'", '
|
| 356 |
.'gewi_bdd_hote ="'.$valeur['bdd_hote'].'", '
|
407 |
.'gewi_bdd_hote ="'.$valeur['bdd_hote'].'", '
|
| 357 |
.'gewi_bdd_nom="'.$valeur['bdd_nom'].'", '
|
408 |
.'gewi_bdd_nom="'.$valeur['bdd_nom'].'", '
|
| 358 |
.'gewi_bdd_utilisateur ="'.$valeur['bdd_utilisateur'].'", '
|
409 |
.'gewi_bdd_utilisateur ="'.$valeur['bdd_utilisateur'].'", '
|
| 359 |
.'gewi_bdd_mdp="'.$valeur['bdd_mdp'].'", '
|
410 |
.'gewi_bdd_mdp="'.$valeur['bdd_mdp'].'", '
|