当前位置: 首页>>代码示例>>PHP>>正文


PHP is_valid_email函数代码示例

本文整理汇总了PHP中is_valid_email函数的典型用法代码示例。如果您正苦于以下问题:PHP is_valid_email函数的具体用法?PHP is_valid_email怎么用?PHP is_valid_email使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了is_valid_email函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: smarty_function_user_link

/**
 * Display user name with a link to users profile
 * 
 * - user - User - We create link for this User
 * - short - boolean - Use short display name
 * 
 * @param array $params
 * @param Smarty $smarty
 * @return string
 */
function smarty_function_user_link($params, &$smarty)
{
    static $cache = array();
    $user = array_var($params, 'user');
    $short = array_var($params, 'short', false);
    // User instance
    if (instance_of($user, 'User')) {
        if (!isset($cache[$user->getId()])) {
            //BOF:mod 20121030
            /*
            //EOF:mod 20121030
                    $cache[$user->getId()] = '<a href="' . $user->getViewUrl() . '" class="user_link">' . clean($user->getDisplayName($short)) . '</a>';
            //BOF:mod 20121030
            */
            $cache[$user->getId()] = '<a href="' . $user->getViewUrl() . '" class="user_link">' . clean($user->getDisplayName()) . '</a>';
            //EOF:mod 20121030
        }
        // if
        return $cache[$user->getId()];
        // AnonymousUser instance
    } elseif (instance_of($user, 'AnonymousUser') && trim($user->getName()) && is_valid_email($user->getEmail())) {
        return '<a href="mailto:' . $user->getEmail() . '" class="anonymous_user_link">' . clean($user->getName()) . '</a>';
        // Unknown user
    } else {
        return '<span class="unknow_user_link unknown_object_link">' . clean(lang('Unknown user')) . '</span>';
    }
    // if
}
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:38,代码来源:function.user_link.php

示例2: authenticate

 /**
  * Authenticate user
  * 
  * Returns TRUE on success or error message on failure
  *
  * @param string $email
  * @param string $password
  * @return boolean
  */
 function authenticate($email, $password)
 {
     if (empty($email) || trim($password) == '') {
         return 'Email address and password values are required';
     }
     // if
     if (!is_valid_email($email)) {
         return 'Invalid email address format';
     }
     // if
     $user = $this->db->execute_one('SELECT role_id, password FROM ' . TABLE_PREFIX . 'users WHERE email = ?', array($email));
     if (is_array($user)) {
         if (!$this->checkUserPassword($password, $user['password'])) {
             return 'Invalid password';
         }
         // if
     } else {
         return "Invalid email address. User does not exist";
     }
     // if
     if (!$user['role_id']) {
         return 'Authenticated user is not administrator';
     }
     // if
     // Check administration access
     if ($this->isUserAdministrator($user['role_id'])) {
         return true;
     } else {
         return 'Authenticated user is not administrator';
     }
     // if
 }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:41,代码来源:UpgradeUtility.class.php

示例3: get_email

function get_email($query_result)
{
    $possible_emails = array();
    $valid_emails = array();
    if (!empty($query_result[0]["mail"][0])) {
        $valid_emails[] = $query_result[0]["mail"][0];
    }
    if (is_array($query_result[0]["proxyaddresses"])) {
        foreach ($query_result[0]["proxyaddresses"] as $key => $val) {
            if (is_numeric($key)) {
                $email = strtolower($val);
                if (substr($email, 0, 5) == "smtp:") {
                    $possible_emails[] = substr($email, 5);
                } else {
                    $possible_emails[] = $email;
                }
            }
        }
    }
    foreach ($possible_emails as $key => $val) {
        if (is_valid_email($val) && !in_array($val, $valid_emails)) {
            $valid_emails[] = $val;
        }
    }
    return $valid_emails;
}
开发者ID:brightskylee,项目名称:swe,代码行数:26,代码来源:mu_ldap_helper.php

示例4: smarty_function_mtcommentauthorlink

function smarty_function_mtcommentauthorlink($args, &$ctx)
{
    $mt = MT::get_instance();
    $comment = $ctx->stash('comment');
    $name = $comment->comment_author;
    if (!$name && isset($args['default_name'])) {
        $name = $args['default_name'];
    }
    $name or $name = $mt->translate("Anonymous");
    require_once "MTUtil.php";
    $name = encode_html($name);
    $email = $comment->comment_email;
    $url = $comment->comment_url;
    if (isset($args['show_email'])) {
        $show_email = $args['show_email'];
    } else {
        $show_email = 0;
    }
    if (isset($args['show_url'])) {
        $show_url = $args['show_url'];
    } else {
        $show_url = 1;
    }
    $target = isset($args['new_window']) && $args['new_window'] ? ' target="_blank"' : '';
    _comment_follow($args, $ctx);
    $cmntr = $ctx->stash('commenter');
    if (!isset($cmntr) && isset($comment->comment_commenter_id)) {
        $cmntr = $comment->commenter();
    }
    if ($cmntr) {
        $name = isset($cmntr->author_nickname) ? encode_html($cmntr->author_nickname) : $name;
        if ($cmntr->author_url) {
            return sprintf('<a title="%s" href="%s"%s>%s</a>', encode_html($cmntr->author_url), encode_html($cmntr->author_url), $target, $name);
        }
        return $name;
    } elseif ($show_url && $url) {
        require_once "function.mtcgipath.php";
        $cgi_path = smarty_function_mtcgipath($args, $ctx);
        $comment_script = $ctx->mt->config('CommentScript');
        $name = strip_tags($name);
        $url = encode_html(strip_tags($url));
        if ($comment->comment_id && (!isset($args['no_redirect']) || isset($args['no_redirect']) && !$args['no_redirect']) && (!isset($args['nofollowfy']) || isset($args['nofollowfy']) && !$args['nofollowfy'])) {
            return sprintf('<a title="%s" href="%s%s?__mode=red;id=%d"%s>%s</a>', $url, $cgi_path, $comment_script, $comment->comment_id, $target, $name);
        } else {
            return sprintf('<a title="%s" href="%s"%s>%s</a>', $url, $url, $target, $name);
        }
    } elseif ($show_email && $email && is_valid_email($email)) {
        $email = encode_html(strip_tags($email));
        $str = 'mailto:' . $email;
        if ($args['spam_protect']) {
            $str = spam_protect($str);
        }
        return sprintf('<a href="%s">%s</a>', $str, $name);
    }
    return $name;
}
开发者ID:benvanstaveren,项目名称:movabletype,代码行数:56,代码来源:function.mtcommentauthorlink.php

示例5: test_email

 /**
  * Test Mailer
  *
  * @param void
  * @return null
  */
 function test_email()
 {
     $email_data = $this->request->post('email');
     if (!is_array($email_data)) {
         $email_data = array('recipient' => $this->logged_user->getEmail(), 'subject' => lang('activeCollab - test email'), 'message' => lang("<p>Hi,</p>\n\n<p>Purpose of this message is to test whether activeCollab can send emails or not</p>"));
     }
     // if
     $this->smarty->assign('email_data', $email_data);
     if ($this->request->isSubmitted()) {
         $errors = new ValidationErrors();
         $subject = trim(array_var($email_data, 'subject'));
         $message = trim(array_var($email_data, 'message'));
         $recipient = trim(array_var($email_data, 'recipient'));
         if ($subject == '') {
             $errors->addError(lang('Message subject is required'), 'subject');
         }
         // if
         if ($message == '') {
             $errors->addError(lang('Message body is required'), 'message');
         }
         // if
         if (is_valid_email($recipient)) {
             $recipient_name = null;
             $recipient_email = $recipient;
         } else {
             if (($pos = strpos($recipient, '<')) !== false && str_ends_with($recipient, '>')) {
                 $recipient_name = trim(substr($recipient, 0, $pos));
                 $recipient_email = trim(substr($recipient, $pos + 1, strlen($recipient) - $pos - 2));
                 if (!is_valid_email($recipient_email)) {
                     $errors->addError(lang('Invalid email address'), 'recipient');
                 }
                 // if
             } else {
                 $errors->addError(lang('Invalid recipient'), 'recipient');
             }
             // if
         }
         // if
         if ($errors->hasErrors()) {
             $this->smarty->assign('errors', $errors);
             $this->render();
         }
         // if
         $mailer =& ApplicationMailer::mailer();
         $email_message = new Swift_Message($subject, $message, 'text/html', EMAIL_ENCODING, EMAIL_CHARSET);
         if ($mailer->send($email_message, new Swift_Address($recipient_email, $recipient_name), $this->logged_user->getEmail())) {
             flash_success('Test email has been sent, check your inbox');
         } else {
             flash_error('Failed to send out test email');
         }
         // if
         $this->redirectTo('admin_tools_test_email');
     }
     // if
 }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:61,代码来源:SystemToolsController.class.php

示例6: send_email

function send_email($email, $subject, $texte, $from = "", $headers = "")
{
    global $hebergeur, $queue_mails, $flag_wordwrap, $os_serveur;
    include_lcm('inc_filters');
    if (!$from) {
        $email_envoi = read_meta("email_sender");
        $from = is_valid_email($email_envoi) ? $email_envoi : $email;
    }
    if (!is_valid_email($email)) {
        return false;
    }
    lcm_debug("mail ({$email}): {$subject}");
    $charset = read_meta('charset');
    $headers = "From: {$from}\n" . "MIME-Version: 1.0\n" . "Content-Type: text/plain; charset={$charset}\n" . "Content-Transfer-Encoding: 8bit\n{$headers}";
    $texte = filtrer_entites($texte);
    $subject = filtrer_entites($subject);
    // fignoler ce qui peut l'etre...
    if ($charset != 'utf-8') {
        $texte = str_replace("&#8217;", "'", $texte);
        $subject = str_replace("&#8217;", "'", $subject);
    }
    // encoder le sujet si possible selon la RFC
    if ($GLOBALS['flag_multibyte'] and @mb_internal_encoding($charset)) {
        $subject = mb_encode_mimeheader($subject, $charset, 'Q');
    }
    if ($flag_wordwrap) {
        $texte = wordwrap($texte);
    }
    if ($os_serveur == 'windows') {
        $texte = preg_replace("/\r*\n/", "\r\n", $texte);
        $headers = preg_replace("/\r*\n/", "\r\n", $headers);
    }
    switch ($hebergeur) {
        case 'lycos':
            $queue_mails[] = array('email' => $email, 'sujet' => $subject, 'texte' => $texte, 'headers' => $headers);
            return true;
        case 'free':
            return false;
        case 'online':
            if (!($ret = @email('webmaster', $email, $subject, $texte))) {
                lcm_log("ERROR mail: (online) returned false");
            }
            return $ret;
        default:
            if (!($ret = @mail($email, $subject, $texte, $headers))) {
                lcm_log("ERROR mail: (default) returned false");
            }
            return $ret;
    }
}
开发者ID:nyimbi,项目名称:legalcase,代码行数:50,代码来源:inc_mail.php

示例7: validate_submission_data

/**
 * Validate the submission data by ensure required data exists and is in the 
 * desired format.
 * 
 * @param $data - data array to validate based on expectations
 * @return bool - whether or not the data validated
 */
function validate_submission_data($data)
{
    // name must not be empty
    if (empty($data['name'])) {
        return false;
    }
    // email must not be empty, nor invalid
    if (empty($data['email']) || !is_valid_email($data['email'])) {
        return false;
    }
    // comment must not be empty
    if (empty($data['comment'])) {
        return false;
    }
    return true;
}
开发者ID:Craftpeak,项目名称:Academy-Understanding-PHP,代码行数:23,代码来源:form-submit.php

示例8: get_user_by_email

 public function get_user_by_email($email, $force_refresh = FALSE, $return_id = FALSE)
 {
     if (!$this->id) {
         return FALSE;
     }
     if (!is_valid_email($email)) {
         return FALSE;
     }
     $uid = FALSE;
     $r = $this->db2->query('SELECT iduser FROM users WHERE email="' . $this->db2->escape($email) . '" LIMIT 1', FALSE);
     if ($o = $this->db2->fetch_object($r)) {
         $uid = intval($o->iduser);
         return $return_id ? $uid : $this->get_user_by_id($uid);
     }
     return FALSE;
 }
开发者ID:waqasraza123,项目名称:social_network_in_php_frenzy,代码行数:16,代码来源:class_network.php

示例9: handle_fatal_error

 /**
  * Handle fatal error
  *
  * @param Error $error
  * @return null
  */
 function handle_fatal_error($error)
 {
     if (DEBUG >= DEBUG_DEVELOPMENT) {
         dump_error($error);
     } else {
         if (instance_of($error, 'RoutingError') || instance_of($error, 'RouteNotDefinedError')) {
             header("HTTP/1.1 404 Not Found");
             print '<h1>Not Found</h1>';
             if (instance_of($error, 'RoutingError')) {
                 print '<p>Page "<em>' . clean($error->getRequestString()) . '</em>" not found.</p>';
             } else {
                 print '<p>Route "<em>' . clean($error->getRouteName()) . '</em>" not mapped.</p>';
             }
             // if
             print '<p><a href="' . assemble_url('homepage') . '">&laquo; Back to homepage</a></p>';
             die;
         }
         // if
         // Send email to administrator
         if (defined('ADMIN_EMAIL') && is_valid_email(ADMIN_EMAIL)) {
             $content = '<p>Hi,</p><p>activeCollab setup at ' . clean(ROOT_URL) . ' experienced fatal error. Info:</p>';
             ob_start();
             dump_error($error, false);
             $content .= ob_get_clean();
             @mail(ADMIN_EMAIL, 'activeCollab Crash Report', $content, "Content-Type: text/html; charset=utf-8");
         }
         // if
         // log...
         if (defined('ENVIRONMENT_PATH') && class_exists('Logger')) {
             $logger =& Logger::instance();
             $logger->logToFile(ENVIRONMENT_PATH . '/logs/' . date('Y-m-d') . '.txt');
         }
         // if
     }
     // if
     $error_message = '<div style="text-align: left; background: white; color: red; padding: 7px 15px; border: 1px solid red; font: 12px Verdana; font-weight: normal;">';
     $error_message .= '<p>Fatal error: activeCollab has failed to executed your request (reason: ' . clean(get_class($error)) . '). Information about this error has been logged and sent to administrator.</p>';
     if (is_valid_url(ROOT_URL)) {
         $error_message .= '<p><a href="' . ROOT_URL . '">&laquo; Back to homepage</a></p>';
     }
     // if
     $error_message .= '</div>';
     print $error_message;
     die;
 }
开发者ID:NaszvadiG,项目名称:activecollab_loc,代码行数:51,代码来源:init.php

示例10: parseText

function parseText($input)
{
    $email = array();
    $invalid_email = array();
    $input = ereg_replace("[^-A-Za-z._0-9@ ]", " ", $input);
    $token = trim(strtok($input, " "));
    while ($token !== "") {
        if (strpos($token, "@") !== false) {
            $token = ereg_replace("[^-A-Za-z._0-9@]", "", $token);
            if (is_valid_email($email) !== true) {
                $email[] = strtolower($token);
            } else {
                $invalid_email[] = strtolower($token);
            }
        }
        $token = trim(strtok(" "));
    }
    $email = array_unique($email);
    $invalid_email = array_unique($invalid_email);
    //  return array("valid_email"=>$email, "invalid_email" => $invalid_email);
    return array("valid_email" => $email);
}
开发者ID:adaptive,项目名称:email-extractor-php,代码行数:22,代码来源:lib.php

示例11: get_user_by_email

 public function get_user_by_email($email, $force_refresh = FALSE, $return_id = FALSE)
 {
     if (!$this->id) {
         return FALSE;
     }
     if (!is_valid_email($email)) {
         return FALSE;
     }
     $cachekey = 'n:' . $this->id . 'usermail:' . strtolower($email);
     $uid = $this->cache->get($cachekey);
     if (FALSE != $uid && TRUE != $force_refresh) {
         return $return_id ? $uid : $this->get_user_by_id($uid);
     }
     $uid = FALSE;
     $r = $this->db->query('SELECT id FROM sk_user WHERE email="' . $this->db->e($email) . '" AND active=1 LIMIT 1', FALSE);
     if ($o = $this->db->fetch_object($r)) {
         $uid = intval($o->id);
         $this->cache->set($cachekey, $uid, $BLOBALS['C']->CACHE_EXPIRE);
         return $return_id ? $uid : $this->get_user_by_id($uid);
     }
     $this->cache->del($cachekey);
     return FALSE;
 }
开发者ID:chaobj001,项目名称:tt,代码行数:23,代码来源:class_network.php

示例12: validate

 public function validate(&$data, $nonce_name)
 {
     global $_wt_options;
     $is_valid = parent::validate($data, $nonce_name);
     if ($is_valid) {
         $is_valid = true;
         if (empty($data["comment_content"])) {
             $is_valid = false;
             $this->add_db_result("comment_content", "required", "Content is missing");
         }
         if (empty($data["comment_author"])) {
             $is_valid = false;
             $this->add_db_result("comment_author", "required", "Author is missing");
         }
         if (!empty($data["comment_event_id"]) && $data["comment_event_id"] == 0) {
             $is_valid = false;
             $this->add_db_result("comment_event_id", "required", "Comment event id is missing");
         }
         if (!empty($data["comment_author_email"]) && !is_valid_email($data["comment_author_email"])) {
             $is_valid = false;
             $this->add_db_result("comment_author_email", "field", "Email in not valid");
         }
         if (isset($data["recaptcha_challenge_field"]) && isset($data["recaptcha_response_field"])) {
             require_once WT_PLUGIN_PATH . 'recaptcha/recaptchalib.php';
             $private_key = (string) $_wt_options->options("captcha_private_key");
             if (!empty($private_key)) {
                 $resp = recaptcha_check_answer($private_key, $_SERVER["REMOTE_ADDR"], $data["recaptcha_challenge_field"], $data["recaptcha_response_field"]);
                 $is_valid = $resp->is_valid;
                 $this->add_db_result("comment_captcha", "field", "The reCAPTCHA wasn't entered correctly. Go back and try it again.");
             }
         }
         if (!$is_valid) {
             $this->db_result("error", null, array("data" => $this->db_response_msg));
         }
     }
     return $is_valid;
 }
开发者ID:Ashleyotero,项目名称:oldest-old,代码行数:37,代码来源:class.comment.php

示例13: author_save_new

function author_save_new()
{
    require_privs('admin.edit');
    extract(doSlash(psa(array('privs', 'name', 'email', 'RealName'))));
    $privs = assert_int($privs);
    $length = function_exists('mb_strlen') ? mb_strlen($name, '8bit') : strlen($name);
    if ($name and $length <= 64 and is_valid_email($email)) {
        $exists = safe_field('name', 'txp_users', "name = '" . $name . "'");
        if ($exists) {
            author_list(array(gTxt('author_already_exists', array('{name}' => $name)), E_ERROR));
            return;
        }
        $password = generate_password(PASSWORD_LENGTH);
        $hash = doSlash(txp_hash_password($password));
        $nonce = doSlash(md5(uniqid(mt_rand(), TRUE)));
        $rs = safe_insert('txp_users', "\n\t\t\t\tprivs    = {$privs},\n\t\t\t\tname     = '{$name}',\n\t\t\t\temail    = '{$email}',\n\t\t\t\tRealName = '{$RealName}',\n\t\t\t\tnonce    = '{$nonce}',\n\t\t\t\tpass     = '{$hash}'\n\t\t\t");
        if ($rs) {
            send_password($RealName, $name, $email, $password);
            author_list(gTxt('password_sent_to') . sp . $email);
            return;
        }
    }
    author_list(array(gTxt('error_adding_new_author'), E_ERROR));
}
开发者ID:balcides,项目名称:Cathartic_server,代码行数:24,代码来源:txp_admin.php

示例14: csvFileToArray

 case 'text/csv':
 case 'text/x-csv':
 case 'application/x-csv':
 case 'application/csv':
 case 'text/comma-separated-values':
 case 'application/octet-stream':
     $_userInfo['csv'] = csvFileToArray($_FILES['cvsfile']['tmp_name'], $_userInfo['delimeter']);
     if (is_array($_userInfo['csv'])) {
         $_userInfo['nonImported'] = array();
         $c = 1;
         $_userInfo['csvTime'] = time();
         foreach ($_userInfo['csv'] as $row) {
             if (!isset($row[1])) {
                 $row[1] = '';
             }
             if (!empty($row[0]) && is_valid_email($row[0])) {
                 $sql = "INSERT INTO " . DB_PREPEND . "phpwcms_address (";
                 $sql .= "address_email, address_name, address_key, address_subscription, address_verified, address_tstamp) VALUES (";
                 $sql .= "'" . aporeplace($row[0]) . "', ";
                 $sql .= "'" . aporeplace($row[1]) . "', ";
                 $sql .= "'" . aporeplace(shortHash($row[0] . time())) . "', ";
                 $sql .= "'" . ($_userInfo['subscribe_all'] ? '' : aporeplace(serialize($_userInfo['subscribe_select']))) . "', ";
                 $sql .= $_userInfo['subscribe_active'] . ", FROM_UNIXTIME(" . $_userInfo['csvTime'] . ") )";
                 $sql = _dbQuery($sql, 'INSERT');
                 if (empty($sql['INSERT_ID'])) {
                     $_userInfo['nonImported'][$c] = $row[0] . '; ' . $row[1] . ' (' . mysql_error() . ')';
                 }
             } else {
                 $_userInfo['nonImported'][$c] = $row[0] . '; ' . $row[1];
             }
             $c++;
开发者ID:EDVLanger,项目名称:phpwcms,代码行数:31,代码来源:subscriberimport.form.inc.php

示例15: shouldEnterFirstMessage

function shouldEnterFirstMessage()
{
    global $captcha;
    $chatimmediatly = verify_param('chatimmediately', "/^\\d{1}\$/", '') == 1;
    if ($chatimmediatly) {
        return false;
    }
    if (!isset($_REQUEST['submitted'])) {
        displayStartChat();
        return true;
    } else {
        $TML = new SmartyClass();
        setupStartChat($TML);
        $_SESSION['webim_uname'] = $visitor_name = getSecureText($_REQUEST['visitorname']);
        $_SESSION['webim_email'] = $email = getSecureText($_REQUEST['email']);
        $_SESSION['webim_phone'] = $phone = getSecureText($_REQUEST['phone']);
        $message = getSecureText($_REQUEST['message']);
        $captcha_num = getSecureText($_REQUEST['captcha']);
        $has_errors = false;
        if (!$captcha->checkNumber($captcha_num)) {
            $TML->assign('errorcaptcha', true);
            $has_errors = true;
        } elseif (empty($visitor_name) && Visitor::getInstance()->canVisitorChangeName()) {
            $TML->assign('errorname', true);
            $has_errors = true;
        } elseif (!is_valid_name($visitor_name) && Visitor::getInstance()->canVisitorChangeName()) {
            $TML->assign('errornameformat', true);
            $has_errors = true;
        } elseif (empty($message)) {
            $TML->assign('errormessage', true);
            $has_errors = true;
        } else {
            if (!is_valid_email($email) && !intval($_SESSION['uid'])) {
                $TML->assign('erroremailformat', true);
                $has_errors = true;
            }
        }
        $captcha->setNumber();
        if ($has_errors) {
            $TML->assign('visitorname', $visitor_name);
            $TML->assign('email', $email);
            $TML->assign('phone', $phone);
            $TML->assign('captcha_num', '');
            $TML->display('start-chat.tpl');
            return true;
        }
        return false;
    }
}
开发者ID:kapai69,项目名称:fl-ru-damp,代码行数:49,代码来源:client.php


注:本文中的is_valid_email函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。