Changeset 1670
- Timestamp:
- 01/04/2008 01:07:23 PM (12 months ago)
- Location:
- trunk/system
- Files:
-
- 1 added
- 2 modified
-
config/credit_cards.php (added)
-
helpers/valid.php (modified) (2 diffs)
-
libraries/Calendar.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/system/helpers/valid.php
r1579 r1670 123 123 124 124 /** 125 * Validates a credit card number using the Luhn (mod10) formula. Make sure 126 * to remove all non-digit characters from the number before using validating 127 * the card number or it will fail. 125 * Validates a credit card number using the Luhn (mod10) formula. 128 126 * @see http://en.wikipedia.org/wiki/Luhn_algorithm 129 127 * 130 * @param integer credit card number (13-16 digits)128 * @param integer credit card number 131 129 * @param string card type 132 130 * @return boolean 133 131 */ 134 public static function creditcard($number, $type = 'default') 135 { 136 // Make sure the number and expiration are not empty and consist of only numbers 137 if (empty($number) OR ! ctype_digit((string) $number)) 138 return FALSE; 139 140 // Card types based on http://en.wikipedia.org/wiki/Credit_card_number 141 $cards = array 142 ( 143 'default' => array 144 ( 145 'length' => '13,14,15,16,17,18,19', 146 'prefix' => '', 147 'luhn' => TRUE 148 ), 149 'american express' => array 150 ( 151 'length' => '15', 152 'prefix' => '3[47]', 153 'luhn' => TRUE 154 ), 155 'maestro' => array 156 ( 157 'length' => '16,18', 158 'prefix' => '50(?:20|38)|6(?:304|759)', 159 'luhn' => TRUE 160 ), 161 'mastercard' => array 162 ( 163 'length' => '16', 164 'prefix' => '5[1-5]', 165 'luhn' => TRUE 166 ), 167 'visa' => array 168 ( 169 'length' => '13,16', 170 'prefix' => '4', 171 'luhn' => TRUE 172 ), 173 'visa electron' => array 174 ( 175 'length' => '16', 176 'prefix' => '4(?:17500|91[37]|508|844)', 177 'luhn' => TRUE 178 ), 179 ); 132 public static function credit_card($number, $type = 'default') 133 { 134 // Remove all non-digit characters from the number 135 if (($number = preg_replace('/[^0-9]/', '', $number)) === '') 136 return FALSE; 137 138 $cards = Config::item('credit_cards'); 180 139 181 140 // Check card type … … 188 147 $length = strlen($number); 189 148 149 // Validate the card length by the card type 190 150 if ( ! preg_match('/\b'.$length.'\b/', $cards[$type]['length'])) 191 151 return FALSE; -
trunk/system/libraries/Calendar.php
r1616 r1670 17 17 18 18 // Start the calendar on Sunday by default 19 public $week_start = 3;19 public $week_start = 0; 20 20 21 21 // Event data
