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


PHP Valid::email方法代码示例

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


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

示例1: isValid

 public function isValid($Validation_data)
 {
     $errors = [];
     foreach ($Validation_data as $name => $value) {
         if (isset($_REQUEST[$name])) {
             $exploded = explode(':', $value);
             switch ($exploded[0]) {
                 case 'min':
                     $min = $exploded[1];
                     if (Valid::string()->length(3)->validate($_REQUEST[$name]) == false) {
                         $errors[] = "{$name} must be {$min} caracters long";
                     }
                     break;
                 case 'email':
                     if (Valid::email()->validate($_REQUEST[$name]) == false) {
                         $errors[] = $name . ' is not a valid email';
                     }
                     break;
                 case 'equalsTo':
                     $field = $exploded[1];
                     if (!Valid::equals($name)->validate($field)) {
                         $errors[] = $name . " must be equal to " . $field;
                     }
                     break;
             }
         }
     }
     return $errors;
 }
开发者ID:rezof,项目名称:acme,代码行数:29,代码来源:Validator.php

示例2: action_update

 /**
  * CRUD controller: UPDATE
  */
 public function action_update()
 {
     $this->template->title = __('Update') . ' ' . __($this->_orm_model) . ' ' . $this->request->param('id');
     $form = new FormOrm($this->_orm_model, $this->request->param('id'));
     if ($this->request->post()) {
         if ($success = $form->submit()) {
             if (Valid::email($form->object->email, TRUE)) {
                 //check we have this email in the DB
                 $user = new Model_User();
                 $user = $user->where('email', '=', Kohana::$_POST_ORIG['formorm']['email'])->where('id_user', '!=', $this->request->param('id'))->limit(1)->find();
                 if ($user->loaded()) {
                     Alert::set(Alert::ERROR, __('A user with the email you specified already exists'));
                 } else {
                     $form->save_object();
                     Alert::set(Alert::SUCCESS, __('Item updated') . '. ' . __('Please to see the changes delete the cache') . '<br><a class="btn btn-primary btn-mini ajax-load" href="' . Route::url('oc-panel', array('controller' => 'tools', 'action' => 'cache')) . '?force=1" title="' . __('Delete cache') . '">' . __('Delete cache') . '</a>');
                     $this->redirect(Route::get($this->_route_name)->uri(array('controller' => Request::current()->controller())));
                 }
             } else {
                 Alert::set(Alert::ERROR, __('Invalid Email'));
             }
         } else {
             Alert::set(Alert::ERROR, __('Check form for errors'));
         }
     }
     return $this->render('oc-panel/pages/user/update', array('form' => $form));
 }
开发者ID:ThomWensink,项目名称:common,代码行数:29,代码来源:user.php

示例3: _login

 private function _login()
 {
     $array = $this->request->post('login');
     $array = Validation::factory($array)->label('username', 'Username')->label('password', 'Password')->label('email', 'Email')->rules('username', array(array('not_empty')))->rules('password', array(array('not_empty')));
     $fieldname = Valid::email(Arr::get($array, 'username')) ? Auth::EMAIL : Auth::USERNAME;
     // Get the remember login option
     $remember = isset($array['remember']);
     Observer::notify('admin_login_validation', $array);
     if ($array->check()) {
         Observer::notify('admin_login_before', $array);
         if (Auth::instance()->login($array['username'], $array['password'], $remember)) {
             Observer::notify('admin_login_success', $array['username']);
             Session::instance()->delete('install_data');
             Kohana::$log->add(Log::INFO, ':user login')->write();
             if ($next_url = Flash::get('redirect')) {
                 $this->go($next_url);
             }
             // $this->go to defaut controller and action
             $this->go_backend();
         } else {
             Observer::notify('admin_login_failed', $array);
             Messages::errors(__('Login failed. Please check your login data and try again.'));
             $array->error($fieldname, 'incorrect');
             Kohana::$log->add(Log::ALERT, 'Try to login with :field: :value. Incorrect data', array(':field' => $fieldname, ':value' => $array['username']))->write();
         }
     } else {
         Messages::errors($array->errors('validation'));
     }
     $this->go(Route::get('user')->uri(array('action' => 'login')));
 }
开发者ID:ZerGabriel,项目名称:cms-1,代码行数:30,代码来源:login.php

示例4: on_page_load

 public function on_page_load()
 {
     $email_ctx_id = $this->get('email_id_ctx', 'email');
     $email = $this->_ctx->get($email_ctx_id);
     $referrer_page = Request::current()->referrer();
     $next_page = $this->get('next_url', Request::current()->referrer());
     if (!Valid::email($email)) {
         Messages::errors(__('Use a valid e-mail address.'));
         HTTP::redirect($referrer_page);
     }
     $user = ORM::factory('user', array('email' => $email));
     if (!$user->loaded()) {
         Messages::errors(__('No user found!'));
         HTTP::redirect($referrer_page);
     }
     $reflink = ORM::factory('user_reflink')->generate($user, 'forgot', array('next_url' => URL::site($this->next_url, TRUE)));
     if (!$reflink) {
         Messages::errors(__('Reflink generate error'));
         HTTP::redirect($referrer_page);
     }
     Observer::notify('admin_login_forgot_before', $user);
     try {
         Email_Type::get('user_request_password')->send(array('username' => $user->username, 'email' => $user->email, 'reflink' => Route::url('reflink', array('code' => $reflink)), 'code' => $reflink));
         Messages::success(__('Email with reflink send to address set in your profile'));
     } catch (Exception $e) {
         Messages::error(__('Something went wrong'));
     }
     HTTP::redirect($next_page);
 }
开发者ID:ZerGabriel,项目名称:cms-1,代码行数:29,代码来源:forgot.php

示例5: action_create

 public function action_create()
 {
     try {
         if (!Valid::email(core::request('email'))) {
             $this->_error(__('Invalid email'), 501);
         } elseif (!is_numeric(core::request('id_product'))) {
             $this->_error(__('Invalid product'), 501);
         } else {
             $product = new Model_Product(core::request('id_product'));
             if ($product->loaded()) {
                 $user = Model_User::create_email(core::request('email'), core::request('name'));
                 $order = Model_Order::new_order($user, $product);
                 $order->confirm_payment(core::request('paymethod', 'API'), core::request('txn_id'), core::request('pay_date'), core::request('amount'), core::request('currency'), core::request('fee'));
                 //adding the notes
                 $order->notes = core::request('notes');
                 $order->save();
                 $this->rest_output(array('order' => self::get_order_array($order)));
             } else {
                 $this->_error(__('Something went wrong'), 501);
             }
         }
     } catch (Kohana_HTTP_Exception $khe) {
         $this->_error($khe);
     }
 }
开发者ID:Ryanker,项目名称:open-eshop,代码行数:25,代码来源:order.php

示例6: action_user_contact

 public function action_user_contact()
 {
     $ad = new Model_Ad($this->request->param('id'));
     //message to user
     if ($ad->loaded() and $this->request->post()) {
         $user = new Model_User($ad->id_user);
         //require login to contact
         if ((core::config('advertisement.login_to_contact') == TRUE or core::config('general.messaging') == TRUE) and !Auth::instance()->logged_in()) {
             Alert::set(Alert::INFO, __('Please, login before contacting'));
             HTTP::redirect(Route::url('ad', array('category' => $ad->category->seoname, 'seotitle' => $ad->seotitle)));
         }
         if (captcha::check('contact')) {
             //check if user is loged in
             if (Auth::instance()->logged_in()) {
                 $email_from = $this->user->email;
                 $name_from = $this->user->name;
             } else {
                 $email_from = core::post('email');
                 $name_from = core::post('name');
             }
             //akismet spam filter
             if (!core::akismet($name_from, $email_from, core::post('message'))) {
                 if (core::config('general.messaging')) {
                     //price?
                     $price = (core::post('price') !== NULL and is_numeric(core::post('price'))) ? core::post('price') : NULL;
                     $ret = Model_Message::send_ad(core::post('message'), $this->user, $ad->id_ad, $price);
                 } else {
                     if (isset($_FILES['file'])) {
                         $file = $_FILES['file'];
                     } else {
                         $file = NULL;
                     }
                     //contact email is set use that one
                     if (isset($ad->cf_contactemail) and Valid::email($ad->cf_contactemail)) {
                         $to = $ad->cf_contactemail;
                     } else {
                         $to = NULL;
                     }
                     $ret = $user->email('user-contact', array('[EMAIL.BODY]' => core::post('message'), '[AD.NAME]' => $ad->title, '[EMAIL.SENDER]' => $name_from, '[EMAIL.FROM]' => $email_from, '[URL.AD]' => Route::url('ad', array('category' => $ad->category->seoname, 'seotitle' => $ad->seotitle))), $email_from, $name_from, $file, $to);
                 }
                 //if succesfully sent
                 if ($ret) {
                     Alert::set(Alert::SUCCESS, __('Your message has been sent'));
                     // we are updating field of visit table (contact)
                     Model_Visit::contact_ad($ad->id_ad);
                 } else {
                     Alert::set(Alert::ERROR, __('Message not sent'));
                 }
                 HTTP::redirect(Route::url('ad', array('category' => $ad->category->seoname, 'seotitle' => $ad->seotitle)));
             } else {
                 Alert::set(Alert::SUCCESS, __('This email has been considered as spam! We are sorry but we can not send this email.'));
             }
         } else {
             Alert::set(Alert::ERROR, __('Captcha is not correct'));
             HTTP::redirect(Route::url('ad', array('category' => $ad->category->seoname, 'seotitle' => $ad->seotitle)));
         }
     }
 }
开发者ID:kotsios5,项目名称:openclassifieds2,代码行数:58,代码来源:contact.php

示例7: on_page_load

 public function on_page_load()
 {
     if (Request::current()->method() !== Request::POST) {
         return;
     }
     $data = Request::current()->post();
     $login_fieldname = Valid::email(Arr::get($data, $this->get('login_field'))) ? Auth::EMAIL : Auth::USERNAME;
     $data = Validation::factory($data)->label($this->get('login_field'), 'Username')->label($this->get('password_field'), 'Password')->rules('username', array(array('not_empty')))->rules('password', array(array('not_empty')));
     Observer::notify('login_validation', $data);
     // Get the remember login option
     $remember = isset($data[$this->get('remember_field')]) and $this->get('remember') === TRUE;
     return Request::current()->is_ajax() ? $this->_ajax_login($data, $remember) : $this->_login($data, $remember);
 }
开发者ID:ZerGabriel,项目名称:cms-1,代码行数:13,代码来源:login.php

示例8: action_index

 public function action_index()
 {
     $email = Core::post('email_subscribe');
     if (Valid::email($email, TRUE)) {
         /* find user and compare emails */
         $obj_user = new Model_User();
         $user = $obj_user->where('email', '=', $email)->limit(1)->find();
         // case when user is not logged in.
         // We create new user if he doesn't exists in DB
         // and send him mail for ad created + new profile created
         if (!$user->loaded()) {
             $user = Model_User::create_email($email);
         }
         /* save this user to data base as subscriber */
         $arr_cat = Core::post('category_subscribe');
         // string in this case is returned as "int,int" so we need to format min/max price
         $price = Core::post('price_subscribe');
         if ($price = Core::post('price_subscribe')) {
             $min_price = substr($price, '0', stripos($price, ','));
             $max_price = substr($price, strrpos($price, ',') + 1);
         } else {
             //in case of mobile version
             // jquery mobile have different slider, so we need to get data differently
             $min_price = Core::post('price_subscribe-1');
             $max_price = Core::post('price_subscribe-2');
         }
         //if categry is not selected, subscribe them for al, set category to 0 thats all...
         if ($arr_cat === NULL) {
             $arr_cat[] = 0;
         }
         // create entry table subscriber for each category selected
         foreach ($arr_cat as $c => $id_value) {
             $obj_subscribe = new Model_Subscribe();
             $obj_subscribe->id_user = $user->id_user;
             $obj_subscribe->id_category = $id_value;
             $obj_subscribe->id_location = Core::post('location_subscribe');
             $obj_subscribe->min_price = $min_price;
             $obj_subscribe->max_price = $max_price;
             try {
                 $obj_subscribe->save();
             } catch (Exception $e) {
                 throw HTTP_Exception::factory(500, $e->getMessage());
             }
         }
         Alert::set(Alert::SUCCESS, __('Thank you for subscribing'));
         $this->redirect(Route::url('default'));
     } else {
         Alert::set(Alert::ALERT, __('Invalid Email'));
         $this->redirect(Route::url('default'));
     }
 }
开发者ID:Chinese1904,项目名称:openclassifieds2,代码行数:51,代码来源:subscribe.php

示例9: multi_email

 public function multi_email($field, $value, $validation)
 {
     $emails = explode(',', $value);
     $valid = TRUE;
     foreach ($emails as $email) {
         $email = trim($email);
         if (Valid::email($email) === FALSE) {
             $valid = FALSE;
         }
     }
     if ($valid === FALSE) {
         $validation->error($field, 'email');
     }
 }
开发者ID:yubinchen18,项目名称:A-basic-website-project-for-a-company-using-the-MVC-pattern-in-Kohana-framework,代码行数:14,代码来源:Config.php

示例10: action_register

 /**
  * Simple register for user
  *
  */
 public function action_register()
 {
     $this->template->content = View::factory('pages/auth/register');
     $this->template->content->msg = '';
     //if user loged in redirect home
     if (Auth::instance()->logged_in()) {
         $this->request->redirect(Route::get('oc-panel')->uri());
     } elseif (core::post('email') and CSRF::valid('register')) {
         $email = core::post('email');
         if (Valid::email($email, TRUE)) {
             if (core::post('password1') == core::post('password2')) {
                 //check we have this email in the DB
                 $user = new Model_User();
                 $user = $user->where('email', '=', $email)->limit(1)->find();
                 if ($user->loaded()) {
                     Form::set_errors(array(__('User already exists')));
                 } else {
                     //create user
                     $user->email = $email;
                     $user->name = core::post('name');
                     $user->status = Model_User::STATUS_ACTIVE;
                     $user->id_role = 1;
                     //normal user
                     $user->password = core::post('password1');
                     $user->seoname = $user->gen_seo_title(core::post('name'));
                     try {
                         $user->save();
                     } catch (ORM_Validation_Exception $e) {
                         //Form::errors($content->errors);
                     } catch (Exception $e) {
                         throw new HTTP_Exception_500($e->getMessage());
                     }
                     //login the user
                     Auth::instance()->login(core::post('email'), core::post('password1'));
                     //send email
                     $user->email('auth.register', array('[USER.PWD]' => core::post('password1'), '[URL.QL]' => $user->ql('default', NULL, TRUE)));
                     Alert::set(Alert::SUCCESS, __('Welcome!'));
                     //login the user
                     $this->request->redirect(Core::post('auth_redirect', Route::url('oc-panel')));
                 }
             } else {
                 Form::set_errors(array(__('Passwords do not match')));
             }
         } else {
             Form::set_errors(array(__('Invalid Email')));
         }
     }
     //template header
     $this->template->title = __('Register new user');
 }
开发者ID:Wildboard,项目名称:WbWebApp,代码行数:54,代码来源:auth.php

示例11: valid_contact

 /**
  * Validate Contact Against Contact Type
  *
  * @param array $validation
  * @param string $field field name
  * @param [type] [varname] [description]
  * @return void
  */
 public function valid_contact($contact, $data, $validation)
 {
     // Valid Email?
     if (isset($data['type']) and $data['type'] == Contact::EMAIL and !Valid::email($contact)) {
         return $validation->error('contact', 'invalid_email', [$contact]);
     } else {
         if (isset($data['type']) and $data['type'] == Contact::PHONE) {
             // Remove all non-digit characters from the number
             $number = preg_replace('/\\D+/', '', $contact);
             if (strlen($number) == 0) {
                 $validation->error('contact', 'invalid_phone', [$contact]);
             }
         }
     }
 }
开发者ID:tobiasziegler,项目名称:platform,代码行数:23,代码来源:Update.php

示例12: valid_contact

 public function valid_contact($contact, $data, $validation)
 {
     // Valid Email?
     if (isset($data['type']) and $data['type'] == Contact::EMAIL and !Valid::email($contact)) {
         return $validation->error('contact', 'invalid_email', [$contact]);
     } else {
         if (isset($data['type']) and $data['type'] == Contact::PHONE) {
             // Allow for alphanumeric sender
             $number = preg_replace('/[^a-zA-Z0-9 ]/', '', $contact);
             if (strlen($number) == 0) {
                 $validation->error('contact', 'invalid_phone', [$contact]);
             }
         }
     }
 }
开发者ID:tobiasziegler,项目名称:platform,代码行数:15,代码来源:Receive.php

示例13: valid_contact

 /**
  * Validate Contact Against Contact Type
  *
  * @param array $validation
  * @param string $field field name
  * @param [type] [varname] [description]
  * @return void
  */
 public function valid_contact($validation, $field)
 {
     // Valid Email?
     if (isset($validation['type']) and $validation['type'] == self::EMAIL and !Valid::email($validation[$field])) {
         $validation->error($field, 'invalid_email');
     } else {
         if (isset($validation['type']) and $validation['type'] == self::PHONE) {
             // Remove all non-digit characters from the number
             $number = preg_replace('/\\D+/', '', $validation[$field]);
             if (strlen($number) < 9) {
                 $validation->error($field, 'invalid_phone');
             }
         } else {
             if (!$validation[$field]) {
                 $validation->error($field, 'invalid_account');
             }
         }
     }
 }
开发者ID:kwameboame,项目名称:platform,代码行数:27,代码来源:Contact.php

示例14: action_index

 /**
  *
  * Loads a basic list info
  * @param string $view template to render 
  */
 public function action_index($view = NULL)
 {
     $this->template->title = __($this->_orm_model);
     $this->template->scripts['footer'][] = 'js/oc-panel/crud/index.js';
     $elements = ORM::Factory($this->_orm_model);
     //->find_all();
     //email search
     if (Valid::email(core::get('email'))) {
         $users = new Model_User();
         $users->where('email', '=', core::get('email'))->limit(1)->find();
         if ($users->loaded()) {
             $elements->where('id_user', '=', $users->id_user);
         }
     }
     $pagination = Pagination::factory(array('view' => 'oc-panel/crud/pagination', 'total_items' => $elements->count_all()))->route_params(array('controller' => $this->request->controller(), 'action' => $this->request->action()));
     $pagination->title($this->template->title);
     $elements = $elements->order_by('created', 'desc')->limit($pagination->items_per_page)->offset($pagination->offset)->find_all();
     $pagination = $pagination->render();
     $this->render('oc-panel/pages/download/index', array('elements' => $elements, 'pagination' => $pagination));
 }
开发者ID:alirezadamash,项目名称:open-eshop,代码行数:25,代码来源:download.php

示例15: action_index

 /**
  * Controller default action
  */
 public function action_index()
 {
     $this->view->title = __('Contact');
     $section = $this->section_contact();
     if (Visitor::$user) {
         $section->name = Visitor::$user->username;
         $section->email = Visitor::$user->email;
     }
     // Handle post
     $errors = array();
     if ($_POST && Security::csrf_valid()) {
         $name = trim(Arr::get($_POST, 'name'));
         $email = trim(Arr::get($_POST, 'email'));
         $subject = trim(Arr::get($_POST, 'subject'));
         $content = trim(Arr::get($_POST, 'content'));
         if (!Valid::email($email)) {
             $errors['email'] = __('Please check the email address');
         }
         if (!$content) {
             $errors['content'] = __('Please say something');
         }
         // Send feedback
         if (!$errors) {
             $topic = __('Feedback') . ': ' . $subject;
             $mail = $content . "\n\n" . Request::$client_ip . ' - ' . Request::host_name();
             if (Anqh_Email::send(Kohana::$config->load('site.email_contact'), array($email, $name), $topic, $mail, false, array($email, $name))) {
                 $this->view->add(View_Page::COLUMN_CENTER, new View_Alert(__('Thank you! We will try to return back to you as soon as possible.'), true, View_Alert::SUCCESS));
             } else {
                 $errors['content'] = __('Could not send feedback');
             }
         }
         if ($errors) {
             $section->errors = $errors;
             $section->name = $name;
             $section->email = $email;
             $section->subject = $subject;
             $section->content = $content;
         }
     }
     $this->view->add(View_Page::COLUMN_CENTER, $section);
 }
开发者ID:anqh,项目名称:anqh,代码行数:44,代码来源:contact.php


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