diff --git a/.env.example b/.env.example index 1570bcb..4cd7025 100644 --- a/.env.example +++ b/.env.example @@ -1,2 +1,6 @@ DEV=true +DB_HOST=mariadb +DB_USER=mapguesser +DB_PASSWORD=mapguesser +DB_NAME=mapguesser GOOGLE_MAPS_JS_API_KEY=your_google_maps_js_api_key diff --git a/install/db.sql b/install/db.sql new file mode 100644 index 0000000..538e3da --- /dev/null +++ b/install/db.sql @@ -0,0 +1,27 @@ +SET NAMES utf8mb4; +SET foreign_key_checks = 0; + + +DROP TABLE IF EXISTS `maps`; +CREATE TABLE `maps` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `name` varchar(255) NOT NULL, + `description` text NOT NULL, + `bound_south_lat` decimal(8,6) NOT NULL, + `bound_west_lng` decimal(9,6) NOT NULL, + `bound_north_lat` decimal(8,6) NOT NULL, + `bound_east_lng` decimal(9,6) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + + +DROP TABLE IF EXISTS `places`; +CREATE TABLE `places` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `map_id` int(10) unsigned NOT NULL, + `lat` decimal(8,6) NOT NULL, + `lng` decimal(9,6) NOT NULL, + PRIMARY KEY (`id`), + KEY `map_id` (`map_id`), + CONSTRAINT `places_map_id` FOREIGN KEY (`map_id`) REFERENCES `maps` (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; diff --git a/main.php b/main.php index bd37059..b8c37f0 100644 --- a/main.php +++ b/main.php @@ -2,7 +2,9 @@ require 'vendor/autoload.php'; -$dotenv = Dotenv\Dotenv::createImmutable(__DIR__); +const ROOT = __DIR__; + +$dotenv = Dotenv\Dotenv::createImmutable(ROOT); $dotenv->load(); if (!empty($_ENV['DEV'])) { diff --git a/public/.htaccess b/public/.htaccess new file mode 100644 index 0000000..3a37342 --- /dev/null +++ b/public/.htaccess @@ -0,0 +1,5 @@ +RewriteEngine On +RewriteBase / +RewriteCond %{REQUEST_FILENAME} !-d +RewriteCond %{REQUEST_FILENAME} !-f +RewriteRule ^ index.php [L] diff --git a/public/index.php b/public/index.php index 2bb1e39..cae72c9 100644 --- a/public/index.php +++ b/public/index.php @@ -2,39 +2,15 @@ require '../main.php'; -// demo position -$realPosition = new MapGuesser\Geo\Position(47.85239, 13.35101); +// very basic routing +$url = $_SERVER['REQUEST_URI']; +switch($url) { + case '/': + $controller = new MapGuesser\Controller\GuessController(); + break; + default: + echo 'Error 404'; + die; +} -// demo bounds -$bounds = new MapGuesser\Geo\Bounds($realPosition); -$bounds->extend(new MapGuesser\Geo\Position(48.07683,7.35758)); -$bounds->extend(new MapGuesser\Geo\Position(47.57496, 19.08077)); - -?> - - - - -
- -