PEAR is archived and read-only

This mirror preserves historical PEAR package releases and metadata so existing references remain available.

Home » Validate » Validate_US » Bug #2394

Validate_US needs updating

Details

Submitted2004-09-24 21:05 UTC
Frommemeyou at memeyou dot net
Assignedbusterb
StatusClosed
PackageValidate_US
PHP Version4.3.8
OSLinux
Roadmaps0.5.3

Comments

[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

[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
+?>