Subversion Repositories Sites.tela-botanica.org

Rev

Rev 380 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 380 Rev 383
Line 424... Line 424...
424
		    	if(preg_match('/"(.*)"\s*=>\s*"(.*)"\s*,/', $ligne, $match)) {
424
		    	if(preg_match('/"(.*)"\s*=>\s*"(.*)"\s*,/', $ligne, $match)) {
425
		    		//trigger_error(print_r($match, true), E_USER_NOTICE);
425
		    		//trigger_error(print_r($match, true), E_USER_NOTICE);
426
		    		$wakka_config[$match[1]] = $match[2];
426
		    		$wakka_config[$match[1]] = $match[2];
427
			    }
427
			    }
428
			}
428
			}
429
			//trigger_error(print_r($wakka_config, true), E_USER_NOTICE);
-
 
-
 
429
			
430
			if (isset($wakka_config['mysql_user']) && isset($wakka_config['mysql_password']) && isset($wakka_config['mysql_host']) && isset($wakka_config['mysql_database'])) {
430
			if (isset($wakka_config['mysql_user']) && isset($wakka_config['mysql_password']) && isset($wakka_config['mysql_host']) && isset($wakka_config['mysql_database'])) {
431
				// Connexion à la base de données
431
				// Connexion à la base de données
432
				$dsn = 'mysql://'.$wakka_config['mysql_user'].':'.$wakka_config['mysql_password'].'@'.$wakka_config['mysql_host'].'/'.$wakka_config['mysql_database'];
432
				$dsn = 'mysql://'.$wakka_config['mysql_user'].':'.$wakka_config['mysql_password'].'@'.$wakka_config['mysql_host'].'/'.$wakka_config['mysql_database'];
433
				$this->connexion = DB::connect($dsn, $this->bdd_options);
433
				$this->connexion = DB::connect($dsn, $this->bdd_options);
434
				if (PEAR::isError($this->connexion)) {
434
				if (PEAR::isError($this->connexion)) {
435
					$e = $this->connexion->getMessage();
435
					$e = $this->connexion->getMessage();
436
					trigger_error($e, E_USER_ERROR);
436
					trigger_error($e, E_USER_ERROR);
437
				}
437
				}
438
				$res = $this->connexion->query('SHOW TABLES');
-
 
439
				if (PEAR::isError($res)) {
-
 
440
					die($res->getMessage());
-
 
441
				}
-
 
442
				$tab_tables = array();
-
 
443
				$ligne = '';
-
 
444
				while ($res->fetchInto($ligne)) {
-
 
445
					$tab_tables[] = $ligne[0];
-
 
446
				}
-
 
Line 447... Line 438...
447
				
438
				
448
				// Ajout des nouveaux referrers à ceux par défaut
439
				// Ajout des nouveaux referrers à ceux par défaut
449
				if (!empty($_POST['sc_referrers'])) {
440
				if (!empty($_POST['sc_referrers'])) {
450
					$this->sites = array_merge(preg_split("~,~",  $_POST['sc_referrers'], -1, PREG_SPLIT_NO_EMPTY), $this->sites);
441
					$this->sites = array_merge(preg_split("~,~",  $_POST['sc_referrers'], -1, PREG_SPLIT_NO_EMPTY), $this->sites);
Line 451... Line 442...
451
				}
442
				}
452
				
-
 
453
				foreach ($tab_tables as $table) {
443
				
454
					$requetes = array();
-
 
455
					// Referrers
444
				// +---------------------------------------------------------------------------------------------------+
456
					if (preg_match('/_referrers$/', $table)) {
445
				// Referrers
457
						$site_nbre = count($this->sites);
446
				$site_nbre = count($this->sites);
458
						$site_0 = $this->sites[0];
447
				$site_0 = $this->sites[0];
459
						$requete = 	'DELETE FROM '.$table.' '.
448
				$requete = 	'DELETE FROM '.$wakka_config['table_prefix'].'referrers '.
460
									'WHERE referrer NOT LIKE "'.$site_0.'%" ';
449
							'WHERE referrer NOT LIKE "'.$site_0.'%" ';
-
 
450
				for ($i = 1; $i < $site_nbre; $i++) {
-
 
451
					$requete .= 'AND referrer NOT LIKE "'.$this->sites[$i].'%" ';
-
 
452
				}
-
 
453
				$requetes[] = $requete."\n";
-
 
454
				$res = $this->connexion->query($requete);
-
 
455
				if (PEAR::isError($res)) {
-
 
456
					die($res->getMessage());
-
 
457
				}
-
 
458
 
-
 
459
				// +---------------------------------------------------------------------------------------------------+	
-
 
460
				// Pages : commentaires
-
 
461
				$requete = 	'SELECT tag FROM '.$wakka_config['table_prefix'].'pages '.
-
 
462
							'WHERE tag LIKE "Comment%" ';
-
 
463
				$requetes[] = $requete."\n";
-
 
464
				$aso_pages = $this->connexion->getAll($requete, null, DB_FETCHMODE_ASSOC);
-
 
465
				if (PEAR::isError($aso_pages)) {
-
 
466
					die($aso_pages->getMessage());
-
 
467
				}
-
 
468
				if (count($aso_pages) > 0) {
-
 
469
					$tab_pages = array();
-
 
470
					foreach ($aso_pages as $page) {
461
						for ($i = 1; $i < $site_nbre; $i++) {
471
						if (preg_match('/^Comment\d+$/', $page['tag'])){
-
 
472
							$tab_pages[] = $page['tag'];
-
 
473
						}
-
 
474
					}
-
 
475
					if (count($tab_pages) > 0) {
462
							$requete .= 'AND referrer NOT LIKE "'.$this->sites[$i].'%" ';
476
						$requete = 	'DELETE FROM '.$wakka_config['table_prefix'].'pages '.
463
						}
477
									'WHERE tag IN ("'.implode('","', $tab_pages).'") ';
464
						$requetes[] = $requete."\n";
478
						$requetes[] = $requete."\n";
465
						$res = $this->connexion->query($requete);
479
						$res = $this->connexion->query($requete);
466
						if (PEAR::isError($res)) {
480
						if (PEAR::isError($res)) {
467
							die($res->getMessage());
-
 
468
						}
-
 
469
					}
-
 
470
		
-
 
471
					// Pages : commentaires
-
 
472
					if (preg_match('/_pages$/', $table)) {
-
 
473
						$requete = 	'SELECT tag FROM '.$table.' '.
-
 
474
									'WHERE tag LIKE "Comment%" ';
481
							die($res->getMessage());
475
						$requetes[] = $requete."\n";
-
 
476
						$aso_pages = $this->connexion->getAll($requete, null, DB_FETCHMODE_ASSOC);
-
 
477
						if (PEAR::isError($aso_pages)) {
-
 
478
							die($aso_pages->getMessage());
-
 
479
						}
-
 
480
						if (count($aso_pages) > 0) {
-
 
481
							$tab_pages = array();
-
 
482
							foreach ($aso_pages as $page) {
-
 
483
								if (preg_match('/^Comment\d+$/', $page['tag'])){
-
 
484
									$tab_pages[] = $page['tag'];
-
 
485
								}
-
 
486
							}
-
 
487
							if (count($tab_pages) > 0) {
-
 
488
								$requete = 	'DELETE FROM '.$table.' '.
-
 
489
											'WHERE tag IN ("'.implode('","', $tab_pages).'") ';
-
 
490
								$requetes[] = $requete."\n";
-
 
491
								$res = $this->connexion->query($requete);
-
 
492
								if (PEAR::isError($res)) {
-
 
493
									die($res->getMessage());
-
 
494
								}
-
 
495
							}
-
 
496
						}
-
 
497
					}
482
						}
498
					
-
 
499
					// ACLs : commentaires
483
						// +---------------------------------------------------------------------------------------------------+				
500
					if (preg_match('/_acls$/', $table)) {
484
						// ACLs : commentaires
501
						$requete = 	'DELETE FROM '.$table.' '.
485
						$requete = 	'DELETE FROM '.$wakka_config['table_prefix'].'acls '.
502
									'WHERE page_tag LIKE "Comment%" ';
486
									'WHERE page_tag LIKE "Comment%" ';
503
						$requetes[] = $requete."\n";
487
						$requetes[] = $requete."\n";
504
						$res = $this->connexion->query($requete);
488
						$res = $this->connexion->query($requete);
505
						if (PEAR::isError($res)) {
489
						if (PEAR::isError($res)) {
Line 506... Line 490...
506
							die($res->getMessage());
490
							die($res->getMessage());
507
						}
491
						}
508
						
492
						
509
						$requete = 	'UPDATE '.$table.' '.
493
						$requete = 	'UPDATE '.$wakka_config['table_prefix'].'acls '.
510
									'SET list = "+" '.
494
									'SET list = "+" '.
511
									'WHERE privilege = "comment" ';
495
									'WHERE privilege = "comment" ';
512
						$requetes[] = $requete."\n";
496
						$requetes[] = $requete."\n";
513
						$res = $this->connexion->query($requete);
497
						$res = $this->connexion->query($requete);
514
						if (PEAR::isError($res)) {
498
						if (PEAR::isError($res)) {
-
 
499
							die($res->getMessage());
-
 
500
						}
-
 
501
					}
515
							die($res->getMessage());
502
				}
516
						}
503
 
517
					}
504
				// +---------------------------------------------------------------------------------------------------+
518
					// Stockage des requetes
505
				// Stockage des requetes
519
					if (count($requetes) > 0 ) {
506
				if (count($requetes) > 0 ) {
520
						$aso_donnees['wikinis'][] = array( 	'dossier' => $fichier,
507
					$aso_donnees['wikinis'][] = array( 	'dossier' => $fichier,
-
 
508
														'nom' => $wakka_config['wakka_name'],
-
 
509
														'version' =>  $wakka_config['wikini_version'], 
-
 
510
														'requetes' => $requetes);
-
 
511
				}
-
 
512
			}
-
 
513
			// Attribution des données pour remplir le squelette
-
 
514
			$this->getRegistre()->set('squelette_donnees', $aso_donnees);
-
 
515
		}
-
 
516
	}
-
 
517
	
-
 
518
	public function executerProprietaire()
-
 
519
	{
-
 
520
		// Initialisation des variables
-
 
521
		$this->setChrono('debut');
-
 
522
		$aso_donnees = $this->getRegistre()->get('squelette_donnees');
-
 
523
		
-
 
524
		// Gestion de l'url de l'envoie de mail
-
 
525
		$url = clone $GLOBALS['_SCRIPT_']['url'];
-
 
526
		$url->addQueryString('module', 'wikini');
-
 
527
		$url->addQueryString('action', 'proprietaire_maj');
-
 
528
		$aso_donnees['url'] = $url->getUrl();
-
 
529
 
-
 
530
		// Attribution des données pour remplir le squelette
-
 
531
		$this->getRegistre()->set('squelette_donnees', $aso_donnees);
-
 
532
		$this->setChrono('fin');
-
 
533
	}
-
 
534
	
-
 
535
	public function executerProprietaireMaj()
-
 
536
	{
-
 
537
		// Initialisation des variables
-
 
538
		$this->setChrono('debut');
-
 
539
		
-
 
540
		// Récupération des infos pour conpléter le squelette du courriel
-
 
541
		$this->rechercherWikini($_POST['sc_chemin'], 'modifierProprietaire');
-
 
542
 
-
 
543
		// Nous ajoutons une action à éxecuter avant de rendre la main
-
 
544
		$this->poursuivreVers('proprietaire');
-
 
545
				
-
 
546
		// Fin de l'action
-
 
547
		$this->setChrono('fin');
-
 
548
	}
-
 
549
	
-
 
550
	public function modifierProprietaire($fichier)
-
 
551
	{
-
 
552
		if (file_exists($fichier)) {
-
 
553
			// Initialisation de variables
-
 
554
			$aso_donnees = array();
-
 
555
			$wakka_config = array();
-
 
556
			$requetes = array();
-
 
557
			
-
 
558
			// Récupération de la config du wikini
-
 
559
			$tab_fichier = file($fichier);
-
 
560
			foreach ($tab_fichier as $ligne_num => $ligne) {
-
 
561
		    	if(preg_match('/"(.*)"\s*=>\s*"(.*)"\s*,/', $ligne, $match)) {
-
 
562
		    		//trigger_error(print_r($match, true), E_USER_NOTICE);
-
 
563
		    		$wakka_config[$match[1]] = $match[2];
-
 
564
			    }
-
 
565
			}
-
 
566
			//trigger_error(print_r($wakka_config, true), E_USER_NOTICE);
-
 
567
			if (isset($wakka_config['mysql_user']) && isset($wakka_config['mysql_password']) && isset($wakka_config['mysql_host']) && isset($wakka_config['mysql_database'])) {
-
 
568
				// Connexion à la base de données
-
 
569
				$dsn = 'mysql://'.$wakka_config['mysql_user'].':'.$wakka_config['mysql_password'].'@'.$wakka_config['mysql_host'].'/'.$wakka_config['mysql_database'];
-
 
570
				$this->connexion = DB::connect($dsn, $this->bdd_options);
-
 
571
				if (PEAR::isError($this->connexion)) {
-
 
572
					$e = $this->connexion->getMessage();
-
 
573
					trigger_error($e, E_USER_ERROR);
-
 
574
				}
-
 
575
				// Mise à jour des droits
-
 
576
				$requete = 	'UPDATE '.$wakka_config['table_prefix'].'pages '.
-
 
577
							'SET owner = "'.$_POST['sc_owner'].'" '.
-
 
578
							((!empty($_POST['sc_page'])) ? 'WHERE tag IN ("'.implode('","', preg_split("~,~",  $_POST['sc_page'], -1, PREG_SPLIT_NO_EMPTY)).'") ' : '');
-
 
579
				$requetes[] = $requete."\n";
-
 
580
				$res = $this->connexion->query($requete);
521
															'nom' => $wakka_config['wakka_name'],
581
				if (PEAR::isError($res)) {
-
 
582
					$requetes[] = $res->getMessage().$res->getDebugInfo();
-
 
583
					trigger_error($res->getMessage().$res->getDebugInfo(), E_USER_WARNING);
-
 
584
				}
-
 
585
				
-
 
586
				// Stockage des requetes
-
 
587
				if (count($requetes) > 0 ) {
-
 
588
					$aso_donnees['wikinis'][] = array( 	'dossier' => $fichier,
522
															'version' =>  $wakka_config['wikini_version'], 
589
														'nom' => $wakka_config['wakka_name'],
523
															'requetes' => $requetes);
590
														'version' =>  $wakka_config['wikini_version'], 
524
					}
591
														'requetes' => $requetes);
525
				}
592
				}
526
			}
593
			}