#!/usr/bin/perl # # Author: Trever Furnish, trever AT wondious D0T com, 2002-03-29. # Released as public domain code with absolutely no warranty for any purpose. # # This script is meant to be called from a web browser and executed on # a web server. It provides a form for entering a bandwidth measurement and # a set of units to convert to. Required Perl, probably 5.6 or later. # This kind of thing really should just be pure javascript, but I don't know # javascript very well, so... :-) It also works best if you link it using # javascript to have it open in its own little window, like so: #bandwidth converter # $error_contact="t\@wondious.com"; $my_url="/bwconvert/index.cgi"; $workdir="/var/www/html/bwconvert"; use HTML::Entities; # for encode/decode_entities() use CGI; # CGI::Carp for making our errors more useful. # fatalsToBrowser: fatal errors go to the browser. # set_message: Define the message to send to the browser for errors. # warningsToBrowser: warnings go to browser as comments. # warningsToBrowser(0) to disable temporarily # warningsToBrowser(1) to enable again. use CGI::Carp qw(fatalsToBrowser warningsToBrowser set_message); # Limit the max post data we'll accept at once for security. $CGI::POST_MAX=1024*1024*1024; # 1 megabyte # Disable CGI upload acceptance for security. $CGI::DISABLE_UPLOADS=1; # Disable uploads. BEGIN { sub handle_errors { my $msg = shift; print "
"; print "Got an error message:\n
",
encode_entities("$msg"), "\n";
}
set_message(\&handle_errors);
}
# Parse the client data into %in.
CGI::ReadParse();
print <