paulmjno |
10-11-2004 05:12 PM |
Thank you very much for this. :)
I required a simple list of recent postings rather than to display all that information. So, I changed all the HTML in the hack to suit my needs, maybe someone else will also find this useful?:
PHP Code:
<?
//...........Last X Posts v1.0.5...........\\
//......by Kevin (kevin@tubescan.com)......\\
// For vBulletin version 2 (betas 3, 4, 5, RC1, RC2, RC3)
// (c) 2001 Jelsoft Enterprises, Ltd.
// vBulletin.com thread: http://www.vbulletin.com/forum/showthread.php?threadid=12324
// let's get connected
require("last10config.php");
require("$path/config.php");
$db=mysql_connect($servername,$dbusername,$dbpassword) or die("Can't open connection to MySQL");
mysql_select_db($dbname) or die("Can't select database");
// the base WHERE statement
$wheresql = "WHERE thread.lastposter=user.username AND thread.open!='10'";
// we can't have both the last 24 hours *and* the last 7 days, so error out if needed
if ($last24 == "1" && $last7 == "1") {
print("Error: \$last24 and \$last7 are both set to 1. Please change one of them to 0.");
exit;
}
// otherwise we're gonna find out which one it is
// last 24
if ($last24 == "1") {
$time = time()-86400;
$wheresql .= " AND thread.lastpost>'$time'";
}
// last 7
if ($last7 == "1") {
$time = time()-604800;
$wheresql .= " AND thread.lastpost>'$time'";
}
// are we trying to exclude *and* include forums? if so, error out
if ($excludeforums != "" && $includeforums != "") {
print("Error: \$includeforums and \$excludeforums are both set with numbers. Please remove the numbers from <b>one</b> of these two to proceed.");
exit;
}
// otherwise figure out which one we're using
// include forums
if ($includeforums == "" or $includeforums <= "0") {
$quarter = "no";
} else {
$incfid = explode(",",$includeforums); $i = 0; $a = count($incfid);
if ($a > 1) {
$wheresql .= " AND (thread.forumid='$incfid[0]'";
++$i;
while ($i < $a) {
$wheresql .= " OR thread.forumid='$incfid[$i]'"; ++$i;
}
$wheresql .= ")";
} else {
$wheresql .= " AND thread.forumid='$incfid[$i]'";
}
}
// or exclude forums
if ($excludeforums == "" or $excludeforums <= "0") {
$quarter = "no";
} else {
$excfid = explode(",",$excludeforums); $i = 0; $a = count($excfid);
while ($i < $a) {
$wheresql .= " AND thread.forumid!='$excfid[$i]'"; ++$i;
}
}
if ($showforumtitle == "1") {
$ftitle = ",forum";
$fsel = ",forum.title AS ftitle";
$wheresql .= " AND thread.forumid=forum.forumid";
}
// ooh a query!
$query = "SELECT thread.lastpost,thread.title,thread.lastposter,thread.replycount,thread.views,user.userid,thread.threadid,thread.forumid$fsel,thread.iconid FROM thread,user$ftitle $wheresql ORDER BY thread.$ob $obdir LIMIT $maxthreads";
// let's get the info
$tr = mysql_query($query) or die("MySQL reported this error while trying to retreive the info: ".mysql_error());
$dtf = mysql_query("SELECT value FROM setting WHERE varname='dateformat' OR varname='timeformat' OR varname='timeoffset' ORDER BY varname");
$df = mysql_result($dtf,0,0);
$tf = mysql_result($dtf,1,0);
$tof = mysql_result($dtf,2,0);
if ($showdate == "1") {
$fdt = "$df $tf";
} else {
$fdt = "$tf";
}
$cols = 1;
// let's display the info
while ($threads = mysql_fetch_array($tr)) {
// are we going to show the message too?
if ($showmessages == "1") {
$query0 = "SELECT pagetext,postid,dateline,iconid FROM post WHERE threadid='$threads[threadid]' ORDER BY dateline DESC LIMIT 1";
$lastpost = mysql_query($query0) or die("MySQL reported this error while trying to retrieve the last post info: ".mysql_error());
while ($lastpost1 = mysql_fetch_array($lastpost)) {
$lastpostshort = $lastpost1[pagetext];
$postii = $lastpost1[iconid];
}
if (strlen($lastpostshort) > $lplen) {
$lastpostshort = substr($lastpostshort,0,$lplen);
$lastpostshort .= "...";
}
$smilies = mysql_query("SELECT smilietext,smiliepath FROM smilie");
while ($smiles = mysql_fetch_array($smilies)) {
$lastpostshort = str_replace($smiles[smilietext],"<img src=\"".$url."/".$smiles[smiliepath]."\" border=0>",$lastpostshort);
}
if ($nb == "1") {
$lastpostshort = nl2br($lastpostshort);
}
$lastpostshort = str_replace("[i]","<i>",$lastpostshort);
$lastpostshort = str_replace("[/i]","</i>",$lastpostshort);
$lastpostshort = str_replace("[u]","<u>",$lastpostshort);
$lastpostshort = str_replace("[/u]","</u>",$lastpostshort);
$lastpostshort = str_replace("[b]","<b>",$lastpostshort);
$lastpostshort = str_replace("[/b]","</b>",$lastpostshort);
$lastpostshort = str_replace("[quote]","<br>quote:<br><hr> ",$lastpostshort);
$lastpostshort = str_replace("[/quote]"," <hr><br>\n",$lastpostshort);
$lastpostshort = str_replace("[I]","<i>",$lastpostshort);
$lastpostshort = str_replace("[/I]","</i>",$lastpostshort);
$lastpostshort = str_replace("[U]","<u>",$lastpostshort);
$lastpostshort = str_replace("[/U]","</u>",$lastpostshort);
$lastpostshort = str_replace("[B]","<b>",$lastpostshort);
$lastpostshort = str_replace("[/B]","</b>",$lastpostshort);
$lastpostshort = str_replace("[QUOTE]","<br>quote:<br><hr> ",$lastpostshort);
$lastpostshort = str_replace("[/QUOTE]"," <hr><br>\n",$lastpostshort);
$lastpostshort = str_replace("[CODE]","<br>code:<br><hr> ",$lastpostshort);
$lastpostshort = str_replace("[/CODE]"," <hr><br>\n",$lastpostshort);
$lastpostshort = str_replace("[code]","<br>code:<br><hr> ",$lastpostshort);
$lastpostshort = str_replace("[/code]"," <hr><br>\n",$lastpostshort);
$lastpostshort = str_replace("[img]https://vborg.vbsupport.ru/[/img]","",$lastpostshort);
$lastpostshort = str_replace("[img]https://vborg.vbsupport.ru/[/img]","",$lastpostshort);
$lastpostshort = str_replace("[url]","",$lastpostshort);
$lastpostshort = str_replace("[/url]","",$lastpostshort);
$lastpostshort = str_replace("[URL]","",$lastpostshort);
$lastpostshort = str_replace("[/URL]","",$lastpostshort);
}
// thanks to kier for this idea to do the alternating row colors
if (($counter++ % 2) != 0) {
$bc=$bc1;
} else {
$bc=$bc2;
}
// if the title is more than $len characters, we need to cut it off and add ... to the end
if (strlen($threads[title]) > $len) {
$title = substr($threads[title],0,$len);
$title .= "...";
} else {
$title = $threads[title];
}
// convert the date to a format readable by non-unix geeks :)
$fd = date($fdt,$threads[lastpost]);
echo("<li>");
if ($showforumtitle == "1") {
echo("<a href=\"$url/forumdisplay.php?forumid=$threads[forumid]\">$threads[ftitle]</a>: ");
}
echo("<a href=\"$url/showthread.php?threadid=$threads[threadid]&goto=newpost\" title=\"$threads[title]\">$title</a></li>\n");
// last poster column?
if ($lastposter == "1") {
echo("<li><a href=\"$url/member.php?action=getinfo&userid=$threads[userid]\">$threads[lastposter]</a></li>\n");
++$cols;
}
// replies column?
if ($replies == "1") {
echo("<li>$threads[replycount]</li>\n");
++$cols;
}
}
?>
When including the file, be sure to wrap the include in <ul>'s.
|