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


PHP Request::getClientIP方法代码示例

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


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

示例1: postSignup

 /**
  * Account sign up form processing.
  *
  * @return Redirect
  */
 public function postSignup()
 {
     /************TEMP VARIABLE************/
     /*
      * 0 - Disabled
      * 1 - Enabled and no activation
      * 2 - User activation
      * 3 - Admin activation
      */
     $signupStatus = \Base::getSetting('USER_REGISTRATION');
     /************TEMP VARIABLE************/
     $signupEnabled = $signupStatus != 0;
     $userActivation = $signupStatus == 2;
     $adminActivation = $signupStatus == 3;
     if (!$signupEnabled) {
         return Redirect::to(URL::previous())->withInput()->with('error', Lang::get('base.auth.account.registration_disabled'));
     }
     $rules = array();
     // Declare the rules for the form validation
     foreach (Sentinel::createModel()->getRegisterFields() as $fieldid => $field) {
         $rules[$fieldid] = $field['validator'];
     }
     $rules['g-recaptcha-response'] = 'required';
     // Create a new validator instance from our validation rules
     $validator = Validator::make(Input::all(), $rules);
     $err = false;
     // If validation fails, we'll exit the operation now.
     if ($validator->fails() || ($err = $this->captchaCheck()) == false) {
         if ($err) {
             return Redirect::to(URL::previous())->withInput()->withErrors(['g-recaptcha-response' => Lang::get('base.captcha.error')]);
         }
         // Ooops.. something went wrong
         return Redirect::to(URL::previous())->withInput()->withErrors($validator);
     }
     try {
         $data = array();
         // Set the data to the user from the User class
         foreach (Sentinel::createModel()->getRegisterFields() as $fieldid => $field) {
             $data[$fieldid] = Input::get($fieldid);
         }
         // Set the standard data to the user
         $data['ip'] = Request::getClientIP();
         $data['status'] = 0;
         $data['staff'] = 0;
         if ($data['birthday'] != null) {
             $data['birthday'] = \Carbon\Carbon::createFromFormat('d/m/Y', $data['birthday']);
         }
         // Find the user if it exists and needs to be created
         $user = Sentinel::getUserRepository()->findByCredentials(['email' => Input::get('email')]);
         if ($user != null) {
             // Update the temporary user to the new one
             if (Sentinel::validForUpdate($data, ['email' => Input::get('email')])) {
                 $testing = Sentinel::createModel()->getRegisterFields();
                 $user = Sentinel::findById($user->id);
                 foreach ($data as $fieldid => $field) {
                     if (!isset($testing[$fieldid]) || $testing[$fieldid]['save'] == true) {
                         $user[$fieldid] = $field;
                     }
                 }
                 $user['password'] = bcrypt($user['password']);
                 Sentinel::update($user, ['email' => Input::get('email')]);
             } else {
                 return Redirect::to(URL::previous())->withInput()->with('error', Lang::get('base.auth.account.registration_failed'));
             }
         } else {
             $user = Sentinel::register($data, false);
         }
         // If the user needs to activate the account send him an email
         if ($userActivation) {
             $activation = Activation::create($user);
             // Data to be used on the email view
             $data = array('user' => $user, 'activationUrl' => URL::route('activate', [$user->id, $activation->code]));
             // Send the activation code through email
             Mail::queue('emails.auth.register-activate', $data, function ($m) use($user) {
                 $m->to($user->email, $user->first_name . ' ' . $user->last_name);
                 $m->subject(Lang::get('base.mails.welcome') . ' ' . $user->first_name);
             });
         }
         // If the administrator needs to activate the account send the user a warning saying that
         if ($adminActivation) {
             Mail::queue('emails.auth.register-admin-activate', ['user' => $user], function ($m) use($user) {
                 $m->to($user->email, $user->first_name . ' ' . $user->last_name);
                 $m->subject(Lang::get('base.mails.welcome') . ' ' . $user->first_name);
             });
         }
         // Log the user in
         if (!$adminActivation && !$userActivation) {
             $activation = Activation::create($user);
             if (Activation::complete($user, $activation->code)) {
                 Sentinel::login($user, false);
                 Mail::queue('emails.auth.activated', ['user' => $user], function ($m) use($user) {
                     $m->to($user->email, $user->first_name . ' ' . $user->last_name);
                     $m->subject(Lang::get('base.mails.welcome') . ' ' . $user->first_name);
                 });
             }
//.........这里部分代码省略.........
开发者ID:joaogl,项目名称:base,代码行数:101,代码来源:AuthController.php


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