| … | |
… | |
| 10 | |
10 | |
| 11 | use lib '.'; use webworkInit; # WeBWorKInitLine |
11 | use lib '.'; use webworkInit; # WeBWorKInitLine |
| 12 | use Global; |
12 | use Global; |
| 13 | use CGI qw(:standard); |
13 | use CGI qw(:standard); |
| 14 | use CGI::Carp qw(fatalsToBrowser); |
14 | use CGI::Carp qw(fatalsToBrowser); |
| 15 | use HTML::Entities (); |
15 | use HTML::Entities (); |
| 16 | use Net::SMTP; |
16 | use Net::SMTP; |
| 17 | |
17 | |
| 18 | $ENV{'PATH'} = ''; # try to avoid PATH attacks |
18 | $ENV{'PATH'} = ''; # try to avoid PATH attacks |
| 19 | |
19 | |
| 20 | # log access |
20 | # log access |
| … | |
… | |
| 51 | |
51 | |
| 52 | if ( $smtp->recipient($ADDR)) { # this one's okay, keep going |
52 | if ( $smtp->recipient($ADDR)) { # this one's okay, keep going |
| 53 | $smtp->data(&output(0,$ADDR) . access_link($ADDR) ) || |
53 | $smtp->data(&output(0,$ADDR) . access_link($ADDR) ) || |
| 54 | &internal_error("Unknown problem sending message data to SMTP server."); |
54 | &internal_error("Unknown problem sending message data to SMTP server."); |
| 55 | } else { # we have a problem with this address |
55 | } else { # we have a problem with this address |
| 56 | $smtp->reset; |
56 | $smtp->reset; |
| 57 | &internal_error("SMTP server doesn't like this address: <$ADDR>."); |
57 | &internal_error("SMTP server doesn't like this address: <$ADDR>."); |
| 58 | } |
58 | } |
| 59 | $smtp->quit; |
59 | $smtp->quit; |
| 60 | &log("Mail sent to: " . $ADDR . " from: " .param('email') ); |
60 | &log("Mail sent to: " . $ADDR . " from: " .param('email') ); |
| 61 | } |
61 | } |
| 62 | # &log("Mail sent to: " . param('To') . " from: " .param('email') ); |
62 | # &log("Mail sent to: " . param('To') . " from: " .param('email') ); |
| 63 | &thank_you; |
63 | &thank_you; |
| 64 | |
64 | |
| 65 | } else { |
65 | } else { |
| 66 | |
66 | |
| 67 | # No path info: we're generating a form to be filled-out |
67 | # No path info: we're generating a form to be filled-out |
| 68 | |
68 | |
| 69 | $To = $ENV{'QUERY_STRING'}; |
69 | $To = $ENV{'QUERY_STRING'}; |
| … | |
… | |
| 93 | } |
93 | } |
| 94 | |
94 | |
| 95 | sub user_error { |
95 | sub user_error { |
| 96 | my $msg = join " ", @_; |
96 | my $msg = join " ", @_; |
| 97 | print header, |
97 | print header, |
| 98 | start_html('-title' => 'User error', -BGCOLOR=>"$BGCOLOR"), |
98 | start_html('-title' => 'User error', -BGCOLOR=>"$BGCOLOR"), |
| 99 | h1('User error'), |
99 | h1('User error'), |
| 100 | p, |
100 | p, |
| 101 | b(HTML::Entities::encode($msg)), |
101 | b(HTML::Entities::encode($msg)), |
| 102 | p, |
102 | p, |
| 103 | "Please hit the "<B>Back</B>" button on your browser to ", |
103 | "Please hit the "<B>Back</B>" button on your browser to ", |
| … | |
… | |
| 120 | |
120 | |
| 121 | #http://webwork.math.rochester.edu/cgi-bin/development/processProblem7.pl?probSetKey=51823&probNum=7&Mode=HTML_tth&course=mth161dev&user=gage&key=NQ18Kry70j*.8Lsok3ulG^QHAp3zRG0hjHE5emT4 |
121 | #http://webwork.math.rochester.edu/cgi-bin/development/processProblem7.pl?probSetKey=51823&probNum=7&Mode=HTML_tth&course=mth161dev&user=gage&key=NQ18Kry70j*.8Lsok3ulG^QHAp3zRG0hjHE5emT4 |
| 122 | sub access_link { |
122 | sub access_link { |
| 123 | my $ADDR = shift; |
123 | my $ADDR = shift; |
| 124 | my $url = param('referring_url'); |
124 | my $url = param('referring_url'); |
|
|
125 | $USER = $ADDR; #param('To'); |
|
|
126 | $USER =~s/@.*$//; # determine the user (the recipient of this message) from the mail message. This method may change. |
| 125 | $url =~ s/\?.*$//; |
127 | $url =~ s/\?.*$//; |
| 126 | if (defined param('user')) { |
|
|
| 127 | $USER = param('user'); |
|
|
| 128 | } |
|
|
| 129 | else { |
|
|
| 130 | $USER = $ADDR; #param('To'); |
|
|
| 131 | $USER =~s/@.*$//; # determine the user (the recipient of this message) from the mail message |
|
|
| 132 | } # if param('user') not defined. E.g feedback before login. |
|
|
| 133 | |
|
|
| 134 | my $warning_limit = $^W; $^W=0; |
128 | my $warning_limit = $^W; $^W=0; |
| 135 | $url .= '?probSetKey='.param('probSetKey').'&probNum='.param('probNum').'&Mode='.param('Mode').'&show_old_answers=1'.'&course='.param('course')."&user=$USER&key=".param('key'); |
129 | $url .= '?probSetKey='.param('probSetKey').'&probNum='.param('probNum').'&Mode='.param('Mode').'&show_old_answers=1'.'&course='.param('course')."&user=$USER&key=".param('key'); |
| 136 | $^W= $warning_limit; |
130 | $^W= $warning_limit; |
| 137 | return ("-------\nTo go directly to the student's page, click on the Access Link and enter your password under Fast relogin.\nAccess Link " . $url . "\n"); |
131 | return ("-------\nTo go directly to the student's page, click on the Access Link and enter your password under Fast relogin.\nAccess Link " . $url . "\n"); |
| 138 | } |
132 | } |
| … | |
… | |
| 201 | my $suppress_output = $_[0]; |
195 | my $suppress_output = $_[0]; |
| 202 | my $addr = $_[1]; |
196 | my $addr = $_[1]; |
| 203 | my $msg; |
197 | my $msg; |
| 204 | my $replyTo = param('email'); |
198 | my $replyTo = param('email'); |
| 205 | $replyTo .= ', ' . $Global::defaultReply if ($Global::defaultReply =~ /\w/); |
199 | $replyTo .= ', ' . $Global::defaultReply if ($Global::defaultReply =~ /\w/); |
| 206 | |
200 | |
| 207 | $msg = |
201 | $msg = |
| 208 | # message header |
202 | # message header |
| 209 | "From: " . param('email') . " (" . param('name') . ")\n" . |
203 | "From: " . param('email') . " (" . param('name') . ")\n" . |
| 210 | "To: " . $addr . "\n" . |
204 | "To: " . $addr . "\n" . |
| 211 | "Reply-To: " . $replyTo . "\n" . |
205 | "Reply-To: " . $replyTo . "\n" . |