<?php
class Validate
{
/**
* Copyright (c) 2005-2006 Major Computing, Inc.
* Author: Pedram Nimreezi
* Email: <hide@address.com>
* Website: <http://www.majorcomputing.com>
* Written: circa 2003
*
* Full LGPL License: <http://www.rapidframework.com/lgpl.txt>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA\
*
* @brief Validate is a very simple class to validate general
* American money, time, phone, date, etc.
*
* I know there is a Validate(1) class but if it only validates
* strings it should be called alpha, upper, lower, etc.
* They can be added to here, The author of Validate.class.php
* is welcome to do so, or take this code and put it in his class,
* Sharing is Caring ;-)
*
*** USER ENCAPSULATION INSTRUCTIONS
*
* $v = new Validate;
* var_dump($v->dateValidate("4/22/32"));
* var_dump($v->time12Validate("11:42 am"));
* var_dump($v->urlValidate("http://moo.com"));
* var_dump($v->emailValidate("hide@address.com"));
* var_dump($v->safeValidate("john"));
* var_dump($v->moneyValidate("$29,128,312.64"));
* var_dump($v->zipValidate("90060-1923"));
* var_dump($v->phoneValidate("923-060-1923"));
*
*/
function emailValidate($email)
{
// works to determine if an email address is valid
return (bool) ereg('^([a-zA-Z0-9_\-]) (\.([a-zA-Z0-9_\-]) )*@((\[(((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5])))\.(((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5])))\.(((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5])))\.(((([0-1])?([0-9])?[0-9])|(2[0-4][0-9])|(2[0-5][0-5]))\]))|((([a-zA-Z0-9]) (([\-]) ([a-zA-Z0-9]) )*\.) ([a-zA-Z]) (([\-]) ([a-zA-Z0-9]) )*))$',$email);
}
function urlValidate($url)
{
// works to determine if a url is valid
return (bool) ereg('^(http|https|ftp)\://[a-zA-Z0-9\-\.] \.[a-zA-Z]{2,3}(:[a-zA-Z0-9]*)?/?([a-zA-Z0-9\-\._\?\,\'/\\\