Skip to content

Commit

Permalink
Nice coding.
Browse files Browse the repository at this point in the history
  • Loading branch information
ethem committed Aug 5, 2005
1 parent 78e7f92 commit b94448d
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions enrol/authorize/enrol.php
Expand Up @@ -28,15 +28,16 @@ function print_entry($course) {
// check payment // check payment
$this->check_paid(); $this->check_paid();


// HTTPS support: I want to paid on secure layer. // I want to paid on SSL.
if ((!empty($CFG->loginhttps)) && (!isset($_SERVER['HTTPS']))) { if (empty($_SERVER['HTTPS'])) {
$wwwsroot = str_replace('http://','https://', $CFG->wwwroot); if (empty($CFG->loginhttps)) {
$sdestination = "$wwwsroot/course/enrol.php?id=$course->id"; error(get_string("httpsrequired", "enrol_authorize"));
redirect($sdestination); } else {
exit; $wwwsroot = str_replace('http://','https://', $CFG->wwwroot);
} $sdestination = "$wwwsroot/course/enrol.php?id=$course->id";
if (!isset($_SERVER['HTTPS'])) { redirect($sdestination);
error(get_string("httpsrequired", "enrol_authorize")); exit;
}
} }


$CCTYPES = array( $CCTYPES = array(
Expand All @@ -61,7 +62,7 @@ function print_entry($course) {


print_header($strloginto, $course->fullname, "<a href=\"$CFG->wwwroot/course/\">$strcourses</a> -> $strloginto"); print_header($strloginto, $course->fullname, "<a href=\"$CFG->wwwroot/course/\">$strcourses</a> -> $strloginto");
print_course($course, "80%"); print_course($course, "80%");

if ($course->password) { if ($course->password) {
print_simple_box(get_string('choosemethod', 'enrol_authorize'), 'center'); print_simple_box(get_string('choosemethod', 'enrol_authorize'), 'center');
$password = ''; $password = '';
Expand Down Expand Up @@ -95,7 +96,8 @@ function cc_submit($form, $course) {
return; return;
} }


$exp_date = (($form->ccexpiremm<10) ? strval('0'.$form->ccexpiremm) : strval($form->ccexpiremm)) . ($form->ccexpireyyyy); $exp_date = ($form->ccexpiremm < 10) ? strval('0'.$form->ccexpiremm) : strval($form->ccexpiremm);
$exp_date .= $form->ccexpireyyyy;
$valid_cc = CCVal($form->cc, $form->cctype, $exp_date); $valid_cc = CCVal($form->cc, $form->cctype, $exp_date);
$curcost = $this->get_course_cost($course); $curcost = $this->get_course_cost($course);
$useripno = getremoteaddr(); // HTTP_CLIENT_IP, HTTP_X_FORWARDED_FOR, REMOTE_ADDR $useripno = getremoteaddr(); // HTTP_CLIENT_IP, HTTP_X_FORWARDED_FOR, REMOTE_ADDR
Expand Down Expand Up @@ -214,7 +216,7 @@ function cc_submit($form, $course) {
} }


if (!enrol_student($USER->id, $course->id, $timestart, $timeend)) { 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); $this->email_to_admin("Error while trying to enrol ".fullname($USER)." in '$course->fullname'", $response);
} else { } else {
// begin: send email // begin: send email
$teacher = get_teacher($course->id); $teacher = get_teacher($course->id);
Expand Down Expand Up @@ -250,7 +252,7 @@ function cc_submit($form, $course) {
$datax->avscode = strval($response[5]); $datax->avscode = strval($response[5]);
$datax->transid = strval($response[6]); $datax->transid = strval($response[6]);
if (!insert_record("enrol_authorize", $datax)) { // Insert a transaction record if (!insert_record("enrol_authorize", $datax)) { // Insert a transaction record
$this->email_cc_error_to_admin("Error while trying to insert valid transaction", $datax); $this->email_to_admin("Error while trying to insert valid transaction", $datax);
} }
} // end if (!enrol_student) } // end if (!enrol_student)


Expand All @@ -277,7 +279,9 @@ function get_course_cost($course) {
$cost = (float)(((float)$course->cost) < 0) ? $CFG->enrol_cost : $course->cost; $cost = (float)(((float)$course->cost) < 0) ? $CFG->enrol_cost : $course->cost;
} }


$currency = (!empty($course->currency)) ? $course->currency : (empty($CFG->enrol_currency) ? 'USD' : $CFG->enrol_currency); $currency = (!empty($course->currency))
? $course->currency :( empty($CFG->enrol_currency)
? 'USD' : $CFG->enrol_currency );


$cost = format_float($cost, 2); $cost = format_float($cost, 2);
$ret = array('cost' => $cost, 'currency' => $currency); $ret = array('cost' => $cost, 'currency' => $currency);
Expand Down Expand Up @@ -394,7 +398,7 @@ function process_config($config) {
return $return; return $return;
} }


function email_cc_error_to_admin($subject, $data) { function email_to_admin($subject, $data) {
$admin = get_admin(); $admin = get_admin();
$site = get_site(); $site = get_site();


Expand Down

0 comments on commit b94448d

Please sign in to comment.