Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
3 lars 1
<?php
2
 
3
/**
4
 * Project:     SmartyValidate: Form Validator for the Smarty Template Engine
5
 * File:        validate_criteria.isEmail.php
6
 * Author:      Monte Ohrt <monte at newdigitalgroup dot com>
7
 *
8
 * This library is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU Lesser General Public
10
 * License as published by the Free Software Foundation; either
11
 * version 2.1 of the License, or (at your option) any later version.
12
 *
13
 * This library is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16
 * Lesser General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU Lesser General Public
19
 * License along with this library; if not, write to the Free Software
20
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21
 *
22
 * @link http://www.phpinsider.com/php/code/SmartyValidate/
23
 * @copyright 2001-2005 New Digital Group, Inc.
24
 * @author Monte Ohrt <monte at newdigitalgroup dot com>
25
 * @package SmartyValidate
26
 */
27
 
28
 /**
29
 * test if a value is a valid e-mail address
30
 *
31
 * @param string $value the value being tested
32
 * @param boolean $empty if field can be empty
33
 * @param array params validate parameter values
34
 * @param array formvars form var values
35
 */
36
 
37
function smarty_validate_criteria_isEmail($value, $empty, &$params, &$formvars) {
38
 
39
    if(strlen($value) == 0)
40
        return $empty;
41
 
42
    // in case value is several addresses separated by newlines
43
    $_addresses = preg_split('![\n\r]+!', $value);
44
 
45
    foreach($_addresses as $_address) {
46
		$_is_valid = !(preg_match('!@.*@|\.\.|\,|\;!', $_address) ||
47
	        !preg_match('!^.+\@(\[?)[a-zA-Z0-9\.\-]+\.([a-zA-Z]{2,6}|[0-9]{1,3})(\]?)$!', $_address));
48
 
49
        if(!$_is_valid)
50
            return false;
51
    }
52
    return true;
53
}
54
 
55
?>