view release on metacpan or search on metacpan
cgi/archive.cgi view on Meta::CPAN
use OnSearch::AppConfig;
use OnSearch::Base64;
use OnSearch::CGIQuery;
use OnSearch::UI;
use OnSearch::Utils;
use OnSearch::WebLog;
use OnSearch::WebClient;
my $cfg = OnSearch::AppConfig -> new;
my $prefs_val = undef;
my $q = OnSearch::CGIQuery -> new;
$q -> parsequery;
my $ui = OnSearch::UI -> new;
if ($ENV{HTTP_REFERER} =~ /archive\.(shtml|cgi)/) {
my $req_method = $ENV{REQUEST_METHOD};
###
### POST means that a file is being uploaded.
cgi/archive.cgi view on Meta::CPAN
print FILE $file;
close FILE;
$/ = $oldrs if $oldrs;
} elsif ($req_method =~ /GET/ && $q -> {targeturl}) {
###
### Here it means we're indexing a Web page or a Web site.
###
my ($yeardate, $proto_name, $server, $port, $path);
my ($app_uri, $l, @lines, $dirtree, $serverdirname);
my ($robotspage, $robotsfile, $page, $client_pid);
$prefs_val = $cfg -> webidx_prefs_val ($q);
($proto_name, $server, $port, $path) = parse_url ($q->{targeturl});
unless ($server) {
browser_warn ("Could not index URL: " . $q -> {targeturl} .'.');
exit 1;
}
$webbot = OnSearch::WebBot -> new;
$serverdirname = (($port == 80) ? "/$server" : "/$server:$port");
if ($robotspage) {
$robotsfile = OnSearch::RobotsDotTxt -> new;
$robotsfile -> parse ($robotspage);
cgi/archive.cgi view on Meta::CPAN
if (! $page || $page =~ m|HTTP/1.[01]\s+[45](\d+)|) {
$page = 'Error requesting page.' unless $page;
browser_warn ($q->{targeturl} . ": $page");
exit 1;
}
$webbot -> cache_page ($page, $q -> param_value (qw/targeturl/));
}
}
}
my (@cookies, $key, $val, $prefs);
$prefs = 'defaults';
if (($ENV{HTTP_COOKIE}) && (! $prefs_val)) {
@cookies = split /\;\s?/, $ENV{HTTP_COOKIE};
($val) = grep (/webidx/, @cookies);
if ($val) {
($val) = $val =~ /.*?\=(.*)/;
$prefs = $cfg -> get_prefs ($val);
}
} elsif ($prefs_val) {
$prefs = $cfg -> get_prefs ($prefs_val);
}
if (defined ($prefs_val)) {
# Expire cookie in a year.
my $yeardate = OnSearch::Utils::http_date (31536000);
$ui -> header_cookie ('OnSearch', 'webidx', $prefs_val,
$yeardate) -> wprint;
} else {
$ui -> header_css ('OnSearch') -> wprint;
}
$ui -> navbar_map -> wprint;
$ui -> javascripts -> wprint;
$ui -> navbar -> wprint;
$ui -> archive_title -> wprint;
$ui -> webindex_form ($prefs) -> wprint;
$ui -> fileindex_form -> wprint;
$ui -> html_footer -> wprint;
cgi/filters.cgi view on Meta::CPAN
BEGIN { use Config; unshift @INC, ("./lib", "./lib/$Config{archname}"); }
use OnSearch;
use OnSearch::Base64;
use OnSearch::CGIQuery qw/:all/;
use OnSearch::UI;
my $c = OnSearch::AppConfig -> new;
my @vols_selected;
my %vols = $c -> Volumes ();
my $prefs = 'Default';
my (@cookies, $key, $val);
my $ui_obj = OnSearch::UI -> new;
my $vol_query = new OnSearch::CGIQuery;
$vol_query -> parsequery ();
###
### Delete query instance variables because they won't be
### needed here.
###
delete $vol_query->{$_} foreach (qw /pwd regex displayregex context
cache ppid sid/);
if ($ENV{HTTP_REFERER} =~ /filters\.(shtml|cgi)/) {
my %vols_prefs;
foreach my $k (keys %$vol_query) {
next if $k =~ /submit\.(x|y)/;
push @vols_selected, ($k);
}
my $val = $c -> vols_prefs_val (\@vols_selected);
my $yearexpdate = OnSearch::Utils::http_date (31536000);
$ui_obj -> header_cookie ('OnSearch', 'onsearchvols', $val,
$yearexpdate)
-> wprint;
} else {
if ($ENV{HTTP_COOKIE}) {
@cookies = split /\;\s?/, $ENV{HTTP_COOKIE};
($val) = grep (/onsearchvols/, @cookies);
if ($val) {
($val) = $val =~ /.*?\=(.*)/ if $val;
$prefs = $c -> get_prefs ($val);
@vols_selected = split /,/, $prefs;
}
}
$ui_obj -> header_css ('OnSearch') -> wprint;
}
$ui_obj -> navbar_map -> wprint;
$ui_obj -> javascripts -> wprint;
$ui_obj -> navbar -> wprint;
$ui_obj -> volume_form (\%vols, \@vols_selected) -> wprint;
cgi/main.cgi view on Meta::CPAN
my $ui = OnSearch::UI -> new;
my $cfg = OnSearch::AppConfig -> new;
unless ($cfg -> have_config) {
$cfg -> read_config ('onsearch.cfg');
$ui -> header_css -> wprint;
$ui -> critical_error_form ("Missing \"SearchRoot\" directive<br>in onsearch.cfg") -> wprint;
exit (1);
}
my (@cookies, $key, $val, $prefs, $vol_prefs);
$prefs = 'defaults';
$vol_prefs = 'Default';
if ($ENV{HTTP_COOKIE}) {
@cookies = split /\;\s?/, $ENV{HTTP_COOKIE};
($val) = grep (/onsearchprefs/, @cookies);
if ($val) {
($val) = $val =~ /.*?\=(.*)/ if $val;
$prefs = $cfg -> get_prefs ($val);
}
($val) = grep (/onsearchvols/, @cookies);
if ($val) {
($val) = $val =~ /.*?\=(.*)/ if $val;
$vol_prefs = $cfg -> get_prefs ($val);
}
}
$ui -> header_css ('OnSearch') -> wprint;
$ui -> navbar_map -> wprint;
$ui -> javascripts -> wprint;
$ui -> navbar -> wprint;
$ui -> input_form ($prefs, $vol_prefs) -> wprint;
$ui -> html_footer -> wprint;
cgi/search.cgi view on Meta::CPAN
}
if ($cfg -> lst ('ExcludeDir')) {
my @excdirs = $cfg -> lst ('ExcludeDir');
push @{$q->{excludedirs}}, @excdirs;
}
my @tlds;
my %volumes = $cfg -> Volumes ();
my $vol_prefs = 'Default';
if ($ENV{HTTP_COOKIE}) {
@cookies = split /\;\s?/, $ENV{HTTP_COOKIE};
($val) = grep (/onsearchvols/, @cookies);
if ($val) {
($val) = $val =~ /.*?\=(.*)/ if $val;
$vol_prefs = $cfg -> get_prefs ($val);
}
my @preflist = split /,/, $vol_prefs;
foreach my $k (keys %volumes) {
next unless scalar grep /$k/, @preflist;
push @tlds, ($volumes{$k});
}
} else {
push @tlds, ($volumes{Default});
}
my $extcode_s;
if (($extcode_s = perform_search ($q, \@tlds)) == 0) { exit }
lib/OnSearch/AppConfig.pm view on Meta::CPAN
package OnSearch::AppConfig;
#$Id: AppConfig.pm,v 1.8 2005/07/24 07:57:21 kiesling Exp $
require Exporter;
require DynaLoader;
use OnSearch::Utils;
our (@ISA, @EXPORT_OK);
@ISA = qw(Exporter DynaLoader);
@EXPORT_OK = (qw/webidx_prefs_val new DESTROY/);
=head1 NAME
OnSearch::AppConfig - Configuration library for OnSearch search engine.
=head1 DESCRIPTION
OnSearch::AppConfig provides an object oriented configuration library
that dynmaically manages the configuration of an operating search engine.
lib/OnSearch/AppConfig.pm view on Meta::CPAN
}
close CFG;
return $Config;
}
###
### In general, run-time changes cannot be made to OnSearch's
### pathnames or permissions, and they are not recognized here.
###
### We should not need to re-write global prefs anyway, because
### the user settings are stored in the cookies.
###
###sub write_pref {
### my $label = $_[0];
### my $value1 = $_[1];
### my $value2 = $_[2];
### my $line;
### my $app_dir = $ENV{DOCUMENT_ROOT} . '/' .
### OnSearch::AppConfig -> str ('OnSearchDir');
### my $cfgpath = "$app_dir/onsearch.cfg";
lib/OnSearch/AppConfig.pm view on Meta::CPAN
### print NEWCONFIG "$label $value1 $value2\n";
### }
### print NEWCONFIG $line;
### }
###
### close NEWCONFIG;
### close OLDCONFIG;
### rename ($newcfgpath, $cfgpath);
###}
=head2 $cfg -> prefs_val (I<query_object>);
Formats and encodes the value of a search preferences cookie from the
OnSearch::CGIQuery object given as the argument.
=cut
sub prefs_val {
my $ref = $_[0];
my $q = $_[1];
my $prefs_str = "<prefs>\n" .
" <param name=\"matchcase\">" . $q->param_value('matchcase') . "</param>\n" .
" <param name=\"matchtype\">" . $q->param_value('matchtype') . "</param>\n" .
" <param name=\"partword\">".$q->param_value('partword')."</param>\n" .
" <param name=\"pagesize\">".$q->param_value('pagesize')."</param>\n" .
" <param name=\"nresults\">".$q->param_value('nresults')."</param>\n" .
"</prefs>\n";
$prefs_str = OnSearch::Base64::encode_base64 ($prefs_str);
$prefs_str =~ s/\n/!!/gm;
return $prefs_str;
}
=head2 webidx_prefs_val (I<query_object>);
Formats the value of the Web index cookie from the values in
the OnSearch::CGIQuery object given as the argument.
=cut
sub webidx_prefs_val {
my $self = $_[0];
my $q = $_[1];
$prefs_str ='<prefs>' . "\n" .
'<param name="targetscope">'.$q -> param_value('targetscope').'</param>'."\n".
'</prefs>' . "\n";
$prefs_str = OnSearch::Base64::encode_base64 ($prefs_str);
$prefs_str =~ s/\n/!!/gm;
return $prefs_str;
}
=head2 $cfg -> vols_prefs_val (I<query_object>);
Formats the value of the volume preferences cookie from the values in
the argument's OnSearch::CGIQuery object
=cut
sub vols_prefs_val {
my $self = $_[0];
my $volref = $_[1];
my $volumes = join ',', @{$volref};
my $volumes_str = OnSearch::Base64::encode_base64 ($volumes);
$volumes_str =~ s/\n/!!/gm;
return $volumes_str;
}
=head2 $cfg -> get_prefs (I<value>);
Return the preferences from the cookie value given in the argument.
=cut
sub get_prefs {
my $self = $_[0];
my $val = $_[1];
$val =~ s/!!/\n/g;
return OnSearch::Base64::decode_base64 ($val);
}
=head2 $cfg -> parse_prefs (I<str>);
Return a hash of preference key/value pairs.
=cut
sub parse_prefs {
my $self = $_[0];
my $prefs_str = $_[1];
my %prefs_hash;
return undef if $prefs_str =~ /none/;
my @prefs_list = split /\n/, $prefs_str;
my ($attrib, $val);
foreach my $p (@prefs_list) {
next if $p !~ /\s*<param/;
($attrib, $val) =
$p =~ /\s*<param name="(.*)">(.*)</;
$prefs_hash{$attrib} = $val;
}
return %prefs_hash;
}
=head2 $cfg -> Volumes ();
Return a hash of the volumes configured in F<onsearch.cfg.>
=cut
sub Volumes {
my $self = $_[0];
lib/OnSearch/Cache.pm view on Meta::CPAN
sub cache_path {
my $cfg = OnSearch::AppConfig -> new;
my $onsearchdir = $cfg -> str (qw/OnSearchDir/);
undef $cfg;
return $ENV{DOCUMENT_ROOT} . "/$onsearchdir/cache";
}
sub get_selected_volumes {
my ($r, $k, $val, @cookies, $vol_prefs);
my $c = OnSearch::AppConfig -> new;
my %vols = $c -> Volumes;
my @voldirs;
if ($ENV{HTTP_COOKIE}) {
@cookies = split /\;\s?/, $ENV{HTTP_COOKIE};
($val) = grep (/onsearchvols/, @cookies);
if ($val) {
($val) = $val =~ /.*?\=(.*)/ if $val;
$vol_prefs = $c -> get_prefs ($val) if $val;
}
if (! $val) {
push @voldirs, ($vols{Default});
} else {
my @preflist = split /,/, $vol_prefs;
foreach $k (keys %vols) {
next unless scalar grep /$k/, @preflist;
push @voldirs, ($vols{$k});
}
}
}
return @voldirs;
}
1;
lib/OnSearch/Results.pm view on Meta::CPAN
my $ppid = $_[0];
my $resultspid = $_[1];
my ($l, $rec, $r, $q, $buf, @lines, $linebuf);
$q = $ui_obj -> {q};
$ui_obj -> {firstpagedisplayed} = 0;
# Expire cookie in a year.
my $yearexpdate = OnSearch::Utils::http_date (31536000);
$ui_obj -> header_cookie ('OnSearch', 'onsearchprefs',
OnSearch::AppConfig->prefs_val ($ui_obj -> {q}),
$yearexpdate)
-> wprint;
local $SIG{ALRM} = \&client_ping;
alarm 30;
###
### Try to save the results before exiting if the Web server sends
### a SIGINT.
###
lib/OnSearch/UI.pm view on Meta::CPAN
=head2 $ui -> input_form (I<search_preferences>, I<volume_preferences>);
OnSearch search page template. The arguments are hash references
of user preferences.
=cut
sub input_form {
my $self = shift;
my $prefs = $_[0];
my $vol_prefs = $_[1];
my ($case_opt, $nocase_opt, $matchany_opt, $matchall_opt,
$partword_opt,$matchexact_opt, $completeword_opt, $pagesize_opt,
%dfmatch, $nresults_opt, %volumes, $OnSearchDir);
$case_opt = $nocase_opt = '';
$matchany_opt = $matchall_opt = $matchexact_opt = '';
$partword_opt = $completeword_opt = '';
my $c = OnSearch::AppConfig -> new;
%volumes = $c -> Volumes;
$OnSearchDir = $c -> str (qw/OnSearchDir/);
$self -> volume_info (\%volumes, $vol_prefs);
my $volinfo = $self -> {text};
if ($prefs !~ /defaults|none/) {
my %prefs = $c->parse_prefs ($prefs);
(($prefs{matchcase} =~ /yes/) ? $case_opt = 'checked' :
$nocase_opt = 'checked');
$partword_opt = ($prefs{partword} =~ /yes/) ? 'checked' : '';
$completeword_opt = ($prefs{partword} =~ /no/) ? 'checked' : '';
foreach (@matchtypes) {
$dfmatch{$_} = (m"$prefs{matchtype}" ? 'checked' : '');
}
$pagesize_opt = $prefs{pagesize};
$nresults_opt = $prefs{nresults};
} else {
###
### These are the default search options.
###
$case_opt = 'checked';
$dfmatch{$_} = '' foreach (@matchtypes);
$dfmatch{any} = 'checked';
$completeword_opt = 'checked';
$pagesize_opt = $c->str ('PageSize');
lib/OnSearch/UI.pm view on Meta::CPAN
}
=head2 $ui -> webindex_form (I<preferences>);
Template for the Web index form.
=cut
sub webindex_form {
my $self = shift;
my $prefs = $_[0];
my ($pagescope_opt, $sitescope_opt, %prefs, $cfg, $OnSearchDir);
$cfg = OnSearch::AppConfig -> new;
$OnSearchDir = $cfg -> str (qw/OnSearchDir/);
if ($prefs =~ /defaults/) {
$pagescope_opt = 'checked';
$sitescope_opt = '';
} else {
%prefs = OnSearch::AppConfig->parse_prefs ($prefs);
$pagescope_opt = ($prefs{targetscope} =~ /page/) ? 'checked' : '';
$sitescope_opt = ($prefs{targetscope} =~ /site/) ? 'checked' : '';
}
$self -> {text} =<<EOT;
<form action="archive.cgi">
<table width="75%" align="center">
<colgroup>
<col width="75%">
<col width="25%">
<tr>
<td valign="top">
lib/OnSearch/UI.pm view on Meta::CPAN
<input type="image" name="submit" class="search" src="/$OnSearchDir/images/update.jpg">
</td>
</tr>
</colgroup>
</table>
</form>
EOT
return $self;
}
=head2 $ui -> volume_info (I<volume_list>, I<user_prefs>);
Matches site volume information with user preferences.
=cut
sub volume_info {
my $self = $_[0];
my $vol_ref = $_[1];
my $vol_prefs = $_[2];
my $c = OnSearch::AppConfig -> new;
my ($vol, $vol_name, $v, $k, @selected);
@selected = split /,/, $vol_prefs;
$self -> {text} = qq|<label><strong>Volumes Selected:</strong>\n|;
$self -> {text} .= qq|<table>\n|;
foreach my $k (keys %{$vol_ref}) {
next unless scalar grep /$k/, @selected;
$self -> {text} .= qq|<tr><td><label>$k</label></td></tr>\n|;
}
$self -> {text} .= qq|</table>\n|;
return $self;
}