#!/usr/bin/perl # fill in amount with needed # really need the fully/partially deal? # make database-ready and invoice ready output use Mysql; unshift(@INC,"/usr/local/etc/httpd/sites/virtualfoundation.org/admin"); require('cgisettings.pl'); $email_donation_msg_to = ("webmaster\@ecologia.org", "ecologia\@igc.apc.org" ); # connect to the DB -- we'll need this no matter what $dbh = Mysql->connect(undef, "foundation", "vf", "virtualfoundation"); #debug $process_delay = "1"; #debug # check for id to process, and process it (spooled at job) if ($ARGV[0] =~ /^\d{10}$/) { &process_donation($ARGV[0]); exit; } &parse_input; &tweak_input(%stdin); if (!$stdin{'step'}) { if ($argv{'project_id'} =~ /^.{10}$/) { &get_project_info($argv{'project_id'}); } elsif ($ENV{'HTTP_REFERER'} =~ m#/proposals/(.{10})\.(html|cgi)#) { &get_project_info($1); } unless ($stdin{'project_name'}) { $stdin{'project_name'} = "Project Name"; } &first_page; &project_stuff; &first_pageb; } elsif ($stdin{'step'} eq "2") { &assign_id; &record_info; if ( ($stdin{'how'} eq "fully" || $stdin{'how'} eq "partially") && ( !$stdin{'project_name'} || $stdin{'project_name'} eq "Project Name" ) ) { &error_page("need_project_name"); exit; } if ( !$stdin{'amount'} || $stdin{'amount'} !~ /^\d+$/ ) { &error_page("need_amount"); exit; } &second_page; } elsif ($stdin{'step'} eq "3") { #$time = `date +%y%m%d%H%M`; chop($time); #if ( $time > ( $stdin{'id'} + $process_delay ) ) { # &assign_id; # &fork_processor; #} &fork_processor; &record_info; &fix_amount; if ( !$stdin{'name'} ) { &error_page("need_name"); exit; } unless ($stdin{'phone'} || $stdin{'email'} || $stdin{'address'}) { &error_page("need_contact"); exit; } if ( $stdin{'email'} && $stdin{'email'} !~ /.+\@.+/ ) { &error_page("invalid_email"); exit; } if ( $stdin{'phone'} ) { if ( $stdin{'phone'} =~ /(\d{3}).*(\d{3}).*(\d{4})/ ) { $stdin{'phone'} = "($1) $2-$3"; } else { &error_page("invalid_phone"); exit; } } &third_page; } exit; sub assign_id { $stdin{'id'} = `date +%y%m%d%H%M`; chop($stdin{'id'}); } sub get_project_info { local($project_id = $_[0],%hash); #so we don't drag that around # if ( $project_id =~ /^.{10}$/ ) { # connect to the DB $dbh = Mysql->connect(undef, $database_name, "vf", "virtualfoundation"); unless ($sth_select = $dbh->query("SELECT * FROM main WHERE id = '$project_id'") ) { print "Select query failed."; die "Select query failed.
";
}
%hash = $sth_select->fetchhash;
$stdin{'project_name'} = $hash{'title'};
$stdin{'amount'} = $hash{'budget'} - $hash{'collected'};
# }
}
######################
### Page Functions ###
######################
#
#
sub first_page {
print <
The Virtual Foundation - your donation makes it happen
Donating to the Virtual Foundation
Please complete the form and then click "Proceed to the Next Page".
If you have any trouble with this form or would feel more comfortable speaking
to someone, please don't hesitate to call us at (888)801-7101.