Re: cvs: pear /Validate/Validate US.php

From: Date: Wed, 19 Jun 2002 16:02:08 +0000
Subject: Re: cvs: pear /Validate/Validate US.php
References: 1  Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-4692@lists.php.net to get a copy of this message
Please do not include the File dependency for the class for doing such little work, makes no sense. Also take in mind that Validate methods are really static functions and should be used in the same way normal PHP functions works (return bool and trigger an error on internal error). Prepend the "@" operator if you don't want to show the error). IMHO this path should be reverted. Tomas V.V.Cox El mié, 19-06-2002 a las 17:41, Brent Cook escribió: > 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 > +?> > > > > -- > PEAR CVS Mailing List (http://pear.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

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