本文整理汇总了PHP中Validator::IsEmail方法的典型用法代码示例。如果您正苦于以下问题:PHP Validator::IsEmail方法的具体用法?PHP Validator::IsEmail怎么用?PHP Validator::IsEmail使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Validator
的用法示例。
在下文中一共展示了Validator::IsEmail方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: xSaveSettingsAction
public function xSaveSettingsAction()
{
$this->request->defineParams(array('dnsZoneId' => array('type' => 'int'), 'axfrAllowedHosts' => array('type' => 'string'), 'allowedAccounts' => array('type' => 'string'), 'allowManageSystemRecords' => array('type' => 'int')));
$DBDNSZone = DBDNSZone::loadById($this->getParam('dnsZoneId'));
$this->user->getPermissions()->validate($DBDNSZone);
$Validator = new Validator();
if ($this->getParam('axfrAllowedHosts') != '') {
$hosts = explode(";", $this->getParam('axfrAllowedHosts'));
foreach ($hosts as $host) {
$host = trim($host);
if (!$Validator->IsIPAddress($host)) {
$errors['axfrAllowedHosts'] = sprintf(_("'%s' is not valid IP address"), $host);
}
}
}
if ($this->getParam('allowedAccounts')) {
$accounts = explode(";", $this->getParam('allowedAccounts'));
foreach ($accounts as $account) {
if (!$Validator->IsEmail($account)) {
$errors['allowedAccounts'] = sprintf(_("'%s' is not valid Email address"), $account);
}
}
}
if (count($errors) == 0) {
if ($this->getParam('axfrAllowedHosts') != $DBDNSZone->axfrAllowedHosts) {
$DBDNSZone->axfrAllowedHosts = $this->getParam('axfrAllowedHosts');
$DBDNSZone->isZoneConfigModified = 1;
}
$DBDNSZone->allowManageSystemRecords = $this->getParam('allowManageSystemRecords');
$DBDNSZone->allowedAccounts = $this->getParam('allowedAccounts');
$DBDNSZone->save();
$this->response->success('Changes have been saved. They will become active in few minutes.');
} else {
$this->response->failure();
$this->response->data(array('errors' => $errors));
}
}
示例2: xSaveAction
public function xSaveAction()
{
$validator = new Validator();
try {
if (!$validator->IsDomain($this->getParam('domainName'))) {
$err['domainName'] = _("Domain name is incorrect");
}
if (!$this->getParam('farmId')) {
$err['farmId'] = _("Farm required");
} else {
$dbFarm = DBFarm::LoadByID($this->getParam('farmId'));
$this->user->getPermissions()->validate($dbFarm);
}
if (!$this->getParam('farmRoleId')) {
$err['farmRoleId'] = _("Role required");
} else {
$dbFarmRole = DBFarmRole::LoadByID($this->getParam('farmRoleId'));
if ($dbFarmRole->FarmID != $dbFarm->ID) {
$err['farmRoleId'] = _("Role not found");
}
}
if (!$validator->IsEmail($this->getParam('serverAdmin'))) {
$err['serverAdmin'] = _("Server admin's email is incorrect or empty ");
}
if (!$this->getParam('documentRoot')) {
$err['documentRoot'] = _("Document root required");
}
if (!$this->getParam('logsDir')) {
$err['logsDir'] = _("Logs directory required");
}
if ($this->db->GetOne("SELECT id FROM apache_vhosts WHERE env_id=? AND `name` = ? AND id != ?", array($this->getEnvironmentId(), $this->getParam('domainName'), $this->getParam('vhostId')))) {
$err['domainName'] = "'{$this->getParam('domainName')}' virtualhost already exists";
}
} catch (Exception $e) {
$err[] = $e->getMessage();
}
if (count($err) == 0) {
$vHost = Scalr_Service_Apache_Vhost::init();
if ($this->getParam('vhostId')) {
$vHost->loadById($this->getParam('vhostId'));
$this->user->getPermissions()->validate($vHost);
} else {
$vHost->envId = $this->getEnvironmentId();
$vHost->clientId = $this->user->getAccountId();
}
$vHost->domainName = $this->getParam('domainName');
$vHost->isSslEnabled = $this->getParam('isSslEnabled') == 'on' ? true : false;
$vHost->farmId = $this->getParam('farmId');
$vHost->farmRoleId = $this->getParam('farmRoleId');
$vHost->httpdConf = $this->getParam("nonSslTemplate");
$vHost->templateOptions = serialize(array("document_root" => trim($this->getParam('documentRoot')), "logs_dir" => trim($this->getParam('logsDir')), "server_admin" => trim($this->getParam('serverAdmin')), "server_alias" => trim($this->getParam('serverAlias'))));
//SSL stuff
if ($vHost->isSslEnabled) {
if ($_FILES['certificate']['tmp_name']) {
$vHost->sslCert = file_get_contents($_FILES['certificate']['tmp_name']);
}
if ($_FILES['privateKey']['tmp_name']) {
$vHost->sslKey = file_get_contents($_FILES['privateKey']['tmp_name']);
}
if ($_FILES['certificateChain']['tmp_name']) {
$vHost->caCert = file_get_contents($_FILES['certificateChain']['tmp_name']);
}
$vHost->httpdConfSsl = $this->getParam("sslTemplate");
} else {
$vHost->sslCert = "";
$vHost->sslKey = "";
$vHost->caCert = "";
$vHost->httpdConfSsl = "";
}
$vHost->save();
$servers = $dbFarm->GetServersByFilter(array('status' => array(SERVER_STATUS::INIT, SERVER_STATUS::RUNNING)));
foreach ($servers as $dBServer) {
if ($dBServer->GetFarmRoleObject()->GetRoleObject()->hasBehavior(ROLE_BEHAVIORS::NGINX) || $dBServer->GetFarmRoleObject()->GetRoleObject()->hasBehavior(ROLE_BEHAVIORS::APACHE) && $dBServer->farmRoleId == $vHost->farmRoleId) {
$dBServer->SendMessage(new Scalr_Messaging_Msg_VhostReconfigure());
}
}
$this->response->success(_('Virtualhost successfully saved'));
} else {
$this->response->failure();
$this->response->data(array('errors' => $err));
}
}
示例3: testValidation
function testValidation()
{
$Validator = new Validator();
// IsEmpty
$empty_var = 'sdfsdfsdfs';
$empty_var2 = 'sdfsdfs';
$result = $Validator->IsNotEmpty($empty_var) && $Validator->IsNotEmpty($empty_var2);
$this->assertTrue($result, "Validator->IsEmpty returned true on non empty var");
$empty_var = '';
$empty_var2 = 0;
$result = $Validator->IsNotEmpty($empty_var) && $Validator->IsNotEmpty($empty_var2);
$this->assertFalse($result, "Validator->IsEmpty returned false on empty var");
// IsNumeric
$number1 = 0;
$number2 = -1;
$number3 = 1.2;
$result = $Validator->IsNumeric($number1) && $Validator->IsNumeric($number2) && $Validator->IsNumeric($number3);
$this->assertTrue($result, "Validator->IsNumeric returned true on number var");
$number1 = "1,2";
$number2 = "abc";
$result = $Validator->IsNumeric($number1) && $Validator->IsNumeric($number2);
$this->assertFalse($result, "Validator->IsNumeric returned false on non-number var");
// IsAlpha
$alpha = "Alpha";
$result = $Validator->IsAlpha($alpha);
$this->assertTrue($result, "Validator->IsAlpha returned true");
$alpha = "22323";
$result = $Validator->IsAlpha($alpha);
$this->assertFalse($result, "Validator->IsAlpha returned false");
// IsAlphaNumeric
$alpha = "Alpha12";
$result = $Validator->IsAlphaNumeric($alpha);
$this->assertTrue($result, "Validator->IsAlphaNumeric returned true");
$alpha = "22323 sdfsd fsdf s";
$result = $Validator->IsAlphaNumeric($alpha);
$this->assertFalse($result, "Validator->IsAlphaNumeric returned false");
// IsEmail
$email = "test@test.com";
$result = $Validator->IsEmail($email);
$this->assertTrue($result, "Validator->IsEmail returned true");
$email = "asdasdsdfs";
$result = $Validator->IsEmail($email);
$this->assertFalse($result, "Validator->IsEmail returned false");
// IsURL
$url = "http://webta.net";
$url2 = "webta.net";
$url3 = "www.webta.net";
$url4 = "http://www.webta.net";
$result = $Validator->IsURL($url) && $Validator->IsURL($url2) && $Validator->IsURL($url3) && $Validator->IsURL($url4);
$this->assertTrue($result, "Validator->IsURL returned true");
$url = "asdasdsdfs";
$url2 = "asdasdsdfs-222.1-";
$url3 = "-webta.com";
$result = $Validator->IsURL($url) && $Validator->IsURL($url2) && $Validator->IsURL($url3);
$this->assertFalse($result, "Validator->IsURL returned false");
// IsIPAddress
$ip = "10.100.10.10";
$result = $Validator->IsIPAddress($ip);
$this->assertTrue($result, "Validator->IsIPAddress returned true");
$ip = "288.1221.11.11";
$result = $Validator->IsIPAddress($ip);
$this->assertFalse($result, "Validator->IsIPAddress returned false");
// IsExternalIPAddress
$result = $Validator->IsExternalIPAddress("111.120.11.1");
$this->assertTrue($result, "Validator->IsExternalIPAddress returned true for '111.120.11.1'");
$result = $Validator->IsExternalIPAddress("192.168.1.1");
$this->assertFalse($result, "Validator->IsExternalIPAddress returned false for '192.168.1.1'");
$result = $Validator->IsExternalIPAddress("172.16.10.100");
$this->assertFalse($result, "Validator->IsExternalIPAddress returned false for '172.16.10.100'");
$result = $Validator->IsExternalIPAddress("172.32.10.100");
$this->assertTrue($result, "Validator->IsExternalIPAddress returned true for '172.32.10.100'");
// IsDomain
$result = $Validator->IsDomain("webta.net");
$this->assertTrue($result, "Validator->IsDomain returned true for webta.net");
$result = $Validator->IsDomain("c1.webta.net");
$this->assertTrue($result, "Validator->IsDomain returned true for c1.webta.net");
$result = $Validator->IsDomain("webta@net") || $Validator->IsDomain("webtanet");
$this->assertFalse($result, "Validator->IsDomain returned false for weird zones");
// MatchesPattern
$string = "abs_111";
$pattern = "/^[A-Za-z]{3}_[0-9]{3}\$/";
$result = $Validator->MatchesPattern($string, $pattern);
$this->assertTrue($result, "Validator->MatchesPattern returned true");
$pattern = "/^[A-Za-z]_[0-9]\$/";
$result = $Validator->MatchesPattern($string, $pattern);
$this->assertFalse($result, "Validator->MatchesPattern returned false");
// AreEqual
$s1 = "abc123";
$s2 = "abc123";
$result = $Validator->AreEqual($s1, $s2);
$this->assertTrue($result, "Validator->AreEqual returned true");
$s2 = "sdfsdfasd";
$result = $Validator->AreEqual($s1, $s2);
$this->assertFalse($result, "Validator->AreEqual returned false");
}
示例4: _IsEmail
public function _IsEmail($value)
{
return StrLen($value) == 0 || Validator::IsEmail($value);
}
示例5: IsEmailPlusDNS
/**
* Return true if $var is valid e-mail. RFC-compliant. Also checks in DNS.
*
* @param mixed $var
* @param string $name
* @param string $error
* @return bool
* @link http://www.linuxjournal.com/article/9585
*/
function IsEmailPlusDNS($var, $name = null, $error = null)
{
Validator::IsEmail($var, $name, $error, true);
}
示例6: array
<?
require_once('src/prepend.inc.php');
if ($_POST)
{
// get user information from database
$user = $db->GetRow("SELECT *
FROM users
WHERE id=? AND password = ?", array($_SESSION['userid'], $Crypto->Hash($post_pass)));
$Validator = new Validator();
if (!$Validator->IsEmail($post_email))
$err[] = sprintf(_("'%s' is not a valid email address"), $post_email);
if (!$user)
$err[] = _("Incorrect password");
if ($post_email == $user["email"])
$err[] = _("New email address cannot be the same as the old one");
// if user password is correct update info
if (count($err) == 0)
{
$db->Execute("UPDATE users SET nemail=? WHERE id=?", array($post_email, $_SESSION['userid']));
$code = base64_encode($Crypto->Hash("{$user['id']}::{$user['password']}::{$post_email}"));
$link = CONFIG::$SITE_URL."/client/login.php?id={$user['id']}&code={$code}&action=confirmeml";
$args = array("link" => $link, "client" => $user);
示例7: Validator
<?
if ($_SESSION['wizard']['check_user']['reg_type'] == 'newclient')
{
$_POST = array_map("trim", $_POST);
// Validate new client fields
$Validator = new Validator();
if (!$Validator->IsEmail($_POST["email"]))
$err[] = _("Invalid E-mail address");
//
if (!$Validator->IsNotEmpty($_POST["login"]))
$err[] = _("Login required");
if (!$Validator->IsNotEmpty($_POST["name"]))
$err[] = _("Name required");
if (!$Validator->IsNotEmpty($_POST["address"]))
$err[] = _("Address 1 required");
if (!$Validator->IsNotEmpty($_POST["city"]))
$err[] = _("Town/City required");
if (!$Validator->IsNotEmpty($_POST["state"]))
$err[] = _("State required");
if (!$Validator->IsNotEmpty($_POST["country"]))
$err[] = _("Country required");
示例8: xCreateAccountAction
public function xCreateAccountAction()
{
global $Mailer;
//FIXME:
if (!class_exists("Scalr_Billing")) {
exit;
}
$this->request->defineParams(array('name', 'org', 'email', 'password', 'agreeTerms', 'newBilling', 'country', 'phone', 'lastname', 'firstname', 'v', 'numServers'));
$Validator = new Validator();
if ($this->getParam('v') == 2) {
if (!$this->getParam('firstname')) {
$err['firstname'] = _("First name required");
}
if (!$this->getParam('lastname')) {
$err['lastname'] = _("Last name required");
}
if (!$this->getParam('org')) {
$err['org'] = _("Organization required");
}
$name = $this->getParam('firstname') . " " . $this->getParam('lastname');
} else {
if (!$this->getParam('name')) {
$err['name'] = _("Account name required");
}
$name = $this->getParam("name");
}
$password = $this->getParam('password');
if (!$password) {
$password = $this->getCrypto()->sault(10);
}
if (!$Validator->IsEmail($this->getParam('email'))) {
$err['email'] = _("Invalid E-mail address");
}
if (strlen($password) < 6) {
$err['password'] = _("Password should be longer than 6 chars");
}
// Check email
$DBEmailCheck = $this->db->GetOne("SELECT COUNT(*) FROM account_users WHERE email=?", array($this->getParam('email')));
if ($DBEmailCheck > 0) {
$err['email'] = _("E-mail already exists in database");
}
if (!$this->getParam('agreeTerms')) {
$err['agreeTerms'] = _("You need to agree with terms and conditions");
}
if (count($err) == 0) {
$account = Scalr_Account::init();
$account->name = $this->getParam("org") ? $this->getParam("org") : $name;
$account->status = Scalr_Account::STATUS_ACTIVE;
$account->save();
$account->createEnvironment("default", true);
$user = $account->createUser($this->getParam('email'), $password, Scalr_Account_User::TYPE_ACCOUNT_OWNER);
$user->fullname = $name;
$user->save();
if ($this->getParam('v') == 2) {
$user->setSetting('website.phone', $this->getParam('phone'));
$user->setSetting('website.country', $this->getParam('country'));
$user->setSetting('website.num_servers', $this->getParam('numServers'));
}
/**
* Limits
*/
try {
$billing = new Scalr_Billing();
$billing->loadByAccount($account);
$billing->createSubscription(Scalr_Billing::PACKAGE_SEED, "", "", "", "");
/*******************/
} catch (Exception $e) {
$account->delete();
header("Location: https://scalr.net/order/?error={$e->getMessage()}");
exit;
}
if ($_COOKIE['__utmz']) {
$gaParser = new Scalr_Service_GoogleAnalytics_Parser();
$clientSettings[CLIENT_SETTINGS::GA_CAMPAIGN_CONTENT] = $gaParser->campaignContent;
$clientSettings[CLIENT_SETTINGS::GA_CAMPAIGN_MEDIUM] = $gaParser->campaignMedium;
$clientSettings[CLIENT_SETTINGS::GA_CAMPAIGN_NAME] = $gaParser->campaignName;
$clientSettings[CLIENT_SETTINGS::GA_CAMPAIGN_SOURCE] = $gaParser->campaignSource;
$clientSettings[CLIENT_SETTINGS::GA_CAMPAIGN_TERM] = $gaParser->campaignTerm;
$clientSettings[CLIENT_SETTINGS::GA_FIRST_VISIT] = $gaParser->firstVisit;
$clientSettings[CLIENT_SETTINGS::GA_PREVIOUS_VISIT] = $gaParser->previousVisit;
$clientSettings[CLIENT_SETTINGS::GA_TIMES_VISITED] = $gaParser->timesVisited;
}
$clientSettings[CLIENT_SETTINGS::RSS_LOGIN] = $this->getParam('email');
$clientSettings[CLIENT_SETTINGS::RSS_PASSWORD] = $this->getCrypto()->sault(10);
foreach ($clientSettings as $k => $v) {
$account->setSetting($k, $v);
}
try {
$this->db->Execute("INSERT INTO default_records SELECT null, '{$account->id}', rtype, ttl, rpriority, rvalue, rkey FROM default_records WHERE clientid='0'");
} catch (Exception $e) {
}
$clientinfo = array('fullname' => $name, 'firstname' => $this->getParam('firstname') ? $this->getParam('firstname') : $name, 'email' => $this->getParam('email'), 'password' => $password);
$mailer = new PHPMailer();
$mailer->Subject = 'Welcome to the Scalr revolution!';
$mailer->From = 'yoda@scalr.com';
$mailer->FromName = 'Scalr';
$mailer->AddAddress($this->getParam('email'));
$mailer->IsHTML(true);
$mailer->Body = @file_get_contents(dirname(__FILE__) . '/../../../../templates/en_US/emails/welcome.html');
$mailer->Body = str_replace(array('{{FirstName}}', '{{Password}}'), array($clientinfo['firstname'], $clientinfo['password']), $mailer->Body);
//.........这里部分代码省略.........