je te mets tout le script du fichier recuperation-posts.php :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" >
<head>
<title>Recupération des messages</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<div style="text-align:center;">
<img id="chargement" src="chargement.gif" alt="Recherche en cours..." title="Recherche en cours..." \><br /> <!-- Animation de chargement -->
<span id="progression">0</span> messages ont été trouvés. <!-- Nombre de forums trouvés -->
<div id="fin"><br /></div></div> <!-- Affichage de la fin -->
<?php
/* License: GNU/GPL
Auteur: Roromis*/
ini_set('display_errors', 0);
set_time_limit(0);
include("config.php"); //Fichier de configuration généré par le fichier install.php
include("include.php"); //Fichier permettant de se connecter au forum.
set_time_limit(0);
$NombreDePages = 0;
$MessagesParPage = 0;
$cookies = connectionForum(FORUM_URL, FORUM_USER, FORUM_PASS);
mysql_connect(BDD_HOST, BDD_USER, BDD_PASS);
mysql_select_db(BDD_NAME)or die(mysql_error());
mysql_query("SET NAMES 'utf8'");
mysql_query("SET CHARACTER SET utf8");
$sql = "CREATE TABLE if not exists forumactif_posts (
id bigint(4) unsigned NOT NULL auto_increment,
contenu text,
topic int,
date int,
auteur text,
PRIMARY KEY (id)
) CHARACTER SET utf8";
/********************************************************************
************** forumactif_posts: contient les messages. ************
* id: id du message. *
* contenu: texte du message. *
* topic: topic auquel appartient le message. *
* date: Date (timestamp) *
* auteur: auteur du message *
********************************************************************/
mysql_query($sql)or die('Erreur: ' . mysql_error() . '<br />Requête: "' . $sql . '"');
$sql = "TRUNCATE TABLE forumactif_posts"; //On vide la table avant tout
mysql_query($sql)or die('Erreur: ' . mysql_error() . '<br />Requête: "' . $sql .'"');
$total = 0;
//calcul des dates hier et aujourd'hui
$val_aujourdhui = getdate();
$val_hier = getdate(time() - (24*60*60) );
$jours = array("Dim","Lun","Mar","Mer","Jeu","Ven","Sam");
$mois = array("","Jan","Fév","Mar","Avr","Mai","Juin","Juil","Aoû","Sep","Oct","Nov","Dec");
$aujourdhui = $jours[$val_aujourdhui["wday"]]." ".$val_aujourdhui["mday"]." ".$mois[$val_aujourdhui["mon"]]." ".$val_aujourdhui["year"]." -";
$hier = $jours[$val_hier["wday"]]." ".$val_hier["mday"]." ".$mois[$val_hier["mon"]]." ".$val_hier["year"]." -";
$months = array(
'Jan' => 1,
'Fév' => 2,
'Mar' => 3,
'Avr' => 4,
'Mai' => 5,
'Juin' => 6,
'Juil' => 7,
'Aoû' => 8,
'Sep' => 9,
'Oct' => 10,
'Nov' => 11,
'Déc' => 12
);
$sql = "SELECT * FROM forumactif_topics"; //cherche dans la BDD les forums pas encore fouillés
$data = mysql_query($sql)or die('Erreur: ' . mysql_error() . '<br />Requête: "' . $sql . '"');
while ($topics = mysql_fetch_array($data))
{
for ($j = 0; $j <= $NombreDePages; $j++)
{
$NumPage = $j * $MessagesParPage;
$lien = FORUM_URL . "/a-t" . $topics['id'] . "-" . $NumPage . ".htm";
$CodeOriginal = recupererContenu(FORUM_URL, $lien, FORUM_USER, FORUM_PASS, $cookies, true);
if ($j == '0')
{
$NombreDePages = 0;
preg_match_all('#function do_pagination_start\(\)[^\}]*start = \(start > \d+\) \? (\d+) : start;[^\}]*start = \(start - 1\) \* (\d+);[^\}]*\}#s', $CodeOriginal, $Page);
$MessagesParPage = $Page[2][1];
$NombreDePages = $Page[1][1];
}
$CodeFinal = preg_replace('#<\!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">.*<th nowrap="nowrap" width="150">Derniers Messages</th></tr>#s','<table>', $CodeOriginal);
preg_match_all('#<tr class="post"><td class="(row1|row2)" valign="top" width="\d+"><span class="name"><a name="(\d+)"></a><strong>(<a href="/profile\.forum\?mode=viewprofile&u=\d+">|)(<span style="color:\#.{6}"><strong>|)(.+)(</strong></span>|)</a></strong>#U', $CodeFinal, $Messages);
preg_match_all('#<img src="[^">]*" alt="" border="0" />([^<]*)</span></td><td( align="right"|) valign="top" nowrap="nowrap" class="post-options">#U', $CodeFinal, $Messages_suite);
for ($i = 0; isset($Messages[0][$i])==true; $i++) //insere les messages dans la BDD
{
$total++;
$Auteur = mysql_real_escape_string(utf8_encode(html_entity_decode($Messages[5][$i])));
$Date = str_replace(array("Aujourd'hui à","Hier à"), array($aujourdhui,$hier), utf8_encode(html_entity_decode($Messages_suite[1][$i])));
preg_match('#.{3} (\d{1,2}) (.{3,4}) (\d{4}) - (\d{1,2}):(\d{1,2})#', $Date, $arrayDate);
$timestamp = mktime($arrayDate[4], $arrayDate[5], '0', $months[$arrayDate[2]], $arrayDate[1], $arrayDate[3]);
$sql = "INSERT INTO forumactif_posts VALUES('" . $Messages[2][$i] . "', '', '" . $topics['id'] . "', '" . $timestamp . "', '" . $Auteur . "')";
mysql_query($sql)or die('Erreur: ' . mysql_error() . '<br />Requête: "' . $sql . '"');
$total = progression($total);
}
}
}
fin('Traitement des timestamps terminée.<br />La recherche des messages est terminée.<br />Vous pouvez maintenant <a href="contenu-posts.php">rechercher le contenu des messages</a>.');
?>
</body>
</html>