Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Authorize.net plugin, some fixes.

  • Loading branch information...
commit 425b7741772e9a9505db44837a4ef0f6bb9b8865 1 parent 5d319ac
ethem authored
View
2  enrol/authorize/ccval.php
@@ -1,4 +1,4 @@
-<?php
+<?php // $Id$
/************************************************************************
*
* CCVal - Credit Card Validation function.
View
225 enrol/authorize/config.html
@@ -1,107 +1,118 @@
-<table cellspacing="0" cellpadding="5" border="0" align="center">
-
-<tr valign="top">
- <td align="right">enrol_cost:</td>
- <td>
- <input type="text" size="5" name="enrol_cost" value="<?php p($frm->enrol_cost) ?>" />
- </td>
- <td>
- <?php print_string("costdefault") ?>
- </td>
-</tr>
-
-<tr valign="top">
- <td align="right">enrol_currency:</td>
- <td>
- <?php choose_from_menu ($paypalcurrencies, "enrol_currency", $frm->enrol_currency, "","", "") ?>
- </td>
- <td>
- <?php print_string("currency") ?>
- </td>
-</tr>
-
-
-
-
-<tr valign="top">
- <td align="right">an_login:</td>
- <td>
- <input type="text" name="an_login" value="<?php echo $frm->an_login ?>" />
- </td>
- <td>
- <?php print_string("anlogin", "enrol_authorize") ?>
- </td>
-</tr>
-
-<tr valign="top">
- <td align="right">an_tran_key:</td>
- <td>
- <input type="text" name="an_tran_key" value="<?php echo $frm->an_tran_key ?>" />
- </td>
- <td>
- <?php print_string("antrankey", "enrol_authorize") ?>
- </td>
-</tr>
-
-<tr valign="top">
- <td align="right">an_password:</td>
- <td>
- <input type="text" name="an_password" value="<?php echo $frm->an_password ?>" />
- </td>
- <td>
- <?php print_string("anpassword", "enrol_authorize") ?>
- </td>
-</tr>
-
-<tr valign="top">
- <td align="right">an_test:</td>
- <td>
- <input type="checkbox" value=1 name="an_test" <?php if ($frm->an_test) echo "checked=\"true\"" ?> />
- </td>
- <td>
- <?php print_string("antestmode", "enrol_authorize") ?>
- </td>
-</tr>
-
-
-<tr valign="top">
- <td align="right">enrol_mailstudents:</td>
- <td>
- <input type="checkbox" value=1 name="enrol_mailstudents" <?php if ($frm->enrol_mailstudents) echo "checked=\"true\"" ?> />
- </td>
- <td>
- <?php print_string("mailstudents") ?>
- </td>
-</tr>
-
-<tr valign="top">
- <td align="right">enrol_mailteachers:</td>
- <td>
- <input type="checkbox" value=1 name="enrol_mailteachers" <?php if ($frm->enrol_mailteachers) echo "checked=\"true\"" ?> />
- </td>
- <td>
- <?php print_string("mailteachers") ?>
- </td>
-</tr>
-
-<tr valign="top">
- <td align="right">enrol_mailadmins:</td>
- <td>
- <input type="checkbox" value=1 name="enrol_mailadmins" <?php if ($frm->enrol_mailadmins) echo "checked=\"true\"" ?> />
- </td>
- <td>
- <?php print_string("mailadmins") ?>
- </td>
-</tr>
-
-<tr valign="top">
- <td align="right">enrol_allowinternal:</td>
- <td>
- <input type="checkbox" value="1" name="enrol_allowinternal" <?php if ($frm->enrol_allowinternal) echo "checked=\"true\"" ?> />
- </td>
- <td>
- <?php print_string('allowinternal') ?>
- </td>
-</tr>
-
-</table>
+<table cellspacing="0" cellpadding="5" border="0" align="center">
+
+<tr valign="top">
+ <td align="right">enrol_cost:</td>
+ <td>
+ <input type="text" size="5" name="enrol_cost" value="<?php p($frm->enrol_cost) ?>" />
+ </td>
+ <td>
+ <?php print_string("costdefault") ?>
+ </td>
+</tr>
+
+<tr valign="top">
+ <td align="right">enrol_currency:</td>
+ <td>
+ <?php choose_from_menu ($ancurrencies, "enrol_currency", $frm->enrol_currency, "","", "") ?>
+ </td>
+ <td>
+ <?php print_string("currency") ?>
+ </td>
+</tr>
+
+
+
+
+<tr valign="top">
+ <td align="right">an_login:</td>
+ <td>
+ <input type="text" name="an_login" value="<?php echo $frm->an_login ?>" />
+ </td>
+ <td>
+ <?php print_string("anlogin", "enrol_authorize") ?>
+ </td>
+</tr>
+
+<tr valign="top">
+ <td align="right">an_tran_key:</td>
+ <td>
+ <input type="text" name="an_tran_key" value="<?php echo $frm->an_tran_key ?>" />
+ </td>
+ <td>
+ <?php print_string("antrankey", "enrol_authorize") ?>
+ </td>
+</tr>
+
+<tr valign="top">
+ <td align="right">an_password:</td>
+ <td>
+ <input type="text" name="an_password" value="<?php echo $frm->an_password ?>" />
+ </td>
+ <td>
+ <?php print_string("anpassword", "enrol_authorize") ?>
+ </td>
+</tr>
+
+<tr valign="top">
+ <td align="right">an_referer:</td>
+ <td>
+ <input type="text" name="an_referer" value="<?php echo $frm->an_referer ?>" />
+ </td>
+ <td>
+ <?php print_string("anreferer", "enrol_authorize") ?>
+ </td>
+</tr>
+
+<tr valign="top">
+ <td align="right">an_test:</td>
+ <td>
+ <input type="checkbox" value=1 name="an_test" <?php if ($frm->an_test) echo "checked=\"true\"" ?> />
+ </td>
+ <td>
+ <?php print_string("antestmode", "enrol_authorize") ?>
+ </td>
+</tr>
+
+<tr valign="top"><td colspan="3"><hr noshade size="1"></td></tr>
+
+<tr valign="top">
+ <td align="right">enrol_mailstudents:</td>
+ <td>
+ <input type="checkbox" value=1 name="enrol_mailstudents" <?php if ($frm->enrol_mailstudents) echo "checked=\"true\"" ?> />
+ </td>
+ <td>
+ <?php print_string("mailstudents") ?>
+ </td>
+</tr>
+
+<tr valign="top">
+ <td align="right">enrol_mailteachers:</td>
+ <td>
+ <input type="checkbox" value=1 name="enrol_mailteachers" <?php if ($frm->enrol_mailteachers) echo "checked=\"true\"" ?> />
+ </td>
+ <td>
+ <?php print_string("mailteachers") ?>
+ </td>
+</tr>
+
+<tr valign="top">
+ <td align="right">enrol_mailadmins:</td>
+ <td>
+ <input type="checkbox" value=1 name="enrol_mailadmins" <?php if ($frm->enrol_mailadmins) echo "checked=\"true\"" ?> />
+ </td>
+ <td>
+ <?php print_string("mailadmins") ?>
+ </td>
+</tr>
+
+<tr valign="top">
+ <td align="right">enrol_allowinternal:</td>
+ <td>
+ <input type="checkbox" value="1" name="enrol_allowinternal" <?php if ($frm->enrol_allowinternal) echo "checked=\"true\"" ?> />
+ </td>
+ <td>
+ <?php print_string('allowinternal') ?>
+ </td>
+</tr>
+
+</table>
View
95 enrol/authorize/enrol.html
@@ -1,44 +1,51 @@
-<p align="center"><?php if (! empty($this->errormsg)) {formerr($this->errormsg);} ?></p>
-
-<div align="center">
-
-<p><?php print_string("paymentrequired") ?></p>
-<p><b><?php echo get_string("cost").": $CFG->enrol_currency $cost"; ?></b></p>
-<p><?php print_string("paymentinstant") ?></p>
-
-<form name="form" method="post" action="enrol.php" autocomplete="off">
-<input type="hidden" name="id" value="<?php p($course->id) ?>" />
-<table align="center" width="100%" border=0>
-<tr>
- <td align="right"><?php print_string("nameoncard", "enrol_authorize") ?>: </td>
- <td align="left"><input type="text" name="ccfirstname" size="16" value="<?php p($userfirstname) ?>" />
- <input type="text" name="cclastname" size="16" value="<?php p($userlastname) ?>" /></td>
-</tr>
-<tr>
- <td align="right"><?php print_string("ccno", "enrol_authorize") ?>: </td>
- <td align="left"><input type="text" name="cc" size="16" value="<?php p($form->cc) ?>" /></td>
-</tr>
-<tr>
- <td align="right"><?php print_string("ccexpire", "enrol_authorize") ?>: </td>
- <td align="left"><?php
- for ($i=1; $i<=12; $i++) {
- $months[$i] = userdate(gmmktime(12,0,0,$i,1,2000), "%B");
- }
- choose_from_menu($months, 'ccexpiremm', $form->ccexpiremm, '');
- ?> <input type="text" name="ccexpireyyyy" size="4" maxlength="4" value="<?php p($form->ccexpireyyyy) ?>" /></td>
-</tr>
-<tr>
- <td align="right"><?php print_string("ccvv", "enrol_authorize") ?>: </td>
- <td align="left"><input type="text" name="cvv" size="4" maxlength="4" value="<?php p($form->cvv) ?>" />
- <font size=1><?php print_string("ccvvhelp", "enrol_authorize") ?></font></td>
-</tr>
-<tr>
- <td align="right"><?php print_string("zipcode", "enrol_authorize") ?>: </td>
- <td align="left"><input type="text" name="cczip" size="5" value="<?php p($form->cczip) ?>" /></td>
-</tr>
-
-</table>
-<input type="submit" value="<?php print_string("sendpaymentbutton", "enrol_authorize") ?>">
-</form>
-
-</div>
+<p align="center"><?php if (! empty($this->errormsg)) {formerr($this->errormsg);} ?></p>
+
+<div align="center">
+
+<p><?php print_string("paymentrequired") ?></p>
+<p><b><?php echo get_string("cost").": $CFG->enrol_currency $cost"; ?></b></p>
+<p><?php print_string("paymentinstant") ?></p>
+
+<form name="form" method="post" action="enrol.php" autocomplete="off">
+<input type="hidden" name="id" value="<?php p($course->id) ?>" />
+<table align="center" width="100%" border=0>
+<tr>
+ <td align="right"><?php print_string("nameoncard", "enrol_authorize") ?>: </td>
+ <td align="left"><input type="text" name="ccfirstname" size="16" value="<?php p($userfirstname) ?>" />
+ <input type="text" name="cclastname" size="16" value="<?php p($userlastname) ?>" /></td>
+</tr>
+<tr>
+ <td align="right"><?php print_string("ccno", "enrol_authorize") ?>: </td>
+ <td align="left"><input type="text" name="cc" size="16" value="<?php p($form->cc) ?>" /></td>
+</tr>
+<tr>
+ <td align="right"><?php print_string("ccexpire", "enrol_authorize") ?>: </td>
+ <td align="left"><?php
+ for ($i=1; $i<=12; $i++) {
+ $months[$i] = userdate(gmmktime(12,0,0,$i,1,2000), "%B");
+ }
+ choose_from_menu($months, 'ccexpiremm', $form->ccexpiremm, '');
+ ?> <input type="text" name="ccexpireyyyy" size="4" maxlength="4" value="<?php p($form->ccexpireyyyy) ?>" /></td>
+</tr>
+<tr>
+ <td align="right"><?php print_string("cctype", "enrol_authorize") ?>: </td>
+ <td align="left"><?php
+ choose_from_menu($CCTYPES, 'cctype', $form->cctype);
+ ?>
+</td>
+</tr>
+<tr>
+ <td align="right"><?php print_string("ccvv", "enrol_authorize") ?>: </td>
+ <td align="left"><input type="text" name="cvv" size="4" maxlength="4" value="<?php p($form->cvv) ?>" />
+ <font size=1><?php print_string("ccvvhelp", "enrol_authorize") ?></font></td>
+</tr>
+<tr>
+ <td align="right"><?php print_string("zipcode", "enrol_authorize") ?>: </td>
+ <td align="left"><input type="text" name="cczip" size="5" value="<?php p($form->cczip) ?>" /></td>
+</tr>
+
+</table>
+<input type="submit" value="<?php print_string("sendpaymentbutton", "enrol_authorize") ?>">
+</form>
+
+</div>
View
469 enrol/authorize/enrol.php
@@ -42,15 +42,14 @@ function print_entry($course) {
print_course($course, "80%");
print_simple_box_start("center");
- //Sanitise some fields before building the CC form
- $coursefullname = $this->sanitise_for_cc($course->fullname);
- $courseshortname= $this->sanitise_for_cc($course->shortname);
- $userfirstname = $this->sanitise_for_cc($USER->firstname);
- $userlastname = $this->sanitise_for_cc($USER->lastname);
- $useraddress = $this->sanitise_for_cc($USER->address);
- $usercity = $this->sanitise_for_cc($USER->city);
+ $coursefullname = $course->fullname;
+ $courseshortname= $course->shortname;
+ $userfirstname = $USER->firstname;
+ $userlastname = $USER->lastname;
+ $useraddress = $USER->address;
+ $usercity = $USER->city;
$cost = $this->get_cource_cost($course);
-
+
$CCTYPES = array(
'mcd' => 'Master Card',
'vis' => 'Visa',
@@ -147,7 +146,7 @@ function cc_submit($form, $course)
} else {
$formdata['x_password'] = (isset($CFG->an_password)) ? $CFG->an_password : '';
}
-
+
//build the post string
$poststring = '';
foreach($formdata AS $key => $val) {
@@ -155,11 +154,8 @@ function cc_submit($form, $course)
}
// strip off trailing ampersand
$poststring = substr($poststring, 0, -1);
- $response = array();
- $fp = fsockopen("zip://" . "wwww." . AN_HOST , AN_PORT, $errno, $errstr, $timeout = 60);
-
- echo isset($fp); exit;
-
+
+ $fp = fsockopen("ssl://" . AN_HOST, AN_PORT, $errno, $errstr, $timeout = 60);
if(!$fp) {
$this->errormsg = "$errstr ($errno)";
return;
@@ -168,12 +164,12 @@ function cc_submit($form, $course)
if (isset($CFG->an_referer) && (!empty($CFG->an_referer)) &&
($CFG->an_referer != "http://") && ($CFG->an_referer != "https://")) {
$anrefererheader = "Referer: " . $CFG->an_referer . "\r\n";
- }
-
+ }
+
//send the server request
fputs($fp,
"POST " . AN_PATH . " HTTP/1.1\r\n" .
- //"Host: " . AN_HOST . "\r\n" .
+ "Host: " . AN_HOST . "\r\n" .
$anrefererheader .
"Content-type: application/x-www-form-urlencoded\r\n" .
"Content-length: " . strlen($poststring) . "\r\n" .
@@ -201,297 +197,244 @@ function cc_submit($form, $course)
$response = explode("|", $data);
}
- if ($response[0] == AN_APPROVED) {
- $SESSION->ccpaid = 1; // security check: don't duplicate payment
-
- // XXX: Is this valid for paid cources?
- //if ($course->enrolperiod) {
- // $timestart = time();
- // $timeend = $timestart + $course->enrolperiod;
- //} else {
- // $timestart = $timeend = 0;
- //}
- // XXX: Is this valid for paid cources?
- // if (!enrol_student($USER->id, $course->id, $timestart, $timeend)) {
-
- if (!enrol_student($USER->id, $course->id)) {
- $this->email_cc_error_to_admin("Error while trying to enrol ".fullname($USER)." in '$course->fullname'", $response);
- } else {
- // begin: send email
- $teacher = get_teacher($course->id);
- if (!empty($CFG->enrol_mailstudents)) {
- $a->coursename = "$course->fullname";
- $a->profileurl = "$CFG->wwwroot/user/view.php?id=$user->id";
- email_to_user($USER, $teacher, get_string("enrolmentnew", '', $course->shortname),
- get_string('welcometocoursetext', '', $a));
- }
-
- if (!empty($CFG->enrol_mailteachers)) {
- $a->course = "$course->fullname";
- $a->user = fullname($USER);
- email_to_user($teacher, $USER, get_string("enrolmentnew", '', $course->shortname),
- get_string('enrolmentnewuser', '', $a));
+ if ($response[0] != AN_APPROVED) {
+ $this->errormsg = isset($response[3]) ? $response[3] : 'unknown error';
+ } else {
+ $SESSION->ccpaid = 1; // security check: don't duplicate payment
+ if ($course->enrolperiod) {
+ $timestart = time();
+ $timeend = $timestart + $course->enrolperiod;
+ } else {
+ $timestart = $timeend = 0;
}
-
- if (!empty($CFG->enrol_mailadmins)) {
- $a->course = "$course->fullname";
- $a->user = fullname($USER);
- $admins = get_admins();
- foreach ($admins as $admin) {
- email_to_user($admin, $USER, get_string("enrolmentnew", '', $course->shortname),
+
+ if (!enrol_student($USER->id, $course->id, $timestart, $timeend)) {
+ $this->email_cc_error_to_admin("Error while trying to enrol ".fullname($USER)." in '$course->fullname'", $response);
+ } else {
+ // begin: send email
+ $teacher = get_teacher($course->id);
+ if (!empty($CFG->enrol_mailstudents)) {
+ $a->coursename = "$course->fullname";
+ $a->profileurl = "$CFG->wwwroot/user/view.php?id=$user->id";
+ email_to_user($USER, $teacher, get_string("enrolmentnew", '', $course->shortname),
+ get_string('welcometocoursetext', '', $a));
+ }
+
+ if (!empty($CFG->enrol_mailteachers)) {
+ $a->course = "$course->fullname";
+ $a->user = fullname($USER);
+ email_to_user($teacher, $USER, get_string("enrolmentnew", '', $course->shortname),
get_string('enrolmentnewuser', '', $a));
}
- }
- // end: send email
- // begin: authorize_table
- $cclast4 = substr($form->cc, -4);
- $datax->cclastfour = ($cclast4 === false) ? '0000' : $cclast4;
- $datax->ccexp = $formdata['x_exp_date'];
- $datax->cvv = $form->cvv;
- $datax->ccname = $formdata['x_first_name'] . " " . $formdata['x_last_name'];
- $datax->courseid = $course->id;
- $datax->userid = $USER->id;
- $datax->avscode = strval($response[5]);
- $datax->transid = strval($response[6]);
-
- if (!insert_record("enrol_authorize", $datax)) { // Insert a transaction record
- $this->email_cc_error_to_admin("Error while trying to insert valid transaction", $datax);
- }
+
+ if (!empty($CFG->enrol_mailadmins)) {
+ $a->course = "$course->fullname";
+ $a->user = fullname($USER);
+ $admins = get_admins();
+ foreach ($admins as $admin) {
+ email_to_user($admin, $USER, get_string("enrolmentnew", '', $course->shortname),
+ get_string('enrolmentnewuser', '', $a));
+ }
+ }
+ // end: send email
+
+ // begin: authorize_table
+ $cclast4 = substr($form->cc, -4);
+ $datax->cclastfour = ($cclast4 === false) ? '0000' : $cclast4;
+ $datax->ccexp = $formdata['x_exp_date'];
+ $datax->cvv = $form->cvv;
+ $datax->ccname = $formdata['x_first_name'] . " " . $formdata['x_last_name'];
+ $datax->courseid = $course->id;
+ $datax->userid = $USER->id;
+ $datax->avscode = strval($response[5]);
+ $datax->transid = strval($response[6]);
+
+ if (!insert_record("enrol_authorize", $datax)) { // Insert a transaction record
+ $this->email_cc_error_to_admin("Error while trying to insert valid transaction", $datax);
+ }
- } // end if (!enrol_student)
-
- if ($SESSION->wantsurl) {
- $destination = $SESSION->wantsurl;
- unset($SESSION->wantsurl);
- } else {
+ } // end if (!enrol_student)
+
+ if ($SESSION->wantsurl) {
+ $destination = $SESSION->wantsurl;
+ unset($SESSION->wantsurl);
+ } else {
$destination = "$CFG->wwwroot/course/view.php?id=$course->id";
- }
- //
- redirect($destination);
- } else {
- $this->errormsg = $response[3];
- }
+ }
+ redirect($destination);
+ }
}
function zero_cost($course) {
$cost = $this->get_cource_cost($course);
-
- if (abs($cost) < 0.01) { // no cost
- return true;
- }
-
- return false;
+ if (abs($cost) < 0.01) { // no cost
+ return true;
+ }
+ return false;
}
function get_cource_cost($course) {
- global $CFG;
- $cost = (float)0;
-
- if (isset($course->cost))
- {
- if (((float)$course->cost) < 0)
- {
- $cost = (float)$CFG->enrol_cost;
- }
- else
- {
- $cost = (float)$course->cost;
- }
- }
-
- $cost = format_float($cost, 2);
- return $cost;
+ global $CFG;
+ $cost = (float)0;
+
+ if (isset($course->cost)) {
+ if (((float)$course->cost) < 0) {
+ $cost = (float)$CFG->enrol_cost;
+ } else {
+ $cost = (float)$course->cost;
+ }
+ }
+ $cost = format_float($cost, 2);
+ return $cost;
}
-
/// Override the get_access_icons() function
function get_access_icons($course) {
- global $CFG;
+ global $CFG;
- $str = '';
- $cost = $this->get_cource_cost($course);
+ $str = '';
+ $cost = $this->get_cource_cost($course);
- if (abs($cost) < 0.01) {
- $str = parent::get_access_icons($course);
- } else {
-
- $strrequirespayment = get_string("requirespayment");
- $strcost = get_string("cost");
+ if (abs($cost) < 0.01) {
+ $str = parent::get_access_icons($course);
+ } else {
+ $strrequirespayment = get_string("requirespayment");
+ $strcost = get_string("cost");
- if (empty($CFG->enrol_currency)) {
- set_config('enrol_currency', 'USD');
- }
+ if (empty($CFG->enrol_currency)) {
+ set_config('enrol_currency', 'USD');
+ }
- switch ($CFG->enrol_currency) {
- case 'EUR': $currency = '&euro;'; break;
- case 'CAD': $currency = '$'; break;
- case 'GBP': $currency = '&pound;'; break;
- case 'JPY': $currency = '&yen;'; break;
- default: $currency = '$'; break;
+ switch ($CFG->enrol_currency) {
+ case 'EUR': $currency = '&euro;'; break;
+ case 'CAD': $currency = '$'; break;
+ case 'GBP': $currency = '&pound;'; break;
+ case 'JPY': $currency = '&yen;'; break;
+ default: $currency = '$'; break;
}
-
- $str .= "<p class=\"coursecost\"><font size=-1>$strcost: ".
- "<a title=\"$strrequirespayment\" href=\"$CFG->wwwroot/course/view.php?id=$course->id\"></a>";
- $str .= "$currency".format_float($cost,2).'</a></p>';
-
- }
-
- return $str;
+
+ $str .= "<p class=\"coursecost\"><font size=-1>$strcost: " .
+ "<a title=\"$strrequirespayment\" href=\"$CFG->wwwroot/course/view.php?id=$course->id\"></a>" .
+ "$currency" . format_float($cost, 2) . '</a></p>';
+ }
+ return $str;
}
function config_form($frm) {
- global $CFG;
-
- $ancurrencies = array( 'USD' => 'US Dollars',
- 'EUR' => 'Euros',
- 'JPY' => 'Japanese Yen',
- 'GBP' => 'British Pounds',
- 'CAD' => 'Canadian Dollars'
- );
-
- $vars = array('enrol_cost', 'enrol_currency', 'an_login', 'an_tran_key', 'an_password', 'an_referer', 'an_test',
- 'enrol_mailstudents', 'enrol_mailteachers', 'enrol_mailadmins', 'enrol_allowinternal');
- foreach ($vars as $var) {
- if (!isset($frm->$var)) {
- $frm->$var = '';
- }
- }
-
- $this->check_openssl_loaded(false);
- include("$CFG->dirroot/enrol/authorize/config.html");
+ global $CFG;
+ $ancurrencies = array(
+ 'USD' => 'US Dollars',
+ 'EUR' => 'Euros',
+ 'JPY' => 'Japanese Yen',
+ 'GBP' => 'British Pounds',
+ 'CAD' => 'Canadian Dollars'
+ );
+
+ $vars = array('enrol_cost', 'enrol_currency', 'an_login', 'an_tran_key', 'an_password', 'an_referer', 'an_test',
+ 'enrol_mailstudents', 'enrol_mailteachers', 'enrol_mailadmins', 'enrol_allowinternal');
+ foreach ($vars as $var) {
+ if (!isset($frm->$var)) {
+ $frm->$var = '';
+ }
+ }
+
+ $this->check_openssl_loaded(false);
+ include("$CFG->dirroot/enrol/authorize/config.html");
}
function check_openssl_loaded($die)
{
if (!extension_loaded('openssl')) {
- echo "<font color=red><center>PHP must be compiled --with-openssl</center></font>";
- if ($die)
- die;
- }
+ echo "<font color=red><center>PHP must be compiled --with-openssl</center></font>";
+ if ($die)
+ die;
+ }
}
function process_config($config) {
$this->check_openssl_loaded(true);
-
- if (!isset($config->an_login)) {
- $config->an_login = '';
- }
- set_config('an_login', $config->an_login);
-
- if (!isset($config->an_password)) {
- $config->an_password = '';
- }
- set_config('an_password', $config->an_password);
-
- if (!isset($config->an_tran_key)) {
- $config->an_tran_key = '';
- }
- set_config('an_tran_key', $config->an_tran_key);
-
- // Some required fields
- if (empty($config->an_login))
- {
- echo "an_login required";
- die;
- }
- if (empty($config->an_tran_key) && empty($config->an_password))
- {
- echo "an_tran_key or an_password required";
- die;
- }
-
- if (empty($config->an_referer)) {
- $config->an_referer = 'http://';
- }
- set_config('an_referer', $config->an_referer);
-
- if (!isset($config->an_test)) {
- $config->an_test = '';
- }
- set_config('an_test', $config->an_test);
-
- // ----
- if (!isset($config->enrol_cost)) {
- $config->enrol_cost = '0';
- }
- set_config('enrol_cost', $config->enrol_cost);
-
- if (!isset($config->enrol_currency)) {
- $config->enrol_currency = 'USD';
- }
- set_config('enrol_currency', $config->enrol_currency);
-
- if (!isset($config->enrol_mailstudents)) {
- $config->enrol_mailstudents = '';
- }
- set_config('enrol_mailstudents', $config->enrol_mailstudents);
-
- if (!isset($config->enrol_mailteachers)) {
- $config->enrol_mailteachers = '';
- }
- set_config('enrol_mailteachers', $config->enrol_mailteachers);
-
- if (!isset($config->enrol_mailadmins)) {
- $config->enrol_mailadmins = '';
- }
- set_config('enrol_mailadmins', $config->enrol_mailadmins);
-
- if (!isset($config->enrol_allowinternal)) {
- $config->enrol_allowinternal = '';
- }
- set_config('enrol_allowinternal', $config->enrol_allowinternal);
-
- return true;
-}
+ if (!isset($config->an_login)) {
+ $config->an_login = '';
+ }
+ set_config('an_login', $config->an_login);
-function email_cc_error_to_admin($subject, $data) {
- $admin = get_admin();
- $site = get_admin();
+ if (!isset($config->an_password)) {
+ $config->an_password = '';
+ }
+ set_config('an_password', $config->an_password);
- $message = "$site->fullname: Transaction failed.\n\n$subject\n\n";
+ if (!isset($config->an_tran_key)) {
+ $config->an_tran_key = '';
+ }
+ set_config('an_tran_key', $config->an_tran_key);
- foreach ($data as $key => $value) {
- $message .= "$key => $value\n";
- }
- email_to_user($admin, $admin, "CC ERROR: ".$subject, $message);
-}
+ // Some required fields
+ if (empty($config->an_login)) {
+ echo "an_login required";
+ die;
+ }
+ if (empty($config->an_tran_key) && empty($config->an_password)) {
+ echo "an_tran_key or an_password required";
+ die;
+ }
+ if (empty($config->an_referer)) {
+ $config->an_referer = 'http://';
+ }
+ set_config('an_referer', $config->an_referer);
-//To avoid wrong (for PayPal) characters in sent data
-function sanitise_for_cc($text) {
- global $CFG;
-
- if (!empty($CFG->sanitise_for_paypal)) {
- //Array of characters to replace (not allowed by PayPal)
- //Can be expanded as necessary to add other diacritics
- $replace = array('á' => 'a', //Spanish characters
- 'é' => 'e',
- 'í' => 'i',
- 'ó' => 'o',
- 'ú' => 'u',
- 'Á' => 'A',
- 'É' => 'E',
- 'Í' => 'I',
- 'Ó' => 'O',
- 'Ú' => 'U',
- 'ñ' => 'n',
- 'Ñ' => 'N',
- 'ü' => 'u',
- 'Ü' => 'U');
- $text = strtr($text, $replace);
-
- //Make here other sanities if necessary
+ if (!isset($config->an_test)) {
+ $config->an_test = '';
+ }
+ set_config('an_test', $config->an_test);
+
+ // --------------------------------------
+ if (!isset($config->enrol_cost)) {
+ $config->enrol_cost = '0';
+ }
+ set_config('enrol_cost', $config->enrol_cost);
- }
+ if (!isset($config->enrol_currency)) {
+ $config->enrol_currency = 'USD';
+ }
+ set_config('enrol_currency', $config->enrol_currency);
- return $text;
+ if (!isset($config->enrol_mailstudents)) {
+ $config->enrol_mailstudents = '';
+ }
+ set_config('enrol_mailstudents', $config->enrol_mailstudents);
+
+ if (!isset($config->enrol_mailteachers)) {
+ $config->enrol_mailteachers = '';
+ }
+ set_config('enrol_mailteachers', $config->enrol_mailteachers);
+ if (!isset($config->enrol_mailadmins)) {
+ $config->enrol_mailadmins = '';
+ }
+ set_config('enrol_mailadmins', $config->enrol_mailadmins);
+
+ if (!isset($config->enrol_allowinternal)) {
+ $config->enrol_allowinternal = '';
+ }
+ set_config('enrol_allowinternal', $config->enrol_allowinternal);
+
+ return true;
}
+function email_cc_error_to_admin($subject, $data) {
+ $admin = get_admin();
+ $site = get_admin();
-} // end of class definition
+ $message = "$site->fullname: Transaction failed.\n\n$subject\n\n";
+ foreach ($data as $key => $value) {
+ $message .= "$key => $value\n";
+ }
+ email_to_user($admin, $admin, "CC ERROR: ".$subject, $message);
+}
-?>
+} // end of class definition
+?>
Please sign in to comment.
Something went wrong with that request. Please try again.