#!/usr/bin/perl use DBI; require "config.pl"; &read_data; $INPUT{REQ} = "$pieces/".lc$INPUT{REQ}.".pl"; if (-e $INPUT{REQ}) { $script = "$script_folder/serve.cgi"; unless ($INPUT{REQ} =~ /am_/i) { require "$pieces/common_mod.pl"; require "$screen/commonhf.pl"; print "Content-Type: text/html\n\n"; } else { require "$pieces/am_mod.pl"; } require "$INPUT{REQ}"; } else { print "Content-Type: text/html\n\n"; print "Invalid module!"; } exit; sub read_data { my(@dts,$bf,$p); if ($ENV{REQUEST_METHOD} eq 'POST') { read(STDIN, $bf, $ENV{CONTENT_LENGTH}); @dts = split(/&/, $bf); } elsif ($ENV{REQUEST_METHOD} eq 'GET') { if ($ENV{QUERY_STRING}) { @dts = split(/&/, $ENV{QUERY_STRING}); } else { @dts = split(/&/, $ENV{PATH_INFO}); $dts[0] = substr($dts[0],1); } } else { print "Content-Type: text/html\n\n"; &common_header(0,'Fetching error'); &server_error; } foreach $p (@dts) { my ($n,$v) = split(/=/, $p); $n = uc$n; $n =~ tr/+/ /; $n =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $v =~ tr/+/ /; $v =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $n =~ s/~!/ ~!/g; $n =~ s///g; $v =~ s/~!/ ~!/g; $v =~ s///g unless $n eq 'BRMED'; $n =~ s/[\"\'\>\<\*\;]//g; $v =~ s/[\"\'\>\<\*\;]//g unless $n eq 'BRMED'; $v =~ s/\'/\\'/g if $n eq 'BRMED'; $INPUT{$n} = $v; } }