當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。