AAAAhome/academiac/www/administrator/components/com_virtuemart/helpers/creditcard.php000060400000012110151372154470024573 0ustar00number = self::_strtonum($cardnum); /* if(!$this->detectType($this->number)) { $this->errno = CC_ETYPE; $d['error'] = $this->errno; return false; } */ if (empty($this->number) || !self::mod10($this->number)) { //JError::raiseWarning('', JText::_('COM_VIRTUEMART_CC_ENUMBER')); // $this->errno = CC_ENUMBER; // $d['error'] = $this->errno; return false; } return true; } /* * _strtonum private method * return formated string - only digits */ function _strtonum($string) { $nstr = ""; for ($i = 0; $i < strlen($string); $i++) { if (!is_numeric($string{$i})) continue; $nstr = "$nstr" . $string{$i}; } return $nstr; } /* * mod10 method - Luhn check digit algorithm * return 0 if true and !0 if false */ function mod10($card_number) { $digit_array = array(); $cnt = 0; //Reverse the card number $card_temp = strrev($card_number); //Multiple every other number by 2 then ( even placement ) //Add the digits and place in an array for ($i = 1; $i <= strlen($card_temp) - 1; $i = $i + 2) { //multiply every other digit by 2 $t = substr($card_temp, $i, 1); $t = $t * 2; //if there are more than one digit in the //result of multipling by two ex: 7 * 2 = 14 //then add the two digits together ex: 1 + 4 = 5 if (strlen($t) > 1) { //add the digits together $tmp = 0; //loop through the digits that resulted of //the multiplication by two above and add them //together for ($s = 0; $s < strlen($t); $s++) { $tmp = substr($t, $s, 1) + $tmp; } } else { // result of (* 2) is only one digit long $tmp = $t; } //place the result in an array for later //adding to the odd digits in the credit card number $digit_array [$cnt++] = $tmp; } $tmp = 0; //Add the numbers not doubled earlier ( odd placement ) for ($i = 0; $i <= strlen($card_temp); $i = $i + 2) { $tmp = substr($card_temp, $i, 1) + $tmp; } //Add the earlier doubled and digit-added numbers to the result $result = $tmp + array_sum($digit_array); //Check to make sure that the remainder //of dividing by 10 is 0 by using the modulas //operator return ($result % 10 == 0); } /* * validate_credit_card_cvv * The three- or four-digit number on the back of a credit card (on the front for American Express). * @author Valerie Isaksen */ static function validate_credit_card_cvv($creditcard_type, $cvv, $required = true) { if ($required and empty($cvv)) return false; return true; } /* * validate_credit_card_date * expiration date should be tested * @author Valerie Isaksen */ function validate_credit_card_date($creditcard_type, $month, $year) { return true; } } // pure php no closing tag