Cicada
08-17-2002, 11:14 AM
show "previously active posts" from a v bulletin messageboard...is that possible?
i suppose it would have to access the mySQL database and report back with the currently active posts...
id like to to print out something like
"Hello!" last post post by SomeGuy at 10:45pm
and maybe a script to where it can print out the first few lines of a post..like forums where only admins and such can post...
and it would print out the subject and the first few lines of a post and at the end something like "Read more.."
so it would print out something like the main page of: http://www.markeedragon.com
where it prints out the most previous posts in teh news forum with a date and timestamp and a "read more... | Comments " link.
any help with this is appreciated.
Spookster
08-17-2002, 04:59 PM
For something as involved as that you are probably better off searching around vbulletin's help forums. They have a forum specifically for customizations/hacks. Somebody else may have already posted a hack similar to this which you could use:
http://www.vbulletin.org/forum/index.php
Cicada
08-19-2002, 07:42 AM
ok, i decided to write the code myself and here it is for anyone looking for somethign similar. it's still got some bugs, in it, as you can see at:
www.stink-blossom.net/latestposts.php
it doesn;t correctly print out the poster, so if someone could take a look at like 60, and help i';d appreciate it:
<?php
/////////////// GENERAL SETTINGS ///////////////
define("SQL_HOST", "localhost"); // Name or IP of MySQL server
define("SQL_USER", "username"); // MySQL user name
define("SQL_PWD", "password"); // MySQL password
define("SQL_DB", "dbname"); // Name of database
$forumhome = "http://www.yourhost.com/forums";
//////////////// Change above settings to match those of yours /////////////////////////////
define("SQL_TABLE", "post"); // Name of table
define("SQL_SHOW_ERRORS", "1"); // Should the script produce MySQL error messages or not
$sql_result = "";
$sql_result2 = "";
$sql_numrows = 0;
if (!($sql_id = @mysql_connect(SQL_HOST, SQL_USER, SQL_PWD))){if (SQL_SHOW_ERRORS <> 0) phphitsShowErrorMsg("mysql_connect", $sql_id);}
if (!@mysql_select_db(SQL_DB, $sql_id)){if (SQL_SHOW_ERRORS <> 0) phphitsShowErrorMsg("mysql_select_db", $sql_id);}
if (!($sql_id2 = @mysql_connect(SQL_HOST, SQL_USER, SQL_PWD))){if (SQL_SHOW_ERRORS <> 0) phphitsShowErrorMsg("mysql_connect", $sql_id2);}
if (!@mysql_select_db(SQL_DB, $sql_id2)){if (SQL_SHOW_ERRORS <> 0) phphitsShowErrorMsg("mysql_select_db", $sql_id2);}
///////////////////////// FORUM LAST POSTS //////////////////////////////////////////////////////////////
$sql_query = "SELECT * FROM `post` ORDER BY `dateline` DESC LIMIT 20";
if (!($sql_res = @mysql_query($sql_query, $sql_id))){if (SQL_SHOW_ERRORS <> 0) phphitsShowErrorMsg("mysql_select", $sql_id);}
/////////////// PRINT //////////////////////
print "<table border=0 cellpadding=0 cellspacing=0>";
$wline = 0;
$count = 0;
$posts = 0;
while ($sql_row = @mysql_fetch_array ($sql_res))
{
$go = 0;
for ($i = 0;;$i++) {
if ($i >= $count) {
break;
}
if ($sql_row["threadid"] == $old[$i]) {$go = 1;}
}
$old[$count] = $sql_row["threadid"];
$count++;
if ($go == 0) {
$posts++;
if ($posts >= 9) {break;}
if ($sql_row["title"] != "") {
$posttitle = $sql_row["title"];
} else {
$sql_query = "SELECT * FROM `post` WHERE (threadid ='" . $sql_row["threadid"] . "')";
if (!($sql_res2 = @mysql_query($sql_query, $sql_id))){if (SQL_SHOW_ERRORS <> 0) phphitsShowErrorMsg("mysql_select", $sql_id);}
while ($sql_row2 = @mysql_fetch_array ($sql_res2)){$posttitle = "Reply to : " . $sql_row2["title"];}
}
print "<tr><td><font face=arial size=1><p align=left>";
print "<a href=$forumhome/showthread.php?threadid=" . $sql_row["threadid"] . "&goto=newpost target=_top>:. ";
print "\"" . $posttitle . "\"</a> - ";
$wdate = date("m/d", $sql_row["dateline"]);
print $wdate . " - " . $sql_row["poster"] . "</p></td></tr>";
}
}
print "</table>";
@mysql_close($sql_id);
@mysql_close($sql_id2);
// =====================================================================================
function phphitsShowErrorMsg($err, $id)
{
switch ($err)
{
case "mysql_connect":
$msg[1] = "Couldn't connect to MySQL server";
$msg[3] = "Check if the name of the MySQL server, user name & password specified in your script are correct!";
break;
case "mysql_select_db":
$msg[1] = "Couldn't activate MySQL database";
$msg[3] = "Check if the name of the MySQL database specified in your script is correct!";
break;
case "mysql_select":
$msg[1] = "Couldn't query MySQL database";
$msg[3] = "Check if the name of the MySQL database specified in your script is correct!";
break;
case "mysql_insert":
$msg[1] = "Couldn't insert new row into table";
$msg[3] = "Check if the name of the MySQL table in your script is correct!";
break;
case "mysql_drop":
$msg[1] = "Couldn't delete table.";
$msg[3] = "Check if the name of the MySQL table in your script is correct!";
break;
default:
$msg[1] = "MySQL error";
$msg[3] = "Check if all MySQL settings specified in your script are correct!";
break;
}
if (@mysql_error($id) <> "")
{
$msg[2] = @mysql_error($id);
}
else
{
$msg[2] = "Unknown";
}
die("<hr><font color=\"#ff0000\"><b>" . $msg[1] . "</b><br>Reason: " . $msg[2] . "<p></p>" . $msg[3] . "<br><br>Contact us about this error</font><hr><br>");
}
// ====== CONT ===============================================================
?>
line 60 is:
print $wdate . " - " . $sql_row["poster"] . "</p></td></tr>";
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.