cvs: pear /Validate/Validate FR.php

From: Date: Sun, 16 Feb 2003 17:30:01 +0000
Subject: cvs: pear /Validate/Validate FR.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-8891@lists.php.net to get a copy of this message
pajoye Sun Feb 16 12:30:01 2003 EDT Modified files: /pear/Validate/Validate FR.php Log: tabs->spaces Index: pear/Validate/Validate/FR.php diff -u pear/Validate/Validate/FR.php:1.4 pear/Validate/Validate/FR.php:1.5 --- pear/Validate/Validate/FR.php:1.4 Sun Feb 16 12:21:34 2003 +++ pear/Validate/Validate/FR.php Sun Feb 16 12:30:01 2003 @@ -18,7 +18,7 @@ // | | // +----------------------------------------------------------------------+ // -// $Id: FR.php,v 1.4 2003/02/16 17:21:34 pajoye Exp $ +// $Id: FR.php,v 1.5 2003/02/16 17:30:01 pajoye Exp $ // // Specific validation methods for data used in France // @@ -112,9 +112,9 @@ */ function rib($aCodeBanque, $aCodeGuichet, $aNoCompte, $aKey) { - if(is_array($aCodeBanque)) { - extract($aCodeBanque); - } + if(is_array($aCodeBanque)) { + extract($aCodeBanque); + } $chars = array('/[AJ]/','/[BKZ]/','/[CLT]/','/[DMU]/','/[ENV]/','/[FOW]/','/[GPX]/','/[HQY]/','/[IRZ]/'); $values = array('1','2','3','4','5','6','7','8','9'); @@ -157,32 +157,32 @@ * @return bool true if number is valid, otherwise false * @author Damien Seguy, added by Pierre-Alain Joye <paj@pearfr.org> */ - function siren($siren) - { - if( is_array($siren) ) { + function siren($siren) + { + if( is_array($siren) ) { extract( $number ); } - $siren = str_replace(' ', '', $siren); - if (!preg_match("/^(\d)(\d)(\d)(\d)(\d)(\d)(\d)(\d)(\d)$/", - $siren, $match)) { - return false; - } else { - $match[2] *= 2; - $match[4] *= 2; - $match[6] *= 2; - $match[8] *= 2; - $somme = 0; - - for ($i = 1; $i<count($match); $i++) { - if ($match[$i] > 9) { - $a = (int)substr($match[$i], 0, 1); - $b = (int)substr($match[$i], 1, 1); - $match[$i] = $a + $b; - } - $somme += $match[$i]; - } - return (($somme % 10) == 0); - } + $siren = str_replace(' ', '', $siren); + if (!preg_match("/^(\d)(\d)(\d)(\d)(\d)(\d)(\d)(\d)(\d)$/", + $siren, $match)) { + return false; + } else { + $match[2] *= 2; + $match[4] *= 2; + $match[6] *= 2; + $match[8] *= 2; + $somme = 0; + + for ($i = 1; $i<count($match); $i++) { + if ($match[$i] > 9) { + $a = (int)substr($match[$i], 0, 1); + $b = (int)substr($match[$i], 1, 1); + $match[$i] = $a + $b; + } + $somme += $match[$i]; + } + return (($somme % 10) == 0); + } /** * Validate a french SIRET number @@ -192,42 +192,42 @@ * @return bool true if number is valid, otherwise false * @author Damien Seguy, added by Pierre-Alain Joye <paj@pearfr.org> */ - function siret($siret) - { - $siret = str_replace(' ', '', $siret); - if ( - !preg_match( - "/^(\d)(\d)(\d)(\d)(\d)(\d)(\d)(\d)(\d)(\d)(\d)(\d)(\d)(\d)$/", - $siret, $match - ) - ) { - return false; - } else { - if( !Validate_FR::siren(implode('', array_slice($match, 1,9))) ) { - return false; - } - } - $match[1] *= 2; - $match[3] *= 2; - $match[5] *= 2; - $match[7] *= 2; - $match[9] *= 2; - $match[11] *= 2; - $match[13] *= 2; - - $somme = 0; - - for ($i = 1; $i<count($match); $i++) { - if ($match[$i] > 9) { - $a = (int)substr($match[$i], 0, 1); - $b = (int)substr($match[$i], 1, 1); - $match[$i] = $a + $b; - } - $somme += $match[$i]; - } + function siret($siret) + { + $siret = str_replace(' ', '', $siret); + if ( + !preg_match( + "/^(\d)(\d)(\d)(\d)(\d)(\d)(\d)(\d)(\d)(\d)(\d)(\d)(\d)(\d)$/", + $siret, $match + ) + ) { + return false; + } else { + if( !Validate_FR::siren(implode('', array_slice($match, 1,9))) ) { + return false; + } + } + $match[1] *= 2; + $match[3] *= 2; + $match[5] *= 2; + $match[7] *= 2; + $match[9] *= 2; + $match[11] *= 2; + $match[13] *= 2; + + $somme = 0; + + for ($i = 1; $i<count($match); $i++) { + if ($match[$i] > 9) { + $a = (int)substr($match[$i], 0, 1); + $b = (int)substr($match[$i], 1, 1); + $match[$i] = $a + $b; + } + $somme += $match[$i]; + } - return ( ($somme % 10) == 0 ) + return ( ($somme % 10) == 0 ) - } + } } ?>

« previous php.pear.cvs (#8891) next »