n/oldblog
Archived
1
0
Fork 0
This repository has been archived on 2024-02-13. You can view files and clone it, but cannot push or open issues or pull requests.
oldblog/modules/include/news.inc.php
2023-04-30 21:50:11 +02:00

91 lines
3.7 KiB
PHP

<?php
// renvoie la news numero NNb du fichier File sous forme de tableau
function getnews($File,$NNb)
{
if (!(file_exists("$File.csv")))
echo "Aucune nouvelle pour l'instant !<br />Attention: Fichier de nouvelles $File.csv inexistant !!<br />";
else
{
// lecture des messages
$fd = fopen("$File.csv","r");
fseek($fd,unstr($File,$NNb-1));
$data = fgetcsv($fd, 10000, ",");
$news["index"] = $data[0];
$news["categorie"] = stripcslashes($data[1]);
$news["timestamp"] = $data[2];
$news["date"] = date("d/m/Y",$data[2]);
$news["heure"] = date("H:i",$data[2]);
if ($data[3] == "")
$news["nom"] = "Anonyme";
else if ($data[4] == "")
$news["nom"] = stripcslashes($data[3]);
else
$news["nom"] = "<a href='mailto:".$data[4]."'>".stripcslashes($data[3])."</a>\n";
$news["email"] = $data[4];
$news["icone"] = $data[5];
$news["titre"] = stripcslashes($data[6]);
$news["message"] = parse_string(stripcslashes($data[7]));
$news["referencelocale"] = "?modulepage=affnews&amp;start=".$data[0];
$news["referenceabsolue"] = "http://www.tourmentine.com/?modulepage=commentnews&amp;idnews=".$data[0]."&amp;NbMaxNews=5";
}
return $news;
}
// renvoie les NbMsg dernieres news d'un fichier donné sous forme d'un tableau à deux dimensions
function getlastnews($FileName, $NbMsg)
{
if (!(file_exists("$FileName.csv")))
echo "Aucune nouvelle pour l'instant !<br>Attention: Fichier de nouvelles '$File' inexistant !!<br>";
else
{
// lecture des messages
$totmsg = gettotal($FileName);
$fd = fopen("$FileName.csv","r");
fseek($fd,unstr($FileName,($totmsg-$NbMsg)));
for($i=0;$i<$NbMsg;$i++)
{
$data = fgetcsv($fd, 10000, ",");
$tabnews[$i]["index"] = $data[0];
$tabnews[$i]["categorie"] = $data[1];
$tabnews[$i]["date"] = date("d/m/Y",$data[2]);
$tabnews[$i]["heure"] = date("H:i",$data[2]);
$tabnews[$i]["timestamp"] = $data[2];
if ($data[3] == "")
$tabnews["nom"] = "Anonyme";
else if ($data[3] == "")
$tabnews[$i]["nom"] = stripcslashes($data[3]);
else
$tabnews[$i]["nom"] = "<a href='mailto:".$data[4]."'>".stripcslashes($data[3])."</a>\n";
$tabnews[$i]["nom"] = $data[3];
$tabnews[$i]["email"] = $data[4];
$tabnews[$i]["icone"] = $data[5];
$tabnews[$i]["titre"] = stripcslashes($data[6]);
$tabnews[$i]["message"] = parse_string(stripcslashes($data[7]));
$tabnews[$i]["referencelocale"] = "?modulepage=affnews&amp;start=".$data[0];
$tabnews[$i]["referenceabsolue"] = "http://www.ifrance.com/phpinfo/index.php?modulepage=affnews&amp;File=$FileName&amp;start=".$data[0]."&amp;NbMaxNews=5";
$GoldbookFile = "$FileName.".$data[$i][0];
if (file_exists("$GoldbookFile.csv"))
$tabnews[$i]["nbcommentaires"] = countcsv($GoldbookFile);
else
$tabnews[$i]["nbcommentaires"] = 0;
}
fclose($fd);
}
unset($data);
return $tabnews;
}
?>