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


PHP Request::ip方法代码示例

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


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

示例1: upvote

 public function upvote($id, Request $request)
 {
     //upvote reply
     $reply = Reply::find($id);
     //notify commenter
     if (Auth::check()) {
         App('App\\Notification')->notify('reply_upvote', Auth::user(), $reply->user, $reply->article, $reply);
         if ($reply->votes()->ByWhom(Auth::id())->count()) {
             // click twice for remove upvote
             $reply->votes()->ByWhom(Auth::id())->delete();
             $reply->decrement('vote_count', 1);
             $reply->article()->decrement('vote_count', 1);
         } else {
             // first time click
             $reply->votes()->create(['user_id' => Auth::id()]);
             $reply->increment('vote_count', 1);
             $reply->article()->increment('vote_count', 1);
         }
     } else {
         //匿名投票
         App('App\\Notification')->nonamenotify('reply_upvote', $reply->user, $reply->article, $reply);
         if ($reply->votes()->ByWhom($request->ip())->count()) {
             $reply->votes()->ByWhom($request->ip())->delete();
             $reply->decrement('vote_count', 1);
         } else {
             $reply->votes()->create(['user_id' => $request->ip()]);
             $reply->increment('vote_count', 1);
         }
     }
     return $reply->vote_count;
 }
开发者ID:stevejobsii,项目名称:gg,代码行数:31,代码来源:RepliesController.php

示例2: postVote

 public function postVote(Request $request, $id)
 {
     $vote = Vote::find($id);
     if (!$vote->is_active) {
         return redirect('/');
     } else {
         $voted = Voter::where('vote_id', '=', $id)->where('ip', '=', sprintf('%u', ip2long($request->ip())))->count();
         if ($voted) {
             return redirect('auth/logout');
         }
     }
     $inputs = $request->all();
     $voter = new Voter();
     $voter->ip = $request->ip();
     $voter->name = trim($inputs['name']);
     $voter->department = trim($inputs['department']);
     $voter->mobile = str_replace(' ', '', $inputs['mobile']);
     $voter->type_id = $inputs['type'];
     $voter->vote_id = $id;
     if ($voter->save()) {
         Voter::find($voter->id)->nominations()->sync($inputs['vote']);
         return redirect('vote/statistics/' . $id)->with('status', '投票保存成功');
     } else {
         return back()->withErrors('投票保存失败');
     }
 }
开发者ID:rxfu,项目名称:vote,代码行数:26,代码来源:VoteController.php

示例3: login

 public function login(Request $request, Manager $fractal, UserTransformer $userTransformer)
 {
     $validator = \Validator::make($request->all(), ['username' => 'required', 'password' => 'required'], ['required' => 'no-:attribute-provided']);
     if ($validator->fails()) {
         $errors = [];
         foreach ($validator->errors()->all() as $error) {
             $errors[] = $error;
         }
         return $this->setStatusCode(400)->respond(['errors' => $errors]);
     }
     $ipCheck = Login::where(['ip' => $request->ip(), 'valid' => false])->where('time', '>', date('Y-m-d H:i:s', time() - 60 * 60 * 24))->get();
     if (count($ipCheck) > 15) {
         Login::create(['time' => date('Y-m-d H:i:s'), 'ip' => $request->ip(), 'valid' => false]);
         return $this->setStatusCode(403)->respond(['errors' => ['ip-banned']]);
     }
     $user = User::where(['username' => $request->get('username')])->orWhere(['email' => $request->get('username')])->first();
     if (is_null($user)) {
         return $this->setStatusCode(404)->respond(['errors' => ['user-not-found']]);
     }
     $userCheck = Login::where(['user_id' => $user->id, 'valid' => false])->where('time', '>', time() - 60 * 15)->get();
     if (count($userCheck) > 15) {
         return $this->setStatusCode(403)->respond(['errors' => ['user-locked']]);
     }
     if (!\Hash::check($request->get('password'), $user->password)) {
         Login::create(['time' => date('Y-m-d H:i:s'), 'ip' => $request->ip(), 'user_id' => $user->id, 'valid' => false]);
         return $this->setStatusCode(403)->respond(['errors' => ['invalid-password']]);
     }
     $user->session = hash('sha512', uniqid(mt_rand(1, mt_getrandmax()), true));
     $user->session_expire_time = date('Y-m-d H:i:s', time() + 60 * 60);
     $user->update();
     Login::create(['time' => date('Y-m-d H:i:s'), 'ip' => $request->ip(), 'user_id' => $user->id, 'valid' => true]);
     $item = new Item($user, $userTransformer);
     $data = $fractal->setSerializer(new ArraySerializer())->createData($item)->toArray();
     return $this->respond($data);
 }
开发者ID:ashbreeze,项目名称:OmniChain-API,代码行数:35,代码来源:AuthController.php

示例4: Post

 public function Post(Request $request)
 {
     $recaptcha = new \ReCaptcha\ReCaptcha('6LfWHfkSAAAAAMj0Kkhn1FJV6y-RiSZ_M9rasufn');
     $resp = $recaptcha->verify($request->input('g-recaptcha-response'), $request->ip());
     $msgValidation = trim(strip_tags(str_replace(" ", ' ', $request->input('message'))));
     $username = trim(strip_tags(str_replace(" ", ' ', $request->input('name'))));
     $errors = [];
     if (!Auth::check() && strlen($username) < 3) {
         array_push($errors, 'Veuillez saisir un nom d\'utilisateur d\'au moins 3 caractères svp !');
     }
     if (strlen($msgValidation) == 0) {
         array_push($errors, 'Le message est obligatoire !');
     }
     if (!$resp->isSuccess()) {
         array_push($errors, 'Veuillez renseigner le captcha svp !');
     }
     if (count($errors) == 0) {
         $msg = new Message();
         if (Auth::check()) {
             $msg->author_id = $request->user()->id;
         } else {
             $msg->username = $username;
         }
         $msg->message = $msgValidation;
         $msg->remote_addr = $request->ip();
         $msg->save();
         return redirect()->route('minichat');
     }
     Session::flash('errors', $errors);
     return redirect()->route('minichat')->withInput();
 }
开发者ID:kbiyo,项目名称:ARTTv2,代码行数:31,代码来源:MinichatController.php

示例5: rate

 public function rate(Request $request, $id)
 {
     $Quote = Quote::withCount(['ratesPlus', 'ratesMinus'])->find($id);
     if (null == $Quote) {
         return response()->json(['status' => 'error', 'message' => trans('app.not_found')]);
     }
     $count = $Quote->rates_plus_count - $Quote->rates_minus_count;
     $voted = $request->cookie(sha1('voted'));
     $voted = null == $voted ? [] : json_decode($voted);
     if (!empty($voted)) {
         if (in_array($id, $voted)) {
             return response()->json(['status' => 'error', 'message' => trans('app.twice_vote'), 'rate' => $count])->cookie(sha1('voted'), json_encode($voted), 60 * 60 * 24 * 120);
         }
     }
     $voted[] = $id;
     $Rate = Rate::where('quote_id', $id)->where('ip', $request->ip())->first();
     if (null != $Rate) {
         return response()->json(['status' => 'error', 'message' => trans('app.twice_vote'), 'rate' => $count])->cookie(sha1('voted'), json_encode($voted), 60 * 60 * 24 * 120);
     }
     $rate = 1 == strpos($request->getPathInfo(), 'omg') ? 1 : (1 == strpos($request->getPathInfo(), 'wtf') ? -1 : 0);
     $Rate = new Rate();
     $Rate->quote_id = $id;
     $Rate->ip = $request->ip();
     $Rate->rate = $rate;
     $Rate->save();
     $Quote->count += $rate;
     $Quote->save();
     return response()->json(['status' => 'ok', 'message' => trans('app.voted'), 'rate' => $count + $rate])->cookie(sha1('voted'), json_encode($voted), 60 * 60 * 24 * 120);
 }
开发者ID:keymic,项目名称:km-qrs,代码行数:29,代码来源:AppController.php

示例6: getLoginGoogle

 public function getLoginGoogle(Request $request)
 {
     # GET OAUTH DATA
     $oauth = Socialite::driver('google')->user();
     # GET USER
     $user = User::where('email', $oauth->email)->first();
     # LOGIN OR KICK
     if ($user) {
         // # RECORD LOGIN
         $log = new LogLogin();
         $log->user_id = $user->id;
         $log->email = $oauth->email;
         $log->ip = $request->ip();
         $log->result = 'successful';
         $log->save();
         Auth::login($user);
         return redirect()->action('\\Skydiver\\RapydDashboard\\Controllers\\DashboardController@getIndex');
     } else {
         // # RECORD LOGIN
         $log = new LogLogin();
         $log->email = $oauth->email;
         $log->ip = $request->ip();
         $log->result = 'failed';
         $log->save();
         Session::flash('message', array('type' => 'danger', 'msg' => 'No user found.<br>Attempt has been recorded.'));
         return redirect()->action('\\Skydiver\\RapydDashboard\\Controllers\\OAuthController@getSSOLogin');
     }
 }
开发者ID:skydiver,项目名称:rapyd-dashboard,代码行数:28,代码来源:OAuthController.php

示例7: start

 public function start(Request $request)
 {
     if ($request->ajax()) {
         //get ip and store info
         $winner = Winner::where('user_id', '=', $request->ip())->first();
         if (!empty($winner)) {
             $result = ['msg' => '您已经抢过了,不能再抢了哦~', 'cdkey' => $winner->cdkey, 'status' => '2'];
         } else {
             $join = Join::create(['ip' => $request->ip()]);
             //get kucun
             if ($join->id) {
                 $award = Award::find($request->input('event_id'));
                 $result = ['msg' => '恭喜!您抢到了', 'cdkey' => $request->input('event_id'), 'status' => '1'];
                 if ($award->surplus <= 0) {
                     $result = ['msg' => '很遗憾,被抢光了!', 'status' => '0'];
                 } else {
                     //库存-1
                     $award->surplus = $award->surplus - 1;
                     $award->save();
                     //生成cdkey
                     $cdkey = $this->generateCdkey(5);
                     //
                     //保存中奖用户
                     $winner = Winner::create(['user_id' => $request->ip(), 'award_id' => $request->input('award_id'), 'cdkey' => $cdkey, 'event_id' => $request->input('event_id')]);
                     $result = ['msg' => '恭喜!您抢到了', 'cdkey' => $cdkey, 'status' => '1'];
                 }
             }
         }
     }
     return response()->json($result);
 }
开发者ID:nutsdo,项目名称:rp-wechat,代码行数:31,代码来源:EventController.php

示例8: giveCookie

 public function giveCookie(Request $request, $cookieID)
 {
     $cookieObj = ChCookie::find($cookieID);
     $infoArr = ["cookie_id" => $cookieObj->id, "first_login_ip" => $request->ip(), "last_login_ip" => $request->ip(), "ban_level" => 0, "admin_flag" => 0];
     User::create($infoArr);
     $cookieObj->state = 1;
     $cookieObj->save();
 }
开发者ID:VOID001,项目名称:NEUP-channel,代码行数:8,代码来源:UserController.php

示例9: log

 public function log($message)
 {
     // if the even is system generated, then add 0 as user id
     // and mark it system event
     if (Auth::guest()) {
         $userId = 1;
         $message = 'System event: ' . $message;
     } else {
         $userId = Auth::user()->id;
     }
     $this->activity->log(['description' => $message, 'user_id' => $userId, 'ip_address' => $this->request->ip(), 'user_agent' => $this->getUserAgent()]);
 }
开发者ID:amitavroy,项目名称:mywall,代码行数:12,代码来源:Logger.php

示例10: store

 public function store(Request $request)
 {
     if ($request->ajax()) {
         parse_str($request->data, $input);
     } else {
         $input = $request->all();
     }
     $rules = ['fullname' => 'required|farsi|min:3|max:150', 'email' => 'required|email|min:5|max:150', 'tel' => 'required|digits_between:8,15', 'des' => 'required|min:10|max:500'];
     $validator = Validator::make($input, $rules);
     if ($validator->fails()) {
         if ($request->ajax()) {
             return response()->json(['result' => 'error', 'errors' => $validator->errors()]);
         } else {
             return back()->withInput()->withErrors($validator);
         }
     } else {
         $supportticket = Support::where('ip', $request->ip())->whereRaw('UTC_TIMESTAMP() <= TIMESTAMP(created_at + INTERVAL ' . config('app.support_throttle') . ')')->count();
         if ($supportticket > 0) {
             if ($request->ajax()) {
                 return response()->json(['result' => 'wait']);
             } else {
                 return redirect()->home()->with('fail', 'شما لحظاتی پیش یک پیام با موفقیت ارسال کرده اید، لطفا بعدا تلاش کنید.');
             }
         } else {
             # Create Support
             $support = new Support();
             $support->fullname = $input['fullname'];
             $support->email = $input['email'];
             $support->tel = $input['tel'];
             $support->description = $input['des'];
             $support->ip = $request->ip();
             # Redirect on Success
             if ($support->save()) {
                 Mail::send('emails.support', ['support' => $support], function ($message) use($support) {
                     $message->from(config('app.info_email'), 'کامت');
                     $message->sender(config('app.info_email'), 'کامت');
                     $message->to($support->email, $support->fullname)->subject('گروه طراحی و توسعه کامت');
                     $message->replyTo(config('app.support_email'), 'کامت');
                 });
                 if ($request->ajax()) {
                     return response()->json(['result' => 'success']);
                 } else {
                     return redirect()->home()->with('success', 'پیام شما با موفقیت ثبت شد.');
                 }
             }
         }
     }
     if ($request->ajax()) {
         return response()->json(['result' => 'fail']);
     } else {
         return back()->withInput()->with('fail', 'مشکل در اتصال به سرور. لطفا مجددا تلاش کنید.');
     }
 }
开发者ID:majid-n,项目名称:cometdev,代码行数:53,代码来源:SupportController.php

示例11: handle

 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request        	
  * @param \Closure $next        	
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $ignore = ['222.20.35.168', '127.0.0.1'];
     if (array_search($request->ip(), $ignore) === false) {
         $ip = $request->ip();
         $path = $request->path();
         $view = new View();
         $view->ip = $ip;
         $view->url = $path;
         $view->location = GeoipParser::parse($ip);
         $view->save();
     }
     return $next($request);
 }
开发者ID:roslairy,项目名称:roslairy,代码行数:21,代码来源:ViewWatch.php

示例12: store

 public function store(Request $request)
 {
     $user = $request->all();
     $companyId = Auth::user()->company_id;
     $cn = \App\Company::where('id', '=', $companyId)->first();
     if (!empty($request->input('email'))) {
         $referee = new References();
         $referee->company_id = Auth::user()->company_id;
         $referee->code = str_random(40);
         $referee->first_name = $request->input('first_name');
         $referee->last_name = $request->input('surname');
         $referee->referee_name = $request->input('name');
         $referee->referee_company = $request->input('company_name');
         $referee->referee_email = $request->input('email');
         $referee->reference_only = '1';
         //$referee->re_employ = $request->input('re_employ');
         $referee->ip_address = $request->ip();
         $referee->referee_contact = $request->input('contact');
         $referee->save();
         $data = array('email' => $request->input('email'), 'name' => $request->input('name'), 'worker' => $request->input('first_name') . ' ' . $request->input('surname'), 'company' => $cn->name, 'code' => $referee->code);
         // Send the email
         Mail::send('emails/references/request', $data, function ($message) use($data) {
             $message->to($data['email'])->from('noreply@madesimpleapp.co.uk')->subject('You have been selected to provide a reference');
         });
     }
     if (!empty($request->input('email2'))) {
         $refereetwo = new References();
         $refereetwo->company_id = Auth::user()->company_id;
         $refereetwo->first_name = $request->input('first_name');
         $refereetwo->last_name = $request->input('surname');
         $refereetwo->code = str_random(40);
         $refereetwo->referee_name = $request->input('name2');
         $refereetwo->referee_company = $request->input('company_name2');
         $refereetwo->referee_email = $request->input('email2');
         $refereetwo->referee_contact2 = $request->input('contact2');
         $refereetwo->completedtwo = 'No';
         $refereetwo->reference_only = '1';
         $refereetwo->ip_address = $request->ip();
         $refereetwo->save();
         $data = array('emailtwo' => $request->input('email2'), 'name' => $request->input('name2'), 'worker' => $request->input('first_name') . ' ' . $request->input('surname'), 'company' => $cn->name, 'code' => $refereetwo->code);
         // Send the email
         Mail::send('emails/references/request2', $data, function ($message) use($data) {
             $message->to($data['emailtwo'])->from('noreply@madesimpleapp.co.uk')->subject('You have been selected to provide a reference');
         });
     }
     flash()->success('Success', 'Reference request has been sent');
     return redirect('/references');
 }
开发者ID:wyrover,项目名称:applications,代码行数:48,代码来源:ReferencesController.php

示例13: handle

 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($request->ip() == '::1') {
         return $next($request);
     }
     return response('Unauthorized.', 401);
 }
开发者ID:alexisAvenel,项目名称:portfolioLaravel,代码行数:14,代码来源:Ip.php

示例14: handle

 /**
  * Handle the command.
  *
  * @param InviteModel $invites
  * @param Request $request
  * @param Dispatcher $events
  * @return array
  */
 public function handle(InviteModel $invites, Request $request, Dispatcher $events)
 {
     $user['ip_address'] = $request->ip();
     // Slack configurations
     $slackTeam = config('anomaly.extension.slack_inviter::slack.team');
     $slackToken = config('anomaly.extension.slack_inviter::slack.token');
     $slackChannels = config('anomaly.extension.slack_inviter::slack.channels');
     if (!$slackToken) {
         throw new \Exception("Slack API has not been configured. Missing 'anomaly.extension.slack_inviter::slack.auth_token'");
     }
     $slackInviteUrl = 'https://' . $slackTeam . '.slack.com/api/users.admin.invite?t=' . time();
     $fields = array('email' => $user['email'] = $this->builder->getFormValue('email'), 'first_name' => urlencode($user['name'] = $this->builder->getFormValue('name')), 'channels' => $slackChannels, 'token' => $slackToken, 'set_active' => true, '_attempts' => '1');
     // Open the connection.
     $ch = curl_init();
     // set the url, number of POST vars, POST data
     curl_setopt($ch, CURLOPT_URL, $slackInviteUrl);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_POST, count($fields));
     curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($fields));
     // Execute the request.
     $reply = json_decode(curl_exec($ch), true);
     if ($reply['ok'] == false) {
         $user['error'] = $reply['error'];
     } else {
         $user['successful'] = true;
     }
     // Close the connection.
     curl_close($ch);
     $events->fire(new SlackInviteWasSent($invites->create($user)));
     return $reply;
 }
开发者ID:anomalylabs,项目名称:slack_inviter-extension,代码行数:39,代码来源:SendInvite.php

示例15: get_item

 public function get_item(Request $request, $q_id)
 {
     $query = new Question();
     if (Gate::allows('admin')) {
         $query = $query->withTrashed();
     }
     $q = $query->with('writer.socials')->with('tags')->with('viewCounts')->with(['answers' => function ($query) {
         // 답변은 점수 높은 순으로 정렬
         $query->selectRaw('qna_answers.*, COALESCE(SUM(qna_votes.grade),0) AS total_grade')->leftJoin('qna_votes', function ($join) {
             $join->on('qna_answers.id', '=', 'qna_votes.votable_id')->on('qna_votes.votable_type', '=', \DB::raw("'ModernPUG\\\\Qna\\\\Models\\\\Answer'"));
         })->groupBy('qna_answers.id')->orderBy('total_grade', 'desc')->with('writer.socials')->with('comments.writer.socials')->with('comments.votes')->with('votes');
     }])->with('votes')->with('comments.writer.socials')->with('comments.votes')->find($q_id);
     if (!$q) {
         abort(404);
     }
     // 조회수 증가
     ViewCount::create(['q_id' => $q->id, 'ip' => $request->ip(), 'user_id' => Auth::check() ? Auth::user()->id : 0]);
     // 메타 지정
     $desc = strip_tags($q->md_content);
     $desc = str_replace("\r\n", "\n", $desc);
     $desc = str_replace("\r", " ", $desc);
     $desc = str_replace("\n", " ", $desc);
     $desc = $this->limit_words($desc, 30);
     config(['title' => $q->title]);
     config(['author' => $q->writer->name]);
     config(['description' => $desc]);
     config(['keywords' => $q->tagsString]);
     config(['og:title' => $q->title]);
     config(['og:description' => $desc]);
     return view('ncells::qna.pages.item', ['q' => $q]);
 }
开发者ID:ninecells,项目名称:cell-qna,代码行数:31,代码来源:QController.php


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