本文整理汇总了PHP中is_valid_email_address函数的典型用法代码示例。如果您正苦于以下问题:PHP is_valid_email_address函数的具体用法?PHP is_valid_email_address怎么用?PHP is_valid_email_address使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_valid_email_address函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pCheckAddress
function pCheckAddress($sAddress, $sMailserver)
{
if (!is_valid_email_address($sAddress)) {
return CA_ERROR_ADDRESS_INVALID;
}
$fp = @fsockopen($sMailserver, 25, $errno, $errstr, $this->nConnectTimeout);
if (!$fp) {
return CA_ERROR_CONNECT;
}
$sResp = $this->send_command($fp, "HELO " . $this->sHostname);
$sCode = $this->extract_return_code($sResp);
if ($sCode != '220') {
$this->close($fp);
return CA_ERROR_UNKOWN;
}
$sResp = $this->send_command($fp, "MAIL FROM: <" . $this->sFrom . ">");
$sCode = $this->extract_return_code($sResp);
if ($sCode != '250') {
$this->close($fp);
return CA_ERROR_UNKOWN;
}
$sResp = $this->send_command($fp, "RCPT TO: <" . $sAddress . ">");
$sCode = $this->extract_return_code($sResp);
if (strlen($sCode) == 3 && substr($sCode, 0, 1) == '4') {
$this->close($fp);
return CA_ERROR_TEMPORARY;
} else {
if ($sCode == '553' && $sCode == '550') {
$this->close($fp);
return CA_ERROR_USER_UNKOWN;
} else {
if ($sCode == '250') {
$this->close($fp);
return CA_OK;
}
}
}
$this->close($fp);
return CA_ERROR_UNKOWN;
}
示例2: run
/**
* Standard modular run function.
*
* @param array A map of parameters.
* @return tempcode The result of execution.
*/
function run($map)
{
require_lang('newsletter');
require_lang('javascript');
$newsletter_id = array_key_exists('param', $map) ? intval($map['param']) : db_get_first_id();
$_newsletter_title = $GLOBALS['SITE_DB']->query_value_null_ok('newsletters', 'title', array('id' => $newsletter_id));
if (is_null($_newsletter_title)) {
return paragraph(do_lang_tempcode('MISSING_RESOURCE'));
}
$newsletter_title = get_translated_text($_newsletter_title);
$address = post_param('address' . strval($newsletter_id), '');
if ($address != '') {
require_code('newsletter');
require_code('type_validation');
if (!is_valid_email_address($address)) {
$msg = do_template('INLINE_WIP_MESSAGE', array('MESSAGE' => do_lang_tempcode('INVALID_EMAIL_ADDRESS')));
return do_template('BLOCK_MAIN_NEWSLETTER_SIGNUP', array('URL' => get_self_url(), 'MSG' => $msg));
}
if (!array_key_exists('path', $map)) {
$map['path'] = 'uploads/website_specific/signup.txt';
}
require_code('character_sets');
$password = basic_newsletter_join($address, 4, NULL, !file_exists(get_custom_file_base() . '/' . $map['path']), $newsletter_id, post_param('firstname' . strval($newsletter_id), ''), post_param('lastname' . strval($newsletter_id), ''));
if ($password == '') {
return do_template('INLINE_WIP_MESSAGE', array('MESSAGE' => do_lang_tempcode('NEWSLETTER_THIS_ALSO')));
}
if ($password == do_lang('NA')) {
$manage_url = build_url(array('page' => 'newsletter', 'email' => $address), get_module_zone('newsletter'));
return do_template('INLINE_WIP_MESSAGE', array('MESSAGE' => do_lang_tempcode('ALREADY_EMAIL_ADDRESS', escape_html($manage_url->evaluate()))));
}
require_code('mail');
if (file_exists(get_custom_file_base() . '/' . $map['path'])) {
$url = (url_is_local($map['path']) ? get_custom_base_url() . '/' : '') . $map['path'];
mail_wrap(array_key_exists('subject', $map) ? $map['subject'] : do_lang('WELCOME'), convert_to_internal_encoding(http_download_file($url)), array($address), array_key_exists('to', $map) ? $map['to'] : '', '', '', 3, NULL, false, NULL, true);
}
return do_template('BLOCK_MAIN_NEWSLETTER_SIGNUP_DONE', array('_GUID' => '9953c83685df4970de8f23fcd5dd15bb', 'NEWSLETTER_TITLE' => $newsletter_title, 'NID' => strval($newsletter_id), 'PASSWORD' => $password));
} else {
return do_template('BLOCK_MAIN_NEWSLETTER_SIGNUP', array('NEWSLETTER_TITLE' => $newsletter_title, 'NID' => strval($newsletter_id), 'URL' => get_self_url()));
}
}
示例3: checkEmail
public function checkEmail($email)
{
if(!$email) {
$this->errors = 'Email is required<br/>';
return false;
}
if(!is_valid_email_address($email)) {
$this->errors = 'Incorrect email<br/>';
return false;
}
if($this->isEmailExists($email)) {
$this->errors = 'This is email is already exists<br/>';
return false;
}
return true;
}
示例4: isset
//Preprocessing
if ($error == false) {
//set here the template to process
$tplname = 'activation';
//load language specific variables
require_once $stylepath . '/' . $tplname . '.inc.php';
$email = isset($_REQUEST['email']) ? $_REQUEST['email'] : '';
$code = isset($_REQUEST['code']) ? $_REQUEST['code'] : '';
tpl_set_var('email', htmlspecialchars($email, ENT_COMPAT, 'UTF-8'));
tpl_set_var('code', htmlspecialchars($code, ENT_COMPAT, 'UTF-8'));
tpl_set_var('message_start', '<!--');
tpl_set_var('message_end', '-->');
tpl_set_var('message', '');
tpl_set_var('email_message', '');
if (isset($_REQUEST['submit'])) {
$email_not_ok = is_valid_email_address($email) ? false : true;
if ($email_not_ok == true) {
tpl_set_var('email_message', $message_email_notok);
} else {
$rs = sql("SELECT `user_id` `id`, `activation_code` `code` FROM `user` WHERE `email`='&1'", $email);
if ($r = sql_fetch_array($rs)) {
if ($r['code'] == $code && $code != '') {
// ok, account aktivieren
sql("UPDATE `user` SET `is_active_flag`=1, `activation_code`='' WHERE `user_id`='&1'", $r['id']);
$tplname = 'activation_confirm';
} else {
tpl_set_var('message_start', '');
tpl_set_var('message_end', '');
tpl_set_var('message', $message_no_success);
}
} else {
示例5: array
#
# run the tests
#
$totals = array(
'all' => 0,
'public' => 0,
'strict' => 0,
);
foreach ($tests as $k => $v){
$tests[$k]['expected'] = $v['valid'] ? 1 : 0;
$tests[$k]['result_public'] = is_valid_email_address($v['address']) ? 1 : 0;
$tests[$k]['result_strict'] = is_valid_email_address($v['address'], array('public_internet' => false)) ? 1 : 0;
$totals['all']++;
$totals['public'] += ($tests[$k]['result_public'] == $tests[$k]['expected']) ? 1 : 0;
$totals['strict'] += ($tests[$k]['result_strict'] == $tests[$k]['expected']) ? 1 : 0;
}
function is_valid($x){
return $x ? 'Valid' : 'Invalid';
}
function show_escapes($s){
return str_replace(array("\r","\n"," ","\0"), array("&#13;","&#10;"," ","&#0;"), $s);
}
?>
示例6: test_fail_php_type_check
/**
* Type-check the specified parameter (giving an error if the type checking fails) [just value against type]
*
* @param ID_TEXT The parameter type
* @param string The functions name (used in error message)
* @param string The parameter name (used in error message)
* @param mixed The parameters value (cannot be null)
* @param boolean Whether we just echo errors instead of exiting
*/
function test_fail_php_type_check($type, $function_name, $name, $value, $echo = false)
{
$null_allowed = $type[0] == '?';
$false_allowed = $type[0] == '~';
$_type = $null_allowed || $false_allowed ? substr($type, 1) : $type;
if ($value === false && !$false_allowed && !in_array($_type, array('mixed', 'boolean'))) {
fatal_exit(do_lang_tempcode('UNALLOWED_NULL', escape_html($name), escape_html($function_name), array('false')));
}
if (is_null($value) && !$null_allowed) {
fatal_exit(do_lang_tempcode('UNALLOWED_NULL', escape_html($name), escape_html($function_name), array('NULL')));
}
if ($_type == 'mixed') {
return;
}
switch ($_type) {
case 'integer':
if (!is_integer($value) && (!is_float($value) || strval(intval(round($value))) != strval($value))) {
_fail_php_type_check($type, $function_name, $name, $value, $echo);
}
break;
case 'UINTEGER':
if (!is_integer($value) && (!is_float($value) || strval(intval(round($value))) != strval($value)) || $value < 0) {
_fail_php_type_check($type, $function_name, $name, $value, $echo);
}
break;
case 'resource':
if (!is_resource($value)) {
_fail_php_type_check($type, $function_name, $name, $value, $echo);
}
break;
case 'object':
if (!is_object($value)) {
_fail_php_type_check($type, $function_name, $name, $value, $echo);
}
break;
case 'tempcode':
if (!is_object($value) || !is_a($value, 'ocp_tempcode')) {
_fail_php_type_check($type, $function_name, $name, $value, $echo);
}
break;
case 'REAL':
case 'float':
if (!is_float($value)) {
_fail_php_type_check($type, $function_name, $name, $value, $echo);
}
break;
case 'boolean':
if (!is_bool($value)) {
_fail_php_type_check($type, $function_name, $name, $value, $echo);
}
break;
case 'list':
if (!is_array($value)) {
_fail_php_type_check($type, $function_name, $name, $value, $echo);
}
break;
case 'map':
if (!is_array($value)) {
_fail_php_type_check($type, $function_name, $name, $value, $echo);
}
break;
case 'array':
if (!is_array($value)) {
_fail_php_type_check($type, $function_name, $name, $value, $echo);
}
break;
case 'string':
if (!is_string($value)) {
_fail_php_type_check($type, $function_name, $name, $value, $echo);
}
break;
case 'PATH':
if (!is_string($value)) {
_fail_php_type_check($type, $function_name, $name, $value, $echo);
}
break;
case 'MD5':
if (!is_string($value) || strlen($value) > 33) {
_fail_php_type_check($type, $function_name, $name, $value, $echo);
}
break;
case 'EMAIL':
if (!is_string($value) || is_valid_email_address($value)) {
_fail_php_type_check($type, $function_name, $name, $value, $echo);
}
break;
case 'URLPATH':
if (!is_string($value) || strlen($value) > 127) {
_fail_php_type_check($type, $function_name, $name, $value, $echo);
}
break;
//.........这里部分代码省略.........
示例7: get_by_email
static function get_by_email($email)
{
$email = trim(strtolower($email));
if (!is_valid_email_address($email)) {
return false;
}
$db = Get::db('songwork');
$db->query("SELECT * FROM persons WHERE LOWER(email)='" . $db->escape($email) . "' LIMIT 1");
return $db->num_rows() == 0 ? false : new Person($db->next_record());
}
示例8: is_valid_email
/**
* Test email based on RFC 822/2822/5322 Email Parser
* @copyright Cal Henderson <cal@iamcal.com>
*
* @param string email address
* @return bool
*/
function is_valid_email($email, $options = array())
{
// IDN conversion
$email = idn_encode($email);
// wrapped by default function as used since long time in phpwcms
return is_valid_email_address($email, $options);
}
示例9: ocf_make_member
//.........这里部分代码省略.........
shuffle($codes);
$results = array();
foreach ($codes as $code) {
if (strpos($code, 'ocp_fanatic') !== false) {
continue;
}
$count = $GLOBALS['FORUM_DB']->query_value_null_ok_full('SELECT SUM(m_cache_num_posts) FROM ' . $GLOBALS['FORUM_DB']->get_table_prefix() . 'f_members WHERE ' . db_string_equal_to('m_avatar_url', find_theme_image($code, false, true)));
if (is_null($count)) {
$count = 0;
}
$results[$code] = $count;
}
@asort($results);
// @'d as type checker fails for some odd reason
$found_avatars = array_keys($results);
$avatar_url = find_theme_image(array_shift($found_avatars), true, true);
}
if (is_null($avatar_url)) {
$GLOBALS['SITE_DB']->query_delete('theme_images', array('id' => 'ocf_default_avatars/default', 'path' => ''));
// In case failure cached, gets very confusing
$avatar_url = find_theme_image('ocf_default_avatars/default', true, true);
if (is_null($avatar_url)) {
$avatar_url = '';
}
}
}
}
if ($check_correctness) {
if (!in_array($password_compatibility_scheme, array('ldap', 'httpauth'))) {
ocf_check_name_valid($username, NULL, $password_compatibility_scheme == '' ? $password : NULL);
}
if (!function_exists('has_actual_page_access') || !has_actual_page_access(get_member(), 'admin_ocf_join')) {
require_code('type_validation');
if (!is_valid_email_address($email_address) && $email_address != '') {
warn_exit(do_lang_tempcode('_INVALID_EMAIL_ADDRESS', escape_html($email_address)));
}
}
}
require_code('ocf_members');
require_code('ocf_groups');
if (is_null($last_submit_time)) {
$last_submit_time = time();
}
if (is_null($join_time)) {
$join_time = time();
}
if (is_null($last_visit_time)) {
$last_visit_time = time();
}
if (is_null($primary_group)) {
$primary_group = get_first_default_group();
// This is members
}
if (is_null($secondary_groups)) {
$secondary_groups = ocf_get_all_default_groups(false);
}
foreach ($secondary_groups as $_g_id => $g_id) {
if ($g_id == $primary_group) {
unset($secondary_groups[$_g_id]);
}
}
if (is_null($ip_address)) {
$ip_address = get_ip_address();
}
if ($password_compatibility_scheme == '' && get_value('no_password_hashing') === '1') {
$password_compatibility_scheme = 'plain';
示例10: isset
//form load setting
$display_all_countries = $_POST['allcountries'];
$username = $_POST['username'];
$password = $_POST['password1'];
$password2 = $_POST['password2'];
$email = $_POST['email'];
$country = $_POST['country'];
$tos = isset($_POST['TOS']) ? $_POST['TOS'] == 'ON' : false;
if (isset($_POST['submit'])) {
//try to register
//validate the entered data
$email_not_ok = !is_valid_email_address($email);
$username_not_ok = mb_ereg_match(regex_username, $username) ? false : true;
if ($username_not_ok == false) {
// username should not be formatted like an email-address
$username_not_ok = is_valid_email_address($username);
}
$password_not_ok = mb_ereg_match(regex_password, $password) ? false : true;
$password_diffs = $password != $password2;
//check if email is in the database
$rs = sql("SELECT `username` FROM `user` WHERE `email`='&1'", $email);
if (mysql_num_rows($rs) > 0) {
$email_exists = true;
} else {
$email_exists = false;
}
//check if username is in the database
$rs = sql("SELECT `username` FROM `user` WHERE `username`='&1'", $username);
if (mysql_num_rows($rs) > 0) {
$username_exists = true;
} else {
示例11: setNewEMail
function setNewEMail($value)
{
if ($value !== null) {
if (!is_valid_email_address($value)) {
return false;
}
if (user::existEMail($value)) {
return false;
}
}
return $this->reUser->setValue('new_email', $value);
}
示例12: tpl_set_var
//load language specific variables
require_once $stylepath . '/' . $tplname . '.inc.php';
tpl_set_var('new_email', '');
tpl_set_var('message', '');
tpl_set_var('email_message', '');
tpl_set_var('code_message', '');
tpl_set_var('change_email', $change_email);
tpl_set_var('reset', $reset);
tpl_set_var('getcode', $get_code);
if (isset($_POST['submit_getcode']) || isset($_POST['submit_changeemail'])) {
$new_email = $_POST['newemail'];
tpl_set_var('new_email', htmlspecialchars($new_email, ENT_COMPAT, 'UTF-8'));
//validate the email
$email_exists = false;
$new_email_not_ok = false;
if (!is_valid_email_address($new_email)) {
$new_email_not_ok = true;
tpl_set_var('email_message', $error_email_not_ok);
} else {
//prüfen, ob email schon in der Datenbank vorhanden
$rs = sql("SELECT `username` FROM `user` WHERE `email`='&1'", $new_email);
if (mysql_num_rows($rs) > 0) {
$email_exists = true;
tpl_set_var('email_message', $error_email_exists);
}
}
if (!$email_exists && !$new_email_not_ok) {
if (isset($_POST['submit_getcode'])) {
//send the secure code via email and store the new email in the database
$secure_code = uniqid('');
//code in DB eintragen
示例13: test
function test($email)
{
echo "<tr><td>" . HtmlEntities($email) . "</td>";
echo "<td>" . (is_valid_email_address($email) ? 'Yes' : 'No') . "</td></tr>";
}
示例14: newsletter_maintenance
/**
* The actualiser for newsletter subscription maintenance (adding, updating, deleting).
*
* @return tempcode The UI
*/
function newsletter_maintenance()
{
require_code('type_validation');
breadcrumb_set_parents(array(array('_SELF:_SELF:misc', get_option('newsletter_title'))));
$title = get_page_title('_NEWSLETTER_JOIN', true, array(escape_html(get_option('newsletter_title'))));
// Add
$email = trim(post_param('email'));
$password = trim(post_param('password'));
$forename = trim(post_param('forename'));
$surname = trim(post_param('surname'));
if ($password != trim(post_param('password_confirm'))) {
warn_exit(make_string_tempcode(escape_html(do_lang('PASSWORD_MISMATCH'))));
}
$lang = post_param('lang', user_lang());
if (!is_valid_email_address($email) || $password == '') {
return warn_screen($title, do_lang_tempcode('IMPROPERLY_FILLED_IN'));
}
$message = do_lang_tempcode('NEWSLETTER_UPDATE');
$old_confirm = $GLOBALS['SITE_DB']->query_value_null_ok('newsletter', 'code_confirm', array('email' => $email));
if (is_null($old_confirm)) {
$newsletters = $GLOBALS['SITE_DB']->query_select('newsletters', array('id'));
$found_level = false;
foreach ($newsletters as $newsletter) {
if (get_option('interest_levels') == '1') {
$level = post_param_integer('level' . strval($newsletter['id']));
} else {
$level = post_param_integer('level' . strval($newsletter['id']), 0);
if ($level == 1) {
$level = 4;
}
}
if ($level != 0) {
$found_level = true;
}
}
if (!$found_level) {
warn_exit(do_lang_tempcode('NOT_NEWSLETTER_SUBSCRIBER'));
}
$code_confirm = mt_rand(1, 32000);
$salt = produce_salt();
$GLOBALS['SITE_DB']->query_insert('newsletter', array('n_forename' => $forename, 'n_surname' => $surname, 'join_time' => time(), 'language' => $lang, 'email' => $email, 'code_confirm' => $code_confirm, 'pass_salt' => $salt, 'the_password' => md5($password . $salt)));
$this->send_confirmation($email, $code_confirm, NULL, $forename, $surname);
$message = do_lang_tempcode('NEWSLETTER_CONFIRM', escape_html($email));
} elseif ($old_confirm != 0) {
$this->send_confirmation($email, $old_confirm, NULL, $forename, $surname);
return inform_screen($title, do_lang_tempcode('NEWSLETTER_CONFIRM', escape_html($email)));
}
// Change/make settings
$old_password = $GLOBALS['SITE_DB']->query_value('newsletter', 'the_password', array('email' => $email));
$old_salt = $GLOBALS['SITE_DB']->query_value('newsletter', 'pass_salt', array('email' => $email));
if (!has_specific_permission(get_member(), 'change_newsletter_subscriptions') && $old_password != '' && $old_password != md5($password . $old_salt)) {
$_reset_url = build_url(array('page' => '_SELF', 'type' => 'reset', 'email' => $email), '_SELF');
$reset_url = $_reset_url->evaluate();
return warn_screen($title, do_lang_tempcode('NEWSLETTER_PASSWORD_RESET', escape_html($reset_url)));
} else {
$newsletters = $GLOBALS['SITE_DB']->query_select('newsletters', array('id'));
foreach ($newsletters as $newsletter) {
if (get_option('interest_levels') == '1') {
$level = post_param_integer('level' . strval($newsletter['id']));
} else {
$level = post_param_integer('level' . strval($newsletter['id']), 0);
if ($level == 1) {
$level = 4;
}
}
// First we delete
$GLOBALS['SITE_DB']->query_delete('newsletter_subscribe', array('newsletter_id' => $newsletter['id'], 'email' => $email), '', 1);
if ($level != 0) {
$GLOBALS['SITE_DB']->query_insert('newsletter_subscribe', array('newsletter_id' => $newsletter['id'], 'email' => $email, 'the_level' => $level));
}
// Update name
$GLOBALS['SITE_DB']->query_update('newsletter', array('n_forename' => $forename, 'n_surname' => $surname), array('email' => $email), '', 1);
}
}
return inform_screen($title, $message);
}
示例15: mb_ereg_match
$longitude = -$longitude;
}
} else {
$longitude = null;
$lon_h_not_ok = false;
$lon_min_not_ok = false;
}
$lon_not_ok = $lon_min_not_ok || $lon_h_not_ok;
$lat_not_ok = $lat_min_not_ok || $lat_h_not_ok;
//check if username is in the database
$username_exists = false;
$username_not_ok = mb_ereg_match(regex_username, $username) ? false : true;
if ($username_not_ok == false) {
// username should not be formatted like an email-address
// exception: $username == $email
$username_not_ok = is_valid_email_address($username) ? true : false;
}
if ($username_not_ok) {
tpl_set_var('username_message', $error_username_not_ok);
} else {
if ($username != $usr['username']) {
$sql = "SELECT `username` FROM `user` WHERE `username`=:1";
$db->multiVariableQuery($sql, $username);
if ($db->rowCount() > 0) {
$username_exists = true;
tpl_set_var('username_message', $error_username_exists);
}
}
}
if ($radius != '') {
$radius = $radius + 0;