diff --git a/ext/et_server/info.php b/ext/et_server/info.php new file mode 100644 index 00000000..c87f6514 --- /dev/null +++ b/ext/et_server/info.php @@ -0,0 +1,15 @@ +page_matches("register.php")) { + $database->execute( + "INSERT INTO registration(data) VALUES(:data)", + ["data"=>$_POST["data"]] + ); + $page->add_block(new Block("Thanks!", "Your data has been recorded~")); + } + } + + public function onDatabaseUpgrade(DatabaseUpgradeEvent $event) + { + global $config, $database; + + // shortcut to latest + if ($config->get_int("et_server_version") < 1) { + $database->create_table("registration", " + id SCORE_AIPK, + responded TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, + data TEXT NOT NULL, + "); + $config->set_int("et_server_version", 1); + log_info("et_server", "extension installed"); + } + } +} diff --git a/tests/router.php b/tests/router.php index db6224ad..d04ff314 100644 --- a/tests/router.php +++ b/tests/router.php @@ -10,18 +10,21 @@ if (PHP_SAPI !== 'cli-server') { require_once "core/sys_config.php"; require_once "core/polyfills.php"; require_once "core/util.php"; + $matches = []; if (preg_match('/\/_(images|thumbs)\/([0-9a-f]{32}).*$/', $_SERVER["REQUEST_URI"], $matches)) { header('Content-Type: image/jpeg'); print(file_get_contents(warehouse_path($matches[1], $matches[2]))); return true; } -unset($matches); // use the default handler (serve static files, interpret php files) -if (preg_match('/\.(?:png|jpg|jpeg|gif|css|js|php)(\?.*)?$/', $_SERVER["REQUEST_URI"])) { - return false; +elseif (preg_match('/\.(?:png|jpg|jpeg|gif|css|js|php)(\?.*)?$/', $_SERVER["REQUEST_URI"])) { + if (!preg_match('/register\.php(\?.*)?$/', $_SERVER["REQUEST_URI"])) { + return false; + } } +unset($matches); // all other requests (use shimmie routing based on URL) $_SERVER["PHP_SELF"] = '/index.php';