Библиотека для cis, online, cms1
This commit is contained in:
commit
3c2e614d87
269 changed files with 39854 additions and 0 deletions
30
core/validator/rule/email.php
Normal file
30
core/validator/rule/email.php
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
require_once 'abstract.php';
|
||||
|
||||
/**
|
||||
* Ïðîâåðêà ôîðìàòà ýëåêòðîííîé ïî÷òû
|
||||
*/
|
||||
class Rule_Email extends Rule_Abstract
|
||||
{
|
||||
public function getErrorMsg()
|
||||
{
|
||||
return "Íåâåðíûé ôîðìàò ýëåêòðîííîé ïî÷òû";
|
||||
}
|
||||
|
||||
public function isValid(Collection $container, $status = null)
|
||||
{
|
||||
$user = '[a-zA-Z0-9_\-\.\+\^!#\$%&*+\/\=\?\|\{\}~\']+';
|
||||
$doIsValid = '(?:[a-zA-Z0-9]|[a-zA-Z0-9][a-zA-Z0-9\-]*[a-zA-Z0-9]\.?)+';
|
||||
$ipv4 = '[0-9]{1,3}(\.[0-9]{1,3}){3}';
|
||||
$ipv6 = '[0-9a-fA-F]{1,4}(\:[0-9a-fA-F]{1,4}){7}';
|
||||
|
||||
$emails = explode(",", $container->get($this->field));
|
||||
foreach ($emails as $email) {
|
||||
// if (! preg_match("/^$user@($doIsValid|(\[($ipv4|$ipv6)\]))$/", $email)) return false;
|
||||
if (! filter_var($email, FILTER_VALIDATE_EMAIL)) return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue