mirror of
https://github.com/newnius/YAO-portal.git
synced 2025-12-15 09:36:43 +00:00
init & add agent & add job
This commit is contained in:
36
util4p/Validator.class.php
Executable file
36
util4p/Validator.class.php
Executable file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
class Validator
|
||||
{
|
||||
/**/
|
||||
public static function isIP($str)
|
||||
{
|
||||
$ip = explode('.', $str);
|
||||
for ($i = 0; $i < count($ip); $i++) {
|
||||
if ($ip[$i] < 0 || $ip[$i] > 255) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return preg_match('/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$/', $str);
|
||||
}
|
||||
|
||||
/**/
|
||||
public static function isEmail($str)
|
||||
{
|
||||
if ($str === null) {
|
||||
return false;
|
||||
}
|
||||
return preg_match("/^([0-9A-Za-z\\-_\\.]+)@([0-9a-z]+\\.[a-z]{2,3}(\\.[a-z]{2})?)$/i", $str) === 1;
|
||||
}
|
||||
|
||||
|
||||
/*TODO*/
|
||||
public static function isURL($url)
|
||||
{
|
||||
if (is_null($url) || empty($url)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user