This method can read the client IP address from the "X-Forwarded-For" header
when trusted proxies were set via "setTrustedProxies()". The "X-Forwarded-For"
header value is a comma+space separated list of IP addresses, the left-most
being the original client, and each successive proxy that passed the request
adding the IP address where it received the request from.
If your reverse proxy uses a different header name than "X-Forwarded-For",
("Client-Ip" for instance), configure it via "setTrustedHeaderName()" with
the "client-ip" key.
public static getClientIp ( ) : string | ||
return | string | The client IP address |
/** * Constructor. * @version 0.9.3 * */ public function registerModules() { $this->translator = $this->getTranslator(); $this->aesencoder = new AES256(); $this->request = $this->getRequest(); $this->userip = $this->request->getClientIp(); }
public function login() { Config::set('database.default', Input::get('server')); $db = Input::get('server'); $credentials = array('memb___id' => Input::get('id'), 'password' => Input::get('pass'), 'bloc_code' => 0); $ip = Request::getClientIp(); $suspect = LoginAttempt::find($ip); if (is_null($suspect)) { $newlogin = new LoginAttempt(); $newlogin->ip = $ip; $newlogin->attempt = 1; $newlogin->save(); if (Auth::attempt($credentials)) { Session::put('db', $db); $webuser_id = Auth::user()->webuser_id; if ($webuser_id != 0) { Session::put('WebUserId', $webuser_id); } return Redirect::to(Input::get('url'))->with('message', 'Bạn đã đăng nhập thành công!'); } else { return Redirect::to(Input::get('url'))->with('message', 'Thông tin tài khoản không chính xác!')->withError(10); } } else { $updated_at = $suspect->updated_at; $attempt = $suspect->attempt; $nowless5 = date('Y-m-d H:i:s', time() - 300); if ($updated_at > $nowless5) { if ($suspect->attempt > 5) { return Redirect::to(Input::get('url'))->with('message', 'Wait another 5 minutes to login!')->withError(10); } else { if (Auth::attempt($credentials)) { Session::put('db', $db); $webuser_id = Auth::user()->webuser_id; if ($webuser_id != 0) { Session::put('WebUserId', $webuser_id); } return Redirect::to(Input::get('url'))->with('message', 'Bạn đã đăng nhập thành công!'); } else { $suspect->attempt = $suspect->attempt + 1; $suspect->save(); return Redirect::to(Input::get('url'))->with('message', 'Thông tin tài khoản không chính xác!')->withError(10); } } } else { if (Auth::attempt($credentials)) { Session::put('db', $db); $webuser_id = Auth::user()->webuser_id; if ($webuser_id != 0) { Session::put('WebUserId', $webuser_id); } return Redirect::to(Input::get('url'))->with('message', 'Bạn đã đăng nhập thành công!'); } else { $suspect->attempt = 1; $suspect->save(); $suspect->touch(); return Redirect::to(Input::get('url'))->with('message', 'Thông tin tài khoản không chính xác!')->withError(10); } } } }
public function postRegistroEmpresas() { DB::beginTransaction(); try { $empresa = new LandingEmpresa(); $empresa->razon_social = ucwords(strtolower(Input::get('empresa_razonsocial'))); $empresa->ruc = Input::get('empresa_ruc'); $empresa->inscritos = Input::get('empresa_inscritos'); $empresa->domicilio = Input::get('empresa_domicilio'); $empresa->email = Input::get('empresa_email'); $empresa->telefono = Input::get('empresa_telefono'); $empresa->celular = Input::get('empresa_celular'); $empresa->curso = Input::get('empresa_curso'); $empresa->comentario = Input::get('empresa_comentario'); $empresa->recibir_noticias = Input::get('empresa_informacion'); $empresa->ip = Request::getClientIp(true); $empresa->save(); $respuesta = array('status' => 'ok'); DB::commit(); } catch (\Exception $e) { DB::rollback(); $respuesta = array('status' => 'error', 'messages' => 'Exception with msg: ' . $e->getMessage()); } return Response::json($respuesta, 200); }
public function login() { if (Request::isMethod('get')) { $company = DB::table('tb_global_settings')->where('name', 'company')->first(); $product = DB::table('tb_product')->join('tb_global_settings', function ($join) { $join->on('tb_product.name', '=', 'tb_global_settings.value')->where('tb_global_settings.name', '=', 'product'); })->select('tb_product.description')->first(); return View::make('login.login')->with('product', ($company ? $company->value : '') . ($product ? $product->description : '')); } else { if (Request::isMethod('post')) { $ip_string = Request::getClientIp(true); $user = array('username' => Input::get('username'), 'password' => Input::get('password')); $remember = Input::has('remember_me') ? true : false; if (false !== ($msg = SysAccountFrozenController::isFrozenIp($ip_string))) { return Redirect::to('/login')->with('login_error_info', '禁止登录!此IP(' . $ip_string . ')已被冻结!<br/>' . $msg); } if (false === SysAccountController::isInBindip($user['username'], $ip_string)) { return Redirect::to('/login')->with('login_error_info', '禁止登录!此账户已绑定IP!'); } if (Auth::attempt($user, $remember)) { SysAccountFrozenController::delRecord($ip_string); return Redirect::to('/')->with('login_ok_info', $user['username'] . '登录成功'); } else { SysAccountFrozenController::appendRecord($ip_string); return Redirect::to('/login')->with('login_error_info', '用户名或者密码错误')->withInput(); } } else { return Response::make('访问login页面的方法只能是GET/POST方法!', 404); } } }
public function postEdit($id) { if (!$this->checkRoute()) { return Redirect::route('index'); } $title = 'Edit A Modpack Code - ' . $this->site_name; $input = Input::only('code', 'launcher', 'modpack'); $modpackcode = ModpackCode::find($id); $messages = ['unique' => 'A code for this launcher/modpack combination already exists in the database!']; $validator = Validator::make($input, ['code' => 'required|unique:modpack_codes,code,' . $modpackcode->id, 'launcher' => 'required', 'modpack' => 'required'], $messages); if ($validator->fails()) { // TODO this line originally redirects to modpack-code/edit, there's no route for this, is this an error? return Redirect::action('ModpackCodeController@getEdit', [$id])->withErrors($validator)->withInput(); } $modpackcode->code = $input['code']; $modpackcode->modpack_id = $input['modpack']; $modpackcode->launcher_id = $input['launcher']; $modpackcode->last_ip = Request::getClientIp(); $success = $modpackcode->save(); if ($success) { Cache::tags('modpacks')->flush(); Queue::push('BuildCache'); return View::make('modpackcodes.edit', ['title' => $title, 'success' => true, 'modpackcode' => $modpackcode]); } return Redirect::action('ModpackCodeController@getEdit', [$id])->withErrors(['message' => 'Unable to add modpack code.'])->withInput(); }
public function logoutAction() { // Log out if (Auth::User()) { $user = new Usernhc(); $user_id = Auth::User()->id; $user_info = $user->getUsernhcById($user_id); $logs = new Logs(); $logs->ip = Request::getClientIp(); $logs->host = Request::root(); $logs->lastpage = ''; $logs->last_visit = date('Y-m-d H:i:s'); $logs->role_id = $user_info[0]->role_id; $logs->data_id = rand(1, 11); $logs->userid = $user_id; $logs->save(); } // Redirect to homepage if (Auth::logout()) { Auth::logout(); return Redirect::to('login')->with('success', 'ออกจากระบบสำเร็จ'); } else { return Redirect::to('login')->with('success', 'ออกจากระบบสำเร็จ'); } }
public function run() { User::truncate(); $user = User::create(array("username" => "danielheyman", "name" => "Daniel Heyman", "email" => "*****@*****.**", "password" => "hello", "newsletter" => true, "admin_emails" => true, "membership" => "platinum", "admin" => true, "paypal" => "", "membership_expires" => Carbon::now()->addMonth(), "referrals" => 0, "upline" => "", "cash" => 0, "credits" => 0, "credits_today" => 0, "views_total" => 0, "views_today" => 0, 'auto_assign' => 0, 'register_ip' => Request::getClientIp(), 'last_login' => Carbon::now())); register_event($user, Request::getClientIp(), "http://activation.link"); login_event($user); }
public function run() { $now = date('Y-m-d H:i:s'); //DB::table('users')->delete(); $users = [['group_id' => 5, 'username' => 'nick', 'fullname' => 'Nicholas Law', 'active' => 1, 'email' => '*****@*****.**', 'email_verified' => 1, 'password' => Hash::make('nl511988'), 'ip_address' => Request::getClientIp(), 'gender' => 'male', 'country' => 'Australia', 'created_at' => $now, 'updated_at' => $now], ['group_id' => 5, 'username' => 'demo', 'fullname' => 'Demo Account', 'active' => 1, 'email' => '*****@*****.**', 'email_verified' => 1, 'password' => Hash::make('demo'), 'ip_address' => Request::getClientIp(), 'gender' => 'male', 'country' => 'United States', 'created_at' => $now, 'updated_at' => $now], ['group_id' => 5, 'username' => 'test', 'fullname' => 'John Doe', 'active' => 1, 'email' => '*****@*****.**', 'email_verified' => 1, 'password' => Hash::make('test'), 'ip_address' => Request::getClientIp(), 'gender' => 'male', 'country' => 'United States', 'created_at' => $now, 'updated_at' => $now]]; DB::table('users')->insert($users); }
public function recordLogout() { if ($oLogin = Login::lastLoginWithIpAndSession(\Request::getClientIp(), \Session::getId())->first()) { $oLogin->logout(); } return true; }
protected static function boot() { parent::boot(); static::saving(function ($model) { $model->remote_addr = \Request::getClientIp(); }); }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { $validation = Validator::make($input = Input::all(), Blink::$rules); if ($validation->passes()) { $imgFld = Blink::GenerateFolder(); $mime = Input::file('item')->getMimeType(); $extension = Input::file('item')->getClientOriginalExtension(); $fileType = FileType::whereRaw("LOWER(mimetype)='" . strtolower($mime) . "'")->firstOrFail(); $input["file_type_id"] = $fileType->id; $tempF = tempnam($imgFld, ''); $tempF = str_replace(".tmp", "", basename($tempF)); Input::file('item')->move($imgFld, $tempF . "." . $extension); $input["file_location"] = $imgFld . $tempF . "." . $extension; $input["upload_ip"] = Request::getClientIp(); $c = 0; $token = Blink::getToken(10); $uniqueC = Blink::where("url_token", "=", $token)->whereNull("expired_at")->count(); while ($uniqueC > 0 && $c < 20) { $c++; $token = Blink::getToken(10); $uniqueC = Blink::where("url_token", "=", $token)->whereNull("expired_at")->whereNull("deleted_at")->count(); } $input["url_token"] = $token; $blink = Blink::create($input); $base = SysVariable::Get(SysVariable::$shorten_url); echo $base . $blink->url_token; //return Redirect::route('blinks.index'); } /*return Redirect::route('blinks.create') ->withInput() ->withErrors($validation) ->with('message', 'There were validation errors.');*/ }
public function run() { Banner::truncate(); Website::truncate(); $user = User::create(array("username" => "danheyman", "name" => "Daniel Heyman", "email" => "*****@*****.**", "password" => "hello", "newsletter" => true, "admin_emails" => true, "membership" => "platinum", "paypal" => "", "membership_expires" => Carbon::now()->addMonth(), "referrals" => 0, "upline" => "", "cash" => 0, "credits" => 0, "credits_today" => 0, "views_total" => 0, "views_today" => 0, 'auto_assign' => 0, 'register_ip' => Request::getClientIp(), 'last_login' => Carbon::now())); for ($x = 0; $x < 20; $x++) { $website = new Website(); $website->url = "http://listviral.com"; $website->enabled = true; $website->credits = 10000; $website->views = 0; $website->days = array(); $website->hours = array(); $user->websites()->save($website); $banner = new Banner(); $banner->banner = "http://brisksurf.com/banner.png"; $banner->url = "http://brisksurf.com"; $banner->enabled = true; $banner->credits = 10000; $banner->views = 0; $banner->days = array(); $banner->hours = array(); $user->banners()->save($banner); } }
/** * Initialize a new cart in the DB * * @return int id of the current cart */ function initCart() { $cart = new Cart(array('began_shopping_at' => date('Y-m-d H:i:s'), 'ip' => \Request::getClientIp())); $cart->save(); Session::set('carty.cart_id', $cart->id); return $cart->id; }
/** * Store a newly created resource in storage. * POST /usuarios * * @return Response */ public function store() { $validator = Validator::make(Input::all(), ['id' => 'required', 'first_name' => 'required|min:3', 'last_name' => 'required|min:3', 'email' => 'required|email', 'access_token' => 'required', 'expire_token' => 'required', 'gender' => 'required']); if ($validator->fails()) { return $this->reponseApi(200, 'true', $validator->errors()->all()); } $response = array(); #Crear instancia modelo usuario $usuario = new Usuario(); #Si registra desde otro metodo $exists = $usuario->existsByFuid(Input::get('id')); if ($exists === null) { $arrUserAdd = array("fbuid" => Input::get('id'), "firstname" => Input::get('first_name'), "lastname" => Input::get('last_name'), "email" => Input::get('email'), "genero" => Input::get('gender'), "ip" => Request::getClientIp(), "complete" => 0, "meta" => json_encode(array("link" => Input::get('link'), "locale" => Input::get('locale'), "name" => Input::get('name'), "timezone" => Input::get('timezone'), "updated_time" => Input::get('updated_time'), "username" => Input::get('username'))), "access_token" => Input::get('access_token'), "expire_token" => Input::get('expire_token')); $usuario_id = $usuario->saveUsuario($arrUserAdd); if ($usuario_id) { return $this->reponseApi(201, 'false', '', array('id' => $usuario_id, 'token' => Input::get('access_token'))); } else { return $this->reponseApi(200, 'true', 'Error al guardar', array('code' => 100)); } } else { $exists->updated_at = date('Y-m-d H:i:s'); $exists->access_token = Input::get('access_token'); $exists->expire_token = Input::get('expire_token'); $exists->save(); return $this->reponseApi(200, 'false', '', array('id' => $exists->id, 'token' => Input::get('access_token'))); } }
public function beforeCreate() { $this->login_at = new Carbon(); $this->ip = \Request::getClientIp(); $this->session_id = \Session::getId(); return true; }
public function get_click($id) { //Are we even working with a number? if (!is_numeric($id)) { //Yikes let's get the hell out of here App::abort(404, 'Invalid click link'); } //Now to pull our VA record or fail $va = User::find($id); if (empty($va)) { return Redirect::to('/')->with('topmessage', 'Sorry, that VA URL could not be located. Please try again and open a ticket if you continue experiencing the same issue.'); } //Great a VA exists, let's make sure to add one to their clicks if this IP hasn't added a click within the last minute. $existingClick = Click::where('ip', '=', Request::getClientIp())->orderBy('created_at', 'DESC')->first(); if (!empty($existingClick)) { $lastClickByIp = strtotime($existingClick->created_at); if (time() - $lastClickByIp > 60) { //No click found by the same IP in the last 60 seconds thus we should add this one $click = new Click(); $click->vid = $id; $click->ip = Request::getClientIp(); $click->save(); } } else { //No click found by that same IP at all. Let's insert into the DB $click = new Click(); $click->vid = $id; $click->ip = Request::getClientIp(); $click->save(); } //Finally redirect the user to the VA URL return Redirect::to($va->url); }
public function newComment() { // POST İLE GÖNDERİLEN DEĞERLERİ ALALIM. $postData = Input::all(); // FORM KONTROLLERİNİ BELİRLEYELİM $rules = array('question_id' => 'required|integer', 'comment' => 'required'); // HATA MESAJLARINI OLUŞTURALIM $messages = array('question_id.required' => 'İşleminiz yapılırken teknik bir sorun oluştu', 'question_id.integer' => 'İşleminiz yapılırken teknik bir sorun oluştu', 'comment.required' => 'Lütfen yanıtınızı yazın'); // KONTROL (VALIDATION) İŞLEMİNİ GERÇEKLEŞTİRELİM $validator = Validator::make($postData, $rules, $messages); // EĞER VALİDASYON BAŞARISIZ OLURSA HATALARI GÖSTERELİM if ($validator->fails()) { // KULLANICIYI SORU SAYFASINA GERİ GÖNDERELİM return Redirect::to(URL::previous())->withErrors($validator->messages()); } else { // SORUYU VERİTABANINA EKLEYELİM $comment = new Comments(); $comment->user_id = Auth::user()->id; $comment->question_id = $postData['question_id']; $comment->comment = e(trim($postData['comment'])); $comment->created_at = date('Y-m-d H:i:s'); $comment->created_ip = Request::getClientIp(); $comment->save(); // KULLANICIYI YENİDEN SORUYA YÖNLENDİRELİM return Redirect::to(URL::previous()); } }
public function postEdit($id) { if (!$this->checkRoute()) { return Redirect::route('index'); } $title = 'Edit A Modpack Creator - ' . $this->site_name; $creator = Creator::find($id); $input = Input::only('name', 'deck', 'website', 'donate_link', 'bio', 'slug'); $messages = ['unique' => 'The modpack creator already exists in the database.', 'url' => 'The :attribute field is not a valid URL.']; $validator = Validator::make($input, ['name' => 'required|unique:creators,name,' . $creator->id, 'website' => 'url', 'donate_link' => 'url'], $messages); if ($validator->fails()) { return Redirect::action('CreatorController@getAdd')->withErrors($validator)->withInput(); } $creator->name = $input['name']; $creator->deck = $input['deck']; $creator->website = $input['website']; $creator->donate_link = $input['donate_link']; $creator->bio = $input['bio']; if ($input['slug'] == '' || $input['slug'] == $creator->slug) { $slug = Str::slug($input['name']); } else { $slug = $input['slug']; } $creator->slug = $slug; $creator->last_ip = Request::getClientIp(); $success = $creator->save(); if ($success) { return View::make('creators.edit', ['title' => $title, 'creator' => $creator, 'success' => true]); } return Redirect::action('CreatorController@getEdit', [$id])->withErrors(['message' => 'Unable to edit modpack creator.'])->withInput(); }
public function postEdit($id) { if (!$this->checkRoute()) { return Redirect::route('index'); } $title = 'Edit A Modpack Code - ' . $this->site_name; $input = Input::only('name', 'deck', 'description', 'slug'); $modpacktag = ModpackTag::find($id); $messages = ['unique' => 'This modpack tag already exists in the database!']; $validator = Validator::make($input, ['name' => 'required|unique:modpack_tags,name,' . $modpacktag->id, 'deck' => 'required'], $messages); if ($validator->fails()) { return Redirect::action('ModpackTagController@getEdit', [$id])->withErrors($validator)->withInput(); } $modpacktag->name = $input['name']; $modpacktag->deck = $input['deck']; $modpacktag->description = $input['description']; $modpacktag->last_ip = Request::getClientIp(); if ($input['slug'] == '' || $input['slug'] == $modpacktag->slug) { $slug = Str::slug($input['name']); } else { $slug = $input['slug']; } $modpacktag->slug = $slug; $success = $modpacktag->save(); if ($success) { Cache::tags('modpacks')->flush(); Queue::push('BuildCache'); return View::make('tags.modpacks.edit', ['title' => $title, 'success' => true, 'modpacktag' => $modpacktag]); } return Redirect::action('ModpackTagController@getEdit', [$id])->withErrors(['message' => 'Unable to edit modpack code.'])->withInput(); }
public function __construct() { $this->userIp = class_exists('\\Illuminate\\Support\\Facades\\Request') ? \Request::getClientIp() : $_SERVER['REMOTE_ADDR']; $this->userAgent = class_exists('\\Illuminate\\Support\\Facades\\Request') ? \Request::server('HTTP_USER_AGENT') : $_SERVER['HTTP_USER_AGENT']; $this->referrer = class_exists('\\Illuminate\\Support\\Facades\\URL') ? \URL::previous() : $_SERVER['HTTP_REFERER']; $this->permalink = class_exists('\\Illuminate\\Support\\Facades\\Request') ? \Request::url() : $_SERVER['REQUEST_URI']; }
public function newQuestion() { // POST İLE GÖNDERİLEN DEĞERLERİ ALALIM. $postData = Input::all(); // FORM KONTROLLERİNİ BELİRLEYELİM $rules = array('title' => 'required|between:3,256', 'content' => 'required'); // HATA MESAJLARINI OLUŞTURALIM $messages = array('title.required' => 'Lütfen sorunuzun başlığını yazın', 'title.between' => 'Soru başlığı minumum 3 maksimum 256 karakterden oluşabilir', 'content.required' => 'Lütfen sorunuza ait detayları yazın'); // KONTROL (VALIDATION) İŞLEMİNİ GERÇEKLEŞTİRELİM $validator = Validator::make($postData, $rules, $messages); // EĞER VALİDASYON BAŞARISIZ OLURSA HATALARI GÖSTERELİM if ($validator->fails()) { // HATA MESAJLARI VE INPUT DEĞERLERİYLE FORMA YÖNLENDİRELİM return Redirect::route('newQuestionForm')->withInput()->withErrors($validator->messages()); } else { // SORUYU VERİTABANINA EKLEYELİM $question = new Questions(); $question->user_id = Auth::user()->id; $question->title = e(trim($postData['title'])); $question->content = e(trim($postData['content'])); $question->created_at = date('Y-m-d H:i:s'); $question->created_ip = Request::getClientIp(); $question->save(); // KULLANICIYI SORULARIN LİSTELENDİĞİ SAYFAYA YÖNLENDİRELİM return Redirect::route('allQuestions'); } }
public function getError($exception, $code) { // for local testing and getting error emails just make not sign remove, i.e: if(Config::get('app.debug')) if (!Config::get('app.debug')) { // From where user is coming $previous_url = URL::previous(); //The above one is for Laravel, you can use this also in PHP projects $previous_url = $_SERVER['HTTP_REFERER']; //User IP address $ip = Request::getClientIp(); //The above one is for Laravel, you can use this also in PHP projects $ip = $_SERVER['REMOTE_ADDR']; // Get requested URL, Date and Time. $url = Request::url(); $now = new DateTime(); $errorDate = date_format($now, 'l, d-M-Y => H:i:s T'); // Getting browser Info from models/Error404 class. $browserInfo = Error404::getBrowser(); $browserName = $browserInfo['name']; $browserVersion = $browserInfo['version']; $platform = $browserInfo['platform']; // Getting Location Info passing the ip address to the function in models/Error404 class. $ipInfo = Error404::getIp($ip); $country = $ipInfo['country']; $state = $ipInfo['state']; $town = $ipInfo['town']; //generate more Info in mail-subject, for example for multiple web sites you can change MY Web to the name of your web $subject = 'My Web Error : '; // Log the info if you want to... Log::info("###### My Web ERROR ######"); Log::info("IP: {$ip}"); Log::info("URL: {$url}"); Log::info("Date and Time: {$errorDate}"); Log::info("Browser Name/Version: {$browserName} / {$browserVersion}"); Log::info("Visitor's Country, State and City: {$country}, {$state}, {$town}"); Log::info("Visitor coming from: {$previous_url}"); Log::info("###### !ERROR ######\n"); //Creating the final message to send via E-mail to web-admin $message = "###### ERROR ###### <br/>\n Error Code: <b>{$code}</b> <br/>\n IP: {$ip} <br/>\n URL: {$url} <br/>\n Date and Time: {$errorDate} <br/>\n Browser Name/Version: {$browserName} / {$browserVersion} <br/>\n Operating System: {$platform} <br/>\n Visitor's Country, State and City: {$country}, {$state}, {$town} .<br/>\n Visitor coming from: {$previous_url} <br/>"; if ($code != 404) { $message .= "Exeption:<br/>{$exception}<br/>"; $subject .= " php_error : {$code}"; } else { $subject .= ' Route missing'; } $message .= "###### !ERROR ######"; // Sending Error Report via E-mail -> Please edit this and enter your email receiving and sending e-mail address try { Mail::send('emails.error_email', array('var' => $message), function ($message) use($subject) { $message->to('*****@*****.**')->from('*****@*****.**')->subject("{$subject}"); }); } catch (Exception $e) { Log::info("{$e}\n"); } $headline = "OOPS! YOU DON'T WANT TO BE HERE"; // $headline is the line you want to display on the page. // Finally after reciving error email and loging the information show the HTML page to user you created for end-user. return View::make('view/error')->withCode($code)->withHeadline($headline); } //Closing of if(app.debug) }
public function crearEncuesta($encuesta, $email, $nombre = 'sin dato', $empresa = 'sin dato') { if (Session::token() != Input::get('_token')) { die; } $respuesta = Input::all(); //array respuestas form //print_r($respuesta); $datosEncuesta = DB::table('encuesta')->where('id', $encuesta)->first(); $cantidad = DB::table('pregunta')->where('idEncuesta', $encuesta)->count(); //Inserta usuario por email e ip $ip = Request::getClientIp(); $usuariosEmail = DB::table('users')->where('email', $email)->first(); //codigo rand /*$usuariosEmail = DB::table('users')->where('email', $email)->first(); $base = 1245; $cant= DB::table('users')->count(); $random = $base + $cant;*/ if (empty($usuariosEmail)) { $x = new User(); $x->email = $email; $x->nombre = $nombre; $x->empresa = $empresa; $x->ip = $ip; $x->codigo = ''; $x->save(); //codigo $usuarios = DB::table('users')->where('email', $email)->first(); $usuario = $usuarios->id; $codigo = '12' . $usuario; DB::table('users')->where('id', $usuario)->update(array('codigo' => $codigo)); } else { $mensaje = 'Usted ya ha completado la encuesta, sólo puede realizar esta acción una vez'; return View::make('encuesta.completado', array('mensaje' => $mensaje, 'encuesta' => $datosEncuesta)); } $usuarios = DB::table('users')->where('email', $email)->first(); $usuario = $usuarios->id; $codigo = $usuarios->codigo; Session::put('codigo', $codigo); //Inserta usuario_encuesta $x = new UsuarioEncuesta(); $x->idUsuario = $usuario; $x->idEncuesta = $encuesta; $x->save(); $usuarioEnc = DB::table('usuario_encuesta')->where('idUsuario', $usuario)->first(); $usuarioEncuesta = $usuarioEnc->id; //Inserta respuestas for ($i = 1; $i <= $cantidad; $i++) { $valor = Input::get('pregunta' . $i); if ($valor != '') { $x = new Respuesta(); $x->idUsuarioEncuesta = $usuarioEncuesta; $x->idEncuestaPregunta = $i; $x->valor = $valor; $x->save(); } } return Redirect::to('/formulario-ok'); //return View::make('encuesta.completado', array('encuesta' => $datosEncuesta,'email' => $email, 'nombre' => $nombre, 'empresa' => $empresa, 'codigo' => $random)); }
/** * Handle the event. * * @param Events $event * @return void */ public function handle(User $user, $remember) { \Auth::user()->last_login = \Auth::user()->last_login_now; \Auth::user()->last_login_ip = \Auth::user()->last_login_ip_now; \Auth::user()->last_login_now = new \DateTime(); \Auth::user()->last_login_ip_now = \Request::getClientIp(); \Auth::user()->save(); }
public function logOut() { Helpers::logAudits("System Exit", Request::getClientIp(), Session::get('user_id')); Session::flush(); //Remove all items from the session return Redirect::to('/'); //Return the user back to login page }
public function __construct(JarboeController $controller) { $this->controller = $controller; if (\Config::get('jarboe::log.enabled')) { $this->event = new Event(); $this->event->setUserId(\Sentry::getUser()->getId()); $this->event->setIp(\Request::getClientIp()); $this->attachObserver(new EventsObserver()); } }
public static function storeevents($event) { DB::table('lich_su_hoat_dong')->insert(array('id_nguoi_dung' => Auth::user()->id, 'dia_chi_ip' => Request::getClientIp(), 'mo_ta_tac_vu' => $event, 'thoi_gian_tac_vu' => date('Y-m-d H:i:s', time()))); DB::statement(DB::raw('CALL delete_auto_logs(' . TG_XOA_LS_HOAT_DONG . ');')); // xoa lich su hoat dong if (Auth::user()->quyen_han == 'THU_THU') { DB::statement(DB::raw('CALL huy_phieu_muon_auto(' . TG_HUY_PHIEU_MUON . ');')); //huy phieu muon } }
public static function setReadPoints($post) { $ip_address = Request::getClientIp(); $exists = $post->read()->whereIpAddress($ip_address)->exists(); if (!$exists) { $post->points += 1; $post->save(); self::create(['post_id' => $post->id, 'ip_address' => $ip_address]); } }
public function pushToQueue(array $condition) { $config = config("es_config"); $data = array('user_id' => '', 'action' => '', 'object' => '', 'object_id' => '', 'param' => '', 'ip' => \Request::getClientIp(), 'timestamp' => Carbon::now()->timestamp); if (isset($condition) && !empty($condition)) { $data = array_merge($data, $condition); } $settings = array('index' => 'dm-' . Carbon::now()->year . '.' . Carbon::now()->month, 'type' => 'user', 'body' => $data); \Queue::push($config["path"], $settings); }
/** * handle the command * * @param CreateShortCommand $command * @return ShortRepository */ public function handle($command) { // get the short hash for this url, making sure we have no collisions $hash = $this->hasher->make($this->shortRepository); // get the client ip $ip = \Request::getClientIp(); // save to the database $short = $this->shortRepository->save($command->url, $hash, $ip); return $short; }