PDA

View Full Version : Search Thread


Erwin
10-28-2002, 10:00 PM
Search Thread - by Erwin Loh
-----------------------------

This hack will add a "Search This Thread" search box at the bottom of threads (similar to the "Search This Forum" search box at the bottom of Forum Display).

Should be useful for loooooooooooooong threads, especially for a forum like this one. ;)


Demo
-------

This hack is installed here at vB.org - just use the Search This Thread box at the bottom right hand corner of this page. :)


Features
-----------

1. Only posts from the thread will be searched.
2. Uses that standard searchindex table.
3. Uses the same vB search algorithms.
4. This will add NO extra queries to your forum.
5. Uses the standard search and forum permissions set by you.


Installation
------------

1. Running 1 database query
2. Making 2 changes to showthread.php
3. Making 6 changes to search.php
4. Making 1 change to template "showthread"
5. Adding a new template "showthread_searchthread"

Enjoy!

Please click install if you want updates to this hack!

Dr. Erwin Loh

I've updated the installation text file to make things clearer, and made the search box visible to guests as well. :)

Erwin
10-29-2002, 12:32 AM
Demo
-------

This hack is installed here at vB.org - just use the Search This Thread box at the bottom right hand corner of this page. :)

Screenshot removed since it's not needed.

Vile
10-29-2002, 12:32 AM
Nice hack, I'll be insatlling this.

Also, just noticed you're a Mod Erwin:)
Congrats. Keep up the good work:)

DrkFusion
10-29-2002, 12:50 AM
Ah yes, very ueful for threads with huge number of pages.

Very good Job, erwin, and thank
-ARUNAN

N9ne
10-29-2002, 12:56 AM
Brilliant hack, I'll install in a few hours, 'tis 3am and I'm likely to blow up my forums :-/

Anyway, I've wanted this at vb.org for a while now, for easier searching, I will definitely install this on my forum.

Question: Does it use the same searchindex as the one that comes standard with vB?

wolfe
10-29-2002, 12:57 AM
great work d00d i have been waiting for this for ages :D

also d00d can u get vB to install it here :D and put it in vB3 :D

X-Fan
10-29-2002, 01:12 AM
Cool hack Erwin! I was actually wondering if a hack like this existed after searching for something in a 100+ page thread on my site!

Cheers! :)

X-Fan
10-29-2002, 01:22 AM
Oops, got a database error whilst doing a search on this thread at my site:

http://x-mencomics.com/xfan/forums/showthread.php?s=&threadid=12350


Database error in vBulletin 2.2.8:

Invalid SQL:
SELECT
post.postid, thread.visible
FROM
post
WHERE
post.visible=1 AND thread.visible=1 AND post.threadid=12350 AND post.postid IN (35257,47955,48991,51518,72677,102641,147732,14794 4, ... ,0) AND 1=1
ORDER BY
post.dateline DESC,post.dateline DESC
LIMIT 0,15

mysql error: Unknown table 'thread' in field list

mysql error number: 1109

Date: Tuesday 29th of October 2002 06:23:50 PM
Script: http://x-mencomics.com/xfan/forums/xfan/forums/search.php?s=&action=showresults&searchid=59091&sortby=&sortorder=
Referer:

WoodiE
10-29-2002, 01:25 AM
OMG, this needs to be installed here!

-WoodiE

Erwin
10-29-2002, 01:34 AM
Originally posted by N9ne
Question: Does it use the same searchindex as the one that comes standard with vB?

Yes.

Erwin
10-29-2002, 01:35 AM
Originally posted by X-Fan
Oops, got a database error whilst doing a search on this thread at my site:

http://x-mencomics.com/xfan/forums/showthread.php?s=&threadid=12350



Mmm... that's strange. Make sure you follow the installation instruction exactly - they can be tricky - don't double up on code - some of the code are meant to replace, some are to be added. I assume you ran the db query as well.

X-Fan
10-29-2002, 02:04 AM
Yep, ran the DB query, and all code additions/changes are as they should be.

X-Fan
10-29-2002, 02:11 AM
Okay, the code in my search.php for step 4 is as follows:


$getpostids=$DB_site->query("
SELECT
post.postid, thread.visible".
iif(strlen(strpos(" $orderbysql","posttext")),",IF(post.title='',LEFT(post.pagetext,50),post.titl e) AS posttext","").
iif(strlen(strpos(" $orderbysql","usrname")),",IF(post.userid=0,post.username,user.username) AS usrname","").
"
FROM
post".
iif(strlen(strpos($search[query],"searchindex")),",searchindex","").
iif(strlen(strpos(" $orderbysql","thread.")) or strlen(strpos($search[query],"thread.")) or strlen(strpos($orderbysql,"forum.")) or strlen(strpos($search[query],"forum."))," LEFT JOIN thread ON thread.threadid=post.threadid ","").
iif(strlen(strpos(" $orderbysql","forum.")) or strlen(strpos($search[query],"forum."))," LEFT JOIN forum ON thread.forumid=forum.forumid ","").
iif(strlen(strpos(" $orderbysql","usrname"))," LEFT JOIN user ON (post.userid=user.userid) ","").
"
WHERE
post.visible=1 AND thread.visible=1 AND $searchthreadquery $newpostsql $search[query]
ORDER BY
$orderbysql
LIMIT ".($limitlower-1).",$perpage
");


and for step 5 it's:


$sql="
SELECT
post.postid,post.title AS posttitle,post.dateline AS postdateline,post.userid AS postuserid,post.iconid AS posticonid,LEFT(post.pagetext,250) AS pagetext,
thread.threadid,thread.title AS threadtitle,thread.iconid AS threadiconid,thread.replycount,thread.views,thread .pollid,thread.open,thread.lastpost,
forum.forumid,forum.title AS forumtitle,forum.allowicons,user.username,
IF(post.title='',LEFT(post.pagetext,50),post.title ) AS posttext,
IF(post.userid=0,post.username,user.username) AS usrname,
posticon.iconpath AS posticonpath,posticon.title AS posticontitle,
threadicon.iconpath AS threadiconpath,threadicon.title AS threadicontitle
FROM
post".iif(strpos($search[query],"searchindex")>0,",searchindex","").",thread
LEFT JOIN forum ON forum.forumid=thread.forumid
LEFT JOIN user ON user.userid=post.userid
LEFT JOIN icon AS threadicon ON thread.iconid=threadicon.iconid
LEFT JOIN icon AS posticon ON post.iconid=posticon.iconid
WHERE
$postids AND $searchthreadquery thread.threadid=post.threadid
ORDER BY
$orderbysql";


Does that look right to you?

Okiewan
10-29-2002, 02:19 AM
Does this follow user group options for searches?

Erwin
10-29-2002, 02:22 AM
That looks right. And you REPLACED the relevant sections in your search.php. Make sure you are replacing the correct sections - there are 2 similar sections, one for "threadonly" and one for "showposts" - replace the SECOND lot, not the first lot in search.php - ie. the exact piece of code you are meant to find in the instructions (one reason why I ask to find a huge chunk of code to replace - there are 2 similar sections).

Erwin
10-29-2002, 02:22 AM
Originally posted by Okiewan
Does this follow user group options for searches?

Yes.

If guests are not allowed to search, they won't be able to. Private forum posts will remain hidden. All forum permissions are intact. :)

Okiewan
10-29-2002, 02:29 AM
Very cool.
Thanks, nice hack.

X-Fan
10-29-2002, 02:32 AM
Originally posted by Erwin
That looks right. And you REPLACED the relevant sections in your search.php. Make sure you are replacing the correct sections - there are 2 similar sections, one for "threadonly" and one for "showposts" - replace the SECOND lot, not the first lot in search.php - ie. the exact piece of code you are meant to find in the instructions (one reason why I ask to find a huge chunk of code to replace - there are 2 similar sections).

Yep, that's what I did, and it's not working. I've double-checked the hack installation, and I've followed your instructions to the letter, but I'm still getting that DB error. :(

Erwin
10-29-2002, 04:02 AM
NOTE:
----------

I've updated the installation text file to make the instructions clearer and easier. :)

Also, I changed the way the code is like in showthread.php to make the search box viewable by guests.

However, the search box will still follow search and forum permissions. :) If guests are not allowed to search, they won't be able to. Private forum permissions will be intact as well.

Download the new text file and see if it helps.

Erwin
10-29-2002, 04:14 AM
Alright, just managed to fixed up some of the text font problems and carriage returns in the installation text file.

Instructions now document 6 changes in the search.php file instead of 5 - I have made all the changes SMALLER and EASIER to do and follow. :)

Download the new searchthread1.txt now.

I have also uploaded a new screenshot. :)

Erwin
10-29-2002, 08:16 AM
@ X-Fan:

I got your PM of your search.php - You've got whole chunks of code that I don't what is there for in that file! :)

I've added the threadid bit to one of these chunks of code.

To be honest, your search.php is very messy, with repeated queries.

What is this?


if ($getsearch=$DB_site->query_first("SELECT searchid FROM search WHERE query='".addslashes($wheresql)."'")) {
$searchid=$getsearch[searchid];
} else {
// get last search for this user and check floodcheck
if ($prevsearch=$DB_site->query_first("SELECT searchid,dateline FROM search WHERE ".iif($bbuserinfo[userid]==0,"ipaddress='".addslashes($ipaddress)."'","userid=$bbuserinfo[userid]")." ORDER BY dateline DESC LIMIT 1")) {
if (time()-$prevsearch[dateline]<$searchfloodcheck and $searchfloodcheck!=0) { // and !ismoderator()) {
eval("standarderror(\"".gettemplate("error_searchfloodcheck")."\");");
exit;
}
}
// insert query into db
$DB_site->query("INSERT INTO search (searchid,query,dateline,querystring,showposts,use rid,ipaddress,threadid) VALUES (NULL,'".addslashes($wheresql)."',".time().",'".addslashes($query)."',0,$bbuserinfo[userid],'".addslashes($ipaddress)."',$threadid)");
$searchid=$DB_site->insert_id();
}
eval("standardredirect(\"".gettemplate("redirect_search")."\",\"search.php?s=$session[sessionhash]&action=showresults&getnew=true&searchid=$searchid\");");
}


It's not part of the normal search.php - anyway, I've added the threadid bits to this code (as you can see). This may make your search work.

If it still doesn't work, I cannot help you. My hack may not compatible with al these extra hacks you have in your search.php

I know definitely that this hack works with an unhacked search.php, and should work with the "Last 10 Searches" hack. But some other hacks may interfere with it, or may need to be modified for this to work.

Erwin
10-29-2002, 08:24 AM
The same goes for people having problems with this hack - uninstall your other hacks, or use an UNHACKED search.php and install it and see if it works.

This hack is working fine on my forums with 5000 members with 200 on at once, and my members love it. :) If this hack works for you, or if you know it is compatible with another search hack, please post here and let me know. Thanks.

Chris M
10-29-2002, 10:27 AM
Edit: I sorted it - Confliction with another hack;)

Satan

X-Fan
10-29-2002, 11:05 AM
Originally posted by Erwin
What is this?

I think that's the code for the search flood check - I only allow users on my forum to do one search every 60 seconds.

If it still doesn't work, I cannot help you. My hack may not compatible with al these extra hacks you have in your search.php

Well it's still not working. Any reason why it woluldn't be compatible?

Schorsch
10-29-2002, 12:34 PM
thanks Erwin for your work!

I have two questions:

1) in your manual:

In search.php

1. Find:

************************************************** ***********

// insert query into db

************************************************** ***********

ABOVE, ADD:

************************************************** ***********

// search thread - Erwin
if (!$threadid) {
$threadid="0";
}
// search thread - Erwin

************************************************** ***********

But I have this "// insert query into db" 6 times in my search.php. So do I have to do the changes 6 times or just for the first ?

2.) I don't have the following line of code in my search.php (vB 2.2.6)



5. Find:

************************************************** ***********

post.visible=1 AND thread.visible=1 AND $newpostsql $search[query]

************************************************** ***********

is there a possibility to install your hack with 2.2.6 ?

thanks,
Schorsch

zertox
10-29-2002, 12:43 PM
I was just going to post a request for this hack, (for on this forum) cuz I hate going trough 100 pages searching for my error :)

Chris M
10-29-2002, 12:48 PM
6 Times?

I only have it 4 times...

And yes - Do I have to do it to the first one or all of them?

Satan

Chris M
10-29-2002, 12:51 PM
Ok...Looking at it, I think you just need to do it for the first occurance:)

Satan

Xenon
10-29-2002, 01:06 PM
very nice hack collegue ;)

truely needed.

N9ne
10-29-2002, 03:24 PM
I installed this hack, on my unhacked 2.2.8, and it doesn't............




























Have any bugs ;)

Thanks for this hack, works perfectly :)

Dean C
10-29-2002, 03:29 PM
Awesome Erwin... i wish chen would install this here :D

Im certainly installing it straigt away on my forums :D

Regards

- miSt

N9ne
10-29-2002, 03:48 PM
I think once Chen sees this, he will install it ;)

*HINT HINT* :D

Erwin
10-29-2002, 05:12 PM
Originally posted by X-Fan


I think that's the code for the search flood check - I only allow users on my forum to do one search every 60 seconds.

Well it's still not working. Any reason why it woluldn't be compatible?

No it's not. Seach flood check is not reliant on that piece of code - it's build into the normal unhacked search.php - that piece of code is something very strange. :) Are you using 2.2.8? I suggest starting from scratch with an unhacked 2.2.8 and install my hack first, then the other hacks. That piece of code may be not needed as I don't see what the point is as you are DOUBLING UP on queries.

Erwin
10-29-2002, 05:19 PM
Originally posted by Schorsch
thanks Erwin for your work!

I have two questions:

1) in your manual:



But I have this "// insert query into db" 6 times in my search.php. So do I have to do the changes 6 times or just for the first ?


Just the FIRST occurence, and ignore the rest.

I've edited the installation text file to make it clear that it's the FIRST one. :)



2.) I don't have the following line of code in my search.php (vB 2.2.6)

is there a possibility to install your hack with 2.2.6 ?

thanks,
Schorsch

2.2.6... mmm, I'm using 2.2.8 - My advice is to UPGRADE ASAP as 2.2.6 has huge security holes - dangerous ones.

Just download the search.php for vB 2.2.8 and use the 2.2.8 search.php on your forums while keeping the rest 2.2.6 - it should still work. I recommend upgrading the whole forum though.

Smoothie
10-29-2002, 05:23 PM
Nice addition. Installed and working great!

ManagerJosh
10-29-2002, 06:21 PM
Superb Hack Erwin! I'm definitely installing this hack...the minute I get back to my PC that is.

I hate business trips...cause I can never carry my stuff with me..

Erwin
10-29-2002, 08:40 PM
@ X-Fan:

I found the problem in your search.php - Geez, it was obvious.

In your search.php:

Find this:


// search thread
" WHERE post.visible=1 AND $newpostsql $searchthreadquery $search[query]");
// search thread


Change it to:


" WHERE post.visible=1 AND $newpostsql $searchthreadquery $search[query]");


Get rid of the //search thread bits. You CANNOT put // comments in the MIDDLE of a query!!!

Same goes for this:


// search thread
$postids AND $searchthreadquery thread.threadid=post.threadid
// search thread


Change it to:


$postids AND $searchthreadquery thread.threadid=post.threadid


I repeat - you CANNOT put // comments in the MIDDLE of a QUERY!!!

Look at the code - that whole paragraph is ONE line of code on separate lines - you cannot just put // comments in the middle of it. :) Don't go adding lines to my hack, and then blaming my hack.

Vivi Ornitier
10-29-2002, 11:54 PM
is anyone else experiencing template problems? my side scroll bars go WAY out

N9ne
10-30-2002, 12:09 AM
Vivi, I experience no problems, did you modify the template according to instructions? Do you have any other modifications to that template?

Erwin
10-30-2002, 12:23 AM
You can just modify the template to suit your site. My hack will work for an unmodified template as it is. For modified templates, obviously you need to play around with the templates. :)

Tip: In "showthread" templates, you can move the variable "$searchthread" anywhere you like and the search box will appear. ;)

N9ne
10-30-2002, 12:24 AM
Erwin, I have an extremely modified showthread template and it still worked perfectly ;)

Smoothie
10-30-2002, 01:01 AM
8 styles on my forums. All have the search thread installed. All look marvy.

Vivi Ornitier
10-30-2002, 01:50 AM
yes i'm absolutely sure i followed the steps correctly for the hack. Here is my showthread if it means anything.

{htmldoctype}
<html>
<head><title>$bbtitle - $thread[title]</title>
$headinclude
<script language="javascript" type="text/javascript">
<!--
function aimwindow(aimid) {
window.open("member.php?s=$session[sessionhash]&action=aimmessage&aim="+aimid,"_blank","toolbar=no,location=no,menubar=no,scrol lbars=no,width=175,height=275,resizeable=yes,statu s=no")

}
function who(userid) {
window.open("userrate.php?s=$session[sessionhash]&action=show&rateuser="+userid, "whorated", "toolbar=no,scrollbars=yes,resizable=yes,width=230, height=300"); }
// -->
<!-- Warnings Hack v2.0 [ g-force2k2 ] -->
function showwarnings(userid) { window.open
("warn.php?s=&action=show_warn&userid="+userid,
"show_warn", "toolbar=no,scrollbars=yes,resizable=yes,width=600, height=350"); }
function addwarnings(postid) { window.open
("warn.php?s=&action=add_warn&postid="+postid,
"add_warn", "toolbar=no,scrollbars=yes,resizable=yes,width=400, height=200"); }
<!-- Warnings Hack v2.0 [ g-force2k2 ] -->
</script>
</head>
<body>
$header

<!-- breadcrumb, nav links -->
<table cellpadding="2" cellspacing="0" border="0" width="{contenttablewidth}" {tableinvisibleextra} align="center">
<tr>
<td>$navbar</td>
$ratingdisplay
</tr>
</table>
<!-- /breadcrumb, nav links -->

<a name="posttop"></a>

<!-- End content area table (CREATED IN HEADER!!) -->
</td>
</tr>
</table>

<!-- spacer -->
<table bgcolor="{pagebgcolor}" width="{tablewidth}" cellpadding="0" cellspacing="0" border="0">
<tr><td width="10"><img width="10" height="1" src="{imagesfolder}/space.gif" alt=""></td><td width="100%">
<!-- /spacer -->

$poll

<smallfont>$onlineusers</smallfont>
<br><br>

<!-- first unread and next/prev -->
<table cellpadding="2" cellspacing="0" border="0" width="{contenttablewidth}" {tableinvisibleextra} align="center">
<tr>
<td><smallfont>$pagenav $firstunread&nbsp;</smallfont></td>
<td align="right"><smallfont>
<img src="{imagesfolder}/prev.gif" alt="" border="0">
<a href="showthread.php?s=$session[sessionhash]&threadid=$threadid&goto=nextoldest">Last Thread</a>
&nbsp;
<a href="showthread.php?s=$session[sessionhash]&threadid=$threadid&goto=nextnewest">Next Thread</a>
<img src="{imagesfolder}/next.gif" alt="" border="0">
</smallfont></td>
</tr>
</table>
<!-- first unread and next/prev -->

<table cellpadding="{tableouterborderwidth}" cellspacing="0" border="0" bgcolor="{tablebordercolor}" {tableouterextra} width="{contenttablewidth}" align="center"><tr><td>
<table cellpadding="4" cellspacing="{tableinnerborderwidth}" border="0" {tableinnerextra} width="100%">
<tr>
<td bgcolor="{tableheadbgcolor}" width="175" nowrap><smallfont color="{tableheadtextcolor}" class="thtcolor"><b>Author</b></smallfont></td>
<td bgcolor="{tableheadbgcolor}" width="100%">
<!-- Thread nav and post images -->
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="100%"><smallfont color="{tableheadtextcolor}" class="thtcolor"><b>Thread</b></smallfont></td>
<td><a href="newthread.php?s=$session[sessionhash]&action=newthread&forumid=$forum[forumid]"><img src="{newthreadimage}" border="0" alt="Post New Thread"></a></td>
<td><normalfont>&nbsp;&nbsp;</normalfont></td>
<td><a href="newreply.php?s=$session[sessionhash]&action=newreply&threadid=$threadid"><img src="$replyclose" border="0" alt="Post A Reply"></a></td>
</tr>
</table>
<!-- /Thread nav and post images -->
</td>
</tr>
</table>
</td></tr></table>

<!-- /spacer -->
</td><td width="10"><img width="10" height="1" src="{imagesfolder}/space.gif" alt=""></td></tr></table>
<!-- /spacer -->

<br>

$postbits
$replybox
<!-- spacer -->
<table bgcolor="{pagebgcolor}" width="{tablewidth}" cellpadding="0" cellspacing="0" border="0">
<tr><td width="10"><img width="10" height="1" src="{imagesfolder}/space.gif" alt=""></td><td width="100%">
<!-- spacer -->

<table cellpadding="{tableouterborderwidth}" cellspacing="0" border="0" bgcolor="{tablebordercolor}" {tableouterextra} width="{contenttablewidth}" align="center"><tr><td>
<table cellpadding="4" cellspacing="{tableinnerborderwidth}" border="0" {tableinnerextra} width="100%">
<tr>
<td bgcolor="{tableheadbgcolor}" width="100%">
<!-- time zone and post buttons -->
<table border="0" cellspacing="0" cellpadding="0" bgcolor="{tableheadbgcolor}">
<tr>
<td width="100%"><smallfont color="{tableheadtextcolor}"><b>$timezone</b></smallfont></td>
<td><a href="newthread.php?s=$session[sessionhash]&action=newthread&forumid=$forum[forumid]"><img src="{newthreadimage}" border="0" alt="Post New Thread"></a></td>
<td><normalfont>&nbsp;&nbsp;</normalfont></td>
<td><a href="newreply.php?s=$session[sessionhash]&action=newreply&threadid=$threadid"><img src="$replyclose" border="0" alt="Post A Reply"></a></td>
</tr>
</table>
<!-- /time zone and post buttons -->
</td>
</tr>
</table>
</td></tr></table>

<!-- first unread and next/prev -->
<table cellpadding="2" cellspacing="0" border="0" width="{contenttablewidth}" {tableinvisibleextra} align="center">
<tr>
<td><smallfont>$pagenav&nbsp;</smallfont></td>
<td align="right"><smallfont>
<img src="{imagesfolder}/prev.gif" alt="" border="0">
<a href="showthread.php?s=$session[sessionhash]&threadid=$threadid&goto=nextoldest">Last Thread</a>
&nbsp;
<a href="showthread.php?s=$session[sessionhash]&threadid=$threadid&goto=nextnewest">Next Thread</a>
<img src="{imagesfolder}/next.gif" alt="" border="0">
</smallfont></td>
</tr>
</table>
<!-- first unread and next/prev -->

<!-- /spacer -->
</td><td width="10"><img width="10" height="1" src="{imagesfolder}/space.gif" alt=""></td></tr></table>
<!-- /spacer -->

<!-- restart content table from header -->
<table cellpadding="10" cellspacing="0" border="0" width="{tablewidth}" bgcolor="{pagebgcolor}" align="center">
<tr>
<td>
$similarthreads
<!-- thread options links -->
<table cellpadding="{tableouterborderwidth}" cellspacing="0" border="0" bgcolor="{tablebordercolor}" {tableouterextra} align="center"><tr><td>

<table cellpadding="4" cellspacing="{tableinnerborderwidth}" border="0" {tableinnerextra} width="100%">
<tr>
<td bgcolor="{firstaltcolor}" align="center"><smallfont>
<img src="{imagesfolder}/printer.gif" alt="" border="0" align="absmiddle">
<a href="printthread.php?s=$session[sessionhash]&threadid=$threadid">Show Printable Version</a> |
<img src="{imagesfolder}/sendtofriend.gif" alt="" border="0" align="absmiddle">
<a href="sendtofriend.php?s=$session[sessionhash]&threadid=$threadid">Email this Page</a> |
<img src="{imagesfolder}/subscribe.gif" alt="" border="0" align="absmiddle">
<a href="member2.php?s=$session[sessionhash]&action=addsubscription&threadid=$threadid">Subscribe to this Thread</a>
| <img src="{imagesfolder}/sortasc.gif" alt="" border="0" align="absmiddle"><a href="showthread.php?s=$session[sessionhash]&threadid=$threadid&action=download">Download Thread</a>
</smallfont></td>
</tr>
</table>
</td></tr></table>
<!-- /thread options links -->

<br>

<!-- forum jump and rate thread -->
<table cellpadding="2" cellspacing="0" border="0" width="{contenttablewidth}" {tableinvisibleextra} align="center">
<tr>
<td>$forumjump</td>
<td>$threadrateselect</td>
<td align="right">$searchthread</td>
</tr>
</table>
<!-- /Rate this thread -->

<br>

<!-- forum rules and admin links -->
<table cellpadding="2" cellspacing="0" border="0" width="{contenttablewidth}" {tableinvisibleextra} align="center">
<tr valign="bottom">
<td><smallfont><b>Forum Rules:</b>$forumrules</smallfont></td>
<td align="right">
$adminoptions
</td>
</tr>
</table>
<!-- /forum rules and admin links -->

$footer

</body>
</html>

Vivi Ornitier
10-30-2002, 01:59 AM
wait nm, i fixed it. that was very odd, oh well, GREAT HACK!!!

Erwin
10-30-2002, 01:59 AM
I went to your site - your showthread scrolls to the right even without my hack there.

Smoothie
10-30-2002, 02:08 AM
Got a link to your forums with the hack installed?

Erwin
10-30-2002, 02:15 AM
Remember, if putting the $searchthread variable in your showthread templates makes it scroll to the right where I tell you to in the installation text file, you can always move the $searchthread variable ANYWHERE in your showthread template. To the top if you want it to.

Admin
10-30-2002, 10:47 AM
Very nice! :)

Chris M
10-30-2002, 10:58 AM
Does that mean vB.org will have it?:D

Yey! - It Does!! *looks down to the bottom of the screen*

Satan

DrkFusion
10-30-2002, 11:03 AM
Its particularly vital to some people here at vb.org, its very useful, I will use it atleast 1-3 times each day.

Now I can have this for my board, thanks Erwin.
-Arunan

Erwin
10-30-2002, 11:17 AM
Firefly has installed this hack here at vB.org!!!

You can test this out in real life here - the search box is at the bottom right hand corner! :)

Dean C
10-30-2002, 05:24 PM
Wow damn good to have it on here :D

Thanks Dr 'Evil' Erwin ;)

Regards

- miSt

DrkFusion
10-30-2002, 06:19 PM
Congrats Erwin, if any hack is added here at vb.org it must mean it is good ;)

-Arunan

Erwin
10-30-2002, 06:29 PM
As long as it makes life easier for people looking for a particular post in a loooooooong thread here.... some posts here like the Quick Reply hack support post is LONG. Also, the Store Hack support thread is another example.

Chris M
10-30-2002, 08:18 PM
And vBhome(lite) and vBindex2.1:)

Satan

N9ne
10-30-2002, 08:48 PM
The store hack is the biggest thread on this whole forum, the search thread feature is gonna be useful :), congrats Erwin!

NTLDR
10-30-2002, 09:38 PM
A great addition to vB.org thanks for sharing Erwin, it will make life alot easier :D

Chris M
10-30-2002, 09:45 PM
@N9ne - Are you sure?

I thought the Quick Reply Box was;)

Followed by vBindex2.1:)

Satan

N9ne
10-30-2002, 10:05 PM
No hellsatan, biggest thread means how many replies it has ;)

But it has come to my attention that TECK's vBHome hack has taken the store hack over! https://vborg.vbsupport.ru/forumdisplay.php?s=&forumid=4&daysprune=1000&pagenumber=1&perpage=25&sortorder=desc&sortfield=replycount

-=dm=-
10-30-2002, 10:51 PM
Erwin very nice :)
it working fine on my 2.2.4 board.

Yo HellSatan whats up man?? :D

Okiewan
10-31-2002, 02:20 PM
Humm...

When searching in a thread, all it returns is a blank page ...
which is "http://domain.com/forums/newreply.php"

The only install issue I found was in search.php:

Find:
post.visible=1 AND thread.visible=1 AND $newpostsql $search[query]

My file had:

post.visible=1 AND $newpostsql $search[query]


Regular searches work.
ver 2.2.1 (yes, I know :( )

Help?

N9ne
10-31-2002, 03:58 PM
Erwin, guess what! vB3 IS USING SEARCH THREAD!!!!

I'm not sure if it's the same code as yours but it probably is! Congrats!

Erwin
10-31-2002, 05:54 PM
2.2.1? May not work for that. As the title of this hack suggests, it works with 2.2.8.

I suggest you upgrade - 2.2.1 has security holes the size of the Titanic.

As for vB3 - great!!! No need to update this hack when it comes out! ;) I did suggest this to them after I wrote it.

Okiewan
10-31-2002, 06:27 PM
I'll be waiting to see 3.4 out of beta before upgrading 20,200 members. I've got two years of hacks to re-apply, no way am I taking an interum step.

Thanks for the reply.

CRego3D
11-18-2002, 04:25 AM
good job .. works great :D

CRego3D
11-18-2002, 04:29 AM
Erwin

on your "search results" .. we get a more detailed search with your hack then a regular forum search gives us (on your I see parts of the post and all) .. I rember there was a hack that did that for the main forum search .. do you know wich one is it ?

Erwin
11-18-2002, 06:31 AM
My hack actually just uses the inbuilt vB functionality of searching for posts - you can do it for any forum, by clicking on Adcanced Search, then choosing "Show Posts" rather than "Show Threads". I just made it so that you can specify a forum from within the forum. :)

SpeedStreet
11-18-2002, 04:38 PM
Erwin,

This hack was very well written, and very easy to follow!

/me installs

BigJohnson
11-25-2002, 09:19 AM
Like the other X fan i am getting the same error

Database error in vBulletin 2.2.5:

Invalid SQL: SELECT COUNT(*) AS posts FROM post
WHERE post.visible=1 AND post.threadid= AND 1=1 AND post.userid='1'
mysql error: You have an error in your SQL syntax near 'AND 1=1 AND post.userid='1'' at line 2

mysql error number: 1064

The only time i get this error is when I click the button that says

See all posts made by this user.

The search thread hack works fine. It is just searching peoples posts it don't work. Please I don't know what to do.

Why is it doing this.

Erwin
11-25-2002, 09:59 AM
I assume you are using 2.2.8. If so, then you need to uninstall the hack, and install it again. That error you are getting looks like an error with your search query - possibly one of the variables is written wrongly.

As you can see on this site which is using the same hack, and on many other sites, the hack works perfectly. :)

Erwin
11-25-2002, 10:00 AM
Also, I assumed you ran the database query in the instructions too. :)

NuclioN
11-25-2002, 12:12 PM
? cookie error after using a 2.2.8. search php in VB 2.2.6

Erwin
11-25-2002, 07:46 PM
That's because vB 2.2.8 uses a different cookie saving method compared to vB 2.2.6 - you cannot use 1 file in 2.2.8 with 2.2.6 - upgrade your whole site to 2.2.8. 2.2.8 fixes the cookie bug for AOL users, that's why.

Kohhal
12-11-2002, 10:39 AM
Aaaah, I've been looking for this hack for so long and never came across it, mostly for going thru threads on here that I needed it, never noticed the option at the bottom of the screen :( All that reading thru the vbIndex thread and vbproArcade :speechless:

Anyhoo great hack, I've added it to my forum, no problems, I just have one issue though!

Attached is what my search results page looks like after using this feature, notice the way the topic field pushes the others over and makes everything look cluttered :(

(See next post for more...)

Kohhal
12-11-2002, 10:41 AM
Attached here is what my post results look like from the main search page, no problems with the topic field?

Any idea why this is happening? Am I the only one?

I know it's nothing major but it is frustrating!

Thanks,

G :rambo:

Erwin
12-12-2002, 02:56 AM
Try searching another thread. I suspect one of the posts in that thread has a long word that is not being broken up onto a new line.

This hack uses the same templates as the normal search page, so it's nothing to do with the hack. :)

Kohhal
12-12-2002, 10:08 AM
Ah, I figured it out. It's because of the quote box hack, if the quote is long then the box pushes the other fields across, same occurs when using the main Search and selecting "results as posts". I'll just ignore it :p

Cool beans, great hack :D

Erwin
12-13-2002, 01:35 AM
Great to know it's working for you! :)

jeffj
01-19-2003, 12:16 PM
2.2.6 Search.php

I'm attempting to install this hack on 2.2.5 and I need a 2.2.5 Search.php - does anyone have a virgin copy of 2.2.6 search 2.2.6. The code in 2.2.6 search.php is slightly different than 2.2.5 but will still work with 2.2.5 and I want to install this hack but don't have 2.2.6 - if you have it, please email it to webmaster@fastboats.info

thanks in advance

Chris M
02-04-2003, 05:38 PM
Originally posted by Erwin
I assume you are using 2.2.8. If so, then you need to uninstall the hack, and install it again. That error you are getting looks like an error with your search query - possibly one of the variables is written wrongly.

As you can see on this site which is using the same hack, and on many other sites, the hack works perfectly. :)

:( I am getting exactly the same error:(

Any help Erwin?

Satan

Erwin
02-04-2003, 11:22 PM
What's the error, Chris? What version vB are you using?

Dany
02-05-2003, 01:57 AM
Hello Erwin,

I have this Error when trying to search the thread.

Database error in vBulletin 2.2.9:

Invalid SQL:
SELECT
post.postid, thread.visible
FROM
post LEFT JOIN thread ON thread.threadid=post.threadid
WHERE
// REPLACED with search thread - Erwin
post.visible=1 AND thread.visible=1 AND post.threadid=59462 AND post.postid IN (258360,0) AND 1=1 AND NOT (thread.forumid='19')
// search thread - Erwin
// post.visible=1 AND thread.visible=1 AND post.postid IN (258360,0) AND 1=1 AND NOT (thread.forumid='19')
ORDER BY
post.dateline DESC,post.dateline DESC
LIMIT 0,20

mysql error: You have an error in your SQL syntax near '// REPLACED with search thread - Erwin
post.visible=1 AND thread.visib' at line 7

mysql error number: 1064

Date: Tuesday 04th of February 2003 08:50:34 PM


Any help?

Erwin
02-05-2003, 02:11 AM
Just remove all the // lines and it will work. You cannot put // comments in the middle of a search query like that. :)

Dany
02-05-2003, 03:18 AM
Thanks Erwinnow, now it works fine :rolleyes:

try changing this:
<table cellpadding="2" cellspacing="0" border="0" width="95%" align="center">
<tr valign="bottom">
<td align="right">
<table cellpadding="0" cellspacing="0" border="0"><tr>
<form action="search.php" method="post">
<td><smallfont><b>Search this Thread:</b>
<input type="hidden" name="s" value="$session[sessionhash]"><input type="hidden" name="searchdate" value="-1">
<input type="hidden" name="beforeafter" value="after"><input type="hidden" name="threadid" value="$threadid"><input type="hidden" value="1" name="showposts">
<input type="hidden" name="action" value="simplesearch"><br><input type="text" class="bginput" name="query">$gobutton
</smallfont></td>
</form>
</tr></table>
</td>
</tr>
</table>

with this:
<table cellpadding="2" cellspacing="0" border="0" width="95%" align="center">
<tr valign="bottom">
<td align="right">
<table cellpadding="0" cellspacing="0" border="0"><tr>
<form action="search.php" method="post">
<td><smallfont>
<input type="hidden" name="s" value="$session[sessionhash]"><input type="hidden" name="searchdate" value="-1">
<input type="hidden" name="beforeafter" value="after"><input type="hidden" name="threadid" value="$threadid"><input type="hidden" value="1" name="showposts">
<input type="text" class="bginput" name="query" VALUE="Search this Thread" OnFocus="if (value == 'Search this Thread') {value =''}" OnBlur="if (value == '') {value = 'Search this Thread'}" size="20" dir="ltr">$gobutton
</smallfont></td>
</form>
</tr></table>
</td>
</tr>
</table>

Chris M
02-08-2003, 01:09 PM
@Erwin -

Database error in vBulletin 2.2.9:

Invalid SQL: SELECT COUNT(*) AS posts FROM post
WHERE post.visible=1 AND post.threadid= AND 1=1 AND post.userid='1'
mysql error: You have an error in your SQL syntax near 'AND 1=1 AND post.userid='1'' at line 2

mysql error number: 1064

Thats the error I get:confused:

I use vB2.2.9;)

Satan

Erwin
02-08-2003, 01:39 PM
You installed the hack wrongly.

Uninstall it, and install it again, following the instructions EXACTLY. It is very easy to make a mistake with this hack. It works as long as you make sure you follow the instructions word for word.

Chris M
02-08-2003, 02:04 PM
Erwin - I did install the hack correctly - I have rechecked all the instructions from the file I had downloaded, and they are all as they should be:confused:

I will re-download the hack, and check to see if there are any differences:(

Satan

Chris M
02-08-2003, 02:15 PM
Nope...Not a single one:(

Satan

Erwin
02-09-2003, 05:49 AM
PM me your search.php and I'll take a look.

Chris M
02-09-2003, 09:38 AM
Ok:)

Pm on the way:)

Satan

Erwin
02-09-2003, 07:57 PM
I've replied. Basically, your search.php looks fine, but I reformatted that long query for you.

Make sure you've run the database query to add that extra column in the search table, that is specified in the text file.

Craigr
03-09-2003, 05:36 PM
Works great for me.

Thanks Erwin. :)

Craig

Gutspiller
03-23-2003, 01:00 AM
Problem with hack??? or problem with search?

When I search in this thread:

http://www.theforumz.com/forumz/showthread.php?s=&threadid=38156&

for "people" it says "Displaying Topics 1 to 2 of 2" yet it doesn't show any topics at all.

So you may think well his hack isn't working.

But when you go into that same thread and do a search for "max" it brings up 3 results.

I have had problems before with generic names that search wont allow. Could "people" be one of those? I talked to firefly about this a while and I guess there are certain words that it wont seach because your search index (or something like that) would get to big.

Could this be the case? I was just playing around with it and noticed this. Can somebody please help me troubleshoot this problem?

Thanks.

Boofo
03-23-2003, 01:20 AM
When I tried it, it gave me the try another term error message. I didn't get displaying 1 of 2 or anything like that. There are certain words in the badwords.php file that don't show up for the same reason Firefly said. Your search index would sky-rocket without that.

And also, 30 posts per page makes for a long page. ;)

Gutspiller
03-23-2003, 02:43 AM
Today at 08:20 PM Boofo said this in Post #94 (https://vborg.vbsupport.ru/showthread.php?postid=371631#post371631)
When I tried it, it gave me the try another term error message. I didn't get displaying 1 of 2 or anything like that. There are certain words in the badwords.php file that don't show up for the same reason Firefly said. Your search index would sky-rocket without that.

And also, 30 posts per page makes for a long page. ;)


OK, so now I have a bigger problem. Why is it showing you that and telling me there is 1of 2 and not shoing anything?

30 posts is considered a long page? I'm about ready to bump it up to 45 or 50 just to please my users.

Here's another example of the problem.

in this thread: http://www.theforumz.com/forumz/showthread.php?s=&threadid=46176

You do a search for "TheForumz" and it does say no matches found. Well you can clearly see that "TheForumz" appears in the first post. What gives? :ermm:

Erwin
03-23-2003, 04:12 AM
This hack uses the normal searchindex and search functions. Any search error you get will be specific to your forum, and not from this hack.

X-Fan
03-23-2003, 10:39 AM
Hey Erwin, remember how I had trouble with this hack before? Well I just installed it on a hacked 2.3.0 board (I actually still had the extra field in the search table from my previous install) and it worked fine, first try!

Erwin
03-23-2003, 11:13 AM
Yesterday at 11:39 PM X-Fan said this in Post #97 (https://vborg.vbsupport.ru/showthread.php?postid=371836#post371836)
Hey Erwin, remember how I had trouble with this hack before? Well I just installed it on a hacked 2.3.0 board (I actually still had the extra field in the search table from my previous install) and it worked fine, first try!

Great! :) It must have been another hack on your older board. :)

Boofo
03-23-2003, 12:07 PM
Erwin, try this:

Enter a single number in your search thread box and you will get the error that tells you that you are below the 3 letter limit. Now enter a single alphabet character and you get the "try a different term" error. That seems to only happen with the bottom 3 rows of keys on a search. ;)

By the way, that happens with vBulletin's search too.

Erwin
03-23-2003, 09:04 PM
I have no idea what you mean. Like I said, this hack uses the same search function that the normal search uses, with the variable "search results as post" ticked. Whatever it is you got (and I tried and cannot duplicate it), if you get the same with the "search result as post" ticked on the normal search page, then it is a native vB issue.

Boofo
03-23-2003, 10:01 PM
That's exactly what I said. The vb search does it to. I wasn't complaining about your hack. I have it installed and use it constantly. I was giving you more of a "looks what I found out about vb's search from using your hack." And it can be duplicated here. This is where I found it. ;)

Erwin
03-23-2003, 10:26 PM
Oh, okay. :)

Da`Nacho
04-26-2003, 10:38 AM
Erwin, I'm still having trouble integrating this with the MySQL 4 search hack per your instructions (https://vborg.vbsupport.ru/showthread.php?s=&threadid=51716&perpage=15&display=&pagenumber=3). I've totally redone the hacks on a fresh search.php and I still get a parse error on the following line:

$DB_site->query("UPDATE search SET dateline=".time().", userid=$bbuserinfo[userid], ipaddress='".$ipaddress)."', threadid=$threadid WHERE searchid=$getsearch[searchid]");

Erwin
04-26-2003, 10:44 AM
I have exactly the same line in mine, and it works. :) I just checked. I have no idea what the problem could be. Post 10 lines before and 10 lines after.

Da`Nacho
04-26-2003, 11:00 AM
Today at 06:44 AM Erwin said this in Post #104 (https://vborg.vbsupport.ru/showthread.php?postid=387329#post387329)
I have exactly the same line in mine, and it works. :) I just checked. I have no idea what the problem could be. Post 10 lines before and 10 lines after.

I'm sure it's something simple I'm just not getting through my thich head at 7AM saturday morning, lol:

$wheresql.=$datesql;

}

// search thread - Erwin

if (!$threadid) {
$threadid="0";
}
// check for existing query:
if ($getsearch=$DB_site->query_first("SELECT searchid FROM search WHERE showposts='".$showposts)."' AND query='".$wheresql)."' AND postids='".$goodpostlist)."' AND querystring='".$masterquery)."'") {
$DB_site->query("UPDATE search SET dateline=".time().", userid=$bbuserinfo[userid], ipaddress='".$ipaddress)."', threadid=$threadid WHERE searchid=$getsearch[searchid]");
$searchid=$getsearch[searchid];
} else {
// insert query into db
$DB_site->query("INSERT INTO search (searchid,query,postids,dateline,querystring,showp osts,userid,ipaddress,threadid) VALUES (NULL,'".$wheresql)."','".$goodpostlist)."',".time().",'".$masterquery)."','".$showposts)."',$bbuserinfo[userid],'".$ipaddress)."',$threadid)");
$searchid=$DB_site->insert_id();
}

// search thread - Erwin


eval("standardredirect(\"".gettemplate("redirect_search")."\",\"search.php?s=$session[sessionhash]&action=showresults&searchid=$searchid&sortby=".addslashes($sortby)."&sortorder=".addslashes($sortorder)."\");");

Da`Nacho
04-26-2003, 11:44 AM
By the way, it's giving the parse error on the following line now:
if ($getsearch=$DB_site->query_first("SELECT searchid FROM search WHERE showposts='".$showposts)."' AND query='".$wheresql)."' AND postids='".$goodpostlist)."' AND querystring='".$masterquery)."'")) {

Erwin
04-26-2003, 11:45 AM
You are missing a } somewhere I'm sure. You really have to get it back to a working file, then reinstall as instructed. :)

Da`Nacho
04-26-2003, 11:50 AM
Today at 07:45 AM Erwin said this in Post #107 (https://vborg.vbsupport.ru/showthread.php?postid=387350#post387350)
You are missing a } somewhere I'm sure. You really have to get it back to a working file, then reinstall as instructed. :)

I've done it three times now, each time to a fresh copy of search.php... the two hacks work seperate fine. :(

I wonder if it has to do with the problem some of us were having with the phantom query with the MySQL 4 search hack? *shrug*

Oh well... thanks for your help... looks like today is going to be one of those days. :(

Erwin
04-26-2003, 11:55 AM
Okay, PM me your search.php with the MY hack installed, without the MYSQL 4 hack, and I'll fix it for you. :)

Da`Nacho
04-26-2003, 12:35 PM
Erwin helped me out. all is good with integrating his search thread hack and the MySQL 4 hack. :)

ViewMy.biz
04-29-2003, 04:09 PM
While I have installed a couple of hacks before I don't think I have ever:

"1. Running 1 database query"

How do I do this?

ViewMy.biz
04-29-2003, 10:23 PM
What does "Running 1 database query" mean?

Erwin
04-30-2003, 08:41 AM
Today at 09:23 AM 4326692027f8 said this in Post #112 (https://vborg.vbsupport.ru/showthread.php?postid=389133#post389133)
What does "Running 1 database query" mean?

It means running a database query in phpMyAdmin or any other MySQL database manager. If you don't know how to do this, there are online tutorials on this site - search for them.

Oblivion Knight
04-30-2003, 09:40 AM
Working like a charm.. :)

Thankyou Erwin!
* Oblivion Knight clicks install.

shungo
05-01-2003, 03:20 AM
Hi there :)

After installing this hack i got the following error when i tried to view new forum messages :

Database error in vBulletin 2.3.0:

Invalid SQL: INSERT INTO search (searchid,query,postids,dateline,querystring,showp osts,userid,ipaddress,threadid) VALUES (NULL,'1=1 AND thread.lastpost>=1051757847 AND thread.open<>10','',1051762224,'','0',1,'80.13.127.83',)
mysql error: You have an error in your SQL syntax near ')' at line 1

mysql error number: 1064

Date: Thursday 01st of May 2003 06:10:24 AM
Script: search.php?s=&action=getnew

Can anyboddy help me please ?? :(

Best regards

Erwin
05-01-2003, 03:32 AM
You installed the hack wrongly - uninstall, and do it again. Like I said in the instructions, one wrong cut and paste, and it won't work. :)

shungo
05-01-2003, 04:07 AM
Ok, it works very nice now ! :)

Sorry and thx for your answer ;)

Congratulations for all your hacks, you make a really good job

PhoenixBB
06-01-2003, 11:23 PM
Has anybody got this working with 2.26? I don't want to upgrade as it took me all my time to install various hacks and I can't face it again.

I've compared my current search php with the original 2.26 and it's unchanged. There is changed code obviously in the 2.30 search file. Could it work if I just did a straight swap? Or could that do bad things to the board?

WEForums
06-02-2003, 12:20 AM
Today at 01:23 AM PhoenixBB said this in Post #118 (https://vborg.vbsupport.ru/showthread.php?postid=403156#post403156)
Has anybody got this working with 2.26? I don't want to upgrade as it took me all my time to install various hacks and I can't face it again.

I've compared my current search php with the original 2.26 and it's unchanged. There is changed code obviously in the 2.30 search file. Could it work if I just did a straight swap? Or could that do bad things to the board? https://vborg.vbsupport.ru/showthread.php?s=&threadid=38545 (How to upgrade hacked boards)

I recommend you do that and don't swap any files. Any code alterations in one file means other files have been changed as well (most likely anyway).

tamarian
06-06-2003, 11:44 PM
Great hack Erwin!!!

This should be a feature in stock vB

Erwin
06-07-2003, 12:30 AM
It's incorporated in vB3. :)

tamarian
06-07-2003, 12:46 AM
Today at 02:30 AM Erwin said this in Post #121 (https://vborg.vbsupport.ru/showthread.php?postid=405376#post405376)
It's incorporated in vB3. :)


I think I've suggested it way back when :)

S.Shady
06-07-2003, 03:17 AM
works perfect thanks

DiscussAnything
08-20-2003, 03:03 PM
i really like this hack and it works fine, but i am having a side-effect and I'm not sure why. I did everything the instructions said, and it works fine. But if i go into a users profile and 'find all users posts' it gives me a database error:

Invalid SQL: SELECT COUNT(*) AS posts FROM post
LEFT JOIN thread ON thread.threadid=post.threadid WHERE post.visible=1 AND post.threadid= AND 1=1 AND NOT
(thread.forumid='12' OR thread.forumid='10' OR thread.forumid='11') AND post.userid='2'
mysql error: You have an error in your SQL syntax near 'AND 1=1
AND NOT (thread.forumid='12' OR thread.forumid='10' OR thread.forumid='' at line 2

mysql error number: 1064

the post.threadid is empty there, which seems to cause the error. Why would a 'thread search' have that effect on a 'find users posts' function, and am i the only one that has this problem? As far as I'm aware this is the only change to my search.php

any help is apprecatied

FleaBag
11-01-2003, 06:34 PM
Finally got around to adding this hack, should come in handy.

Thanks Erwin.