10-25-2000, 04:27 PM
Forumdisplay Optimization for vB 1.1.2 & 1.1.3 by rangersfan 2000
Open forumdisplay.php, and dont put in the dashes! As always backup forumdisplay.php in case something goes wrong.
Find this Code:
---------------
$threads=$DB_site->query("SELECT threadid,title,open,lastpost,replycount,postuserna me,lastposter,notes,iconid,views FROM thread WHERE forumid=$forumid AND visible=1 $datecut ORDER BY lastpost DESC LIMIT $limitlower,$perpage");
---------------
(editor note.. If you have changed this query and it no longer matches the above, the important part is to replace "iconid" with "thread.iconid", add "icon.title AS icontitle",
add "icon.iconpath", replace "title" with "thread.title AS threadtitle" and add "LEFT JOIN icon ON (icon.iconid = thread.iconid)" after "FROM thread")
Replace with:
---------------
$threads=$DB_site->query("SELECT thread.iconid, icon.title AS icontitle, icon.iconpath,threadid,thread.title AS threadtitle,
open,lastpost,replycount,postusername,lastposter,n otes,views,userindex
FROM thread
LEFT JOIN icon ON (icon.iconid = thread.iconid)
WHERE forumid=$forumid AND visible=1 $datecut
ORDER BY lastpost
DESC LIMIT $limitlower,$perpage");
----------------
Find this code:
----------------
if ($showicons==1 and $thread[iconid]!=0) {
if ($icon=$DB_site->query_first("SELECT title,iconpath FROM icon WHERE iconid=$thread[iconid]")) {
$threadicon="<img src=\"$icon[iconpath]\" alt=\"$icon[title]\" border=0>";
} else {
$threadicon=" ";
}
} else {
$threadicon=" ";
}
----------------
Replace with:
----------------
$threadicon=" ";
if ($showicons==1 and $thread[iconid]!=0)
{
$threadicon="<img src=\"$thread[iconpath]\" alt=\"$thread[icontitle]\" border=0>";
}
-----------------
version 1.1.2 and version 1.1.3beta1 and 2 Find this code:
-----------------
if ($wordwrap!=0) {
$thread[title]=eregi_replace("([^\n\r <>\"\\-]{$wordwrap})"," \\1 ",$thread[title]);
}
$threadtitle=htmlspecialchars($thread[title]);
-----------------
Replace with:
-----------------
if ($wordwrap!=0) {
$thread[threadtitle]=eregi_replace("([^\n\r <>\"\\-]{$wordwrap})"," \\1 ",$thread[threadtitle]);
}
$threadtitle=htmlspecialchars($thread[threadtitle]);
-----------------
version 1.1.3beta3 find this code:
-----------------
if ($wordwrap!=0) {
$thread[title]=dowordwrap($thread[title]);
}
$threadtitle=htmlspecialchars($thread[title]);
Replace with:
-----------------
if ($wordwrap!=0) {
$thread[title]=dowordwrap($thread[threadtitle]);
}
$threadtitle=htmlspecialchars($thread[threadtitle]);
That's it! Enjoy. This will cut your queries on forumdisplay from (Num of threads on page + 6) to 6!
Also please forgive me but I have a thing about code structure and readability.
[Edited by rangersfan on 10-26-2000 at 04:43 PM]
Open forumdisplay.php, and dont put in the dashes! As always backup forumdisplay.php in case something goes wrong.
Find this Code:
---------------
$threads=$DB_site->query("SELECT threadid,title,open,lastpost,replycount,postuserna me,lastposter,notes,iconid,views FROM thread WHERE forumid=$forumid AND visible=1 $datecut ORDER BY lastpost DESC LIMIT $limitlower,$perpage");
---------------
(editor note.. If you have changed this query and it no longer matches the above, the important part is to replace "iconid" with "thread.iconid", add "icon.title AS icontitle",
add "icon.iconpath", replace "title" with "thread.title AS threadtitle" and add "LEFT JOIN icon ON (icon.iconid = thread.iconid)" after "FROM thread")
Replace with:
---------------
$threads=$DB_site->query("SELECT thread.iconid, icon.title AS icontitle, icon.iconpath,threadid,thread.title AS threadtitle,
open,lastpost,replycount,postusername,lastposter,n otes,views,userindex
FROM thread
LEFT JOIN icon ON (icon.iconid = thread.iconid)
WHERE forumid=$forumid AND visible=1 $datecut
ORDER BY lastpost
DESC LIMIT $limitlower,$perpage");
----------------
Find this code:
----------------
if ($showicons==1 and $thread[iconid]!=0) {
if ($icon=$DB_site->query_first("SELECT title,iconpath FROM icon WHERE iconid=$thread[iconid]")) {
$threadicon="<img src=\"$icon[iconpath]\" alt=\"$icon[title]\" border=0>";
} else {
$threadicon=" ";
}
} else {
$threadicon=" ";
}
----------------
Replace with:
----------------
$threadicon=" ";
if ($showicons==1 and $thread[iconid]!=0)
{
$threadicon="<img src=\"$thread[iconpath]\" alt=\"$thread[icontitle]\" border=0>";
}
-----------------
version 1.1.2 and version 1.1.3beta1 and 2 Find this code:
-----------------
if ($wordwrap!=0) {
$thread[title]=eregi_replace("([^\n\r <>\"\\-]{$wordwrap})"," \\1 ",$thread[title]);
}
$threadtitle=htmlspecialchars($thread[title]);
-----------------
Replace with:
-----------------
if ($wordwrap!=0) {
$thread[threadtitle]=eregi_replace("([^\n\r <>\"\\-]{$wordwrap})"," \\1 ",$thread[threadtitle]);
}
$threadtitle=htmlspecialchars($thread[threadtitle]);
-----------------
version 1.1.3beta3 find this code:
-----------------
if ($wordwrap!=0) {
$thread[title]=dowordwrap($thread[title]);
}
$threadtitle=htmlspecialchars($thread[title]);
Replace with:
-----------------
if ($wordwrap!=0) {
$thread[title]=dowordwrap($thread[threadtitle]);
}
$threadtitle=htmlspecialchars($thread[threadtitle]);
That's it! Enjoy. This will cut your queries on forumdisplay from (Num of threads on page + 6) to 6!
Also please forgive me but I have a thing about code structure and readability.
[Edited by rangersfan on 10-26-2000 at 04:43 PM]