#!/usr/bin/perl use CGI::Carp; use CGI::Carp qw(fatalsToBrowser); print "Content-type:text/html\n\n"; if ($ENV{'REQUEST_METHOD'} eq 'GET') { @pairs = split(/&/, $ENV{'QUERY_STRING'}); } elsif ($ENV{'REQUEST_METHOD'} eq 'POST') { read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $buffer); } else { print "This script must be called from the Web\nusing either GET or POST requests\n\n"; } foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $INPUT{$name} = $value; } $INPUT{'a'} = "" if ($INPUT{'a'} eq "-1"); # ME/WASH RECENT HEADLINES produces a -1 for this month if ($INPUT{'function'} eq "right") { $target = "target=_top"; &right; } if ($INPUT{'function'} eq "left") { $target = "target=_top"; &left; } if ($INPUT{'function'} eq "middle") { $target = "target=_top"; &middle; } if ($INPUT{'function'} eq "mer") { $target = "target=_top"; &mer; } &normal if ($INPUT{'function'} eq ""); &plugin if ($INPUT{'function'} eq "plugin"); &popup if ($INPUT{'function'} eq "popup"); if ($INPUT{'function'} eq "cache") { if (-e "redirect/" . $INPUT{'num'} . ".txt") { &cache; } } sub popup { $target = "target=main"; #print "
"; #&right; #print ""; #&left; #print "
"; $notpop = 1; &middle; } sub cache { open(IN, "redirect/" . $INPUT{'num'} . ".txt"); @indata = ; close(IN); print "MEReport $INPUT{'num'}"; if ($indata[0] =~ /base href=/) { foreach $line (@indata) { print $line; } } else { print "\n\n"; $total = ""; $good = 0; foreach $line (@indata) { $line =~ s/
/\r/g; $line =~ s/\r/
/g; $line =~ s/

/
/g; $total = $total . $line; } if ($good == 0) { print "
$total
"; } else { $cnt=0; $counter=0; $mul = 70; $from = $counter * $mul; $to = ($counter+1) * $mul; while (substr($total, $from, $to) ne "") { $extract[$counter] = substr($total, $from, $mul); $counter++; $from = $counter * $mul; $to = ($counter+1) * $mul; } for ($x=0; $x < $counter; $x++) { $entry = $extract[$x]; if ($entry ne "") { print $entry . "
\n"; } } } print ""; } } sub left { &archived; print "MEReport
"; $url = "redirect.cgi?archive=$INPUT{'archive'}&function=top&num=$INPUT{'num'}&background=white&empty=no" if ($INPUT{'empty'} eq "yes"); $white = "white"; print ""; print "" if ($INPUT{'c'} eq ""); print "
Back to MER World
" if ($INPUT{'c'} eq "2"); print "
Back to ME Report
" if ($INPUT{'c'} eq "3"); ($junk, $keep) = split(//, $keep); $filename = "redirect/" . $keep . ".txt"; if (-e $filename) { print ""; } print "
Back to WASH ReportRead Archived Version
"; if ($INPUT{'c'} ne "3") { print "
  • MER Homepage"; print "
  • MERTV"; print "

    "; } if ($INPUT{'window'} eq "1") { $target ="newBrowserWindow"; $url ="javascript:window.close()"; print "
  • Close this frame"; } print ""; } sub mer { print <
    You are viewing a selection from MiddleEast.org
    endofhtml ; print "\n"; } sub archived { open(IN, "archives/counter.txt"); @indata=; close(IN); if (($INPUT{'archive'} eq $indata[0]) || ($INPUT{'archive'} eq "")) { open(IN, "news.txt"); @indata=; close(IN); } else { $filename = "archives/" . $INPUT{'archive'} . ".txt"; open(IN, "$filename"); @indata=; close(IN); } $record = @indata-$INPUT{'num'}; ($title, $url, $desc, $head) = split(/\|/, $indata[$record]); } sub middle { &archived; $bgcolor = "#42527B"; $bgcolor = "white" if ($INPUT{'background'} eq "white"); print "MER"; $bg = "#42527B" if ($INPUT{'background'} ne "white"); $bg = "#FFFFFF" if ($INPUT{'background'} eq "white"); $white = "white" if ($INPUT{'background'} ne "white"); $white = "black" if ($INPUT{'background'} eq "white"); print "
    "; $bgcolor = "white"; $bgcolor = "black" if ($INPUT{'background'} eq "white"); print ""; if ($notpop == 1) { print "" if ($INPUT{'c'} eq "2"); print "
    Back to MiddleEast.org
    " if ($INPUT{'c'} eq "3"); ($junk, $keep) = split(//, $keep); $filename = "redirect/" . $keep . ".txt"; if (-e $filename) { print ""; } print "
    Back to WASH REPORTRead Archived Version
    "; } if (!($desc =~ /<\/b>/)) { if (($INPUT{'c'} eq "2") || ($INPUT{'c'} eq "3")) { print "Comment
    "; } else { print "MER Comment
    "; } print "$desc

    "; } print "


    "; } sub right { print ""; print ""; open(IN, "news.txt"); @indata=; close(IN); print <
    Down Up Stop Top
    endofhtml ; $total=@indata; $stop = $total-20; $cnt2=0; foreach $line (@indata) { if ($line ne "") { ($title, $url, $desc, $head, $preview, $date) = split(/\|/, $line); if (($head ne "off") && ($head ne "hidden")) { $url =~ s/\?/QUESTIONMARK/g; $url =~ s/\&/AND/g; $url =~ s/\=/EQUAL/g; if ($INPUT{'c'} eq "3") { if (!($preview =~ /wash/)) { print "$title

    \n"; } } elsif ($INPUT{'c'} eq "2") { if (!($preview =~ /me/)) { print "$title

    \n"; } } else { print "$title

    \n"; } last if ($cnt2 == 40); $cnt2++; } $total--; } } print <
    endofhtml ; } sub normal { $arcnum = $INPUT{'a'} if ($INPUT{'a'} ne ""); $arcnum = $INPUT{'archive'} if ($INPUT{'archive'} ne ""); $theminute = (localtime(time()))[1]; $thehour = (localtime(time()))[2]; $theday = (localtime(time()))[3]; $thedayyear = (localtime(time()))[7]; $themonth = (localtime(time()))[4]; $themonth++; $theyear = (localtime(time()))[5]; $theyear = $theyear + 1900; if ($INPUT{'t'} eq "p") { open(OUT, ">>../promote/h_logs.txt"); print OUT "$ENV{'HTTP_REFERER'}|$themonth $theday $theyear|$INPUT{'archive'}|$INPUT{'num'}\n"; close(OUT); } if ($INPUT{'t'} eq "f") { open(OUT, ">>../promote/f_logs.txt"); print OUT "$ENV{'HTTP_REFERER'}|$themonth $theday $theyear|$INPUT{'archive'}|$INPUT{'num'}\n"; close(OUT); } open(IN, "archives/counter.txt"); @indata=; close(IN); if (($arcnum eq $indata[0]) || ($arcnum eq "")) { open(IN, "news.txt"); @indata=; close(IN); } else { $filename = "archives/" . $arcnum . ".txt"; open(IN, "$filename"); @indata=; close(IN); } $record = @indata-$INPUT{'num'}; ($title, $url, $desc, $head) = split(/\|/, $indata[$record]); ($junk, $showtitle) = split(/-->/, $title); $showtitle = $title if ($showtitle eq ""); $url =~ s/QUESTIONMARK/\?/g; $url =~ s/AND/\&/g; $url =~ s/EQUAL/=/g; $INPUT{'location'} =~ s/QUESTIONMARK/\?/g; $INPUT{'location'} =~ s/AND/\&/g; $INPUT{'location'} =~ s/EQUAL/=/g; open(IN, "framebusters.txt"); @in = ; close(IN); $framebuster=0; foreach $line (@in) { chop $line; if ($url =~ /$line/) { $framebuster=1; } } if ($framebuster == 0) { if ($url eq "") { print "MER - $showtitle"; print ""; print "\n"; #print ""; print ""; print "\n"; print "\n"; #print "\n"; print ""; print ""; print ""; } else { print "MER - $showtitle"; print ""; print "\n"; print "\n"; print ""; print ""; } } else { print "Redirect\n"; print "\n\n"; $test = $desc; $test =~ s/<(?:[^>'"]*|(['"]).*?\1)*>//gs; if (length($test) > 5) { print "\n"; } print ""; } print < $desc endofhtml ; }