diff --git a/configs/nginx/folder.conf b/configs/nginx/folder.conf index 36694c1..bfac0b6 100644 --- a/configs/nginx/folder.conf +++ b/configs/nginx/folder.conf @@ -19,7 +19,7 @@ server { # PHP routing - everything under /tkr goes through index.php location /tkr { - alias /var/www/html/public; + alias /var/www/html/tkr/public; index index.php; # Cache static files @@ -37,7 +37,7 @@ server { # so bots and scanners can't tell this is a php app location = /tkr/index.php { fastcgi_pass php:9000; - fastcgi_param SCRIPT_FILENAME /var/www/html/public/index.php; + fastcgi_param SCRIPT_FILENAME /var/www/html/tkr/public/index.php; include fastcgi_params; # Additional FastCGI params @@ -60,7 +60,7 @@ server { # Fallback for /tkr routing - all non-file requests go to index.php location @tkr_fallback { fastcgi_pass php:9000; - fastcgi_param SCRIPT_FILENAME /var/www/html/public/index.php; + fastcgi_param SCRIPT_FILENAME /var/www/html/tkr/public/index.php; include fastcgi_params; # Additional FastCGI params diff --git a/docker-compose.yml b/docker-compose.yml index f763954..f1b9afd 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,7 +5,7 @@ services: ports: - "80:80" volumes: - - ./src:/var/www/html + - ./public:/var/www/html/tkr/public - ./configs/nginx/folder.conf:/etc/nginx/conf.d/default.conf depends_on: - php @@ -15,11 +15,14 @@ services: image: php:8.2-fpm-alpine container_name: php-fpm volumes: - - ./src:/var/www/html + - ./public:/var/www/html/tkr/public + - ./src:/var/www/html/tkr/src + - ./storage:/var/www/html/tkr/storage + - ./templates:/var/www/html/tkr/templates command: > sh -c " - chown -R www-data:www-data /var/www/html/storage && - chmod -R 775 /var/www/html/storage && + chown -R www-data:www-data /var/www/html/tkr/storage && + chmod -R 775 /var/www/html/tkr/storage && php-fpm " restart: unless-stopped diff --git a/src/public/css/tkr.css b/public/css/tkr.css similarity index 100% rename from src/public/css/tkr.css rename to public/css/tkr.css diff --git a/src/public/index.php b/public/index.php similarity index 87% rename from src/public/index.php rename to public/index.php index 1095f18..1acce64 100644 --- a/src/public/index.php +++ b/public/index.php @@ -3,8 +3,8 @@ define('APP_ROOT', dirname(dirname(__FILE__))); -define('CLASSES_DIR', APP_ROOT . '/classes'); -define('LIB_DIR', APP_ROOT . '/lib'); +define('CLASSES_DIR', APP_ROOT . '/src/classes'); +define('LIB_DIR', APP_ROOT . '/src/lib'); define('STORAGE_DIR', APP_ROOT . '/storage'); define('TEMPLATES_DIR', APP_ROOT . '/templates'); @@ -29,15 +29,9 @@ $isLoggedIn = isset($_SESSION['user_id']); $config = Config::load(); $user = User::load(); -// Define your base path (subdirectory) -#$basePath = '/tkr'; - -// Get HTTP data +// Get request data $method = $_SERVER['REQUEST_METHOD']; $request = $_SERVER['REQUEST_URI']; - -// Remove the base path from the URL -// and strip the trailing slash from the resulting route $path = parse_url($request, PHP_URL_PATH); // return a 404 if s request for a .php file gets this far. @@ -47,6 +41,8 @@ if (preg_match('/\.php$/', $path)) { exit; } +// Remove the base path from the URL +// and strip the trailing slash from the resulting route if (strpos($path, $config->basePath) === 0) { $path = substr($path, strlen($config->basePath)); } @@ -77,10 +73,8 @@ function route($pattern, $callback, $methods = ['GET']) { header('Content-Type: text/html; charset=utf-8'); echo "Path: " . $path; -// Define your routes +// routes route('', function() use ($isLoggedIn, $config, $user) { - #include TEMPLATES_DIR . "/home.php"; - #echo render_home_page($isLoggedIn, $config, $user); $page = isset($_GET['page']) ? max(1, (int)$_GET['page']) : 1; $limit = $config->itemsPerPage; $offset = ($page - 1) * $limit; @@ -95,4 +89,3 @@ route('', function() use ($isLoggedIn, $config, $user) { echo render_template(TEMPLATES_DIR . "/home.php", $vars); }); -//isset($_SESSION['user_id']) \ No newline at end of file diff --git a/src/public/save_tick.php b/public/save_tick.php similarity index 100% rename from src/public/save_tick.php rename to public/save_tick.php diff --git a/src/storage/.gitkeep b/storage/.gitkeep similarity index 100% rename from src/storage/.gitkeep rename to storage/.gitkeep diff --git a/src/templates/admin.php b/templates/admin.php similarity index 100% rename from src/templates/admin.php rename to templates/admin.php diff --git a/src/templates/atom/index.php b/templates/atom/index.php similarity index 100% rename from src/templates/atom/index.php rename to templates/atom/index.php diff --git a/src/templates/home.php b/templates/home.php similarity index 100% rename from src/templates/home.php rename to templates/home.php diff --git a/src/templates/login.php b/templates/login.php similarity index 100% rename from src/templates/login.php rename to templates/login.php diff --git a/src/templates/logout.php b/templates/logout.php similarity index 100% rename from src/templates/logout.php rename to templates/logout.php diff --git a/src/templates/rss/index.php b/templates/rss/index.php similarity index 100% rename from src/templates/rss/index.php rename to templates/rss/index.php diff --git a/src/templates/set_mood.php b/templates/set_mood.php similarity index 100% rename from src/templates/set_mood.php rename to templates/set_mood.php diff --git a/src/templates/setup.php b/templates/setup.php similarity index 100% rename from src/templates/setup.php rename to templates/setup.php diff --git a/src/templates/tick.php b/templates/tick.php similarity index 100% rename from src/templates/tick.php rename to templates/tick.php