cvs: pear /Validate/Validate US.php
| From: | Brent Cook | Date: | Wed, 19 Jun 2002 15:41:42 +0000 |
| Subject: | cvs: pear /Validate/Validate US.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-4691@lists.php.net to get a copy of this message | ||
busterb Wed Jun 19 11:41:42 2002 EDT
Modified files:
/pear/Validate/Validate US.php
Log:
fixed error message typo and improved file handling in function ssnGetHighGroups
Index: pear/Validate/Validate/US.php
diff -u pear/Validate/Validate/US.php:1.3 pear/Validate/Validate/US.php:1.4
--- pear/Validate/Validate/US.php:1.3 Mon Jun 10 12:37:54 2002
+++ pear/Validate/Validate/US.php Wed Jun 19 11:41:42 2002
@@ -17,11 +17,13 @@
// | Tim Gallagher <timg@sunflowerroad.com> |
// +----------------------------------------------------------------------+
//
-// $Id: US.php,v 1.3 2002/06/10 16:37:54 cox Exp $
+// $Id: US.php,v 1.4 2002/06/19 15:41:42 busterb Exp $
//
// Specific validation methods for data used in the United States
//
+require_once 'PEAR.php';
+require_once 'File.php';
class Validate_US
{
@@ -129,24 +131,21 @@
* from the Social Security Administration website. This info can be
* cached for performance (and to lessen the load on the SSA website)
*
- * @param string $source The SSA highgroup.htm file
+ * @param string $uri Path to the SSA highgroup.htm file
* @param bool $is_text Take the $highgroup_htm param as directly the contents
* @returns array
*/
- function ssnGetHighGroups($source = 'http://www.ssa.gov/foia/highgroup.htm',
+ function ssnGetHighGroups($uri = 'http://www.ssa.gov/foia/highgroup.htm',
$is_text = false)
{
if (!$is_text) {
- if (!$fd = @fopen($source, 'r')) {
- trigger_error("Could not access to the SSA High Groups file",
E_USER_WARNING);
- return array();
+ $source = File::readAll($uri);
+ if (PEAR::isError($source)) {
+ return PEAR::raiseError('Could not access the SSA High Groups file: ' .
$uri);
+ return $source;
}
- $source = '';
- while ($data = fread($fd, 2048)) {
- $source .= $data;
- }
- fclose($fd);
}
+
$search = array ("'<script[^>]*?>.*?</script>'si", //
Strip javascript
"'<[\/\!]*?[^<>]*?>'si", //
Strip html tags
"'([\r\n])[\s]+'", // Strip white
space
@@ -167,4 +166,4 @@
return $high_groups;
}
}
-?>
\ No newline at end of file
+?>