Card Validation and Postal Code field validation fix. (is_int & is_numeric)

This commit is contained in:
ethem
2006-01-27 09:16:01 +00:00
parent bdc003eb05
commit b1fa2cf269
3 changed files with 28 additions and 18 deletions
+14 -5
View File
@@ -23,7 +23,7 @@ $usercountry = empty($form->cccountry) ? $USER->country : $form->cccountry;
<div align="center">
<p><?php print_string("paymentrequired") ?></p>
<p><b><?php echo get_string("cost").": $curcost[currency] $curcost[cost]"; ?></b></p>
<p><b><?php echo get_string("cost").": $curcost[currency] $curcost[cost]"; ?></b></p>
<p><?php print_string("paymentinstant") ?></p>
<form name="form" method="post" action="enrol.php" autocomplete="off">
@@ -31,13 +31,13 @@ $usercountry = empty($form->cccountry) ? $USER->country : $form->cccountry;
<table align="center" width="100%" border=0>
<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 align="left"><input type="text" name="cc" size="16" value="<?php p($form->cc) ?>" />
<?php if (!empty($this->ccerrors['cc'])) { formerr($this->ccerrors['cc']); } ?></td>
</tr>
<tr>
<td align="right"><?php print_string("nameoncard", "enrol_authorize") ?>: </td>
<td align="left"><input type="text" name="ccfirstname" size="8" value="<?php p($userfirstname) ?>" />
<input type="text" name="cclastname" size="8" value="<?php p($userlastname) ?>" />
<td align="left"><input type="text" name="ccfirstname" size="8" value="<?php p($userfirstname) ?>" />
<input type="text" name="cclastname" size="8" value="<?php p($userlastname) ?>" />
<?php if (!empty($this->ccerrors['ccfirstlast'])) { formerr($this->ccerrors['ccfirstlast']); } ?></td>
</tr>
<tr>
@@ -78,7 +78,7 @@ $usercountry = empty($form->cccountry) ? $USER->country : $form->cccountry;
<?php if (!empty($CFG->an_avs)) { /* Address Verification System */ ?>
<tr>
<td align="right"><?php print_string("address") ?>: </td>
<td align="left"><input type="text" name="ccaddress" size="32" value="<?php p($useraddress) ?>" />
<td align="left"><input type="text" name="ccaddress" size="32" value="<?php p($useraddress) ?>" />
<?php if (!empty($this->ccerrors['ccaddress'])) { formerr($this->ccerrors['ccaddress']); } ?></td>
</tr>
<tr>
@@ -92,6 +92,15 @@ $usercountry = empty($form->cccountry) ? $USER->country : $form->cccountry;
<td align="left"><?php choose_from_menu(get_list_of_countries(), "cccountry", $usercountry, get_string("selectacountry")."..."); ?>
<?php if (!empty($this->ccerrors['cccountry'])) { formerr($this->ccerrors['cccountry']); } ?></td>
</tr>
<?php } else { /* not AVS */ ?>
<tr>
<td colspan="2">
<input type="hidden" name="ccstate" value="" />
<input type="hidden" name="ccaddress" value="<?php p($useraddress) ?>" />
<input type="hidden" name="cccity" value="<?php p($usercity) ?>" />
<input type="hidden" name="cccountry" value="<?php p($usercountry) ?>" />
</td>
</tr>
<?php } ?>
<tr>
<td align="right"><?php print_string("zipcode", "enrol_authorize") ?>: </td>
+14 -12
View File
@@ -147,26 +147,28 @@ class enrolment_plugin extends enrolment_base
}
$extra = new stdClass();
$extra->x_phone = '';
$extra->x_fax = '';
$extra->x_first_name = $form->ccfirstname;
$extra->x_last_name = $form->cclastname;
$extra->x_address = $form->ccaddress;
$extra->x_city = $form->cccity;
$extra->x_zip = $form->cczip;
$extra->x_state = $form->ccstate;
$extra->x_country = $form->cccountry;
$extra->x_card_num = $form->cc;
$extra->x_card_code = $form->cvv;
$extra->x_exp_date = $exp_date;
$extra->x_currency_code = $curcost['currency'];
$extra->x_amount = $curcost['cost'];
$extra->x_first_name = $form->ccfirstname;
$extra->x_last_name = $form->cclastname;
$extra->x_country = $form->cccountry;
$extra->x_address = $form->ccaddress;
$extra->x_state = $form->ccstate;
$extra->x_city = $form->cccity;
$extra->x_zip = $form->cczip;
$extra->x_invoice_num = $order->id;
$extra->x_description = $course->shortname;
$extra->x_cust_id = $USER->id;
$extra->x_customer_ip = $useripno;
$extra->x_email = $USER->email;
$extra->x_customer_ip = $useripno;
$extra->x_email_customer = empty($CFG->enrol_mailstudents) ? 'FALSE' : 'TRUE';
$extra->x_phone = '';
$extra->x_fax = '';
$message = '';
$an_review = !empty($CFG->an_review);
@@ -296,7 +298,7 @@ class enrolment_plugin extends enrolment_base
if (empty($form->cc)) {
$this->ccerrors['cc'] = get_string('missingcc', 'enrol_authorize');
}
if (empty($form->cvv) || !is_int($form->cvv)) {
if (empty($form->cvv) || !is_numeric($form->cvv)) {
$this->ccerrors['cvv'] = get_string('missingcvv', 'enrol_authorize');
}
if (empty($form->cctype)) {
@@ -313,7 +315,7 @@ class enrolment_plugin extends enrolment_base
$this->ccerrors['cccountry'] = get_string('missingcountry');
}
}
if (empty($form->cczip) || !is_int($form->cczip)) {
if (empty($form->cczip) || !is_numeric($form->cczip)) {
$this->ccerrors['cczip'] = get_string('missingzip', 'enrol_authorize');
}
if (!empty($this->ccerrors)) {
-1
View File
@@ -2,7 +2,6 @@
require_once '../../config.php';
require_once $CFG->dirroot.'/enrol/authorize/const.php';
require_once $CFG->dirroot.'/enrol/authorize/enrol.php';
require_once $CFG->dirroot.'/enrol/authorize/action.php';
define('ORDER_CAPTURE', 'capture');