Commit 819948a2 authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

Not used

parent aecafd64
#!wml -oindex.html
#use wml::openldap::openldap area=find subarea=main page=main
<page_title name="Find"
keywords="find, search, site map, site map"
description="Search OpenLDAP site by keyword or phrase"
Search the OpenLDAP site by keyword or phrase.
The operators AND, OR, and NOT are supported. If you enter
multiple words <i>without</i> an operator, the AND operator
is implied. The search is not case sensitive.
<form method=GET action="results.epl">
<td align=right><face>Search String:</face></td>
<td rowspan=3><space width=5 heigth=1></td>
<td><input type=txt name=query size=32 maxlength=80></td>
<td align=right><face>Limit Results:</face></td>
<td><input type=txt name=results value=20 size=2 maxlength=2></td>
<td><input type=submit><space width=10 height=1><input type=reset></td>
#!wml -oresults.epl
#use wml::openldap::openldap area=find subarea=search page=results header=off
<page_title name="Search Results"
keywords="search results, results"
description="Search Results"
# ePerl!
#- Configurable Variables ---------------------------------------------------#
#Our host
$host = "";
#Path to SWISH-E executable
$swish = "/usr/local/bin/swish-e";
#Path to this CGI script
$swishcgi = "/find/";
#Path to the SWISH-E index
$index = "/data/www/sites/$host/find/swish-e.idx";
#Path to the SWISH-E configuration file
$config = "/usr/local/etc/apache/swish-e/${host}.cf";
#- Main Program -------------------------------------------------------------#
#Parse the form data
&parse_form_data (*FORM);
#Construct a simple query
$query = $FORM{'query'};
$results = $FORM{'results'};
$results = "10" unless ($results);
if ($query) {
&search_error("You must enter a keyword or phrase in one or more of the text boxes");
#- Subroutines ---------------------------------------------------------------#
#Subroutine for checking and parsing the incoming form data.
sub parse_form_data {
local (*FORM_DATA) = @_;
local ($request_method, $query_string, @key_value_pairs, $key_value, $key, $value);
$request_method = $ENV{'REQUEST_METHOD'};
if ($request_method eq "GET") {
$query_string = $ENV{'QUERY_STRING'};
} elsif ($request_method eq "POST") {
read (STDIN, $query_string, $ENV{'CONTENT_LENGTH'});
} else {
&search_error ("Forms must use either GET or POST.");
@key_value_pairs = split (/&/, $query_string);
foreach $key_value (@key_value_pairs) {
($key, $value) = split (/=/, $key_value);
$value =~ tr/+/ /;
$value =~ s/%([\dA-Fa-f][\dA-Fa-f])/pack ("C", hex ($1))/eg;
if (defined ($FORM_DATA{$key})) {
$FORM_DATA{$key} = join ("\0", $FORM_DATA{$key}, $value);
} else {
$FORM_DATA{$key} = $value;
#Subroutine for constructing the Swish-E search request and formating the results.
sub search_parse {
#Create your SWISH-E query command
$cmd ="$swish -w '$query' -m '$results' -f '$index' |";
open(SWISH, $cmd) or
return &search_error("open failed: $cmd");
while (<SWISH>) {
# Check for errors
if ($_ eq "err: no results") {
&search_error("There were no items that matched your search request");
if ($_ eq "err: could not open index file") {
&search_error("Could not open SWISH Index File $index");
if ($_ eq "err: no search words specified") {
&search_error("Please Enter at least one Search Word");
if ($_ eq "err: a word is too common") {
"One of your search terms is too common, please try again");
next if /^\D/;
push(@results, $_);
#Print the results page
&html_header("Search Results");
print <<Search_Results;
Your search for <strong>$query</strong> returned
<tt>$count</tt> items of <tt>$results</tt> requested.
In order of computed relevance, they are:<br>
foreach (@results) {
($stringone, $title, $filesize) = split(/\"/, $_);
($rank, $url) = split(/ /, $stringone);
print "<li><a href=\"$url\">$title</a>\n";
print "</ul>\n";
#Subroutine for printing a generic HTML header.
sub html_header {
my $h = $_[0];
print <<HTML_Header;
#Subroutine for printing a generic HTML trailer.
sub html_trailer {
#Subroutine for printing error messages.
sub search_error {
&html_header("Search Error");
$error_message = $_[0];
print "<P>\n$error_message</P>\n";
#!wml -ositemap.html
#use wml::openldap::openldap area=find subarea=sitemap
<page_title name="Site Map"
keywords="find, site map, pages, index, toc, table of contents, index"
description="A map of the <openldap> site"
<a href="../">Main Page</a>
<li><a href="../project/">Project</a>
<li><a href="../foundation/">Foundation</a>
<li><a href="../software/">Software</a>
<li><a href="../devel/">Development</a>
# SWISH-E Configuration file for:
# Master index
IndexDir /data/www/sites/pages
IndexFile /data/www/sites/
MetaNames swish-keywords swish-description
IndexName ""
IndexDescription "Index of OpenLDAP"
IndexPointer ""
IndexAdmin "OpenLDAP Webmaster <>"
IndexOnly .html .txt .phtml
IndexReport 2
FollowSymLinks no
NoContents .gif .xbm .au .mov .mpg .pdf .ps
ReplaceRules replace "/data/www/sites/" "/"
ReplaceRules replace "/data/www/sites/pages/" "/"
ReplaceRules replace "/data/www/share/icons" "/icons"
ReplaceRules replace "/data/www/share/cgi-bin" "/cgi-bin"
ReplaceRules replace "/index.html" "/"
ReplaceRules replace "/index.htm" "/"
ReplaceRules replace "/index.shtml" "/"
ReplaceRules replace "/index.phtml" "/"
ReplaceRules replace "/index.cgi" "/"
FileRules pathname contains restricted CVS
FileRules filename is robots.txt
FileRules filename is results.phtml
FileRules filename contains % ~ .bak .orig .old old. ORIG. .wmlrc .wml .idx #
FileRules title contains DRAFT
IgnoreLimit 80 50
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment