Dark Jim |
09-27-2002 09:41 AM |
Works with the current version of the lasttitle hack. (Not fully my work, read 2 pages earlier in this topic.) I will (try to) update it everytime PPN/Teck update the last title hack.
Run this query:
PHP Code:
ALTER TABLE forum ADD lasticon SMALLINT(5) NOT NULL AFTER lastthread;
File: FORUM/admin/functions.php
Find:
PHP Code:
$lastpost=0;
$lastthread='';
$lastposter='';
Add after that:
Find:
PHP Code:
if($getchildforum[lastthread]=='') {
$threadtitle=$DB_site->fetch_array($DB_site->query("SELECT * FROM thread WHERE forumid='$forumid' AND lastposter='$getchildforum[lastposter]' AND lastpost='$getchildforum[lastpost]'"));
$lastthread=$threadtitle[title];
} else {
$lastthread=$getchildforum[lastthread];
}
Add after that:
PHP Code:
if($getchildforum[lasticon]=='') {
$posticon=$DB_site->query_first("SELECT iconid FROM post WHERE dateline='$threadtitle[lastpost]' AND username='$threadtitle[lastposter]'");
$lasticon=$posticon[iconid];
} else {
$lasticon=$getchildforum[lasticon];
}
Find:
PHP Code:
$lastposts=$DB_site->query_first("SELECT MAX(title) as title,MAX(lastpost) AS lastpost FROM thread WHERE forumid=$forumid AND visible=1 AND open<>10");
if ($lastposts['lastpost']>$lastpost) {
$lastposts=$DB_site->query_first("
SELECT lastpost,lastposter,title
FROM thread
WHERE forumid = $forumid AND lastpost = '$lastposts[lastpost]'");
$lastpost=$lastposts['lastpost'];
$lastthread=$lastposts['title'];
$lastposter=$lastposts['lastposter'];
}
Add after that:
PHP Code:
$posticon=$DB_site->query_first("SELECT iconid FROM post WHERE dateline='$lastposts[lastpost]' AND username='$lastposts[lastposter]'");
$lasticon=$posticon['iconid'];
Find:
PHP Code:
$lastpostquery=",lastpost='$lastpost',lastthread='".addslashes($lastthread)."',lastposter='".addslashes($lastposter)."'";
Replace with:
PHP Code:
$lastpostquery=",lastpost='$lastpost',lastthread='".addslashes($lastthread)."',lasticon='$lasticon',lastposter='".addslashes($lastposter)."'";
File: FORUM/index.php
Find:
PHP Code:
if (strlen($forum['lastthread']) > $maxchars) {
$forum['lastthread'] = substr($forum['lastthread'], 0, $maxchars-2) . '...';
}
Add after that:
PHP Code:
if ($forum['lasticon']) {
$icon="<img src=\"$forum[iconpath]\" alt=\"$forum[icontitle]\" width=\"15\" height=\"15\" border=\"0\">";
} else {
$icon="";
}
Find:
PHP Code:
//Forum info
$forums=$DB_site->query('SELECT * FROM forum WHERE displayorder<>0 AND active=1 ORDER BY parentid,displayorder');
Replace with:
PHP Code:
//Forum info
$forums=$DB_site->query('SELECT forum.*,icon.title as icontitle,icon.iconpath as iconpath FROM forum
LEFT JOIN icon
ON (forum.lasticon=icon.iconid)
WHERE displayorder<>0 AND active=1 ORDER BY parentid,displayorder');
File: FORUM/forumdisplay.php
Find:
PHP Code:
if (strlen($forum['lastthread']) > $maxchars) {
$forum['lastthread'] = substr($forum['lastthread'], 0, $maxchars-2) . '...';
}
Add after that:
PHP Code:
if ($forum['lasticon']) {
$icon="<img src=\"$forum[iconpath]\" alt=\"$forum[icontitle]\" width=\"15\" height=\"15\" border=\"0\">";
} else {
$icon="";
}
Find:
PHP Code:
//Forum info
$forums=$DB_site->query('SELECT * FROM forum WHERE displayorder<>0 AND active=1 ORDER BY parentid,displayorder');
Replace with:
PHP Code:
//Forum info
$forums=$DB_site->query('SELECT forum.*,icon.title as icontitle,icon.iconpath as iconpath FROM forum
LEFT JOIN icon
ON (forum.lasticon=icon.iconid)
WHERE displayorder<>0 AND active=1 ORDER BY parentid,displayorder');
File: FORUM/newthread.php
Find:
PHP Code:
//create new thread
if ($postpoll) {
$visible = 0;
$DB_site->query("UPDATE forum SET lastthread='".addslashes(htmlspecialchars($subject))."' WHERE forumid IN ($foruminfo[parentlist])");
}
Replace with:
PHP Code:
//create new thread
if ($postpoll) {
$visible = 0;
$DB_site->query("UPDATE forum SET lastthread='".addslashes(htmlspecialchars($subject))."',lasticon=$iconid WHERE forumid IN ($foruminfo[parentlist])");
}
Find:
PHP Code:
// update forum stuff
if ($visible==1) {
$DB_site->query("UPDATE forum SET replycount=replycount+1,threadcount=threadcount+1,lastpost='".time()."',lastthread='".addslashes(htmlspecialchars($subject))."',lastposter='".addslashes($postusername)."' WHERE forumid IN ($foruminfo[parentlist])");
}
Replace with:
PHP Code:
// update forum stuff
if ($visible==1) {
$DB_site->query("UPDATE forum SET replycount=replycount+1,threadcount=threadcount+1,lastpost='".time()."',lastthread='".addslashes(htmlspecialchars($subject))."',lasticon=$iconid,lastposter='".addslashes($postusername)."' WHERE forumid IN ($foruminfo[parentlist])");
}
File: FORUM/reply.php
Find:
PHP Code:
// update forum stuff
if ($visible==1) {
$DB_site->query("UPDATE forum SET replycount=replycount+1,threadcount=threadcount+1,lastpost='".time()."',lastthread='".addslashes(htmlspecialchars($subject))."',lastposter='".addslashes($postusername)."' WHERE forumid IN ($foruminfo[parentlist])");
}
Replace with:
PHP Code:
// update forum stuff
if ($visible==1) {
$DB_site->query("UPDATE forum SET replycount=replycount+1,threadcount=threadcount+1,lastpost='".time()."',lastthread='".addslashes(htmlspecialchars($subject))."',lasticon=$iconid,lastposter='".addslashes($postusername)."' WHERE forumid IN ($foruminfo[parentlist])");
}
File: FORUM/editpost.php
Find:
PHP Code:
if ($isfirst and $title!="" and $postinfo[dateline]+$editthreadtitlelimit*60>time()) {
$DB_site->query("UPDATE thread SET title='".addslashes(htmlspecialchars($title))."', iconid=".intval($iconid)." WHERE threadid=$threadinfo[threadid]");
$lastpost=$DB_site->query_first("SELECT * FROM forum WHERE forumid=$threadinfo[forumid]");
if($lastpost['lastpost']==$threadinfo['dateline']) {
$DB_site->query("UPDATE forum SET lastthread='".addslashes(htmlspecialchars($title))."' WHERE forumid=$threadinfo[forumid]");
}
}
Replace with:
PHP Code:
if ($isfirst and $title!="" and $postinfo[dateline]+$editthreadtitlelimit*60>time()) {
$DB_site->query("UPDATE thread SET title='".addslashes(htmlspecialchars($title))."', iconid=".intval($iconid)." WHERE threadid=$threadinfo[threadid]");
$lastpost=$DB_site->query_first("SELECT * FROM forum WHERE forumid=$threadinfo[forumid]");
if($lastpost['lastpost']==$threadinfo['dateline']) {
$DB_site->query("UPDATE forum SET lastthread='".addslashes(htmlspecialchars($title))."',lasticon=$iconid WHERE forumid=$threadinfo[forumid]");
}
}
File: FORUM/postings.php
Find:
PHP Code:
$lastpost=$DB_site->query_first("SELECT * FROM forum WHERE forumid='$threadinfo[forumid]'");
if($lastpost['lastpost']==$threadinfo['dateline']) {
$DB_site->query("UPDATE forum SET lastthread='".addslashes(htmlspecialchars($title))."' WHERE forumid='$threadinfo[forumid]'");
}
Replace with:
PHP Code:
$lastpost=$DB_site->query_first("SELECT * FROM forum WHERE forumid='$threadinfo[forumid]'");
if($lastpost['lastpost']==$threadinfo['dateline']) {
$DB_site->query("UPDATE forum SET lastthread='".addslashes(htmlspecialchars($title))."' WHERE forumid='$threadinfo[forumid]'");
}
Template: forumhome_lastpostby
Find:
Code:
<a href="showthread.php?s=$session[sessionhash]&goto=lastpost&forumid=$forum[forumid]">$forum[lastthread]</a>
Change to:
Code:
$icon <a href="showthread.php?s=$session[sessionhash]&goto=lastpost&forumid=$forum[forumid]">$forum[lastthread]</a>
It works however updating the forums in the admin cp is very slow. Could someone tell me how to fix this?
|