Exemplo n.º 1
0
 public function __construct()
 {
     $AppSettings = new AppSettings();
     $config = $AppSettings->GetConfig();
     $databaseConfig = $config->Database->{$config->Mode};
     $this->conn = mysqli_connect($databaseConfig->host, $databaseConfig->username, $databaseConfig->password);
     mysqli_set_charset($this->conn, "utf8");
     if (mysqli_connect_errno()) {
         echo "failed to connect to mysql" . mysqli_connect_errno();
         header($_SERVER['SERVER_PROTOCOL'] . ' 500 Internal Server Error', true, 500);
     }
     mysqli_select_db($this->conn, $databaseConfig->database) or die("Nicht gefunden");
 }
Exemplo n.º 2
0
 public static function Autherize()
 {
     $appSettings = new AppSettings();
     if ($appSettings->GetConfig()->Mode == "Debug") {
         $authHeader = getallheaders()["authorization"];
     } else {
         $authHeader = $_SERVER["REDIRECT_Authorization"];
     }
     if (isset($authHeader)) {
         $token = $authHeader;
         $rememberRepository = new RememberRepository();
         $remembers = $rememberRepository->LoadWhere("Token = '{$token}'");
         if (count($remembers) == 0) {
             header('HTTP/1.0 401 Unauthorized');
             return false;
         } else {
             self::$userId = $remembers[0]["UserId"];
             return true;
         }
     } else {
         header('HTTP/1.0 401 Unauthorized');
         return false;
     }
 }