Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 0.5.5

Bug #2394 Validate_US needs updating
Submitted: 2004-09-24 21:05 UTC
From: memeyou at memeyou dot net Assigned: busterb
Status: Closed Package: Validate_US
PHP Version: 4.3.8 OS: Linux
Roadmaps: 0.5.3    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 49 - 20 = ?

 
 [2004-09-24 21:05 UTC] memeyou at memeyou dot net
Description: ------------ Validate/US.php (Validate_US), by default, checks an old url and expects to parse html. The content it points to is now not html. I have a patch to fix this. Reproduce code: --------------- Validate_US::ssn($ssn); Expected result: ---------------- TRUE Actual result: -------------- NULL

Comments

 [2004-10-17 01:55 UTC] busterb
Can you attach your patch? I see that the new info is plain text, which makes things easier. Push it up, or I will write a new ssnGetHighGroups method.
 [2004-10-19 01:54 UTC] memeyou at memeyou dot net
Aloha! Here is what I fixed to get it working fine on both cached and live-download highland retreival. I counldn't figure out any other way to send the patch. --- US-20040924.php 2004-09-24 08:50:11.525186544 -1000 +++ US.php 2004-09-24 10:27:27.808936552 -1000 @@ -46,7 +46,7 @@ $group = intval(substr($ssn, 3, 2)); $serial = intval(substr($ssn, 5, 4)); - if (is_null($high_groups)) { + if (!$high_groups) { $high_groups = Validate_US::ssnGetHighGroups(); } return Validate_US::ssnCheck($area, $group, $serial, $high_groups); @@ -95,10 +95,10 @@ * @param array $high_groups array of highest issued group numbers * area number=>group number */ - function ssnCheck($ssnCheck, $group, $serial, $high_groups) + function ssnCheck($area, $group, $serial, $high_groups) { - if(is_array($ssnCheck)){ - extract($ssnCheck); + if(is_array($area)){ + extract($area); } // perform trivial checks // no field should contain all zeros @@ -141,7 +141,7 @@ * @param bool $is_text Take the $highgroup_htm param as directly the contents * @returns array */ - function ssnGetHighGroups($uri = 'http://www.ssa.gov/foia/highgroup.htm', + function ssnGetHighGroups($uri = 'http://www.ssa.gov/employer/highgroup.txt', $is_text = false) { if (!$is_text) { @@ -156,24 +156,19 @@ fclose($fd); } - $search = array ("'<script[^>]*?>.*?</script>'si", // Strip javascript - "'<[\/\!]*? [^<>]*?>'si", // Strip html tags - "'([\r\n]) [\s]+'", // Strip white space - "'\*'si"); - - $replace = array ('','','\\1',''); - - $lines = explode("\n", preg_replace($search, $replace, $source)); + $lines = explode("\n",ereg_replace("[^\n0-9]*",'',$source)); $high_groups = array(); foreach ($lines as $line) { - $line = trim($line); - if ((strlen($line) == 3) && is_numeric($line)) { - $current_group = $line; - } elseif ((strlen($line) == 2) && is_numeric($line)) { - $high_groups[$current_group] = $line; + if(ereg("^([0-9]{3})([0-9]{2})([0-9]{3}) ([0-9]{2})([0-9]{3})([0-9]{2})([0-9]{3})([0-9]{2})([0-9] {3})([0-9]{2})([0-9]{3})([0-9]{2})$",$line,$grouping)) { + $high_groups[$grouping[1]] = $grouping[2]; + $high_groups[$grouping[3]] = $grouping[4]; + $high_groups[$grouping[5]] = $grouping[6]; + $high_groups[$grouping[7]] = $grouping[8]; + $high_groups[$grouping[9]] = $grouping[10]; + $high_groups[$grouping[11]] = $grouping[12]; } } return $high_groups; } } -?> \ No newline at end of file +?>
 [2004-10-20 01:49 UTC] busterb
This bug has been fixed in CVS. In case this was a documentation problem, the fix will show up at the end of next Sunday (CET) on pear.php.net. In case this was a pear.php.net website problem, the change will show up on the website in short time. Thank you for the report, and for helping us make PEAR better. I have applied your patch, thanks! I'm not sure when the next release will be (there's a lot of other stuff in this package) but its in CVS now.