backwards-compatible registry
This commit is contained in:
parent
c528cd9a42
commit
fea8f90f68
3 changed files with 53 additions and 3 deletions
15
ext/et_server/info.php
Normal file
15
ext/et_server/info.php
Normal file
|
@ -0,0 +1,15 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
class ETServerInfo extends ExtensionInfo
|
||||
{
|
||||
public const KEY = "et_server";
|
||||
|
||||
public $key = self::KEY;
|
||||
public $name = "System Info Registry";
|
||||
public $url = self::SHIMMIE_URL;
|
||||
public $authors = self::SHISH_AUTHOR;
|
||||
public $license = self::LICENSE_GPLV2;
|
||||
public $description = "Keep track of shimmie registrations";
|
||||
public $documentation = "For internal use";
|
||||
public $visibility = self::VISIBLE_HIDDEN;
|
||||
}
|
32
ext/et_server/main.php
Normal file
32
ext/et_server/main.php
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?php declare(strict_types=1);
|
||||
|
||||
class ETServer extends Extension
|
||||
{
|
||||
public function onPageRequest(PageRequestEvent $event)
|
||||
{
|
||||
global $database, $page;
|
||||
if ($event->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");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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';
|
||||
|
|
Reference in a new issue