email() public static method

public static email ( $value )
コード例 #1
0
 public function individualMail($section, $arr = array())
 {
     $this->autoRender = false;
     $contents = $this->Mail->findBySection($section);
     $content = $contents['Mail']['content'];
     foreach ($arr as $key => $val) {
         $content = str_replace("~~{$key}~~", $val, $content);
     }
     if (!empty($arr['TO_EMAIL']) && Validation::email($arr['TO_EMAIL'], true)) {
         $email = new CakeEmail();
         $email->template('default');
         $email->config('default');
         $email->emailFormat('html')->to($arr['TO_EMAIL'])->subject($contents['Mail']['subject']);
         try {
             if ($email->send($content)) {
                 return;
             } else {
                 return;
             }
         } catch (Exception $e) {
             return;
         }
     }
     return;
 }
コード例 #2
0
 function validateEmailFormat($check)
 {
     if (empty($check['email'])) {
         return true;
     }
     return Validation::email($check['email']);
 }
コード例 #3
0
 /**
  * answerValidation 登録内容の正当性
  *
  * @param object &$model use model
  * @param array $data Validation対象データ
  * @param array $question 登録データに対応する項目
  * @param array $allAnswers 入力された登録すべて
  * @return bool
  */
 public function answerFileValidation(&$model, $data, $question, $allAnswers)
 {
     if ($question['question_type'] != $this->_myType) {
         return true;
     }
     return Validation::email($data['answer_value']);
 }
コード例 #4
0
 function register()
 {
     global $timezones;
     $this->pageTitle = __('register', true);
     $this->set('tzs', $timezones);
     $this->set('utz', $this->data['User']['tz']);
     if (!empty($this->data)) {
         $this->Security->requirePost('register');
         $v = new Validation();
         if ($this->data['User']['email'] !== $this->data['User']['confemail']) {
             $this->User->invalidate('confemail');
         }
         if ($this->User->findByEmail($this->data['User']['email']) || !$v->email($this->data['User']['email'])) {
             $this->User->invalidate('email');
         }
         if ($this->data['User']['password'] !== $this->data['User']['confpass']) {
             $this->User->invalidate('confpass');
         }
         if (!$v->url($this->data['User']['website']) && !empty($this->data['User']['website'])) {
             $this->User->invalidate('website');
         }
         if ($this->User->validates()) {
             $clean = new Sanitize();
             // Generate and set the password, salt and activation key
             $pass = $this->Hash->password($this->data['User']['password'], $this->data['User']['email']);
             $this->data['User']['active'] = $this->Hash->keygen(10, true);
             $this->data['User']['password'] = $pass['pass'];
             $this->data['User']['salt'] = $pass['salt'];
             // Save a few fields from the wrath of cleanArray()
             $temp = array('lat' => $this->data['User']['lat'], 'lng' => $this->data['User']['lng'], 'tz' => $this->data['User']['tz'], 'email' => $this->data['User']['email']);
             // Scrub 'a dub
             $clean->clean($this->data);
             $this->data['User']['email'] = $clean->escape($temp['email']);
             $this->data['User']['lng'] = floatval($temp['lng']);
             $this->data['User']['lat'] = floatval($temp['lat']);
             $this->data['User']['tz'] = intval($temp['tz']);
             $this->data['User']['role'] = 0;
             $this->User->begin();
             if ($this->User->save($this->data)) {
                 $this->Email->to = $this->data['User']['email'];
                 $this->Email->replyTo = $this->data['User']['email'];
                 $this->Email->from = APP_NAME . ' <' . APP_EMAIL . '>';
                 $this->Email->subject = sprintf(__('email_subject_welcome', true), APP_NAME);
                 $this->Email->template = 'register';
                 $this->Email->sendAs = 'both';
                 $this->set('actcode', $this->data['User']['active']);
                 if ($this->Email->send()) {
                     $this->User->commit();
                     $this->Session->setFlash('Account created!');
                 } else {
                     $this->User->rollback();
                     $this->Session->setFlash('Error!');
                 }
             } else {
                 $this->User->rollback();
                 $this->Session->setFlash('Error\'d');
             }
         }
     }
 }
コード例 #5
0
 public function startup(Controller $Controller)
 {
     $this->Controller = $Controller;
     if (extension_loaded('mbstring')) {
         switch (Configure::read('Config.language')) {
             case 'jpn':
                 $lang = "ja";
                 break;
             case 'eng':
                 $lang = "en";
                 break;
             default:
                 $lang = "uni";
         }
         mb_language($lang);
         mb_internal_encoding("UTF-8");
     }
     //tmp crash fix
     $email = "*****@*****.**";
     if (Validation::email($this->Controller->Setting->mail_from)) {
         $email = $this->Controller->Setting->mail_from;
     }
     $this->Email = new CakeEmail(array('transport' => $this->Controller->Setting->mail_transport, 'from' => $email, 'host' => $this->Controller->Setting->mail_host, 'port' => $this->Controller->Setting->mail_port, 'username' => $this->Controller->Setting->mail_username, 'password' => $this->Controller->Setting->mail_password));
     $this->Email->viewVars(array('footer' => $this->Controller->Setting->emails_footer));
     if ($this->Controller->Setting->plain_text_mail) {
         $this->Email->emailFormat('text');
     } else {
         $this->Email->emailFormat('both');
     }
 }
コード例 #6
0
ファイル: register.php プロジェクト: RuseHackV2/LifePlus
 public function create_user($username, $password, $email, $phone, $bdate, $information, $interests, $city, $image)
 {
     $user = new User();
     try {
         $user->set_username(Validation::username($username));
     } catch (Exception $ex) {
         echo 'Failed: ', $ex->getMessage();
         exit;
     }
     try {
         $user->set_password(Validation::password($password));
     } catch (Exception $ex) {
         echo 'Failed: ', $ex->getMessage();
         exit;
     }
     try {
         $user->set_email(Validation::email($email));
     } catch (Exception $ex) {
         echo 'Failed: ', $ex->getMessage();
         exit;
     }
     try {
         $user->set_phone(Validation::phone($phone));
     } catch (Exception $ex) {
         echo 'Failed: ', $ex->getMessage();
         exit;
     }
     try {
         $user->set_bdate(Validation::bdate($bdate));
     } catch (Exception $ex) {
         echo 'Failed: ', $ex->getMessage();
         exit;
     }
     try {
         $user->set_information(Validation::information($information));
     } catch (Exception $ex) {
         echo 'Failed: ', $ex->getMessage();
         exit;
     }
     try {
         $user->set_interests(Validation::interests($interests));
     } catch (Exception $ex) {
         echo 'Failed: ', $ex->getMessage();
         exit;
     }
     try {
         $user->set_city(Validation::city($city));
     } catch (Exception $ex) {
         echo 'Failed: ', $ex->getMessage();
         exit;
     }
     try {
         $user->set_image(Validation::image($image));
     } catch (Exception $ex) {
         echo 'Failed: ', $ex->getMessage();
         exit;
     }
     return $user;
 }
コード例 #7
0
ファイル: formatting.php プロジェクト: styfle/core
 /**
  * Takes an email and hides the identity. If the string is not an email address
  * it will be returned as-is
  *
  * @param string $email
  */
 public function secretEmail($email = '')
 {
     if (Validation::email($email)) {
         $emailSplit = explode('@', $email);
         $identity = $emailSplit[0][0] . '.....' . $emailSplit[0][strlen($emailSplit[0]) - 1];
         return $identity . '@' . $emailSplit[1];
     }
     return $email;
 }
コード例 #8
0
 /**
  * answerValidation 登録内容の正当性
  *
  * @param object &$model use model
  * @param array $data Validation対象データ
  * @param array $question 登録データに対応する項目
  * @param array $allAnswers 入力された登録すべて
  * @return bool
  */
 public function answerEmailValidation(&$model, $data, $question, $allAnswers)
 {
     if ($question['question_type'] != $this->_myType) {
         return true;
     }
     if ($question['is_require'] === true || $data['answer_value']) {
         return Validation::email($data['answer_value']);
     }
     return true;
 }
コード例 #9
0
 public function multiEmail($check)
 {
     $email_list = preg_split("/[\\s,]+/", $check['contact_email']);
     $V = new Validation();
     foreach ($email_list as $email) {
         if (!$V->email(trim($email))) {
             return false;
         }
     }
     return true;
 }
コード例 #10
0
ファイル: ResetShell.php プロジェクト: Jony01/LLD
 /**
  * Resets all emails - e.g. to your admin email (for local development).
  *
  * @return void
  */
 public function email()
 {
     $this->out('Email:');
     App::uses('Validation', 'Utility');
     while (empty($email) || !Validation::email($email)) {
         $email = $this->in(__('New email address (must have a valid form at least)'));
     }
     $this->User = ClassRegistry::init(CLASS_USER);
     if (!$this->User->hasField('email')) {
         return $this->error(CLASS_USER . ' model doesnt have an email field!');
     }
     $this->hr();
     $this->out('resetting...');
     Configure::write('debug', 2);
     $this->User->recursive = -1;
     $this->User->updateAll(array('User.email' => '\'' . $email . '\''), array('User.email !=' => $email));
     $count = $this->User->getAffectedRows();
     $this->out($count . ' emails resetted - DONE');
 }
コード例 #11
0
ファイル: userController.php プロジェクト: abdouh/pets
 public function update()
 {
     if (Login::get_instance()->check_login() == 'valid') {
         if ($_POST) {
             $errors = array();
             $user_info = array();
             $user_data = Register::get_instance()->get_current_user();
             $user_info['id'] = $user_data['id'];
             $user_info['username'] = addslashes($_POST['username']);
             $user_info['email'] = addslashes($_POST['email']);
             $user_info['phone'] = '1' . $_POST['phone'];
             if (!empty($_POST['new_pass'])) {
                 $user_info['password'] = md5($_POST['new_pass']);
             }
             if ($user_data['password'] != md5($_POST['old_pass'])) {
                 $errors[] = 'كلمة المرور خاطئة';
             }
             if (md5($_POST['new_pass']) != md5($_POST['new_pass_confirm'])) {
                 $errors[] = 'خطأ فى تأكيد كلمة المرور';
             }
             if (!is_numeric($_POST['phone'])) {
                 $errors[] = 'رقم الهاتف غير صحيح';
             }
             if (!Validation::email($_POST['email'])) {
                 $errors[] = 'البريد الاكترونى غير صحيح';
             }
             if (!empty($_POST['username']) && is_numeric($_POST['username'])) {
                 $errors[] = 'اسم المستخدم يتكون من حروف فقط';
             }
             a:
             if (empty($errors)) {
                 Operations::get_instance()->init($user_info, 'users', 'update');
                 $this->img_upload();
                 if (isset($user_info['password'])) {
                     $_SESSION['user_info']['password'] = $user_info['password'];
                 }
                 echo json_encode(array('operation' => 1));
             } else {
                 echo json_encode(array('operation' => 2, 'errors' => $errors));
             }
         }
     }
 }
コード例 #12
0
 /**
  * email method
  *
  * @param string $entrytypeLabel
  * @param string $id
  * @return void
  */
 public function email($id = null)
 {
     App::uses('Validation', 'Utility');
     $this->layout = false;
     /* GET access not allowed */
     if ($this->request->is('get')) {
         $data = array('status' => 'error', 'msg' => __d('webzash', 'Method not allowed.'));
         $this->set('data', $data);
         return;
     }
     /* Check if valid id */
     if (empty($id)) {
         $data = array('status' => 'error', 'msg' => __d('webzash', 'Entry not specified.'));
         $this->set('data', $data);
         return;
     }
     /* Check if entry exists */
     $entry = $this->Entry->findById($id);
     if (!$entry) {
         $data = array('status' => 'error', 'msg' => __d('webzash', 'Entry not found.'));
         $this->set('data', $data);
         return;
     }
     /* On POST */
     if ($this->request->is('post') || $this->request->is('put')) {
         if (!empty($this->request->data)) {
             if (!Validation::email($this->request->data['email'])) {
                 $data = array('status' => 'error', 'msg' => __d('webzash', 'Invalid email specified.'));
                 $this->set('data', $data);
                 return;
             }
             /* Get entry type */
             $entrytype = $this->Entrytype->findById($entry['Entry']['entrytype_id']);
             if (!$entrytype) {
                 $data = array('status' => 'error', 'msg' => __d('webzash', 'Invalid entry type.'));
                 $this->set('data', $data);
                 return;
             }
             /* Get entry items */
             $entryitems = array();
             $rawentryitems = $this->Entryitem->find('all', array('conditions' => array('Entryitem.entry_id' => $id)));
             foreach ($rawentryitems as $row => $entryitem) {
                 if ($entryitem['Entryitem']['dc'] == 'D') {
                     $entryitems[$row] = array('dc' => 'D', 'ledger_id' => $entryitem['Entryitem']['ledger_id'], 'ledger_name' => $this->Ledger->getName($entryitem['Entryitem']['ledger_id']), 'dr_amount' => toCurrency('D', $entryitem['Entryitem']['amount']), 'cr_amount' => '');
                 } else {
                     $entryitems[$row] = array('dc' => 'C', 'ledger_id' => $entryitem['Entryitem']['ledger_id'], 'ledger_name' => $this->Ledger->getName($entryitem['Entryitem']['ledger_id']), 'dr_amount' => '', 'cr_amount' => toCurrency('C', $entryitem['Entryitem']['amount']));
                 }
             }
             /* Sending email */
             $viewVars = array('entry' => $entry, 'entryitems' => $entryitems, 'entrytype' => $entrytype);
             $email_status = $this->Generic->sendEmail($this->request->data['email'], h($entrytype['Entrytype']['name']) . ' Number ' . $this->getEntryNumber($entry['Entry']['number'], $entry['Entry']['entrytype_id']), 'entry_email', $viewVars, Configure::read('Account.email_use_default'), false);
             if ($email_status) {
                 $data = array('status' => 'success', 'msg' => __d('webzash', 'Email sent.'));
             } else {
                 $data = array('status' => 'error', 'msg' => __d('webzash', 'Failed to send email. Please check your email settings.'));
             }
             $this->set('data', $data);
             return;
         } else {
             $data = array('status' => 'error', 'msg' => __d('webzash', 'No data. Please, try again.'));
             $this->set('data', $data);
             return;
         }
     }
     return;
 }
コード例 #13
0
ファイル: InstallShell.php プロジェクト: rintaun/cake-forum
 /**
  * Gather all the data for creating a new user.
  *
  * @access protected
  * @param string $mode
  * @return string
  */
 protected function _newUser($mode)
 {
     switch ($mode) {
         case 'username':
             $username = trim($this->in('Username:'******'userMap']['username'], $this->db->value($username)));
                 if ($this->db->hasResult() && $result[0]['count']) {
                     $this->out('Username already exists, please try again.');
                     $username = $this->_newUser($mode);
                 }
             }
             return $username;
             break;
         case 'password':
             $password = trim($this->in('Password:'******'email':
             $email = trim($this->in('Email:'));
             if (empty($email)) {
                 $email = $this->_newUser($mode);
             } else {
                 if (!Validation::email($email)) {
                     $this->out('Invalid email address, please try again.');
                     $email = $this->_newUser($mode);
                 } else {
                     $result = $this->db->fetchRow(sprintf("SELECT COUNT(*) AS `count` FROM `users` AS `User` WHERE `%s` = %s", $this->config['userMap']['email'], $this->db->value($email)));
                     if ($this->db->hasResult() && $result[0]['count']) {
                         $this->out('Email already exists, please try again.');
                         $email = $this->_newUser($mode);
                     }
                 }
             }
             return $email;
             break;
     }
 }
コード例 #14
0
 /**
  * Get the value of an input.
  *
  * @param string $field
  * @return string
  */
 public function getFieldInput($field)
 {
     $model = ClassRegistry::init($this->usersModel);
     switch ($field) {
         case 'username':
             $username = trim($this->in('Username:'******'count', array('conditions' => array($model->alias . '.' . $this->userFields['username'] => $username)));
                 if ($result) {
                     $this->out('<error>Username already exists, please try again</error>');
                     $username = $this->getFieldInput($field);
                 }
             }
             return $username;
             break;
         case 'email':
             $email = trim($this->in('Email:'));
             if (!$email) {
                 $email = $this->getFieldInput($field);
             } else {
                 if (!Validation::email($email)) {
                     $this->out('<error>Invalid email address, please try again</error>');
                     $email = $this->getFieldInput($field);
                 } else {
                     $result = $model->find('count', array('conditions' => array($model->alias . '.' . $this->userFields['email'] => $email)));
                     if ($result) {
                         $this->out('<error>Email already exists, please try again</error>');
                         $email = $this->getFieldInput($field);
                     }
                 }
             }
             return $email;
             break;
             // Password, others...
         // Password, others...
         default:
             $value = trim($this->in(sprintf('%s:', Inflector::humanize($field))));
             if (!$value) {
                 $value = $this->getFieldInput($field);
             }
             return $value;
             break;
     }
 }
コード例 #15
0
ファイル: email.php プロジェクト: alexruliov/mysite
<?php

require_once __DIR__ . '/val.php';
$a = new Validation();
echo $a->email();
コード例 #16
0
ファイル: BcAppController.php プロジェクト: hanhunhun/hanlog
 /**
  * メールを送信する
  *
  * @param string $to 送信先アドレス
  * @param string $title タイトル
  * @param mixed $body 本文
  * @param array $options オプション
  * @return bool 送信結果
  */
 public function sendMail($to, $title = '', $body = '', $options = array())
 {
     $options = array_merge(array('agentTemplate' => true, 'template' => 'default'), $options);
     if (!empty($this->siteConfigs['smtp_host'])) {
         $transport = 'Smtp';
         $host = $this->siteConfigs['smtp_host'];
         $port = $this->siteConfigs['smtp_port'] ? $this->siteConfigs['smtp_port'] : 25;
         $username = $this->siteConfigs['smtp_user'] ? $this->siteConfigs['smtp_user'] : null;
         $password = $this->siteConfigs['smtp_password'] ? $this->siteConfigs['smtp_password'] : null;
         $tls = $this->siteConfigs['smtp_tls'] && $this->siteConfigs['smtp_tls'] == 1;
     } else {
         $transport = 'Mail';
         $host = 'localhost';
         $port = 25;
         $username = null;
         $password = null;
         $tls = null;
     }
     $config = array('transport' => $transport, 'host' => $host, 'port' => $port, 'username' => $username, 'password' => $password, 'tls' => $tls);
     $cakeEmail = new CakeEmail($config);
     // charset
     if (!empty($this->siteConfigs['mail_encode'])) {
         $encode = $this->siteConfigs['mail_encode'];
     } else {
         $encode = 'ISO-2022-JP';
     }
     // ISO-2022-JPの場合半角カナが文字化けしてしまうので全角に変換する
     if ($encode == 'ISO-2022-JP') {
         $title = mb_convert_kana($title, 'KV', "UTF-8");
         if (is_string($body)) {
             $body = mb_convert_kana($body, 'KV', "UTF-8");
         } elseif (isset($body['message']) && is_array($body['message'])) {
             foreach ($body['message'] as $key => $val) {
                 if (is_string($val)) {
                     $body['message'][$key] = mb_convert_kana($val, 'KV', "UTF-8");
                 }
             }
         }
     }
     //CakeEmailの内部処理のencodeを統一したいので先に値を渡しておく
     $cakeEmail->headerCharset($encode);
     $cakeEmail->charset($encode);
     //$format
     if (!empty($options['format'])) {
         $cakeEmail->emailFormat($options['format']);
     } else {
         $cakeEmail->emailFormat('text');
     }
     //bcc 'mail@example.com,mail2@example.com'
     if (!empty($options['bcc'])) {
         // 文字列の場合
         $bcc = array();
         if (is_string($options['bcc'])) {
             if (strpos($options['bcc'], ',') !== false) {
                 $bcc = explode(',', $options['bcc']);
             } else {
                 $bcc[] = $options['bcc'];
             }
             // 配列の場合
         } elseif (is_array($options['bcc'])) {
             $bcc = $options['bcc'];
         }
         foreach ($bcc as $val) {
             if (Validation::email(trim($val))) {
                 $cakeEmail->addBcc($val);
             }
         }
         unset($bcc);
     }
     //cc 'mail@example.com,mail2@example.com'
     if (!empty($options['cc'])) {
         // 文字列の場合
         $cc = array();
         if (is_string($options['cc'])) {
             if (strpos($options['cc'], ',') !== false) {
                 $cc = explode(',', $options['cc']);
             } else {
                 $cc[] = $options['cc'];
             }
             // 配列の場合
         } elseif (is_array($options['cc'])) {
             $cc = $options['cc'];
         }
         foreach ($cc as $val) {
             if (Validation::email(trim($val))) {
                 $cakeEmail->addCc($val);
             }
         }
         unset($cc);
     }
     // to 送信先アドレス (最初の1人がTOで残りがBCC)
     if (strpos($to, ',') !== false) {
         $_to = explode(',', $to);
         $i = 0;
         if (count($_to) >= 1) {
             foreach ($_to as $val) {
                 if ($i == 0) {
                     $cakeEmail->addTo($val);
                     $toAddress = $val;
                 } else {
                     $cakeEmail->addBcc($val);
                 }
                 ++$i;
             }
         }
     } else {
         $cakeEmail->addTo($to);
     }
     // 件名
     $cakeEmail->subject($title);
     //From
     $fromName = $from = '';
     if (!empty($options['from'])) {
         $from = $options['from'];
     } else {
         if (!empty($this->siteConfigs['email'])) {
             $from = $this->siteConfigs['email'];
             if (strpos($from, ',') !== false) {
                 $from = explode(',', $from);
             }
         } else {
             $from = $toAddress;
         }
     }
     if (!empty($options['fromName'])) {
         $fromName = $options['fromName'];
     } else {
         if (!empty($this->siteConfigs['formal_name'])) {
             $fromName = $this->siteConfigs['formal_name'];
         } else {
             $formalName = Configure::read('BcApp.title');
         }
     }
     $cakeEmail->from($from, $fromName);
     //Reply-To
     if (!empty($options['replyTo'])) {
         $replyTo = $options['replyTo'];
     } else {
         $replyTo = $from;
     }
     $cakeEmail->replyTo($replyTo);
     //Return-Path
     if (!empty($options['returnPath'])) {
         $returnPath = $options['returnPath'];
     } else {
         $returnPath = $from;
     }
     $cakeEmail->returnPath($returnPath);
     //$sender
     if (!empty($options['sender'])) {
         $cakeEmail->sender($options['sender']);
     }
     //$theme
     if ($this->theme) {
         $cakeEmail->theme($this->theme);
     }
     if (!empty($options['theme'])) {
         $cakeEmail->theme($options['theme']);
     }
     //viewRender (利用するviewクラスを設定する)
     $cakeEmail->viewRender('BcApp');
     //template
     if (!empty($options['template'])) {
         $layoutPath = $subDir = $plugin = '';
         if ($options['agentTemplate'] && Configure::read('BcRequest.agent')) {
             $layoutPath = Configure::read('BcRequest.agentPrefix');
             $subDir = Configure::read('BcRequest.agentPrefix');
         }
         list($plugin, $template) = pluginSplit($options['template']);
         if ($subDir) {
             $template = "{$subDir}/{$template}";
         }
         if (!empty($plugin)) {
             $template = "{$plugin}.{$template}";
         }
         if (!empty($options['layout'])) {
             $cakeEmail->template($template, $options['layout']);
         } else {
             $cakeEmail->template($template);
         }
         $content = '';
         if (is_array($body)) {
             $cakeEmail->viewVars($body);
         } else {
             $cakeEmail->viewVars(array('body' => $body));
         }
     } else {
         $content = $body;
     }
     // $attachments tmp file path
     $attachments = array();
     if (!empty($options['attachments'])) {
         if (!is_array($options['attachments'])) {
             $attachments = array($options['attachments']);
         } else {
             $attachments = $options['attachments'];
         }
     }
     $cakeEmail->attachments($attachments);
     try {
         $cakeEmail->send($content);
         return true;
     } catch (Exception $e) {
         $this->log($e->getMessage());
         return false;
     }
 }
コード例 #17
0
 public function login()
 {
     if ($this->request->is('post')) {
         App::uses("Validation", "Utility");
         if (Validation::email($this->request->data['User']['username'])) {
             $this->Auth->authenticate = array('Form' => array('fields' => array('username' => 'email')));
             $this->request->data['User']['email'] = $this->request->data['User']['username'];
             unset($this->request->data['User']['username']);
         }
         if ($this->Auth->login()) {
             $this->Session->setFlash('LoggedIn Successfully');
             $this->redirect($this->Auth->redirect());
         } else {
             $this->Session->setFlash('Something went wrong...');
             $this->redirect("/users/login");
         }
     }
 }
コード例 #18
0
ファイル: BcAppModel.php プロジェクト: kenz/basercms
 /**
  * 複数のEメールチェック(カンマ区切り)
  * 
  * @param array $check
  * @return boolean 
  */
 public function emails($check)
 {
     $emails = array();
     if (strpos($check[key($check)], ',') !== false) {
         $emails = explode(',', $check[key($check)]);
     }
     if (!$emails) {
         $emails = array($check[key($check)]);
     }
     $result = true;
     foreach ($emails as $email) {
         if (!Validation::email($email)) {
             $result = false;
         }
     }
     return $result;
 }
コード例 #19
0
ファイル: MembersController.php プロジェクト: peterlogic/bio
 public function login()
 {
     if ($this->Session->check('Auth.Member')) {
         $this->Session->setFlash('You are already logged in', 'default', array('class' => 'successfully'));
         $this->redirect(array('controller' => '/'));
     }
     if ($this->request->is('post')) {
         //debug($this->data);
         App::Import('Utility', 'Validation');
         if (isset($this->data['Member']['username']) && $this->data['Member']['username'] != '' && isset($this->data['Member']['password']) && $this->data['Member']['password'] != '') {
             if (isset($this->data['Member']['username']) && Validation::email($this->data['Member']['username'])) {
                 $this->request->data['Member']['email'] = $this->data['Member']['username'];
                 $this->Auth->authenticate['Form'] = array('fields' => array('userModel' => 'Member', 'username' => 'email'));
                 $x = $this->Member->find('first', array('conditions' => array('email' => $this->data['Member']['username'])));
             } else {
                 $this->Auth->authenticate['Form'] = array('fields' => array('userModel' => 'Member', 'username' => 'username'));
                 $x = $this->Member->find('first', array('conditions' => array('username' => $this->data['Member']['username'])));
                 //$this->Session->setFlash("Email address not found.", 'default', array ('class' => 'errormsg'));
                 //$this->redirect(array('controller' => 'Members', 'action' => 'login'));
             }
             if (isset($x['Member']['type']) && $x['Member']['type'] == '0') {
                 if ($this->Auth->login()) {
                     $this->Member->query("UPDATE members set online=1, last_activity=NOW() where id ='" . $this->Session->read('Auth.Member.id') . "'");
                     $this->redirect(array('controller' => 'Members', 'action' => 'profile'));
                 } else {
                     $this->Session->setFlash('Invalid username or password, try again', 'default', array('class' => 'errormsg'));
                 }
             } else {
                 $this->Session->setFlash("Email address not exist.", 'default', array('class' => 'errormsg'));
                 $this->redirect(array('controller' => 'Members', 'action' => 'login'));
             }
         } else {
             $this->Session->setFlash("Please enter email or password.", 'default', array('class' => 'errormsg'));
             $this->redirect(array('controller' => 'Members', 'action' => 'login'));
         }
     }
 }
コード例 #20
0
 /**
  * Add email
  *
  * @param string $varName
  * @param mixed $email
  * @param mixed $name
  * @return CakeEmail $this
  * @throws SocketException
  */
 protected function _addEmail($varName, $email, $name)
 {
     if (!is_array($email)) {
         if (!Validation::email($email)) {
             throw new SocketException(__d('cake_dev', 'Invalid email: "%s"', $email));
         }
         if ($name === null) {
             $name = $email;
         }
         $this->{$varName}[$email] = $name;
         return $this;
     }
     $list = array();
     foreach ($email as $key => $value) {
         if (is_int($key)) {
             $key = $value;
         }
         if (!Validation::email($key)) {
             throw new SocketException(__d('cake_dev', 'Invalid email: "%s"', $key));
         }
         $list[$key] = $value;
     }
     $this->{$varName} = array_merge($this->{$varName}, $list);
     return $this;
 }
コード例 #21
0
 /**
  * Chức năng kiểm tra user có tồn tại hay không
  */
 public function check_email()
 {
     $this->autoLayout = false;
     $this->autoRender = false;
     $data = $this->request->query;
     $email = $data['email'];
     if (!empty($email)) {
         if (Validation::email($email)) {
             $check_email = $this->User->findByEmail($email);
             if (empty($check_email)) {
                 echo '<span style="color: green;">Bạn có thể sử dụng</span>';
             } else {
                 echo '<span style="color: red;">Email đã tồn tại trên hệ thống</span>';
             }
         } else {
             echo '<span style="color: red;">Email không đúng định dạng</span>';
         }
     } else {
         echo '<span style="color: red;">Bạn phải nhập email</span>';
     }
 }
コード例 #22
0
ファイル: ActionMailer.php プロジェクト: gildonei/candycane
 /**
  * Uses $email and $name to generate a RFC 2822 compatible e-mail
  * adress. If securityMode is enabled some checks on the input are
  * performed which may cause the function to return false instead of
  * the generated adress.
  *
  * @link http://www.faqs.org/rfcs/rfc2822
  * @param string $email
  * @param string $name
  * @return mixed
  */
 function __makeRFC2822MailAdress($email, $name = null)
 {
     if ($this->securityMode == true) {
         // Make sure nobody can inject own headers into our email
         if (preg_grep("/[\r\n]/", array($email, $name))) {
             return false;
         }
         if (!Validation::email($email)) {
             return false;
         }
     }
     if (empty($name)) {
         $adress = $email;
     } else {
         $adress = $name . ' <' . $email . '>';
     }
     return $adress;
 }
コード例 #23
0
ファイル: User.php プロジェクト: nilBora/konstruktor
 public function search($currUserID, $q, $limit = 20, $state = null, $locale = null)
 {
     $this->loadModel('Country');
     $this->loadModel('Synonym');
     if (mb_strlen($q) == 1) {
         $fields = 'User.id, User.username, User.full_name, User.skills, User.rating, UserMedia.*';
         $conditions = array('User.id <> ' . $currUserID, 'OR' => array(array('User.full_name LIKE ?' => $q . '%')));
     } else {
         $conditions = array('OR' => array(array('Synonym.title' => $q), array('Synonym.variations LIKE ?' => '%' . $q . '|%')));
         $synRec = $this->Synonym->find('first', array('conditions' => $conditions));
         if ($synRec) {
             $synCheck = explode('|', $synRec['Synonym']['variations']);
             array_pop($synCheck);
             array_push($synCheck, $synRec['Synonym']['title']);
             $conditions = array('country_name' => $synCheck);
         } else {
             $conditions = array('country_name LIKE ?' => $q . '%');
         }
         $fields = array('country_code', 'country_name');
         $countries = array_keys($this->Country->find('list', compact('fields', 'conditions')));
         if (!$countries) {
             $countries = '';
         }
         $fields = 'User.id, User.username, User.full_name, User.skills, User.rating, UserMedia.*';
         if (!($q == '@')) {
             if (!preg_match('/[A-Za-z]/', $q)) {
                 $t = $this->transliterateArray($q);
                 foreach ($t as $term) {
                     $sql[] = array('User.full_name LIKE ?' => $term . '%');
                     $sql[] = array('User.username LIKE ?' => $term . '%');
                     $sql[] = array('User.skills LIKE ?' => $term . '%');
                     $sql[] = array('User.live_place LIKE ?' => $term . '%');
                     $sql[] = array('User.full_name LIKE ?' => '% ' . $term . '%');
                     $sql[] = array('User.username LIKE ?' => '% ' . $term . '%');
                     $sql[] = array('User.skills LIKE ?' => '% ' . $term . '%');
                     $sql[] = array('User.live_place LIKE ?' => '% ' . $term . '%');
                 }
                 $sql[] = array('User.full_name LIKE ?' => '% ' . $q . '%');
                 $sql[] = array('User.username LIKE ?' => '% ' . $q . '%');
                 $sql[] = array('User.skills LIKE ?' => '% ' . $q . '%');
                 $sql[] = array('User.live_place LIKE ?' => '% ' . $q . '%');
                 $sql[] = array('User.full_name LIKE ?' => $q . '%');
                 $sql[] = array('User.username LIKE ?' => $q . '%');
                 $sql[] = array('User.skills LIKE ?' => $q . '%');
                 $sql[] = array('User.live_place LIKE ?' => $q . '%');
                 $conditions = array('User.id <> ' . $currUserID, 'AND' => array('OR' => $sql));
             } else {
                 $conditions = array('User.id <> ' . $currUserID, 'AND' => array('OR' => array(array('User.full_name LIKE ?' => '% ' . $q . '%'), array('User.username LIKE ?' => '% ' . $q . '%'), array('User.skills LIKE ?' => '% ' . $q . '%'), array('User.live_place LIKE ?' => '% ' . $q . '%'), array('User.full_name LIKE ?' => $q . '%'), array('User.username LIKE ?' => $q . '%'), array('User.skills LIKE ?' => $q . '%'), array('User.live_place LIKE ?' => $q . '%'))));
             }
             if ($countries) {
                 $conditions['AND']['OR'][] = array('User.live_country' => $countries);
             }
         }
     }
     $conditions['AND'][] = array('User.is_deleted' => 0);
     if (!empty($locale)) {
         $conditions['AND'][] = array(array('User.lat >=' => $locale['minlat'], 'User.lat <=' => $locale['maxlat']), array('User.lng >=' => $locale['minlng'], 'User.lng <=' => $locale['maxlng']));
     }
     if ($state == 'map') {
         $conditions['AND'][] = array('not' => array('User.lat' => null, 'User.lng' => null));
     }
     $order = array('User.full_name', 'User.username', 'User.skills');
     $aUsers = $this->find('all', compact('fields', 'conditions', 'limit'));
     if (empty($aUsers) && Validation::email($q)) {
         $aUsers[] = ['User' => ['id' => null, 'img_url' => 'img/no-photo.jpg', 'name' => $q]];
     }
     return $aUsers;
 }
コード例 #24
0
ファイル: MyModel.php プロジェクト: robksawyer/grabitdown
 /**
  * NOW: can be set to work offline only (if server is down etc)
  *
  * checks if a email is not from a garbige hoster
  * @param string email (neccessary)
  * @return boolean true if valid, else false
  * 2009-03-09 ms
  */
 public function isUndisposableEmail($email, $onlineMode = false, $proceed = false)
 {
     if (!isset($this->UndisposableEmail)) {
         App::import('Vendor', 'undisposable/undisposable');
         $this->UndisposableEmail = new UndisposableEmail();
     }
     if (!$onlineMode) {
         # crashed with white screen of death otherwise... (if foreign page is 404)
         $this->UndisposableEmail->useOnlineList(false);
     }
     if (!class_exists('Validation')) {
         App::uses('Validation', 'Utility');
     }
     if (!Validation::email($email)) {
         return false;
     }
     if ($this->UndisposableEmail->isUndisposableEmail($email) === false) {
         # trigger log
         $this->log('Disposable Email detected: ' . h($email) . ' (IP ' . env('REMOTE_ADDR') . ')', 'undisposable');
         if ($proceed === true) {
             return true;
         }
         return false;
     }
     return true;
 }
コード例 #25
0
 /**
  * @testdox email should return false to invalid email
  */
 public function testInvalidEmail()
 {
     $value = 'spaghettiphp.spaghettiphp.org';
     $this->assertFalse(Validation::email($value));
 }
コード例 #26
0
ファイル: checkout.php プロジェクト: bensonby/csc2720
        $error = true;
        $msg = "Name format incorrect (it can only contain alphabets or spaces)<br>";
    }
    if (Validation::address($_POST["address"])) {
        $order->set_address($_POST["address"]);
    } else {
        $error = true;
        $msg = $msg . "Address format incorrect (it cannot be empty)<br>";
    }
    if (Validation::phone($_POST["phone"])) {
        $order->set_phone($_POST["phone"]);
    } else {
        $error = true;
        $msg = $msg . "Phone format incorrect, it must be of 8 digits only<br>";
    }
    if (Validation::email($_POST["email"])) {
        $order->set_email($_POST["email"]);
    } else {
        $error = true;
        $msg = $msg . "Email format incorrect<br>";
    }
    $order->update();
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    if ($error) {
        set_msg("<h4>{$msg}</h4>");
    } else {
        set_msg("<h4>Preview here</h4>");
        if ($_SESSION["checkout"] == true) {
            $order->set_status("completed");
            $order->update();
コード例 #27
0
 function buy()
 {
     try {
         if ($this->request->is('post')) {
             $store = $this->Store->findByStoreHash($this->data['Item']['store_hash']);
             if (!$store) {
                 throw new Exception('Invalid store hash.');
             }
             $this->Item->id = $this->data['Item']['id'];
             $item_is_active = $this->Item->field('is_active');
             if (!$item_is_active) {
                 throw new Exception('Item is sold out.');
             }
             if (!Validation::email($this->data['Item'][$this->_imap['email']])) {
                 $this->Item->invalidate($this->_imap['email'], __('Invalid email.'));
             }
             if (!Validation::notEmpty($this->data['Item']['message'])) {
                 $this->Item->invalidate('message', __('Cannot be left empty.'));
             }
             if ($this->Item->validates()) {
                 if ($this->Item->Save($this->data)) {
                     $this->Session->setFlash('Item purchased.', 'default', array('class' => 'message success'));
                     $message = array('Message' => array('store_id' => $store['Store']['id'], 'item_id' => $this->Item->id, 'sender_email' => $this->data['Item'][$this->_imap['email']], 'receiver_email' => $store['Store']['email'], 'body' => $this->data['Item']['message']));
                     if ($this->_logged_user) {
                         $message['Message']['sender_id'] = $this->_logged_user['id'];
                         $message['Message']['sender_email'] = $this->_logged_user['email'];
                     }
                     if (isset($store['Store']['user_id'])) {
                         $message['Message']['receiver_id'] = $store['Store']['user_id'];
                     }
                     if ($this->Message->save($message)) {
                         $subject = 'Someone bought your item';
                         $this->Email->send($message['Message']['sender_email'], $store['Store']['email'], $subject, $this->data['Item']['message']);
                     }
                 }
             }
             $this->_processIframeForm($this->Item->validationErrors, $this->data, $this->referer());
         }
     } catch (Exception $e) {
         $this->Session->setFlash($e->getMessage(), 'default', array('class' => 'message error'));
         $this->redirect($this->referer());
         exit;
     }
 }
コード例 #28
0
         $status_msg[] = 'Your comment cannot exceed 255 characters';
     }
     // Validate parent sid
     if (Validation::sid($sid) !== true) {
         $status_msg[] = 'Invalid section ID';
     }
     // Validate parent id
     if (Validation::parent($parent) !== true) {
         $status_msg[] = 'Invalid parent ID';
     }
     // Validate author name
     if (Validation::username($author_name) !== true) {
         $status_msg[] = 'Invalid name';
     }
     // Validate email address
     if (Validation::email($author_email) !== true) {
         $status_msg[] = 'Invalid email address';
     }
     // If all user provided data is valid and trimmed
     if ($status_msg === array()) {
         $comment_handler = new CommentHandler();
         // Insert the comment
         if (($msg_id = $comment_handler->insert_comment($sid, $msg, $parent, $author_name, $author_email)) !== false) {
             $response = array('status_code' => 0, 'message_id' => $msg_id, 'author' => $author_name);
         } else {
             $response = array('status_code' => 4, 'status_msg' => array('An error has been occurred'));
         }
     } else {
         $response = array('status_code' => 3, 'status_msg' => $status_msg);
     }
 } else {
コード例 #29
0
ファイル: ValidationTest.php プロジェクト: alvaroziqar/galei
 /**
  * testEmailCustomRegex method
  *
  * @return void
  */
 public function testEmailCustomRegex()
 {
     $this->assertTrue(Validation::email('*****@*****.**', null, '/^[A-Z0-9._%-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}$/i'));
     $this->assertFalse(Validation::email('*****@*****.**', null, '/^[A-Z0-9._%-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}$/i'));
 }
コード例 #30
0
 /**
  * Ajax request to find roommates by criteria
  *
  * @param  int    $this->request->params['form']['signUpId']
  * @param  string $this->request->params['form']['email']
  * @param  string $this->request->params['form']['lastname']
  * @param  string $this->request->params['form']['nickname']
  * @author Povstyanoy
  */
 function findAllRoommate()
 {
     Configure::write('debug', '0');
     $this->layout = false;
     if (!$this->RequestHandler->isAjax()) {
         echo "Incorrect request.";
         exit;
     }
     $diverrorb = '<div id="finderror">';
     $diverrore = '</div>';
     //Get data from form
     $signupId = $this->request->params['form']['signUpId'];
     $email = trim($this->request->params['form']['email']);
     $lastname = trim($this->request->params['form']['lastname']);
     $nickname = trim($this->request->params['form']['nickname']);
     //Get details about signup
     $signupDetails = $this->_getSignupDetails($signupId, true);
     if ($signupDetails === false) {
         echo $diverrorb . "Parameters are wrong" . $diverrore;
         exit;
     }
     if (empty($email) && empty($lastname) && empty($nickname)) {
         echo $diverrorb . "Criteria is empty" . $diverrore;
         exit;
     }
     //Check access
     $accessGranted = $this->Access->getAccess('Signup', 'r', $signupDetails['Signup']['user_id']);
     if ($accessGranted === false) {
         echo $diverrorb . "Access denied" . $diverrore;
         exit;
     }
     $my_user_id = $signupDetails['Signup']['user_id'];
     $model = $signupDetails['Signup']['model'];
     $model_id = $signupDetails['Signup']['model_id'];
     //Validate email address
     $isValidEmail = false;
     if (!empty($email)) {
         $objValidate = new Validation();
         $isValidEmail = $objValidate->email($email);
         unset($objValidate);
         if (!$isValidEmail) {
             echo $diverrorb . "Email is incorrect" . $diverrore;
             exit;
         }
     }
     if (!$this->RequestHandler->isAjax()) {
         echo $diverrorb . "Incorrect request" . $diverrore;
         exit;
     }
     //find room id for current owner
     $CreatorRoomId = $this->SignupRoommate->_getMyRoomId($signupDetails['Signup']['user_id'], $model, $model_id);
     //Quantity of users in room
     $mates_in_room = $this->SignupRoommate->currentQuantityOfPeople($CreatorRoomId);
     //Check, Is room full of people?
     if ($signupDetails['Package']['people_in_room'] <= $mates_in_room) {
         echo $diverrorb . "You can not add mates.The Room is full." . $diverrore;
         exit;
     }
     //Check your payments
     if ($signupDetails['Signup']['status'] != 'paid') {
         echo $diverrorb . "Please pay full price to invite mates." . $diverrore;
         exit;
     }
     //Create criteria
     $criteria = array();
     if ($isValidEmail) {
         $criteria['email'] = $email;
     }
     if (!empty($lastname)) {
         $criteria['lastname'] = $lastname;
     }
     if (!empty($nickname)) {
         $criteria['lgn'] = $nickname;
     }
     $users = array();
     if (!empty($criteria)) {
         //Exclude my Id
         $criteria[] = "id <> {$my_user_id}";
         //Get list of users by criteria
         $this->Signup->User->recursive = -1;
         $users = $this->Signup->User->find('all', array('conditions' => $criteria));
     }
     if (empty($users)) {
         echo $diverrorb . "Can not find user(s) matching your criteria." . $diverrore;
         exit;
     }
     foreach ($users as $index => $user) {
         $users[$index]['User']['checked_status'] = $this->checkFindedMate($user['User']['id'], $signupDetails);
         if (!$isValidEmail) {
             $users[$index]['User']['email'] = "";
         }
         $users[$index]['User']['lastname'] = strtoupper(substr($users[$index]['User']['lastname'], 0, 1)) . ".";
     }
     $this->set('users', $users);
     $this->set('signupId', $signupId);
 }