#!/usr/bin/perl # Roche Links / Contacts Database # v1.00 # # Written by Alex Jeffreys for Hill & Knowlton NetCommunications # 22th August, 1997. # # Notes: $OS_type="linux"; $version="1.00"; $title="Roche Links / Contacts Database"; $webmaster="alex\@2b.com"; $CGINAME="links.pl"; $default_language="en"; $form_name="orgform_"; $result_name="orgresult_"; $pathname="templates"; $db_name="linksdb.txt"; $bgcolor="FFFFFF"; $HTMLHEAD="$title

Casinos Not On GamstopNon Gamstop CasinosCasinos Not On GamstopNon Gamstop Casinos UKNon Gamstop Casinos
\n"; $HTMLFOOT="\n"; $FONT=""; $FONTEND=""; $cr="
\n"; &ReadParse(*input); $language=$input{"language"}; $language="en" if (!$language); $search_category=$input{"category"}; #$search_category="*" if (!$category); $search_country=$input{"country"}; $search_organisation=lc($input{"organisation"}); if (($search_category eq "")||($search_country eq "")) { &Search_Page; } else { &Results_Page; } &Print_Header("html"); print $HTMLHEAD; print "language=$language$cr"; print "Search Category=\"$search_category\"$cr"; # foreach $test (split(/\0/,$search_category)) { # print "--$test"; # } print "Search Country=\"$search_country\""; print $HTMLFOOT; sub Search_Page { &Read_DB; $filename="$pathname/$form_name$language.htm"; $result=&Read_File($filename, *form); if ($result==-1) { &ERROR("$filename not found! Please report to Webmaster."); } $form=@form; for ($count=0; $count/$countrylist_html/g; $form[$count]=~s//$categorylist_html/g; $form[$count]=~s/%%%cginame%%%|%25%25%25cginame%25%25%25/$CGINAME/g; } print @form; exit; # print $HTMLHEAD."Search Page$cr"; # print "Countries: "; # print $countrylist_html; # print $categorylist_html; # print $HTMLFOOT; exit; $search=@search; for ($count=0; $count$url$cr" } #else { $results.="No Link"; } $each.="$cr\n"; $result.=$each; $list{$organisation}=$each; } } } } $result=""; foreach $link (sort keys (%list)) { $result.=$list{$link}; } $catresult.="$search_category
$result
" if ($result); } if ($catresult) { $results.="
$search_country
$catresult
"; } } if (!$results) { $results="$results"; $results="No records matched with your selected criteria.\n"; } $results="$results
Click to search again.$cr"; $form=@form; for ($count=0; $count/$results/g; $form[$count]=~s/%%%cginame%%%/$CGINAME/g; } print @form; exit; } sub Read_DB { $result=&Read_File($db_name, *db); if ($result==-1) { &ERROR("$db_name not found! Please report to Webmaster."); } #Build Country & Category list foreach $line (@db) { ($id, $country_field, $category_field, $organisation, $url)=split(/\|/,$line); foreach $country (split(/,/,$country_field)) { $temp_country{$country}=1; } foreach $category (split(/,/,$category_field)) { $temp_category{$category}=1; } } $countrylist_html=""; $categorylist_html=""; @countrylist=(sort keys (%temp_country)); @categorylist=(sort keys (%temp_category)); foreach $country (@countrylist) { $countrylist_html.="\n"; } foreach $category (@categorylist) { $categorylist_html.="\n"; } } sub ERROR { local ($error=@_[0]); &Print_Header("html"); print $HTMLHEAD; print "$error\n"; print $HTMLFOOT; exit; } sub Table { local (@html=@_, $width, $formname, $method, $action, $count, $startpoint, $result); local ($type, $value, $align); $width=$html[4]; $formname=$html[1]; $method=$html[3]; $action=$html[2]; $num=$html[0]; $startpoint=5; $result=""; $result.=""; for ($count=1; $count"; $value=$html[$startpoint++]; ($type,$value,$align)=split(/=/,$value); #DEBUG print "type=$type, value=$value$cr"; if ($type eq "text") { $result.=""; $result.=""; } elsif ($type eq "submit") { $result.=""; $result.=""; } elsif ($type eq "hidden") { $result.=""; } $startpoint+=3; if ($type ne "hidden") { $result.=""; } } $result.="
$FONT$html[$startpoint]$FONTEND
"; return ($result); } #Common Perl routines # All routines should be able to cater for OS_Type="linux|dos" # Written by Alex Jeffreys # Started 08/08/1997. # V1.00 # #Start of common routines #----------------------- #----------------------- # Print_Header # # if parameter then check for type of: # txt - plain text #----------------------- sub Print_Header { local ($value=@_[0], $content); if ($print_header_done==1) { return; } if (($OS_type eq "linux")||($OS_type eq "dos")) { $content="text/html"; if ($value eq "txt") { $content="plain-text"; } print "Content-type: $content\n"; } print "\n"; $print_header_done=1; } #----------------------- # Read_File # # parameter 1 is filename to read - if not set or file not found then error = -1 # parameter 2 is variable to read the file to (set with *variablename) # when sucessful, the return value is the # of textlines in the file. #----------------------- sub Read_File { local ($filename); $filename=@_[0]; *array=@_[1]; if ($filename eq "") { return (-1); } if (! -e $filename) { return (-1); } open (filehandle, $filename); @array=; close (filehandle); $filename=@array; return ($filename); } #----------------------- # View_Form # #parameter 1 - title of form #parameter 2 - HTML contents for form #----------------------- sub View_Form { local ($title=@_[0], $html=@_[1], $width=@_[2]); if ($width eq "") { $width=400; } print "
"; print ""; print ""; print ""; print "
"; print "$title
$html
"; print "
"; } # alexcgi.pl included below: # MethGet # Return true if this cgi call was using the GET request, false otherwise sub MethGet { return ($ENV{'REQUEST_METHOD'} eq "GET"); } # MethPost # Return true if this cgi call was using the POST request, false otherwise # Alex Jeffreys 03/12/96 sub MethPost { return ($ENV{'REQUEST_METHOD'} eq "POST"); } # ReadParse # Reads in GET or POST data, converts it to unescaped text, and puts # one key=value in each member of the list "@in" # Also creates key/value pairs in %in, using '\0' to separate multiple # selections # Returns TRUE if there was input, FALSE if there was no input # UNDEF may be used in the future to indicate some failure. # Now that cgi scripts can be put in the normal file space, it is useful # to combine both the form and the script in one place. If no parameters # are given (i.e., ReadParse returns FALSE), then a form could be output. # If a variable-glob parameter (e.g., *cgi_input) is passed to ReadParse, # information is stored there, rather than in $in, @in, and %in. sub ParseBack { local ($pass=@_[0]); $pass=~s/ /\+/g; return ($pass); } sub ReadParse { local (*in) = @_ if @_; local ($i, $key, $val); # Read in text if (&MethGet) { $in = $ENV{'QUERY_STRING'}; } elsif ($ENV{'REQUEST_METHOD'} eq "POST") { read(STDIN,$in,$ENV{'CONTENT_LENGTH'}); } @in = split(/&/,$in); foreach $i (0 .. $#in) { # Convert plus's to spaces $in[$i] =~ s/\+/ /g; # Split into key and value. ($key, $val) = split(/=/,$in[$i],2); # splits on the first =. # Convert %XX from hex numbers to alphanumeric $key =~ s/%(..)/pack("c",hex($1))/ge; $val =~ s/%(..)/pack("c",hex($1))/ge; # Associate key and value $in{$key} .= "\0" if (defined($in{$key})); # \0 is the multiple separator $in{$key} .= $val; } return length($in); } # PrintVariables # Nicely formats variables in an associative array passed as a parameter # And returns the HTML string. sub PrintVariables { local (%in) = @_; local ($old, $out, $output); $old = $*; $* =1; $output .= "
"; foreach $key (sort keys(%in)) { foreach (split("\0", $in{$key})) { ($out = $_) =~ s/\n/
/g; $output .= "
$key
$out
"; } } $output .= "
"; $* = $old; return $output; } # PrintVariablesShort # Nicely formats variables in an associative array passed as a parameter # Using one line per pair (unless value is multiline) # And returns the HTML string. sub PrintVariablesShort { local (%in) = @_; local ($old, $out, $output); $old = $*; $* =1; foreach $key (sort keys(%in)) { foreach (split("\0", $in{$key})) { ($out = $_) =~ s/\n/
/g; $output .= "$key is $out
"; } } $* = $old; return $output; } #----------------------- # End # DO NOT REMOVE THE LINE BELOW!!! NEEDED FOR A REQUIRED FILE.... ##return true;

Worth checking out