diff --git a/.htaccess b/.htaccess new file mode 100644 index 0000000000000000000000000000000000000000..f97815c26fd0f4799935b9159c06cba58e5cb0d6 --- /dev/null +++ b/.htaccess @@ -0,0 +1,4 @@ +Options -MultiViews +RewriteEngine On +RewriteCond %{REQUEST_FILENAME} !-f +RewriteRule ^ public/index.php [QSA,L] \ No newline at end of file diff --git a/public/index.php b/public/index.php new file mode 100644 index 0000000000000000000000000000000000000000..b14eceb95e995c2a1cad22102b593be205482639 --- /dev/null +++ b/public/index.php @@ -0,0 +1,9 @@ +<?php + + error_reporting(E_ALL); + ini_set('display_errors', 1); + + require __DIR__.'/../src/app.php'; + + $App = DagoJek::Instance(); + $App->Start(); \ No newline at end of file diff --git a/public/main.css b/public/main.css new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/public/scripts.js b/public/scripts.js new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/src/app.php b/src/app.php new file mode 100644 index 0000000000000000000000000000000000000000..62e26a9e7a274f85f716791bc6685baa29407aa9 --- /dev/null +++ b/src/app.php @@ -0,0 +1,59 @@ +<?php + +class DagoJek { + + private function __construct() { + // empty constructor + } + + public static function Instance() { + static $instance = null; + if ($instance === null) { + $instance = new DagoJek(); + } + + $instance->includeAllController(); + + return $instance; + } + + private function includeAllController() { + foreach (scandir(dirname(__FILE__)."/controller") as $filename) { + $path = dirname(__FILE__)."/controller" . '/' . $filename; + if (is_file($path)) { + require_once $path; + } + } + } + + private function getCurrentUri() { + $basepath = implode('/', array_slice(explode('/', $_SERVER['SCRIPT_NAME']), 0, -1)) . '/'; + $uri = substr($_SERVER['REQUEST_URI'], strlen($basepath)); + if (strstr($uri, '?')) $uri = substr($uri, 0, strpos($uri, '?')); + $uri = '/' . trim($uri, '/'); + return $uri; + } + + public function Start() { + $base_url = $this->getCurrentUri(); + switch ($base_url) { + case "/" : + echo "Login page"; + break; + case "/login" : + MainController::LoginHandler(); + break; + case "/register" : + echo "Register page"; + break; + case "/profil" : + echo "Profil page"; + break; + default : + echo "404 not found"; + } + } + +} + +?> \ No newline at end of file diff --git a/src/controller/MainController.php b/src/controller/MainController.php new file mode 100644 index 0000000000000000000000000000000000000000..30991ff78f6f880c12a900eb512cc3da4812d820 --- /dev/null +++ b/src/controller/MainController.php @@ -0,0 +1,10 @@ +<?php + +class MainController { + + public static function LoginHandler() { + echo "This is login handler"; + } + + +} \ No newline at end of file