";
function write2csv($csvfile, $data)
{
$fp = fopen ($csvfile,"a");
$csvstring = "\"".$data["idmessage"].
"\",\"".$data["date"].
"\",\"".$data["heure"].
"\",\"".$data["authorname"].
"\",\"".$data["authoremail"].
"\",\"".$data["titlemessage"].
"\",\"".$data["textmessage"]."\"\n";
fwrite ($fp, $csvstring);
fclose ($fp);
}
function form($rep, $to,$numrep, $idnews, $File)
{
global $lang;
global $name;
global $email_adress;
global $subject;
global $help;
global $closedpost;
global $view, $clear, $write, $hide_help, $confirm_post_message, $previewed_message, $posted_message, $reply;
if ($_POST["preview"] == "Voir" || $_POST["preview"] == "Preview")
{
$preview = $_POST["preview"];
$VName = $_POST["VName"];
$VEmail = $_POST["VEmail"];
$VSubject = $_POST["VSubject"];
$VText = $_POST["VText"];
}
else $VSubject = $rep;
$VSubject = str_replace("'","'",$VSubject);
$VName = str_replace("'","'",$VName);
// affichage du formulaire
echo "
";
// affichage d'un message à prévisualister
if (isset($preview))
{
if ($VName == "")
$VName = "Anonyme";
if ($VEmail != "")
$VEmail = "$VName";
else
$VEmail = $VName;
//echo "
";
echo "
";
echo "
";
echo "\n";
}
echo "
\n";
}
// récupération du numéro du dernier message
if (file_exists("$forumfile"))
{
$fp = fopen ($forumfile,"r");
while ($data[$index++] = fgetcsv ($fp, 1000, ","));
fclose ($fp);
}
else
{
$index = 0;
}
// Écriture effective du message
if (isset($Ecrire) && !isset($piejacon) && ($Ecrire == "Ecrire" || $Ecrire == "Write"))
{
if ($VSubject == "" || $VText == "" || $NumRep == "")
echo $please_fill_fields."
";
else
{
$t["idmessage"] = $NumRep;
$t["titlemessage"] = $VSubject;
$t["textmessage"] = htmlentities(parse_string($VText,"yes"));
$VSubject = str_replace("'","'",$VSubject);
$VName = str_replace("'","'",$VName);
$t["authorname"] = $VName;
$t["authoremail"] = $VEmail;
if ($lang == "fr")
{
$t["date"] = strftime("%d/%m/%Y", time());
$t["heure"] = date("H:i");
}
else
{
$t["date"] = strftime("%m/%d/%Y", time());
$t["heure"] = strftime("%I:%M %p", time());
}
write2csv($forumfile,$t);
//mail("n@tourmentine.com","[Tourmentine] post forum ".$forumfile, "titre:".$VSubject."\nauteur: ".$VName." <".$VEmail.">");
mailalert("n@tourmentine.com",("post forum ".$forumfile), $VName, $VEmail, $VSubject, $VText);
sendviajabber("n@tourmentine.com","post forum $forumfile $VName <$VEmail> $VSubject: $VText");
// met à jour le cache
touch("modules/news");
echo "$message_sent
";
}
echo "$back";
}
else
{
// affichage des messages
for ($i=0; $i < $index; $i++)
{
$thread[$i]["idmessage"] = $data[$i][0];
$thread[$i]["date"] = $data[$i][1];
$thread[$i]["heure"] = $data[$i][2];
$thread[$i]["auteur"] = $data[$i][3];
$thread[$i]["mail"] = $data[$i][4];
$thread[$i]["titlemessage"] = $data[$i][5];
$thread[$i]["textmessage"] = $data[$i][6];
}
if ($thread[1]["idmessage"] != "")
sort($thread);
$nbthreads = substr($thread[$i-1]["idmessage"],2,2);
if (isset($indexmsg) && $indexmsg == 0)
{
if ($nbthreads < 11)
$NumRep = "id0".($nbthreads+1);
else
$NumRep = "id".($nbthreads+1);
//form("", "?modulepage=commentnews&idnews=$idnews&indexmsg=$indexmsg", $NumRep, $idnews, $File);
form("", "comment.$idnews.$indexmsg.html#$indexmsg", $NumRep, $idnews, $File, "yes");
echo "\n";
//echo "Annuler \n";
echo "$cancel \n";
}
else
//echo "[Poster un nouveau message]
\n";
if ($closedpost == false)
echo "\n[$post_a_new_message]
\n";
// entête d'un message (auteur, @email, titre, date, etc.)
for ($i=1; $i < $index; $i++)
{
if ($thread[$i]["idmessage"] != "")
{
if (strlen($thread[$i]["idmessage"]) >= $oldstrength)
echo str_repeat(" ",strlen($thread[$i]["idmessage"])-2);
if ($thread[$i]["auteur"] == "")
if ($lang == "fr")
$thread[$i]["auteur"] = "Anonyme";
else
$thread[$i]["auteur"] = "Anonymous";
if ($thread[$i]["mail"] != "")
$thread[$i]["auteur"] = "".$thread[$i]["auteur"]."";
// formatage du numéro de commentaire (nombre à 4 chiffres)
$indexmsglength = strlen($i);
if ($indexmsglength == 1 )
$izero = "000".$i;
if ($indexmsglength == 2 )
$izero = "00".$i;
if ($indexmsglengh == 3 )
$izero = "0".$i;
//echo "\n[".stripcslashes($thread[$i]["titlemessage"])."] posté le ".$thread[$i]["date"]." à ".$thread[$i]["heure"]." par ".stripcslashes($thread[$i]["auteur"])." \n";
if ($lang == "fr")
echo "\n\n \n";
else
echo "\n\n \n";
echo str_repeat(" ",strlen($thread[$i]["idmessage"]));
echo " \n";
//echo " |
";
$oldlength = strlen($thread[$i]["idmessage"]);
}
// le numéro de message corresponds à celui demandé: on affiche le formulaire
if (isset($indexmsg) && $indexmsg == $i)
{
$long = strlen($thread[$i]["idmessage"]);
//$cpt = $i+1;
while (strlen($thread[$cpt]["idmessage"]) == $long+2)
if (substr($thread[$cpt]["idmessage"], 0, $long) == $thread[$i]["idmessage"])
$cpt++;
$NbReponses = ($cpt);
if ($NbReponses < 10)
$NbReponses = "0".$NbReponses;
if ($NbReponses == 0)
$NumRep = $thread[$i]["idmessage"]."01";
else
$NumRep = $thread[$i]["idmessage"].$NbReponses;
$reponse = "RE:".$thread[$i]["titlemessage"];
form($reponse, "comment.$idnews.$indexmsg.html#$indexmsg", $NumRep, $idnews, $File);
echo "";
}
}
}
?>
|