Compare commits

...

5 Commits

Author SHA1 Message Date
d849349ad0
MAPG-243 delete unused class members
All checks were successful
mapguesser/pipeline/pr-develop This commit looks good
2023-04-07 21:10:32 +02:00
f338cc7908
MAPG-243 set COMPOSER_HOME to the workspace 2023-04-07 21:10:15 +02:00
06275975f6
MAPG-243 install git in Dockerfile-test 2023-04-07 21:10:15 +02:00
c565fc2b65
MAPG-243 replace and adapt to soko-web 2023-04-07 21:10:14 +02:00
0bfebec8ca
MAPG-243 install soko-web by composer 2023-04-07 21:10:14 +02:00
44 changed files with 1200 additions and 879 deletions

View File

@ -1,4 +1,5 @@
APP_NAME=MapGuesser APP_NAME=MapGuesser
APP_URL=mapguesser.dev
DEV=1 DEV=1
DB_HOST=mariadb DB_HOST=mariadb
DB_USER=mapguesser DB_USER=mapguesser

3
Jenkinsfile vendored
View File

@ -8,6 +8,9 @@ pipeline {
stages { stages {
stage('Install composer') { stage('Install composer') {
environment {
COMPOSER_HOME="${WORKSPACE}/.composer"
}
agent { agent {
dockerfile { dockerfile {
filename 'docker/Dockerfile-test' filename 'docker/Dockerfile-test'

View File

@ -3,15 +3,19 @@
"type": "project", "type": "project",
"description": "MapGuesser Application", "description": "MapGuesser Application",
"license": "GNU GPL 3.0", "license": "GNU GPL 3.0",
"repositories": [
{
"url": "https://git.esoko.eu/esoko/soko-web.git",
"type": "git"
}
],
"require": { "require": {
"vlucas/phpdotenv": "^4.1", "esoko/soko-web": "0.1",
"symfony/console": "^5.1",
"phpmailer/phpmailer": "^6.1",
"fzaninotto/faker": "^1.9" "fzaninotto/faker": "^1.9"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "^9", "phpunit/phpunit": "^9.6",
"phpstan/phpstan": "^0.12.32" "phpstan/phpstan": "^1.10"
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {

1758
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,8 @@
<?php <?php
use MapGuesser\Database\Query\Modify; use SokoWeb\Database\Query\Modify;
use MapGuesser\Database\Query\Select; use SokoWeb\Database\Query\Select;
use MapGuesser\Interfaces\Database\IResultSet; use SokoWeb\Interfaces\Database\IResultSet;
use MapGuesser\Util\Geo\Bounds; use MapGuesser\Util\Geo\Bounds;
$select = new Select(\Container::$dbConnection, 'maps'); $select = new Select(\Container::$dbConnection, 'maps');

View File

@ -1,8 +1,8 @@
<?php <?php
use MapGuesser\Database\Query\Modify; use SokoWeb\Database\Query\Modify;
use MapGuesser\Database\Query\Select; use SokoWeb\Database\Query\Select;
use MapGuesser\Interfaces\Database\IResultSet; use SokoWeb\Interfaces\Database\IResultSet;
$select = new Select(\Container::$dbConnection, 'users'); $select = new Select(\Container::$dbConnection, 'users');
$select->columns(['id']); $select->columns(['id']);

View File

@ -1,4 +1,6 @@
FROM php:7.4.7-cli-buster FROM ubuntu:focal
RUN apt-get update && apt-get install -y unzip ENV DEBIAN_FRONTEND noninteractive
RUN apt update && apt install -y curl git unzip php7.4-cli php7.4-mbstring php7.4-xml
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer

View File

@ -14,10 +14,10 @@ $dotenv->load();
class Container class Container
{ {
static MapGuesser\Interfaces\Database\IConnection $dbConnection; static SokoWeb\Interfaces\Database\IConnection $dbConnection;
static MapGuesser\Routing\RouteCollection $routeCollection; static SokoWeb\Routing\RouteCollection $routeCollection;
static MapGuesser\Interfaces\Session\ISessionHandler $sessionHandler; static SokoWeb\Interfaces\Session\ISessionHandler $sessionHandler;
static MapGuesser\Interfaces\Request\IRequest $request; static SokoWeb\Interfaces\Request\IRequest $request;
} }
Container::$dbConnection = new MapGuesser\Database\Mysql\Connection($_ENV['DB_HOST'], $_ENV['DB_USER'], $_ENV['DB_PASSWORD'], $_ENV['DB_NAME']); Container::$dbConnection = new SokoWeb\Database\Mysql\Connection($_ENV['DB_HOST'], $_ENV['DB_USER'], $_ENV['DB_PASSWORD'], $_ENV['DB_NAME']);

2
mapg
View File

@ -8,6 +8,6 @@ $app = new Symfony\Component\Console\Application('MapGuesser Console', '');
$app->add(new MapGuesser\Cli\MigrateDatabaseCommand()); $app->add(new MapGuesser\Cli\MigrateDatabaseCommand());
$app->add(new MapGuesser\Cli\AddUserCommand()); $app->add(new MapGuesser\Cli\AddUserCommand());
$app->add(new MapGuesser\Cli\LinkViewCommand()); $app->add(new MapGuesser\Cli\LinkViewCommand());
$app->add(new \MapGuesser\Cli\MaintainDatabaseCommand()); $app->add(new MapGuesser\Cli\MaintainDatabaseCommand());
$app->run(); $app->run();

View File

@ -19,14 +19,14 @@ if ($match !== null) {
$handler = $route->getHandler(); $handler = $route->getHandler();
$controller = new $handler[0](Container::$request); $controller = new $handler[0](Container::$request);
if ($controller instanceof MapGuesser\Interfaces\Authorization\ISecured) { if ($controller instanceof SokoWeb\Interfaces\Authorization\ISecured) {
$authorized = $controller->authorize(); $authorized = $controller->authorize();
} else { } else {
$authorized = true; $authorized = true;
} }
if ($method === 'post' && Container::$request->post('anti_csrf_token') !== Container::$request->session()->get('anti_csrf_token')) { if ($method === 'post' && Container::$request->post('anti_csrf_token') !== Container::$request->session()->get('anti_csrf_token')) {
$content = new MapGuesser\Response\JsonContent(['error' => 'no_valid_anti_csrf_token']); $content = new SokoWeb\Response\JsonContent(['error' => 'no_valid_anti_csrf_token']);
header('Content-Type: text/html; charset=UTF-8', true, 403); header('Content-Type: text/html; charset=UTF-8', true, 403);
$content->render(); $content->render();
return; return;
@ -35,12 +35,12 @@ if ($match !== null) {
if ($authorized) { if ($authorized) {
$response = call_user_func([$controller, $handler[1]]); $response = call_user_func([$controller, $handler[1]]);
if ($response instanceof MapGuesser\Interfaces\Response\IContent) { if ($response instanceof SokoWeb\Interfaces\Response\IContent) {
header('Content-Type: ' . $response->getContentType() . '; charset=UTF-8'); header('Content-Type: ' . $response->getContentType() . '; charset=UTF-8');
$response->render(); $response->render();
return; return;
} elseif ($response instanceof MapGuesser\Interfaces\Response\IRedirect) { } elseif ($response instanceof SokoWeb\Interfaces\Response\IRedirect) {
header('Location: ' . $response->getUrl(), true, $response->getHttpCode()); header('Location: ' . $response->getUrl(), true, $response->getHttpCode());
return; return;
@ -48,6 +48,6 @@ if ($match !== null) {
} }
} }
$content = new MapGuesser\Response\HtmlContent('error/404'); $content = new SokoWeb\Response\HtmlContent('error/404');
header('Content-Type: text/html; charset=UTF-8', true, 404); header('Content-Type: text/html; charset=UTF-8', true, 404);
$content->render(); $content->render();

View File

@ -1,7 +1,7 @@
<?php namespace MapGuesser\Cli; <?php namespace MapGuesser\Cli;
use DateTime; use DateTime;
use MapGuesser\PersistentData\PersistentDataManager; use SokoWeb\PersistentData\PersistentDataManager;
use MapGuesser\PersistentData\Model\User; use MapGuesser\PersistentData\Model\User;
use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;

View File

@ -1,7 +1,7 @@
<?php namespace MapGuesser\Cli; <?php namespace MapGuesser\Cli;
use FilesystemIterator; use FilesystemIterator;
use MapGuesser\View\Linker; use SokoWeb\View\Linker;
use RecursiveDirectoryIterator; use RecursiveDirectoryIterator;
use RecursiveIteratorIterator; use RecursiveIteratorIterator;
use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Command\Command;

View File

@ -1,10 +1,10 @@
<?php namespace MapGuesser\Cli; <?php namespace MapGuesser\Cli;
use DateTime; use DateTime;
use MapGuesser\Database\Query\Modify; use SokoWeb\Database\Query\Modify;
use MapGuesser\Database\Query\Select; use SokoWeb\Database\Query\Select;
use MapGuesser\Interfaces\Database\IResultSet; use SokoWeb\Interfaces\Database\IResultSet;
use MapGuesser\PersistentData\PersistentDataManager; use SokoWeb\PersistentData\PersistentDataManager;
use MapGuesser\Repository\MultiRoomRepository; use MapGuesser\Repository\MultiRoomRepository;
use MapGuesser\Repository\UserConfirmationRepository; use MapGuesser\Repository\UserConfirmationRepository;
use MapGuesser\Repository\UserPasswordResetterRepository; use MapGuesser\Repository\UserPasswordResetterRepository;

View File

@ -1,8 +1,8 @@
<?php namespace MapGuesser\Cli; <?php namespace MapGuesser\Cli;
use MapGuesser\Database\Query\Modify; use SokoWeb\Database\Query\Modify;
use MapGuesser\Database\Query\Select; use SokoWeb\Database\Query\Select;
use MapGuesser\Interfaces\Database\IResultSet; use SokoWeb\Interfaces\Database\IResultSet;
use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;

View File

@ -2,24 +2,24 @@
use DateTime; use DateTime;
use Faker\Factory; use Faker\Factory;
use MapGuesser\Interfaces\Authorization\ISecured; use SokoWeb\Interfaces\Authorization\ISecured;
use MapGuesser\Interfaces\Request\IRequest; use SokoWeb\Interfaces\Request\IRequest;
use MapGuesser\Response\HtmlContent; use SokoWeb\Response\HtmlContent;
use MapGuesser\Response\JsonContent; use SokoWeb\Response\JsonContent;
use MapGuesser\Interfaces\Response\IContent; use SokoWeb\Interfaces\Response\IContent;
use MapGuesser\Interfaces\Response\IRedirect; use SokoWeb\Interfaces\Response\IRedirect;
use MapGuesser\Multi\MultiConnector; use MapGuesser\Multi\MultiConnector;
use MapGuesser\PersistentData\Model\Challenge; use MapGuesser\PersistentData\Model\Challenge;
use MapGuesser\PersistentData\Model\MultiRoom; use MapGuesser\PersistentData\Model\MultiRoom;
use MapGuesser\PersistentData\Model\PlaceInChallenge; use MapGuesser\PersistentData\Model\PlaceInChallenge;
use MapGuesser\PersistentData\Model\UserInChallenge; use MapGuesser\PersistentData\Model\UserInChallenge;
use MapGuesser\PersistentData\PersistentDataManager; use SokoWeb\PersistentData\PersistentDataManager;
use MapGuesser\Repository\ChallengeRepository; use MapGuesser\Repository\ChallengeRepository;
use MapGuesser\Repository\MapRepository; use MapGuesser\Repository\MapRepository;
use MapGuesser\Repository\MultiRoomRepository; use MapGuesser\Repository\MultiRoomRepository;
use MapGuesser\Repository\PlaceRepository; use MapGuesser\Repository\PlaceRepository;
use MapGuesser\Repository\UserInChallengeRepository; use MapGuesser\Repository\UserInChallengeRepository;
use MapGuesser\Response\Redirect; use SokoWeb\Response\Redirect;
class GameController implements ISecured class GameController implements ISecured
{ {
@ -103,7 +103,7 @@ class GameController implements ISecured
} }
public function getChallenge(): IContent public function getChallenge(): IContent
{ {
$challengeToken = $this->request->query('challengeToken'); $challengeToken = $this->request->query('challengeToken');
return new HtmlContent('game', ['challengeToken' => $challengeToken]); return new HtmlContent('game', ['challengeToken' => $challengeToken]);
@ -120,7 +120,7 @@ class GameController implements ISecured
$challenge = new Challenge(); $challenge = new Challenge();
$challenge->setToken($challengeToken); $challenge->setToken($challengeToken);
$challenge->setCreatedDate(new DateTime()); $challenge->setCreatedDate(new DateTime());
if ($this->request->post('timerEnabled') !== null && $this->request->post('timeLimit') !== null) { if ($this->request->post('timerEnabled') !== null && $this->request->post('timeLimit') !== null) {
$challenge->setTimeLimit($this->request->post('timeLimit')); $challenge->setTimeLimit($this->request->post('timeLimit'));
} }

View File

@ -1,13 +1,13 @@
<?php namespace MapGuesser\Controller; <?php namespace MapGuesser\Controller;
use DateTime; use DateTime;
use MapGuesser\Interfaces\Authorization\ISecured; use SokoWeb\Interfaces\Authorization\ISecured;
use MapGuesser\Interfaces\Request\IRequest; use SokoWeb\Interfaces\Request\IRequest;
use MapGuesser\Util\Geo\Position; use MapGuesser\Util\Geo\Position;
use MapGuesser\Response\JsonContent; use SokoWeb\Response\JsonContent;
use MapGuesser\Interfaces\Response\IContent; use SokoWeb\Interfaces\Response\IContent;
use MapGuesser\Multi\MultiConnector; use MapGuesser\Multi\MultiConnector;
use MapGuesser\PersistentData\PersistentDataManager; use SokoWeb\PersistentData\PersistentDataManager;
use MapGuesser\PersistentData\Model\Challenge; use MapGuesser\PersistentData\Model\Challenge;
use MapGuesser\PersistentData\Model\Guess; use MapGuesser\PersistentData\Model\Guess;
use MapGuesser\PersistentData\Model\Map; use MapGuesser\PersistentData\Model\Map;
@ -40,14 +40,8 @@ class GameFlowController implements ISecured
private PlaceRepository $placeRepository; private PlaceRepository $placeRepository;
private MapRepository $mapRepository;
private UserRepository $userRepository;
private UserPlayedPlaceRepository $userPlayedPlaceRepository; private UserPlayedPlaceRepository $userPlayedPlaceRepository;
private ChallengeRepository $challengeRepository;
private UserInChallengeRepository $userInChallengeRepository; private UserInChallengeRepository $userInChallengeRepository;
private PlaceInChallengeRepository $placeInChallengeRepository; private PlaceInChallengeRepository $placeInChallengeRepository;
@ -61,10 +55,7 @@ class GameFlowController implements ISecured
$this->multiConnector = new MultiConnector(); $this->multiConnector = new MultiConnector();
$this->multiRoomRepository = new MultiRoomRepository(); $this->multiRoomRepository = new MultiRoomRepository();
$this->placeRepository = new PlaceRepository(); $this->placeRepository = new PlaceRepository();
$this->mapRepository = new MapRepository();
$this->userRepository = new UserRepository();
$this->userPlayedPlaceRepository = new UserPlayedPlaceRepository(); $this->userPlayedPlaceRepository = new UserPlayedPlaceRepository();
$this->challengeRepository = new ChallengeRepository();
$this->userInChallengeRepository = new UserInChallengeRepository(); $this->userInChallengeRepository = new UserInChallengeRepository();
$this->placeInChallengeRepository = new PlaceInChallengeRepository(); $this->placeInChallengeRepository = new PlaceInChallengeRepository();
$this->guessRepository = new GuessRepository(); $this->guessRepository = new GuessRepository();
@ -154,16 +145,16 @@ class GameFlowController implements ISecured
private function prepareChallengeResponse(int $userId, Challenge $challenge, int $currentRound, bool $withHistory = false): array private function prepareChallengeResponse(int $userId, Challenge $challenge, int $currentRound, bool $withHistory = false): array
{ {
$currentPlace = $this->placeRepository->getByRoundInChallenge($challenge, $currentRound); $currentPlace = $this->placeRepository->getByRoundInChallenge($challenge, $currentRound);
// if the last round was played ($currentPlace == null) or history is explicitly requested (for initializing) // if the last round was played ($currentPlace == null) or history is explicitly requested (for initializing)
if (!isset($currentPlace) || $withHistory) { if (!isset($currentPlace) || $withHistory) {
$withRelations = [User::class, PlaceInChallenge::class, Place::class]; $withRelations = [User::class, PlaceInChallenge::class, Place::class];
foreach ($this->guessRepository->getAllInChallenge($challenge, $withRelations) as $guess) { foreach ($this->guessRepository->getAllInChallenge($challenge, $withRelations) as $guess) {
$round = $guess->getPlaceInChallenge()->getRound(); $round = $guess->getPlaceInChallenge()->getRound();
if ($guess->getUser()->getId() === $userId) { if ($guess->getUser()->getId() === $userId) {
$response['history'][$round]['position'] = $response['history'][$round]['position'] =
$guess->getPlaceInChallenge()->getPlace()->getPosition()->toArray(); $guess->getPlaceInChallenge()->getPlace()->getPosition()->toArray();
$response['history'][$round]['result'] = [ $response['history'][$round]['result'] = [
'guessPosition' => $guess->getPosition()->toArray(), 'guessPosition' => $guess->getPosition()->toArray(),
@ -188,8 +179,8 @@ class GameFlowController implements ISecured
'distance' => null, 'distance' => null,
'score' => 0 'score' => 0
]; ];
$response['history'][$i]['position'] = $response['history'][$i]['position'] =
$this->placeRepository->getByRoundInChallenge($challenge, $i)->getPosition()->toArray(); $this->placeRepository->getByRoundInChallenge($challenge, $i)->getPosition()->toArray();
} }
} }
@ -250,7 +241,7 @@ class GameFlowController implements ISecured
if ($challenge->getTimeLimitType() === 'game' && $challenge->getTimeLimit() !== null && $userInChallenge->getCurrentRound() > 0) { if ($challenge->getTimeLimitType() === 'game' && $challenge->getTimeLimit() !== null && $userInChallenge->getCurrentRound() > 0) {
$timeLimit = max(10, $userInChallenge->getTimeLeft()); $timeLimit = max(10, $userInChallenge->getTimeLeft());
$response['restrictions']['timeLimit'] = $timeLimit * 1000; $response['restrictions']['timeLimit'] = $timeLimit * 1000;
} }
return new JsonContent($response); return new JsonContent($response);
} }

View File

@ -1,10 +1,10 @@
<?php namespace MapGuesser\Controller; <?php namespace MapGuesser\Controller;
use MapGuesser\Interfaces\Request\IRequest; use SokoWeb\Interfaces\Request\IRequest;
use MapGuesser\Interfaces\Response\IContent; use SokoWeb\Interfaces\Response\IContent;
use MapGuesser\Interfaces\Response\IRedirect; use SokoWeb\Interfaces\Response\IRedirect;
use MapGuesser\Response\JsonContent; use SokoWeb\Response\JsonContent;
use MapGuesser\Response\Redirect; use SokoWeb\Response\Redirect;
class HomeController class HomeController
{ {

View File

@ -2,25 +2,25 @@
use DateInterval; use DateInterval;
use DateTime; use DateTime;
use MapGuesser\Http\Request; use SokoWeb\Http\Request;
use MapGuesser\Interfaces\Request\IRequest; use SokoWeb\Interfaces\Request\IRequest;
use MapGuesser\Interfaces\Response\IContent; use SokoWeb\Interfaces\Response\IContent;
use MapGuesser\Interfaces\Response\IRedirect; use SokoWeb\Interfaces\Response\IRedirect;
use MapGuesser\Mailing\Mail; use SokoWeb\Mailing\Mail;
use MapGuesser\OAuth\GoogleOAuth; use SokoWeb\OAuth\GoogleOAuth;
use MapGuesser\PersistentData\Model\User; use MapGuesser\PersistentData\Model\User;
use MapGuesser\PersistentData\Model\UserConfirmation; use MapGuesser\PersistentData\Model\UserConfirmation;
use MapGuesser\PersistentData\Model\UserPasswordResetter; use MapGuesser\PersistentData\Model\UserPasswordResetter;
use MapGuesser\PersistentData\PersistentDataManager; use SokoWeb\PersistentData\PersistentDataManager;
use MapGuesser\Repository\UserConfirmationRepository; use MapGuesser\Repository\UserConfirmationRepository;
use MapGuesser\Repository\UserPasswordResetterRepository; use MapGuesser\Repository\UserPasswordResetterRepository;
use MapGuesser\Repository\UserPlayedPlaceRepository; use MapGuesser\Repository\UserPlayedPlaceRepository;
use MapGuesser\Repository\UserRepository; use MapGuesser\Repository\UserRepository;
use MapGuesser\Response\HtmlContent; use SokoWeb\Response\HtmlContent;
use MapGuesser\Response\JsonContent; use SokoWeb\Response\JsonContent;
use MapGuesser\Response\Redirect; use SokoWeb\Response\Redirect;
use MapGuesser\Util\CaptchaValidator; use SokoWeb\Util\CaptchaValidator;
use MapGuesser\Util\JwtParser; use SokoWeb\Util\JwtParser;
class LoginController class LoginController
{ {

View File

@ -1,15 +1,15 @@
<?php namespace MapGuesser\Controller; <?php namespace MapGuesser\Controller;
use DateTime; use DateTime;
use MapGuesser\Interfaces\Authentication\IUser; use SokoWeb\Interfaces\Authentication\IUser;
use MapGuesser\Interfaces\Authorization\ISecured; use SokoWeb\Interfaces\Authorization\ISecured;
use MapGuesser\Interfaces\Request\IRequest; use SokoWeb\Interfaces\Request\IRequest;
use MapGuesser\Interfaces\Response\IContent; use SokoWeb\Interfaces\Response\IContent;
use MapGuesser\PersistentData\Model\Challenge; use MapGuesser\PersistentData\Model\Challenge;
use MapGuesser\PersistentData\Model\Map; use MapGuesser\PersistentData\Model\Map;
use MapGuesser\PersistentData\Model\Place; use MapGuesser\PersistentData\Model\Place;
use MapGuesser\PersistentData\Model\PlaceInChallenge; use MapGuesser\PersistentData\Model\PlaceInChallenge;
use MapGuesser\PersistentData\PersistentDataManager; use SokoWeb\PersistentData\PersistentDataManager;
use MapGuesser\Repository\ChallengeRepository; use MapGuesser\Repository\ChallengeRepository;
use MapGuesser\Repository\GuessRepository; use MapGuesser\Repository\GuessRepository;
use MapGuesser\Repository\MapRepository; use MapGuesser\Repository\MapRepository;
@ -17,8 +17,8 @@ use MapGuesser\Repository\PlaceInChallengeRepository;
use MapGuesser\Repository\PlaceRepository; use MapGuesser\Repository\PlaceRepository;
use MapGuesser\Repository\UserInChallengeRepository; use MapGuesser\Repository\UserInChallengeRepository;
use MapGuesser\Repository\UserPlayedPlaceRepository; use MapGuesser\Repository\UserPlayedPlaceRepository;
use MapGuesser\Response\HtmlContent; use SokoWeb\Response\HtmlContent;
use MapGuesser\Response\JsonContent; use SokoWeb\Response\JsonContent;
use MapGuesser\Util\Geo\Bounds; use MapGuesser\Util\Geo\Bounds;
use MapGuesser\Util\Panorama\Pov; use MapGuesser\Util\Panorama\Pov;

View File

@ -1,12 +1,12 @@
<?php namespace MapGuesser\Controller; <?php namespace MapGuesser\Controller;
use MapGuesser\Database\Query\Select; use SokoWeb\Database\Query\Select;
use MapGuesser\Database\RawExpression; use SokoWeb\Database\RawExpression;
use MapGuesser\Interfaces\Authentication\IUser; use SokoWeb\Interfaces\Authentication\IUser;
use MapGuesser\Interfaces\Database\IResultSet; use SokoWeb\Interfaces\Database\IResultSet;
use MapGuesser\Interfaces\Request\IRequest; use SokoWeb\Interfaces\Request\IRequest;
use MapGuesser\Interfaces\Response\IContent; use SokoWeb\Interfaces\Response\IContent;
use MapGuesser\Response\HtmlContent; use SokoWeb\Response\HtmlContent;
class MapsController class MapsController
{ {

View File

@ -1,24 +1,23 @@
<?php namespace MapGuesser\Controller; <?php namespace MapGuesser\Controller;
use DateTime; use DateTime;
use MapGuesser\Http\Request; use SokoWeb\Http\Request;
use MapGuesser\Interfaces\Authorization\ISecured; use SokoWeb\Interfaces\Authorization\ISecured;
use MapGuesser\Interfaces\Request\IRequest; use SokoWeb\Interfaces\Request\IRequest;
use MapGuesser\Interfaces\Response\IContent; use SokoWeb\Interfaces\Response\IContent;
use MapGuesser\Interfaces\Response\IRedirect; use SokoWeb\Interfaces\Response\IRedirect;
use MapGuesser\OAuth\GoogleOAuth; use SokoWeb\OAuth\GoogleOAuth;
use MapGuesser\PersistentData\PersistentDataManager; use SokoWeb\PersistentData\PersistentDataManager;
use MapGuesser\PersistentData\Model\User; use MapGuesser\PersistentData\Model\User;
use MapGuesser\PersistentData\Model\UserInChallenge;
use MapGuesser\Repository\GuessRepository; use MapGuesser\Repository\GuessRepository;
use MapGuesser\Repository\UserConfirmationRepository; use MapGuesser\Repository\UserConfirmationRepository;
use MapGuesser\Repository\UserInChallengeRepository; use MapGuesser\Repository\UserInChallengeRepository;
use MapGuesser\Repository\UserPasswordResetterRepository; use MapGuesser\Repository\UserPasswordResetterRepository;
use MapGuesser\Repository\UserPlayedPlaceRepository; use MapGuesser\Repository\UserPlayedPlaceRepository;
use MapGuesser\Response\HtmlContent; use SokoWeb\Response\HtmlContent;
use MapGuesser\Response\JsonContent; use SokoWeb\Response\JsonContent;
use MapGuesser\Response\Redirect; use SokoWeb\Response\Redirect;
use MapGuesser\Util\JwtParser; use SokoWeb\Util\JwtParser;
class UserController implements ISecured class UserController implements ISecured
{ {

View File

@ -1,6 +1,7 @@
<?php namespace MapGuesser\PersistentData\Model; <?php namespace MapGuesser\PersistentData\Model;
use DateTime; use DateTime;
use SokoWeb\PersistentData\Model\Model;
class Challenge extends Model class Challenge extends Model
{ {

View File

@ -1,5 +1,6 @@
<?php namespace MapGuesser\PersistentData\Model; <?php namespace MapGuesser\PersistentData\Model;
use SokoWeb\PersistentData\Model\Model;
use MapGuesser\Util\Geo\Position; use MapGuesser\Util\Geo\Position;
class Guess extends Model class Guess extends Model

View File

@ -1,5 +1,6 @@
<?php namespace MapGuesser\PersistentData\Model; <?php namespace MapGuesser\PersistentData\Model;
use SokoWeb\PersistentData\Model\Model;
use MapGuesser\Util\Geo\Bounds; use MapGuesser\Util\Geo\Bounds;
class Map extends Model class Map extends Model

View File

@ -1,6 +1,7 @@
<?php namespace MapGuesser\PersistentData\Model; <?php namespace MapGuesser\PersistentData\Model;
use DateTime; use DateTime;
use SokoWeb\PersistentData\Model\Model;
class MultiRoom extends Model class MultiRoom extends Model
{ {

View File

@ -2,8 +2,9 @@
use DateInterval; use DateInterval;
use DateTime; use DateTime;
use MapGuesser\Http\Request; use SokoWeb\PersistentData\Model\Model;
use MapGuesser\PersistentData\PersistentDataManager; use SokoWeb\Http\Request;
use SokoWeb\PersistentData\PersistentDataManager;
use MapGuesser\Util\Geo\Position; use MapGuesser\Util\Geo\Position;
use MapGuesser\Util\Panorama\Pov; use MapGuesser\Util\Panorama\Pov;

View File

@ -1,5 +1,7 @@
<?php namespace MapGuesser\PersistentData\Model; <?php namespace MapGuesser\PersistentData\Model;
use SokoWeb\PersistentData\Model\Model;
class PlaceInChallenge extends Model class PlaceInChallenge extends Model
{ {
protected static string $table = 'place_in_challenge'; protected static string $table = 'place_in_challenge';

View File

@ -1,7 +1,8 @@
<?php namespace MapGuesser\PersistentData\Model; <?php namespace MapGuesser\PersistentData\Model;
use DateTime; use DateTime;
use MapGuesser\Interfaces\Authentication\IUser; use SokoWeb\PersistentData\Model\Model;
use SokoWeb\Interfaces\Authentication\IUser;
class User extends Model implements IUser class User extends Model implements IUser
{ {

View File

@ -1,6 +1,7 @@
<?php namespace MapGuesser\PersistentData\Model; <?php namespace MapGuesser\PersistentData\Model;
use DateTime; use DateTime;
use SokoWeb\PersistentData\Model\Model;
class UserConfirmation extends Model class UserConfirmation extends Model
{ {

View File

@ -1,5 +1,7 @@
<?php namespace MapGuesser\PersistentData\Model; <?php namespace MapGuesser\PersistentData\Model;
use SokoWeb\PersistentData\Model\Model;
class UserInChallenge extends Model class UserInChallenge extends Model
{ {
protected static string $table = 'user_in_challenge'; protected static string $table = 'user_in_challenge';

View File

@ -1,6 +1,7 @@
<?php namespace MapGuesser\PersistentData\Model; <?php namespace MapGuesser\PersistentData\Model;
use DateTime; use DateTime;
use SokoWeb\PersistentData\Model\Model;
class UserPasswordResetter extends Model class UserPasswordResetter extends Model
{ {

View File

@ -1,6 +1,7 @@
<?php namespace MapGuesser\PersistentData\Model; <?php namespace MapGuesser\PersistentData\Model;
use DateTime; use DateTime;
use SokoWeb\PersistentData\Model\Model;
class UserPlayedPlace extends Model class UserPlayedPlace extends Model
{ {

View File

@ -1,11 +1,11 @@
<?php namespace MapGuesser\Repository; <?php namespace MapGuesser\Repository;
use Generator; use Generator;
use MapGuesser\Database\Query\Select; use SokoWeb\Database\Query\Select;
use MapGuesser\PersistentData\Model\Challenge; use MapGuesser\PersistentData\Model\Challenge;
use MapGuesser\PersistentData\Model\Place; use MapGuesser\PersistentData\Model\Place;
use MapGuesser\PersistentData\Model\User; use MapGuesser\PersistentData\Model\User;
use MapGuesser\PersistentData\PersistentDataManager; use SokoWeb\PersistentData\PersistentDataManager;
class ChallengeRepository class ChallengeRepository
{ {
@ -25,7 +25,7 @@ class ChallengeRepository
{ {
$select = new Select(\Container::$dbConnection); $select = new Select(\Container::$dbConnection);
$select->where('token', '=', $token); $select->where('token', '=', $token);
return $this->pdm->selectFromDb($select, Challenge::class); return $this->pdm->selectFromDb($select, Challenge::class);
} }
@ -72,4 +72,4 @@ class ChallengeRepository
yield from $this->pdm->selectMultipleFromDb($select, Challenge::class); yield from $this->pdm->selectMultipleFromDb($select, Challenge::class);
} }
} }

View File

@ -1,14 +1,13 @@
<?php namespace MapGuesser\Repository; <?php namespace MapGuesser\Repository;
use Generator; use Generator;
use MapGuesser\Database\Query\Select; use SokoWeb\Database\Query\Select;
use MapGuesser\PersistentData\Model\Challenge; use MapGuesser\PersistentData\Model\Challenge;
use MapGuesser\PersistentData\Model\Guess; use MapGuesser\PersistentData\Model\Guess;
use MapGuesser\PersistentData\Model\User; use MapGuesser\PersistentData\Model\User;
use MapGuesser\PersistentData\Model\UserInChallenge;
use MapGuesser\PersistentData\Model\Place; use MapGuesser\PersistentData\Model\Place;
use MapGuesser\PersistentData\Model\PlaceInChallenge; use MapGuesser\PersistentData\Model\PlaceInChallenge;
use MapGuesser\PersistentData\PersistentDataManager; use SokoWeb\PersistentData\PersistentDataManager;
class GuessRepository class GuessRepository
{ {
@ -79,7 +78,7 @@ class GuessRepository
$necessaryRelations = [PlaceInChallenge::class]; $necessaryRelations = [PlaceInChallenge::class];
$withRelations = array_unique(array_merge($withRelations, $necessaryRelations)); $withRelations = array_unique(array_merge($withRelations, $necessaryRelations));
} }
$select = new Select(\Container::$dbConnection); $select = new Select(\Container::$dbConnection);
$select->where('challenge_id', '=', $challenge->getId()); $select->where('challenge_id', '=', $challenge->getId());
$select->where('round', '=', $round); $select->where('round', '=', $round);

View File

@ -1,10 +1,10 @@
<?php namespace MapGuesser\Repository; <?php namespace MapGuesser\Repository;
use MapGuesser\Database\Query\Select; use SokoWeb\Database\Query\Select;
use MapGuesser\PersistentData\Model\Challenge; use MapGuesser\PersistentData\Model\Challenge;
use MapGuesser\PersistentData\Model\Map; use MapGuesser\PersistentData\Model\Map;
use MapGuesser\PersistentData\Model\Place; use MapGuesser\PersistentData\Model\Place;
use MapGuesser\PersistentData\PersistentDataManager; use SokoWeb\PersistentData\PersistentDataManager;
class MapRepository class MapRepository
{ {

View File

@ -2,9 +2,9 @@
use DateTime; use DateTime;
use Generator; use Generator;
use MapGuesser\Database\Query\Select; use SokoWeb\Database\Query\Select;
use MapGuesser\PersistentData\Model\MultiRoom; use MapGuesser\PersistentData\Model\MultiRoom;
use MapGuesser\PersistentData\PersistentDataManager; use SokoWeb\PersistentData\PersistentDataManager;
class MultiRoomRepository class MultiRoomRepository
{ {

View File

@ -1,12 +1,11 @@
<?php namespace MapGuesser\Repository; <?php namespace MapGuesser\Repository;
use Generator; use Generator;
use MapGuesser\Database\Query\Select; use SokoWeb\Database\Query\Select;
use MapGuesser\PersistentData\Model\Challenge; use MapGuesser\PersistentData\Model\Challenge;
use MapGuesser\PersistentData\Model\Map;
use MapGuesser\PersistentData\Model\Place; use MapGuesser\PersistentData\Model\Place;
use MapGuesser\PersistentData\Model\PlaceInChallenge; use MapGuesser\PersistentData\Model\PlaceInChallenge;
use MapGuesser\PersistentData\PersistentDataManager; use SokoWeb\PersistentData\PersistentDataManager;
class PlaceInChallengeRepository class PlaceInChallengeRepository
{ {

View File

@ -1,11 +1,11 @@
<?php namespace MapGuesser\Repository; <?php namespace MapGuesser\Repository;
use Generator; use Generator;
use MapGuesser\Database\Query\Select; use SokoWeb\Database\Query\Select;
use MapGuesser\PersistentData\Model\Challenge; use MapGuesser\PersistentData\Model\Challenge;
use MapGuesser\PersistentData\Model\Map; use MapGuesser\PersistentData\Model\Map;
use MapGuesser\PersistentData\Model\Place; use MapGuesser\PersistentData\Model\Place;
use MapGuesser\PersistentData\PersistentDataManager; use SokoWeb\PersistentData\PersistentDataManager;
class PlaceRepository class PlaceRepository
{ {
@ -41,7 +41,7 @@ class PlaceRepository
} }
$oldPlaces = $this->getRandomOldNForMapWithValidPano($mapId, $n - count($unvisitedPlaces), $userId); $oldPlaces = $this->getRandomOldNForMapWithValidPano($mapId, $n - count($unvisitedPlaces), $userId);
return array_merge($unvisitedPlaces, $oldPlaces); return array_merge($unvisitedPlaces, $oldPlaces);
} }
} }
@ -198,5 +198,5 @@ class PlaceRepository
yield from $this->pdm->selectMultipleFromDb($select, Place::class); yield from $this->pdm->selectMultipleFromDb($select, Place::class);
} }
} }

View File

@ -1,9 +1,9 @@
<?php namespace MapGuesser\Repository; <?php namespace MapGuesser\Repository;
use MapGuesser\Database\Query\Select; use SokoWeb\Database\Query\Select;
use MapGuesser\PersistentData\Model\User; use MapGuesser\PersistentData\Model\User;
use MapGuesser\PersistentData\Model\UserConfirmation; use MapGuesser\PersistentData\Model\UserConfirmation;
use MapGuesser\PersistentData\PersistentDataManager; use SokoWeb\PersistentData\PersistentDataManager;
class UserConfirmationRepository class UserConfirmationRepository
{ {

View File

@ -1,11 +1,11 @@
<?php namespace MapGuesser\Repository; <?php namespace MapGuesser\Repository;
use Generator; use Generator;
use MapGuesser\Database\Query\Select; use SokoWeb\Database\Query\Select;
use MapGuesser\PersistentData\Model\Challenge; use MapGuesser\PersistentData\Model\Challenge;
use MapGuesser\PersistentData\Model\User; use MapGuesser\PersistentData\Model\User;
use MapGuesser\PersistentData\Model\UserInChallenge; use MapGuesser\PersistentData\Model\UserInChallenge;
use MapGuesser\PersistentData\PersistentDataManager; use SokoWeb\PersistentData\PersistentDataManager;
class UserInChallengeRepository class UserInChallengeRepository
{ {

View File

@ -2,10 +2,10 @@
use DateTime; use DateTime;
use Generator; use Generator;
use MapGuesser\Database\Query\Select; use SokoWeb\Database\Query\Select;
use MapGuesser\PersistentData\Model\User; use MapGuesser\PersistentData\Model\User;
use MapGuesser\PersistentData\Model\UserPasswordResetter; use MapGuesser\PersistentData\Model\UserPasswordResetter;
use MapGuesser\PersistentData\PersistentDataManager; use SokoWeb\PersistentData\PersistentDataManager;
class UserPasswordResetterRepository class UserPasswordResetterRepository
{ {

View File

@ -1,12 +1,11 @@
<?php namespace MapGuesser\Repository; <?php namespace MapGuesser\Repository;
use DateTime;
use Generator; use Generator;
use MapGuesser\Database\Query\Select; use SokoWeb\Database\Query\Select;
use MapGuesser\PersistentData\Model\User; use MapGuesser\PersistentData\Model\User;
use MapGuesser\PersistentData\Model\Place; use MapGuesser\PersistentData\Model\Place;
use MapGuesser\PersistentData\Model\UserPlayedPlace; use MapGuesser\PersistentData\Model\UserPlayedPlace;
use MapGuesser\PersistentData\PersistentDataManager; use SokoWeb\PersistentData\PersistentDataManager;
class UserPlayedPlaceRepository class UserPlayedPlaceRepository
{ {

View File

@ -2,12 +2,13 @@
use DateTime; use DateTime;
use Generator; use Generator;
use MapGuesser\Database\Query\Select; use SokoWeb\Interfaces\Repository\IUserRepository;
use SokoWeb\Database\Query\Select;
use MapGuesser\PersistentData\Model\Guess; use MapGuesser\PersistentData\Model\Guess;
use MapGuesser\PersistentData\Model\User; use MapGuesser\PersistentData\Model\User;
use MapGuesser\PersistentData\PersistentDataManager; use SokoWeb\PersistentData\PersistentDataManager;
class UserRepository class UserRepository implements IUserRepository
{ {
private PersistentDataManager $pdm; private PersistentDataManager $pdm;

28
web.php
View File

@ -10,17 +10,17 @@ if (!empty($_ENV['DEV'])) {
ini_set('display_errors', '0'); ini_set('display_errors', '0');
} }
Container::$routeCollection = new MapGuesser\Routing\RouteCollection(); Container::$routeCollection = new SokoWeb\Routing\RouteCollection();
Container::$routeCollection->get('index', '', [MapGuesser\Controller\MapsController::class, 'getMaps']); Container::$routeCollection->get('index', '', [MapGuesser\Controller\MapsController::class, 'getMaps']);
Container::$routeCollection->get('startSession', 'startSession.json', [MapGuesser\Controller\HomeController::class, 'startSession']); Container::$routeCollection->get('startSession', 'startSession.json', [MapGuesser\Controller\HomeController::class, 'startSession']);
Container::$routeCollection->group('login', function (MapGuesser\Routing\RouteCollection $routeCollection) { Container::$routeCollection->group('login', function (SokoWeb\Routing\RouteCollection $routeCollection) {
$routeCollection->get('login', '', [MapGuesser\Controller\LoginController::class, 'getLoginForm']); $routeCollection->get('login', '', [MapGuesser\Controller\LoginController::class, 'getLoginForm']);
$routeCollection->post('login-action', '', [MapGuesser\Controller\LoginController::class, 'login']); $routeCollection->post('login-action', '', [MapGuesser\Controller\LoginController::class, 'login']);
$routeCollection->get('login-google', 'google', [MapGuesser\Controller\LoginController::class, 'getGoogleLoginRedirect']); $routeCollection->get('login-google', 'google', [MapGuesser\Controller\LoginController::class, 'getGoogleLoginRedirect']);
$routeCollection->get('login-google-action', 'google/code', [MapGuesser\Controller\LoginController::class, 'loginWithGoogle']); $routeCollection->get('login-google-action', 'google/code', [MapGuesser\Controller\LoginController::class, 'loginWithGoogle']);
}); });
Container::$routeCollection->group('signup', function (MapGuesser\Routing\RouteCollection $routeCollection) { Container::$routeCollection->group('signup', function (SokoWeb\Routing\RouteCollection $routeCollection) {
$routeCollection->get('signup', '', [MapGuesser\Controller\LoginController::class, 'getSignupForm']); $routeCollection->get('signup', '', [MapGuesser\Controller\LoginController::class, 'getSignupForm']);
$routeCollection->post('signup-action', '', [MapGuesser\Controller\LoginController::class, 'signup']); $routeCollection->post('signup-action', '', [MapGuesser\Controller\LoginController::class, 'signup']);
$routeCollection->get('signup-google', 'google', [MapGuesser\Controller\LoginController::class, 'getSignupWithGoogleForm']); $routeCollection->get('signup-google', 'google', [MapGuesser\Controller\LoginController::class, 'getSignupWithGoogleForm']);
@ -31,7 +31,7 @@ Container::$routeCollection->group('signup', function (MapGuesser\Routing\RouteC
$routeCollection->get('signup.activate', 'activate/{token}', [MapGuesser\Controller\LoginController::class, 'activate']); $routeCollection->get('signup.activate', 'activate/{token}', [MapGuesser\Controller\LoginController::class, 'activate']);
$routeCollection->get('signup.cancel', 'cancel/{token}', [MapGuesser\Controller\LoginController::class, 'cancel']); $routeCollection->get('signup.cancel', 'cancel/{token}', [MapGuesser\Controller\LoginController::class, 'cancel']);
}); });
Container::$routeCollection->group('password', function (MapGuesser\Routing\RouteCollection $routeCollection) { Container::$routeCollection->group('password', function (SokoWeb\Routing\RouteCollection $routeCollection) {
$routeCollection->get('password-requestReset', 'requestReset', [MapGuesser\Controller\LoginController::class, 'getRequestPasswordResetForm']); $routeCollection->get('password-requestReset', 'requestReset', [MapGuesser\Controller\LoginController::class, 'getRequestPasswordResetForm']);
$routeCollection->post('password-requestReset-action', 'requestReset', [MapGuesser\Controller\LoginController::class, 'requestPasswordReset']); $routeCollection->post('password-requestReset-action', 'requestReset', [MapGuesser\Controller\LoginController::class, 'requestPasswordReset']);
$routeCollection->get('password-requestReset.success', 'requestReset/success', [MapGuesser\Controller\LoginController::class, 'getRequestPasswordResetSuccess']); $routeCollection->get('password-requestReset.success', 'requestReset/success', [MapGuesser\Controller\LoginController::class, 'getRequestPasswordResetSuccess']);
@ -39,7 +39,7 @@ Container::$routeCollection->group('password', function (MapGuesser\Routing\Rout
$routeCollection->post('password-reset.action', 'reset/{token}', [MapGuesser\Controller\LoginController::class, 'resetPassword']); $routeCollection->post('password-reset.action', 'reset/{token}', [MapGuesser\Controller\LoginController::class, 'resetPassword']);
}); });
Container::$routeCollection->get('logout', 'logout', [MapGuesser\Controller\LoginController::class, 'logout']); Container::$routeCollection->get('logout', 'logout', [MapGuesser\Controller\LoginController::class, 'logout']);
Container::$routeCollection->group('account', function (MapGuesser\Routing\RouteCollection $routeCollection) { Container::$routeCollection->group('account', function (SokoWeb\Routing\RouteCollection $routeCollection) {
$routeCollection->get('account', '', [MapGuesser\Controller\UserController::class, 'getAccount']); $routeCollection->get('account', '', [MapGuesser\Controller\UserController::class, 'getAccount']);
$routeCollection->post('account-action', '', [MapGuesser\Controller\UserController::class, 'saveAccount']); $routeCollection->post('account-action', '', [MapGuesser\Controller\UserController::class, 'saveAccount']);
$routeCollection->get('account.delete', 'delete', [MapGuesser\Controller\UserController::class, 'getDeleteAccount']); $routeCollection->get('account.delete', 'delete', [MapGuesser\Controller\UserController::class, 'getDeleteAccount']);
@ -48,13 +48,13 @@ Container::$routeCollection->group('account', function (MapGuesser\Routing\Route
$routeCollection->get('account.googleAuthenticate-action', 'googleAuthenticate/code', [MapGuesser\Controller\UserController::class, 'authenticateWithGoogle']); $routeCollection->get('account.googleAuthenticate-action', 'googleAuthenticate/code', [MapGuesser\Controller\UserController::class, 'authenticateWithGoogle']);
}); });
//Container::$routeCollection->get('maps', 'maps', [MapGuesser\Controller\MapsController::class, 'getMaps']); //Container::$routeCollection->get('maps', 'maps', [MapGuesser\Controller\MapsController::class, 'getMaps']);
Container::$routeCollection->group('game', function (MapGuesser\Routing\RouteCollection $routeCollection) { Container::$routeCollection->group('game', function (SokoWeb\Routing\RouteCollection $routeCollection) {
$routeCollection->get('game', '{mapId}', [MapGuesser\Controller\GameController::class, 'getGame']); $routeCollection->get('game', '{mapId}', [MapGuesser\Controller\GameController::class, 'getGame']);
$routeCollection->post('game.prepare-json', '{mapId}/prepare.json', [MapGuesser\Controller\GameController::class, 'prepareGame']); $routeCollection->post('game.prepare-json', '{mapId}/prepare.json', [MapGuesser\Controller\GameController::class, 'prepareGame']);
$routeCollection->post('game.initialData-json', '{mapId}/initialData.json', [MapGuesser\Controller\GameFlowController::class, 'initialData']); $routeCollection->post('game.initialData-json', '{mapId}/initialData.json', [MapGuesser\Controller\GameFlowController::class, 'initialData']);
$routeCollection->post('game.guess-json', '{mapId}/guess.json', [MapGuesser\Controller\GameFlowController::class, 'guess']); $routeCollection->post('game.guess-json', '{mapId}/guess.json', [MapGuesser\Controller\GameFlowController::class, 'guess']);
}); });
Container::$routeCollection->group('multiGame', function (MapGuesser\Routing\RouteCollection $routeCollection) { Container::$routeCollection->group('multiGame', function (SokoWeb\Routing\RouteCollection $routeCollection) {
$routeCollection->get('multiGame.new', 'new/{mapId}', [MapGuesser\Controller\GameController::class, 'getNewMultiGame']); $routeCollection->get('multiGame.new', 'new/{mapId}', [MapGuesser\Controller\GameController::class, 'getNewMultiGame']);
$routeCollection->get('multiGame', '{roomId}', [MapGuesser\Controller\GameController::class, 'getMultiGame']); $routeCollection->get('multiGame', '{roomId}', [MapGuesser\Controller\GameController::class, 'getMultiGame']);
$routeCollection->post('multiGame.prepare-json', '{roomId}/prepare.json', [MapGuesser\Controller\GameController::class, 'prepareMultiGame']); $routeCollection->post('multiGame.prepare-json', '{roomId}/prepare.json', [MapGuesser\Controller\GameController::class, 'prepareMultiGame']);
@ -62,14 +62,14 @@ Container::$routeCollection->group('multiGame', function (MapGuesser\Routing\Rou
$routeCollection->post('multiGame.nextRound-json', '{roomId}/nextRound.json', [MapGuesser\Controller\GameFlowController::class, 'multiNextRound']); $routeCollection->post('multiGame.nextRound-json', '{roomId}/nextRound.json', [MapGuesser\Controller\GameFlowController::class, 'multiNextRound']);
$routeCollection->post('multiGame.guess-json', '{roomId}/guess.json', [MapGuesser\Controller\GameFlowController::class, 'multiGuess']); $routeCollection->post('multiGame.guess-json', '{roomId}/guess.json', [MapGuesser\Controller\GameFlowController::class, 'multiGuess']);
}); });
Container::$routeCollection->group('challenge', function (MapGuesser\Routing\RouteCollection $routeCollection) { Container::$routeCollection->group('challenge', function (SokoWeb\Routing\RouteCollection $routeCollection) {
$routeCollection->post('challenge.create', 'create.json', [\MapGuesser\Controller\GameController::class, 'createNewChallenge']); $routeCollection->post('challenge.create', 'create.json', [\MapGuesser\Controller\GameController::class, 'createNewChallenge']);
$routeCollection->get('challenge', '{challengeToken}', [MapGuesser\Controller\GameController::class, 'getChallenge']); $routeCollection->get('challenge', '{challengeToken}', [MapGuesser\Controller\GameController::class, 'getChallenge']);
$routeCollection->post('challenge.prepare-json', '{challengeToken}/prepare.json', [MapGuesser\Controller\GameController::class, 'prepareChallenge']); $routeCollection->post('challenge.prepare-json', '{challengeToken}/prepare.json', [MapGuesser\Controller\GameController::class, 'prepareChallenge']);
$routeCollection->post('challenge.initialData-json', '{challengeToken}/initialData.json', [MapGuesser\Controller\GameFlowController::class, 'challengeInitialData']); $routeCollection->post('challenge.initialData-json', '{challengeToken}/initialData.json', [MapGuesser\Controller\GameFlowController::class, 'challengeInitialData']);
$routeCollection->post('challenge.guess-json', '{challengeToken}/guess.json', [MapGuesser\Controller\GameFlowController::class, 'challengeGuess']); $routeCollection->post('challenge.guess-json', '{challengeToken}/guess.json', [MapGuesser\Controller\GameFlowController::class, 'challengeGuess']);
}); });
Container::$routeCollection->group('admin', function (MapGuesser\Routing\RouteCollection $routeCollection) { Container::$routeCollection->group('admin', function (SokoWeb\Routing\RouteCollection $routeCollection) {
$routeCollection->get('admin.mapEditor', 'mapEditor/{mapId?}', [MapGuesser\Controller\MapAdminController::class, 'getMapEditor']); $routeCollection->get('admin.mapEditor', 'mapEditor/{mapId?}', [MapGuesser\Controller\MapAdminController::class, 'getMapEditor']);
$routeCollection->get('admin.place', 'place.json/{placeId}', [MapGuesser\Controller\MapAdminController::class, 'getPlace']); $routeCollection->get('admin.place', 'place.json/{placeId}', [MapGuesser\Controller\MapAdminController::class, 'getPlace']);
$routeCollection->post('admin.saveMap', 'saveMap/{mapId}/json', [MapGuesser\Controller\MapAdminController::class, 'saveMap']); $routeCollection->post('admin.saveMap', 'saveMap/{mapId}/json', [MapGuesser\Controller\MapAdminController::class, 'saveMap']);
@ -77,7 +77,7 @@ Container::$routeCollection->group('admin', function (MapGuesser\Routing\RouteCo
}); });
if (isset($_COOKIE['COOKIES_CONSENT'])) { if (isset($_COOKIE['COOKIES_CONSENT'])) {
Container::$sessionHandler = new MapGuesser\Session\DatabaseSessionHandler(); Container::$sessionHandler = new SokoWeb\Session\DatabaseSessionHandler();
session_set_save_handler(Container::$sessionHandler, true); session_set_save_handler(Container::$sessionHandler, true);
session_start([ session_start([
@ -106,7 +106,13 @@ if (isset($_COOKIE['COOKIES_CONSENT'])) {
$_SESSION = []; $_SESSION = [];
} }
Container::$request = new MapGuesser\Request\Request($_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'], $_GET, $_POST, $_SESSION); Container::$request = new SokoWeb\Request\Request(
$_SERVER['REQUEST_SCHEME'] . '://' . $_SERVER['HTTP_HOST'],
$_GET,
$_POST,
$_SESSION,
new MapGuesser\Repository\UserRepository()
);
if (!Container::$request->session()->has('anti_csrf_token')) { if (!Container::$request->session()->has('anti_csrf_token')) {
Container::$request->session()->set('anti_csrf_token', bin2hex(random_bytes(16))); Container::$request->session()->set('anti_csrf_token', bin2hex(random_bytes(16)));