Пример #1
0
 public function verify($message = null)
 {
     // Verify Existing?
     if (Cookie::has('twilio::phone') && $this->verified()) {
         return $this->verified();
     }
     // Else New Request
     $method = Input::get('method');
     $phone = preg_replace('/[^\\d]+/', '', Input::get('phone'));
     if (!Input::has('phone') || strlen($phone) < 10) {
         return $this->respond('Please supply a valid phone number.', 500);
     }
     // Create Token
     $token = $this->createToken($phone);
     // Populate Message
     $message = is_string($message) ? str_ireplace('{code}', $token['token'], $message) : null;
     // Method Responder
     switch (strtolower($method)) {
         case 'sms':
             return $this->sendSms($phone, $token, $message);
             break;
         case 'call':
             return $this->sendCall($phone, $token);
             break;
         default:
             return $this->respond('Please choose a valid verification method.', 500);
             break;
     }
     // Return Default Error
     return $this->respond('Malformed request.', 500);
 }
 /**
  * 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);
 }
 public function __construct()
 {
     $this->package = \Vsch\TranslationManager\ManagerServiceProvider::PACKAGE;
     $this->packagePrefix = $this->package . '::';
     $this->manager = App::make($this->package);
     $this->cookiePrefix = $this->manager->getConfig('persistent_prefix', 'K9N6YPi9WHwKp6E3jGbx');
     $locale = Cookie::get($this->cookieName(self::COOKIE_LANG_LOCALE), \Lang::getLocale());
     App::setLocale($locale);
     $this->primaryLocale = Cookie::get($this->cookieName(self::COOKIE_PRIM_LOCALE), $this->manager->getConfig('primary_locale', 'en'));
     $this->locales = $this->loadLocales();
     $this->translatingLocale = Cookie::get($this->cookieName(self::COOKIE_TRANS_LOCALE));
     if (!$this->translatingLocale || $this->translatingLocale === $this->primaryLocale && count($this->locales) > 1) {
         $this->translatingLocale = count($this->locales) > 1 ? $this->locales[1] : $this->locales[0];
         Cookie::queue($this->cookieName(self::COOKIE_TRANS_LOCALE), $this->translatingLocale, 60 * 24 * 365 * 1);
     }
     $this->displayLocales = Cookie::has($this->cookieName(self::COOKIE_DISP_LOCALES)) ? Cookie::get($this->cookieName(self::COOKIE_DISP_LOCALES)) : implode(',', array_slice($this->locales, 0, 5));
     $this->displayLocales .= implode(',', array_flatten(array_unique(explode(',', ($this->displayLocales ? ',' : '') . $this->primaryLocale . ',' . $this->translatingLocale))));
     //$this->sqltraces = [];
     //$this->logSql = 0;
     //
     //$thisController = $this;
     //\Event::listen('illuminate.query', function ($query, $bindings, $time, $name) use ($thisController)
     //{
     //    if ($thisController->logSql)
     //    {
     //        $thisController->sqltraces[] = ['query' => $query, 'bindings' => $bindings, 'time' => $time];
     //    }
     //});
 }
Пример #4
0
 public function __construct()
 {
     if (Cookie::has('cart')) {
         $this->storage = Cookie::get('cart');
         return;
     }
     $this->storage = [];
 }
 public static function addUserDevice()
 {
     if (Cookie::has('d_i')) {
         self::create(['user_id' => Auth::user()->id, 'uid' => Cookie::get('d_i'), 'browser' => Agent::browser(), 'platform' => Agent::platform(), 'device' => Agent::device()]);
         return true;
     } else {
         return false;
     }
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (Cookie::has('dataFromSever')) {
         $dataFromSever = Cookie::get('dataFromSever');
         if ($dataFromSever['data']['role']['partner'] == 1) {
             return $next($request);
         } elseif ($dataFromSever['data']['role']['admin'] == 1) {
             return redirect()->back();
         } else {
             $cookie = Cookie::forget('dataFromSever');
             session_start();
             session_destroy();
             return redirect()->route('get.auth.auth.login')->withCookie($cookie)->with('message_error', 'Bạn không có quyền truy cập vào dành cho người quản lý');
         }
     }
     return redirect()->route('get.auth.auth.login')->with('message_error', 'Phiên làm việc của bạn đã bị hết. Vui lòng đăng nhập lại');
 }
Пример #7
0
 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;
 }