Firefox PHP

"last post" feature in phorum5 ... implement it in phorum 3?

Posted by Don 
Don
"last post" feature in phorum5 ... implement it in phorum 3?
August 11, 2003 01:05PM
i find this "last post" feature really useful as my board doesn't get a lot of traffic and people should see who the last poster is ...
Re: "last post" feature in phorum5 ... implement it in phorum 3?
January 01, 2004 06:21PM
Sorry for the French language, this script works on Phorum 3.2.1 and upper
<?php

// ------------------------------------------------------------------------- //
// Show the n last posts in Phorum. //
// ------------------------------------------------------------------------- //
// Auteur: J-Pierre DEZELUS //
// Email: jpdezelus@phpinfo.net //
// Web: [www.phpinfo.net] //
// ------------------------------------------------------------------------- //
//you may secure the following lines adding an include file
$cfgHote = "localhost";//
$cfgUser = "";//username of the DB
$cfgPass = "";//password
$cfgBase = "";//name of the DB

$cfgTable = "";// name of the table you want to show the last posts (add a request in forums tables + while if you want to search in all the tables)
$cfgRep = "";
$cfgRead = "read.php";

$nbMsgForum = 10; // Number of last post to show

// connexion à la base
mysql_connect($cfgHote, $cfgUser, $cfgPass);

echo "The ".$nbMsgForum." last posts - ";

// Nb msg today
$sql = "SELECT COUNT(id) ";
$sql .= "FROM ".$cfgTable." ";
$sql .= "WHERE approved = 'Y' AND datestamp LIKE '".date("Y-m-d")."%'";

$resultat = mysql_db_query($cfgBase, $sql);
$enr = mysql_fetch_array($resultat);

echo "<B>".($nb = $enr[0])."</B> message".($nb > 1 ? "s" : "");
echo " today";

// Nb msg yesterday
$date = date("d/m/Y");
$elts = explode("/", $date);
$hier = mktime(0, 0, 0, $elts[1], $elts[0]-1, $elts[2]);

$sql = "SELECT COUNT(id) ";
$sql .= "FROM ".$cfgTable." ";
$sql .= "WHERE approved = 'Y' AND datestamp LIKE '".date("Y-m-d", $hier)."%'";

$resultat = mysql_db_query($cfgBase, $sql);
$enr = mysql_fetch_array($resultat);
echo " [<B>".$enr[0]."</B> yesterday]";

echo "<BR><BR>\n";

// Affichage des fils de discussion et du nombre de réponses
$sql = "SELECT id,subject,datestamp ";
$sql .= "FROM ".$cfgTable." ";
$sql .= "WHERE approved = 'Y' AND parent = 0 ";
$sql .= "ORDER BY id DESC LIMIT 0,".$nbMsgForum;

$resultat = mysql_db_query($cfgBase, $sql);

while ($message = mysql_fetch_array($resultat)) {

$sql2 = "SELECT count(*) ";
$sql2 .= "FROM ".$cfgTable." ";
$sql2 .= "WHERE approved = 'Y' AND thread=".$message[0]." AND parent <> 0";

$resultat2 = mysql_db_query($cfgBase, $sql2);
$nbRep = mysql_fetch_array($resultat2);

echo " - ";
$date = substr($message[2], 8, 2) . "/";
$date .= substr($message[2], 5, 2) . " ";
$date .= substr($message[2], 11, 5);

echo "[<B>".$date."</B>] ";
if (strlen($message[1]) > 40)
$msg = substr($message[1], 0, 40)." ...";
else
$msg = $message[1];

$lien = $cfgRep.$cfgRead."?f=1&loc=0&i=".$message[0]."&t=".$message[0];
echo "<A HREF='".$lien."' TARGET='_self'>".$msg."</A>";

// nb de réponses
if ($nbRep[0] > 0) echo " [".$nbRep[0]."]";

echo "<BR>\n";
}

?>

Sorry, you do not have permission to post/reply in this forum.