cvs: pear /Validate/Validate ES.php FR.php UK.php US.php
| From: | Pierre-Alain Joye | Date: | Mon, 17 Feb 2003 04:25:35 +0000 |
| Subject: | cvs: pear /Validate/Validate ES.php FR.php UK.php US.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-8905@lists.php.net to get a copy of this message | ||
pajoye Sun Feb 16 23:25:35 2003 EDT
Modified files:
/pear/Validate/Validate ES.php FR.php UK.php US.php
Log:
Update interfaces, see release notes
Index: pear/Validate/Validate/ES.php
diff -u pear/Validate/Validate/ES.php:1.5 pear/Validate/Validate/ES.php:1.6
--- pear/Validate/Validate/ES.php:1.5 Sun Feb 16 12:28:29 2003
+++ pear/Validate/Validate/ES.php Sun Feb 16 23:25:35 2003
@@ -17,7 +17,7 @@
// | |
// +----------------------------------------------------------------------+
//
-// $Id: ES.php,v 1.5 2003/02/16 17:28:29 pajoye Exp $
+// $Id: ES.php,v 1.6 2003/02/17 04:25:35 pajoye Exp $
//
// Specific validation methods for data used in Spain
//
@@ -34,9 +34,6 @@
*/
function dni($dni)
{
- if(is_array($dni)){
- extract($dni);
- }
$letra = substr($dni, -1);
$number = substr($dni, 0, -1);
if (!Validate::string($number, VAL_NUM, 8, 8)) {
Index: pear/Validate/Validate/FR.php
diff -u pear/Validate/Validate/FR.php:1.6 pear/Validate/Validate/FR.php:1.7
--- pear/Validate/Validate/FR.php:1.6 Sun Feb 16 17:37:32 2003
+++ pear/Validate/Validate/FR.php Sun Feb 16 23:25:35 2003
@@ -18,7 +18,7 @@
// | |
// +----------------------------------------------------------------------+
//
-// $Id: FR.php,v 1.6 2003/02/16 22:37:32 pajoye Exp $
+// $Id: FR.php,v 1.7 2003/02/17 04:25:35 pajoye Exp $
//
// Specific validation methods for data used in France
//
@@ -42,13 +42,9 @@
* @return bool true if number is valid, otherwise false
* @author Pierre-Alain Joye <paj@pearfr.org>
*/
- function ssn($number)
+ function ssn($ssn)
{
- if( is_array($number) ) {
- extract( $number );
- }
-
- $str = strtolower(preg_replace('/[^0-9a-zA-Z]/','',$number));
+ $str = strtolower(preg_replace('/[^0-9a-zA-Z]/','',$ssn));
$regexp = "/^([12])(\d\d)(\d\d)(\d\d|2a|2b)(\d\d\d)(\d\d\d)(\d\d)$/";
@@ -110,19 +106,22 @@
* @return bool true if number is valid, otherwise false
* @author Pierre-Alain Joye <paj@pearfr.org>
*/
- function rib($aCodeBanque, $aCodeGuichet='', $aNoCompte='',
$aKey='')
+ function rib($rib)
{
- if(is_array($aCodeBanque)) {
- extract($aCodeBanque);
+ if(is_array($rib)) {
+ $codebanque=$codeguichet=$nocompte=$key='';
+ extract($rib);
+ } else {
+ return false;
}
$chars =
array('/[AJ]/','/[BKZ]/','/[CLT]/','/[DMU]/','/[ENV]/','/[FOW]/','/[GPX]/','/[HQY]/','/[IRZ]/');
$values =
array('1','2','3','4','5','6','7','8','9');
- $codebank = preg_replace('/[^0-9]/','',$aCodeBanque);
- $officecode = preg_replace('/[^0-9]/','',$aCodeGuichet);
- $account = preg_replace($chars,$values,$aNoCompte);
+ $codebank = preg_replace('/[^0-9]/','',$codebanque);
+ $officecode = preg_replace('/[^0-9]/','',$codeguichet);
+ $account = preg_replace($chars,$values,$nocompte);
+
- echo " ". $codebank . " " . $officecode . " " . $account .
"\n";
if (strlen($codebank)!=5){
return false;
}
@@ -135,17 +134,18 @@
return false;
}
- $l = $codebank.$officecode.$account;
- $a1 = (int)substr($l,0,7);
- $b1 = (int)substr($l,7,7);
- $c1 = (int)substr($l,15,7);
+ $l = $codebank.$officecode.$account;
+ $a1 = substr($l,0,7);
+ $b1 = substr($l,7,7);
+ $c1 = substr($l,14,7);
$key = 97 - Validate::_modf((62*$a1+34*$b1+3*$c1),97);
if ($key==0){
$key = 97;
}
- return $key==$aKey;
+
+ return $key==intval($key);
}
@@ -159,14 +159,11 @@
*/
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;
@@ -181,6 +178,7 @@
}
$somme += $match[$i];
}
+
return (($somme % 10) == 0);
}
@@ -226,8 +224,9 @@
$somme += $match[$i];
}
- return ( ($somme % 10) == 0 )
+ return ( ($somme % 10) == 0 );
}
+
}
?>
Index: pear/Validate/Validate/UK.php
diff -u pear/Validate/Validate/UK.php:1.2 pear/Validate/Validate/UK.php:1.3
--- pear/Validate/Validate/UK.php:1.2 Sun Feb 16 17:31:23 2003
+++ pear/Validate/Validate/UK.php Sun Feb 16 23:25:35 2003
@@ -17,7 +17,7 @@
// | |
// +----------------------------------------------------------------------+
//
-// $Id: UK.php,v 1.2 2003/02/16 22:31:23 pajoye Exp $
+// $Id: UK.php,v 1.3 2003/02/17 04:25:35 pajoye Exp $
//
// Specific validation methods for data used in UK
//
@@ -26,11 +26,8 @@
class Validate_UK
{
- function postcode($code){
- if(is_array($code)){
- extract($code);
- }
- return (ereg ('^[A-Z]{1, 2}[0-9]{1, 2}[A-Z]{0, 1} [0-9][A-Z]{2}$', $str));
+ function postcode($postcode){
+ return (ereg ('^[A-Z]{1, 2}[0-9]{1, 2}[A-Z]{0, 1} [0-9][A-Z]{2}$', $postcode));
}
}
?>
Index: pear/Validate/Validate/US.php
diff -u pear/Validate/Validate/US.php:1.8 pear/Validate/Validate/US.php:1.9
--- pear/Validate/Validate/US.php:1.8 Sun Feb 16 12:29:40 2003
+++ pear/Validate/Validate/US.php Sun Feb 16 23:25:35 2003
@@ -17,7 +17,7 @@
// | Tim Gallagher <timg@sunflowerroad.com> |
// +----------------------------------------------------------------------+
//
-// $Id: US.php,v 1.8 2003/02/16 17:29:40 pajoye Exp $
+// $Id: US.php,v 1.9 2003/02/17 04:25:35 pajoye Exp $
//
// Specific validation methods for data used in the United States
//
@@ -35,9 +35,6 @@
*/
function ssn($ssn, $high_groups = null)
{
- if(is_array($ssn)){
- extract($ssn);
- }
// remove any dashes, spaces, returns, tabs or slashes
$ssn = str_replace(array('-','/','
',"\t","\n"), '', $ssn);
@@ -98,10 +95,10 @@
* @param array $high_groups array of highest issued group numbers
* area number=>group number
*/
- function ssnCheck($area, $group, $serial, &$high_groups)
+ function ssnCheck($ssnCheck, $group, $serial, &$high_groups)
{
- if(is_array($area)){
- extract($area);
+ if(is_array($ssnCheck)){
+ extract($ssnCheck);
}
// perform trivial checks
// no field should contain all zeros
@@ -179,4 +176,4 @@
return $high_groups;
}
}
-?>
+?>
\ No newline at end of file