Link to home
Start Free TrialLog in
Avatar of usmansultan
usmansultanFlag for Australia

asked on

How to transfer across Search Engines during Website Transition.

I am transferring the website, link for the live website is http://www.response-systems.com, and the link for the one on which i am going to transfer the website is; http://rere6659.staging-zeus.netregistry.net, i am having trouble in transferring across the search engine and the knowledgebase page, now the code for the search engine is i believe written in Perl, and i am not sure how can i make it work under the staging website. I am going to paste the code for search.pl
Let me know if you guys need anything else.......
#!/usr/bin/perl --
#use warnings 'all';#if-debug
#use strict;#if-debug
 
=head1 copyright
 
Fluid Dynamics Search Engine
 
Copyright 1997-2005 by Zoltan Milosevic.  Please adhere to the copyright
notice and conditions of use, described in the attached help file and hosted
at the URL below.  For the latest version and help files, visit:
 
	http://www.xav.com/scripts/search/
 
This search engine is managed from the web, and it comes with a password to
keep it secure.  You can set the password when you first visit this script
using the special "Mode=Admin" query string - for example:
 
	http://my.host.com/search.pl?Mode=Admin
 
If you edit the source code, you'll find it useful to restore the function comments and #&Assert checks:
 
	cd "search/searchmods/powerusr/"
	hacksubs.pl build_map
	hacksubs.pl restore_comments
	hacksubs.pl assert_on
 
<h1>If you can see this text from a web browser, then there is a problem. <a
href="http://www.xav.com/scripts/search/help/1089.html">Get help here.</a></h1><xmp>
 
=cut
 
$::VERSION = '2.0.0.0073';
%::FORM = ();
 
my $all_code = "\n" x 36 . <<'END_OF_FILE';
 
my $err = '';
Err: {
 
	# initialize and schedule clean-up for package globals:
	$::realms = undef();
	%::private = %::FORM = %::const = %::Rules = @::str = ();
	@::sendmail = (
		'/usr/sbin/sendmail -t',
		'/usr/bin/sendmail -t',
		'/usr/lib/sendmail -t',
		'/usr/sendmail -t',
		'/bin/sendmail -t',
		);
	END {
		$::VERSION = $::realms = undef();
		%::private = %::FORM = %::const = %::Rules = @::str = @::sendmail = ();
		}
 
	# clear ENV for -T compatibility
	block: {
		last block if ( #changed 0072 mod_perl compat issue
			(exists $ENV{'GATEWAY_INTERFACE'} and $ENV{'GATEWAY_INTERFACE'} =~ /CGI-Perl/)
			or exists $ENV{'MOD_PERL'} );
		local $_;
		foreach ('IFS','CDPATH','ENV','BASH_ENV','PATH') {
			delete $ENV{$_} if (defined($ENV{$_}));
			}
		}
 
	binmode(STDOUT);
 
	#high-explosive hash option
#	tie(%::private,'FDSC::HEH');#if-debug
#	tie(%::Rules,'FDSC::HEH');#if-debug
#	tie(%::const,'FDSC::HEH');#if-debug
 
	%::private = (
		'antiword utility folder'  => "",
		'pdf utility folder' => "",
		'global_lockfile_count' => 1,
		'script_start_time' => time(),
		'visitor_ip_addr' => &query_env('REMOTE_ADDR'),
		'allow_admin_access_from' => '', # space-separated list of IP addresses or IP patterns
		'file_mask' => 0666,
		'needs_header' => 1,
		'trust_api' => 0,
		'html_footer' => '',
		'inline_elements' => qq!(a|abbr|acronym|applet|b|bdo|big|button|cite|dfn|em|embed|font|i|img|input|ins|kbd|label|noscript|object|q|rt|ruby|samp|select|small|span|strong|tt|u)!,
		'p_nc_cache' => 0,
		'http_headers' => '',
		);
 
	$::private{'PRINT_HTTP_STATUS_HEADER'} = 0;
 
	%::const = (
		'is_cmd' => 0,
		'help_file' => 'http://www.xav.com/scripts/search/help/',
		'copyright' => '<p style="text-align:center"><small>Powered by the<br /><a href="http://www.xav.com/scripts/search/">Fluid Dynamics<br />Search Engine</a><br />v' . $::VERSION . '<br />&copy; 2005</small></p>',
		);
 
	# Give the folder where all data files are located
	# See http://www.xav.com/scripts/search/help/1138.html about changing this value:
 
	$err = &load_files_ex( '.' );
	next Err if ($err);
 
 
	my $terms = '';
	foreach ('Terms','terms','q') {
		next unless exists $::FORM{$_};
		$terms = $::FORM{$_};
		last;
		}
	$::FORM{'Terms'} = $::FORM{'terms'} = $::FORM{'q'} = $terms;
	$::const{'terms'} = &he($::FORM{'Terms'});
	$::const{'terms_url'} = &ue($::FORM{'Terms'});
 
	# create self-reference string:
 
	my $sn = &query_env('SCRIPT_NAME');
	$sn =~ s!^.*/(.+?)$!$1!s;
 
	if (exists $::FORM{'search_url'}) {
		$sn = &he($::FORM{'search_url'});
		}
 
	$::const{'script_name'} = $::const{'search_url'} = $sn;
	$::const{'admin_url'} = $sn . '?Mode=Admin';
	$::const{'search_url_ex'} = $sn . '?';
 
	# support persistent fields and secondary queries
	my ($n,$v);
	while (($n,$v) = each %::FORM) {
		next unless ($n =~ m!^p:!s);
		$::const{'search_url_ex'} .= &ue($n) . '=' . &ue($v) . '&amp;';
 
		if ($n =~ m!^p:t:!s) { $::const{$n} = $v; } # changed 0053 - persistent/template namespace
 
		next unless ($n =~ m!^p:q(\d+)$!s);
 
		#changed 0064 - prepend, append
 
		next unless (length($v));
		if ((exists($::FORM{"p:pq$1"})) and (exists($::FORM{"p:aq$1"}))) {
			$terms .= ' ' . $::FORM{"p:pq$1"} . $v . $::FORM{"p:aq$1"};
			}
		else {
			$terms .= ' ' . $v;
			}
		}
 
 
	# are we being called from a PHP/ASP/CFM parent?
 
	my $b_is_shell_include = ((exists($::FORM{'is_shell_include'})) and ($::FORM{'is_shell_include'} eq '1')) ? 1 : 0;
 
	my $address_offer = '';
	AddressAsTerm: {
		last unless ($::Rules{'handling url search terms'} > 1);
		last if ($b_is_shell_include);
		last if ($terms =~ m!\s!s);
		my $address = '';
		if ($terms =~ m!^(http|ftp|https|telnet)://(\w+)\.(\w+)(.*)$!s) {
			$address = $terms;
			}
		elsif ($terms =~ m!^www\.(\w+)\.(\w+)(.*)$!is) {
			$address = "http://$terms";
			}
		if ($address) {
			$address_offer = '<p>' . &pstr(23, &he($address, $address) ) . '</p>';
			if ($::Rules{'handling url search terms'} == 3) {
				&header_print( "Location: $address" );
				print $address_offer;
				last Err;
				}
			}
		}
 
 
 
	if (exists($::FORM{'NextLink'})) {
		#changed 0034 - fixes bug where NextLink contains &
		if (&query_env('QUERY_STRING') =~ m!^NextLink=(.*)$!s) {
			$::FORM{'NextLink'} = $1;
			}
		my $html_link = &he($::FORM{'NextLink'});
		# security re-director from admin screen (prevents query-string-based
		# password from showing up in referer logs of remote systems:
		&header_print();
		print qq!<head><meta http-equiv="refresh" content="0;url=$html_link"></head><a href="$html_link">$html_link</a>!;
		last Err;
		}
 
 
	# changed 0067
	my $Realm = 'All';
	block: {
 
		last unless exists $::FORM{'Realm'};
 
		if ($::FORM{'Realm'} eq '') {
			$Realm = 'All';
			}
		elsif (($::FORM{'Realm'} eq 'All') or ($::FORM{'Realm'} eq 'include-by-name')) {
			# reserved names; ok
			$Realm = $::FORM{'Realm'};
			}
		else {
			# explode if invalid $Realm param is passed, but special-case for All include-by-name and empty
			my $p_realm;
			($err, $p_realm) = $::realms->hashref( $::FORM{'Realm'} );
			next Err if ($err);
			$Realm = $::FORM{'Realm'};
			}
 
		}
 
 
	$::const{'realm'} = &he($Realm);
 
	if ($::FORM{'Mode'} eq 'Admin') {
		$err = &admin_main();
		next Err if ($err);
		last Err;
		}
 
	if (($b_is_shell_include) and (not $ARGV[0])) {
		$err = "the 'is_shell_include' parameter can only be set when this script is being called from the command line";
		next Err;
		}
 
	if ($b_is_shell_include) {
		$::private{'needs_header'} = 0;
		}
 
 
 
	$::const{'copyright'} =~ s!<br />! !sg;
 
	&header_print();
 
	#changed 0058 - hard validate
	if ((exists($::FORM{'Match'})) and length($::FORM{'Match'})) {
		if ($::FORM{'Match'} =~ m!^(0|1|2)$!s) {
			# ok
			}
		else {
			my $hval = &he($::FORM{'Match'});
			$err = "parameter 'Match' value '$hval' is invalid. Must be 0, 1 or 2";
			next Err;
			}
		}
	else {
		$::FORM{'Match'} = $::Rules{'default match'};
		}
	if ((exists($::FORM{'maxhits'})) and length($::FORM{'maxhits'})) {
		if (($::FORM{'maxhits'} =~ m!^\d+$!s) and ($::FORM{'maxhits'} > 0)) {
			# ok
			}
		else {
			my $hval = &he($::FORM{'maxhits'});
			$err = "parameter 'maxhits' value '$hval' is invalid. Must be a positive integer";
			next Err;
			}
		}
	else {
		$::FORM{'maxhits'} = $::Rules{'hits per page'};
		}
 
 
 
	#changed 0058
	if (($::Rules{'logging: display most popular'}) and ($::Rules{'use dbm routines'})) {
		eval {
			my %str_t20 = ();
 
			dbmopen( %str_t20, 'dbm_strlog_top', 0666 ) || die &pstr( 43, 'dbm_strlog_top', $! );
 
			$::const{'t_since'} = &FormatDateTime( $str_t20{'++'}, $::Rules{'ui: date format'} );
			my $count = 1;
			foreach (sort { $str_t20{$b} <=> $str_t20{$a} || $a cmp $b } keys %str_t20) {
				next if (m!^\++$!s);
				$::const{ 'tu' . $count } = &ue( &hd($_) );
				$::const{ 'th' . $count } = $_;
				$::const{ 'c' . $count } = $str_t20{$_};
				$::const{'c'.$count}++ if ($::const{'terms'} eq $_);#tweakui
				$count++;
				last if ($count > $::Rules{'logging: display most popular'});
				}
			for ($count..$::Rules{'logging: display most popular'}) {
				$::const{ 'tu' . $_ } = '';
				$::const{ 'th' . $_ } = '';
				$::const{ 'c' . $_ } = '';
				}
			};
		if ($@) {
			&ppstr(53, &pstr(20, &he($@), "$::const{'help_file'}1169.html" ) );
			}
		}
 
 
 
	#changed 0046
	if ($::FORM{'Mode'} eq 'SearchForm') {
		print &str_search_form($::const{'search_url'});
		last Err;
		}
 
	unless ($b_is_shell_include) {
		# build and print header:
		&PrintTemplate(0, 'header.htm', $::Rules{'language'}, \%::const);
		$| = 0;
		}
 
	# build and queue footer:
 
	if (($::Rules{'allowanonadd'}) and ($::realms->realm_count('has_no_base_url')) and (not $::private{'is_freeware'})) {
		# print: Search Tips - Add New URL - Main Page
		$::private{'html_footer'} = &PrintTemplate(1, 'linkline2.txt', $::Rules{'language'}, \%::const);
		}
	else {
		# print: Search Tips - Main Page
		$::private{'html_footer'} = &PrintTemplate(1, 'linkline1.txt', $::Rules{'language'}, \%::const);
		}
 
	unless ($b_is_shell_include) {
		$::private{'html_footer'} .= &PrintTemplate(1, 'footer.htm', $::Rules{'language'}, \%::const);
		}
 
 
	if ($::FORM{'Mode'} eq 'AnonAdd') {
		$err = &anonadd_main();
		next Err if ($err);
		last Err;
		}
 
	if (not ($::FORM{'Terms'})) {
		$::const{'query_example'} = $::str[46];
		$::const{'url_query_example'} = &ue($::const{'query_example'});
		print &str_search_form($::const{'search_url'});
		&PrintTemplate(0, 'tips.htm', $::Rules{'language'}, \%::const);
		last Err;
		}
 
	print $address_offer;
 
	my $Rank = 1;
	if (defined($::FORM{'Rank'})) {
		if (($::FORM{'Rank'} =~ m!^\d+$!s) and ($::FORM{'Rank'} > 0)) {
			$Rank = $::FORM{'Rank'}; # fixed 0060
			}
		else {
			my $hval = &he($::FORM{'Rank'});
			$err = "parameter 'Rank' value '$hval' is invalid. Must be a positive integer";
			next Err;
			}
		}
	my $b_substring_match = $::Rules{'default substring match'};
	if (defined($::FORM{'p:ssm'})) {
		if ($::FORM{'p:ssm'} =~ m!^(0|1)$!s) {
			$b_substring_match = $1;
			}
		else {
			my $hval = &he($::FORM{'p:ssm'});
			$err = "parameter 'p:ssm' value '$hval' is invalid. Must be 0 or 1";
			next Err;
			}
		}
 
	my ($bTermsExist, $Ignored_Terms, $Important_Terms, $DocSearch, $RealmSearch) = &parse_search_terms($terms, $::FORM{'Match'}, $b_substring_match);
 
	#changed 0042 - persist maxhits
	my $linkhits = $::const{'search_url_ex'} . 'Realm=' . &ue($::FORM{'Realm'}) . "&amp;Match=$::FORM{'Match'}&amp;Terms=" . &ue($::FORM{'Terms'}) . '&amp;';
 
	if ($::FORM{'sort-method'}) {
		$linkhits .= 'sort-method=' . &ue($::FORM{'sort-method'}) . '&amp;';
		}
 
 
	my ($pages_searched, @HITS, $p_realm_data, $DD, $MM, $YYYY, $FBYTES) = (0);
 
#printf("<h2>Init + prep: user time: %s; system time: %s</h2>", times());
 
	Search: {
		next Search unless ($bTermsExist);
 
		#changed 0042 -- added support for include-by-name
 
		# include runtime realms:
		if ($Realm eq 'include-by-name') {
			foreach $p_realm_data ($::realms->listrealms('is_runtime')) {
				next unless ($::FORM{"Realm:$$p_realm_data{'name'}"});
				$linkhits .= "Realm:$$p_realm_data{'url_name'}=1&amp;";
				$::const{'record_realm'} = $$p_realm_data{'url_name'};
				&SearchRunTime($p_realm_data, $DocSearch, \$pages_searched, \@HITS);
				}
			}
		elsif ($Realm eq 'All') {
			foreach $p_realm_data ($::realms->listrealms('is_runtime')) {
				$::const{'record_realm'} = $$p_realm_data{'url_name'};
				&SearchRunTime($p_realm_data, $DocSearch, \$pages_searched, \@HITS);
				}
			}
		else {
			($err, $p_realm_data) = $::realms->hashref($Realm);
			next Err if ($err);
			if ($$p_realm_data{'is_runtime'}) {
				$::const{'record_realm'} = $$p_realm_data{'url_name'};
				&SearchRunTime($p_realm_data, $DocSearch, \$pages_searched, \@HITS);
				last Search;
				}
			}
 
		# include indexed realms:
 
		if ($Realm eq 'include-by-name') {
			foreach $p_realm_data ($::realms->listrealms('has_file')) {
				next unless ($::FORM{"Realm:$$p_realm_data{'name'}"});
				$linkhits .= "Realm:$$p_realm_data{'url_name'}=1&amp;";
				$::const{'record_realm'} = $$p_realm_data{'url_name'};
				&SearchIndexFile($$p_realm_data{'file'}, $RealmSearch, \$pages_searched, \@HITS);
				}
			}
		elsif ($Realm ne 'All') {
			($err, $p_realm_data) = $::realms->hashref($Realm);
			next Err if ($err);
			$::const{'record_realm'} = $$p_realm_data{'url_name'};
			&SearchIndexFile($$p_realm_data{'file'}, $RealmSearch, \$pages_searched, \@HITS);
			}
		else {
			foreach $p_realm_data ($::realms->listrealms('has_file')) {
				$::const{'record_realm'} = $$p_realm_data{'url_name'};
				&SearchIndexFile($$p_realm_data{'file'}, $RealmSearch, \$pages_searched, \@HITS);
				}
			}
		}
 
#printf("<h2>Search complete: user time: %s; system time: %s</h2>", times());
 
	my ($HitCount, $PerPage, $Next) = (scalar @HITS, $::FORM{'maxhits'}, 0);
	$linkhits .= 'maxhits=' . $PerPage . '&amp;';
	my $Remaining = $HitCount - $Rank - $PerPage + 1;
	my $RangeUpper = $Rank + $PerPage - 1;
 
	if ($Remaining >= $PerPage) {
		$Next = $PerPage;
		}
	elsif ($Remaining > 0) {
		$Next = $Remaining;
		}
	else {
		$RangeUpper = $HitCount;
		}
 
	my @Ads = &SelectAdEx();
	print $Ads[0];
 
	print &str_search_form($::const{'search_url'}) if ($::Rules{'ui: search form display'} % 2);
 
	print '<p class="fd_results"><b>' . $::str[10] . '</b><br />';
 
	if ($Ignored_Terms) {
		&ppstr(11, &he($Ignored_Terms));
		}
 
	if ($HitCount) {
		&ppstr(12, &he($Important_Terms), $pages_searched);
		}
	else {
		&ppstr(13, &he($Important_Terms), $pages_searched);
		}
 
	print '<br />';
 
	print $Ads[1];
 
	PrintHits: {
		if ($HitCount < 1) {
			# print: No documents found
			print qq!</p><p class="fd_results">$::str[19]</p>\n!;
			last PrintHits;
			}
 
		# print: Results $Rank-$RangeUpper of $HitCount
		&ppstr(14, $Rank, $RangeUpper, $HitCount );
 
		print '</p>';
 
		my ($jump_sum, $jumptext) = &str_jumptext( $Rank, $PerPage, $HitCount, $linkhits . 'Rank=', 1 );
		# $jump_sum = "Documents 1-10 of 15 displayed."
		# $jumptext = "<p><- Previous 1 2 3 4 5 Next -></p>"
 
		my $i = $Rank;
		foreach ((sort @HITS)[($Rank-1)..($RangeUpper-1)]) {
			next unless (m!^\d+\.(\d+)\.(\d+)\s*\d*\s*\d* u= (.+) t= (.*?) d= (.*?) c= (.*?) r= (.*?)$!s);
			($DD, $MM, $YYYY, $FBYTES) = (unpack('A2A2A2A4A*',$2))[1..4];
			my $relevance = 10E6 - $1;
			print &StandardVersion(
				'relevance' => $relevance,
				'redirector' => $::Rules{'redirector'},
				'rank' => $i,
				'url' => $3,
				'title' => $4,
				'description' => $5,
				'size' => $FBYTES,
				'dd' => $DD,
				'mm' => $MM,
				'yyyy' => $YYYY,
				'context' => $6,
				'record_realm' => &he(&ud($7)),
				);
			$i++;
			}
		print $jump_sum;
		print $jumptext;
		}
	print $Ads[2];
	print &str_search_form($::const{'search_url'}) if ($::Rules{'ui: search form display'} > 1);
	print $Ads[3];
	$err = &log_search( $Realm, $terms, $Rank, $HitCount, $pages_searched );
	next Err if ($err);
 
#printf("<h2>Display complete: user time: %s; system time: %s</h2>", times());
 
	last Err;
	}
continue {
	&header_print();
	if ($::str[29]) {
		print &pstr(29,$err);
		}
	else {
		print "<p><b>Error:</b> $err.</p>\n"; # still print meaningful errors when $::str[] fails to load
		}
	}
print $::private{'html_footer'};
 
 
sub query_env {
	my ($name,$default) = @_;
	if (($ENV{$name}) and ($ENV{$name} =~ m!^(.*)$!s)) {
		return $1;
		}
	elsif (defined($default)) {
		return $default;
		}
	else {
		return '';
		}
	}
 
 
sub untaintme {
	my ($p_val) = @_;
	$$p_val = $1 if ($$p_val =~ m!^(.*)$!s);
	}
 
 
 
 
 
sub header_add {
	my ($header) = @_;
	$::private{'http_headers'} .= $header . "\015\012";
	}
 
 
 
 
 
sub header_print {
	return unless $::private{'needs_header'};
	return if $::const{'is_cmd'};
	foreach (@_) {
		&header_add( $_ );
		}
 
	# fine-tune the header response:
	if ($::private{'PRINT_HTTP_STATUS_HEADER'}) {
		my $status = '200 OK';
		if ($::private{'http_headers'} =~ m!(^|\012)Location:!is) {
			$status = '302 Moved';
			&header_add( 'Status: ' . $status ); # duplicate
			}
		$::private{'http_headers'} = "HTTP/1.0 $status\015\012" . $::private{'http_headers'};
		}
	if ($::private{'http_headers'} !~ m!(^|\012)Content-Type:!is) {
		&header_add( "Content-Type: text/html" );
		}
 
	# prepare and print:
	$::private{'http_headers'} .= "\015\012";
	print $::private{'http_headers'};
	delete $::private{'http_headers'}; #save mem
	$::private{'needs_header'} = 0;
	}
 
 
 
 
 
sub load_files_ex {
	($::private{'support_dir'}) = @_;
 
	my $err = '';
	Err: {
 
		# This manually sets the current working directory to the directory that
		# contains this script. This is necessary in case people have used a
		# relative path to the $data_files_dir:
 
		if (($0 =~ m!^(.+)(\\|/)!s) and ($0 !~ m!safeperl\d*$!is)) {
			#changed 0045 - added error check
			unless (chdir($1)) {
				$err = "unable to chdir to folder '$1' - $! ($^E)";
				next Err;
				}
			}
 
		# force forward slashes:
		$::private{'support_dir'} =~ s!\\!/!sg;
		$::private{'support_dir'} .= "/searchdata";
		$::private{'support_dir'} =~ s!/+searchdata$!/searchdata!s;
 
		unless (chdir($::private{'support_dir'})) {
			$err = "unable to chdir to folder '$::private{'support_dir'}' - $! ($^E)";
			next Err;
			}
 
		@INC = ( '../searchmods', @INC );
 
 
		#require
		my $lib = 'common.pl';
		delete $INC{$lib};
		require $lib;
		if (&version_c() ne $::VERSION) {
			$err = "the library '$lib' is not version $::VERSION";
			next Err;
			}
		#/require
 
		&ReadInput();
 
 
 
		if (exists($::FORM{'ApproveRealm'})) {
			$::FORM{'Realm'} = $::FORM{'ApproveRealm'};
			$::FORM{'Mode'} = 'Admin';
			$::FORM{'Action'} = 'FilterRules';
			$::FORM{'subaction'} = 'ShowPending';
			}
 
		unless ($::FORM{'Mode'}) {
			#revcompat - pre-0010
			if (exists($::FORM{'AddSite'})) {
				$::FORM{'Mode'} = 'AnonAdd';
				$::FORM{'URL'} = $::FORM{'AddSite'};
				delete $::FORM{'AddSite'};
				}
			#/revcompat
			if ('mode=admin' eq lc(&query_env('QUERY_STRING'))) {
				$::FORM{'Mode'} = 'Admin';
				delete $::FORM{'mode'};
				}
			}
		#revcompat 0030
		if ((exists($::FORM{'Action'})) and ($::FORM{'Action'} eq 'ReCrawlRealm')) {
			$::FORM{'Action'} = 'rebuild';
			}
		#/revcompat
 
		my $is_admin_rq = (($::FORM{'Mode'}) and (($::FORM{'Mode'} eq 'Admin') or ($::FORM{'Mode'} eq 'AnonAdd'))) or (&query_env('FDSE_NO_EXEC'));
 
 
 
		$::private{'bypass_file_locking'} = (-e 'bypass_file_locking.txt') ? 1 : 0;
 
		# Can we load the rules?
 
		my $DEFAULT_LANGUAGE = 'english';
 
		$err = &LoadRules($DEFAULT_LANGUAGE);
		next Err if ($err);
 
 
		#0056 - user lang selection algorithm by Ian Dobson
 
		($err, $::const{'lang_options'}, $::Rules{'language'}) = &choose_interface_lang($is_admin_rq, &query_env('HTTP_ACCEPT_LANGUAGE'));
		next Err if ($err);
 
		#to hard-code a lang, uncomment this line:
		# $::Rules{'language'} = 'english';
 
		$::const{'language'} = $::FORM{'set:lang'} = $::Rules{'language'};
 
		# init err strings
		$::str[44] = 'unable to read from file "$s1" - $s2';
 
		my $str_file = 'templates/' . $::Rules{'language'} . '/strings.txt';
		my $str_text;
		($err, $str_text) = &ReadFileL($str_file);
		next Err if ($err);
		my $MAX_PUB_STR = 88;
		@::str = (0);
		my $i = 1;
		foreach (split(m!\n!s,$str_text)) {
			s!(\r|\n|\015|\012)!!sg;
			push(@::str,$_);
			unless ($is_admin_rq) {
				last if ($i > $MAX_PUB_STR);
				}
			$i++;
			}
		unless (&Trim($::str[1]) eq "VERSION $::VERSION") {
			$err = "strings file '$str_file' is not version $::VERSION ($::str[1]).</p><p>Loaded $i strings from file; sample: <xmp>" . substr($str_text,0,128) . "</" . "xmp>";
			next Err;
			}
 
		#changed 0064: quality audit
		foreach ($MAX_PUB_STR,100,200,300,400,500,558) {
			if ($::str[$_] ne "$_-anchor") {
				$::str[29] = '<p><b>Error:</b> $s1.</p>'; # force default value
				$err = qq!strings file "$str_file" is corrupted.  Extra line breaks have been added or removed.  We know this because line $_ does not have expected value "$_-anchor".</p><p>To fix, re-upload the original strings.txt file in ASCII mode!;
				next Err;
				}
			last if ((not $is_admin_rq) and ($_ >= $MAX_PUB_STR));
			}
 
 
		$::const{'dir'} = $::str[4];
		$::const{'content_type'} = $::str[3];
		$::const{'language_str'} = $::str[2];
 
 
 
		$::realms = &fdse_realms_new();
		$::realms->load();
 
		# set mode: demo/trial/registered/freeware == 0/1/2/3
		$::private{'mode'} = $::Rules{'mode'};
 
		if (-e 'is_demo') {
			$::private{'mode'} = 0;
			}
		elsif (($::private{'mode'} == 2) and (not $::Rules{'regkey'})) {
			$::private{'mode'} = 1;
			}
 
		$::private{'is_demo'} = ($::private{'mode'} == 0);
		$::private{'is_freeware'} = ($::private{'mode'} == 3);
 
 
 
		#require
		if (($is_admin_rq) or ($::realms->listrealms('is_runtime'))) {
			$lib = 'common_parse_page.pl';
			delete $INC{$lib};
			require $lib;
			if (&version_cpp() ne $::VERSION) {
				$err = "the library '$lib' is not version $::VERSION";
				next Err;
				}
			}
		if ($is_admin_rq) {
			$lib = 'common_admin.pl';
			delete $INC{$lib};
			require $lib;
			if (&version_ca() ne $::VERSION) {
				$err = "the library '$lib' is not version $::VERSION";
				next Err;
				}
			}
		#/require
 
 
		last Err;
		}
	return $err;
	}
 
package FDSC::HEH;
sub TIEHASH  { bless {}, $_[0] }
sub STORE    { $_[0]->{$_[1]} = $_[2] }
sub FIRSTKEY { my $a = scalar keys %{$_[0]}; each %{$_[0]} }
sub NEXTKEY  { each %{$_[0]} }
sub EXISTS   { exists $_[0]->{$_[1]} }
sub DELETE   { delete $_[0]->{$_[1]} }
sub CLEAR    { %{$_[0]} = () }
sub FETCH {
	my ($self, $key) = @_;
	if (exists ($self->{$key})) {
		return $self->{$key};
		}
	else {
		my ($package, $file, $line) = caller();
		my $err = "blind fetch of non-existent hash element '$key' file $file line $line<br />\n";
		foreach (sort keys %$self) {
			$err .= "$_: $self->{$_}<br />\n";
			}
		die $err;
		}
	};
 
END_OF_FILE
 
sub he {
	my @out = @_;
	local $_;
	foreach (@out) {
		$_ = '' if (not defined($_));
		s!\&!\&amp;!sg;
		s!\>!\>!sg;
		s!\<!\<!sg;
		s!\"!\"!sg;
		}
	if ((wantarray) or ($#out > 0)) {
		return @out;
		}
	else {
		return $out[0];
		}
	}
 
undef($@);
eval $all_code;
if ($@) {
	my $errstr = &he($@);
	print "Content-Type: text/html\015\012\015\012";
	print "<hr /><p><b>Perl Execution Error</b> in $0:</p><blockquote><pre>$errstr</pre></blockquote>";
print <<"EOM";
 
<script>g_loaded=true;</script>
<form method="post" action="http://www.xav.com/bug.pl">
<input type="hidden" name="product" value="search" />
<input type="hidden" name="version" value="$::VERSION" />
<input type="hidden" name="Perl Version" value="$]" />
<input type="hidden" name="Script Path" value="$0" />
<input type="hidden" name="Perl Error" value="$errstr" />
EOM
 
my ($name, $value) = ();
while (($name, $value) = each %::FORM) {
	next if ($name =~ m!(Password|new_pass_\d)!s);
	($name, $value) = &he($name,$value);
	print qq!<input type="hidden" name="Form: $name" value="$value" />\n!;
	}
print <<"EOM";
 
<p>Please report this error to the script author:</p>
<blockquote><input type="submit" value="Report Error" /></blockquote>
</form><hr />
 
EOM
	}
1;

Open in new window

Avatar of Bernard Savonet
Bernard Savonet
Flag of France image

Just to be sure I understand correctly:
- you have developed a site which uses a "native" search engine in PERL.
- the staging site is at staging-zeus, the target site is at response-systems
- the search engine works on live, not on staging.

----------------------
Here is what I have observed:
- wether the search engines is called from stagin or live, in both cases it runs in fact from live, eg searching for "support" on BOTH sides end at
http://response-systems.com/cgi-bin/search/search.pl?Terms=support
Not sure if this is done on purpose (ie, as search is not working on staging you redirected to live) or if THIS is the error you are trying to solve
The html code on staging currently says:
<DIV class=header_search>
  <FORM action=http://response-systems.com/cgi-bin/search/search.pl method=get>
   <P><INPUT class=search name=Terms>
   <INPUT class=submit type=submit value=Search>
    </P>
</FORM></DIV>
- for the sake of coherence and to use efficiently outside search engines (Google etc), I would prefer that this addresses http://www.response-systems.com/cgi-bin/search/search.pl?Terms=support
- trying to manually ask for page
http://rere6659.staging-zeus.netregistry.net/cgi-bin/search/search.pl?Terms=support
returns an error message.

---------------- UNRELATED to your question ------------
Dont' take it badly:I suggest you do NOT show the French version until the translation is fine. The current version leaves lots of room for improvement. I might buy your services reading the English text, but I would run away if looking at the French text.
Avatar of usmansultan

ASKER

<<you have developed a site which uses a "native" search engine in PERL.
- the staging site is at staging-zeus, the target site is at response-systems
- the search engine works on live, not on staging.>>
You are right on most of the things, except the first one, i havent developed it, i have just transferred across, so all the code is same, its just the structure has changed a bit, before all the folders and files used to be under /www/ folder, now they are all under root folder.

<<Not sure if this is done on purpose (ie, as search is not working on staging you redirected to live) or if THIS is the error you are trying to solve>
You are right i am trying to make search engine work on the staging website, so on which page you recomm, i have to go and make necessary changes....
On the index.php page i tried to change the path from response systems to the one for staging site

DIV class=header_search>
  <FORM action=http://rere6659.staging-zeus.netregistry.net/cgi-bin/search/search.pl method=get>


But it generated this error;


Access Denied (Error 403)
You are not allowed to see the page.
If you have any queries about this error, please e-mail webmaster@response-systems.com.
--------------------------------------------------------------------------------

Back to rere6659.staging-zeus.netregistry.net homepage
<<its just the structure has changed a bit, before all the folders and files used to be under /www/ folder, now they are all under root folder.>>
??
Not sure what the REAL situation is.

Depending on your ISP, the file used for http://www.mysite.com/index.htm (the typical home page) will be placed on a /www/directory or / directory, or /public/ directory (etc.)
This should NOT affect the web site if you transfer the complete files-tree structure. It WILL have some impact though for those parameters that need to have the physical address of the directory, and it might have some impact for the directory used for sessions and some other special directories... like the one used to store cgi-bin scripts (such as, in your case, the perl script)

Suggestions:
1 - find which is the normal directory used on the staging system to host and run perl scripts
2 - place your search script there
3 - make a backup copy of the script, then search in it for any reference to the live site 'response-systems' and updtate it accordingly
4 - edit your search box so that it links to the right "staging" address
5 - test. maybe your search engine needs some initialization before being operational...
Well i tried to place the files under /www/ htdocs/  directory,but it was not reading the index file then i placed all the files and folders under the root directory / ,
i have tried yours suggestion;
1. There are more then one Perl scripts that are running, i have changed "response-systems.com" to stagging site address but it didnt work, it started giving Access denied 403 error.
2.How can i edit my search box to link it to stagging address?

I am pasting the link for the Perl script that i have changed,

# This is the main server configuration file for response-systems.com. 
# See URL http://www.apache.org/ for instructions.
 
# Do NOT simply read the instructions in here without understanding what 
# they do, if you are unsure consult the online docs. You have been warned.
 
# Originally by Rob McCool
 
##############################################################################
# directives relating to the operation of the server as a whole including
# logging and management of the server pool
##############################################################################
 
# Dynamic Shared Object (DSO) Support
#
# To be able to use the functionality of a module which was built as a DSO you
# have to place corresponding `LoadModule' lines at this location so the
# directives contained in it are actually available _before_ they are used.
# Load the info module and access server-info for a list of already built-in 
# (statically linked and thus always available) modules as well as any 
# dynamic modules in your httpd binary.
#
# More information can be found at the following URLs:
#   http://www.apache.org/docs/dso.html
#   http://www.apache.org/docs/mod/
#   http://www.apache.org/docs/mod/mod_so.html
#
# Examples:
# LoadModule asis_module modules/mod_asis.so
# LoadModule info_module modules/mod_info.so
# LoadModule negotiation_module modules/mod_negotiation.so
# LoadModule status_module modules/mod_status.so
# LoadModule php3_module modules/mod_php3-module-mysql-imap.so
# LoadModule frontpage_module modules/mod_frontpage.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule php4_module modules/mod_php4-4.4.1.so
 
# Turn on the Rewrite engine for emulation of Best's RedirectRefer
# directive
RewriteEngine on
 
# ResourceConfig: where the server resource map file is located.  Note that 
# by default, a single config file is used. 
ResourceConfig /dev/null
 
# AccessConfig: where is the access control file is located.  Note that by
# default, a single config file is used. 
AccessConfig /dev/null
 
# HostnameLookups: Log the names of clients or just their IP numbers
#   e.g.   www.apache.org (on) or 63.211.145.10 (off)
# The default is off because it'd be overall better for the net if people
# had to knowingly turn this feature on.  Turning this feature to on can
# slow access to your site.  Most logfile analysis programs will do 
# hostname lookups off-line (which obviously does not affect your server
# perfromance).
 
HostnameLookups off
 
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.
 
# ServerAdmin: Your address, where problems with the server should be
# e-mailed.
 
ServerAdmin webmaster@response-systems.com
 
# ServerRoot: The directory the server's config, error, and log files
# are kept in.
 
ServerRoot /usr/local/etc/httpd
 
# ErrorLog: The location of the error log file. If this does not start
# with /, ServerRoot is prepended to it.
 
ErrorLog logs/error_log
 
# The following directives define log formats (combined and common)
 
# common log format
# LogFormat "%h %l %u %t \"%r\" %>s %b" 
 
# combined log format
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" 
 
# The location of the access logfile 
# If this does not start with /, ServerRoot is prepended to it.
 
TransferLog logs/access_log
 
# If you would like to have a separate agent and referer logfile 
# uncomment the following directives.
 
#RefererLog logs/referer_log
#AgentLog logs/agent_log
 
# ServerName allows you to set a host name which is sent back to clients for
# your server if it's different than the one the program would get (i.e. use
# "www" instead of the host's real name).
# 
# Note: You cannot just invent host names and hope they work. The name you
# define here must be a valid DNS name for your host. If you don't understand
# this, ask your network administrator.
# If your host doesn't have a registered DNS name, enter its IP address here.
# You will have to access it by its address (e.g., http://123.45.67.89)
# anyway, and this will make redirections work in a sensible way.
 
ServerName rere6659.staging-zeus.netregistry.net
 
# KeepAlive: Whether or not to allow persistent connections (more than
# one request per connection). Set to "Off" to deactivate.
 
KeepAlive On
 
# MaxKeepAliveRequests: The maximum number of requests to allow
# during a persistent connection. Set to 0 to allow an unlimited amount.
# We reccomend you leave this number high, for maximum performance.
 
MaxKeepAliveRequests 20
  
# KeepAliveTimeout: Number of seconds to wait for the next request
 
KeepAliveTimeout 5
 
# MaxRequestsPerChild: the number of requests each child process is
#  allowed to process before the child dies.
#  The child will exit so as to avoid problems after prolonged use when
#  Apache (and maybe the libraries it uses) leak.  On most systems, this
#  isn't really needed, but a few (such as Solaris) do have notable leaks
#  in the libraries.
 
MaxRequestsPerChild 500 
 
# TimeOut: number of seconds Apache will wait to receive responses
 
TimeOut 600
 
# The NameVirtualHost directive is a required directive if you want to
# configure name-based virtual hosts.
 
NameVirtualHost 202.124.241.200:*
 
# VirtualHost: Allows the daemon to respond to requests for more than one
# hostname.  
 
#<VirtualHost some-domain.name www.some-domain.name>
#ServerAdmin webmaster@some-domain.name
#DocumentRoot /usr/local/etc/httpd/vhosts/www.some-domain.name
#ServerName www.some-domain.name
#ErrorLog logs/error_log-www.some-domain.name
#TransferLog logs/access_log-www.some-domain.name
#</VirtualHost>
 
##############################################################################
# directives which relate to the management of the namespace and resources
# in the filesystem, i.e.-  file typing, directory indexes, aliases, etc. 
##############################################################################
 
# With this section, you define the name space that users see of your http
# server.  This file also defines server settings which affect how requests are
# serviced, and how results should be formatted.
 
# See the tutorials at http://www.apache.org/ for more information.
 
# Originally by Rob McCool; Adapted for Apache
 
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
 
DocumentRoot /usr/local/etc/httpd/htdocs
 
# DirectoryIndex: Name of the file to use as a pre-written HTML
# directory index
 
DirectoryIndex index.cgi index.php3 index.html index.htm index.shtml index.shtm index.php index.php4
 
# FancyIndexing is whether you want fancy directory indexing or standard
 
FancyIndexing on
 
# AddIcon tells the server which icon to show for different files or filename
# extensions
 
AddIconByEncoding (CMP,/icons/compressed.gif) x-compress x-gzip
 
AddIconByType (TXT,/icons/text.gif) text/*
AddIconByType (IMG,/icons/image2.gif) image/*
AddIconByType (SND,/icons/sound2.gif) audio/*
AddIconByType (VID,/icons/movie.gif) video/*
 
AddIcon /icons/binary.gif .bin .exe
AddIcon /icons/binhex.gif .hqx
AddIcon /icons/tar.gif .tar
AddIcon /icons/world2.gif .wrl .wrl.gz .vrml .vrm .iv
AddIcon /icons/compressed.gif .Z .z .tgz .gz .zip
AddIcon /icons/a.gif .ps .ai .eps
AddIcon /icons/layout.gif .html .shtml .htm .pdf
AddIcon /icons/text.gif .txt
AddIcon /icons/c.gif .c
AddIcon /icons/p.gif .pl .py
AddIcon /icons/f.gif .for
AddIcon /icons/dvi.gif .dvi
AddIcon /icons/uuencoded.gif .uu
AddIcon /icons/script.gif .conf .sh .shar .csh .ksh .tcl
AddIcon /icons/tex.gif .tex
AddIcon /icons/bomb.gif core
 
AddIcon /icons/back.gif ..
AddIcon /icons/hand.right.gif README
AddIcon /icons/folder.gif ^^DIRECTORY^^
AddIcon /icons/blank.gif ^^BLANKICON^^
 
# DefaultIcon is which icon to show for files which do not have an icon
# explicitly set.
 
DefaultIcon /icons/unknown.gif
 
# AddDescription allows you to place a short description after a file in
# server-generated indexes.
# Format: AddDescription "description" filename
 
# ReadmeName is the name of the README file the server will look for by
# default. Format: ReadmeName name
#
# The server will first look for name.html, include it if found, and it will
# then look for name and include it as plaintext if found.
#
# HeaderName is the name of a file which should be prepended to
# directory indexes. 
 
ReadmeName README
HeaderName HEADER
 
# IndexIgnore is a set of filenames which directory indexing should ignore
# Format: IndexIgnore name1 name2...
 
IndexIgnore */.??* *~ *# */HEADER* */README* */RCS
 
# AccessFileName: The name of the file to look for in each directory
# for access control information.
 
AccessFileName .htaccess
 
# DefaultType is the default MIME type for documents which the server
# cannot find the type of from filename extensions.
 
DefaultType text/plain
 
# AddEncoding allows you to have certain browsers (Mosaic/X 2.1+) uncompress
# information on the fly. Note: Not all browsers support this.
 
#AddEncoding x-compress Z
#AddEncoding x-gzip gz
 
# AddLanguage allows you to specify the language of a document. You can
# then use content negotiation to give a browser a file in a language
# it can understand.  Note that the suffix does not have to be the same
# as the language keyword --- those with documents in Polish (whose
# net-standard language code is pl) may wish to use "AddLanguage pl .po"
# to avoid the ambiguity with the common suffix for perl scripts.
 
#AddLanguage en .en
#AddLanguage fr .fr
#AddLanguage de .de
#AddLanguage da .da
#AddLanguage el .el
#AddLanguage it .it
 
# LanguagePriority allows you to give precedence to some languages
# in case of a tie during content negotiation.  Just list the languages 
# in decreasing order of preference.
# Note: you must load the negotiation module if you intend to use
# this directive.  Please see the LoadModule instructions at the top
# of this file.
 
#LanguagePriority en fr de
 
# Redirect allows you to tell clients about documents which used to exist in
# your server's namespace, but do not anymore. This allows you to tell the
# clients where to look for the relocated document.
# Format: Redirect fakename url
 
 
# Aliases: Add here as many aliases as you need, up to 20. The format is 
# Alias fakename realname
 
Alias /icons/ /usr/local/etc/httpd/icons/
 
# ScriptAlias: This controls which directories contain server scripts.
# Format: ScriptAlias fakename realname
 
ScriptAlias /cgi-bin/ /usr/local/etc/httpd/cgi-bin/
 
# If you want to use server side includes, or CGI outside
# ScriptAliased directories, uncomment the following lines.
 
# AddType allows you to tweak mime.types without actually editing it, or to
# make certain files to be certain types.
# Format: AddType type/subtype ext1
 
# Action lets you define media types that will execute a script whenever
# a matching file is called. This eliminates the need for repeated URL
# pathnames for oft-used CGI file processors.
# Format: Action media/type /cgi-script/location 
# Format: Action handler-name /cgi-script/location
 
AddType application/x-httpd-Miva .mv
Action  application/x-httpd-Miva /cgi-bin/miva
 
AddType application/x-httpd-php3 .php3 .phtml
AddType application/x-httpd-php3-source .phps
 
AddType application/x-httpd-php .php .php3 .php4 .phtml
AddType application/x-httpd-php-source .phps
 
# AddHandler allows you to map certain file extensions to "handlers",
# actions unrelated to filetype. These can be either built into the server
# or added with the Action command (see below)
# Format: AddHandler action-name ext1
 
# To use CGI scripts:
AddHandler cgi-script .cgi
 
# To use server-parsed HTML files
AddType text/html .shtml
AddHandler server-parsed .shtml
 
# Addition to allow CSS files
AddType text/css .css
 
# Uncomment the following line to enable Apache's send-asis HTTP file
# feature.  Note: you must load the asis module if you intend to use
# this directive.  Please see the LoadModule instructions at the top
# of this file.
 
#AddHandler send-as-is asis
 
# If you wish to use server-parsed imagemap files, use
AddHandler imap-file map
 
# To enable type maps, you might want to use
#AddHandler type-map var
 
# Customizable error response (Apache style)
#  these come in three flavors
#
#    1) plain text
#ErrorDocument 500 "The server made a boo boo.
#  n.b.  the (") marks it as text, it does not get output
#
#    2) local redirects
#ErrorDocument 404 /missing.html
#  to redirect to local url /missing.html
#ErrorDocument 404 /cgi-bin/missing_handler.pl
#  n.b. can redirect to a script or a document using server-side-includes.
#
#    3) external redirects
#ErrorDocument 402 http://some.other_server.com/subscription_info.html
#
 
XBitHack on
 
##############################################################################
# directives which relate to the access control in various directories
##############################################################################
 
# This section defines server settings which affect which types of services
# are allowed, and in what circumstances.
 
# Each directory to which Apache has access, can be configured with respect
# to which services and features are allowed and/or disabled in that
# directory (and its subdirectories).
 
# Originally by Rob McCool
 
<Directory />
AllowOverride None
</Directory>
 
# This should be changed to whatever you set DocumentRoot to.
 
<Directory /usr/local/etc/httpd/htdocs>
 
# This may also be "None", "All", or any combination of "Indexes",
# "Includes", "FollowSymLinks", "ExecCGI", or "MultiViews".
 
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you (or at least, not yet).
 
Options Indexes FollowSymLinks Includes ExecCGI
 
# This controls which options the .htaccess files in directories can
# override. Can also be "All", or any combination of "Options", "FileInfo",
# "AuthConfig", and "Limit"
 
AllowOverride All
 
# Controls who can get stuff from this server.
 
order allow,deny
allow from all
 
</Directory>
 
# /usr/local/etc/httpd/cgi-bin should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
 
<Directory /usr/local/etc/httpd/cgi-bin>
AllowOverride None
Options None
</Directory>
 
<Directory /usr/local/etc/httpd/vhosts>
Options Indexes FollowSymLinks Includes
AllowOverride All
order allow,deny
allow from all
</Directory>
 
# Allow server status reports, with the URL of http://servername/server-status
# You may wish to add a <Limit> clause inside the location directive to limit 
# access to your server status information.
# Note: you must load the status module if you intend to use this directive.  
# Please see the LoadModule instructions at the top of this file.
 
#<Location /server-status>
#SetHandler server-status
#</Location>
 
# Uncommenting the following provides a comprehensive overview of the server 
# configuration including all installed modules and directives in the 
# configuration files via HTTP.  You may wish to add a <Limit> clause inside 
# the location directive to limit access to your server configuration
# information.
# Note: you must load the info module if you intend to use this directive.  
# Please see the LoadModule instructions at the top of this file.  
 
#<Location /server-info>
#SetHandler server-info
#</Location>
 
# You may place any other directories or locations you wish to have
# access information for after this one.
 
## <===URCHIN VPS 3.309:Urchin VPS 3.309 start===>
## User changes (other than commenting out lines within this block)
## should be placed before or after this block. Any user changes made
## within this block may be lost when Urchin VPS 3.309 is removed or upgraded.
 
<Directory /usr/local/etc/httpd/htdocs/urchin/system>
  AddHandler cgi-script .cgi
  DirectoryIndex index.html index.cgi
  Options FollowSymLinks ExecCGI
</Directory>
<Directory /usr/local/etc/httpd/htdocs/urchin/rere6659.staging-zeus.netregistry.net>
  AddHandler cgi-script .cgi
  DirectoryIndex index.html index.cgi
  Options FollowSymLinks ExecCGI
</Directory>
 
## <===URCHIN VPS 3.309:Urchin VPS 3.309 end===>
 
Alias /vhosts/ /usr/local/etc/httpd/vhosts/
Alias /vhosts /usr/local/etc/httpd/vhosts

Open in new window

Now when i enter the password for the admin mode, this screen comes up.
Search-Engine.JPG
<<1. There are more then one Perl scripts that are running, i have changed "response-systems.com" to stagging site address but it didnt work, it started giving Access denied 403 error.
2.How can i edit my search box to link it to stagging address?>>
Since it says Access denied:
-- this directory exists
-- the current access rights do not allow to access the directory.

This is the problem you have to solve first.
Once this will be solved, the search box will access the script there.

How to solve it? This is not an html issue, and very probably not an Apache issue, but most certainly a Linux (or the OS) question.
1 - What are the current rights? You might be able to visualize them from some CPanel if you have one, and anyway thru ftp. Which user is the owner of this directory?
2 - looking in the directory: have you an .htaccess here? have you some index.htm (or html or any other extension) here?

- The access rights should probably be 755 (4-Read + 2-Write + 1-eXecute) for the directory.
- If this is the case, and if you have no index.* file, you should probably put there an empty index.htm, so that visitors cannot list what is in the directory
- If there is an .htaccess file... can you paste its content (PLEASE obfuscate any reference to a passwd file or other sensitive information!)
I have configured the permissions by following the guide for the search engine on;
http://www.xav.com/scripts/search/install.html 
Now i am getting this error.

Internal Server Error (Code 500)


The page you requested could not be served. This could happen for a variety of reasons, including:
A CGI script failed to produce any output.
The server is incorrectly configured.
The server encountered a critical error.
There may be more information about this error in the server's error logs.
If you have any queries about this error, please e-mail webmaster@response-systems.com.


I am going to paste .htaccess as well
# -FrontPage-
 
IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*
 
<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName "fake.netregistry.net"
AuthUserFile /fake/service.pwd
AuthGroupFile /fake/service.grp

Open in new window

The perl file is placed at  \ usr \ local \ bin ,
Not sure what else is required to change.
Please remove lines 15 and 16 asap as they might help security brteaches.
If you can't, ask for a moderator to do it
Error 500:
now we have made a progress: you can access the script in the directory. The script fails, but as far as the link in your search box is concerned, you can now edit it to point to this script. Looking at the help page you gave, it gives you a check-list to ensure that your perl-script is called as needed.

Where is the perl-engine placed? The standard script assumes it to be in /usr/bin/perl, your post suggest it is at /usr/local/bin/perl

I suggest you first try to have a simple script like below working:

#!/usr/bin/perl --

print <<"EOM";
Access to perl is working fine
EOM
I have placed the code in a txt file and called it perltest, and saved it under usr / bin / perltest.
So how can i call the file from the browser, should it be like this
http://rere6659.staging-zeus.netregistry.net/usr/bin/perltest.

and from where i can call the moderator to remove lines 15 and 16.
1 - Moderators: I asked them to come and help. You can do that from any question (don'to do it here since I've already done it) by the link 'Request Attention' on the bottom right of any initial question.
Use sparingly, 'cause moderators are already quite busy even if we don't notice.

2 - PLEASE place an empty index.htm file in your directory. And I would guess that some additional access right limitations should be in place (ie 700 or 711 instead of the current, presumably 744 or 755)

3 - Your file is in fact called http://rere6659.staging-zeus.netregistry.net/usr/bin/perltest.txt and when clicking on it, as with any txt file, its content are simply displayed

4 - If they are to be ran, your script MUST be placed in the cgi-bin directory. Otherwise, they can just run on a command-line in a shell, as is evidenced by http://rere6659.staging-zeus.netregistry.net/usr/bin/which
a script that certainly runs from a command line but just displays when called directly from the web

Can you place your perltest.txt in you cgi-bin directory, with name 'perltest' (no extension) and report the result?
OOps for point 4 above: rename the file to 'perletst.pl', this might help..
From page http://www.xav.com/scripts/search/install.html

<<Perl CGI File Extension

In 99% of cases, the default CGI file extension of ".pl" will work and you won't need to change it. In the remaining cases, you must rename the CGI script files to use the appropriate file extension for your system. Some require ".cgi", and others require weird extensions like ".plx".

How do you know what extension is needed? Your web hosting provider should tell you. Or, if you have existing Perl CGI scripts that work, you can copy whatever extension they use. Or if, after following all other instructions listed here, your script returns its own source code when you visit it with a browser, or returns some other error, then the problem may be the extension. You may want to experiment with both ".pl" and ".cgi".>>

I have done that, so how i can test it, means how can i access it.
On your point 2 where should i place an empty index file, under which directory...
Clicking on http://rere6659.staging-zeus.netregistry.net/usr/bin/ shows this directory to ne wide-open and safety is therefore  at risk. The minimum protection would be to place there an emty index.htm file: if someone clcks the link above, they will not be any more able to list the directory content.
Since the link has been explictly given, you MUST now ensure that the directory is write protected against visitors: there fore its chmod should not allow write acces.
If the current chmod is 700 744 711 or 755 fine (any combination where the last 2 digits are some combination of 4 (Read) and 1 (eXecute)) and combination where one or several of the last 2 digits are 2 (Write), 3 (2+1), 6 (4+2) or 7 (4+2+1) should be changed to its non-write equivalent.
<<Can you place your perltest.pl in you cgi-bin directory, with name 'perltest' (no extension)
and report the result?>> [I initially said perltest.txt but amended later]
<<I have done that, so how i can test it, means how can i access it.>>

If you cgi-bin directory is reachable at
http://rere6659.staging-zeus.netregistry.net/cgi-bin [don't forget to apply the same security treatment as above]
then the test would be
http://rere6659.staging-zeus.netregistry.net/cgi-bin/perltest.pl
and indeed it works now...
so now you know how your perl script can work.
ATTENTION DANGER
Your whole system is currently at risk. /url MUST NOT BE ACCESSABLE THRU THE WEB, nor its descendants

MOST OF THE PARTS OF YOUR SYSTEM ARE CURRENTLY ACCESSABLE THRU THE WEB, including user files.

I suggest you shutdown web access until you have fixed this....
Thanks for the attention.
I have changed couple of security settings, so some of them are not visible but some of them still are, like /usr.
On the old website if you browse to http://www.response-systems.com/usr, you get an error 403, and on the current staging website if you browse to http://rere6659.staging-zeus.netregistry.net/usr, all the folders are visible, although the folder permissions are same, which is 755. So if i would make it 644, will it effect on other things, and if the security permissions are same, how the other one is not accessible and this one is.
UsmanSultan,

Let me say it brutally: you seem to have no idea of the risks of your current system and its lack of protection. Instead of trying to understand before doing, you should really do what I told you several times. Do it first. Your system is publicly exposed here as lacking of security, and although what I suggest is not totally secure against any dedicated hacker, at least it will place a basic security which should block most of botnets and script kiddies.

I will not make any additional answer before you take these measures.

Please, place an empty index.htm file in all the visible directories: this will at least prevent outsiders to "guess and shoot" in your directories, since they will not bee able to see their content.
- if you have no index.htm (or .html or .php) and if the directory is readable, then "opening" it lists content and all the subdirs.
- if you have an index.htm file, then the content of this index.htm file is listed and it is no more possible to see which files and directories are in this directory; in the case of an empty (but present!) index.htm file, it simply displays a blank screen

Ok, done...now check it....

Thanks.
Thx. I feel better for you now!

OK let's resume business.

- what is currently in directory /cgi-bin/search/ on the old system  should be put on the new system in /cgi-bin/search/ (so cgi-bin should have at least the perltest.pl you placed there, and the search directory
- once this is done, you should be able to call / run
http://rere6659.staging-zeus.netregistry.net/cgi-bin/search/search.pl?Terms=support
(it should run... but maybe it will crash or reoprt some missing data)
and so you should udpate the search box on your web pages:
<DIV class=header_search>
  <FORM action=http://rere6659.staging-zeus.netregistry.net/cgi-bin/search/search.pl method=get>

as said earlier.
Wow! nice trip to reach here!  B-))
Thanks for your concern i appreciate it.

I had compared the / cgi-bin / search / directory on both websites, its same.
The only difference is, on the old website its located under /www/cgi-bin/ and on the current one its located under root folder (main directoy).
I have placed the perltest.pl under search directory, and called the link that you gave me, i.e. http://rere6659.staging-zeus.netregistry.net/cgi-bin/search/search.pl?Terms=support
But its showing the same error, "Internal Server Error", i had a chat with Netregistry and their response was
"As per our phone conversation, the problem is the line feeds the script is using. You are using hex 015/012, it needs to be /n/n.

We have fixed a few of them and the script partially works now. You need to fix the rest so that it has full functionality.

It looks like programming issue the you should be addressing or contact the script vendor rather than us as they will be able to help you better."

I dont think they have fixed anything and i didnt understand what they mean, and there is no change in the error.

Regarding updating the search box on the page, on which pages i have to include that code.
I had a look at the index.php, it had the similar  code so i thought i wont change it, the code was:

<div class="header_search">
<form method="get" action="http://rere6659.staging-zeus.netregistry.net/cgi-bin/search/search.pl">
<p><input type="text" name="Terms" class="search" /> <input type="submit" value="Search" class="submit" /></p>
</form>
SOLUTION
Avatar of Bernard Savonet
Bernard Savonet
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I am with you, from which files i need to remove the extra /r, and on which lines of code i can find it.
The editors i have used so far are CuteFTP and SmartFTP,
and should i use Ultraedit.
CuteFTP and SmatrtFTP are FTP client programs, not editors.
While they can help you doing simple edit tasks, they are not at the level required here.
You seem to be serious in your business, therefore you should consider using a professional text/ program editor.
To sole your problem, it seems you just need to remove the '\r' that do exist in your file.

While for PHP development you best choice would probably be IDEs like those (commercial) from Zend and Nusphere, you will probably need a full text editor.

I am personally a great fan and a satisfied customer of (commercial) UltraEdit.

All these commercial programs have open-source (free) equivalent, but I have not made extensive search and comparison.

I suggest that you save your time by:
- downloading ultraedit for a trial version for some weeks.
- install and launch
- open your suspect files. use "file" / "conversion" / "DOS to Unix", save your file, upload it to your server
YOU'RE DONE
Since the trial version is free and costs you no money, please do as above and report the result
Thanks.
Can you please make me clear about you third suggestion. How can i find the suspect files?
After locating the files do i have to just use conversion option in that software from DOS to Unix and i would be done......right.....
Also i have receive another reply from netregistry.

"The following files in cgi-bin/search/ all use \015\012 to represent a
new line on multiple occasions:

proxy.pl
search.pl
searchmods/common.pl
searchmods/common_admin.pl
searchmods/powerusr/lang.pl
searchmods/powerusr/lib.pl

All occurrences of \015\012 should be replaced with \n in the above files."

How can i find where the new line is starting means which lines of codes, can you give me an example, can you tell me which lines needs editing.I am going to paste search.pl. and which other files needs editing.



#!/usr/bin/perl --
#use warnings 'all';#if-debug
#use strict;#if-debug
 
=head1 copyright
 
Fluid Dynamics Search Engine
 
Copyright 1997-2005 by Zoltan Milosevic.  Please adhere to the copyright
notice and conditions of use, described in the attached help file and hosted
at the URL below.  For the latest version and help files, visit:
 
	http://www.xav.com/scripts/search/
 
This search engine is managed from the web, and it comes with a password to
keep it secure.  You can set the password when you first visit this script
using the special "Mode=Admin" query string - for example:
 
	http://my.host.com/search.pl?Mode=Admin
 
If you edit the source code, you'll find it useful to restore the function comments and #&Assert checks:
 
	cd "search/searchmods/powerusr/"
	hacksubs.pl build_map
	hacksubs.pl restore_comments
	hacksubs.pl assert_on
 
<h1>If you can see this text from a web browser, then there is a problem. <a
href="http://www.xav.com/scripts/search/help/1089.html">Get help here.</a></h1><xmp>
 
=cut
 
$::VERSION = '2.0.0.0073';
%::FORM = ();
 
my $all_code = "\n" x 36 . <<'END_OF_FILE';
 
my $err = '';
Err: {
 
	# initialize and schedule clean-up for package globals:
	$::realms = undef();
	%::private = %::FORM = %::const = %::Rules = @::str = ();
	@::sendmail = (
		'/usr/sbin/sendmail -t',
		'/usr/bin/sendmail -t',
		'/usr/lib/sendmail -t',
		'/usr/sendmail -t',
		'/bin/sendmail -t',
		);
	END {
		$::VERSION = $::realms = undef();
		%::private = %::FORM = %::const = %::Rules = @::str = @::sendmail = ();
		}
 
	# clear ENV for -T compatibility
	block: {
		last block if ( #changed 0072 mod_perl compat issue
			(exists $ENV{'GATEWAY_INTERFACE'} and $ENV{'GATEWAY_INTERFACE'} =~ /CGI-Perl/)
			or exists $ENV{'MOD_PERL'} );
		local $_;
		foreach ('IFS','CDPATH','ENV','BASH_ENV','PATH') {
			delete $ENV{$_} if (defined($ENV{$_}));
			}
		}
 
	binmode(STDOUT);
 
	#high-explosive hash option
#	tie(%::private,'FDSC::HEH');#if-debug
#	tie(%::Rules,'FDSC::HEH');#if-debug
#	tie(%::const,'FDSC::HEH');#if-debug
 
	%::private = (
		'antiword utility folder'  => "",
		'pdf utility folder' => "",
		'global_lockfile_count' => 1,
		'script_start_time' => time(),
		'visitor_ip_addr' => &query_env('REMOTE_ADDR'),
		'allow_admin_access_from' => '', # space-separated list of IP addresses or IP patterns
		'file_mask' => 0666,
		'needs_header' => 1,
		'trust_api' => 0,
		'html_footer' => '',
		'inline_elements' => qq!(a|abbr|acronym|applet|b|bdo|big|button|cite|dfn|em|embed|font|i|img|input|ins|kbd|label|noscript|object|q|rt|ruby|samp|select|small|span|strong|tt|u)!,
		'p_nc_cache' => 0,
		'http_headers' => '',
		);
 
	$::private{'PRINT_HTTP_STATUS_HEADER'} = 0;
 
	%::const = (
		'is_cmd' => 0,
		'help_file' => 'http://www.xav.com/scripts/search/help/',
		'copyright' => '<p style="text-align:center"><small>Powered by the<br /><a href="http://www.xav.com/scripts/search/">Fluid Dynamics<br />Search Engine</a><br />v' . $::VERSION . '<br />&copy; 2005</small></p>',
		);
 
	# Give the folder where all data files are located
	# See http://www.xav.com/scripts/search/help/1138.html about changing this value:
 
	$err = &load_files_ex( '.' );
	next Err if ($err);
 
 
	my $terms = '';
	foreach ('Terms','terms','q') {
		next unless exists $::FORM{$_};
		$terms = $::FORM{$_};
		last;
		}
	$::FORM{'Terms'} = $::FORM{'terms'} = $::FORM{'q'} = $terms;
	$::const{'terms'} = &he($::FORM{'Terms'});
	$::const{'terms_url'} = &ue($::FORM{'Terms'});
 
	# create self-reference string:
 
	my $sn = &query_env('SCRIPT_NAME');
	$sn =~ s!^.*/(.+?)$!$1!s;
 
	if (exists $::FORM{'search_url'}) {
		$sn = &he($::FORM{'search_url'});
		}
 
	$::const{'script_name'} = $::const{'search_url'} = $sn;
	$::const{'admin_url'} = $sn . '?Mode=Admin';
	$::const{'search_url_ex'} = $sn . '?';
 
	# support persistent fields and secondary queries
	my ($n,$v);
	while (($n,$v) = each %::FORM) {
		next unless ($n =~ m!^p:!s);
		$::const{'search_url_ex'} .= &ue($n) . '=' . &ue($v) . '&amp;';
 
		if ($n =~ m!^p:t:!s) { $::const{$n} = $v; } # changed 0053 - persistent/template namespace
 
		next unless ($n =~ m!^p:q(\d+)$!s);
 
		#changed 0064 - prepend, append
 
		next unless (length($v));
		if ((exists($::FORM{"p:pq$1"})) and (exists($::FORM{"p:aq$1"}))) {
			$terms .= ' ' . $::FORM{"p:pq$1"} . $v . $::FORM{"p:aq$1"};
			}
		else {
			$terms .= ' ' . $v;
			}
		}
 
 
	# are we being called from a PHP/ASP/CFM parent?
 
	my $b_is_shell_include = ((exists($::FORM{'is_shell_include'})) and ($::FORM{'is_shell_include'} eq '1')) ? 1 : 0;
 
	my $address_offer = '';
	AddressAsTerm: {
		last unless ($::Rules{'handling url search terms'} > 1);
		last if ($b_is_shell_include);
		last if ($terms =~ m!\s!s);
		my $address = '';
		if ($terms =~ m!^(http|ftp|https|telnet)://(\w+)\.(\w+)(.*)$!s) {
			$address = $terms;
			}
		elsif ($terms =~ m!^www\.(\w+)\.(\w+)(.*)$!is) {
			$address = "http://$terms";
			}
		if ($address) {
			$address_offer = '<p>' . &pstr(23, &he($address, $address) ) . '</p>';
			if ($::Rules{'handling url search terms'} == 3) {
				&header_print( "Location: $address" );
				print $address_offer;
				last Err;
				}
			}
		}
 
 
 
	if (exists($::FORM{'NextLink'})) {
		#changed 0034 - fixes bug where NextLink contains &
		if (&query_env('QUERY_STRING') =~ m!^NextLink=(.*)$!s) {
			$::FORM{'NextLink'} = $1;
			}
		my $html_link = &he($::FORM{'NextLink'});
		# security re-director from admin screen (prevents query-string-based
		# password from showing up in referer logs of remote systems:
		&header_print();
		print qq!<head><meta http-equiv="refresh" content="0;url=$html_link"></head><a href="$html_link">$html_link</a>!;
		last Err;
		}
 
 
	# changed 0067
	my $Realm = 'All';
	block: {
 
		last unless exists $::FORM{'Realm'};
 
		if ($::FORM{'Realm'} eq '') {
			$Realm = 'All';
			}
		elsif (($::FORM{'Realm'} eq 'All') or ($::FORM{'Realm'} eq 'include-by-name')) {
			# reserved names; ok
			$Realm = $::FORM{'Realm'};
			}
		else {
			# explode if invalid $Realm param is passed, but special-case for All include-by-name and empty
			my $p_realm;
			($err, $p_realm) = $::realms->hashref( $::FORM{'Realm'} );
			next Err if ($err);
			$Realm = $::FORM{'Realm'};
			}
 
		}
 
 
	$::const{'realm'} = &he($Realm);
 
	if ($::FORM{'Mode'} eq 'Admin') {
		$err = &admin_main();
		next Err if ($err);
		last Err;
		}
 
	if (($b_is_shell_include) and (not $ARGV[0])) {
		$err = "the 'is_shell_include' parameter can only be set when this script is being called from the command line";
		next Err;
		}
 
	if ($b_is_shell_include) {
		$::private{'needs_header'} = 0;
		}
 
 
 
	$::const{'copyright'} =~ s!<br />! !sg;
 
	&header_print();
 
	#changed 0058 - hard validate
	if ((exists($::FORM{'Match'})) and length($::FORM{'Match'})) {
		if ($::FORM{'Match'} =~ m!^(0|1|2)$!s) {
			# ok
			}
		else {
			my $hval = &he($::FORM{'Match'});
			$err = "parameter 'Match' value '$hval' is invalid. Must be 0, 1 or 2";
			next Err;
			}
		}
	else {
		$::FORM{'Match'} = $::Rules{'default match'};
		}
	if ((exists($::FORM{'maxhits'})) and length($::FORM{'maxhits'})) {
		if (($::FORM{'maxhits'} =~ m!^\d+$!s) and ($::FORM{'maxhits'} > 0)) {
			# ok
			}
		else {
			my $hval = &he($::FORM{'maxhits'});
			$err = "parameter 'maxhits' value '$hval' is invalid. Must be a positive integer";
			next Err;
			}
		}
	else {
		$::FORM{'maxhits'} = $::Rules{'hits per page'};
		}
 
 
 
	#changed 0058
	if (($::Rules{'logging: display most popular'}) and ($::Rules{'use dbm routines'})) {
		eval {
			my %str_t20 = ();
 
			dbmopen( %str_t20, 'dbm_strlog_top', 0666 ) || die &pstr( 43, 'dbm_strlog_top', $! );
 
			$::const{'t_since'} = &FormatDateTime( $str_t20{'++'}, $::Rules{'ui: date format'} );
			my $count = 1;
			foreach (sort { $str_t20{$b} <=> $str_t20{$a} || $a cmp $b } keys %str_t20) {
				next if (m!^\++$!s);
				$::const{ 'tu' . $count } = &ue( &hd($_) );
				$::const{ 'th' . $count } = $_;
				$::const{ 'c' . $count } = $str_t20{$_};
				$::const{'c'.$count}++ if ($::const{'terms'} eq $_);#tweakui
				$count++;
				last if ($count > $::Rules{'logging: display most popular'});
				}
			for ($count..$::Rules{'logging: display most popular'}) {
				$::const{ 'tu' . $_ } = '';
				$::const{ 'th' . $_ } = '';
				$::const{ 'c' . $_ } = '';
				}
			};
		if ($@) {
			&ppstr(53, &pstr(20, &he($@), "$::const{'help_file'}1169.html" ) );
			}
		}
 
 
 
	#changed 0046
	if ($::FORM{'Mode'} eq 'SearchForm') {
		print &str_search_form($::const{'search_url'});
		last Err;
		}
 
	unless ($b_is_shell_include) {
		# build and print header:
		&PrintTemplate(0, 'header.htm', $::Rules{'language'}, \%::const);
		$| = 0;
		}
 
	# build and queue footer:
 
	if (($::Rules{'allowanonadd'}) and ($::realms->realm_count('has_no_base_url')) and (not $::private{'is_freeware'})) {
		# print: Search Tips - Add New URL - Main Page
		$::private{'html_footer'} = &PrintTemplate(1, 'linkline2.txt', $::Rules{'language'}, \%::const);
		}
	else {
		# print: Search Tips - Main Page
		$::private{'html_footer'} = &PrintTemplate(1, 'linkline1.txt', $::Rules{'language'}, \%::const);
		}
 
	unless ($b_is_shell_include) {
		$::private{'html_footer'} .= &PrintTemplate(1, 'footer.htm', $::Rules{'language'}, \%::const);
		}
 
 
	if ($::FORM{'Mode'} eq 'AnonAdd') {
		$err = &anonadd_main();
		next Err if ($err);
		last Err;
		}
 
	if (not ($::FORM{'Terms'})) {
		$::const{'query_example'} = $::str[46];
		$::const{'url_query_example'} = &ue($::const{'query_example'});
		print &str_search_form($::const{'search_url'});
		&PrintTemplate(0, 'tips.htm', $::Rules{'language'}, \%::const);
		last Err;
		}
 
	print $address_offer;
 
	my $Rank = 1;
	if (defined($::FORM{'Rank'})) {
		if (($::FORM{'Rank'} =~ m!^\d+$!s) and ($::FORM{'Rank'} > 0)) {
			$Rank = $::FORM{'Rank'}; # fixed 0060
			}
		else {
			my $hval = &he($::FORM{'Rank'});
			$err = "parameter 'Rank' value '$hval' is invalid. Must be a positive integer";
			next Err;
			}
		}
	my $b_substring_match = $::Rules{'default substring match'};
	if (defined($::FORM{'p:ssm'})) {
		if ($::FORM{'p:ssm'} =~ m!^(0|1)$!s) {
			$b_substring_match = $1;
			}
		else {
			my $hval = &he($::FORM{'p:ssm'});
			$err = "parameter 'p:ssm' value '$hval' is invalid. Must be 0 or 1";
			next Err;
			}
		}
 
	my ($bTermsExist, $Ignored_Terms, $Important_Terms, $DocSearch, $RealmSearch) = &parse_search_terms($terms, $::FORM{'Match'}, $b_substring_match);
 
	#changed 0042 - persist maxhits
	my $linkhits = $::const{'search_url_ex'} . 'Realm=' . &ue($::FORM{'Realm'}) . "&amp;Match=$::FORM{'Match'}&amp;Terms=" . &ue($::FORM{'Terms'}) . '&amp;';
 
	if ($::FORM{'sort-method'}) {
		$linkhits .= 'sort-method=' . &ue($::FORM{'sort-method'}) . '&amp;';
		}
 
 
	my ($pages_searched, @HITS, $p_realm_data, $DD, $MM, $YYYY, $FBYTES) = (0);
 
#printf("<h2>Init + prep: user time: %s; system time: %s</h2>", times());
 
	Search: {
		next Search unless ($bTermsExist);
 
		#changed 0042 -- added support for include-by-name
 
		# include runtime realms:
		if ($Realm eq 'include-by-name') {
			foreach $p_realm_data ($::realms->listrealms('is_runtime')) {
				next unless ($::FORM{"Realm:$$p_realm_data{'name'}"});
				$linkhits .= "Realm:$$p_realm_data{'url_name'}=1&amp;";
				$::const{'record_realm'} = $$p_realm_data{'url_name'};
				&SearchRunTime($p_realm_data, $DocSearch, \$pages_searched, \@HITS);
				}
			}
		elsif ($Realm eq 'All') {
			foreach $p_realm_data ($::realms->listrealms('is_runtime')) {
				$::const{'record_realm'} = $$p_realm_data{'url_name'};
				&SearchRunTime($p_realm_data, $DocSearch, \$pages_searched, \@HITS);
				}
			}
		else {
			($err, $p_realm_data) = $::realms->hashref($Realm);
			next Err if ($err);
			if ($$p_realm_data{'is_runtime'}) {
				$::const{'record_realm'} = $$p_realm_data{'url_name'};
				&SearchRunTime($p_realm_data, $DocSearch, \$pages_searched, \@HITS);
				last Search;
				}
			}
 
		# include indexed realms:
 
		if ($Realm eq 'include-by-name') {
			foreach $p_realm_data ($::realms->listrealms('has_file')) {
				next unless ($::FORM{"Realm:$$p_realm_data{'name'}"});
				$linkhits .= "Realm:$$p_realm_data{'url_name'}=1&amp;";
				$::const{'record_realm'} = $$p_realm_data{'url_name'};
				&SearchIndexFile($$p_realm_data{'file'}, $RealmSearch, \$pages_searched, \@HITS);
				}
			}
		elsif ($Realm ne 'All') {
			($err, $p_realm_data) = $::realms->hashref($Realm);
			next Err if ($err);
			$::const{'record_realm'} = $$p_realm_data{'url_name'};
			&SearchIndexFile($$p_realm_data{'file'}, $RealmSearch, \$pages_searched, \@HITS);
			}
		else {
			foreach $p_realm_data ($::realms->listrealms('has_file')) {
				$::const{'record_realm'} = $$p_realm_data{'url_name'};
				&SearchIndexFile($$p_realm_data{'file'}, $RealmSearch, \$pages_searched, \@HITS);
				}
			}
		}
 
#printf("<h2>Search complete: user time: %s; system time: %s</h2>", times());
 
	my ($HitCount, $PerPage, $Next) = (scalar @HITS, $::FORM{'maxhits'}, 0);
	$linkhits .= 'maxhits=' . $PerPage . '&amp;';
	my $Remaining = $HitCount - $Rank - $PerPage + 1;
	my $RangeUpper = $Rank + $PerPage - 1;
 
	if ($Remaining >= $PerPage) {
		$Next = $PerPage;
		}
	elsif ($Remaining > 0) {
		$Next = $Remaining;
		}
	else {
		$RangeUpper = $HitCount;
		}
 
	my @Ads = &SelectAdEx();
	print $Ads[0];
 
	print &str_search_form($::const{'search_url'}) if ($::Rules{'ui: search form display'} % 2);
 
	print '<p class="fd_results"><b>' . $::str[10] . '</b><br />';
 
	if ($Ignored_Terms) {
		&ppstr(11, &he($Ignored_Terms));
		}
 
	if ($HitCount) {
		&ppstr(12, &he($Important_Terms), $pages_searched);
		}
	else {
		&ppstr(13, &he($Important_Terms), $pages_searched);
		}
 
	print '<br />';
 
	print $Ads[1];
 
	PrintHits: {
		if ($HitCount < 1) {
			# print: No documents found
			print qq!</p><p class="fd_results">$::str[19]</p>\n!;
			last PrintHits;
			}
 
		# print: Results $Rank-$RangeUpper of $HitCount
		&ppstr(14, $Rank, $RangeUpper, $HitCount );
 
		print '</p>';
 
		my ($jump_sum, $jumptext) = &str_jumptext( $Rank, $PerPage, $HitCount, $linkhits . 'Rank=', 1 );
		# $jump_sum = "Documents 1-10 of 15 displayed."
		# $jumptext = "<p><- Previous 1 2 3 4 5 Next -></p>"
 
		my $i = $Rank;
		foreach ((sort @HITS)[($Rank-1)..($RangeUpper-1)]) {
			next unless (m!^\d+\.(\d+)\.(\d+)\s*\d*\s*\d* u= (.+) t= (.*?) d= (.*?) c= (.*?) r= (.*?)$!s);
			($DD, $MM, $YYYY, $FBYTES) = (unpack('A2A2A2A4A*',$2))[1..4];
			my $relevance = 10E6 - $1;
			print &StandardVersion(
				'relevance' => $relevance,
				'redirector' => $::Rules{'redirector'},
				'rank' => $i,
				'url' => $3,
				'title' => $4,
				'description' => $5,
				'size' => $FBYTES,
				'dd' => $DD,
				'mm' => $MM,
				'yyyy' => $YYYY,
				'context' => $6,
				'record_realm' => &he(&ud($7)),
				);
			$i++;
			}
		print $jump_sum;
		print $jumptext;
		}
	print $Ads[2];
	print &str_search_form($::const{'search_url'}) if ($::Rules{'ui: search form display'} > 1);
	print $Ads[3];
	$err = &log_search( $Realm, $terms, $Rank, $HitCount, $pages_searched );
	next Err if ($err);
 
#printf("<h2>Display complete: user time: %s; system time: %s</h2>", times());
 
	last Err;
	}
continue {
	&header_print();
	if ($::str[29]) {
		print &pstr(29,$err);
		}
	else {
		print "<p><b>Error:</b> $err.</p>\n"; # still print meaningful errors when $::str[] fails to load
		}
	}
print $::private{'html_footer'};
 
 
sub query_env {
	my ($name,$default) = @_;
	if (($ENV{$name}) and ($ENV{$name} =~ m!^(.*)$!s)) {
		return $1;
		}
	elsif (defined($default)) {
		return $default;
		}
	else {
		return '';
		}
	}
 
 
sub untaintme {
	my ($p_val) = @_;
	$$p_val = $1 if ($$p_val =~ m!^(.*)$!s);
	}
 
 
 
 
 
sub header_add {
	my ($header) = @_;
	$::private{'http_headers'} .= $header . "\015\012";
	}
 
 
 
 
 
sub header_print {
	return unless $::private{'needs_header'};
	return if $::const{'is_cmd'};
	foreach (@_) {
		&header_add( $_ );
		}
 
	# fine-tune the header response:
	if ($::private{'PRINT_HTTP_STATUS_HEADER'}) {
		my $status = '200 OK';
		if ($::private{'http_headers'} =~ m!(^|\012)Location:!is) {
			$status = '302 Moved';
			&header_add( 'Status: ' . $status ); # duplicate
			}
		$::private{'http_headers'} = "HTTP/1.0 $status\015\012" . $::private{'http_headers'};
		}
	if ($::private{'http_headers'} !~ m!(^|\012)Content-Type:!is) {
		&header_add( "Content-Type: text/html" );
		}
 
	# prepare and print:
	$::private{'http_headers'} .= "\015\012";
	print $::private{'http_headers'};
	delete $::private{'http_headers'}; #save mem
	$::private{'needs_header'} = 0;
	}
 
 
 
 
 
sub load_files_ex {
	($::private{'support_dir'}) = @_;
 
	my $err = '';
	Err: {
 
		# This manually sets the current working directory to the directory that
		# contains this script. This is necessary in case people have used a
		# relative path to the $data_files_dir:
 
		if (($0 =~ m!^(.+)(\\|/)!s) and ($0 !~ m!safeperl\d*$!is)) {
			#changed 0045 - added error check
			unless (chdir($1)) {
				$err = "unable to chdir to folder '$1' - $! ($^E)";
				next Err;
				}
			}
 
		# force forward slashes:
		$::private{'support_dir'} =~ s!\\!/!sg;
		$::private{'support_dir'} .= "/searchdata";
		$::private{'support_dir'} =~ s!/+searchdata$!/searchdata!s;
 
		unless (chdir($::private{'support_dir'})) {
			$err = "unable to chdir to folder '$::private{'support_dir'}' - $! ($^E)";
			next Err;
			}
 
		@INC = ( '../searchmods', @INC );
 
 
		#require
		my $lib = 'common.pl';
		delete $INC{$lib};
		require $lib;
		if (&version_c() ne $::VERSION) {
			$err = "the library '$lib' is not version $::VERSION";
			next Err;
			}
		#/require
 
		&ReadInput();
 
 
 
		if (exists($::FORM{'ApproveRealm'})) {
			$::FORM{'Realm'} = $::FORM{'ApproveRealm'};
			$::FORM{'Mode'} = 'Admin';
			$::FORM{'Action'} = 'FilterRules';
			$::FORM{'subaction'} = 'ShowPending';
			}
 
		unless ($::FORM{'Mode'}) {
			#revcompat - pre-0010
			if (exists($::FORM{'AddSite'})) {
				$::FORM{'Mode'} = 'AnonAdd';
				$::FORM{'URL'} = $::FORM{'AddSite'};
				delete $::FORM{'AddSite'};
				}
			#/revcompat
			if ('mode=admin' eq lc(&query_env('QUERY_STRING'))) {
				$::FORM{'Mode'} = 'Admin';
				delete $::FORM{'mode'};
				}
			}
		#revcompat 0030
		if ((exists($::FORM{'Action'})) and ($::FORM{'Action'} eq 'ReCrawlRealm')) {
			$::FORM{'Action'} = 'rebuild';
			}
		#/revcompat
 
		my $is_admin_rq = (($::FORM{'Mode'}) and (($::FORM{'Mode'} eq 'Admin') or ($::FORM{'Mode'} eq 'AnonAdd'))) or (&query_env('FDSE_NO_EXEC'));
 
 
 
		$::private{'bypass_file_locking'} = (-e 'bypass_file_locking.txt') ? 1 : 0;
 
		# Can we load the rules?
 
		my $DEFAULT_LANGUAGE = 'english';
 
		$err = &LoadRules($DEFAULT_LANGUAGE);
		next Err if ($err);
 
 
		#0056 - user lang selection algorithm by Ian Dobson
 
		($err, $::const{'lang_options'}, $::Rules{'language'}) = &choose_interface_lang($is_admin_rq, &query_env('HTTP_ACCEPT_LANGUAGE'));
		next Err if ($err);
 
		#to hard-code a lang, uncomment this line:
		# $::Rules{'language'} = 'english';
 
		$::const{'language'} = $::FORM{'set:lang'} = $::Rules{'language'};
 
		# init err strings
		$::str[44] = 'unable to read from file "$s1" - $s2';
 
		my $str_file = 'templates/' . $::Rules{'language'} . '/strings.txt';
		my $str_text;
		($err, $str_text) = &ReadFileL($str_file);
		next Err if ($err);
		my $MAX_PUB_STR = 88;
		@::str = (0);
		my $i = 1;
		foreach (split(m!\n!s,$str_text)) {
			s!(\r|\n|\015|\012)!!sg;
			push(@::str,$_);
			unless ($is_admin_rq) {
				last if ($i > $MAX_PUB_STR);
				}
			$i++;
			}
		unless (&Trim($::str[1]) eq "VERSION $::VERSION") {
			$err = "strings file '$str_file' is not version $::VERSION ($::str[1]).</p><p>Loaded $i strings from file; sample: <xmp>" . substr($str_text,0,128) . "</" . "xmp>";
			next Err;
			}
 
		#changed 0064: quality audit
		foreach ($MAX_PUB_STR,100,200,300,400,500,558) {
			if ($::str[$_] ne "$_-anchor") {
				$::str[29] = '<p><b>Error:</b> $s1.</p>'; # force default value
				$err = qq!strings file "$str_file" is corrupted.  Extra line breaks have been added or removed.  We know this because line $_ does not have expected value "$_-anchor".</p><p>To fix, re-upload the original strings.txt file in ASCII mode!;
				next Err;
				}
			last if ((not $is_admin_rq) and ($_ >= $MAX_PUB_STR));
			}
 
 
		$::const{'dir'} = $::str[4];
		$::const{'content_type'} = $::str[3];
		$::const{'language_str'} = $::str[2];
 
 
 
		$::realms = &fdse_realms_new();
		$::realms->load();
 
		# set mode: demo/trial/registered/freeware == 0/1/2/3
		$::private{'mode'} = $::Rules{'mode'};
 
		if (-e 'is_demo') {
			$::private{'mode'} = 0;
			}
		elsif (($::private{'mode'} == 2) and (not $::Rules{'regkey'})) {
			$::private{'mode'} = 1;
			}
 
		$::private{'is_demo'} = ($::private{'mode'} == 0);
		$::private{'is_freeware'} = ($::private{'mode'} == 3);
 
 
 
		#require
		if (($is_admin_rq) or ($::realms->listrealms('is_runtime'))) {
			$lib = 'common_parse_page.pl';
			delete $INC{$lib};
			require $lib;
			if (&version_cpp() ne $::VERSION) {
				$err = "the library '$lib' is not version $::VERSION";
				next Err;
				}
			}
		if ($is_admin_rq) {
			$lib = 'common_admin.pl';
			delete $INC{$lib};
			require $lib;
			if (&version_ca() ne $::VERSION) {
				$err = "the library '$lib' is not version $::VERSION";
				next Err;
				}
			}
		#/require
 
 
		last Err;
		}
	return $err;
	}
 
package FDSC::HEH;
sub TIEHASH  { bless {}, $_[0] }
sub STORE    { $_[0]->{$_[1]} = $_[2] }
sub FIRSTKEY { my $a = scalar keys %{$_[0]}; each %{$_[0]} }
sub NEXTKEY  { each %{$_[0]} }
sub EXISTS   { exists $_[0]->{$_[1]} }
sub DELETE   { delete $_[0]->{$_[1]} }
sub CLEAR    { %{$_[0]} = () }
sub FETCH {
	my ($self, $key) = @_;
	if (exists ($self->{$key})) {
		return $self->{$key};
		}
	else {
		my ($package, $file, $line) = caller();
		my $err = "blind fetch of non-existent hash element '$key' file $file line $line<br />\n";
		foreach (sort keys %$self) {
			$err .= "$_: $self->{$_}<br />\n";
			}
		die $err;
		}
	};
 
END_OF_FILE
 
sub he {
	my @out = @_;
	local $_;
	foreach (@out) {
		$_ = '' if (not defined($_));
		s!\&!\&amp;!sg;
		s!\>!\&gt;!sg;
		s!\<!\&lt;!sg;
		s!\"!\&quot;!sg;
		}
	if ((wantarray) or ($#out > 0)) {
		return @out;
		}
	else {
		return $out[0];
		}
	}
 
undef($@);
eval $all_code;
if ($@) {
	my $errstr = &he($@);
	print "Content-Type: text/html\015\012\015\012";
	print "<hr /><p><b>Perl Execution Error</b> in $0:</p><blockquote><pre>$errstr</pre></blockquote>";
print <<"EOM";
 
<script>g_loaded=true;</script>
<form method="post" action="http://www.xav.com/bug.pl">
<input type="hidden" name="product" value="search" />
<input type="hidden" name="version" value="$::VERSION" />
<input type="hidden" name="Perl Version" value="$]" />
<input type="hidden" name="Script Path" value="$0" />
<input type="hidden" name="Perl Error" value="$errstr" />
EOM
 
my ($name, $value) = ();
while (($name, $value) = each %::FORM) {
	next if ($name =~ m!(Password|new_pass_\d)!s);
	($name, $value) = &he($name,$value);
	print qq!<input type="hidden" name="Form: $name" value="$value" />\n!;
	}
print <<"EOM";
 
<p>Please report this error to the script author:</p>
<blockquote><input type="submit" value="Report Error" /></blockquote>
</form><hr />
 
EOM
	}
1;

Open in new window

1 - I have attached a version of your script with Unix-type of end of lines

2 - rather than trying to amend things, I would suggest that you start with a fresh clean copy of your scripts. either with an auto-install from http://install.xav.com/index.cgi (but be prepared to change your ftp password after installation). You know all the questions that will be asked.
You can also manually download the file to your machine, unzip it to the right directory, then transfer with FTP the complete directory: the transferred files, since they have no extra \r on your machine, should not get affected in any way by the transfer.
NOTE: if you need to edit the files... be careful, 'cause chances are high that when saved on your machine, they will silently get the \r
Or check that the text editor you will be using (whether ultraedit or other) will allow you NOT to add these damned \r


search.txt
So you mean i have to download all the website content on to a folder, then delete it from netregisrty and then upload it through that software, or should i just delete the .pl files and then upload them again through that software.
<<So you mean i have to download all the website content on to a folder,>>
no. if you want to make a backup download the search folder from netregistry.

<< then delete it from netregisrty>>
Yes, so that you can start with a fresh clean copy

<< and then upload it through that software, or should i just delete the .pl files and then upload them again through that software.>>
- downloading first might help you creating a backup before you delete the files in the local and remote /search directories
- get the tar.gz file, uncompress it into search directory, then upload this directory.

There should be no problem doing that: do it and report any problems you might find.
If i have understood it correctly, i dont have to take up a backup of the whole website, i just have to take a backup of serach folder, delete it and then upload it again.
Also whould it affect the database connection, i think it probably wont, but i thought i should ask you first.
1 - yes.
You already have a backup of the complete site since, if I understand correctly, you transferred the site from prod to your machine, then to staging. (BTW prod->local is when the extra \r were added; they do not matter with php and other HTML code... but they do with Perl).

2 - I have no idea if it will affect database, but I would guess that it will NOT alter any content data: that would not be very smart for a search engine!
I have downloaded the software, i have deleted/backed-up the cgi-bin folder on which the search and associated files were located. Now regarding this software i.e. UltraEdit, how can i upload the cgi-bin back to ftp.netregistry.net., the cgi-bin folder is on my machine.
I have downloaded UltraEdit Professional Text Editor V 14.10,
Can i convert the affected files from Dos to Unix,  
if yes, then where i can this option, the files always opens in DOS mode.
Found the conversion option for converting files from DOS to UNIX but didnt work..........
I have tried the other option as well, i downloaded the cgi-bin folder on my machine. converted .pl files to unix through UltraEdit, and then uploaded the folder again through SmartFTP back to Netregistry, applied the permissions.Refreshed the page, but the error is still there.
<>
Can you paste the error message?
Internal Server Error

The page you requested could not be served. This could happen for a variety of reasons, including:
A CGI script failed to produce any output.
The server is incorrectly configured.
The server encountered a critical error.
There may be more information about this error in the server's error logs.
If you have any queries about this error, please e-mail webmaster@response-systems.com.
Thanks.

But if they are working then why its generating the Error, that i told you about in my last post.
Also i have changed the value for Security_Enable to 1, now it giving this error "must supply a URL parameter.
Also on the Serach.pl file i found this code
 s!(\r|\n|\015|\012)!!sg;
i have changed it t
s!(\n)!!sg;
Also on proxy.pl (pasted below) i have found multiple occurance of \r and \015\012\ should i replace them with \n, like what i have done above. Thanks.
#!/usr/bin/perl --
#use strict;#if-debug
use Socket;
$::VERSION = '2.0.0.0073';
 
# <h1>If you can see this text from a web browser, then there is a problem.
# <a href="http://www.xav.com/scripts/search/help/1089.html">Get help here.</a></h1><xmp>
 
 
my $ext = 'pl';
$ext = $1 if (&query_env('SCRIPT_NAME') =~ m!proxy\.(\w+)$!s);
 
my $overview = <<"EOM";
 
Overview
========
 
The proxy.$ext redirect script is a utility to be used with the Fluid Dynamics
Search Engine.
 
What It Does
============
 
Visitors who wish to view a search result can request this proxy.$ext script
instead, with the destination URL passed as a parameter.  This proxy script
will request the URL on their behalf, and then display it to the visitor
with all search terms highlighted in bold yellow.  This should help the
visitor find the sought-after information.
 
More?  See: http://www.xav.com/scripts/search/help/1106.html
 
How To Enable
=============
 
First, install FDSE and make sure it works normally for normal search
results.
 
Next, test the proxy.$ext script by requesting it directly.
 
Then edit the "line_listing.txt" template.  Add a link below the search
results as follows:
 
# for *.pl script:
 
<br /><a href="proxy.pl?terms=%url_terms%&url=%url_url%">
View with Highlighted Search Terms</a>
 
# for *.cgi script:
 
<br /><a href="proxy.cgi?terms=%url_terms%&url=%url_url%">
View with Highlighted Search Terms</a>
 
On some systems, this script will be named proxy.pl, or proxy.cgi, or
proxy.somthing.  On those systems, simply use that alternate filename.
 
Copyright 2005 by Zoltan Milosevic; distributed under the same terms as FDSE.
 
EOM
 
 
# ~~ read http://www.xav.com/scripts/search/help/1106.html "Security" first ~~
#
# "turn on" the proxy:
 
my $SECURITY_ENABLE = 1;
 
# allow retrieval of only URL's on this server:
 
my $SECURITY_MATCH_SERVER_NAME = 0;
 
# allow retrieval of only URL's listed in the search.pending.txt file: (recommended)
 
my $SECURITY_MATCH_PENDING_FILE = 1;
 
# if network sockets are not allowed on this host, you must set this to zero. You will only be able to use the %maps feature.
 
my $NETWORK_SOCKETS_OK = 1;
 
# is a specific hostname must be used to access this system, enter:
 
my $SECURITY_HOSTNAME = '';
 
%::FORM = ();
&WebFormL(\%::FORM);
my $hurl = &he($::FORM{'url'});
 
 
my $highlight_open = '<span style="font-weight:bold;color:#000000;background-color:#ffff77">';
my $highlight_close = '</span>';
 
my $header = <<"EOM";
 
<meta name="robots" content="none" />
<base href="%base_href%" />
<table width="100%" border="1" bgcolor="#ffffff"><tr><td style="color:#000000"><font color="#000000">
 
	<p>This is a pre-processed version of the web page <a href="%link_href%" style="text-decoration:underline">%base_href%</a>. In this copy, the search terms %str% have been $highlight_open highlighted $highlight_close to make them easier to find. If a search term was not found, then it may exist in the non-visible title, description, keywords or URL fields, or the contents of this document may have changed since it was indexed.</p>
 
	<p>Some web pages will not display properly in this pre-processor. Visit those pages directly by following <a href="%link_href%" style="text-decoration:underline">this link</a>. Visit the page itself before bookmarking it.</p>
 
	<p align="center"><small>The search engine that brought you here is not necessarily affiliated with, nor responsible for, the contents of this page.</small></p>
 
</font></td></tr></table>
 
EOM
 
 
# optional - maps are of the form "url/" => "folder/"
# If proxy.pl intercepts a URL which matches one of these maps entries, it will do a file-request rather than an HTTP request.
# Use forward slashes for Windows paths. Always include trailing slashes.
# caveats:
#	will bypass server logging of visits
#	will bypass username-password and/or SSL protection of file
#	will return source code of file; not appropriate for active content or files that contain includes
# Remove the "#" signs in the %maps entries below to activate:
 
my %maps = (
	#'http://www.xav.com/' => '/usr/www/users/xav/',
	#'http://nickname.net/tori/' => '/usr/www/users/xav/tori/',
	);
 
%::private = ();
$::private{'PRINT_HTTP_STATUS_HEADER'} = 0;
 
 
 
my %termcount = ();
 
my %httpcookie = ();
my $NetStream = '';
my $httpInit = 1;
 
 
my $err = '';
Err: {
	local $_;
 
	unless ($SECURITY_ENABLE) {
		$err = "this proxy script is currently turned off. To turn it on, edit it's source code and set:</P><P><PRE>my \$SECURITY_ENABLE = 1;</PRE>";
		next Err;
		}
 
	my $ua_host = &query_env('HTTP_HOST');
	if (($ua_host) and ($SECURITY_HOSTNAME) and ($ua_host ne $SECURITY_HOSTNAME)) {
		$err = "this proxy script can only be accessed via hostname $SECURITY_HOSTNAME";
		next Err;
		}
 
 
	my $base_href = $hurl;
	my $link_href = $hurl;
 
	$::FORM{'terms'} = $::FORM{'terms'} || '';
	$::FORM{'terms'} =~ s!\+|\-|\||\"!!sg;
	$::FORM{'terms'} =~ s!&quot;!!sg;
	my @terms = split(m!\s+!s, $::FORM{'terms'});
 
	unless ($::FORM{'url'}) {
		$err = "must supply a URL parameter";
		next Err;
		}
 
	#changed 0056 -- override on *.pdf, *.mp3, *.doc, *.xls
	if ($::FORM{'url'} =~ m!\.(pdf|mp3|doc|xls)$!is) {
		&http_redirect( $::FORM{'url'} );
		last Err;
		}
 
 
	my $text = '';
 
 
	if (($0 =~ m!^(.+)(\\|/)!s) and ($0 !~ m!safeperl\d*$!is)) {
		unless (chdir($1)) {
			$err = "unable to chdir to script folder '$1' - $!";
			next Err;
			}
		}
 
	my $http_headers = '';
 
	GetText: {
 
		my $local_path = '';
 
		foreach (sort { length($maps{$b}) <=> length($maps{$a}) } keys %maps) { # changed 0056 - length-first search
			# i.e. http://host/cgi-bin/ comes before http://host/
			my $pat = quotemeta($_);
			next unless ($::FORM{'url'} =~ m!^$pat(.*)$!is);
			unless (-d $maps{$_}) {
				$err = "unable to find folder named '$maps{$_}'";
				next Err;
				}
			$local_path = $maps{$_} . &ud($1);
 
			if ($local_path =~ m!\.\.!s) {
				$err = "path cannot contain '..' string";
				next Err;
				}
			if (not -f $local_path) {
				# error probably due to URL == http://xav/ but FILE == http://xav/index.html
				# or due to URL == http://xav.com/index.html?query
				# not necessarily a critical error; just failover to HTTP request
				$local_path = '';
				}
			last;
			}
 
		if ($local_path) {
			unless (open(FILE, "<$local_path")) {
				$err = "unable to open file '$local_path' for reading - $!";
				next Err;
				}
			binmode(FILE);
			$text = join('',<FILE>);
			close(FILE);
			#$http_headers .= "HTTP/1.0 200 OK\015\012" if ($::private{'PRINT_HTTP_STATUS_HEADER'});
			#edit nr support
			$http_headers .= "HTTP/1.0 200 OK\n\n" if ($::private{'PRINT_HTTP_STATUS_HEADER'});
			#$http_headers .= "Content-Type: text/html\015\012\015\012";
			$http_headers .= "Content-Type: text/html\n\n";
			last GetText;
			}
 
		unless ($NETWORK_SOCKETS_OK) {
			&http_redirect( $::FORM{'url'} );
			last Err;
			}
 
 
		my ($clean, $host, $port, $path, $query);
		($err, $clean, $host, $port, $path, $query) = &uri_parse( $::FORM{'url'} );
		next Err if ($err);
 
		my $sn = &query_env('SERVER_NAME');
 
		#changed 2005-02-12
		$host =~ s!^www\.!!is;
		$sn =~ s!^www\.!!is;
 
		if (($SECURITY_MATCH_SERVER_NAME) and ($host ne $sn)) {
			$err = "this script has setting \$SECURITY_MATCH_SERVER_NAME = 1 and so it will only query web site http://$sn, not http//" . &he($host);
			next Err;
			}
		if ($SECURITY_MATCH_PENDING_FILE) {
 
			my $pending_file = 'searchdata/search.pending.txt';
 
			my $b_found = 0;
			my $qm_url = quotemeta($clean);
			# get pending file...
			unless (open(FILE, "<$pending_file")) {
				$err = "unable to read from file '$pending_file' - $!";
				next Err;
				}
			binmode(FILE);
			while (defined($_ = <FILE>)) {
				next unless (m!^$qm_url !s);
				next unless (m!^$qm_url \S+ (\d+)!s); # do expensive ()-matching only on valid lines
				next unless ($1 > 2); # match only valid points
				$b_found = 1;
				last;
				}
			close(FILE);
			unless ($b_found) {
				$err = "this script has setting \$SECURITY_MATCH_PENDING_FILE = 1 but it was not able to find the URL '" . &he($clean) . "' in the file '$pending_file'.";
				next Err;
				}
			}
 
 
		my $Method = 'GET';
		my $RequestBody = '';
		my $AllowRedir = 6;
		my %CustomHeaders = (
			'USER-AGENT' => &query_env('HTTP_USER_AGENT'),
			'REFERER' => &query_env('HTTP_REFERER'),
			);
		if ($CustomHeaders{'REFERER'} =~ m!(Mode=Admin|CP=)!s) {
			delete $CustomHeaders{'REFERER'};
			}
		#fixed 0052 - blank-spaces-in-URL bug
		$::FORM{'url'} =~ s! !%20!gs;
		my ($is_error, $error_msg, $URL, $ResponseBody, $ResponseCode, %Headers) = &http_ex($clean, $Method, $RequestBody, $AllowRedir, %CustomHeaders);
		if ($is_error) {
			$err = $error_msg;
			next Err;
			}
		if ($ResponseCode ne '200') {
			$err = "proxy.pl received HTTP response code '$ResponseCode' rather than '200 OK'";
			next Err;
			}
		#$http_headers .= "HTTP/1.0 200 OK\015\012" if ($::private{'PRINT_HTTP_STATUS_HEADER'});
		$http_headers .= "HTTP/1.0 200 OK\n\n" if ($::private{'PRINT_HTTP_STATUS_HEADER'});
		foreach (keys %Headers) {
			next if (m!^(set-cookie|content-length|connection)$!is);
			#$http_headers .= "$_: $Headers{$_}\015\012";
			$http_headers .= "$_: $Headers{$_}\n\n";
			}
		#$http_headers .= "\015\012";
		$http_headers .= "\n\n";
		$text = $ResponseBody;
 
		$base_href = $URL; # update on redirect
 
 
		# override based on content-type
		if (($Headers{'Content-Type'}) and ($Headers{'Content-Type'} !~ m!^text/!s)) {
			&http_redirect( $::FORM{'url'} );
			last Err;
			}
 
 
		last GetText;
		}
 
	#changed 0056 -- override based on document text
	if ($text =~ m!(<frameset.*?</frameset>|fdse-bypass-proxy)!is) {
		&http_redirect( $::FORM{'url'} );
		last Err;
		}
 
	print $http_headers;
 
 
	if ($::FORM{'terms'}) {
 
		my @parts = split(m!\<(SCRIPT|STYLE|TITLE)!is, $text);
 
		my $c = 0;
 
		my $new = &proc( $parts[0], @terms );
		local $_;
 
		for ($c = 1; $c < $#parts; $c += 2) {
			my $end = quotemeta(uc($parts[$c]));
			if ($parts[$c+1] =~ m!^(.*?)</$end>(.+)$!is) {
				$new .= "<$parts[$c]$1</$end>" . &proc( $2, @terms );
				}
			else {
				$new .= '<' . $parts[$c] . $parts[$c+1];
				}
			}
		$text = $new;
		}
 
	my $str = '';
	foreach (@terms) {
		my $qmterm = quotemeta($_);
		$str .= $highlight_open . &he($_) . "$highlight_close (" . ($termcount{$qmterm} || 0) . ") ";
		}
 
	$header =~ s!%base_href%!$base_href!isg;
	$header =~ s!%link_href%!$link_href!isg;
	$header =~ s!%str%!$str!isg;
 
	print $header;
	print $text;
 
 
 
	last Err;
	}
continue {
	#print "HTTP/1.0 200 OK\015\012" if ($::private{'PRINT_HTTP_STATUS_HEADER'});
	print "HTTP/1.0 200 OK\n\n" if ($::private{'PRINT_HTTP_STATUS_HEADER'});
	#print "Content-Type: text/html\015\012\015\012";
	print "Content-Type: text/html\n\n";
 
print <<"EOM";
<meta name="robots" content="none" />
<p><b>Error:</b> $err.</p>
EOM
 
	unless ($::FORM{'url'}) {
print <<"EOM";
<hr />
<form method="get" action="$ENV{'SCRIPT_NAME'}">
URL: <input name="url" value="http://" /><br />
Search Terms: <input name="terms" /> <input type="submit" value="Test" /></form>
<hr /><pre>
EOM
		print &he($overview);
		}
	}
 
 
sub proc {
	my ($text, @terms) = @_;
	local $_;
 
	my $new = '';
	foreach (split(m!<!s, $text)) {
		if (m!^(.*?)\>(.+)$!s) {
			$new .= "<$1>" . &replace($2, @terms);
			}
		else {
			$new .= "<$_";
			}
		}
	$new =~ s!^\<!!os;
	return $new;
	}
 
sub replace {
	my ($text, @terms) = @_;
	local $_;
	foreach (@terms) {
		my $qmterm = quotemeta($_);
		my $pattern = $qmterm;
		$pattern =~ s!\\\*!\\S{0,4}!gs;
		$termcount{$qmterm} += (scalar ($text =~ s!($pattern)!<<$1>>!sig));
		}
	$text =~ s!\<+!$highlight_open!sg;
	$text =~ s!\>\>+!$highlight_close!sg;
	return $text;
	}
 
 
 
 
 
=item WebFormL
 
Usage:
	&WebFormL( \%::FORM );
 
Returns a by-reference hash of all name-value pairs submitted to the CGI script.
 
updated: 8/21/2001
 
Dependencies:
	&query_env
 
=cut
 
sub WebFormL {
	my ($p_hash) = @_;
	my @Pairs = ();
	if ('POST' eq &query_env('REQUEST_METHOD')) {
		my $buffer = '';
		my $len = &query_env('CONTENT_LENGTH',0);
		read(STDIN, $buffer, $len);
		@Pairs = split(m!\&!s, $buffer);
		}
	elsif (&query_env('QUERY_STRING')) {
		@Pairs = split(m!\&!s, &query_env('QUERY_STRING'));
		}
	else {
		@Pairs = @ARGV;
		}
	local $_;
	foreach (@Pairs) {
		next unless (m!^(.*?)=(.*)$!s);
		my ($name, $value) = &ud($1,$2);
		if ($$p_hash{$name}) {
			$$p_hash{$name} .= ",$value";
			}
		else {
			$$p_hash{$name} = $value;
			}
		}
	}
 
 
=item query_env
 
Usage:
	my $remote_host = &query_env('REMOTE_HOST');
 
Abstraction layer for the %ENV hash.  Why abstract?  Here's why:
 1. adds safety for -T taint checks
 2. always returns '' if undef; prevent -w warnings
 
=cut
 
sub query_env {
	my ($name,$default) = @_;
	if (($ENV{$name}) and ($ENV{$name} =~ m!^(.*)$!s)) {
		return $1;
		}
	elsif (defined($default)) {
		return $default;
		}
	else {
		return '';
		}
	}
 
 
 
 
sub ud {
	my @out = @_;
	local $_;
	foreach (@out) {
		next unless (defined($_));
		tr!+! !;
		s!\%([a-fA-F0-9][a-fA-F0-9])!pack('C', hex($1))!esg;
		}
	if ((wantarray) or ($#out > 0)) {
		return @out;
		}
	else {
		return $out[0];
		}
	}
 
 
 
sub he {
	my @out = @_;
	local $_;
	foreach (@out) {
		$_ = '' if (not defined($_));
		s!\&!\&amp;!sg;
		s!\>!\&gt;!sg;
		s!\<!\&lt;!sg;
		s!\"!\&quot;!sg;
		}
	if ((wantarray) or ($#out > 0)) {
		return @out;
		}
	else {
		return $out[0];
		}
	}
 
 
=item http_ex
 
Usage:
	my ($is_error, $error_msg, $URL, $ResponseBody, $ResponseCode, %Headers) = &http_ex($URL, $Method, $RequestBody, $AllowRedir, %CustomHeaders);
 
	if ($is_error) {
		print "<P><B>Error:</B> $error_msg.</P>\n";
		}
 
Error message contains an error fragment, suitable for inclusion as above.
 
=cut
 
sub http_ex {
	my ($URL, $Method, $RequestBody, $AllowRedir, %CustomHeaders) = @_;
 
	my ($is_error, $error_msg) = (0, '');
 
	my ($ResponseBody, $ResponseCode, %ResponseHeaders) = ('', 0);
 
	my $trace = '';
 
	Err: {
 
		my ($Request, %Headers);
		$Method = uc($_[1] ? $_[1] : 'GET'); # default to GET; force uppercase.
		$RequestBody = '' unless $RequestBody; # init
		$AllowRedir = $_[3] ? $_[3] : 0; # force numeric
		local $_;
 
		my ($clean, $host, $port, $path, $query);
		($error_msg, $clean, $host, $port, $path, $query) = &uri_parse( $URL );
		next Err if ($error_msg);
 
		%Headers = (
			'ACCEPT', '*/*',
			'ACCEPT-ENCODING', 'none',
			'ACCEPT-LANGUAGE', 'en-us',
			'CONNECTION', 'close',
			'PRAGMA', 'no-cache',
			'USER-AGENT', 'Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)',
			);
 
		foreach (keys %CustomHeaders) {
			$Headers{uc($_)} = $CustomHeaders{$_};
			}
 
 
		#changed 0052 security/tracking
		delete $Headers{'COOKIE'};
		$Headers{'X_FORWARDED_FOR'} = &query_env('REMOTE_ADDR');
		$Headers{'VIA'} = &query_env('SERVER_NAME');
		if (&query_env('HTTP_VIA')) {
			$Headers{'VIA'} .= "; " . &query_env('HTTP_VIA');
			}
 
 
 
		# Force HTTP/1.1 compliance:
		$Headers{'HOST'} = $host . (($port == 80) ? '' : ":$port");
		if ($RequestBody) {
			$Headers{'CONTENT-LENGTH'} = length($RequestBody);
			$Headers{'CONTENT-TYPE'} = 'application/x-www-form-urlencoded' unless $Headers{'CONTENT-TYPE'};
			}
 
		# Cookies?
		unless ($Headers{'COOKIE'}) {
			$Headers{'COOKIE'} = '';
			foreach (keys %httpcookie) {
				$Headers{'COOKIE'} .= "$_=$httpcookie{$_};";
				}
			}
 
		my $CRLF = "\015\012";
 
		$Request = "$Method $path$query HTTP/1.0$CRLF";
		foreach (keys %Headers) {
			$Request .= "$_: $Headers{$_}$CRLF" if ($Headers{$_});
			}
		$Request .= "$CRLF";
		$Request .= $RequestBody;
 
 
		my $HexIP = inet_aton($host);
		unless ($HexIP) {
			$error_msg = "could not resolve hostname '$host' into an IP address";
			next Err;
			}
 
		unless (socket(HTTP, PF_INET, SOCK_STREAM, getprotobyname('tcp'))) {
			$error_msg = "could not create socket - $! ($^E)";
			next Err;
			}
		unless (connect(HTTP, sockaddr_in($port, $HexIP))) {
			$error_msg = "could not connect to '$host:$port' - $! ($^E)";
			next Err;
			}
		unless (binmode(HTTP)) {
			$error_msg = "could not set binmode on HTTP socket - $! - $^E";
			next Err;
			}
 
		select(HTTP);
		$| = 1;
		select(STDOUT);
 
		$trace = $Request;
 
		my $ExpectBytes = length($Request);
 
		my $SentBytes = send(HTTP, $Request, 0);
 
		if ($SentBytes != $ExpectBytes) {
			$error_msg = "unable to send a full $ExpectBytes - only send $SentBytes - $! ($^E)";
			close(HTTP);
			next Err;
			}
 
		my $FirstLine = <HTTP>;
 
		$trace .= $FirstLine;
 
		# Determine the HTTP version:
		if ($FirstLine =~ m!^HTTP/1.\d (\d+)!s) {
			# Is HTTP 1.x, great.
			$ResponseCode = $1;
 
			# Get HTTP headers:
			while (defined($_ = <HTTP>)) {
				$trace .= $_;
				last unless m!^(.*?)\:\s+(.*?)\r?$!s;
				$ResponseHeaders{uc($1)} = $2;
				if ((uc($1) eq 'SET-COOKIE') and ($2 =~ m!^(\w+)\=([^\;]+)!s)) {
					$httpcookie{$1} = $2;
					}
				}
 
			# Get HTTP body:
			if ($ResponseHeaders{'TRANSFER-ENCODING'} and
					($ResponseHeaders{'TRANSFER-ENCODING'} =~ m!^chunked$!is)) {
				my $buffer;
				my $ReadLine;
				while (defined($ReadLine = <HTTP>)) {
					$NetStream .= $ReadLine;
					last unless ($ReadLine =~ m!^(\w+)\r?$!s);
					last unless read(HTTP, $buffer, hex($1));
					$trace .= $buffer;
					$ResponseBody .= $buffer;
					}
				}
			else {
				$ResponseBody = '';
				while (defined($_ = <HTTP>)) {
					$ResponseBody .= $_;
					}
				$trace .= $ResponseBody;
				}
			}
		else {
 
			# This is an HTTP 0.9 response, which has no headers:
 
			# Set Code to 200 to satisfy 80% of customers:
			$ResponseCode = 200;
 
			$ResponseBody = $FirstLine;
			while (defined($_ = <HTTP>)) {
				$trace .= $_;
				$ResponseBody .= $_;
				}
			}
		close(HTTP);
		if ($AllowRedir and ($ResponseCode =~ m!^(301|302)$!s)) {
			$httpInit = 0;
			$AllowRedir--;
			my ($err, $clean) = &uri_merge( $URL, $ResponseHeaders{'LOCATION'} );
			if ($err) {
				$error_msg = $err;
				next Err;
				}
			return &http_ex($clean, 'GET', '', $AllowRedir, %CustomHeaders);
			}
		else {
			$httpInit = 1;
			}
		last Err;
		}
	continue {
		$is_error = 1;
		}
	return ($is_error, $error_msg, $URL, $ResponseBody, $ResponseCode, %ResponseHeaders);
	}
 
 
 
 
=item Trim
 
Usage:
 
	my $word = &Trim("  word  \t\n");
 
Strips whitespace and line breaks from the beginning and end of the argument.
 
=cut
 
sub Trim {
	local $_ = defined($_[0]) ? $_[0] : '';
	s!^[\r\n\s]+!!os;
	s![\r\n\s]+$!!os;
	return $_;
	}
 
 
 
 
 
sub http_redirect {
	my ($url) = @_;
	$url =~ s!\s!\%20!sg; # strips vertical whitespace, primary concern here
	print "HTTP/1.0 302 Moved\015\012" if ($::private{'PRINT_HTTP_STATUS_HEADER'});
	print "Status: 302 Moved\015\012";
	print "Location: $url\015\012";
	print "\015\012";
	};
 
# updated from master Common.pm for release 0073
sub uri_parse {
	my ($str, $b_retain_frag) = @_;
	my ($err, $clean, $host, $port, $path, $query, $frag, $folder) = ('', '', '', 80, '', '', '', '');
	Err: {
 
		local $_ = $str;
 
		# basic validation steps:
 
		if (not defined($_)) {
			my ($package, $filename, $line) = caller();
			$err = "invalid argument.  Sub <code>uri_parse(URL)</code> called with undefined parameter from file $filename line $line";
			next Err;
			}
 
		my $len = length($_);
		if (($len == 0) or ($_ eq 'http://')) {
			$err = 'invalid argument; URL cannot be blank';
			next Err;
			}
 
		my $maxlen = 2048;
		if ($len > $maxlen) {
			$err = "URL length $len characters is too long.  This software has a limit of $maxlen characters in a URL string";
			next Err;
			}
 
		my $hstr = &he($_);
 
		# free validation - remove leading and trailing whitespace and zero out internal vertical whitespace and tabs
		s!^\s+!!s;
		s!\s+$!!s;
		s!(\r|\n|\015|\012|\t)!!sg;
		s!\s!%20!sg; # for spaces to '%20'
 
		# format validation:
 
		unless (m!^(\w+)\:(.*)$!s) {
			$err = "string '$hstr' is not a valid HTTP URL.  Must be of the format 'http://host.tld/path/file.ext'";
			next Err;
			}
 
		my $protocol = lc($1);
		$_ = $2;
		if ($protocol ne 'http') {
			$err = "string '$hstr' not accepted as HTTP URL.  This software supports only the 'http' protocol, not '$protocol'";
			next Err;
			}
 
		unless (m!^//(.+)$!s) {
			# punish the f**ing morons who enter http:\\xav.com
			$err = "string '$hstr' is not a valid HTTP URL.  The sequence '//' must follow leading 'http:'";
			next Err;
			}
		$_ = $1;
 
		# extract the host and port portion - basically, anything up till the next "/" or the end of the string
		if (m!^(.+?)/(.*)$!s) {
			$host = $1;
			$_ = "/$2";
			}
		else {
			$host = $_;
			$_ = '/';
			}
 
		# perform a URL-decode operation on the server portion; this is allowed because we are free and clear to URL-decode anything we want before the ?
		# user:pass%40host => user:pass@host
		# xav.%63om => xav.com
 
		# URL-decode the hostname, but don't touch '+' signs; just %HH sequences:
		$host =~ s!\+!\%2B!sg;
		$host = &ud($host);
 
		#changed 2003-03-17; force lc()!!
		$host = lc($host);
 
		# is there a user:pass@host format?
		if ($host =~ m!\@!s) {
			$err = "string '$hstr' cannot be parsed as an HTTP URL due to presence of an '\@' character in the hostname substring.  Note that this software does not accept username and password information within the URL string";
			next Err;
			}
 
		# is there a numeric port?
		if ($host =~ m!^(.+)\:(\d+)$!s) {
			$host = $1;
			$port = 1 * $2; # force as number not string - helps deal with "0080" as port
			}
		if (($port < 1) or ($port > 65536)) {
			$err = "string '$hstr' is not a valid HTTP URL.  Port number $port is outside the allowed range 1-65536";
			next Err;
			}
 
		# are the hostname characters valid?
 
	# TODO - what about Windows Netbios names which can contain underscores and non-printable characters?
	# what about the extensions to DNS that allow for localized names? i.e. Unicode DNS, etc.?  (seems to be mostly vaporware for now)
	# what about TLD validation -- there is a known subset of TLD's
 
		if ($host =~ m![^a-z0-9\.\-]!s) {
			$err = "string '$hstr' is not a valid HTTP URL.  The hostname portion contains characters outside the allowed character set of a-z, 0-9, '.' and '-'";
			next Err;
			}
 
		my $hlen = length($host);
		my $hmax = 255;
		if ($hlen > $hmax) {
			$err = "string '$hstr' is not a valid HTTP URL.  The hostname substring is $hlen characters, but the maximum allowed length is $hmax characters";
			next Err;
			}
 
		IsNumberAddr: {
 
			my $b_invalid = 0;
			my $count = 0;
			foreach (split(m!\.!s, $host)) {
				$count++;
				if (m!^0\d+$!s) { # octal
					$b_invalid = 1;
					next;
					}
				if (m!^\d+$!s) { # decimal, non-octal
					$b_invalid = 1 if ($_ > 255);
					next;
					}
				if (m!^0x[0-9a-f]+$!is) { # hex
					$b_invalid = 1;
					next;
					}
				last IsNumberAddr;
				}
 
			# if we get here, then *all* components were numeric (octal or decimal) and/or hex 0xAA.0x9B.etc...
			# we accept *only* decimal numeric with all 4 octets separated
 
			if (($b_invalid) or (4 != $count)) {
				$err = "string '$hstr' not accepted as HTTP URL.  When using a numeric host address (IP address), must use dotted decimal notation such as 255.1.1.1.  This software does not support octal or hex representations, nor octet grouping";
				next Err if ($err);
				}
 
 
			}
 
 
 
		# extract the fragment identifier
 
		if (m!^(.*?)\#(.*)$!s) {
			$_ = $1;
			$frag = '#' . $2 if (length($2));
			}
 
		# extract the query string
 
		if (m!^(.*?)\?(.*)$!s) {
			$_ = $1;
			$query = '?' . $2 if (length($2));
			}
 
		# URL-decode the remaining path portion, but only %HH sequences -- leave '+' as literal
		s!\+!\%2B!sg;
		$path = &ud($_);
 
		# perform magic on . .. / sequences in the path
 
			while ($path =~ s!/+\./+!/!s) {} # make foo/./bar become foo/bar
 
			$path =~ s!/+\.$!/!sg;  # map trailing /. => /
 
			# nuke all leading "/../" entries (meaningless for us)
			# map /../foo => /foo
			while ($path =~ s!^/+\.\./+!/!s) {}
 
 
			# map "folder/../" => "/"
			# map "bar/folder/../" => "bar//"
			while ($path =~ s!([^/]+)/+\.\./+!/!s) {} # BUG - this'll glitch on /foo/./../bar/ => becomes /foo/bar/ but should be /foo/
 
 
			# map "/folder/.." => "/"
			$path =~ s!/+([^/]+)/+\.\.$!/!s;
 
			$path =~ s!/+!/!sg; # collapse chained / characters
 
 
		$path =~ s!\%!%25!sg; # 2003-03-17 force required URL-encodings to return
		$path =~ s!\s!%20!sg;
		$path =~ s!\#!%23!sg;
 
 
		$clean = 'http://' . $host;
		if ($port != 80) {
			$clean .= ':' . $port;
			}
		$clean .= $path;
 
		$folder = $clean;
		$folder =~ s!/([^/]*)$!/!; # strip anything past the last slash (i.e., a filename)
 
		$clean .= $query;
		$clean .= $frag if ($b_retain_frag);
 
		last Err;
		}
	continue {
		# error response should have all other return values zero'ed
		($clean, $host, $port, $path, $query, $frag, $folder) = ('', '', 80, '', '', '', '');
		}
	return ($err, $clean, $host, $port, $path, $query, $frag, $folder);
	}
 
 
 
sub uri_merge {
	my ($v_base, $str) = @_;
	my $err = '';
	my $clean = '';
	Err: {
 
		local $_;
 
		if ('ARRAY' ne ref($v_base)) {
			$v_base = [ &uri_parse( $v_base ) ]; # anonymous array reference to return values
			}
 
		if ($v_base->[0]) {
			# there was an error in parsing the base URL
			# the $str can be returned as $clean iff it validated on its own
 
			($err, $clean) = &uri_parse( $str );
			last Err unless ($err);
 
			# oh.. there was an error - how do we explain this to our end user?
 
			# don't worry too much about the format of this string.  it is *extremely* rare for us to arrive at a situation where
			# the $base_url is not valid in our context.  the only case would be when parsing an HTML document which contains a <base href=""> tag
			# that is malformed or that uses an unsupported protocol like https://xav.com/
			#
			# we only go critical and print the $err from uri_merge in cases of HTTP redirects, and so the $base_url-is-invalid scenario is
			# unlikely to arise in that context
 
			$err = qq!unable to merge URL with fragment.  The primary URL failed to validate with:</p><p style="margin-left:20px"><strong>Error:</strong> $v_base->[0].</p><p>Because the primary URL failed, the fragment could only be evaluated as a stand-alone URL.  It failed that evaluation with:</p><p style="margin-left:20px"><strong>Error:</strong> $err!;
			next Err;
			}
 
		# okay - more general case - base_url valid
 
		local $_ = $str;
 
		if (m!^/!s) {
			# absolute link from top-level directory
			$_ = 'http://' . $v_base->[2] . ':' . $v_base->[3] . $_;
			}
 
		elsif (m!^\#!s) {
			# a relative link on this page.  just strip any current frag and append this one
			$_ = 'http://' . $v_base->[2] . ':' . $v_base->[3] . $v_base->[4] . $v_base->[5] . $_;
			}
 
		elsif (m!^\w+\:!s) {
			# a protocol link.  this link stands on its own as $_
			}
 
		else {
			# relative link
			$_ = $v_base->[7] . $_;
			}
 
		($err, $clean) = &uri_parse( $_ );
		next Err if ($err);
		last Err;
		}
	return ($err, $clean);
	};
 
 
 
1;

Open in new window

s!(\r|\n|\015|\012)!!sg;
i have changed it t
s!(\n)!!sg;
-- I think this should be restored back to the previous state, but read below

Also on proxy.pl (pasted below) i have found multiple occurance of \r and \015\012\ should i replace them with \n, like what i have done above.
-- This should not happen. Therefore suspicious.

a - since you now have backupped in local the whole 'search' directory as well as its subdirectory, please delete now all files in these directory on the remote and on the local systems.
Please check and confirm that there remains no file in any of theses (sub)directories. Keep the directories as they are, since they now have the correct access rights.
This should remove all files with a fuzzy status of \r and \n

b - using the new archive you have downloaded from xav site: unzip it on you local machine in the search directory
This should place in the 'search' directory all the needed files. Since they come directly out of the archive, they should have no \r in end of lines.

c - directly upload the local /search directory to the remote /search directory
Please check and confirm this operation went correctly

d - you can now check the scripts. Report diagnostices.

I replaced \015\012\ to \n, because that was reccommended to me from Netregistry, i have mentioned it in my post at "07.05.2008 at 05:51PM ", if you think its not right i will replace it back to \015\012\.
Also i want to make one thing clear, you said "check and confirm that there remains no file in any of theses (sub)directories" , does that mean i will delete everything in these directories, also if you look at the stagging website and click on knowledgebase, its producing the same error, the reason being its using the search.pl. So there are two search.pl files, one in knowledgebase and one in search folder.
Usmansultan: netregistry explained you what was one cause of problem. they suggested solutions but not complete solutions. The precise replace you have done is probably wrong, but the step I suggest should solve the problem.
Please do them!!!!!!!!!!!!!!!!!!

So there are two search.pl files, one in knowledgebase and one in search folder.
Let's not err. They are probably the same. BUT please do the corrections suggested, then we'll check what happens.

Although I understand you want to understand where the errors come from and the details of the solutions suggested, please also understand that here is not a place for a full detailed course. When I am making suggestions, please apply them!

If you look back at this thread, you will see that each of my suggestions:
a - has made you progress towards your objective
b - was sometimes not clear enough in my wording, and therefore you rightfully asked for clarification in these situations
c - most of the times, required between 1-3 additional exchanges (2-6 posts) before you accepted to do them. This point shows clearly that we could use our time more efficiently.
Will do, but can you please tell me what do you mean by "please delete now all files in these directory on the remote and on the local systems" which files should remain and which files i have to delete...
The idea is that you clean up all these directories, removing from them any file that lays there, possibly/ potentially with some end-of-line problem.
Then the fresh copy directly from the archive should put things straight as they should, with Unix-type ends-of-line
And then transferring them thru ftp to the remote site should not alter the ASCII flow
I deleted all files in the search directory on the remote and on the local systems.

I downloaded the search script which you suggested me, i.e.

http://www.xav.com/scripts/search/download/fdse.2.0.0.0073.tar.gz

I uncompresses it to a folder which became search directory, then i directly uploaded the local /search directory to the remote /search directory, under cgi-bin folder. Tested it, didnt work, then i found around four folders in which search.pl and proxy.pl were used like knowledgebase folder and under \usr\local\httpd\cgi-bin\, i deleted all files and uploaded the new search directory, but didnt worked out, its giving the same error 500.
 
"Internal Server Error
The page you requested could not be served. This could happen for a variety of reasons, including:
A CGI script failed to produce any output.
The server is incorrectly configured.
The server encountered a critical error.
There may be more information about this error in the server's error logs.
If you have any queries about this error, please e-mail webmaster@response-systems.com. "
http://rere6659.staging-zeus.netregistry.net/cgi-bin/search/search.pl?xxx
shows that your script launches correctly and that the \r problem seems now solved
Comparing with http://response-systems.com/cgi-bin/search/search.pl?xxx
shows that there are indeed differences.

http://rere6659.staging-zeus.netregistry.net/cgi-bin/search/search.pl?Terms=Support
generates the error message you mentioned.
What puzzles me however is that this message points to your prod system while this is supposed to appear nowhere in the Perl scripts on your local or on the staging system.
  • It seems that there is some parameter file for the search with that information, somewhere on your site. Can you find this file? what is its content?
  • Or maybe this parameter is present in some database as "site parameter". Can you check which ones?
Finding these on the prod and on the staging systems would pinpoint you to the changes needed for adapting your scripts.


To summarize:
  • you have now working directories and script
  • you need to initialize whichever database is needed for the search
  • you need to find which changes should be done to some files or data so that the scripts, which are currently working but not as expected, do run as expected.


Can you please refine more if possible about the parameter files that you are mentioning, what would be there extensions or how they look like, also would there be a database for the search engine?
no idea. I don't know this software. You know it as well as yout site's, so you are the nest -placed to find that.

COMPARE each directory within the prod and staging sites
I tried to do an automatic install of the search engine script, it produced this error;

Error: could not verify that web address 'http://rere6659.staging-zeus.netregistry.net/' maps to FTP site 'ftp://ftp.netregistry.net/'. This may be a problem with the FTP path. To assist with FTP path discovery, below is the output of the "list" command from the initial FTP directory:
drwxr-xr-x 2 rere6659 response-systems.com 4096 Jul 3 16:10 Assets
-rw-r--r-- 1 rere6659 response-systems.com 4746 Jun 4 11:43 Customer Reports.htm
-rw-r--r-- 1 rere6659 response-systems.com 10 Jun 4 11:43 Customer Reports.htm.LCK
drwxr-xr-x 2 rere6659 response-systems.com 4096 Jul 3 16:05 Mail
drwxr-xr-x 2 rere6659 response-systems.com 4096 Jul 3 14:35 Shellx
drwxr-xr-x 2 rere6659 response-systems.com 4096 Jun 4 10:13 _borders
drwx------ 2 rere6659 response-systems.com 4096 May 27 13:04 _private
drwxr-xr-x 4 rere6659 response-systems.com 4096 May 27 13:04 _vti_bin
drwxr-xr-x 2 rere6659 response-systems.com 4096 Jun 3 16:14 _vti_cnf
-rw-r--r-- 1 rere6659 response-systems.com 1754 Jun 4 16:14 _vti_inf.html
drwxr-xr-x 2 rere6659 response-systems.com 4096 May 27 13:04 _vti_log
drwxr-xr-x 2 rere6659 response-systems.com 4096 May 27 13:04 _vti_pvt
drwxr-xr-x 2 rere6659 response-systems.com 4096 May 27 13:04 _vti_txt
drwxr-xr-x 2 rere6659 response-systems.com 4096 May 30 11:15 about
drwxr-xr-x 6 rere6659 response-systems.com 4096 Jul 3 16:10 admin
drwxr-xr-x 2 rere6659 response-systems.com 4096 May 30 11:16 announcements
-rw-r--r-- 1 rere6659 response-systems.com 1867 Jul 1 12:51 audit.pl
drwxr-xr-x 2 rere6659 response-systems.com 4096 Jul 3 16:10 bin
drwxr-xr-x 2 rere6659 response-systems.com 4096 Jul 3 16:10 cgi-src
drwxr-xr-x 3 rere6659 response-systems.com 4096 Jul 3 16:03 compat
drwxr-xr-x 2 rere6659 response-systems.com 4096 Jul 3 16:03 conf
drwxr-xr-x 2 rere6659 response-systems.com 4096 Jun 18 17:20 contact
-rw-r--r-- 1 rere6659 response-systems.com 599 Jun 6 13:21 dbtesting.php
drwxr-xr-x 4 rere6659 response-systems.com 4096 May 30 11:17 de
-rw-r--r-- 1 rere6659 response-systems.com 0 Jun 4 11:43 dead.letter
drwxr-xr-x 2 rere6659 response-systems.com 4096 Jul 3 14:40 dev
drwxr-xr-x 3 rere6659 response-systems.com 4096 May 30 11:17 enquiry
drwxr-xr-x 4 rere6659 response-systems.com 4096 May 30 11:17 es
drwxr-xr-x 4 rere6659 response-systems.com 4096 Jul 3 16:04 etc
drwxr-xr-x 2 rere6659 response-systems.com 4096 Jul 3 16:04 files
drwxr-xr-x 2 rere6659 response-systems.com 4096 May 30 11:17 find
drwxr-xr-x 4 rere6659 response-systems.com 4096 May 30 11:17 fr
-rw-r--r-- 1 rere6659 response-systems.com 413 Jun 4 16:14 htaccess.backup
drwxr-xr-x 2 rere6659 response-systems.com 4096 Jun 3 13:09 icons
drwxr-xr-x 5 rere6659 response-systems.com 4096 Jun 3 13:50 images
drwxr-xr-x 12 rere6659 response-systems.com 4096 Jul 3 16:04 imanager
-rw-r--r-- 1 rere6659 response-systems.com 5198 Jul 1 14:14 index.php
-rw-r--r-- 1 rere6659 response-systems.com 5171 Jun 4 11:43 kb_master1.cgi
drwxr-xr-x 2 rere6659 response-systems.com 4096 Jun 2 17:08 links
drwxr-xr-x 2 rere6659 response-systems.com 4096 Jun 3 12:08 logs
drwxr-xr-x 2 rere6659 response-systems.com 4096 Jul 3 16:05 mail
drwxr-xr-x 4 rere6659 response-systems.com 4096 Jun 2 17:08 mhorag
drwxr-xr-x 2 rere6659 response-systems.com 4096 Jul 3 16:05 modules
drwxr-xr-x 9 rere6659 response-systems.com 4096 Jul 3 16:05 new
-rw-r--r-- 1 rere6659 response-systems.com 2457 May 27 13:04 postinfo.html
drwxr-xr-x 2 rere6659 response-systems.com 4096 Jun 2 17:08 privacy
drwxr-xr-x 2 rere6659 response-systems.com 4096 Jun 4 10:24 sbin
-rw-r--r-- 1 rere6659 response-systems.com 21 Jun 4 11:43 script1.scp
drwxr-xr-x 2 rere6659 response-systems.com 4096 May 27 12:48 secure
-rwxr-xr-x 1 rere6659 response-systems.com 2109 Jun 25 17:09 session_1_2.sh
drwxr-xr-x 2 rere6659 response-systems.com 4096 Jul 11 12:34 sessions
drwxr-xr-x 7 rere6659 response-systems.com 4096 Jun 2 17:09 solutions
drwx--x--x 4 rere6659 response-systems.com 4096 May 27 12:48 stats
-rw-r--r-- 1 rere6659 response-systems.com 6716 Jun 4 11:44 style.css
drwxr-xr-x 5 rere6659 response-systems.com 4096 Jun 3 12:05 support
drwxr-xr-x 2 rere6659 response-systems.com 4096 Jul 4 12:14 test
drwxrwxrwx 4 rere6659 response-systems.com 4096 Jul 3 14:37 tmp
drwxr-xr-x 4 rere6659 response-systems.com 4096 Jun 2 17:09 urchin
-rw-r--r-- 1 rere6659 response-systems.com 4535 Jul 8 11:06 urchinconf.3473
drwxr-xr-x 11 rere6659 response-systems.com 4096 Jul 3 15:53 usr
drwxr-xr-x 6 rere6659 response-systems.com 4096 Jul 3 16:09 var
drwxr-xr-x 2 rere6659 response-systems.com 4096 Jul 3 15:38 vhosts
drwxr-xr-x 4 rere6659 response-systems.com 4096 Jul 9 10:33 www
drwxr-xr-x 2 rere6659 response-systems.com 4096 Jul 3 14:39 xfer

Click here to explore the FTP system.
Error: no combination of Perl extensions and paths resulted in CGI script execution. Make sure that your web server is CGI-compliant, and that you're using the correct extension and path. Tried all combinations of extensions: 'pl,cgi' and paths '/usr/bin/perl,/usr/local/bin/perl,/usr/local/bin/perl5,/usr/bin/perl5,/bin/perl,/bin/perl5.005_03'.
I did a complete trace of when it transfers the script through FTP, it produced this message..


Socket connected 'ftp.netregistry.net:21'...
220 ftp.netregistry.net ready.
USER user
331 Password required for user.
PASS password
230 User user logged in.
PORT 209,68,2,46,237,230
200 PORT command successful
LIST
150 Opening ASCII mode data connection for file list
Attempting to read response on control socket...

226 Transfer complete.
PWD
257 "/" is current directory.
Adding absolute FTP path '/.'.
Adding absolute FTP path '/public_html'.
Adding absolute FTP path '/public_html/cgi-bin'.
Adding absolute FTP path '/var/www/cgi-bin'.
Adding absolute FTP path '/htdocs'.
Adding absolute FTP path '/public-web'.
Adding absolute FTP path '/cgi-bin'.
Adding absolute FTP path '/www'.
Adding absolute FTP path '/www/cgi-bin'.
Adding absolute FTP path '/web'.
Adding absolute FTP path '/web'.
Adding absolute FTP path '/~rere6659'.
Adding absolute FTP path '/~rere6659/public_html'.
Adding absolute FTP path '/html'.
Adding absolute FTP path '/rere6659.staging-zeus.netregistry.net'.
Trying FTP directory '/.'
CWD /.
250 CWD command successful
testing file extension pl with Perl path /usr/bin/perl
TYPE A
200 Type set to A
FTP->put( fd_installer.pl )
PORT 209,68,2,46,203,220
200 PORT command successful
STOR fd_installer.pl
150 Opening ASCII mode data connection for fd_installer.pl
Attempting to read response on control socket...

226 Transfer complete.
SITE chmod 755 fd_installer.pl
200 SITE CHMOD command successful
beginning HTTP audit request to http://rere6659.staging-zeus.netregistry.net/fd_installer.pl 
DELE fd_installer.pl
250 DELE command successful
testing file extension pl with Perl path /usr/local/bin/perlFTP->put( fd_installer.pl )
PORT 209,68,2,46,247,149
200 PORT command successful
STOR fd_installer.pl
150 Opening ASCII mode data connection for fd_installer.pl
Attempting to read response on control socket...

226 Transfer complete.
SITE chmod 755 fd_installer.pl
200 SITE CHMOD command successful
beginning HTTP audit request to http://rere6659.staging-zeus.netregistry.net/fd_installer.pl 
DELE fd_installer.pl
250 DELE command successful
testing file extension pl with Perl path /usr/local/bin/perl5FTP->put( fd_installer.pl )
PORT 209,68,2,46,253,191
200 PORT command successful
STOR fd_installer.pl
150 Opening ASCII mode data connection for fd_installer.pl
Attempting to read response on control socket...

226 Transfer complete.
SITE chmod 755 fd_installer.pl
200 SITE CHMOD command successful
beginning HTTP audit request to http://rere6659.staging-zeus.netregistry.net/fd_installer.pl 
DELE fd_installer.pl
250 DELE command successful
testing file extension pl with Perl path /usr/bin/perl5FTP->put( fd_installer.pl )
PORT 209,68,2,46,212,221
200 PORT command successful
STOR fd_installer.pl
150 Opening ASCII mode data connection for fd_installer.pl
Attempting to read response on control socket...

226 Transfer complete.
SITE chmod 755 fd_installer.pl
200 SITE CHMOD command successful
beginning HTTP audit request to http://rere6659.staging-zeus.netregistry.net/fd_installer.pl 
DELE fd_installer.pl
250 DELE command successful
testing file extension pl with Perl path /bin/perlFTP->put( fd_installer.pl )
PORT 209,68,2,46,205,38
200 PORT command successful
STOR fd_installer.pl
150 Opening ASCII mode data connection for fd_installer.pl
Attempting to read response on control socket...

226 Transfer complete.
SITE chmod 755 fd_installer.pl
200 SITE CHMOD command successful
beginning HTTP audit request to http://rere6659.staging-zeus.netregistry.net/fd_installer.pl 
DELE fd_installer.pl
250 DELE command successful
testing file extension pl with Perl path /bin/perl5.005_03FTP->put( fd_installer.pl )
PORT 209,68,2,46,203,55
200 PORT command successful
STOR fd_installer.pl
150 Opening ASCII mode data connection for fd_installer.pl
Attempting to read response on control socket...

226 Transfer complete.
SITE chmod 755 fd_installer.pl
200 SITE CHMOD command successful
beginning HTTP audit request to http://rere6659.staging-zeus.netregistry.net/fd_installer.pl 
DELE fd_installer.pl
250 DELE command successful
testing file extension cgi with Perl path /usr/bin/perlFTP->put( fd_installer.cgi )
PORT 209,68,2,46,247,13
200 PORT command successful
STOR fd_installer.cgi
150 Opening ASCII mode data connection for fd_installer.cgi
Attempting to read response on control socket...

226 Transfer complete.
SITE chmod 755 fd_installer.cgi
200 SITE CHMOD command successful
beginning HTTP audit request to http://rere6659.staging-zeus.netregistry.net/fd_installer.cgi 
DELE fd_installer.cgi
250 DELE command successful
testing file extension cgi with Perl path /usr/local/bin/perlFTP->put( fd_installer.cgi )
PORT 209,68,2,46,231,44
200 PORT command successful
STOR fd_installer.cgi
150 Opening ASCII mode data connection for fd_installer.cgi
Attempting to read response on control socket...

226 Transfer complete.
SITE chmod 755 fd_installer.cgi
200 SITE CHMOD command successful
beginning HTTP audit request to http://rere6659.staging-zeus.netregistry.net/fd_installer.cgi 
DELE fd_installer.cgi
250 DELE command successful
testing file extension cgi with Perl path /usr/local/bin/perl5FTP->put( fd_installer.cgi )
PORT 209,68,2,46,194,26
200 PORT command successful
STOR fd_installer.cgi
150 Opening ASCII mode data connection for fd_installer.cgi
Attempting to read response on control socket...

226 Transfer complete.
SITE chmod 755 fd_installer.cgi
200 SITE CHMOD command successful
beginning HTTP audit request to http://rere6659.staging-zeus.netregistry.net/fd_installer.cgi 
DELE fd_installer.cgi
250 DELE command successful
testing file extension cgi with Perl path /usr/bin/perl5FTP->put( fd_installer.cgi )
PORT 209,68,2,46,237,65
200 PORT command successful
STOR fd_installer.cgi
150 Opening ASCII mode data connection for fd_installer.cgi
Attempting to read response on control socket...

226 Transfer complete.
SITE chmod 755 fd_installer.cgi
200 SITE CHMOD command successful
beginning HTTP audit request to http://rere6659.staging-zeus.netregistry.net/fd_installer.cgi 
DELE fd_installer.cgi
250 DELE command successful
testing file extension cgi with Perl path /bin/perlFTP->put( fd_installer.cgi )
PORT 209,68,2,46,253,252
200 PORT command successful
STOR fd_installer.cgi
150 Opening ASCII mode data connection for fd_installer.cgi
Attempting to read response on control socket...

226 Transfer complete.
SITE chmod 755 fd_installer.cgi
200 SITE CHMOD command successful
beginning HTTP audit request to http://rere6659.staging-zeus.netregistry.net/fd_installer.cgi 
DELE fd_installer.cgi
250 DELE command successful
testing file extension cgi with Perl path /bin/perl5.005_03FTP->put( fd_installer.cgi )
PORT 209,68,2,46,216,182
200 PORT command successful
STOR fd_installer.cgi
150 Opening ASCII mode data connection for fd_installer.cgi
Attempting to read response on control socket...

226 Transfer complete.
SITE chmod 755 fd_installer.cgi
200 SITE CHMOD command successful
beginning HTTP audit request to http://rere6659.staging-zeus.netregistry.net/fd_installer.cgi 
DELE fd_installer.cgi
250 DELE command successful
Trying FTP directory '/public_html'
CWD /public_html
550 /public_html: No such file or directory
Trying FTP directory '/public_html/cgi-bin'
CWD /public_html/cgi-bin
550 /public_html/cgi-bin: No such file or directory
Trying FTP directory '/var/www/cgi-bin'
CWD /var/www/cgi-bin
550 /var/www/cgi-bin: No such file or directory
Trying FTP directory '/htdocs'
CWD /htdocs
550 /htdocs: No such file or directory
Trying FTP directory '/public-web'
CWD /public-web
550 /public-web: No such file or directory
Trying FTP directory '/cgi-bin'
CWD /cgi-bin
550 /cgi-bin: No such file or directory
Trying FTP directory '/www'
CWD /www
250 CWD command successful
testing file extension pl with Perl path /usr/bin/perlFTP->put( fd_installer.pl )
PORT 209,68,2,46,245,60
200 PORT command successful
STOR fd_installer.pl
150 Opening ASCII mode data connection for fd_installer.pl
Attempting to read response on control socket...

226 Transfer complete.
SITE chmod 755 fd_installer.pl
200 SITE CHMOD command successful
beginning HTTP audit request to http://rere6659.staging-zeus.netregistry.net/fd_installer.pl 
DELE fd_installer.pl
250 DELE command successful
testing file extension pl with Perl path /usr/local/bin/perlFTP->put( fd_installer.pl )
PORT 209,68,2,46,233,125
200 PORT command successful
STOR fd_installer.pl
150 Opening ASCII mode data connection for fd_installer.pl
Attempting to read response on control socket...

226 Transfer complete.
SITE chmod 755 fd_installer.pl
200 SITE CHMOD command successful
beginning HTTP audit request to http://rere6659.staging-zeus.netregistry.net/fd_installer.pl 
DELE fd_installer.pl
250 DELE command successful
testing file extension pl with Perl path /usr/local/bin/perl5FTP->put( fd_installer.pl )
PORT 209,68,2,46,252,33
200 PORT command successful
STOR fd_installer.pl
150 Opening ASCII mode data connection for fd_installer.pl
Attempting to read response on control socket...

226 Transfer complete.
SITE chmod 755 fd_installer.pl
200 SITE CHMOD command successful
beginning HTTP audit request to http://rere6659.staging-zeus.netregistry.net/fd_installer.pl 
DELE fd_installer.pl
250 DELE command successful
testing file extension pl with Perl path /usr/bin/perl5FTP->put( fd_installer.pl )
PORT 209,68,2,46,193,116
200 PORT command successful
STOR fd_installer.pl
150 Opening ASCII mode data connection for fd_installer.pl
Attempting to read response on control socket...

226 Transfer complete.
SITE chmod 755 fd_installer.pl
200 SITE CHMOD command successful
beginning HTTP audit request to http://rere6659.staging-zeus.netregistry.net/fd_installer.pl 
DELE fd_installer.pl
250 DELE command successful
testing file extension pl with Perl path /bin/perlFTP->put( fd_installer.pl )
PORT 209,68,2,46,207,207
200 PORT command successful
STOR fd_installer.pl
150 Opening ASCII mode data connection for fd_installer.pl
Attempting to read response on control socket...

226 Transfer complete.
SITE chmod 755 fd_installer.pl
200 SITE CHMOD command successful
beginning HTTP audit request to http://rere6659.staging-zeus.netregistry.net/fd_installer.pl 
DELE fd_installer.pl
250 DELE command successful
testing file extension pl with Perl path /bin/perl5.005_03FTP->put( fd_installer.pl )
PORT 209,68,2,46,192,139
200 PORT command successful
STOR fd_installer.pl
150 Opening ASCII mode data connection for fd_installer.pl
Attempting to read response on control socket...

226 Transfer complete.
SITE chmod 755 fd_installer.pl
200 SITE CHMOD command successful
beginning HTTP audit request to http://rere6659.staging-zeus.netregistry.net/fd_installer.pl 
DELE fd_installer.pl
250 DELE command successful
testing file extension cgi with Perl path /usr/bin/perlFTP->put( fd_installer.cgi )
PORT 209,68,2,46,205,133
200 PORT command successful
STOR fd_installer.cgi
150 Opening ASCII mode data connection for fd_installer.cgi
Attempting to read response on control socket...

226 Transfer complete.
SITE chmod 755 fd_installer.cgi
200 SITE CHMOD command successful
beginning HTTP audit request to http://rere6659.staging-zeus.netregistry.net/fd_installer.cgi 
DELE fd_installer.cgi
250 DELE command successful
testing file extension cgi with Perl path /usr/local/bin/perlFTP->put( fd_installer.cgi )
PORT 209,68,2,46,197,33
200 PORT command successful
STOR fd_installer.cgi
150 Opening ASCII mode data connection for fd_installer.cgi
Attempting to read response on control socket...

226 Transfer complete.
SITE chmod 755 fd_installer.cgi
200 SITE CHMOD command successful
beginning HTTP audit request to http://rere6659.staging-zeus.netregistry.net/fd_installer.cgi 
DELE fd_installer.cgi
250 DELE command successful
testing file extension cgi with Perl path /usr/local/bin/perl5FTP->put( fd_installer.cgi )
PORT 209,68,2,46,249,164
200 PORT command successful
STOR fd_installer.cgi
150 Opening ASCII mode data connection for fd_installer.cgi
Attempting to read response on control socket...

226 Transfer complete.
SITE chmod 755 fd_installer.cgi
200 SITE CHMOD command successful
beginning HTTP audit request to http://rere6659.staging-zeus.netregistry.net/fd_installer.cgi 
DELE fd_installer.cgi
250 DELE command successful
testing file extension cgi with Perl path /usr/bin/perl5FTP->put( fd_installer.cgi )
PORT 209,68,2,46,200,91
200 PORT command successful
STOR fd_installer.cgi
150 Opening ASCII mode data connection for fd_installer.cgi
Attempting to read response on control socket...

226 Transfer complete.
SITE chmod 755 fd_installer.cgi
200 SITE CHMOD command successful
beginning HTTP audit request to http://rere6659.staging-zeus.netregistry.net/fd_installer.cgi 
DELE fd_installer.cgi
250 DELE command successful
testing file extension cgi with Perl path /bin/perlFTP->put( fd_installer.cgi )
PORT 209,68,2,46,243,147
200 PORT command successful
STOR fd_installer.cgi
150 Opening ASCII mode data connection for fd_installer.cgi
Attempting to read response on control socket...

226 Transfer complete.
SITE chmod 755 fd_installer.cgi
200 SITE CHMOD command successful
beginning HTTP audit request to http://rere6659.staging-zeus.netregistry.net/fd_installer.cgi 
DELE fd_installer.cgi
250 DELE command successful
testing file extension cgi with Perl path /bin/perl5.005_03FTP->put( fd_installer.cgi )
PORT 209,68,2,46,238,59
200 PORT command successful
STOR fd_installer.cgi
150 Opening ASCII mode data connection for fd_installer.cgi
Attempting to read response on control socket...

226 Transfer complete.
SITE chmod 755 fd_installer.cgi
200 SITE CHMOD command successful
beginning HTTP audit request to http://rere6659.staging-zeus.netregistry.net/fd_installer.cgi 
DELE fd_installer.cgi
250 DELE command successful
Trying FTP directory '/www/cgi-bin'
CWD /www/cgi-bin
550 /www/cgi-bin: No such file or directory
Trying FTP directory '/web'
CWD /web
550 /web: No such file or directory
Trying FTP directory '/web'
CWD /web
550 /web: No such file or directory
Trying FTP directory '/~rere6659'
CWD /~rere6659
550 /~rere6659: No such file or directory
Trying FTP directory '/~rere6659/public_html'
CWD /~rere6659/public_html
550 /~rere6659/public_html: No such file or directory
Trying FTP directory '/html'
CWD /html
550 /html: No such file or directory
Trying FTP directory '/rere6659.staging-zeus.netregistry.net'
CWD /rere6659.staging-zeus.netregistry.net
550 /rere6659.staging-zeus.netregistry.net: No such file or directory
so far, foundmap is 0 - 0 - Zeus/4.3 - '0'
QUIT
221 Goodbye.

Error: when running with no_verify bit, you must explicitly provide the Perl CGI extension.
We know that the search / install directory is at /cgi-bin/search/
Is there som eway to write that in the program parameters?
It can be, but not sure how i will do that......do you have a way.....
Sorry for late reply, but i was trying everything that can be done, but it didnt worked out,
then i contacted Netregistry and i thought i will try adding there search tool which is available at;
http://www.netregistry.com.au/customer-service/support/hosting/zeus_search.php
Now its working but its loosing all the temaplate and style settings.......
You should be able to keep your templates, right?
yes....but how would i make this script to make work with my templates, right now this script is running under index file, if you go to the staging website address, you will see the search is working but the templates and styles are lost......

<form action="/search" method=POST>
<input type=hidden name=indexfile value="$$indexfile;">
<input type=hidden name=template value="$$template;">
Query: <input type=text name=expr value="">
<input type=submit value=Search>
</form>
 
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I have asked them about the templates, they said they will charge me, if i ask them for anything........
OK.
As promised on the page http://www.netregistry.com.au/customer-service/support/hosting/zeus_search.php , there is some support that they will provide as part of normal operations, and additional work that they will charge if required to do it.

What they should help you on:
- explain you how to remove the URLs I mentioned in my previous post: what should be done so that the search engine does not explore the '/compat' file tree, and so that is reports for what is 'under'  /usr/local/etc/httpd/htdocs/ but not this path.

From what I find in some of my host, I suggest you try this revised version:

<form action="/search" method=POST>
<input type=hidden name=indexfile value="$$indexfile;">
<input type=hidden name=template value="$$template;">
<input type=hidden name=basehref value="http://rere6659.staging-zeus.netregistry.net">
Query: <input type=text name=expr value="">
<input type=submit value=Search>
</form>
And tell me when done

Find where is the template used by the search engine.
Looking on my machine: this is a file in a directory called .htmltemplates.
Have you something similar within your management console?


You are right about that link, it clearly says that they will provide general help, i called them up last week and they said they cant provide much help, if i need help i can just browse through that link,
I have sended them an email, but they havent responded to my query so far,
anyways i have inserted your code, i dont think this search engine is using any template, but i have found a template which the old search engine was using, but i am not sure how can i integrate that over to this search engine.
i am going to paste the function of search.pl that the old search engine was using.

#changed 0046
	if ($::FORM{'Mode'} eq 'SearchForm') {
		print &str_search_form($::const{'search_url'});
		last Err;
		}
 
	unless ($b_is_shell_include) {
		# build and print header:
		&PrintTemplate(0, 'header.htm', $::Rules{'language'}, \%::const);
		$| = 0;
		}
 
	# build and queue footer:
 
	if (($::Rules{'allowanonadd'}) and ($::realms->realm_count('has_no_base_url')) and (not $::private{'is_freeware'})) {
		# print: Search Tips - Add New URL - Main Page
		$::private{'html_footer'} = &PrintTemplate(1, 'linkline2.txt', $::Rules{'language'}, \%::const);
		}
	else {
		# print: Search Tips - Main Page
		$::private{'html_footer'} = &PrintTemplate(1, 'linkline1.txt', $::Rules{'language'}, \%::const);
		}
 
	unless ($b_is_shell_include) {
		$::private{'html_footer'} .= &PrintTemplate(1, 'footer.htm', $::Rules{'language'}, \%::const);
		}
 
 
	if ($::FORM{'Mode'} eq 'AnonAdd') {
		$err = &anonadd_main();
		next Err if ($err);
		last Err;
		}
 
	if (not ($::FORM{'Terms'})) {
		$::const{'query_example'} = $::str[46];
		$::const{'url_query_example'} = &ue($::const{'query_example'});
		print &str_search_form($::const{'search_url'});
		&PrintTemplate(0, 'tips.htm', $::Rules{'language'}, \%::const);
		last Err;
		}

Open in new window

1 - You removed the line
<input type=hidden name=template value="$$template;">
although this has probably no impact on the current problem, I suggest you reinstall it.

2 - Looking at the code you pasted, it sems that your template is/ was defined in several files named footer.htm, linkline1.txt etc.
Can you find back these files?

3 - What is your interface with your host system? do you have some Plesk or Cpanel interface? (don't give username neither password!)
1 -  I have reinstalled the line; <input type=hidden name=template value="$$template;">
Thanks for pointing it out.
2 - There are several files associated to old search engine, i will paste all of them which are under templates folder.
3 - Its not plesk or Cpanel, i am not sure which one is it, i am going to paste a screen shot of it.

Footer File
 
</div>
			<div class="box_bottom3"></div>
		</div>
	<!-- Finish Content Area -->
		
		<div class="header_bottom"></div>
		
	<!-- Begin Footer -->
		
		<div class="language">
			<a href="#"><img src="../../images/Language/France.png" alt="French" /></a>
			<a href="#"><img src="../../images/Language/Germany.png" alt="German" /></a>
			<a href="#"><img src="../../images/Language/Spain.png" alt="Spanish" /></a>
		</div>
		<div class="footer">
			<p><a href="../../about/">About Response Systems</a> | <a href="../../privacy/">Privacy</a> | <a href="../../enquiry/">Feedback</a> | <a href="../../contact/">Contact</a><br />
			&copy; Copyright 2006 Response Systems</p>
		</div>
	</div>
</body>
</html>

Open in new window

Console.JPG
Header File:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!-- Site Copyright 2006 Response Systems -->
<head>
 <meta name="author" content="Hadley Grindrod" />
 <meta http-equiv="content-type" content="text/html;charset=iso-8859-2" />
 <link rel="stylesheet" href="../../style.css" type="text/css" />
 <title>Response Systems :: Search Results</title>
 <% if terms %><meta name="robots" content="index,nofollow" />
 <% end if %><meta http-equiv="Content-Type" content="%content_type%" />
 <!--#include file="style.inc" -->
</head>
<!-- Begin Site Body -->
<body dir="%dir%">
 <div class="content">
 
 <!-- Begin Header Section -->
 
  <div class="header_top"></div>
  <div class="header">
 
  <!-- Begin Navigation Bar -->
 
   <div class="header_right">
    <div id="nav">
        <p><a href="../../solutions/">Solutions</a> | <a href="../../support/">Support</a> | <a href="../../links/">Links</a> | <a href="../../contact/">Contact</a></p>
    </div>
    <div class="header_search">
     <form method="get" action="search.pl">
      <p><input type="text" name="Terms" class="search" /> <input name="submit" type="submit" value="Search" class="submit" /></p>
     </form>
    </div>
   </div>
   
  <!-- Begin Logo Placement -->
   
   <div class="header_left">
    <a href="../../"><img src="../../images/responselogo.jpg" alt="Response Systems" /></a>
   </div>
 
 <!-- Finish Header Section -->
   
  </div>
 
  <div class="header_bottom"></div>
 
 <!-- Begin Banner Placement -->
 
  <div class="spacer"></div>
  <div class="header_top"></div>
  <div class="column3">
   <div class="box_top3">
    <h2>Search Results</h2>
   </div>
   <div class="box3">
Line_Listing File.

<dl>
 <dt><b>%Rank%. <a href="%Redirector%%URL%">%Title%</a></b> %admin_options%</dt>
 <dd class="sr">
  %Description%<br />
  <b>URL:</b> %url% - %Size% - %Day% %Month% %Year%
  %context_line%
 </dd>
</dl>
There is a foler under templates and its name is English,
I am going to paste the files that are under this folder.
SearchForm File
<p class="centre">Please enter a search term</p>
Admin_Personal File
<p><b>Email Settings</b> (<a href="%help_file%1084.html" target="_blank">Help</a>)</p>
<blockquote>
 <p>Provide the information below so that this script can contact you. Currently the script can be configured to send you mail when somebody adds a new URL (see Filter Rules).</p>
 <p>After setting email info, <a href="%admin_url%&amp;Action=PS&amp;subaction=TestMail">send a test message</a> to confirm the settings.</p>
 <p>Use this <a href="http://www.xav.com/mx_lookup.pl" target="_blank">SMTP server lookup tool</a> if you need help determining your mail server.</p>
 <table border="1" cellpadding="4" cellspacing="1">
 <tr>
  <th>Name</th>
  <th>Value</th>
 </tr>
 <tr valign="top" class="fdtan">
  <td align="right"><b>Email Address:</b></td>
  <td>
   <input name="admin notify: email address" /><br />
   <font size="-2">ex: admin@mysite.tld</font>
  </td>
 </tr>
 <tr valign="top" class="fdtan">
  <td align="right"><b>SMTP Server:</b></td>
  <td>
   <input name="admin notify: smtp server" /> optional<br />
   <font size="-2">ex: mail.mysite.tld</font>
  </td>
 </tr>
 <tr valign="top" class="fdtan">
  <td align="right"><b>Sendmail Program:</b></td>
  <td>
   <select name="admin notify: sendmail program">%sendmail_options%</select> optional<br />
   <font size="-2">ex: /usr/sbin/sendmail -t</font>
  </td>
 </tr>
 </table>
 <p>To send mail, this script needs either an SMTP server or a sendmail program. If both are defined, the sendmail program will be used.</p>
 <p><input type="submit" class="submit" value="Save Data" /></p>
</blockquote>
<p><br /></p>
<p><b>Security Settings</b></p>
<blockquote>
 <table border="1" cellpadding="4" cellspacing="1">
 <tr>
  <th>Name</th>
  <th>Value</th>
 </tr>
 <tr class="fdtan">
  <td align="right"><b>Session Timeout:</b></td>
  <td><input name="security: session timeout" /></td>
 </tr>
 </table>
 <p>The session timeout is the number of minutes of inactivity before the script will prompt for a password again.</p>
 <table border="1" cellpadding="4" cellspacing="1">
 <tr>
  <th colspan="2">Reset Password</th>
 </tr>
 <tr class="fdtan">
  <td align="right"><b>Old Password:</b></td>
  <td><input name="op" type="password" /></td>
 </tr>
 <tr class="fdtan">
  <td align="right"><b>New Password:</b></td>
  <td><input name="np" type="password" /></td>
 </tr>
 <tr class="fdtan">
  <td align="right"><b>Confirm New:</b></td>
  <td><input name="cp" type="password" /></td>
 </tr>
 </table>
 <p><input type="submit" class="submit" value="Save Data" /></p>
</blockquote>
<p><br /></p>
 
There are other files as well which are admin_ads, admin_fr, admin_pass1, link1,link2, and strings, let me know if you need to see the code of any of these files.
Avatar of Adam314
Adam314

I just came to this message.  It looks like there was a lot of work already done by fibo.  If fibo answered your original question, but you now have a new question, you should accept an answer, and ask a new question.

If that isn't appropriate: What is the question/problem now?
Thanks for your reply, me and fibo have been working on this issue for quite long, he has been quite helpful, but my problem is still there, we were trying that the search engine will work as it was working before with the same scripts (i.e. PERL) as we were using on the old website (i.e. www.response-systems.com), but it didnt work out then we tried to use the search engine script that the new host provider suggested, i.e, http://www.netregistry.com.au/customer-service/support/hosting/zeus_search.php ; but that didnt work out properly either, the search was working on this script but it lost all the templates, so i switched back to old PERL script, and the question is the same i am having difficulty in making the search engine work, i have installed cgi, Guardian error handling and fluid dynamics search engine from here-->http://install.xav.com/?p_ip=undefined&p_timeout=0&p_up=1&action=SelectProduct&set_vendor=fdsc&set_product=
because this was used on the old website (i.e. www.response-systems.com) , and i am trying to transfer the seach engine script on to the staging website (i.e.http://rere6659.staging-zeus.netregistry.net) which will go live after search engine starts working.
The security on the folders are fine. Right now if i search anything it gives me this error;
 
 
Error: 500 Internal Server Error
Address: http://rere6659.staging-zeus.netregistry.net/cgi-bin/search/search.pl 
hi,
It seems that your search takes forever. Presumably your serach engine needs some kind of initial indexing. Did you do that?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Sorry for late reply, i added the code what adam314 suggested at the top of search.pl, but didnt knew where to look for error logs.
The whole site has been indexed, it was done by the netregistry people.
http://www.netregistry.com.au/customer-service/support/hosting/zeus_search.php
 
The search engine from Netregistry is not being used now, because as i said previously that their search engine was working fine, but it lost all the templates and styles, so i have to switch it back the Perl script.
Zeus-Indexing.JPG
UsmanSultan,
<< Presumably your serach engine needs some kind of initial indexing. Did you do that?>>
Initial indexing done by netrigistry is probably not the one youy need, since you are using another solution.

Which inital indexing have you done?
I did it through Perl script search engine.I am pasting the pictures, i have a doubt that website is indexed because on the second picture (i.e. Indexing1) it shows that there is an error, but on the last picture it shows that the indexing has been successful.
Indexing.JPG
Indexing1.JPG
Indexing3.JPG
Looking in the error log will be really helpful.  Contact your service provider and ask them now you can see the error log.
I have managed to make the netregistry search engine working, by integrating CSS to the search Template, but i am stuck at knowledgebase link, can you please have a look at this question,
https://www.experts-exchange.com/questions/23770261/Search-Engine-to-Search-within-Articles-Within-Folder.html 
Thanks.