diff --git a/src/web/controller/user-replication-controller.php b/src/web/controller/user-replication-controller.php new file mode 100644 index 0000000000000000000000000000000000000000..1ae9ce75c971560b3e89778500e521e2e16b4a8f --- /dev/null +++ b/src/web/controller/user-replication-controller.php @@ -0,0 +1,26 @@ +<?php + +require_once 'db/db-executor.php'; + +if ($_SERVER["REQUEST_METHOD"] != "GET" || + !(isset($_SERVER['HTTP_X_AUTHORIZATION']) && $_SERVER['HTTP_X_AUTHORIZATION'] == getenv('REPLICATION_PASS'))) { + http_response_code(404); + echo getenv('REPLICATION_PASS'), PHP_EOL; + echo $_SERVER['HTTP_X_AUTHORIZATION']; + exit(); +} + +if (!isset($_GET["timestamp"])) { + http_response_code(400); + exit(); +} + +$query = 'SELECT * FROM account WHERE timestamp >= :timestamp;'; +$timestamp = $_GET["timestamp"]; +$params = [ + 'timestamp' => $timestamp +]; + +$res = execSelect_KeyField($query, $params); + +echo json_encode($res); \ No newline at end of file diff --git a/src/web/router.php b/src/web/router.php index 818b1270291c256bd501cba4792d7cebae71b6ed..03988492b34ed3643120c0c922df92eaa09bcf96 100644 --- a/src/web/router.php +++ b/src/web/router.php @@ -15,6 +15,7 @@ $routeMapNonLogin = [ '/music-list' => 'presentation/music/list/musicList.php', '/404' => 'presentation/notfound/404.php', '/500' => 'presentation/notfound/500.php', + '/users-at-db' => 'controller/user-replication-controller.php', //For ajax '/album/fetch' => 'controller/albumController.php',