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


PHP PBValidation::isEmailAddress方法代码示例

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


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

示例1: createResponse

 function createResponse()
 {
     if (ob_get_contents()) {
         ob_clean();
     }
     $response = array();
     $response['error'] = 0;
     $response['field'] = array();
     $Validation = new PBValidation();
     $Session = new PBSession();
     $Session->create();
     $id = $_POST['id'];
     $formMetaData = $Session->getValue($this->getComponentId(), $id);
     if ($formMetaData === false) {
         exit;
     }
     $response['debug'] = $formMetaData['debug'];
     $response['reset'] = $formMetaData['reset'];
     if (!array_key_exists('field', $formMetaData)) {
         exit;
     }
     if (!is_array($formMetaData['field'])) {
         exit;
     }
     if (!count($formMetaData['field'])) {
         exit;
     }
     $response['notice']['error'] = $formMetaData['notice']['error'];
     $response['notice']['success'] = $formMetaData['notice']['success'];
     $replace = array();
     foreach ($formMetaData['field'] as $fieldIndex => $fieldData) {
         if ($fieldData['type'] == 'submit') {
             continue;
         }
         if (!array_key_exists($fieldIndex, $_POST)) {
             $response['error'] = 1;
             continue;
         }
         $value = $_POST[$fieldIndex];
         if ($Validation->isNotEmpty($fieldData['name'])) {
             if (!array_key_exists($fieldData['name'], $replace)) {
                 $replace[$fieldData['name']] = $value;
             }
         }
         if ($fieldData['type'] == 'email') {
             if ($Validation->isNotEmpty($value) || $fieldData['mandatory'] == 1) {
                 if (!$Validation->isEmailAddress($value)) {
                     $response['error'] = 1;
                     $response['field'][$fieldIndex]['notice'] = $fieldData['notice'];
                 }
             }
         } else {
             if ($fieldData['mandatory'] == 1) {
                 if ($Validation->isEmpty($value)) {
                     $response['error'] = 1;
                     $response['field'][$fieldIndex]['notice'] = $fieldData['notice'];
                 }
             }
         }
     }
     if ($response['error'] == 1) {
         PBHelper::ajaxResponse($response);
     }
     PBInclude::includeClass(PLUGIN_PAGE_BUILDER_LIBRARY_PATH . 'phpMailer/PHPMailerAutoload.php', array('PHPMailer'));
     $mail = new PHPMailer();
     $mail->CharSet = 'UTF-8';
     foreach ($replace as $index => $value) {
         $formMetaData['sender']['name'] = preg_replace('/\\(' . $index . '\\)/', $value, $formMetaData['sender']['name']);
         $formMetaData['sender']['email'] = preg_replace('/\\(' . $index . '\\)/', $value, $formMetaData['sender']['email']);
     }
     if ($Validation->isEmailAddress($formMetaData['sender']['email']) && $Validation->isNotEmpty($formMetaData['sender']['name'])) {
         $mail->SetFrom($formMetaData['sender']['email'], $formMetaData['sender']['name']);
         $mail->AddReplyTo($formMetaData['sender']['email'], $formMetaData['sender']['name']);
     }
     $mail->AddAddress($formMetaData['recipient']['email'], $formMetaData['recipient']['name']);
     $recipientAdditionalData = mb_split(';', $formMetaData['recipient']['additional']);
     foreach ($recipientAdditionalData as $value) {
         $recipientAdditional = mb_split(':', $value);
         PBHelper::removeUIndex($recipientAdditional, 0, 1);
         if ($Validation->isEmailAddress($recipientAdditional[1]) && $Validation->isNotEmpty($recipientAdditional[0])) {
             $mail->AddAddress($recipientAdditional[1], $recipientAdditional[0]);
         }
     }
     if ($formMetaData['debug'] == 1) {
         $mail->SMTPDebug = true;
     }
     if ($Validation->isNotEmpty($formMetaData['sender']['smtp_host'])) {
         $mail->IsSMTP();
         $mail->SMTPAuth = true;
         $mail->Port = $formMetaData['sender']['smtp_port'];
         $mail->Host = $formMetaData['sender']['smtp_host'];
         $mail->Username = $formMetaData['sender']['smtp_username'];
         $mail->Password = $formMetaData['sender']['smtp_password'];
         $mail->SMTPSecure = $formMetaData['sender']['smtp_secure_connection_type'];
     }
     $mail->Subject = $formMetaData['message_subject'];
     $value = array_map('htmlspecialchars', $replace);
     $body = $formMetaData['message_content'];
     foreach ($replace as $index => $value) {
         $body = preg_replace('/\\[' . $index . '\\]/', $value, $body);
//.........这里部分代码省略.........
开发者ID:annguyenit,项目名称:HawaiiEducation,代码行数:101,代码来源:PB.Component.ContactForm.class.php


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