public function getInterfaceLocale() { $locale = Input::get("l"); $translating = Input::get("t"); $primary = Input::get("p"); $displayLocales = Input::get("d"); $display = implode(',', $displayLocales ?: []); App::setLocale($locale); Cookie::queue($this->cookieName(self::COOKIE_LANG_LOCALE), $locale, 60 * 24 * 365 * 1); Cookie::queue($this->cookieName(self::COOKIE_TRANS_LOCALE), $translating, 60 * 24 * 365 * 1); Cookie::queue($this->cookieName(self::COOKIE_PRIM_LOCALE), $primary, 60 * 24 * 365 * 1); Cookie::queue($this->cookieName(self::COOKIE_DISP_LOCALES), $display, 60 * 24 * 365 * 1); if (App::runningUnitTests()) { return Redirect::to('/'); } return !is_null(Request::header('referer')) ? Redirect::back() : Redirect::to('/'); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * @return mixed */ public function handle($request, Closure $next) { if (!Cookie::has('d_i')) { Cookie::queue(Cookie::forever('d_i', str_random(60))); } return $next($request); }
/** * Show the form for editing the specified resource. * * @param int $id * @return Response */ public function singUp($code_referrer = '') { if ($code_referrer == '') { $code_referrer = ''; return view('login.register', compact('code_referrer')); } else { Cookie::queue('referrer', $code_referrer, 60 * 24); return view('login.register', compact('code_referrer')); } }
private function killDeadCookies($request) { if (!empty($request->cookie())) { foreach ($request->cookie() as $key => $cookie) { if (strpos($key, 'remember_') !== false) { Cookie::queue($key, null, -9999); } } } }
public function save(Request $request) { Cookie::queue('pl_id', NULL); $peminjaman_pl = new PeminjamanPerangkatLunak(); $peminjaman_pl->tgl_pinjam = $request->input('tgl_pinjam'); $peminjaman_pl->tgl_targetkembali = $request->input('tgl_targetkembali'); $peminjaman_pl->user_id = $request->input('user_id'); $peminjaman_pl->operator_id = Auth::user()->id; $peminjaman_pl->keterangan = $request->input('keterangan'); $peminjaman_pl->pl_data_id = $request->input('pl_data_id'); $peminjaman_pl->save(); return redirect('peminjaman_perangkatlunak/index'); }
public function api() { $data = $this->reportService->getQuery(); if (Request::input('export')) { Cookie::queue('fileDownload', 'true', 69); $className = basename(str_replace('\\', '/', get_class($this))); $filename = str_replace('Controller', '', $className) . '-' . date(Config::get('app.dateformat')); Excel::create($filename, function ($excel) use($filename, $data) { $excel->setTitle($filename)->sheet('Sheet 1', function ($sheet) use($data) { $sheet->fromArray($data['data']); }); })->download(Request::input('export')); } else { return Response::json($data); } }
public function setViewed($model) { $nameClass = strtolower(get_class($model)); if (isset($model->id) && $model->id) { $idPage = $model->id; $nameCookie = md5($nameClass . "_viewed"); $cookies = unserialize(Cookie::get($nameCookie)); if (is_array($cookies)) { array_unshift($cookies, $idPage); array_slice($cookies, 0, Config::get("viewed.config.limit_count")); } else { $cookies[] = $idPage; } $cookies = array_unique($cookies); Cookie::queue($nameCookie, serialize($cookies), Config::get("viewed::config.time_cookie")); } }
/** * Show the application dashboard to the user. * * @return Response */ public function index(Request $request) { if (!isset($_SESSION["timer"])) { $_SESSION["timer"] = time(); } $user_id = Auth::user()->id; if (is_null($user_id)) { return redirect("/auth/login")->withErrors(["Access not allowed, you must login"]); } $notes = Notes::where('user_id', $user_id)->first()->mynotes; $tbd = Tbd::where('user_id', $user_id)->first()->mytbd; $linksArray = Websites::where('user_id', $user_id)->first()->mylink; $email = Auth::user()->email; $website = explode(',', $linksArray); $image = DB::table('myimages')->where('user_id', $user_id)->lists('myimage'); Cookie::queue(Cookie::make('loginEmail', $email, 42 * 60)); return view('home', compact('notes', 'tbd', 'website', 'image')); }
public function getGlobalCartOrder($createIfNone = false) { if (Cookie::has('goprop_order_id') && !isset($this->_currentOrder)) { $order = Order::where('id', Cookie::get('goprop_order_id'))->where('status', Order::STATUS_CART)->whereNull('property_id')->first(); $this->_currentOrder = $order; } if (empty($this->_currentOrder)) { if ($createIfNone) { $order = new Order(); $order->status = Order::STATUS_CART; $order->save(); $this->_currentOrder = $order; $cookie = Cookie::make('goprop_order_id', $order->id, 25200); Cookie::queue($cookie); } } return $this->_currentOrder; }
public function girisKontrol() { #region E-mail ve Şifre kontrolü $data = Input::all(); $kural = array('email' => 'required|email', 'password' => 'required'); $dogrulama = \Validator::Make($data, $kural); if ($dogrulama->fails()) { // gönderilen verilerde hata var return \Redirect::to('admin/')->withErrors($dogrulama)->withInput(); } #endregion! #region Kullanıcı var mı? $bilgi = array(); $gelen = DB::select('select * from admin where mail=? and sifre=?', array($data["email"], md5($data["password"]))); if (count($gelen) == 0) { return Redirect::to('admin'); } $bilgi = $gelen[0]; #endregion #region Kullanıcı varsa ne olacak? /*Session ile bilgilerini tut. Eğer "BENİ HATIRLA" ile giriş yaptı ise Cookie de oluştur. Kullanıcı yoksa giriş sayfasına yönlendir.*/ if ($gelen) { if (isset($data["remember"])) { Session::put('id', $bilgi->id); Session::put('email', $data["email"]); Session::put('password', $data["password"]); Cookie::queue(Cookie::make('user', array($bilgi->id, $data["email"], $data["password"], 24000))); // return Redirect::to('admin/anasayfa'); } else { Session::put('id', $bilgi->id); Session::put('email', $data["email"]); Session::put('password', $data["password"]); // return Redirect::to('admin/anasayfa'); } } else { return view('admin'); } #endregion }
/** * * 登陆方法 */ public function login(Request $request) { $username = $request->input("username"); $password = $request->input("password"); $data = User::where(['un_user' => $username]); // echo $data->count(); $flag = 0; if ($data->count()) { //echo $data->first()->un_pass; if (Hash::check($password, $data->first()->un_pass)) { // The passwords match... Cookie::queue(md5("username"), $username, 10); // echo $name; // redirectToRoute("/dashBord"); //return View::make(xxx)->withCookie($name); $flag = 1; } else { $flag = 2; } } else { $flag = 0; } return $flag; }
/** * {@inheritdoc} */ public function clear() { $this->data = []; return Cookie::queue($this->cookieName, null, -2628000); }
/** * @return mixed **/ public function grid() { $EncryptedSearch = Request::get('search', ""); if ("" == $EncryptedSearch) { return Response::json(['error' => true, 'description' => 'No search'], 412); } // try { $search = Crypt::decrypt($EncryptedSearch); } catch (\Exception $e) { return Response::json(['error' => true, 'description' => 'Search decode'], 412); } // $response = Gulliver::getInsuranceAvailability(['origin' => mb_convert_case($search['origin'], MB_CASE_UPPER), 'destination' => mb_convert_case($search['destination'], MB_CASE_TITLE), 'dateFrom' => $search['dateFrom'], 'dateTo' => $search['dateTo'], 'passengers' => true == is_array($search['passengers']) ? implode(',', $search['passengers']) : $search['passengers'], 'currency' => 'ARS']); if (false == $response) { return Response::json(['error' => true, 'description' => Gulliver::$error], 412); } // $sessionId = $response['sessionId']; $response = $response['availablePlans']; // foreach ($response as $key => $item) { $response[$key]['insuranceTotalPrices']['requestedSellingPrice']['taxes'] = $item['insuranceTotalPrices']['requestedSellingPrice']['afterTax'] - $item['insuranceTotalPrices']['requestedSellingPrice']['beforeTax']; // $row = InsuranceModel::store(['session' => $sessionId, 'plan_number' => $key, 'item' => json_encode($response[$key]), 'search' => json_encode($search)]); // http://viajes-laravel.dev/compra/seguros/?GID=71ff1103-d3c6-4e12-92b1-0caccc864d2a&BID=1 $response[$key]['booking'] = url() . '/compra/seguros?' . http_build_query(['GID' => $sessionId, 'BID' => $row->id]); } // Cookie::queue(self::$config['cookieName'], $search, self::$config['cookieTtl']); // return Response::json(['error' => false, 'description' => 'Ok', 'total' => sizeof($response), 'grid' => view('Insurance/grid')->with(['destination' => mb_convert_case($search['destination'], MB_CASE_LOWER), 'response' => $response])->render()], 200); }
public function rememberLogin(Person $person) { $value = $person->getId() . '-' . $person->getRememberToken(); Cookie::queue(Cookie::forever($this->getAutoLoginCookie(), $value)); }
public function tambahkan_keranjang($id) { Cookie::queue('pl_id', $id, '5'); return redirect('peminjaman_perangkatlunak/create'); }
public function getSwitch($id) { Cookie::queue('store', $id); return redirect()->back(); }
public function index() { Cookie::queue('ebriat', '', -1); Cookie::queue('ebrirt', '', -1); return View::make('ebri::account'); }
public function createComment(Request $request, $id) { $this->validate($request, ['comment' => 'required|max:1000', 'username' => 'required|min:2|max:50', 'email' => 'required|email', 'url' => 'url']); $article = Articles::findOrFail($id); $comment = new ArticlesComments($request->all()); $article->comments()->save($comment); /** * I think need to save username, email and url to cookies */ Cookie::queue(Cookie::forever('username', $request->input('username'))); Cookie::queue(Cookie::forever('email', $request->input('email'))); Cookie::queue(Cookie::forever('url', $request->input('url'))); return view('articles.comments', compact('article')); }
/** * Handle logging in a user. * * @return Response */ public function login() { $status = 401; $input = $this->getUserInput(); $remember = isset($input['remember']) ? true : false; try { // Set login credentials $credentials = array('email' => $this->getApiServer()->getRequest()->getUser(), 'password' => $this->getApiServer()->getRequest()->getPassword()); // Try to authenticate the user $response = $this->getSentry()->authenticate($credentials, false); $status = 200; } catch (\Cartalyst\Sentry\Users\LoginRequiredException $e) { $response = array('message' => $this->getLocale()->t('Provided information is not valid.'), 'errors' => array(array('field' => 'email', 'message' => $this->getLocale()->t('Login field is required.')))); } catch (\Cartalyst\Sentry\Users\PasswordRequiredException $e) { $response = array('message' => $this->getLocale()->t('Provided information is not valid.'), 'errors' => array(array('field' => 'password', 'message' => $this->getLocale()->t('Password field is required.')))); } catch (\Cartalyst\Sentry\Users\WrongPasswordException $e) { $response = array('message' => $this->getLocale()->t('Provided information is not valid.'), 'errors' => array(array('field' => 'password', 'message' => $this->getLocale()->t('Wrong password, try again.')))); } catch (\Cartalyst\Sentry\Users\UserNotFoundException $e) { $response = array('message' => $this->getLocale()->t('User was not found.')); } catch (\Cartalyst\Sentry\Users\UserNotActivatedException $e) { $response = array('message' => $this->getLocale()->t('Your account is not yet activated.')); } catch (\Cartalyst\Sentry\Throttling\UserSuspendedException $e) { $response = array('message' => $this->getLocale()->t('Your account is suspended.')); } catch (\Cartalyst\Sentry\Throttling\UserBannedException $e) { $response = array('message' => $this->getLocale()->t('Your account is banned.')); } if ($status == 200) { $client = $this->getApiServer()->getClient(); $clientEndpoint = $client->endpoint; $clientScopeIds = $this->getApiServer()->getResource()->getScopeIds(); $clientScopes = $this->getApiServer()->getResource()->getScopes(); $scopes = array(); if (!empty($clientScopeIds)) { foreach ($clientScopeIds as $id) { $scopes[] = array('id' => $id); } } unset($clientScopeIds); if (!is_array($clientScopes)) { $clientScopes = array(); } // Create a new client endpoint if not exist if (!is_object($clientEndpoint)) { $redirectUri = $this->getApiServer()->getRequest()->getSchemeAndHttpHost(); $clientEndpoint = OauthClientEndpoint::create(array('client_id' => $client->id, 'redirect_uri' => $redirectUri)); } else { $redirectUri = $clientEndpoint->redirect_uri; } // Create a new authorization code $authCode = $this->getApiServer()->newAuthorizeRequest('user', $response->id, array('client_id' => $client->id, 'redirect_uri' => $redirectUri, 'scopes' => $scopes)); // Authorize the client to a user if (!empty($authCode)) { $params = array('grant_type' => 'authorization_code', 'client_id' => $client->id, 'client_secret' => $client->secret, 'redirect_uri' => $redirectUri, 'code' => $authCode, 'scope' => implode(',', $clientScopes), 'state' => time()); $authorizationResponse = $this->getApiServer()->performAccessTokenFlow(false, $params); if (array_key_exists('status', $authorizationResponse)) { $status = $authorizationResponse['status']; $headers = $authorizationResponse['headers']; unset($authorizationResponse['status']); unset($authorizationResponse['headers']); return $this->getApiServer()->resourceJson($authorizationResponse, $status, $headers); } Cookie::queue('ebriat', $authorizationResponse['access_token'], $authorizationResponse['expires_in'] / 60); Cookie::queue('ebrirt', $authorizationResponse['refresh_token'], Config::get('sule/api::oauth2.grant_types.refresh_token.refresh_token_ttl') / 60); // Fix user quota $quotaUsed = $this->getUserMeta('quota_used', $response); // if ((int) $quotaUsed < 0) { // $this->getFs()->fixUserQuotaUsed($response->getId()); // } unset($quotaUsed); // Merge user data with the new authorization data $authorizationResponse['user'] = new UserTemplate($response, array('available_mime_types' => Config::get('ebri::mime_types'))); $response = $authorizationResponse; unset($authorizationResponse); } else { $response = array('message' => $this->getLocale()->t('There was a problem while logging you in, please try again or contact customer support.')); $status = 500; } unset($scopes); unset($clientScopes); unset($client); } else { $user = $this->getUser(); if (!is_null($user)) { $client = $this->getApiServer()->getClient(); if (!is_null($client)) { $session = new FluentSession(); $session->deleteSession($client->id, 'user', $user->getId()); unset($session); $this->getSentry()->logout(); Cookie::queue('ebriat', '', -1); Cookie::queue('ebrirt', '', -1); } unset($client); } unset($user); } return $this->getApiServer()->resourceJson($response, $status); }
private function requestRefreshToken() { $ch = curl_init(); $params = array('grant_type' => 'refresh_token', 'refresh_token' => $this->refreshToken, 'client_id' => $this->clientId, 'client_secret' => $this->clientSecret, 'state' => time()); $params = json_encode($params); $opts = self::$curlOptions; $opts[CURLOPT_URL] = $this->apiBaseUrl . '/authorizations'; $opts[CURLOPT_HTTPHEADER] = array('Content-MD5: ' . md5($params . $this->clientSecret), 'Content-Type: application/json'); $opts[CURLOPT_POSTFIELDS] = $params; curl_setopt_array($ch, $opts); $result = curl_exec($ch); if (curl_errno($ch) == 60) { // CURLE_SSL_CACERT Log::error('Invalid or no certificate authority found, now trying using bundled information : ' . storage_path() . '/ca_chain_bundle.crt'); // curl_setopt($ch, CURLOPT_CAINFO, storage_path() . '/ca_chain_bundle.crt'); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $result = curl_exec($ch); } // With dual stacked DNS responses, it's possible for a server to // have IPv6 enabled but not have IPv6 connectivity. If this is // the case, curl will try IPv4 first and if that fails, then it will // fall back to IPv6 and the error EHOSTUNREACH is returned by the // operating system. if ($result === false && empty($opts[CURLOPT_IPRESOLVE])) { $matches = array(); $regex = '/Failed to connect to ([^:].*): Network is unreachable/'; if (preg_match($regex, curl_error($ch), $matches)) { if (strlen(@inet_pton($matches[1])) === 16) { Log::error('Invalid IPv6 configuration on server, please disable or get native IPv6 on your server.'); self::$curlOptions[CURLOPT_IPRESOLVE] = CURL_IPRESOLVE_V4; curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); $result = curl_exec($ch); } } unset($matches); } $httpStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE); if ($httpStatus == 200) { $result = json_decode($result); // save tokens information to cookie $this->accessToken = $result->access_token; Cookie::queue('ebriat', $result->access_token, $result->expires_in / 60); } unset($result); curl_close($ch); }