Esempio n. 1
0
 /**
  * Sets up error-handling routines.
  *
  * UserFrosting uses Slim's custom error handler to log the error trace in the PHP error log, and then generates a client-side alert (SERVER_ERROR).
  * It can also take specific actions for certain types of exceptions, such as those thrown from middleware.
  */
 public function setupErrorHandling()
 {
     /**** Error Handling Setup ****/
     // Custom error-handler: send a generic message to the client, but put the specific error info in the error log.
     // A Slim application uses its built-in error handler if its debug setting is true; otherwise, it uses the custom error handler.
     //error_log("Registering error handler");
     $this->error(function (\Exception $e) {
         if ($e instanceof AuthExpiredException) {
             $controller = new AccountController($this);
             return $controller->logout(true);
         }
         if ($e instanceof AccountInvalidException) {
             $controller = new AccountController($this);
             return $controller->logout(false);
         }
         if ($e instanceof AuthCompromisedException) {
             $controller = new AccountController($this);
             return $controller->pageAccountCompromised();
         }
         if ($e instanceof \PDOException) {
             // Log this error
             error_log("Error in " . $e->getFile() . " on line " . $e->getLine() . ": " . $e->getMessage());
             error_log($e->getTraceAsString());
             // In case the error is because someone is trying to reinstall with new db info while still logged in, log them out
             session_destroy();
             $controller = new AccountController($this);
             return $controller->pageDatabaseError();
         }
         if ($this->alerts && is_object($this->alerts) && $this->translator) {
             $this->alerts->addMessageTranslated("danger", "SERVER_ERROR");
         }
         error_log("Error in " . $e->getFile() . " on line " . $e->getLine() . ": " . $e->getMessage());
         error_log($e->getTraceAsString());
     });
     // Also handle fatal errors
     register_shutdown_function([$this, "fatalHandler"]);
 }
Esempio n. 2
0
             		$errorView = new AccountView();
             		$sMainContentView = $errorView->signup($errors);*/
         }
     }
     break;
 case 'login':
     $loginView = new View();
     $sMainContentView = $loginView->fetch('login.tpl');
     if ($_POST) {
         $Controller = new AccountController();
         $user = $Controller->login($_POST['username'], $_POST['password']);
     }
     break;
 case 'logout':
     $Controller = new AccountController();
     $Controller->logout();
     header('location:/home');
     /*********************************************************
      *		GAME
      *********************************************************/
 /*********************************************************
  *		GAME
  *********************************************************/
 case 'instructions':
     $rulesView = new View();
     $sMainContentView = $rulesView->fetch('rules.tpl');
     break;
 case 'play':
     $CardsView = new CardsView();
     $userController = new AccountController();
     $userId = $_SESSION['user']['id'];