#! /usr/local/bin/perl # 2ascii -- Version 1.00b 98.01.02 12:16 # (c) 1997, 1998 Hellenic Resources Institute, Inc. # # This script converts URL's from Elot928 Greek to ASCII Greek. # Usage: GET 2ascii?URL $Banner = "/iis/www/htdocs/includes/banner.inc"; $Footer = "/iis/www/htdocs/includes/map.inc"; $webcopy = "/usr/local/bin/webcopy"; $opendouble = "\140\140"; $closedouble = "\047\047"; $copyright = "(c)"; $registered = "(R)"; $trademark = "(TM)"; $banner = `cat /hrnet/iis/www/htdocs/includes/banner.inc`; $footer = `cat /hrnet/iis/www/htdocs/includes/map.inc`; $myname = $ENV{SCRIPT_NAME}; $myname = "http://www.hri.org" . $myname; if ($ENV{'REQUEST_METHOD'} eq 'GET') { $url = $ENV{'QUERY_STRING'}; if($url =~ /\w/) { $url =~ tr/+/ /; $url =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $url =~ s/^q=//; } else { &return_form("Elot928 to ASCII Greek Converter"); exit; } } else { &return_form("Elot928 to ASCII Greek Converter"); exit; } print "Content-type: text/html\n\n"; chdir("/tmp"); AGAIN: @message = `$webcopy -apfoc -b2ascii$$ -t0 "$url"`; if(open(LOG, "2ascii$$.log")){ @log = ; close(LOG); unlink("2ascii$$.log"); @temp = grep(/(reject\-remote|301 Moved Permanently)/i, @log); if(@temp) { $temp[0] =~ s/^getting\s*//gi; $temp[0] =~ s/^reference\s*//gi; $temp[0] =~ s/\s*reject\-remote\n$//gi; $temp[0] =~ s/\s*301\s*moved\s*permanently\n$/\//gi; $temp[0] =~ s/\:80\//\//gi; $url = $temp[0]; goto AGAIN; } @temp = grep(/(reference null reject-invalid)/i, @log); if(@temp) { $url .= "/"; goto AGAIN; } @temp = grep(/(404)/i, @log); if(@temp) { $notfound = 1; goto OUT; } @temp = grep(/^getting/, @log); $base = $temp[$#temp]; $base =~ s/^getting\s*//gi; $base =~ s/\s*\n$//gi; $base =~ s/\s.*$//gi; $base =~ s/\:80\//\//gi; $base =~ s/$myname\?//; $base =~ s/\/[^\/]*$/\//; } else { $base = $url; $base =~ s/$myname\?//; $base =~ s/\/[^\/]*$/\//; } $system = $base; $system =~ s/^(http\:\/\/[^\/]*).*$/$1\//gi; print "\n"; # print "\[Returned: $base\]\n"; if(@message) { $i = 0; while($i <= $#message) { $_ = @message[$i]; tr [\213\221\222\233\242\264\266-\376] [\`\`\'\'A\'A\267EHI\273O\275YWiABGDEZHQIKLMNJOPR\322STYFXCWIYaehiyabgdezhqiklmnjoprsstyfxcwiyoyw] ; s/\253/$opendouble/ge; s/\273/$closedouble/ge; s/\251/$copyright/ge; s/\256/$registered/ge; s/\231/$trademark/ge; s/(href\s*=\s*\")([^\#\/ ])/$1$myname?$base\/$2/gi; s/(href\s*=\s*\"\s*\+\s*\"\\\"\"\s*\+\s*\")([^\#\/ ])/$1$myname?$base\/$2/gi; s/href\s*=\s*\"#/href=\"$myname\?$url\#/gi; s/href\s*=\s*\"\//href=\"$myname\?$system\//gi; s/(frame.*src\s*=\s*\")([^\#\/])/$1$myname?$base\/$2/gi; s/frame.*src\s*=\s*\"#/frame src=\"$myname\?$url\#/gi; s/frame.*src\s*=\s*\"\//frame src=\"$myname\?$system\//gi; s/($myname\?)($base\/)(http\:\/\/)/$1$3/gi; s/([^:])\/{2,}/$1\//gi; s/\/\w*\/\.\.//gi; s/\/\w*\/\.\.//gi; s/\/\.\//\//gi; s/($myname\?)($base\/*)(mailto\:)/$3/gi; s/($myname\?)($base\/*)(ftp\:)/$3/gi; s/($myname\?)($base\/*)(telnet\:)/$3/gi; s/($myname\?){2,}/$myname\?/gi; print; $i++; } print "
\n";
  print "\[Converted from: $url by $myname\]\n";
  print "
\n"; } else { OUT: print < URL Unobtainable $banner

URL Unobtainable

EOT if($notfound == 1) { print "The specified URL $url does not exist (code 404 returned)."; } else { print "The specified URL $url seems to be unobtainable."; print "Please check your reference, or retry later."; } print < EOT2 } exit; sub return_form { $document_title = $_[0]; print "Content-type: text/html\n\n"; print "\n"; print "\n"; print "$document_title\n"; print "\n"; print "\n"; if(open(BANNER, $Banner)){ while() { print $_; } close(BANNER); } print "

$document_title

\n"; print "

This page allows you to enter a URL which is in Elot928 Greek and to\n"; print "view it using ASCII Greek. The conversion is done automatically on HR-Net.\n"; print "

Enter the URL you wish to view in ASCII Greek, and click the \"Convert\" button:\n"; print "

\n"; print "URL:\n"; print "\n"; print "\n"; print "

Tip:\n"; print "Please remember that installing Greek with your WWW\n"; print "browser has never been easier. Full instructions are available at http://www.hri.org/fonts. If you have\n"; print "been unsuccessful with a prior installation, or run into trouble with our\n"; print "instructions, you can always write to fonts\@hri.org for assistance.\n"; if(open(FOOTER, $Footer)){ while(