| // +----------------------------------------------------------------------+ // // $Id$ require_once('Validate/Finance/IBAN.php'); /** * Financial functions for validation and calculation * * @author Stefan Neufeind * @since PHP 4.1.0 */ class Validate_Finance { /** * Validation of an IBAN (international bankaccount number) * * @param string $iban IBAN to be validated * @access public * @since 0.1 * @return boolean true if IBAN is okay */ function iban($iban='') { return Validate_Finance_IBAN::validate($iban); } // end func iban /** * Validation of a Euro banknote id * * @param string $banknote Euro banknote id to be validated * @access public * @since 0.1 * @return boolean true if Euro banknote id is okay */ function banknoteEuro($banknote='') { $euro_countrycode = array('J', 'K', 'L', 'M', 'N', 'P', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'); if (strlen($banknote) != 12) { return false; } if (!in_array($banknote[0], $euro_countrycode)) { return false; } // build checksum, preparation $banknote_replace_chars = range('A', 'Z'); foreach (range(10,35) as $tempvalue) { $banknote_replace_values[]=strval($tempvalue); } // build checksum, substitute and calc $tempbanknote = str_replace($banknote_replace_chars, $banknote_replace_values, substr($banknote,0,-1)); $tempcheckvalue = 0; for ($strcounter = 0; $strcounter < strlen($tempbanknote); $strcounter++) { $tempcheckvalue += intval($tempbanknote[$strcounter]); } $tempcheckvalue %= 9; // modulo 9 $tempcheckvalue = 8 - $tempcheckvalue; return (intval($banknote[strlen($banknote)-1]) == $tempcheckvalue); } // end func banknoteEuro } // end class Validate_Finance ?>