PDA

View Full Version : Google-Search


Hotte
07-24-2002, 10:00 PM
Hi
with this hack you can get your own google-search from your vbulletin. This hack needs some PEAR-Classes and you need a google-account.

Requirements:
- you need the following PEAR-Classes:
- SOAP (available at http://cvs.php.net)
- Net/Dime (available at http://cvs.php.net)
- SOAP_Google (available at http://www.sebastian-bergmann.de/?page=google)
- Google-Account (free at http://www.google.com/apis/)

installation notes
Make sure that you have the required pear-classes installed. Infos about PEAR are available at http://pear.php.net
If you receive require/include-errors edit websearch.php and add the path to pear.
Edit websearch.php and enter your google-key
Upload websearch.php to your forums-directory
add the 3 templates
create a link to websearch.php where you want

Have fun :)

edit: If you don?t want getting the pearclasses from cvs, take a look here (http://pear.php.net/packages.php)

get a blank page after submitting the search? read this (https://vborg.vbsupport.ru/showthread.php?postid=277839#post277839)

want to integrade the google-search into your regular search enginge? look here (https://vborg.vbsupport.ru/showthread.php?postid=277982#post277982)

Hotte
07-25-2002, 01:55 PM
Screenshot

ULTIMATESSJ
07-25-2002, 01:57 PM
kewl hack, nice work

Webmasta XT
07-25-2002, 01:58 PM
hey very nice..

dgessler
07-25-2002, 06:25 PM
I think it's sort of neat also, never knew you could imbed google results on your site.

Erwin
07-25-2002, 07:35 PM
Cool. :)

Itworx4me
07-25-2002, 09:58 PM
Would be nice if there were a little better detailed information on which pear files you need. Plus where do you put them. Instructions said nothing to the sort of where they go. Overall this looks to be a good hack. Would even be better if the instructions were more CLEAR.

Floris
07-25-2002, 10:53 PM
Shame pears are not independable.

JJR512
07-26-2002, 07:10 AM
Originally posted by Itworx4me
Would be nice if there were a little better detailed information on which pear files you need. Plus where do you put them. Instructions said nothing to the sort of where they go. Overall this looks to be a good hack. Would even be better if the instructions were more CLEAR.
I agree. I've downloaded the files, but what do I do with them? I
ve got SOAP_Google.php, Net_DIME-0.2.tgz, and SOAP-0.6.2.tgz. But now what?

Is this something that someone with a shared hosting account can use, or do I have to have root access to the server?

Chris M
07-26-2002, 11:04 AM
Indeed...I would like to know this:)

Satan

Hotte
07-26-2002, 11:37 AM
Unzip the PEAR-Classes and upload them in the following format on your webserver:

/pear
|
+-> SOAP_Google.php
|
+-> /pear/Net
|
+-> Dime.php
|
+-> /pear/SOAP
|
+-> <files from the SOAP-0.6.2.tgz>

Then enter the absolut path to the pear-dir in the websearch.php

JJR512
07-26-2002, 11:56 AM
And I don't need root access to do this? I read somewhere that all this should be above the web root, to prevent people from executing some of the scripts over the Internet.

Let me just make sure I got this straight.

I'm on a shared server. My webroot is: /home/jjr512/public_html (That's where I put the vB root, too.) So I could put all this starting in /home/public/pear, correct?

Hotte
07-26-2002, 12:00 PM
Originally posted by JJR512
I'm on a shared server. My webroot is: /home/jjr512/public_html (That's where I put the vB root, too.) So I could put all this starting in /home/public/pear, correct? Why /home/public/pear? Upload pear to /home/jjr512/public_html/pear or /home/jjr512/pear if you don?t want the classes accessable from the browser.

JJR512
07-26-2002, 12:02 PM
Sorry, misspoke... /home/jjr512/pear is what I meant. Other than that, it's all good? I'm about to upload it all, so I guess I'll find out in a moment...

Hotte
07-26-2002, 12:05 PM
Don´t forget to enter "/home/jjr512/pear" in websearch.php

JJR512
07-26-2002, 12:06 PM
Hey! It works! Woohoo! :D

Next time you need a nomination for Hack of the Month...let me know!

My only suggestion would be to find a way so that on the initial page, before you do a search, the search box only appears once. I understand you have it twice so that after someone does a search, the search box will appear both above and below the results, but before there are any results, having the exact same thing twice, one above the other, looks a little silly. :)

Link14716
07-26-2002, 06:00 PM
At first, when I saw this, I asked myself how to get the pear things, noow that I know, I will install. Thanks. :)

Link14716
07-26-2002, 06:16 PM
I need to get the SOAP class, but I'd have to download the files 1 by 1. Where can I get a zipped (or tgz) forms of it? I can't find it anywhere.

Nice hack, BTW. :)

Hotte
07-26-2002, 06:35 PM
Originally posted by Link14716
I need to get the SOAP class, but I'd have to download the files 1 by 1. Where can I get a zipped (or tgz) forms of it? I can't find it anywhere.

Nice hack, BTW. :)
Take a look at the last line of my first post

Link14716
07-26-2002, 06:55 PM
I did, but I still couldn't find it :(

EDIT: I just saw the search box and found it :)

Link14716
07-26-2002, 07:14 PM
I just installed it but when I submit a search, it gives me a blank page. :(

Hotte
07-26-2002, 07:24 PM
Originally posted by Link14716
I just installed it but when I submit a search, it gives me a blank page. :(
do you have the templates added?

Link14716
07-26-2002, 07:45 PM
yes, otherwise I wouldn't been able to see the front page of the search.

EDIT: I just double checked. All 3 are there.

Hotte
07-26-2002, 07:51 PM
Originally posted by Link14716
yes, otherwise I wouldn't been able to see the front page of the search.

EDIT: I just double checked. All 3 are there.
Try replacing
<form method="get" action="$PHP_SELF">
with
<form method="get" action="websearch.php">
in the template "websearch"
This must be done 2 times (for the searchboxes at the top and the bottom)

Sparkz
07-26-2002, 07:55 PM
I am having the same problem.
It seems like the script terminates inside $result = $google->search(
array(
'query' => $search,
'start' => $limitlower,
'maxResults' => $perpage,
'ie' => "UTF-8",
'oe' => "UTF-8"
)
);

Any debug-text I put after this will not show up.

Hotte
07-26-2002, 07:56 PM
Sparkz: And when you put debug-text above that? Will that show up?

Sparkz
07-26-2002, 08:01 PM
My debug text... :)
I'm getting a blank page like Link up here... Tried debugging my way through the script and that's where I ended up.

Hotte
07-26-2002, 08:03 PM
hmmm
you have the google-key entered?

Sparkz
07-26-2002, 08:11 PM
yup.
In any case, if I didn't, I'd expect to get a reply back telling me about this :)

Sparkz
07-26-2002, 08:18 PM
Looks like it dies while trying to execute$result = $this->_soapClient->call($apiCall, $parameters, 'urn:GoogleSearch');inside _performAPICall()

Hotte
07-26-2002, 08:22 PM
is your webserver behind some kind of firewall that makes trouble?

Sparkz
07-26-2002, 08:25 PM
It is behind a firewall, but I don't think traffic originating from the inside is restricted...

Hotte
07-26-2002, 08:26 PM
or try these pear-classes. they are the same that i´m using. perhaps we have diffrent versions or something like that.

Sparkz
07-26-2002, 08:26 PM
Just spoke with the sysadmin there. Shouldn't be any restrictions on outgoing traffic at all.

Sparkz
07-26-2002, 08:29 PM
Trying your pear stuff now... I downloaded mine fresh from CVS 30 minutes or so ago

Hotte
07-26-2002, 08:32 PM
perhaps this helps. which php-version are you using? as modul or cgi? linux or windows?

Sparkz
07-26-2002, 08:40 PM
No luck..
PHP-4.2.2 as DSO, apache-1.3.26 on a RH7.1
PHP and apache (and most everything else too, for that matter) compiled from scratch by me.

Hotte
07-26-2002, 08:50 PM
hmmm
i?ve the same config. strange.
don?t know why it doesn?t work on your forum.
but... hmmm... last chance: perhaps there is an old pear-version in the includepath from the php.ini.
at line 10 in websearch.php change
$ipath.=":$pearpath";
to
$ipath=".:$pearpath";
and make sure that you have entered the path to your uploaded pearclasses at line 4 ($pearpath)

Sparkz
07-26-2002, 09:14 PM
No luck... Weird...
I have tried juggling with the include_path too... Search the system for pear-related stuff too...
Only the standard stuff that comes with the PHP-install

JJR512
07-27-2002, 02:48 AM
I was getting a blank page, too, before I knew how to setup the pear stuff and the other stuff. Once Hotte explained it to me, I didn't have the problem anymore. Are you sure you have it setup exactly as he described above?

JJR512
07-27-2002, 04:37 AM
Two issues.

1. While I've been testing this and customizing the templates for my site a bit, I've been using this test search: lyrics "road to nowhere" So I could compare how the results look on my site with the real Google, I did the same search there, too. And I've noticed that my site does not have the exact same set of results that the real Google has. Check it out for yourself. You'll see that the first result is the same, but from there, they start to get more different. Why is this?

2. With the same test search as just mentioned, when the results come back, the search box is filled only with lyrics. In other words, the entire part in the quotes has been dropped out.

JJR512
07-27-2002, 04:53 AM
I was able to solve Issue #2 by making the following changes to your websearch.php.

Near the bottom, find this line:
$pagenav = getpagenav($treffer,"$PHP_SELF?action=$action&suche=".urlencode($suche));
Below it, on a new line, add this:
$suche = addslashes(htmlspecialchars($suche));
Note: I don't know if both addslashes and htmlspecialchars are necessary. However, as it is now, it did fix the problem I was having.

Also: Because Google limits our accounts to 1000 searches per day, this isn't something that you probably want just anybody being able to use. You have an exclusion to not allow unregistered/unlogged-in people to use it, but I've gone a step further. I've added a new usergroup setting so that you can set each usergroup to be able to use it or not. This may be useful to people who have more privilege levels than what standard vBulletin offers, such as paid members vs. non-paying members, or whatever the case may be. If you'd like instructions on how to set this up, let me know.

Sparkz
07-27-2002, 06:22 AM
Originally posted by JJR512
I was getting a blank page, too, before I knew how to setup the pear stuff and the other stuff. Once Hotte explained it to me, I didn't have the problem anymore. Are you sure you have it setup exactly as he described above?

Well, if you read my posts, you'll see that execution actually stops INSIDE one of the pear scripts...

JJR512
07-27-2002, 06:37 AM
I read them, I just don't understand them enough to know that, lol. :D

Sparkz
07-27-2002, 06:43 AM
LOL :)

FWC
07-27-2002, 08:14 AM
Originally posted by JJR512
Note: I don't know if both addslashes and htmlspecialchars are necessary. However, as it is now, it did fix the problem I was having.I just used the htmlspecialchars and it seems to work fine. Thanks for the tip. :)

Hotte
07-27-2002, 12:36 PM
Originally posted by JJR512
1. While I've been testing this and customizing the templates for my site a bit, I've been using this test search: lyrics "road to nowhere" So I could compare how the results look on my site with the real Google, I did the same search there, too. And I've noticed that my site does not have the exact same set of results that the real Google has. Check it out for yourself. You'll see that the first result is the same, but from there, they start to get more different. Why is this?
Good Question. I think that the Google-Api works a bit diffrent compared to the "normal" webpage.

nuno
07-27-2002, 04:29 PM
Can we have a live demo please?
I can't get this to work :=(
All i get is a search result blank page :confused:

Kars10
07-27-2002, 04:47 PM
Me too. Ive tried about 4 hours, and make all step by step. Nothing appears after searching. The "websearch-Page" is there and when i search i get a blank white screen.
This sucks! What can i do. I want this hack, but i don?t know what to do....
My Forum is in the webdirectory called "forum". In this directory is the pearl-folder with the content "soap(with the classes)", "soap_google", "net (with dime.php)"....
Please help! ;)

Hotte
07-27-2002, 05:22 PM
Try the following: Download the latest pear-base system @ http://pear.php.net/package-info.php?pacid=14 (or use the attachment)
Upload the unzipped file in your pear-directory with all subdirectories.
make sure you entered your pearpath in websearch.php
then change $ipath.=":$pearpath"; to $ipath=".:$pearpath";

nuno
07-27-2002, 05:31 PM
BINGO :)
You have to edit your php.ini file and check include-path.

nuno
07-27-2002, 05:34 PM
Very nice *hack* Hotte, thanks :)

Hotte
07-27-2002, 05:38 PM
there is no need to edit the php.ini for the include_path. this is done by the script. but i wonder why a missing pear-class doesn´t produce errors. hmmm

JJR512
07-27-2002, 05:45 PM
I've been getting some emails, instant messages, etc. from people asking me how I got this to work. Some are asking me how, exactly, I setup the pear/soap/etc. files. All I can say is, I setup all those files exactly as Hotte described earlier with his directory tree diagram, and edited the path to those files into websearch.php, and after that, it worked fine. Make sure the path you put into websearch.php is an absolute path, like /home/accountname/pear, not a URL-type path. That's really all I can say; I can't explain it any better than that, because I followed that tree precisely and followed the other directions precisely, so if I tried to explain how I got it to work for me I'd just be repeating what Hotte has already said. Sorry to anyone else who can't get it to work. :(

Kars10
07-27-2002, 06:07 PM
He Guys it works......i cant stand it it works!!!
This is bringing me down!! :)

Hotte
07-27-2002, 06:11 PM
Ok, for all who have problems getting this hack working (blank page after submitting a search):
Download all the required PEAR-Classes at http://pear.php.net or get this attachment (https://vborg.vbsupport.ru/attachment.php?s=&postid=277820).
Upload the pearclasses where you want on your server. I suggest to put them outsite the document-root. After you uploaded the pearclasses, you must have the following structur of you peardirectory:

|- OS
|- Guess.php
|- Net
|- DIME.php
|- PEAR
|- Builder.php
|- Installer.php
|- Dependency.php
|- Remote.php
|- Config.php
|- Command
|- Remote.php
|- Config.php
|- Build.php
|- Registry.php
|- Common.php
|- Install.php
|- Package.php
|- Auth.php
|- Frontend
|- Gtk.php
|- CLI.php
|- Registry.php
|- Packager.php
|- Autoloader.php
|- Common.php
|- Command.php
|- SOAP
|- Parser.php
|- Type
|- dateTime.php
|- duration.php
|- hexBinary.php
|- test
|- 5.2.simpletypes.php
|- 5.2.1.simpletypes.multiref.php
|- all.php
|- xmethods.php
|- 5.2.1.simpletypes.string.php
|- smtp.php
|- test.utility.php
|- tools
|- genproxy.php
|- Server
|- Email_Gateway.php
|- Email.php
|- Value.php
|- Fault.php
|- Transport.php
|- example
|- email_gateway.php
|- email_server.php
|- server.php
|- client.php
|- stockquote.php
|- smtp.php
|- Server.php
|- WSDL.php
|- Client.php
|- Base.php
|- Transport
|- SMTP.php
|- HTTP.php
|- interop
|- client_round2.php
|- server_round2_base.php
|- server_round2_groupB.php
|- server_round2_groupC.php
|- client_round2_run.php
|- client_round2_interop.php
|- client_round2_params.php
|- interopB.wsdl
|- readme.txt
|- server_round2_test.php
|- index.php
|- echoheadersvc.wsdl
|- interop.wsdl
|- client_round2_results.php
|- database_round2.sql
|- server_round2.php
|- package.dtd
|- System.php
|- PEAR.php
|- SOAP_Google.php

Make sure you entered the absolut path to the peardirectory in websearch.php. i.e. /www/<your site>/pear (depends on your host). Do not enter an URL (http://.....). Then should all working.

nuno
07-27-2002, 06:58 PM
Working flawlessly with search.php, there's no need to have a websearch.php file :)
Something like:
1st table - Forum Search Engine
2nd table - Search Options
3rd table - Websearch Engine - Powered by Google

maligno
07-27-2002, 08:54 PM
could you explain the steps?

Hotte
07-27-2002, 09:12 PM
i can explain the steps how to integrate the google-search into the regular search. but for now, i´m enjoying my beer.

Sparkz
07-27-2002, 09:28 PM
Cheers!

nuno
07-27-2002, 09:40 PM
It's Hotte's hack, and i'll not do anything without his permission :)

Hotte
07-27-2002, 10:00 PM
nuno: feel free to explain the steps how to integrade the google-search into the regular search. it should nothing more than add the actions to search.php + a small template modification :)
Myself prefer hacks that are as most compatlible to upgrades as possible :)

nuno
07-27-2002, 10:27 PM
Ok
Lemme know what you think then
enjoy :)

Hotte
07-27-2002, 10:31 PM
edited the first post with a link to your post nuno

nuno
07-27-2002, 10:36 PM
Okie dokie, thanks Hotte :)
Waiting to hear some feedback from you guys. :banana:

Kars10
07-28-2002, 09:59 AM
Hello Guys!!
My Serach works great, and my users love it!!
Is there any way to put this options in the websearch??
See Attachment!!
Thanx!! :D

maligno
07-28-2002, 10:08 AM
Thank you nuno, very kind

CJi
07-28-2002, 11:43 AM
Hmm, I just seem to get the DIME CVS log when I submit a search?

CJi
07-28-2002, 12:30 PM
ok, found the problem.

Doesn't work with php version below 4.1 :(

CJi
07-29-2002, 07:56 PM
Updated php... works GREAT :)

Nice hack, well done.

tkeil69575
07-30-2002, 06:00 PM
Hi all,

im getting the following error (using php 4.2.1)

Fatal error: Call to undefined function: xml_parser_create() in /bla/bla/pear/SOAP/Parser.php on line 93

any Ideas?

Tina

Sparkz
07-30-2002, 07:15 PM
You need to configure your PHP with xml support.
You can find more info here: http://www.php.net/manual/en/ref.xml.php

tkeil69575
07-30-2002, 07:41 PM
Hi Sparkz,
thanks for the info. I thought that would be it but wasnt sure.

got it working now - great stuff!

Regit
08-18-2002, 02:23 PM
How can make the result can display chinese or japanese ....
those asian language ...
my return result all that name become "?" ....

any idea ? thanks

Regit
08-21-2002, 08:28 AM
no one know how to dispaly the chinese in the result page ??
because all the asian language become "?" in my forum !

Regit
08-27-2002, 08:43 AM
hey , why no body answer my question ??
really no one know the answer ??

Brad
09-16-2002, 05:44 AM
it "works" however i get this above the header template when i get the search results


Notice: Undefined variable: pagenumber in /home/kousetsu/public_html/kan/websearch.php on line 15

Notice: Undefined property: URL in /home/kousetsu/public_html/kan/websearch.php on line 35

Notice: Undefined property: snippet in /home/kousetsu/public_html/kan/websearch.php on line 36

Notice: Undefined property: title in /home/kousetsu/public_html/kan/websearch.php on line 38

Notice: Use of undefined constant template - assumed 'template' in /home/kousetsu/public_html/kan/admin/functions.php on line 1140

Notice: Undefined variable: searchbit in /home/kousetsu/public_html/kan/websearch.php(40) : eval()'d code on line 1

Notice: Undefined variable: pagenumber in /home/kousetsu/public_html/kan/websearch.php on line 45

Notice: Undefined variable: curpage in /home/kousetsu/public_html/kan/admin/functions.php on line 36

Notice: Undefined variable: pagenav in /home/kousetsu/public_html/kan/admin/functions.php(46) : eval()'d code on line 1

Notice: Undefined variable: firstlink in /home/kousetsu/public_html/kan/admin/functions.php(52) : eval()'d code on line 1

Notice: Undefined variable: prevlink in /home/kousetsu/public_html/kan/admin/functions.php(52) : eval()'d code on line 1

Notice: Use of undefined constant template - assumed 'template' in /home/kousetsu/public_html/kan/admin/functions.php on line 1140

Notice: Use of undefined constant template - assumed 'template' in /home/kousetsu/public_html/kan/admin/functions.php on line 1140

Notice: Undefined variable: debug in /home/kousetsu/public_html/kan/admin/functions.php on line 593

Mike11212
09-28-2002, 11:07 AM
Originally posted by Link14716
I did, but I still couldn't find it :(

EDIT: I just saw the search box and found it :)

Go to where you find the SOAP_Google.php file at theres a tar of SOAP there

corn
11-04-2002, 03:39 PM
When I try to use the search, I see the following message:

Warning: open_basedir restriction in effect. File is in wrong directory in /www/htdocs/joost/forum/websearch.php on line 13

Warning: open_basedir restriction in effect. File is in wrong directory in /www/htdocs/joost/pear/SOAP_Google.php on line 18

Warning: open_basedir restriction in effect. File is in wrong directory in /www/htdocs/joost/pear/SOAP/Client.php on line 23

Warning: open_basedir restriction in effect. File is in wrong directory in /www/htdocs/joost/pear/SOAP/Value.php on line 22

Warning: open_basedir restriction in effect. File is in wrong directory in /www/htdocs/joost/pear/SOAP/Base.php on line 37

What's that means

Xyphen
02-23-2003, 02:43 PM
This hack is awesome, but I want to see a Live Demo before installing it, also a new version a bug-free version would be GREAT! :nervous: