diff options
-rw-r--r-- | README.md | 25 | ||||
-rw-r--r-- | backend/docker-test-env/compose.yml | 10 | ||||
-rw-r--r-- | backend/index.php | 17 |
3 files changed, 52 insertions, 0 deletions
diff --git a/README.md b/README.md new file mode 100644 index 0000000..d1eaec3 --- /dev/null +++ b/README.md @@ -0,0 +1,25 @@ +# Hitler Clicker + +Hitler Clicker is a simple game where you have to choose one of 3 teams to click for. +The team with the most clicks wins, except that the game is endless. + +- - - + +## Test Environment + +There is an included testing environment. Requirements are Docker and PHP. +Docker is generally not needed, you can replace it with any other DB Server. +PHP has to have the `pdo_mysql` driver enabled. + +```sh +# start mariadb +cd ./backend/docker-test-env/ +docker compose up -d + +# start api +cd .. #./backend/ +php -S localhost:8000 + +# start frontend +# coming soon... +``` diff --git a/backend/docker-test-env/compose.yml b/backend/docker-test-env/compose.yml new file mode 100644 index 0000000..fd109f9 --- /dev/null +++ b/backend/docker-test-env/compose.yml @@ -0,0 +1,10 @@ +services: + db: + image: mariadb:11 + environment: + MARIADB_ROOT_PASSWORD: aA1234Aa + MARIADB_USER: db + MARIADB_PASSWORD: aA1234Aa + MARIADB_DATABASE: hitlerclicker + ports: + - 3306:3306 diff --git a/backend/index.php b/backend/index.php new file mode 100644 index 0000000..dead696 --- /dev/null +++ b/backend/index.php @@ -0,0 +1,17 @@ +<?php +header('Content-Type: application/json; charset=UTF-8'); + +try { + $pdo = new PDO("mysql:host=127.0.0.1;dbname=hitlerclicker", "root", "aA1234Aa"); +} catch(PDOException $e) { + die('{ "status": "database offline" }'); +}; + +$query = $pdo->prepare("CREATE TABLE IF NOT EXISTS `hitlerclicker`.`stats` ( `team` VARCHAR(256) NOT NULL DEFAULT uuid() , `clicks` INT(128) unsigned zerofill NOT NULL DEFAULT '0', PRIMARY KEY (`team`) ) ENGINE = InnoDB;"); +$query->execute(); +$query = $pdo->prepare("CREATE TABLE IF NOT EXISTS `hitlerclicker`.`users` ( `name` VARCHAR(256) NOT NULL DEFAULT uuid() , `password` VARCHAR(256) NOT NULL , `team` VARCHAR(256) NOT NULL DEFAULT 'axis' , `clicks` INT(128) unsigned zerofill NOT NULL DEFAULT '0', PRIMARY KEY (`name`) ) ENGINE = InnoDB;"); +$query->execute(); + +echo '{ "status": "online" }'; + +?> |