bludit/bl-kernel/helpers/valid.class.php

37 lines
720 B
PHP
Raw Permalink Normal View History

2015-08-04 05:10:12 +02:00
<?php defined('BLUDIT') or die('Bludit CMS.');
class Valid {
public static function ip($ip)
{
return filter_var($ip, FILTER_VALIDATE_IP);
}
2015-10-20 05:14:28 +02:00
// Returns the email filtered or FALSE if the filter fails.
2015-08-04 05:10:12 +02:00
public static function email($email)
{
return filter_var($email, FILTER_VALIDATE_EMAIL);
}
public static function int($int)
{
if($int === 0) {
return true;
}
elseif(filter_var($int, FILTER_VALIDATE_INT) === false ) {
return false;
}
return true;
}
2015-08-26 05:42:32 +02:00
// Thanks, http://php.net/manual/en/function.checkdate.php#113205
public static function date($date, $format='Y-m-d H:i:s')
{
$tmp = DateTime::createFromFormat($format, $date);
2015-09-10 04:33:31 +02:00
return $tmp && $tmp->format($format)==$date;
2015-08-26 05:42:32 +02:00
}
}