| version 1.1, 2005/06/05 12:14:40 |
version 1.2, 2005/11/25 09:49:53 |
|
|
| <?php |
<?php |
| /* vim: set expandtab tabstop=4 shiftwidth=4: */ |
/* vim: set expandtab tabstop=4 shiftwidth=4: */ |
| // +----------------------------------------------------------------------+ |
// +----------------------------------------------------------------------+ |
| // | PHP Version 4 | |
// | Copyright (c) 1997-2005 Stefan Neufeind | |
| // +----------------------------------------------------------------------+ |
// +----------------------------------------------------------------------+ |
| // | Copyright (c) 1997-2003 The PHP Group | |
// | This source file is subject to the New BSD license, That is bundled | |
| |
// | with this package in the file LICENSE, and is available through | |
| |
// | the world-wide-web at | |
| |
// | http://www.opensource.org/licenses/bsd-license.php | |
| |
// | If you did not receive a copy of the new BSDlicense and are unable | |
| |
// | to obtain it through the world-wide-web, please send a note to | |
| |
// | pajoye@php.net so we can mail you a copy immediately. | |
| // +----------------------------------------------------------------------+ |
// +----------------------------------------------------------------------+ |
| // | This source file is subject to version 3.0 of the PHP license, | |
// | Author: Tomas V.V.Cox <cox@idecnet.com> | |
| // | that is bundled with this package in the file LICENSE, and is | |
// | Pierre-Alain Joye <pajoye@php.net> | |
| // | available through the world-wide-web at the following url: | |
|
| // | http://www.php.net/license/3_0.txt. | |
|
| // | If you did not receive a copy of the PHP license and are unable to | |
|
| // | obtain it through the world-wide-web, please send a note to | |
|
| // | license@php.net so we can mail you a copy immediately. | |
|
| // +----------------------------------------------------------------------+ |
|
| // | Author: Stefan Neufeind <pear.neufeind@speedpartner.de> | |
|
| // +----------------------------------------------------------------------+ |
// +----------------------------------------------------------------------+ |
| // |
// |
| // $Id$ |
/** |
| |
* Financial functions for validation and calculation |
| require_once('Validate/Finance/IBAN.php'); |
* |
| |
* @category Validate |
| |
* @package Validate_Finance |
| |
* @author Stefan Neufeind <pear.neufeind@speedpartner.de> |
| |
* @copyright 2005 The PHP Group |
| |
* @license http://www.opensource.org/licenses/bsd-license.php new BSD |
| |
* @version CVS: $Id$ |
| |
* @link http://pear.php.net/package/Validate_Finance |
| |
*/ |
| |
|
| /** |
/** |
| * Financial functions for validation and calculation |
* Requires the IBAN Finance Validate class |
| * |
|
| * @author Stefan Neufeind <neufeind@speedpartner.de> |
|
| * @since PHP 4.1.0 |
|
| */ |
*/ |
| class Validate_Finance { |
require_once 'Validate/Finance/IBAN.php'; |
| |
|
| |
/** |
| |
* Financial functions for validation and calculation |
| |
* |
| |
* This class provides methods to validate: |
| |
* - IBAN (international bankaccount number) |
| |
* - Euro banknote id |
| |
* |
| |
* @category Validate |
| |
* @package Validate_Finance |
| |
* @author Stefan Neufeind <neufeind@speedpartner.de> |
| |
* @copyright 1997-2005 Stefan Neufeind |
| |
* @license http://www.opensource.org/licenses/bsd-license.php new BSD |
| |
* @version Release: @package_version@ |
| |
* @link http://pear.php.net/package/Validate_Finance |
| |
*/ |
| |
class Validate_Finance |
| |
{ |
| /** |
/** |
| * Validation of an IBAN (international bankaccount number) |
* Validation of an IBAN (international bankaccount number) |
| * |
* |
| Line 36 class Validate_Finance { |
|
| Line 57 class Validate_Finance { |
|
| * @since 0.1 |
* @since 0.1 |
| * @return boolean true if IBAN is okay |
* @return boolean true if IBAN is okay |
| */ |
*/ |
| function iban($iban='') |
function iban($iban = '') |
| { |
{ |
| return Validate_Finance_IBAN::validate($iban); |
return Validate_Finance_IBAN::validate($iban); |
| } // end func iban |
} // end func iban |
| Line 49 class Validate_Finance { |
|
| Line 70 class Validate_Finance { |
|
| * @since 0.1 |
* @since 0.1 |
| * @return boolean true if Euro banknote id is okay |
* @return boolean true if Euro banknote id is okay |
| */ |
*/ |
| function banknoteEuro($banknote='') |
function banknoteEuro($banknote = '') |
| { |
{ |
| $euro_countrycode = array('J', 'K', 'L', 'M', 'N', 'P', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'); |
$euro_countrycode = array('J', 'K', 'L', 'M', 'N', 'P', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'); |
| |
|
| Line 59 class Validate_Finance { |
|
| Line 80 class Validate_Finance { |
|
| if (!in_array($banknote[0], $euro_countrycode)) { |
if (!in_array($banknote[0], $euro_countrycode)) { |
| return false; |
return false; |
| } |
} |
| |
|
| // build checksum, preparation |
// build checksum, preparation |
| $banknote_replace_chars = range('A', 'Z'); |
$banknote_replace_chars = range('A', 'Z'); |
| foreach (range(10,35) as $tempvalue) { |
foreach (range(10, 35) as $tempvalue) { |
| $banknote_replace_values[]=strval($tempvalue); |
$banknote_replace_values[] = strval($tempvalue); |
| } |
} |
| |
|
| // build checksum, substitute and calc |
// build checksum, substitute and calc |
| $tempbanknote = str_replace($banknote_replace_chars, $banknote_replace_values, substr($banknote,0,-1)); |
$tempbanknote = str_replace($banknote_replace_chars, $banknote_replace_values, substr($banknote, 0, -1)); |
| $tempcheckvalue = 0; |
$tempcheckvalue = 0; |
| for ($strcounter = 0; $strcounter < strlen($tempbanknote); $strcounter++) { |
for ($strcounter = 0; $strcounter < strlen($tempbanknote); $strcounter++) { |
| $tempcheckvalue += intval($tempbanknote[$strcounter]); |
$tempcheckvalue += intval($tempbanknote[$strcounter]); |