Display Last 5 Phorum Posts -script
Posted by dagon
Re: Display Last 5 Phorum Posts -script June 29, 2008 08:59AM |
Registered: 19 years ago Posts: 130 |
March 06, 2009 01:29AM |
Registered: 19 years ago Posts: 666 |
I know this may be considered outdated, but I'm using a modification of this script outside of my board, and it's working fine except for date. Any ideas? Here's the code:
-------------------------------------------
"Everything we see or seem, is but a dream within a dream." -Edgar Allan Poe
Language: PHP$number = 5; // number of messages to show. $count = 20; //words per message to show @$con = mysql_connect(';localhost';,';username';,';password';) or die ("cannot connect to MySQL"); $select_db = mysql_select_db(';username_db';,$con); $result = mysql_query("SELECT * FROM phorum_messages m, phorum_forums f where m.forum_id = f.forum_id and f.forum_id = 1 and m.status > 0 order by m.datestamp desc limit $number") or die("Failed Query of ".$result. mysql_error()); while($row = mysql_fetch_array($result)) { unset($ellipsis); //remove this line to if your not using the ellipsis $row[';body';] = preg_replace( "|</*[a-z][^>]*>|i", "", $row[';body';]); $row[';body';] = preg_replace( "|\[/*[a-z][^\]]*\]|i", "", $row[';body';]); $words = split(';[ ]+';, $row[';body';]); if (sizeof($words) > $count) { $words = array_slice($words, 0, $count); $ellipsis = " ..."; //to indicate message body truncation remove if unwanted } $row[';body';] = implode($words, '; ';); $row[';body';] = trim($row[';body';]); $row[';body';] = nl2br($row[';body';]); $row[';body';] = str_replace("<br />"," ",$row[';body';]); $row[';body';] .= $ellipsis; //remove this line to if your not using the ellipsis $row[';datestamp';] = strftime($PHORUM["short_date"], $row["datestamp"]); echo "<tr>"; echo "<td>Subject: <a href=\"./boards/read.php?/read.php?".$row[';forum_id';].",".$row[';thread';].",".$row[';message_id';]."#".$row[';message_id';]."\">" .$row[';subject';]. "</a><br />\n"; echo "Author: ". $row[';author';]. "<br />\n"; echo "Date: ". $row[';datestamp';]. "<br />\n"; echo "<small>".$row[';body';]. "</small></td>\n"; echo "</tr>"; }
-------------------------------------------
"Everything we see or seem, is but a dream within a dream." -Edgar Allan Poe
Re: Display Last 5 Phorum Posts -script April 03, 2009 10:34AM |
Registered: 14 years ago Posts: 3 |
I'm using this script to show the latest posts on a page. But how do I do to not show posts from 2 specific folders/forums?
<?
header('Refresh: 240');
include_once("./common.php"); //change to match your file system
$host = $PHORUM[DBCONFIG][server];
$dbuser = $PHORUM[DBCONFIG][user];
$dbpass = $PHORUM[DBCONFIG][password];
$dbname = $PHORUM[DBCONFIG][name];
$table = $PHORUM[message_table];
$number = 1; // number of messages to show.
$count = 7; //words per message to show
@$con=mysql_connect($host,$dbuser,$dbpass) or die ("cannot connect to MySQL");
$select_db = mysql_select_db($dbname,$con);
$result = mysql_query("select * from $table order by datestamp desc limit $number") or die("Failed Query of " . $result. mysql_error());
while($row = mysql_fetch_array($result)){
unset($ellipsis);
$row[datestamp] = strftime($PHORUM["short_date"], $row["datestamp"]);
$words = split('[ ]+', $row[body]);
if (sizeof($words) > $count) {
$words = array_slice($words, 0, $count);
$ellipsis = "..."; //to indicate message body truncation remove if unwanted
}
$row[body] = implode($words, ' ');
$row[body]=trim($row[body]);
$row[body]=nl2br($row[body]);
$row[body] .= $ellipsis;
echo " <FONT SIZE=1 Face=verdana> <td><B><!a href=\"".$PHORUM[SETTINGS][http_path]."/phorum/read.php?".$row[forum_id].",".$row[thread].",".$row[message_id]."#".$row[message_id]."\">" .$row[subject]."</B></a></td>";
echo " <td>". $row[body]. "</td>";
}
?>
</tbody>
</table>
Edited 1 time(s). Last edit at 04/03/2009 10:35AM by CHR.
<?
header('Refresh: 240');
include_once("./common.php"); //change to match your file system
$host = $PHORUM[DBCONFIG][server];
$dbuser = $PHORUM[DBCONFIG][user];
$dbpass = $PHORUM[DBCONFIG][password];
$dbname = $PHORUM[DBCONFIG][name];
$table = $PHORUM[message_table];
$number = 1; // number of messages to show.
$count = 7; //words per message to show
@$con=mysql_connect($host,$dbuser,$dbpass) or die ("cannot connect to MySQL");
$select_db = mysql_select_db($dbname,$con);
$result = mysql_query("select * from $table order by datestamp desc limit $number") or die("Failed Query of " . $result. mysql_error());
while($row = mysql_fetch_array($result)){
unset($ellipsis);
$row[datestamp] = strftime($PHORUM["short_date"], $row["datestamp"]);
$words = split('[ ]+', $row[body]);
if (sizeof($words) > $count) {
$words = array_slice($words, 0, $count);
$ellipsis = "..."; //to indicate message body truncation remove if unwanted
}
$row[body] = implode($words, ' ');
$row[body]=trim($row[body]);
$row[body]=nl2br($row[body]);
$row[body] .= $ellipsis;
echo " <FONT SIZE=1 Face=verdana> <td><B><!a href=\"".$PHORUM[SETTINGS][http_path]."/phorum/read.php?".$row[forum_id].",".$row[thread].",".$row[message_id]."#".$row[message_id]."\">" .$row[subject]."</B></a></td>";
echo " <td>". $row[body]. "</td>";
}
?>
</tbody>
</table>
Edited 1 time(s). Last edit at 04/03/2009 10:35AM by CHR.
Sorry, only registered users may post in this forum.