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


PHP SMTP::MakeValidEmailAddress方法代码示例

本文整理汇总了PHP中SMTP::MakeValidEmailAddress方法的典型用法代码示例。如果您正苦于以下问题:PHP SMTP::MakeValidEmailAddress方法的具体用法?PHP SMTP::MakeValidEmailAddress怎么用?PHP SMTP::MakeValidEmailAddress使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SMTP的用法示例。


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

示例1: ProcessFrontend

    public function ProcessFrontend()
    {
        global $sso_provider, $sso_settings, $sso_target_url, $sso_header, $sso_footer, $sso_providers, $sso_selectors_url;
        require_once SSO_ROOT_PATH . "/" . SSO_PROVIDER_PATH . "/" . $sso_provider . "/facebook.php";
        $facebook = new SSO_FacebookSDK(array("appId" => $sso_settings["sso_facebook"]["app_id"], "secret" => $sso_settings["sso_facebook"]["app_secret"]));
        $id = $facebook->getUser();
        if ($id) {
            try {
                // Calculate the required fields.
                $fields = array("id" => true, "first_name" => true, "last_name" => true);
                foreach (self::$fieldmap as $key => $info) {
                    if ($sso_settings["sso_facebook"]["map_" . $key] != "" && !isset($info["pseudo"])) {
                        $fields[isset($info["parent"]) ? $info["parent"] : $key] = true;
                    }
                }
                $profile = $facebook->api("/me", "GET", array("fields" => implode(",", array_keys($fields))));
            } catch (FacebookApiException $e) {
                // Fall through here to go to the next step.
                $id = 0;
                $exceptionmessage = $e->getMessage();
            }
        }
        if (isset($_REQUEST["sso_facebook_action"]) && $_REQUEST["sso_facebook_action"] == "signin") {
            if ($id) {
                // Create a fake username based on available information.
                if ($sso_settings["sso_facebook"]["map_username"] != "") {
                    if (isset($profile["email"])) {
                        $profile["username"] = (string) @substr($profile["email"], 0, strpos($profile["email"], "@"));
                    } else {
                        if (isset($profile["first_name"]) && isset($profile["last_name"])) {
                            $profile["username"] = $profile["first_name"] . @substr($profile["last_name"], 0, 1);
                        } else {
                            if (isset($profile["name"])) {
                                $name = explode(" ", $name);
                                $profile["username"] = $name[0] . @substr($name[count($name) - 1], 0, 1);
                            } else {
                                $profile["username"] = (string) $id;
                            }
                        }
                    }
                    $profile["username"] = preg_replace('/\\s+/', "_", trim(preg_replace('/[^a-z0-9]/', " ", strtolower((string) $profile["username"]))));
                }
                // Check username blacklist.
                $message = "";
                if (isset($profile["username"])) {
                    $blacklist = explode("\n", str_replace("\r", "\n", $sso_settings["sso_facebook"]["username_blacklist"]));
                    foreach ($blacklist as $word) {
                        $word = trim($word);
                        if ($word != "" && stripos($profile["username"], $word) !== false) {
                            $message = BB_Translate("Username contains a blocked word.");
                            break;
                        }
                    }
                }
                // Check e-mail domain blacklist.
                if (isset($profile["email"])) {
                    define("CS_TRANSLATE_FUNC", "BB_Translate");
                    require_once SSO_ROOT_PATH . "/" . SSO_SUPPORT_PATH . "/smtp.php";
                    $email = SMTP::MakeValidEmailAddress($profile["email"]);
                    if (!$email["success"]) {
                        $message = BB_Translate("Invalid e-mail address.  %s", $email["error"]);
                    } else {
                        $domain = strtolower(substr($email["email"], strrpos($email["email"], "@") + 1));
                        $y = strlen($domain);
                        $baddomains = explode("\n", strtolower($sso_settings["sso_facebook"]["email_bad_domains"]));
                        foreach ($baddomains as $baddomain) {
                            $baddomain = trim($baddomain);
                            if ($baddomain != "") {
                                $y2 = strlen($baddomain);
                                if ($domain == $baddomain || $y < $y2 && substr($domain, $y - $y2 - 1, 1) == "." && substr($domain, $y - $y2) == $baddomain) {
                                    $message = BB_Translate("E-mail address is in a blacklisted domain.");
                                    break;
                                }
                            }
                        }
                    }
                }
                if ($message == "") {
                    // Fix birthday to be in international format YYYY-MM-DD.
                    if (isset($profile["birthday"])) {
                        $birthday = explode("/", $profile["birthday"]);
                        $year = array_pop($birthday);
                        array_unshift($birthday, $year);
                        $profile["birthday"] = implode("-", $birthday);
                    }
                    // Convert most profile fields into strings.
                    foreach ($profile as $key => $val) {
                        if (is_string($val)) {
                            continue;
                        }
                        if (is_bool($val)) {
                            $val = (string) (int) $val;
                        } else {
                            if (is_numeric($val)) {
                                $val = (string) $val;
                            } else {
                                if (is_object($val) && isset($val->id) && isset($val->name)) {
                                    $val = $val->name;
                                }
                            }
//.........这里部分代码省略.........
开发者ID:marks2016,项目名称:sso,代码行数:101,代码来源:index.php

示例2: SignupUpdateCheck

 private function SignupUpdateCheck(&$result, $ajax, $update, $admin)
 {
     $data = @json_decode(@file_get_contents(SSO_ROOT_PATH . "/" . SSO_SUPPORT_PATH . "/sms_mms_gateways.txt"));
     if (is_object($data)) {
         $field = $admin ? BB_GetValue("sso_login_sms_recovery_phone", false) : SSO_FrontendFieldValue($update ? "sso_login_sms_recovery_phone_update" : "sso_login_sms_recovery_phone");
         $field2 = $admin ? BB_GetValue("sso_login_sms_recovery_carrier", false) : SSO_FrontendFieldValue($update ? "sso_login_sms_recovery_carrier_update" : "sso_login_sms_recovery_carrier");
         if (!$ajax || $field !== false) {
             $info = $this->GetInfo();
             if ($field === false || $field == "") {
                 if ($ajax && $field2 !== false && $field2 != "") {
                     $result["errors"][] = BB_Translate($admin ? "Fill in the user's mobile phone number." : "Fill in your mobile phone number.");
                 }
             } else {
                 $phone = preg_replace("/[^0-9]/", "", $field);
                 if (strlen($phone) < 9) {
                     $result["warnings"][] = BB_Translate("Phone numbers are typically longer.  Format is usually trunk/country code + area/region code + local number.");
                 } else {
                     if (strlen($phone) > 15) {
                         $result["warnings"][] = BB_Translate("Phone numbers are typically shorter.  Format is usually trunk/country code + area/region code + local number.");
                     }
                 }
                 if (!$ajax || $field2 !== false) {
                     if ($field2 === false || $field2 == "") {
                         if ($ajax) {
                             $result["errors"][] = BB_Translate($admin ? "Select the user's mobile phone carrier." : "Select your mobile phone carrier.");
                         }
                     } else {
                         $field2 = explode("-", $field2);
                         if (count($field2) != 2) {
                             $result["errors"][] = BB_Translate($admin ? "Select the user's mobile phone carrier." : "Select your mobile phone carrier.");
                         } else {
                             $country = $field2[0];
                             $carrier = $field2[1];
                             if (!isset($data->sms_carriers->{$country}) || !isset($data->sms_carriers->{$country}->{$carrier})) {
                                 $result["errors"][] = BB_Translate($admin ? "Select the user's mobile phone carrier." : "Select your mobile phone carrier.");
                             } else {
                                 $item = $data->sms_carriers->{$country}->{$carrier};
                                 $emailaddr = str_replace("{number}", $field, $item[1]);
                                 if (!class_exists("SMTP")) {
                                     define("CS_TRANSLATE_FUNC", "BB_Translate");
                                     require_once SSO_ROOT_PATH . "/" . SSO_SUPPORT_PATH . "/smtp.php";
                                 }
                                 $email = SMTP::MakeValidEmailAddress($emailaddr);
                                 if (!$email["success"]) {
                                     $result["errors"][] = BB_Translate("Invalid e-mail address.  %s", $email["error"]);
                                 } else {
                                     if ($email["email"] != trim($emailaddr)) {
                                         $result["warnings"][] = BB_Translate("Invalid e-mail address.  Perhaps you meant '%s' instead?", $email["email"]);
                                     }
                                     $result["htmlsuccess"] = BB_Translate("Mobile phone information looks okay.  SMS messages will be sent via the e-mail address '%s'.", "<a href=\"mailto:" . htmlspecialchars($emailaddr) . "\">" . htmlspecialchars($emailaddr) . "</a>");
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:marks2016,项目名称:sso,代码行数:59,代码来源:sso_sms_recovery.php


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