cvs: pear /Validate package_IS.xml /Validate/Validate IS.php

From: Date: Wed, 16 Nov 2005 20:45:36 +0000
Subject: cvs: pear /Validate package_IS.xml /Validate/Validate IS.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-36333@lists.php.net to get a copy of this message
bjori Wed Nov 16 15:45:36 2005 EDT Modified files: /pear/Validate package_IS.xml /pear/Validate/Validate IS.php Log: Added extra parameter, $url, to postalCode() Prepared address() to take $strong and $url parameters http://cvs.php.net/diff.php/pear/Validate/package_IS.xml?r1=1.7&r2=1.8&ty=u Index: pear/Validate/package_IS.xml diff -u pear/Validate/package_IS.xml:1.7 pear/Validate/package_IS.xml:1.8 --- pear/Validate/package_IS.xml:1.7 Wed Nov 16 12:45:38 2005 +++ pear/Validate/package_IS.xml Wed Nov 16 15:45:35 2005 @@ -28,6 +28,21 @@ <state>alpha</state> <date>2005-11-04</date> <notes> +- Validate_IS::ssn() + - Now uses ctype_digit() to check for all numbers + - Fixed bug in "var tala" calculation +- Validate_IS::postalCode() + - Allow user defined data dir for Validate_IS::postalCode() + - $strong mode is now default false - BC BREAK! + - Now use retrived data even when data file is read-only (in $strong mode) + - Writes retrived data no matter when data file was last changed (in $strong mode) + - Deleted bogus entrys in the data file + - Fixed live data file (thanks to antab, arnar@8.is) + - Added extra parameter, $url, which allows user defined data file +- Validate_IS::address() + - Initial commit +- Fixed testcases when run under E_STRICT +- Added ext/ctype as dependency - Bump the dep to PHP 4.2+ - Ctype is now a required dep. </notes> http://cvs.php.net/diff.php/pear/Validate/Validate/IS.php?r1=1.9&r2=1.10&ty=u Index: pear/Validate/Validate/IS.php diff -u pear/Validate/Validate/IS.php:1.9 pear/Validate/Validate/IS.php:1.10 --- pear/Validate/Validate/IS.php:1.9 Wed Nov 16 11:51:53 2005 +++ pear/Validate/Validate/IS.php Wed Nov 16 15:45:35 2005 @@ -23,7 +23,7 @@ * @author Hannes Magnússon <bjori@php.net> * @copyright 1997-2005 Hannes Magnússon * @license http://www.opensource.org/licenses/bsd-license.php new BSD - * @version CVS: $Id: IS.php,v 1.9 2005/11/16 16:51:53 bjori Exp $ + * @version CVS: $Id: IS.php,v 1.10 2005/11/16 20:45:35 bjori Exp $ */ /** @@ -133,23 +133,30 @@ * @param int the postcode to be validated * @param bool optional; check against the official list (default off) * @param string optional; /path/to/data/dir/ + * @param string optional; http://domain.tld/path/to/live/data/file.txt * @return bool */ - function postalCode($postcode, $strong = false, $dataDir = '@DATADIR@/Validate_IS') + function postalCode($postcode, $strong = false, $dataDir = '', $url = '') { /* Sanity check, all Icelandic postalcodes are between 101 and 950 */ if ($postcode <= 100 || $postcode > 950) { return false; } + if(!$dataDir) { + $dataDir = '@DATADIR@/Validate_IS'; + } + $file = is_readable($dataDir.'/IS_postcodes.txt') ? $dataDir.'/IS_postcodes.txt' : '@DATADIR@/Validate_IS/IS_postcodes.txt'; $postCodes = array(); if ($strong) { - $url = 'http://www.postur.is/gogn/Gotuskra/postnumer.txt'; - + if(!$url) { + $url = "http://www.postur.is/gogn/Gotuskra/postnumer.txt"; + } + $fp = fopen($url, 'r'); if ($fp) { while (false !== ($data = fgetcsv($fp, 128, ';'))) { @@ -184,14 +191,21 @@ * If postcode is provided, check if address exists in that area. * * NOTE: does *NOT* work completly, yet. + * NOTE: $strong is *NOT* implimented, yet. * - * @param string $address - * @param int $postcode Optional; check if address exists in that area - * @param string $dataDir Optional; /path/to/data/dir/ + * @param string $address Address to validate + * @param int $postcode Optional; check if address exists in that area + * @param bool $strong Optional; Live check + * @param string $dataDir Optional; /path/to/data/dir/ + * @param string $url Optional; http://domain.tld/path/to/data/file.txt * @return bool */ - function address($address, $postcode = null, $dataDir = '@DATADIR@/Validate_IS') + function address($address, $postcode = null, $strong = false, + $dataDir = '', $url = '') { + if(!$dataDir) { + $dataDir = '@DATADIR@/Validate_IS'; + } if (!is_null($postcode)) { /* Shall we dare to call postalCode staticly? */ if (isset($this)) {

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