public function index($lang) { $cookie = Cookie::forever('lang', $lang); $response = Redirect::back(); $response->withCookie($cookie); return $response; }
public function dologin() { $params = Input::all(); if (empty($params['username'])) { Session::flash('error', '用户名必须填写'); return Redirect::route('login'); } if (empty($params['password'])) { Session::flash('error', '密码必须填写'); return Redirect::route('login'); } if (empty($params['captcha'])) { Session::flash('error', '验证码必须填写'); return Redirect::route('login'); } if (!$this->_validate_captcha($params['captcha'])) { Session::flash('error', '验证码错误'); return Redirect::route('login'); } $password = md5(md5($params['password'])); $admin = AdminORM::whereUsername($params['username'])->wherePwd($password)->where('status', '<>', BaseORM::DISABLE)->first(); if (!empty($admin)) { Session::flash('success', '登陆成功'); $admin_id_cookie = Cookie::forever('admin_id', $admin->id); $admin_username_cookie = Cookie::forever('admin_username', $admin->username); $k_cookie = Cookie::forever('k', Crypt::encrypt($admin->id . $admin->username)); $login_time_cookie = Cookie::forever('login_time', time()); $admin->last_login_time = date('Y-m-d H:i:s'); $admin->save(); return Redirect::route('home')->withCookie($k_cookie)->withCookie($admin_id_cookie)->withCookie($admin_username_cookie)->withCookie($login_time_cookie); } else { Session::flash('error', '用户没找到'); return Redirect::route('login'); } }
public function scope_base() { $code = Input::get('code', ''); $state = Input::get('state', ''); $url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=wxe7d58fa8d7ae3416&secret=2204083b829c499d245a46849b2befb2&code=" . $code . "&grant_type=authorization_code"; try { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $result = curl_exec($ch); curl_close($ch); $uri = urldecode($state); $res = json_decode($result, TRUE); $open_id = $res['openid']; $data = callApi('1.0/user/wx/info', ['wx_id' => $open_id]); if ($data->status == 'success') { if (!empty($data->result)) { $id_cookie = Cookie::forever('user_id', $data->result->id); $open_id_cookie = Cookie::forever('open_id', $open_id); return Redirect::to($uri)->withCookie($id_cookie)->withCookie($open_id_cookie); } else { return Redirect::route('forbidden'); } } else { return Redirect::route('forbidden'); } } catch (Exception $e) { return Redirect::route('forbidden'); } }
/** * Detect and set application localization environment (language). * NOTE: Don't foreget to ADD/SET/UPDATE the locales array in app/config/app.php! * */ private function configureLocale() { $mLocale = Config::get('app.locale'); if (!Session::has('locale')) { $mFromCookie = Cookie::get('locale', null); if ($mFromCookie != null && in_array($mFromCookie, Config::get('app.locales'))) { $mLocale = $mFromCookie; } else { $mFromURI = Request::segment(1); if ($mFromURI != null && in_array($mFromURI, Config::get('app.locales'))) { $mLocale = $mFromURI; } else { $mFromBrowser = substr(Request::server('http_accept_language'), 0, 2); if ($mFromBrowser != null && in_array($mFromBrowser, Config::get('app.locales'))) { $mLocale = $mFromBrowser; } } } Session::put('locale', $mLocale); Cookie::forever('locale', $mLocale); } else { $mLocale = Session::get('locale'); } App::setLocale($mLocale); }
public function handle(Request $request, \Closure $next) { if ($request->has('_lang') && ($lang = $request->get('_lang'))) { return back()->cookie(\Cookie::forever('a_lc', $lang)); } app()->setLocale($request->cookie('a_lc', config('admin.locale'))); return $next($request); }
public function addCookie($sName, $mxValue, $iTime = 0) { if ($iTime > 0) { $this->_aCookies[] = \Cookie::make($sName, $mxValue, $iTime); } else { $this->_aCookies[] = \Cookie::forever($sName, $mxValue); } }
/** * Store data in the cookie. * * @param string $index * @param array $data * @param bool|int $period Hours * * @return bool */ public function setCookie($index, $data, $period = false) { if (!$this->getCookie($index)) { $data = serialize($data); if (!$period) { \Cookie::forever($index, $data); } } return false; }
public function ChecksiteLogin() { if (Input::has('site-password')) { if (Input::get('site-password') == Config::get('config.site_password')) { $cookie = Cookie::forever('siteprotection', 'YES'); return Redirect::back()->withCookie($cookie); } } Cookie::forget('siteprotection'); return Redirect::back()->with(['errors' => 'Sorry wrong password for site.']); }
public function postIndex() { /*$hash=Hash::make(Input::get('password')); echo $hash; die();*/ if (trim(Input::get('password')) != "" && Auth::attempt(array('mail' => Input::get('mail'), 'password' => Input::get('password')), true)) { $cookie = Cookie::forever('avatar', Auth::user()->id); return Redirect::to('/')->withCookie($cookie); } else { return Redirect::to('/login')->with('message', 'Your username/password combination was incorrect')->withInput(); } }
private function getIdentifier() { $idt = ''; if (!Sentry::check()) { if (!Cookie::has('Anon_Cart_Extension')) { Cookie::forever('Anon_Cart_Extension', get_unique_id()); } $idt = Cookie::get('Anon_Cart_Extension'); } else { $idt = Sentry::user()->id; } return $idt; }
public function getLogin() { $fb = OAuth::consumer('Facebook'); if (Input::get('code')) { $token = $fb->requestAccessToken(Input::get('code')); $user = json_decode($fb->request('/me'), true); $user['oauth_provider'] = 'facebook'; $user['access_token'] = $token->getAccessToken(); $uid = $this->_saveUser($user); return Redirect::to('index')->withCookie(Cookie::forever('uid', $uid)); } else { $user = $this->_getUser(); if ($user) { return Redirect::to('index'); } else { return View::make('ttwwoo.login')->with('loginUrl', $fb->getAuthorizationUri()->getAbsoluteUri()); } } }
public function login() { $admin = \Neyko\Admin\Model\Administrator::where("username", "=", \Input::get('username'))->first(); if ($admin) { if (\Hash::check(\Input::get('password'), $admin->password)) { \Session::put('admin', $admin->id); if (\Input::get("remember_me") == "on") { $admin->remember_token = str_random(100); $admin->save(); return redirect('/admin')->with('message', 'You have successfully logged in.')->withCookie(\Cookie::forever('neyko_admin_remember_token', $admin->remember_token)); } else { return redirect('/admin')->with('message', 'You have successfully logged in.'); } } else { return redirect('/admin/login')->with('message', 'You have failed to login.'); } } else { return redirect('/admin/login')->with('message', 'You have failed to login.'); } }
public function getCallback() { try { $session = $this->helper->getSessionFromRedirect(); } catch (FacebookRequestException $ex) { // When Facebook returns an error } catch (\Exception $ex) { // When validation fails or other local issues } if ($session) { $request = new FacebookRequest($session, 'GET', '/me'); $response = $request->execute(); $fbuser = $response->getGraphObject(); if ($fbuser) { return Redirect::to('/facebook/checkuser')->with('sessionfb', $session)->with('userfb', $fbuser)->withCookie(Cookie::forever('user', $fbuser)); } else { dd('Error'); } } }
/** * Processes the date of birth submitted in the age gate form */ public function doAgegate() { $previousTooYoung = \Session::get('laravel-agegate.previous_too_young'); if ($previousTooYoung) { return \Redirect::action('Fbf\\LaravelAgegate\\AgegateController@agegate'); } // Get the date of birth that the user submitted $dob = null; if (\Input::has('dob')) { // field name is dob when using input type date $dob = \Input::get('dob'); } elseif (\Input::has('dob_year') && \Input::has('dob_month') && \Input::has('dob_day')) { // field name has _year, _month and _day components if input type select $dob = \Input::get('dob_year') . '-' . \Input::get('dob_month') . '-' . \Input::get('dob_day'); } $maxDob = Carbon::now()->subYears(\Config::get('laravel-agegate::minimum_age'))->addDay()->toDateString(); $validator = \Validator::make(array('dob' => $dob), array('dob' => 'required|date|date_format:Y-m-d|before:' . $maxDob), \Lang::get('laravel-agegate::validation.custom')); if ($validator->fails()) { $failed = $validator->failed(); $validExceptTooYoung = array_get($failed, 'dob.Before'); $canTryAgain = \Config::get('laravel-agegate::can_try_again'); if ($validExceptTooYoung && !$canTryAgain) { \Session::put('laravel-agegate.previous_too_young', true); } else { \Session::keep('url.intended'); } return \Redirect::action('Fbf\\LaravelAgegate\\AgegateController@agegate')->withErrors($validator)->withInput(); } if (\Config::get('laravel-agegate::cookie_age') == 'forever') { // Set a forever cookie saying the user is old enough $cookie = \Cookie::forever(\Config::get('laravel-agegate::cookie_name'), \Config::get('laravel-agegate::cookie_val')); } elseif (is_int(\Config::get('laravel-agegate::cookie_age'))) { // Sets a cookie lasting X minutes saying the user is old enough Cookie::make(\Config::get('laravel-agegate::cookie_name'), \Config::get('laravel-agegate::cookie_val'), \Config::get('laravel-agegate::cookie_age')); } else { // Sets a session cookie saying the user is old enough $cookie = \Cookie::make(\Config::get('laravel-agegate::cookie_name'), \Config::get('laravel-agegate::cookie_val')); } return \Redirect::intended('/')->withCookie($cookie); }
public function getLogin() { if ($remember = Cookie::get('_user_remember')) { $auth_token = Crypt::decrypt($remember); $auth_token = explode(':', $auth_token); $authed = User::authenticateUser($auth_token[0], $auth_token[1]); if (is_object($authed)) { if (isset($_REQUEST['remember'])) { Cookie::forever('_user_remember', Crypt::encrypt($email . ':' . $md5pass)); } Session::put('user', $authed); return Redirect::action('PortalController@getIndex'); } else { logr(array('data' => $_REQUEST, 'time' => date('Y-m-d H:i:s')), 'failed-logins'); return View::make('launch.login', array('validation' => 'Your password has recently changed. Please login again.')); } } if (Session::has('user')) { return Redirect::action('PortalController@getIndex'); } return View::make('launch.login', array('validation' => Session::get('validation'))); }
/** * Redirect user to appropriate product landing page. * It also creates a cookie for the affiliate tracking * * @param $app String */ public function getIndex($app) { // Get Affiliate ID $affiliate_id = Input::get('affiliate'); // Get product Landing page url if ($product = Product::where('code', '=', $app)->first()) { $product_url = $product->landing_url; // if there is encoded link if (Input::get('redirect')) { $product_url = urldecode(Input::get('redirect')); } } else { // Error, redirect to somewhere return Redirect::to(Config::get("project.website")); } // Create cookie for affiliate and Redirect to Landing page if ($affiliate_id) { $cookie = Cookie::forever('_dks_isa', $affiliate_id); return Redirect::to($product_url)->withCookie($cookie); } else { return Redirect::to($product_url); } }
public function searchUser() { // If Cookie is Present Dont Load Any Data! if (Cookie::has('sponsor')) { $cookie = Cookie::get('sponsor'); $link = $cookie['link']; $message = 'Loading... ' . $link . '\'s Sponsor Link'; // Return as an Error Code LOCK! return response()->json(['cookie' => true, 'message' => $message, 'link' => $link], 423); } // If No Cookie Is Present try { $link = Input::get('q'); $splinkdata = Link::findByLink($link)->load('user.profile'); $cookie = $splinkdata->toArray(); $message = 'Loading... ' . $splinkdata['link'] . '\'s Sponsor Link'; return response()->json(['cookie' => false, 'splinkdata' => $splinkdata, 'message' => $message], 200)->withCookie(\Cookie::forever('sponsor', $cookie)); } catch (ModelNotFoundException $e) { $link = Input::get('q'); $message = 'Can\'t Find ' . $link . ' in Database'; return response()->json(['cookie' => false, 'message' => $message, 'link' => $link], 400); } }
public function addProductViewCount($p_id) { $increment_view_count = false; $cookie_name = \Config::get('webshoppack.site_cookie_prefix') . "_mp_product_views"; $cookie_value = $this->getCookie($cookie_name); $cookie = ''; if ($cookie_value != '') { $p_id_arr = explode(',', $cookie_value); $p_id_arr = array_unique($p_id_arr); if (!in_array($p_id, $p_id_arr)) { $p_ids = $p_id . ',' . $cookie_value; $cookie = \Cookie::forever($cookie_name, $p_ids); $increment_view_count = true; } } else { $cookie = \Cookie::forever($cookie_name, $p_id); $increment_view_count = true; } if ($increment_view_count) { //To increment the view count. Product::where('id', '=', $p_id)->increment('total_views'); } return $cookie; }
/** * sets theme cookie and redirects * * @return Illuminate\Http\RedirectResponse */ private function theme_cookie_switch($colorscheme) { return Redirect::to(Utility::backOrUrl("/preferences/theme"))->withCookie(Cookie::forever('theme', $colorscheme)); }
public function createBaseLaptop() { // $cookie = Cookie::make('baseLaptop', 'test', 20); return Redirect::route('dashboard')->with('success', 'Met deze computer kan u nu materiaal afhalen en terugbrengen')->withCookie(Cookie::forever('baseLaptop', 'test')); }
} else { if (!empty($browser_lang) and in_array($browser_lang, Config::get('app.languages'))) { if ($browser_lang != $cookie_lang) { Cookie::forever('language', $browser_lang); Session::put('language', $browser_lang); } App::setLocale($browser_lang); } else { App::setLocale(Config::get('app.locale')); } } }); App::after(function ($request, $response) { $lang = Session::get('language'); if (!empty($lang)) { $response->withCookie(Cookie::forever('language', $lang)); } }); Route::filter('auth', function () { if (!Sentry::check()) { return Redirect::guest('/'); } }); Route::filter('api.patient', function () { if (!Cache::has('_token_')) { return Api\V1\Helpers::Mgs("Api No Acesss. Api. Token"); } }); Route::filter('api.cache', function () { if (!Cache::has('_token_')) { Sentry::logout();
public function doSaveMenuPreference() { $option = \Input::get('option'); $cookie = \Cookie::forever('tb-misc-body_class', $option); $data = array('status' => true); $response = \Response::json($data); $response->headers->setCookie($cookie); return $response; }
/** * @param $user_name * @param $password * @return array */ public function adminLogin($user_name, $password) { if (!$user_name) { return ['status' => false, 'message' => '登录账户不能为空']; } if (!$password) { return ['status' => false, 'message' => '密码不能为空']; } $real_password = $this->encryptPassword($password); if (($user = UserBase::where('password', $real_password)->where('user_name', $user_name)->isOpen()->admin()->first()) || ($user = UserBase::where('password', $real_password)->where('user_cellphone', $user_name)->isOpen()->admin()->first())) { //加密token $token = TokenService::create($user->user_name, $user->user_id, $user->type); $cookie = \Cookie::forever(self::TOKEN_COOKIE_NAME, $token); \Cookie::queue($cookie); return ['status' => true, 'message' => '登录成功']; } return ['status' => false, 'message' => '账户或密码错误']; }
/** * Creates a new paste item * * @return \Illuminate\Support\Facades\Redirect */ public function postCreate() { // Get the site configuration $site = Site::config('general'); // Define validation rules $validator = Validator::make(Input::all(), array('title' => 'max:30', 'data' => 'required|auth|mbmax:' . $site->maxPasteSize, 'language' => 'required|in:' . Highlighter::make()->languages(TRUE), 'expire' => 'in:' . Paste::getExpiration('create', TRUE))); // Generate anti-spam modules $antispam = Antispam::make('paste', 'data'); // Run validations $resultValidation = $validator->passes(); // Execute antispam services $resultAntispam = $antispam->passes(); // Get the paste language. We use it to store a language history $language = Input::get('language'); $historyLangs = Cookie::get('languages'); // History languages must always be an array $historyLangs = is_array($historyLangs) ? $historyLangs : array(); // No dulicates allowed in the history if (in_array($language, $historyLangs)) { $key = array_search($language, $historyLangs); unset($historyLangs[$key]); } else { if (count($historyLangs) >= 10) { $historyLangs = array_slice($historyLangs, 1, count($historyLangs)); } } // Add current language to the history array_push($historyLangs, $language); $cookie = Cookie::forever('languages', $historyLangs); // Evaluate validation results if ($resultValidation and $resultAntispam) { // We inject the project into the input so that // it is also inserted into the DB accordingly Input::merge(array('project' => $this->project)); // All OK! Create the paste already!! $paste = Paste::createNew('web', Input::all()); // Now, save the attachment, if any (and if enabled) if ($site->allowAttachment and Input::hasFile('attachment')) { $file = Input::file('attachment'); if ($file->isValid()) { $file->move(storage_path() . '/uploads', $paste->urlkey); } } // Redirect to paste if there's no password // Otherwise, just show a link if ($paste->password) { $url = link_to("{$paste->urlkey}/{$paste->hash}"); $message = sprintf(Lang::get('create.click_for_paste'), $url); Session::flash('messages.success', $message); } else { return Redirect::to(Paste::getUrl($paste))->withCookie($cookie); } } else { // Set the error message as flashdata if (!$resultValidation) { Session::flash('messages.error', $validator->messages()->all('<p>:message</p>')); } else { if (!$resultAntispam) { Session::flash('messages.error', $antispam->message()); } } } return Redirect::to(URL::previous())->withInput()->withCookie($cookie); }
/** * Detect and set application localization environment (language). * NOTE: Don't foreget to ADD/SET/UPDATE the locales array in app/config/app.php! * */ private function configureLocale() { // Set default locale. $mLocale = Config::get('app.locale'); // Has a session locale already been set? if (!Session::has('locale')) { // No, a session locale hasn't been set. // Was there a cookie set from a previous visit? $mFromCookie = Cookie::get('locale', null); if ($mFromCookie != null && in_array($mFromCookie, Config::get('app.languages'))) { // Cookie was previously set and it's a supported locale. $mLocale = $mFromCookie; } else { // No cookie was set. // Attempt to get local from current URI. $mFromURI = Request::segment(1); if ($mFromURI != null && in_array($mFromURI, Config::get('app.languages'))) { // supported locale $mLocale = $mFromURI; } else { // attempt to detect locale from browser. $mFromBrowser = substr(Request::server('http_accept_language'), 0, 2); if ($mFromBrowser != null && in_array($mFromBrowser, Config::get('app.languages'))) { // browser lang is supported, use it. $mLocale = $mFromBrowser; } // $mFromBrowser } // $mFromURI } // $mFromCookie Session::put('locale', $mLocale); Cookie::forever('locale', $mLocale); } else { // session locale is available, use it. $mLocale = Session::get('locale'); } // Session? // set application locale for current session. App::setLocale($mLocale); }
public function hide_elem($id) { $hidden = unserialize(Cookie::get('hide')); $hidden[] = $id; $hide = Cookie::forever('hide', serialize($hidden)); return Redirect::to('/c/' . Auth::user()->profile_url)->withCookie($hide); }
/** * Create a cookie that lasts for ever * * @param type $key * @param type $value */ function zbase_cookie_forever($key, $value) { \Cookie::forever($key, $value); }
public function rememberRetarget($campaignId, $event) { $cookieName = "Retargeting:{$campaignId}:{$event}"; return Cookie::forever($cookieName, time()); }
/** * Set a cookie so that the user is "remembered". * * @param string $id * @return void */ protected static function remember($id) { $recaller = Crypter::encrypt($id . '|' . Str::random(40)); // This method assumes the "remember me" cookie should have the same // configuration as the session cookie. Since this cookie, like the // session cookie, should be kept very secure, it's probably safe. // to assume the cookie settings are the same. $config = Config::get('session'); extract($config, EXTR_SKIP); $cookie = Config::get('auth.cookie'); Cookie::forever($cookie, $recaller, $path, $domain, $secure); }
/** * 登陆信息提交 * * @param [string] $[login_user] [用户名] * @param [string] $[login_pwd] [用户名] * * @return [Response] [响应] */ public function postLogin() { $userName = Input::get('login_user'); $userPwd = Input::get('login_pwd'); $userRemember = (bool) Input::get('login_remeber_me', false); if (preg_match('/^1\\d{10}$/i', $userName)) { $credentials = array('wy_phone' => $userName, 'password' => $userPwd, 'wy_user_type' => USER_TYPE_2, 'wy_state' => USER_STATUS_2); } elseif (preg_match('/^[\\w\\.]+@\\w+\\.\\w+$/i', $userName)) { $credentials = array('wy_email' => $userName, 'password' => $userPwd, 'wy_user_type' => USER_TYPE_2, 'wy_state' => USER_STATUS_2); } else { $credentials = array('wy_user_name' => $userName, 'password' => $userPwd, 'wy_user_type' => USER_TYPE_2, 'wy_state' => USER_STATUS_2); } if (Auth::attempt($credentials)) { $user = Auth::user(); $user->wy_last_login_time = Carbon::now(); $user->wy_last_login_machine = Request::server('REMOTE_ADDR'); $user->wy_login_status = LOGIN_STATUS_1; $user->save(); if ($userRemember) { $cookie = Cookie::forever('login_user', $userName); } else { $cookie = Cookie::forget('login_user'); } return Redirect::intended('admin')->withCookie($cookie); } else { return Redirect::back()->withInput()->with('error', Lang::get('errormessages.-10000')); } }