public function changeLocale($locale)
 {
     if (array_key_exists($locale, Config::get('app.locales'))) {
         Session::set('applocale', $locale);
     }
     return back();
 }
Esempio n. 2
0
 /**
  * 后台验证登陆操作
  *
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function check()
 {
     $username = Input::get('username', null);
     $password = Input::get('password', null);
     if ($username and $password) {
         $user = AdminUser::where('username', '=', $username)->first();
         if (count($user)) {
             if (sha1($password) == $user->password and $user->enable) {
                 Session::set('admin_user', $user->username);
                 Session::set('admin_id', $user->id);
                 Session::set('admin_level', $user->level);
                 if ($user->level == 1) {
                     return redirect('admin/orders/show');
                 } else {
                     return redirect('admin/promote/user/center');
                 }
             } else {
                 flash('密码错误或用户已禁用~');
                 return redirect()->back();
             }
         } else {
             flash('用户不存在~');
             return redirect()->back();
         }
     } else {
         flash('用户名或密码不能为空~');
         return redirect()->back();
     }
 }
Esempio n. 3
0
 public function switchLang($lang)
 {
     if (array_key_exists($lang, Config::get('languages'))) {
         Session::set('applocale', $lang);
     }
     return Redirect::back();
 }
Esempio n. 4
0
 public function login()
 {
     Session::set('admin_lock_url', null);
     $loginForm = new KForm();
     $loginForm->addField(FormFieldBase::createByType('login', FormFieldBase::Type_Text)->setRules('required')->setLabel('请输入工号'));
     $loginForm->addField(FormFieldBase::createByType('password', FormFieldBase::Type_Password)->setRules('required')->setLabel('请输入密码'));
     if (AuthModel::user() !== null) {
         return Redirect::action('admin.index');
     }
     if (Request::isMethod('POST')) {
         //是管理员登陆请求
         if ($loginForm->validation()) {
             $login = $loginForm->value('login');
             $password = $loginForm->value('password');
             if (AuthModel::attempt(['employee_id' => $login, 'password' => $password])) {
                 $admin = AuthModel::getUser();
                 $admin->last_login = new \Carbon\Carbon();
                 $admin->save();
                 return Redirect::action('admin.index');
             } else {
                 $loginForm->set_error('password', '错误的用户名或密码');
             }
         } else {
             //
         }
     }
     $this->layout = View::make('laravel-cms::admin-lte/login')->with('form', $loginForm);
 }
 /**
  * @param Request $request
  * @return array
  */
 public function update($id, $newQtd)
 {
     $cart = $this->getCart();
     $cart->update($id, $newQtd);
     Session::set('cart', $cart);
     return redirect()->route('cart');
 }
 public function question()
 {
     $user = \Auth::user();
     $isAjax = \Request::ajax();
     $correct_answers = $user->correct_answers;
     if (!$isAjax && $correct_answers >= 3) {
         Redirect::to('user/start');
     }
     $data = Question::select('title')->get();
     $value = Session::get('index');
     if ($value >= count($data) || !$value) {
         $value = 1;
     }
     if ($isAjax) {
         Session::set('index', $value + 1);
         $value = Session::get('index');
     }
     $question = \App\Question::with(array('answers' => function ($query) {
         $query->select("id", "title", "question_id");
     }))->select('id', 'title')->findOrFail($value);
     $question['correct_answers'] = $correct_answers;
     if ($isAjax) {
         return json_encode($question);
     }
     return view('auth.question', compact('question'));
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $card = Request::all();
     $user = Auth::user();
     $user_type = $user->user_type;
     if ($user_type == 'COMPANY') {
         // o bar está abrindo a comanda
         $id_company = $user->id_company;
         $phone = $card['phone'];
         // pega o celular do usuario
         $user = User::where('phone', '=', $phone)->get();
         // encontra o usuario vinculado a esse celular
         foreach ($user as $row) {
             $id_user = $row->id_user;
         }
     } else {
         // o usuário está abrindo a propria comanda
         $id_user = $user->id_user;
         $phone = $user->phone;
         $id_company = $card['id_company'];
         Session::set('id_company', $id_company);
     }
     // Gera o HASH da comanda
     $full_hash = md5($id_user . $phone . $id_company . microtime() . rand());
     $hash_len = strlen($full_hash);
     // HASH FINAL
     $hash_card = strtoupper(substr($full_hash, $hash_len - 6, 6));
     $new_card = ['id_user' => $id_user, 'id_company' => $id_company, 'table' => $card['table'], 'hash_card' => $hash_card];
     Card::create($new_card);
     return redirect('comandas?card=' . $hash_card);
 }
 public function update($id, $refresh)
 {
     $cart = $this->getCart();
     $cart->novaQtd($id, $refresh);
     Session::set('cart', $cart);
     return redirect()->route('cart');
 }
 public function githubLogin()
 {
     $access_token = Input::get('access_token');
     $ch = curl_init('https://api.github.com/user');
     curl_setopt($ch, CURLOPT_HTTPHEADER, array("Authorization: token {$access_token}"));
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
     curl_setopt($ch, CURLOPT_USERAGENT, 'SWAMP');
     $response = curl_exec($ch);
     $user = json_decode($response);
     $account = LinkedAccount::where('user_external_id', '=', $user->id)->first();
     if ($account) {
         Session::set('github_access_token', $access_token);
         $user = User::getIndex($account->user_uid);
         if ($user) {
             if ($user->isEnabled()) {
                 $res = Response::json(array('user_uid' => $user->user_uid));
                 Session::set('timestamp', time());
                 Session::set('user_uid', $user->user_uid);
                 return $res;
             } else {
                 return Response::make('User has not been approved.', 401);
             }
         } else {
             return Response::make('Incorrect username or password.', 401);
         }
     } else {
         return Response::make('Account not found.', 401);
     }
 }
Esempio n. 10
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @param  string  $l
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     //Session::flush();
     if (!Session::has('locale')) {
         /**
          * Get the browser local code and lang code.
          */
         $localCode = $request->getPreferredLanguage();
         $localLang = substr($localCode, 0, 2);
         if (in_array($localLang, $this->lang)) {
             Session::set('locale', $localLang);
         } else {
             Session::set('locale', Config::get('app.locale'));
         }
     }
     /**
      * Set the local config.
      */
     App::setLocale(Session::get('locale'));
     Config::set('app.locale', Session::get('locale'));
     /**
      * Share variables in view.
      */
     if (Config::get('app.locale') == 'fr') {
         View::share(['lang' => 'fr', 'langreverse' => 'en']);
     } else {
         View::share(['lang' => 'en', 'langreverse' => 'fr']);
     }
     return $next($request);
 }
Esempio n. 11
0
 static function whitelisted()
 {
     // Detect API Request
     //
     if (Input::get('api_key') && Input::get('user_uid')) {
         if (Config::get('app.api_key') == Input::get('api_key')) {
             if (!User::getIndex(Input::get('user_uid'))) {
                 return false;
             }
             Session::set('user_uid', Input::get('user_uid'));
             return true;
         }
         return false;
     }
     // Detect Whitelisted Route
     //
     foreach (Config::get('app.whitelist') as $pattern) {
         if (is_array($pattern)) {
             if (Request::is(key($pattern))) {
                 return in_array(self::method(), current($pattern));
             }
         } else {
             if (Request::is($pattern)) {
                 return true;
             }
         }
     }
     return false;
 }
 public function destroy($id)
 {
     $cart = $this->getCart();
     $cart->remove($id);
     Session::set('cart', $cart);
     return redirect()->route('cart');
 }
 /**
  * Update the specified resource in storage.
  *
  * @param Request $request
  * @param  int  $id
  * @return Response
  */
 public function update(Request $request, $lang = 'en')
 {
     if (array_key_exists($lang, Config::get('languages'))) {
         Session::set('applocale', $lang);
     }
     return Redirect::back();
 }
Esempio n. 14
0
 public function home($lang)
 {
     $langs = ['tr', 'en'];
     if (in_array($lang, $langs)) {
         Session::set('lang', $lang);
         return Redirect::back()->with('lang_msg', 'Your Changeing language');
     }
 }
Esempio n. 15
0
 /**
  * @return mixed
  */
 private function getCart()
 {
     if (!Session::has('cart')) {
         Session::set('cart', $this->cart);
     }
     $cart = Session::get('cart');
     return $cart;
 }
 public function update(Requests\CartRequest $request, $id)
 {
     $qtd = $request->get("qtd");
     $cart = $this->getCart();
     $cart->setQtd($id, $qtd);
     Session::set('cart', $cart);
     return redirect()->route('store.cart');
 }
Esempio n. 17
0
 public function update($id, Request $request)
 {
     $cart = $this->getCart();
     $qtd = $request->get('qtd');
     $cart->updateQtd($id, $qtd);
     Session::set('cart', $cart);
     return redirect()->route('cart');
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($this->auth->check()) {
         Session::set('logged_in', '1');
         return redirect('/home');
     }
     return $next($request);
 }
 public function getContactForm(Request $request)
 {
     // if there are http-requests, store them in session
     $address = $request->input("address");
     $addressee = $request->input("addressee");
     Session::set('address', $address);
     Session::set('addressee', $addressee);
     return view('pages.contact');
 }
 protected function updateSessionRepositories(array $repositories)
 {
     $sessionRepositories = array_keys(Session::get('repositories', []));
     $sessionRepositories = array_filter($sessionRepositories, function ($repository) use($repositories) {
         return array_key_exists($repository, $repositories);
     });
     $sessionRepositories = array_fill_keys($sessionRepositories, 1);
     Session::set('repositories', $sessionRepositories);
 }
 public function alterarQtdItem()
 {
     $cart = $this->getCart();
     $id = Input::get('id');
     $qtd = Input::get('qtd');
     $arr = $cart->editarCarrinho($id, $qtd);
     $cart->editar($id, $arr[$id]['name'], $arr[$id]['price'], $qtd);
     Session::set('cart', $cart);
     return 1;
 }
Esempio n. 22
0
 public function randNumber()
 {
     $number2 = mt_rand(1, 50);
     $number1 = mt_rand(1, 50);
     Session::set('firstNb', $number1);
     Session::set('secondNb', $number2);
     $fisrtNumber = Session::get('firstNb');
     $secondNumber = Session::get('secondNb');
     return $fisrtNumber . '+' . $secondNumber;
 }
 /**
  * Display a listing of the resource.
  *
  * @return \Illuminate\Http\Response
  */
 public function index()
 {
     $filter = $this->_getPostInput();
     if (!empty($filter)) {
         Session::set('filter', $filter);
     } else {
         $filter = Session::get('filter');
     }
     $articles = $this->repository->filterBy($filter, 5);
     return view('doctrination.article.list', compact('articles', 'filter'));
 }
Esempio n. 24
0
 public function language(Request $request)
 {
     $lang = $request->input('lang');
     $allowed = \Config::get('app.locales', []);
     $allowed = array_keys($allowed);
     if (in_array($lang, $allowed)) {
         Session::set('lang', $lang);
     }
     return redirect('/');
     // return Redirect::back();
 }
Esempio n. 25
0
 public function ensureUser($forceSession = false)
 {
     if (!Session::has(config('laravel-ab.cache_key')) || $forceSession) {
         $uid = md5(uniqid() . $this->request->getClientIp());
         $laravel_ab_id = $this->request->cookie(config('laravel-ab.cache_key'), $uid);
         Session::set(config('laravel-ab.cache_key'), $uid);
     }
     if (empty(self::$session)) {
         self::$session = Instance::firstOrCreate(['instance' => Session::get(config('laravel-ab.cache_key')), 'identifier' => $this->request->getClientIp(), 'metadata' => function_exists('laravel_ab_meta') ? call_user_func('laravel_ab_meta') : null]);
     }
 }
Esempio n. 26
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!Session::has('language')) {
         $language = $this->geoIP->getISOCode();
         Session::set('language', $language);
         App::setLocale($language);
         return $next($request);
     }
     $language = Session::get('language', Config::get('app.locale'));
     App::setLocale($language);
     return $next($request);
 }
Esempio n. 27
0
 public function update($id, $quantity, Request $request)
 {
     if ($request->ajax()) {
         $cart = $this->getCart();
         if ($cart->setQuantity($id, $quantity)) {
             Session::set('cart', $cart);
             $product = Product::find($id);
             return ['success' => true, 'price' => number_format($product->price * $quantity, 2, ',', '.'), 'total' => number_format($cart->getTotal(), 2, ',', '.')];
         }
         return ['success' => false];
     }
 }
 /**
  * @return Cart
  */
 public function update_qty($id, $qty)
 {
     if (Session::has('cart')) {
         $cart = Session::get('cart');
     } else {
         $cart = $this->cart;
     }
     $conta = 0;
     $cart->update_qty($id, $qty);
     //dd($cart);
     Session::set('cart', $cart);
     return "Cart Atualizado com sucesso";
 }
Esempio n. 29
0
 /**
  * @param Request $request
  * @return $this|RedirectResponse
  */
 public function loginCheck(Request $request)
 {
     $login = $request->get('login', '');
     /** @var Validator $validator */
     $validator = ValidatorFacades::make($request->all(), ['login' => 'required|exists:exam_attendee,login']);
     if ($validator->fails()) {
         return redirect()->route('examLogin')->withErrors($validator);
     }
     /** @var Attendee $attendee */
     $attendee = Attendee::where('login', '=', $login)->first();
     Session::set('exam_attendee_login', $attendee->login);
     return back();
 }
Esempio n. 30
0
 public function postLogin()
 {
     $name = request()->input('name');
     $password = request()->input('password');
     $en = Enterprise::whereRaw('en_name = ? and en_password = ?', [$name, md5($password)]);
     if ($en->count()) {
         Session::set('name', $name);
         Session::set('navData', MenuData::jsonMenu());
         return response(['status' => 1, 'err_code' => '-1', 'err_msg' => '']);
     } else {
         return response(['status' => 0, 'err_code' => 'not found', 'err_msg' => '用户名或密码不正确']);
     }
 }