View previous topic :: View next topic |
Author |
Message |
kbfromindia -
Joined: 21 Apr 2005 Posts: 1
|
Posted: Thu Apr 21, 2005 1:35 pm Post subject: Small Powerful Perl Search Engine For Abyss Web Server |
|
|
Code: |
# This Program Searches All the Alias Directories Files and Files Contents and Shows the Search Results
#
# This will work only for Abyss Web Server X1- Windows Installed in Default Location
#
# Author: Kaushik Biswas
# Email: kbfromindia@yahoo.co.in
use XML::Simple;
use CGI qw(:standard);
$ABYSSPATH = "C:\\Program Files\\Abyss Web Server\\abyss.conf";
$cgi = new CGI;
print $cgi->header();
######## Search Form ###############################
print <<EOF ;
<Title>KB's Search Engine</Title>
<H3>KB's Search Engine</H3>
<form method=post>
<input name=searchstring><input type = submit>
</form>
EOF
####################################################
$stext = $cgi->param('searchstring');
if($stext eq ""){die;}
print "<hr><H3>KB's Search Result For : $stext</H3>";
print "\n<hr>\n";
$stext =~ s/ /.*/g;
$surl = "http://$ENV{SERVER_NAME}";
$xml = new XML::Simple;
$data = $xml->XMLin($ABYSSPATH);
######### ROOT #####################################
$rpath = trim($data->{server}->{parameters}->{root});
$rdocs = trim($data->{server}->{host}->{path});
search("/","$rpath$rdocs");
####################################################
######### ALIAS ###################################
$cnt = 0;
do
{
$h = $data->{server}->{host}->{aliases}->{alias}[$cnt++];
search($h->{virtual},$h->{real});
} until ($aname eq "");
####################################################
print "\n<br><hr>\n";
sub trim{
($txt) = @_;
$txt =~ s/^\s+//;
$txt =~ s/\s+$//;
return $txt;
}
sub search{
($aname, $apath) = @_;
$aname =~ s/\s//g;
$apath = trim($apath);
if($apath =~ m/:\\/)
{
for $fname (`dir "$apath" /B /S`)
{
open F, "$fname";
$fname =~ s/\\/\//g;
chomp($fname);
$fname = substr($fname, length($apath)+1);
$spath = $surl.$aname."/".$fname;
$spath = "<br><a href='$surl$aname/$fname'>$fname</a><br>\n";
if($fname=~ m/$stext/i) { print $spath;close F}
if($fname !~ m/\.doc|\.htm|\.txt/i){close F}
while(<F>)
{
if($_=~ m/$stext/i) { print $spath;close F}
}
close F;
}
}
}
|
|
|
Back to top |
|
|
aprelium -
Joined: 22 Mar 2002 Posts: 6800
|
Posted: Thu Apr 21, 2005 5:40 pm Post subject: Re: Small Powerful Perl Search Engine For Abyss Web Server |
|
|
kbfromindia,
Thank you for the contribution. By the way, this script works only on Abyss Web Server X1 version >= 2. It won't work on versions 1.x.
If you have not installed Abyss Web Server in C:\Program Files\Abyss Web Server, change the value of $ABYSSPATH to suit your actual setup path. _________________ Support Team
Aprelium - http://www.aprelium.com |
|
Back to top |
|
|
Vahn -
Joined: 10 Aug 2005 Posts: 51 Location: At my computer
|
Posted: Fri Aug 12, 2005 5:31 am Post subject: |
|
|
A few questions about this script, Where do you place all of this script and does it only search alisis Directories?
~Vahn |
|
Back to top |
|
|
aprelium -
Joined: 22 Mar 2002 Posts: 6800
|
Posted: Fri Aug 12, 2005 12:22 pm Post subject: |
|
|
Vahn,
You can place it anywhere inside your web site directory.
It searches the Documents Path and the aliases (all your web site). _________________ Support Team
Aprelium - http://www.aprelium.com |
|
Back to top |
|
|
Vahn -
Joined: 10 Aug 2005 Posts: 51 Location: At my computer
|
Posted: Sat Aug 13, 2005 5:02 am Post subject: |
|
|
And what do you name it... and file extensions...
Sorry for the inconveance
~Vahn D. Clark |
|
Back to top |
|
|
aprelium -
Joined: 22 Mar 2002 Posts: 6800
|
Posted: Sat Aug 13, 2005 12:46 pm Post subject: |
|
|
Vahn wrote: | And what do you name it... and file extensions...
Sorry for the inconveance
~Vahn D. Clark |
Add Perl support and create inside htdocs/ (for example) a file called search.pl (for example, the file extension should be pl or cgi) and put the above code in it.
Next browse http://yoursite/search.pl and enjoy. _________________ Support Team
Aprelium - http://www.aprelium.com |
|
Back to top |
|
|
Vahn -
Joined: 10 Aug 2005 Posts: 51 Location: At my computer
|
Posted: Sat Aug 13, 2005 10:33 pm Post subject: |
|
|
-Blinks quietly as if a joke had went completely over his head-
Ok! ^_^
~Vahn _________________ A ship in the harbor is safe, But thats not what Ships were Built for. ~ John Shedd
Success Comes before Work only in the Dictionary ~ Harvey Mackay
|
|
Back to top |
|
|
|