home *** CD-ROM | disk | FTP | other *** search
- # Get the input
- read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
-
- # Split the name-value pairs
- @pairs = split(/&/, $buffer);
-
- foreach $pair (@pairs){
- ($name, $value) = split(/=/, $pair);
-
- $value =~ tr/+/ /;
- $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
- $name =~ tr/+/ /;
- $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
-
- $FORM{$name} = $value;
- }
-
- if ($FORM{'deflimit'}) {
- $deflimit_str = '$DEF_lim = ' . $FORM{'deflimit'} . ';';
- }
- else {
- $deflimit_str = '#$DEF_lim = 500';
- }
-
- if ($FORM{'mostip'}) {
- $mostip_str = '$most_ip = "' . $FORM{'mostip'} . '";';
- }
- else {
- $mostip_str = '#most_ip = "off";';
- }
-
- if ($FORM{'mostreq'}) {
- $mostreq_str = '$most_req = "' . $FORM{'mostreq'} . '";';
- }
- else {
- $mostreq_str = '#$most_req = "off";';
- }
-
- if ($FORM{'mostbrowsers'}) {
- $mostbrowsers_str = '$most_browsers = "' . $FORM{'mostbrowsers'} . '";';
- }
- else {
- $mostbrowsers_str = '#$most_browsers = "off";';
- }
-
- if ($FORM{'timelog'}) {
- $timelog_str = '$timelogging = "' . $FORM{'timelog'} . '";';
- }
- else {
- $timelog_str = '#timelogging = "off";';
- }
-
- if ($FORM{'mostipnum'}) {
- $mostipnum_str = '$most_ip_num = ' . $FORM{'mostipnum'} . ';';
- }
- elsif ($FORM{'mostip'}) {
- $error .= "<LI>Number of top IP's needs to be positive. If you want it disabled unckeck the apropriate box.";
- }
- else {
- $mostipnum_str = '$most_ip_num = 0;';
- }
-
- if ($FORM{'mostbrowsernum'}) {
- $mostbrowsernum_str = '$most_browser_num = ' . $FORM{'mostbrowsernum'} . ';';
- }
- elsif ($FORM{'mostbrowsers'}) {
- $error .= "<LI>Number of top browsers needs to be positive. If you want it disabled unckeck the apropriate box.";
- }
- else {
- $mostbrowsernum_str = '$most_browser_num = 0;';
- }
-
- if ($FORM{'mostreqf'}) {
- $mostreqf_str = '$most_req_f = ' . $FORM{'mostreqf'} . ';';
- }
- elsif ($FORM{'mostreq'}) {
- $error .= "<LI>Number of top files needs to be positive. If you want it disabled unckeck the apropriate box.";
- }
- else {
- $mostreqf_str = '$most_req_f = 0;';
- }
-
-
- if ($FORM{'logloc'}) {
- $logloc_str = '$accesslog = "' . $FORM{'logloc'} . '";';
- }
- else {
- $error .= "<LI>No access log location specifed.";
- }
-
- if ($FORM{'imagebar'}) {
- $imagebar_str = '$imagebar = "' . $FORM{'imagebar'} . '";';
- }
- else {
- $error .= "<LI>No bar image specified.";
- }
-
- if ($FORM{'serveradd'}) {
- $serveradd_str = '$serveradd = "' . $FORM{'serveradd'} . '";';
- }
- else {
- $serveradd_str = '$serveradd = "this server";';
- }
-
- if ($FORM{'barwidth'}) {
- if ($FORM{'barwidth'} > 0) {
- $barwidth_str = '$barwidth = ' . $FORM{'barwidth'} . ';';
- }
- else {
- $error .= "<LI>Bar width needs to be a positive number.";
- }
- }
- else {
- $error .= "<LI>The bar width needs to be entered.";
- }
-
- if ($FORM{'barheight'}) {
- if ($FORM{'barheight'} > 0) {
- $barheight_str = '$barheight = ' . $FORM{'barheight'} . ';';
- }
- else {
- $error .= "<LI>Bar height needs to be a positive number.";
- }
- }
- else {
- $error .= "<LI>The bar height needs to be entered.";
- }
-
- if ($FORM{'listpass'}) {
- $listpass_str = '$listpass = "' . $FORM{'listpass'} . '";';
- }
- else {
- $listpass_str = '#listpass = "";';
- }
-
- if ($FORM{'bgcolor'}) {
- $bgcolor_str = '$bgcolor = "' . $FORM{'bgcolor'} . '";';
- }
- else {
- $bgcolor_str = '$bgcolor = "#FFFFFF";';
- }
-
- if ($FORM{'bgimage'}) {
- $bgimage_str = '$bgimage = "' . $FORM{'bgimage'} . '";';
- }
- else {
- $bgimage_str = '$bgimage = "";';
- }
-
- if ($FORM{'ttBGcolor'}) {
- $ttBGcolor_str = '$tableTopBGColor = "' . $FORM{'ttBGcolor'} . '";';
- }
- else {
- $ttBGcolor_str = '$tableTopBGColor = "#ffffdd";';
- }
-
- if ($FORM{'perllib'}) {
- $perllib_str = 'push(@INC,"'. $FORM{'perllib'} . '");';
- }
- else {
- $error .= "<LI>You didn't report the location of your perl lib directory.";
- }
-
- unless ($FORM{'cgidir'}) {
- $error .= "<LI>You didn't report the location of your cgi-bin directory.";
- }
-
- unless (-f "$FORM{'cgidir'}/stats.prg") {
- $error .= "<LI>Config couldn't find the file stats.prg in your cgi-bin directory.";
- }
-
- unless (-f "$FORM{'perllib'}/ctime.pl") {
- $error .= "<LI>Config couldn't find ctime.pl in your specifed perl lib directory of $FORM{'perllib'}.";
- }
-
- print "Content-type: text/html\n\n";
-
- if ($error) {
- print "<HTML><H3>Errors: <UL>\n$error</UL><P>Please go back and retry.</H3></HTML>";
- exit();
- }
-
- $cgifile = "$FORM{'cgidir'}/stats.pl";
- $progfile = "$FORM{'cgidir'}/stats.prg";
-
- open(CGI, "> $cgifile");
- open(PROG, "$progfile");
-
- print CGI "#!/usr/local/bin/perl5\n";
- print CGI "#AutoConfiged by Statsconfig.pl\n\n";
- print CGI "$deflimit_str\n$mostip_str\n$mostreq_str\n$mostbrowsers_str\n$timelog_str\n$mostipnum_str\n$mostreqf_str\n$mostbrowsernum_str\n$logloc_str\n$imagebar_str\n$serveradd_str\n$barwidth_str\n$barheight_str\n$listpass_str\n$bgcolor_str\n$bgimage_str\n$ttBGcolor_str\n\n$perllib_str\n";
-
- if ($FORM{'debugon'}) {
- print CGI '$debug = 1;' . "\n";
- }
-
- print GCI "\n";
-
- while (<PROG>) {
- print CGI $_;
- }
-
- print "<HTML>\n<BODY BGCOLOR=#FFFFFF>\n<center>\n<h2>Stats successfuly configured.</h2>\n",
- "<FORM ACTION=\"/cgi-bin/stats.pl\" METHOD=POST>\n",
- "<INPUT TYPE=\"submit\" VALUE=\"Click here to try it out\">\n",
- "</FORM>\n</center>\n</BODY>\n</HTML>";