PDA

View Full Version : Search Thread


Erwin
29 Oct 2002, 01:28
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
29 Oct 2002, 01:32
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
29 Oct 2002, 01:32
Nice hack, I'll be insatlling this.

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

DrkFusion
29 Oct 2002, 01:50
Ah yes, very ueful for threads with huge number of pages.

Very good Job, erwin, and thank
-ARUNAN

N9ne
29 Oct 2002, 01:56
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
29 Oct 2002, 01:57
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
29 Oct 2002, 02:12
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
29 Oct 2002, 02:22
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,147944, ... ,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
29 Oct 2002, 02:25
OMG, this needs to be installed here!


-WoodiE

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

Yes.

Erwin
29 Oct 2002, 02:35
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
29 Oct 2002, 03:04
Yep, ran the DB query, and all code additions/changes are as they should be.

X-Fan
29 Oct 2002, 03:11
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.title) 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.las tpost,
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
29 Oct 2002, 03:19
Does this follow user group options for searches?

Erwin
29 Oct 2002, 03:22
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
29 Oct 2002, 03:22
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
29 Oct 2002, 03:29
Very cool.
Thanks, nice hack.

X-Fan
29 Oct 2002, 03:32
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
29 Oct 2002, 05:02
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
29 Oct 2002, 05:14
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
29 Oct 2002, 09:16
@ 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,userid,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
29 Oct 2002, 09:24
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
29 Oct 2002, 11:27
Edit: I sorted it - Confliction with another hack;)

Satan

X-Fan
29 Oct 2002, 12:05
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
29 Oct 2002, 13:34
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
29 Oct 2002, 13:43
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
29 Oct 2002, 13:48
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
29 Oct 2002, 13:51
Ok...Looking at it, I think you just need to do it for the first occurance:)

Satan

Xenon
29 Oct 2002, 14:06
very nice hack collegue ;)

truely needed.

N9ne
29 Oct 2002, 16:24
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
29 Oct 2002, 16:29
Awesome Erwin... i wish chen would install this here :D

Im certainly installing it straigt away on my forums :D

Regards

- miSt

N9ne
29 Oct 2002, 16:48
I think once Chen sees this, he will install it ;)

*HINT HINT* :D

Erwin
29 Oct 2002, 18:12
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
29 Oct 2002, 18:19
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
29 Oct 2002, 18:23
Nice addition. Installed and working great!

ManagerJosh
29 Oct 2002, 19:21
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
29 Oct 2002, 21:40
@ 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
30 Oct 2002, 00:54
is anyone else experiencing template problems? my side scroll bars go WAY out

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

Erwin
30 Oct 2002, 01:23
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
30 Oct 2002, 01:24
Erwin, I have an extremely modified showthread template and it still worked perfectly ;)

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

Vivi Ornitier
30 Oct 2002, 02:50
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,scrollbars=no,width=175,height=275,resizeable= yes,status=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
30 Oct 2002, 02:59
wait nm, i fixed it. that was very odd, oh well, GREAT HACK!!!

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

Smoothie
30 Oct 2002, 03:08
Got a link to your forums with the hack installed?

Erwin
30 Oct 2002, 03:15
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.

Chen
30 Oct 2002, 11:47
Very nice! :)

Chris M
30 Oct 2002, 11:58
Does that mean vB.org will have it?:D

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

Satan

DrkFusion
30 Oct 2002, 12:03
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
30 Oct 2002, 12:17
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
30 Oct 2002, 18:24
Wow damn good to have it on here :D

Thanks Dr 'Evil' Erwin ;)

Regards

- miSt

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

-Arunan

Erwin
30 Oct 2002, 19:29
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
30 Oct 2002, 21:18
And vBhome(lite) and vBindex2.1:)

Satan

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

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

Chris M
30 Oct 2002, 22:45
@N9ne - Are you sure?

I thought the Quick Reply Box was;)

Followed by vBindex2.1:)

Satan

N9ne
30 Oct 2002, 23:05
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! http://www.vbulletin.org/forum/forumdisplay.php?s=&forumid=4&daysprune=1000&pagenumber=1&perpage=25&sortorder=desc&sortfield=replycount

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

Yo HellSatan whats up man?? :D

Okiewan
31 Oct 2002, 15:20
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
31 Oct 2002, 16:58
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
31 Oct 2002, 18:54
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
31 Oct 2002, 19:27
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
18 Nov 2002, 05:25
good job .. works great :D

CRego3D
18 Nov 2002, 05:29
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
18 Nov 2002, 07:31
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
18 Nov 2002, 17:38
Erwin,

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

/me installs

BigJohnson
25 Nov 2002, 10:19
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
25 Nov 2002, 10:59
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
25 Nov 2002, 11:00
Also, I assumed you ran the database query in the instructions too. :)

NuclioN
25 Nov 2002, 13:12
? cookie error after using a 2.2.8. search php in VB 2.2.6

Erwin
25 Nov 2002, 20:46
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
11 Dec 2002, 11:39
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
11 Dec 2002, 11:41
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 Dec 2002, 03:56
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 Dec 2002, 11:08
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
13 Dec 2002, 02:35
Great to know it's working for you! :)

jeffj
19 Jan 2003, 13:16
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
04 Feb 2003, 18:38
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
05 Feb 2003, 00:22
What's the error, Chris? What version vB are you using?

Dany
05 Feb 2003, 02:57
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
05 Feb 2003, 03:11
Just remove all the // lines and it will work. You cannot put // comments in the middle of a search query like that. :)

Dany
05 Feb 2003, 04:18
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
08 Feb 2003, 14:09
@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
08 Feb 2003, 14:39
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
08 Feb 2003, 15:04
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
08 Feb 2003, 15:15
Nope...Not a single one:(

Satan

Erwin
09 Feb 2003, 06:49
PM me your search.php and I'll take a look.

Chris M
09 Feb 2003, 10:38
Ok:)

Pm on the way:)

Satan

Erwin
09 Feb 2003, 20:57
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
09 Mar 2003, 18:36
Works great for me.

Thanks Erwin. :)

Craig

Gutspiller
23 Mar 2003, 02:00
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
23 Mar 2003, 02:20
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
23 Mar 2003, 03:43
Today at 08:20 PM Boofo said this in Post #94 (http://www.vbulletin.org/forum/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
23 Mar 2003, 05:12
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
23 Mar 2003, 11:39
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
23 Mar 2003, 12:13
Yesterday at 11:39 PM X-Fan said this in Post #97 (http://www.vbulletin.org/forum/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
23 Mar 2003, 13:07
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
23 Mar 2003, 22:04
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
23 Mar 2003, 23:01
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
23 Mar 2003, 23:26
Oh, okay. :)

Da`Nacho
26 Apr 2003, 11:38
Erwin, I'm still having trouble integrating this with the MySQL 4 search hack per your instructions (http://www.vbulletin.org/forum/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
26 Apr 2003, 11:44
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
26 Apr 2003, 12:00
Today at 06:44 AM Erwin said this in Post #104 (http://www.vbulletin.org/forum/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,showposts,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
26 Apr 2003, 12:44
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
26 Apr 2003, 12:45
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
26 Apr 2003, 12:50
Today at 07:45 AM Erwin said this in Post #107 (http://www.vbulletin.org/forum/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
26 Apr 2003, 12:55
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
26 Apr 2003, 13:35
Erwin helped me out. all is good with integrating his search thread hack and the MySQL 4 hack. :)

ViewMy.biz
29 Apr 2003, 17:09
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
29 Apr 2003, 23:23
What does "Running 1 database query" mean?

Erwin
30 Apr 2003, 09:41
Today at 09:23 AM 4326692027f8 said this in Post #112 (http://www.vbulletin.org/forum/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
30 Apr 2003, 10:40
Working like a charm.. :)

Thankyou Erwin!
/me clicks install.

shungo
01 May 2003, 04:20
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,showposts,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
01 May 2003, 04:32
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
01 May 2003, 05:07
Ok, it works very nice now ! :)

Sorry and thx for your answer ;)

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

PhoenixBB
02 Jun 2003, 00:23
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
02 Jun 2003, 01:20
Today at 01:23 AM PhoenixBB said this in Post #118 (http://www.vbulletin.org/forum/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? http://www.vbulletin.org/forum/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
07 Jun 2003, 00:44
Great hack Erwin!!!

This should be a feature in stock vB

Erwin
07 Jun 2003, 01:30
It's incorporated in vB3. :)

tamarian
07 Jun 2003, 01:46
Today at 02:30 AM Erwin said this in Post #121 (http://www.vbulletin.org/forum/showthread.php?postid=405376#post405376)
It's incorporated in vB3. :)


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

S.Shady
07 Jun 2003, 04:17
works perfect thanks

DiscussAnything
20 Aug 2003, 16:03
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
01 Nov 2003, 19:34
Finally got around to adding this hack, should come in handy.

Thanks Erwin.