-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdata.php
63 lines (54 loc) · 1.48 KB
/
data.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
/**
Data validation plugin for the PHP Fat-Free Framework
The contents of this file are subject to the terms of the GNU General
Public License Version 3.0. You may not use this file except in
compliance with the license. Any of the license terms and conditions
can be waived if you get permission from the copyright holder.
Copyright (c) 2009-2012 F3::Factory
Bong Cosca <bong.cosca@yahoo.com>
@package Data
@version 2.0.12
**/
//! Data validators
class Data extends Base {
/**
Return TRUE if string is a valid e-mail address with option to check
if DNS MX records exist for the domain
@return boolean
@param $text string
@param $mx boolean
@public
**/
static function validEmail($text,$mx=FALSE) {
return is_string(filter_var($text,FILTER_VALIDATE_EMAIL)) &&
(!$mx ||
extension_loaded('sockets') &&
@fsockopen(substr($text,
strpos($text,'@')+1),25,$errno,$errstr,5) ||
getmxrr(substr($text,strrpos($text,'@')+1),$hosts));
}
/**
Return TRUE if string is a valid URL
@return boolean
@param $text string
@public
**/
static function validURL($text) {
return is_string(filter_var($text,FILTER_VALIDATE_URL));
}
/**
Return TRUE if string and generated CAPTCHA image are identical
@return boolean
@param $text string
@public
**/
static function validCaptcha($text) {
$result=FALSE;
if (isset($_SESSION['captcha'])) {
$result=($text==$_SESSION['captcha']);
unset($_SESSION['captcha']);
}
return $result;
}
}