Esempio n. 1
0
 public function handle($request, Closure $next)
 {
     $currentRoute = $request->path();
     // Check for ignore routes
     if (in_array($currentRoute, $this->ignoredRoutes)) {
         return $next($request);
     }
     // Check case for auto login
     // 1. if cookie not exist, force user logout (sync with live)
     // 2. if session_ver is different, force reset session
     // 3. if no session, create new session from cookie
     $cookieToken = $request->cookie('token');
     if (!$cookieToken && session()->has('user')) {
         Utils::setLogoutSession();
     } else {
         if ($cookieToken && (!session()->has('user') || session()->get('session_ver') !== env('SESSION_VERSION'))) {
             $userModel = new User();
             $user = $userModel->getUser('me', ['token' => $cookieToken]);
             // Update session
             $user['token'] = $cookieToken;
             Utils::setLoginSession($user);
         }
     }
     return $next($request);
 }
 public function index()
 {
     $total_expense = Utils::formatNumber($this->someAll('expense', 'value'));
     $total_recipe = Utils::formatNumber($this->someAll('recipe', 'value'));
     $this->set("total_expense", $total_expense);
     $this->set("total_recipe", $total_recipe);
     return View('home');
 }
Esempio n. 3
0
 public function textLimit($text)
 {
     return Utils::textLimit($text, 40);
 }
Esempio n. 4
0
 function getLatestLocalJPG()
 {
     $files = Utils::dirList($this->FILES_PATH, $this->ext);
     $ref = "";
     $ref1 = 0;
     // larger
     $c = 0;
     if ($files) {
         if ($files[1]) {
             for ($i = 0; $i < count($files[1]); $i++) {
                 $modified = $files[1][$i][4][9];
                 if ($modified > $ref1) {
                     $ref1 = $modified;
                     $ref = $files[1][$i][0];
                 }
                 $c++;
             }
         }
         $this->itemstotal = $c;
         return $this->FILES_PATH . $ref;
     }
     return null;
 }