diff --git a/enrol/authorize/config.html b/enrol/authorize/config.html index 300db188dcf..fca6cc32361 100755 --- a/enrol/authorize/config.html +++ b/enrol/authorize/config.html @@ -1,9 +1,9 @@ - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - + + @@ -37,7 +37,7 @@ + diff --git a/enrol/authorize/enrol.php b/enrol/authorize/enrol.php index a27b5b1fe59..23ba98ef8dd 100755 --- a/enrol/authorize/enrol.php +++ b/enrol/authorize/enrol.php @@ -16,437 +16,437 @@ class enrolment_plugin extends enrolment_base { /// Override: print_entry() function print_entry($course) { - global $CFG, $USER, $form; + global $CFG, $USER, $form; - $strloginto = get_string("loginto", "", $course->shortname); - $strcourses = get_string("courses"); - $teacher = get_teacher($course->id); + $strloginto = get_string("loginto", "", $course->shortname); + $strcourses = get_string("courses"); + $teacher = get_teacher($course->id); - if ($this->zero_cost($course)) { - parent::print_entry($course); - } else { - // check payment - $this->check_paid(); + if ($this->zero_cost($course)) { + parent::print_entry($course); + } else { + // check payment + $this->check_paid(); - if ((!empty($CFG->loginhttps)) && (!isset($_SERVER['HTTPS']))) { - $wwwsroot = str_replace('http://','https://', $CFG->wwwroot); - $sdestination = "$wwwsroot/course/enrol.php?id=$course->id"; - redirect($sdestination); - exit; - } + if ((!empty($CFG->loginhttps)) && (!isset($_SERVER['HTTPS']))) { + $wwwsroot = str_replace('http://','https://', $CFG->wwwroot); + $sdestination = "$wwwsroot/course/enrol.php?id=$course->id"; + redirect($sdestination); + exit; + } - print_header($strloginto, $course->fullname, "wwwroot/course/\">$strcourses -> $strloginto"); - print_course($course, "80%"); - print_simple_box_start("center"); + print_header($strloginto, $course->fullname, "wwwroot/course/\">$strcourses -> $strloginto"); + print_course($course, "80%"); + print_simple_box_start("center"); - $coursefullname = $course->fullname; - $courseshortname= $course->shortname; - $userfirstname = $USER->firstname; - $userlastname = $USER->lastname; - $useraddress = $USER->address; - $usercity = $USER->city; - $cost = $this->get_cource_cost($course); + $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', - 'amx' => 'American Express', - 'dsc' => 'Discover', - 'dnc' => 'Diners Club', - 'jcb' => 'JCB', - 'swi' => 'Switch', - 'dlt' => 'Delta', - 'enr' => 'EnRoute' - ); + $CCTYPES = array( + 'mcd' => 'Master Card', + 'vis' => 'Visa', + 'amx' => 'American Express', + 'dsc' => 'Discover', + 'dnc' => 'Diners Club', + 'jcb' => 'JCB', + 'swi' => 'Switch', + 'dlt' => 'Delta', + 'enr' => 'EnRoute' + ); - $formvars = array('ccfirstname','cclastname','cc','ccexpiremm','ccexpireyyyy','cctype','cvv','cczip'); - foreach ($formvars as $var) { - if (!isset($form->$var)) { - $form->$var = ''; - } - } + $formvars = array('ccfirstname','cclastname','cc','ccexpiremm','ccexpireyyyy','cctype','cvv','cczip'); + foreach ($formvars as $var) { + if (!isset($form->$var)) { + $form->$var = ''; + } + } - include($CFG->dirroot . '/enrol/authorize/enrol.html'); - print_simple_box_end(); - print_footer(); - } + include($CFG->dirroot . '/enrol/authorize/enrol.html'); + print_simple_box_end(); + print_footer(); + } } /// Override: check_entry() function check_entry($form, $course) { - if ($this->zero_cost($course)) { - parent::check_entry($form, $course); - } else { - $this->cc_submit($form, $course); - } + if ($this->zero_cost($course)) { + parent::check_entry($form, $course); + } else { + $this->cc_submit($form, $course); + } } function cc_submit($form, $course) { - global $CFG, $USER, $SESSION; - require_once($CFG->dirroot . '/enrol/authorize/ccval.php'); + global $CFG, $USER, $SESSION; + require_once($CFG->dirroot . '/enrol/authorize/ccval.php'); - if (empty($form->ccfirstname) || empty($form->cclastname) || - empty($form->cc) || empty($form->cvv) || empty($form->cctype) || - empty($form->ccexpiremm) || empty($form->ccexpireyyyy)) { - $this->errormsg = get_string("allfieldsrequired"); - return; - } + if (empty($form->ccfirstname) || empty($form->cclastname) || + empty($form->cc) || empty($form->cvv) || empty($form->cctype) || + empty($form->ccexpiremm) || empty($form->ccexpireyyyy)) { + $this->errormsg = get_string("allfieldsrequired"); + return; + } - if (! CCVal($form->cc, $form->cctype)) { - $this->errormsg = get_string("ccinvalid", "enrol_authorize"); + if (! CCVal($form->cc, $form->cctype)) { + $this->errormsg = get_string("ccinvalid", "enrol_authorize"); return; - } - - $this->check_paid(); - $order_number = 0; // can be get from db - $formdata = array ( - 'x_version' => '3.1', - 'x_delim_data' => 'True', - 'x_delim_char' => AN_DELIM, - 'x_encap_char' => AN_ENCAP, - 'x_relay_response' => 'False', - 'x_login' => $CFG->an_login, - 'x_test_request' => (!empty($CFG->an_test)) ? 'True' : 'False', - 'x_type' => 'AUTH_CAPTURE', - 'x_method' => 'CC', - // user - 'x_first_name' => (empty($form->ccfirstname) ? $USER->firstname : $form->ccfirstname), - 'x_last_name' => (empty($form->cclastname) ? $USER->lastname : $form->cclastname), - 'x_address' => $USER->address, - 'x_city' => $USER->city, - 'x_state' => '', - 'x_zip' => $form->cczip, - 'x_country' => $USER->country, - 'x_card_num' => $form->cc, - 'x_card_code' => $form->cvv, - 'x_currency_code' => $CFG->enrol_currency, - 'x_amount' => $this->get_cource_cost($course), - 'x_exp_date' => (($form->ccexpiremm<10) ? strval('0'.$form->ccexpiremm) : strval($form->ccexpiremm)) . ($form->ccexpireyyyy), - 'x_email' => $USER->email, - 'x_email_customer' => 'False', - 'x_cust_id' => $USER->id, - 'x_customer_ip' => $_SERVER["REMOTE_ADDR"], - 'x_phone' => '', - 'x_fax' => '', - 'x_invoice_num' => $order_number, - 'x_description' => $course->shortname - ); + } + + $this->check_paid(); + $order_number = 0; // can be get from db + $formdata = array ( + 'x_version' => '3.1', + 'x_delim_data' => 'True', + 'x_delim_char' => AN_DELIM, + 'x_encap_char' => AN_ENCAP, + 'x_relay_response' => 'False', + 'x_login' => $CFG->an_login, + 'x_test_request' => (!empty($CFG->an_test)) ? 'True' : 'False', + 'x_type' => 'AUTH_CAPTURE', + 'x_method' => 'CC', + // user + 'x_first_name' => (empty($form->ccfirstname) ? $USER->firstname : $form->ccfirstname), + 'x_last_name' => (empty($form->cclastname) ? $USER->lastname : $form->cclastname), + 'x_address' => $USER->address, + 'x_city' => $USER->city, + 'x_state' => '', + 'x_zip' => $form->cczip, + 'x_country' => $USER->country, + 'x_card_num' => $form->cc, + 'x_card_code' => $form->cvv, + 'x_currency_code' => $CFG->enrol_currency, + 'x_amount' => $this->get_cource_cost($course), + 'x_exp_date' => (($form->ccexpiremm<10) ? strval('0'.$form->ccexpiremm) : strval($form->ccexpiremm)) . ($form->ccexpireyyyy), + 'x_email' => $USER->email, + 'x_email_customer' => 'False', + 'x_cust_id' => $USER->id, + 'x_customer_ip' => $_SERVER["REMOTE_ADDR"], + 'x_phone' => '', + 'x_fax' => '', + 'x_invoice_num' => $order_number, + 'x_description' => $course->shortname + ); - //build the post string - $poststring = ''; - if (!empty($CFG->an_tran_key)) { - $poststring .= urlencode("x_tran_key") . "=" . urlencode($CFG->an_tran_key); - } else { - $an_pswd = (isset($CFG->an_password)) ? $CFG->an_password : ''; - $poststring .= urlencode("x_password") . "=" . urlencode($an_pswd); - } - foreach($formdata as $key => $val) { - $poststring .= "&" . urlencode($key) . "=" . urlencode($val); - } - //built + //build the post string + $poststring = ''; + if (!empty($CFG->an_tran_key)) { + $poststring .= urlencode("x_tran_key") . "=" . urlencode($CFG->an_tran_key); + } else { + $an_pswd = (isset($CFG->an_password)) ? $CFG->an_password : ''; + $poststring .= urlencode("x_password") . "=" . urlencode($an_pswd); + } + foreach($formdata as $key => $val) { + $poststring .= "&" . urlencode($key) . "=" . urlencode($val); + } + //built - $response = array(); - $anrefererheader = ""; - if (isset($CFG->an_referer) && (!empty($CFG->an_referer)) && - ($CFG->an_referer != "http://") && ($CFG->an_referer != "https://")) { - $anrefererheader = "Referer: " . $CFG->an_referer . "\r\n"; - } - $fp = fsockopen("ssl://" . AN_HOST, AN_PORT, $errno, $errstr, 60); - if(!$fp) { - $this->errormsg = "$errstr ($errno)"; - return; - } else { - //send the server request - fputs($fp, - "POST " . AN_PATH . " HTTP/1.1\r\n" . - "Host: " . AN_HOST . "\r\n" . - $anrefererheader . - "Content-type: application/x-www-form-urlencoded\r\n" . - "Content-length: " . strlen($poststring) . "\r\n" . - "Connection: close\r\n\r\n" . - $poststring . "\r\n\r\n"); + $response = array(); + $anrefererheader = ""; + if (isset($CFG->an_referer) && (!empty($CFG->an_referer)) && + ($CFG->an_referer != "http://") && ($CFG->an_referer != "https://")) { + $anrefererheader = "Referer: " . $CFG->an_referer . "\r\n"; + } + $fp = fsockopen("ssl://" . AN_HOST, AN_PORT, $errno, $errstr, 60); + if(!$fp) { + $this->errormsg = "$errstr ($errno)"; + return; + } else { + //send the server request + fputs($fp, + "POST " . AN_PATH . " HTTP/1.1\r\n" . + "Host: " . AN_HOST . "\r\n" . + $anrefererheader . + "Content-type: application/x-www-form-urlencoded\r\n" . + "Content-length: " . strlen($poststring) . "\r\n" . + "Connection: close\r\n\r\n" . + $poststring . "\r\n\r\n"); - //Get the response header from the server - $str = ''; - while(!feof($fp) && !stristr($str, 'content-length')) { - $str = fgets($fp, 4096); - } - // If didnt get content-lenght, something is wrong. - if (!stristr($str, 'content-length')) { - $this->errormsg = "content-length error"; - return; - } + //Get the response header from the server + $str = ''; + while(!feof($fp) && !stristr($str, 'content-length')) { + $str = fgets($fp, 4096); + } + // If didnt get content-lenght, something is wrong. + if (!stristr($str, 'content-length')) { + $this->errormsg = "content-length error"; + return; + } - // Get length of data to be received. - $length = trim(substr($str,strpos($str,'content-length') + 15)); - // Get buffer (blank data before real data) - fgets($fp, 4096); - // Get real data - $data = fgets($fp, $length); - fclose($fp); - $response = explode(AN_ENCAP.AN_DELIM.AN_ENCAP, $data); - if ($response === false) - { - $this->errormsg = "response error"; - return; - } - $rcount = count($response) - 1; - if ($response[0]{0} == AN_ENCAP) { - $response[0] = substr($response[0], 1); - } - if (substr($response[$rcount], -1) == AN_ENCAP) { - $response[$rcount] = substr($response[$rcount], 0, -1); - } - } + // Get length of data to be received. + $length = trim(substr($str,strpos($str,'content-length') + 15)); + // Get buffer (blank data before real data) + fgets($fp, 4096); + // Get real data + $data = fgets($fp, $length); + fclose($fp); + $response = explode(AN_ENCAP.AN_DELIM.AN_ENCAP, $data); + if ($response === false) + { + $this->errormsg = "response error"; + return; + } + $rcount = count($response) - 1; + if ($response[0]{0} == AN_ENCAP) { + $response[0] = substr($response[0], 1); + } + if (substr($response[$rcount], -1) == AN_ENCAP) { + $response[$rcount] = substr($response[$rcount], 0, -1); + } + } - 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 ($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 (!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)); - } - 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 + 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)); + } + 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); - } + // 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) + } // 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); - } + if ($SESSION->wantsurl) { + $destination = $SESSION->wantsurl; + unset($SESSION->wantsurl); + } else { + $destination = "$CFG->wwwroot/course/view.php?id=$course->id"; + } + redirect($destination); + } } function zero_cost($course) { - $cost = $this->get_cource_cost($course); - if (abs($cost) < 0.01) { // no cost - return true; - } - return false; + $cost = $this->get_cource_cost($course); + if (abs($cost) < 0.01) { // no cost + return true; + } + return false; } function get_cource_cost($course) { - global $CFG; - $cost = (float)0; + global $CFG; + $cost = (float)0; - if (isset($course->cost)) { - if (((float)$course->cost) < 0) { - $cost = (float)$CFG->enrol_cost; + 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; + $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 = '€'; break; - case 'CAD': $currency = '$'; break; - case 'GBP': $currency = '£'; break; - case 'JPY': $currency = '¥'; break; - default: $currency = '$'; break; + switch ($CFG->enrol_currency) { + case 'EUR': $currency = '€'; break; + case 'CAD': $currency = '$'; break; + case 'GBP': $currency = '£'; break; + case 'JPY': $currency = '¥'; break; + default: $currency = '$'; break; } $str .= "

$strcost: " . - "wwwroot/course/view.php?id=$course->id\">" . - "$currency" . format_float($cost, 2) . '

'; - } - return $str; + "wwwroot/course/view.php?id=$course->id\">" . + "$currency" . format_float($cost, 2) . '

'; + } + return $str; } function config_form($frm) { - global $CFG; - $ancurrencies = array( - 'USD' => 'US Dollars', - 'EUR' => 'Euros', - 'JPY' => 'Japanese Yen', - 'GBP' => 'British Pounds', - 'CAD' => 'Canadian Dollars' - ); + 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 = ''; - } - } + $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"); + $this->check_openssl_loaded(false); + include("$CFG->dirroot/enrol/authorize/config.html"); } function check_openssl_loaded($die) { - if (!extension_loaded('openssl')) { - echo "
PHP must be compiled --with-openssl
"; - if ($die) { - die; - } - } + if (!extension_loaded('openssl')) { + echo "
PHP must be compiled --with-openssl
"; + 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); + $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_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); + 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; - } + // 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 (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->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_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_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_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_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_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); + if (!isset($config->enrol_allowinternal)) { + $config->enrol_allowinternal = ''; + } + set_config('enrol_allowinternal', $config->enrol_allowinternal); - return true; + return true; } function email_cc_error_to_admin($subject, $data) { - $admin = get_admin(); - $site = get_admin(); + $admin = get_admin(); + $site = get_admin(); - $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); + $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); } function check_paid() { - global $CFG, $SESSION; + global $CFG, $SESSION; - if (isset($SESSION->ccpaid)) { - unset($SESSION->ccpaid); - redirect($CFG->wwwroot . '/login/logout.php'); - exit; - } + if (isset($SESSION->ccpaid)) { + unset($SESSION->ccpaid); + redirect($CFG->wwwroot . '/login/logout.php'); + exit; + } } } // end of class definition -?> \ No newline at end of file +?> diff --git a/enrol/database/config.html b/enrol/database/config.html index 089eee6c99b..9de07d3266b 100644 --- a/enrol/database/config.html +++ b/enrol/database/config.html @@ -1,7 +1,7 @@
enrol_cost: - + enrol_cost: + @@ -11,8 +11,8 @@
enrol_currency: + enrol_currency: enrol_currency, "","", "") ?> @@ -24,8 +24,8 @@
an_login: + an_login: @@ -34,8 +34,8 @@
an_tran_key: + an_tran_key: @@ -44,8 +44,8 @@
an_password: + an_password: @@ -54,8 +54,8 @@
an_referer: + an_referer: @@ -64,8 +64,8 @@
an_test: + an_test: an_test) echo "checked=\"true\"" ?> /> @@ -76,8 +76,8 @@

enrol_mailstudents: + enrol_mailstudents: enrol_mailstudents) echo "checked=\"true\"" ?> /> @@ -86,8 +86,8 @@
enrol_mailteachers: + enrol_mailteachers: enrol_mailteachers) echo "checked=\"true\"" ?> /> @@ -96,8 +96,8 @@
enrol_mailadmins: + enrol_mailadmins: enrol_mailadmins) echo "checked=\"true\"" ?> /> @@ -106,8 +106,8 @@
enrol_allowinternal: + enrol_allowinternal: enrol_allowinternal) echo "checked=\"true\"" ?> /> diff --git a/enrol/authorize/enrol.html b/enrol/authorize/enrol.html index 0116b99a012..4deda1856e9 100755 --- a/enrol/authorize/enrol.html +++ b/enrol/authorize/enrol.html @@ -12,7 +12,7 @@
: -
:
: -
:
- - + - - + - - + - - + - - + - - + - - + - - + - - + - - + - - +
enrol_dbtype: + enrol_dbtype:
enrol_dbhost: + enrol_dbhost: enrol_dbhost)) { $frm->enrol_dbhost = ''; @@ -35,8 +35,8 @@
enrol_dbuser: + enrol_dbuser: @@ -45,8 +45,8 @@
enrol_dbpass: + enrol_dbpass: @@ -55,8 +55,8 @@
enrol_dbname: + enrol_dbname: @@ -65,8 +65,8 @@
enrol_dbtable: + enrol_dbtable: @@ -75,8 +75,8 @@
enrol_localcoursefield: + enrol_localcoursefield: @@ -85,8 +85,8 @@
enrol_localuserfield: + enrol_localuserfield: @@ -95,8 +95,8 @@
enrol_remotecoursefield: + enrol_remotecoursefield: @@ -105,8 +105,8 @@
enrol_remoteuserfield: + enrol_remoteuserfield: @@ -115,8 +115,8 @@
enrol_allowinternal: + enrol_allowinternal: enrol_allowinternal) echo "checked=\"true\"" ?> /> diff --git a/enrol/flatfile/config.html b/enrol/flatfile/config.html index 0cfed7bcc65..19d3aa0ea28 100644 --- a/enrol/flatfile/config.html +++ b/enrol/flatfile/config.html @@ -1,8 +1,8 @@ - - + - - + - - + - - + - - + - - + + + - - + + @@ -89,8 +89,8 @@ optional_variable($frm->enrol_ldap_template, ''); - - + @@ -114,8 +114,8 @@ optional_variable($frm->enrol_ldap_template, ''); - - + @@ -253,13 +253,13 @@ optional_variable($frm->enrol_ldap_template, ''); - - + + diff --git a/enrol/paypal/config.html b/enrol/paypal/config.html index bf78a985cc9..84f42d0fd26 100644 --- a/enrol/paypal/config.html +++ b/enrol/paypal/config.html @@ -1,8 +1,8 @@
enrol_flatfilelocation: + enrol_flatfilelocation: @@ -11,8 +11,8 @@
enrol_mailstudents: + enrol_mailstudents: enrol_mailstudents) echo "checked=\"true\"" ?> /> @@ -21,8 +21,8 @@
enrol_mailteachers: + enrol_mailteachers: enrol_mailteachers) echo "checked=\"true\"" ?> /> @@ -31,8 +31,8 @@
enrol_mailadmins: + enrol_mailadmins: enrol_mailadmins) echo "checked=\"true\"" ?> /> @@ -41,8 +41,8 @@
enrol_allowinternal: + enrol_allowinternal: enrol_allowinternal) echo "checked=\"true\"" ?> /> diff --git a/enrol/ldap/config.html b/enrol/ldap/config.html index 7b0b6adabeb..71140e8d9f9 100755 --- a/enrol/ldap/config.html +++ b/enrol/ldap/config.html @@ -39,25 +39,25 @@ optional_variable($frm->enrol_ldap_template, '');
enrol_ldap_host_url: + enrol_ldap_host_url: - -
enrol_ldap_version: + enrol_ldap_version: enrol_ldap_version, ""); - if (isset($err["enrol_ldap_version"])) formerr($err["enrol_ldap_version"]); + if (isset($err["enrol_ldap_version"])) formerr($err["enrol_ldap_version"]); ?> -
enrol_ldap_student_contexts: + enrol_ldap_student_contexts:
enrol_ldap_teacher_contexts: + enrol_ldap_teacher_contexts:
enrol_ldap_autocreate: + enrol_ldap_autocreate: 'no','1'=>'yes'), "enrol_ldap_autocreate", $frm->enrol_ldap_autocreate, ""); - if (isset($err["enrol_ldap_autocreate"])) formerr($err["enrol_ldap_autocreate"]); + if (isset($err["enrol_ldap_autocreate"])) formerr($err["enrol_ldap_autocreate"]); ?> -
- - + - - + - - + - - + - - + - - +
enrol_cost: + enrol_cost: @@ -11,8 +11,8 @@
enrol_currency: + enrol_currency: enrol_currency, "","", "") ?> @@ -21,8 +21,8 @@
enrol_paypalbusiness: + enrol_paypalbusiness: @@ -31,8 +31,8 @@
enrol_mailstudents: + enrol_mailstudents: enrol_mailstudents) echo "checked=\"true\"" ?> /> @@ -41,8 +41,8 @@
enrol_mailteachers: + enrol_mailteachers: enrol_mailteachers) echo "checked=\"true\"" ?> /> @@ -51,8 +51,8 @@
enrol_mailadmins: + enrol_mailadmins: enrol_mailadmins) echo "checked=\"true\"" ?> /> diff --git a/filter/algebra/AlgParser.pm b/filter/algebra/AlgParser.pm index 6ab1e7967a9..804e8328198 100755 --- a/filter/algebra/AlgParser.pm +++ b/filter/algebra/AlgParser.pm @@ -69,16 +69,16 @@ sub nexttoken { my($p1) = pos($self->{string}) || 0; if(scalar($self->{string} =~ m/\G$tokenregexp/gc)) { push @{$self->{posarray}}, [$p1, pos($self->{string})]; - if (defined($1)) {return ['binop3', $1];} - if (defined($2)) {return ['binop2', $2];} - if (defined($3)) {return ['binop1', $3];} - if (defined($4)) {return ['openp', $4];} - if (defined($5)) {return ['closep', $5];} - if (defined($6)) {return ['func1', $6];} - if (defined($7)) {return ['special', $7];} - if (defined($8)) {return ['varname', $8];} - if (defined($9)) {return ['numberE', $9];} - if (defined($10)) {return ['number', $10];} + if (defined($1)) {return ['binop3', $1];} + if (defined($2)) {return ['binop2', $2];} + if (defined($3)) {return ['binop1', $3];} + if (defined($4)) {return ['openp', $4];} + if (defined($5)) {return ['closep', $5];} + if (defined($6)) {return ['func1', $6];} + if (defined($7)) {return ['special', $7];} + if (defined($8)) {return ['varname', $8];} + if (defined($9)) {return ['numberE', $9];} + if (defined($10)) {return ['number', $10];} } else { push @{$self->{posarray}}, [$p1, undef]; @@ -120,7 +120,7 @@ sub parse { while (${$currentref}->[0] !~ /^(openp|top)/) { $currentref = pop @backtrace; } - my $index = ((${$currentref}->[0] eq 'top')?1:3); + my $index = ((${$currentref}->[0] eq 'top')?1:3); ${$currentref}->[$index] = ['binop1', $currenttok->[1], ${$currentref}->[$index], undef]; push @backtrace, $currentref; @@ -550,12 +550,12 @@ sub tolatex { if ($args[1]->[0] =~ /binop1|numberE/) {($p1,$p2)=qw{ \left( \right) };} # if ($args[2]->[0] =~ /binop[12]|numberE/) - if ($args[2]->[0] =~ /binop[12]|numberE|unop1/) + if ($args[2]->[0] =~ /binop[12]|numberE|unop1/) {($p3,$p4)=qw{ \left( \right) };} if ($args[0] eq '/'){ # return('\frac{' . $p1 . $args[1]->tolatex() . $p2 . '}'. # '{' . $p3 . $args[2]->tolatex() . $p4 . '}' ); - return('\frac{' . $args[1]->tolatex() . '}'. + return('\frac{' . $args[1]->tolatex() . '}'. '{' . $args[2]->tolatex() . '}' ); } else{ diff --git a/filter/algebra/algebradebug.php b/filter/algebra/algebradebug.php index 4883263e479..3077f51d150 100644 --- a/filter/algebra/algebradebug.php +++ b/filter/algebra/algebradebug.php @@ -25,11 +25,11 @@ $algebra = substr($query,8,$splitpos); $md5 = md5($algebra); if (strpos($query,'ShowDB') || strpos($query,'DeleteDB')) { - $texcache = get_record("cache_filters","filter","algebra", "md5key", $md5); + $texcache = get_record("cache_filters","filter","algebra", "md5key", $md5); } if (strpos($query,'ShowDB')) { if ($texcache) { - $output = "DB cache_filters entry for $algebra\n"; + $output = "DB cache_filters entry for $algebra\n"; $output .= "id = $texcache->id\n"; $output .= "filter = $texcache->filter\n"; $output .= "version = $texcache->version\n"; @@ -45,7 +45,7 @@ $output = "Deleting DB cache_filters entry for $algebra\n"; $result = delete_records("cache_filters","id",$texcache->id); if ($result) { - $result = 1; + $result = 1; } else { $result = 0; } @@ -55,17 +55,17 @@ } } if (strpos($query,'TeXStage1')) { - $output = algebra2tex($algebra); + $output = algebra2tex($algebra); } if (strpos($query,'TeXStage2')) { - $output = algebra2tex($algebra); + $output = algebra2tex($algebra); $output = refineTeX($output); } if (strpos($query,'ShowImage')||strpos($query,'SlashArguments')) { - $output = algebra2tex($algebra); + $output = algebra2tex($algebra); $output = refineTeX($output); if (strpos($query,'ShowImage')) { - tex2image($output, $md5); + tex2image($output, $md5); } else { slasharguments($output, $md5); } @@ -103,7 +103,7 @@ function algebra2tex($algebra) { echo "The shell command
$cmd
returned status = $status
\n"; $commandpath = "$CFG->dirroot\\$CFG->algebrafilterdirwin\\algebra2tex.pl"; if (file_exists($commandpath)) { - echo "The file permissions of algebra2tex.pl are: " . decoct(fileperms($commandpath)) . "
"; + echo "The file permissions of algebra2tex.pl are: " . decoct(fileperms($commandpath)) . "
"; } die; } @@ -222,7 +222,7 @@ function tex2image($texexp, $md5, $return=false) { } $pathname = "$CFG->dataroot/$CFG->algebraimagedir/$image"; if (file_exists($pathname)) { - unlink($pathname); + unlink($pathname); } $commandpath = ""; $cmd = ""; @@ -234,23 +234,23 @@ function tex2image($texexp, $md5, $return=false) { case "WINNT": case "WIN32": case "Windows": - $commandpath="$CFG->dirroot/$CFG->texfilterdir/mimetex.exe"; - $texexp = str_replace('"','\"',$texexp); - $cmd = str_replace(' ','^ ',$commandpath); - $cmd .= " ++ -e \"$pathname\" \"$texexp\""; + $commandpath="$CFG->dirroot/$CFG->texfilterdir/mimetex.exe"; + $texexp = str_replace('"','\"',$texexp); + $cmd = str_replace(' ','^ ',$commandpath); + $cmd .= " ++ -e \"$pathname\" \"$texexp\""; break; case "Darwin": - $commandpath="$CFG->dirroot/$CFG->texfilterdir/mimetex.darwin"; + $commandpath="$CFG->dirroot/$CFG->texfilterdir/mimetex.darwin"; $cmd = "\"$CFG->dirroot/$CFG->texfilterdir/mimetex.darwin\" -e \"$pathname\" ". escapeshellarg($texexp); break; } if (!$cmd) { - if (is_executable("$CFG->dirroot/$CFG->texfilterdir/mimetex")) { /// Use the custom binary + if (is_executable("$CFG->dirroot/$CFG->texfilterdir/mimetex")) { /// Use the custom binary $commandpath="$CFG->dirroot/$CFG->texfilterdir/mimetex"; - $cmd = "$CFG->dirroot/$CFG->texfilterdir/mimetex -e $pathname ". escapeshellarg($texexp); - } else { - error($error_message1); - } + $cmd = "$CFG->dirroot/$CFG->texfilterdir/mimetex -e $pathname ". escapeshellarg($texexp); + } else { + error($error_message1); + } } system($cmd, $status); } @@ -329,7 +329,7 @@ function slasharguments($texexp, $md5) {
  1. First click on this button to see the cache_filters database entry for this expression.
  2. -
  3. If the database entry looks corrupt, click on this button to delete it: +
  4. If the database entry looks corrupt, click on this button to delete it:
  5. Now click on this button . A preliminary translation into TeX will appear in the box below.
  6. diff --git a/filter/algebra/filter.php b/filter/algebra/filter.php index d672da556d6..75e3578e4e4 100644 --- a/filter/algebra/filter.php +++ b/filter/algebra/filter.php @@ -180,28 +180,28 @@ function algebra_filter ($courseid, $text) { $texexp = str_replace('\right}','}',$texexp); $texexp = str_replace('\fun',' ',$texexp); $texexp = str_replace('infty','\infty',$texexp); - $texexp = str_replace('alpha','\alpha',$texexp); - $texexp = str_replace('gamma','\gamma',$texexp); - $texexp = str_replace('iota','\iota',$texexp); - $texexp = str_replace('kappa','\kappa',$texexp); - $texexp = str_replace('lambda','\lambda',$texexp); - $texexp = str_replace('mu','\mu',$texexp); - $texexp = str_replace('nu','\nu',$texexp); - $texexp = str_replace('xi','\xi',$texexp); - $texexp = str_replace('rho','\rho',$texexp); - $texexp = str_replace('sigma','\sigma',$texexp); - $texexp = str_replace('tau','\tau',$texexp); - $texexp = str_replace('phi','\phi',$texexp); - $texexp = str_replace('chi','\chi',$texexp); - $texexp = str_replace('psi','\psi',$texexp); - $texexp = str_replace('omega','\omega',$texexp); - $texexp = str_replace('zdelta','\delta',$texexp); - $texexp = str_replace('bita','\beta',$texexp); - $texexp = str_replace('thita','\theta',$texexp); - $texexp = str_replace('zita','\zeta',$texexp); - $texexp = str_replace('xeta','\eta',$texexp); - $texexp = str_replace('zepslon','\epsilon',$texexp); - $texexp = str_replace('zupslon','\upsilon',$texexp); + $texexp = str_replace('alpha','\alpha',$texexp); + $texexp = str_replace('gamma','\gamma',$texexp); + $texexp = str_replace('iota','\iota',$texexp); + $texexp = str_replace('kappa','\kappa',$texexp); + $texexp = str_replace('lambda','\lambda',$texexp); + $texexp = str_replace('mu','\mu',$texexp); + $texexp = str_replace('nu','\nu',$texexp); + $texexp = str_replace('xi','\xi',$texexp); + $texexp = str_replace('rho','\rho',$texexp); + $texexp = str_replace('sigma','\sigma',$texexp); + $texexp = str_replace('tau','\tau',$texexp); + $texexp = str_replace('phi','\phi',$texexp); + $texexp = str_replace('chi','\chi',$texexp); + $texexp = str_replace('psi','\psi',$texexp); + $texexp = str_replace('omega','\omega',$texexp); + $texexp = str_replace('zdelta','\delta',$texexp); + $texexp = str_replace('bita','\beta',$texexp); + $texexp = str_replace('thita','\theta',$texexp); + $texexp = str_replace('zita','\zeta',$texexp); + $texexp = str_replace('xeta','\eta',$texexp); + $texexp = str_replace('zepslon','\epsilon',$texexp); + $texexp = str_replace('zupslon','\upsilon',$texexp); $texexp = str_replace('\mbox{logten}','\mbox{log}_{10}',$texexp); $texexp = str_replace('\mbox{acos}','\mbox{cos}^{-1}',$texexp); $texexp = str_replace('\mbox{asin}','\mbox{sin}^{-1}',$texexp); @@ -216,26 +216,26 @@ function algebra_filter ($courseid, $text) { $texexp = str_replace('\mbox{acsch}','\mbox{csch}^{-1}',$texexp); $texexp = str_replace('\mbox{acoth}','\mbox{coth}^{-1}',$texexp); //$texexp = preg_replace('/\\\frac{(.+?)}{\\\left\((.+?)\\\right\)}/s','\frac{'."\$1}{\$2}",$texexp); - $texexp = preg_replace('/\\\sqrt{(.+?),(.+?)}/s','\sqrt['. "\$2]{\$1}",$texexp); - $texexp = preg_replace('/\\\mbox{abs}\\\left\((.+?)\\\right\)/s',"|\$1|",$texexp); + $texexp = preg_replace('/\\\sqrt{(.+?),(.+?)}/s','\sqrt['. "\$2]{\$1}",$texexp); + $texexp = preg_replace('/\\\mbox{abs}\\\left\((.+?)\\\right\)/s',"|\$1|",$texexp); $texexp = preg_replace('/\\\log\\\left\((.+?),(.+?)\\\right\)/s','\log_{'. "\$2}\\left(\$1\\right)",$texexp); $texexp = preg_replace('/(\\\cos|\\\sin|\\\tan|\\\sec|\\\csc|\\\cot)([h]*)\\\left\((.+?),(.+?)\\\right\)/s',"\$1\$2^{". "\$4}\\left(\$3\\right)",$texexp); - $texexp = preg_replace('/\\\int\\\left\((.+?),(.+?),(.+?)\\\right\)/s','\int_'. "{\$2}^{\$3}\$1 ",$texexp); + $texexp = preg_replace('/\\\int\\\left\((.+?),(.+?),(.+?)\\\right\)/s','\int_'. "{\$2}^{\$3}\$1 ",$texexp); $texexp = preg_replace('/\\\int\\\left\((.+?d[a-z])\\\right\)/s','\int '. "\$1 ",$texexp); - $texexp = preg_replace('/\\\lim\\\left\((.+?),(.+?),(.+?)\\\right\)/s','\lim_'. "{\$2\\to \$3}\$1 ",$texexp); - $texcache->filter = 'algebra'; - $texcache->version = 1; - $texcache->md5key = $md5; - $texcache->rawtext = addslashes($texexp); - $texcache->timemodified = time(); - insert_record("cache_filters",$texcache, false); - $text = str_replace( $matches[0][$i], string_file_picture_algebra($filename, $texexp, '', '', $align), $text); - } else { - $text = str_replace( $matches[0][$i],"Undetermined error: ",$text); + $texexp = preg_replace('/\\\lim\\\left\((.+?),(.+?),(.+?)\\\right\)/s','\lim_'. "{\$2\\to \$3}\$1 ",$texexp); + $texcache->filter = 'algebra'; + $texcache->version = 1; + $texcache->md5key = $md5; + $texcache->rawtext = addslashes($texexp); + $texcache->timemodified = time(); + insert_record("cache_filters",$texcache, false); + $text = str_replace( $matches[0][$i], string_file_picture_algebra($filename, $texexp, '', '', $align), $text); + } else { + $text = str_replace( $matches[0][$i],"Undetermined error: ",$text); } - } else { - $text = str_replace( $matches[0][$i], string_file_picture_algebra($filename, $texcache->rawtext), $text); - } + } else { + $text = str_replace( $matches[0][$i], string_file_picture_algebra($filename, $texcache->rawtext), $text); + } } return $text; } diff --git a/filter/tex/filter.php b/filter/tex/filter.php index 72f25d44ed7..18df876cf9f 100644 --- a/filter/tex/filter.php +++ b/filter/tex/filter.php @@ -61,14 +61,14 @@ function string_file_picture_tex($imagefile, $tex= "", $height="", $width="", $a } if ($imagefile) { if (!file_exists("$CFG->dataroot/$CFG->texfilterdir/$imagefile") && isadmin()) { - $output .= "wwwroot/$CFG->texfilterdir/texdebug.php\">"; + $output .= "wwwroot/$CFG->texfilterdir/texdebug.php\">"; } else { $output .= "wwwroot/$CFG->texfilterdir/displaytex.php?"; $output .= urlencode($tex) . "\" onclick=\"return openpopup('/$CFG->texfilterdir/displaytex.php?"; $output .= urlencode($tex) . "', 'popup', 'menubar=0,location=0,scrollbars,"; $output .= "resizable,width=300,height=240', 0);\">"; - } + } $output .= "\"\"slasharguments) { // Use this method if possible for better caching $output .= "$CFG->wwwroot/$CFG->texfilterdir/pix.php/$imagefile"; diff --git a/filter/tex/texdebug.php b/filter/tex/texdebug.php index d08cdea3082..6c3973638f4 100644 --- a/filter/tex/texdebug.php +++ b/filter/tex/texdebug.php @@ -121,17 +121,17 @@ break; } if (!$cmd) { - if (is_executable("$CFG->dirroot/$CFG->texfilterdir/mimetex")) { /// Use the custom binary + if (is_executable("$CFG->dirroot/$CFG->texfilterdir/mimetex")) { /// Use the custom binary $commandpath="$CFG->dirroot/$CFG->texfilterdir/mimetex"; $cmd = "$CFG->dirroot/$CFG->texfilterdir/mimetex -e $pathname ". escapeshellarg($texexp); } else { error($error_message1); - } + } } system($cmd, $status); } - if ($return) { - return $image; + if ($return) { + return $image; } if ($texexp && file_exists($pathname)) { $lastmodified = filemtime($pathname); diff --git a/grade/exceptions.html b/grade/exceptions.html index b585c576bbf..cd0d736790d 100644 --- a/grade/exceptions.html +++ b/grade/exceptions.html @@ -2,7 +2,7 @@