.htaccess + more pages & routes
This commit is contained in:
parent
abb8b07a02
commit
b2cb0c4bf3
10
.htaccess
10
.htaccess
@ -1,18 +1,14 @@
|
||||
php_flag display_errors on
|
||||
Options -Indexes
|
||||
|
||||
RedirectMatch 404 /\.idea
|
||||
RedirectMatch 404 /\.git
|
||||
RedirectMatch 404 /src
|
||||
RedirectMatch 404 /test
|
||||
RedirectMatch 404 /core
|
||||
|
||||
RewriteEngine On
|
||||
RewriteRule ^api(/.*)?$ /index.php?api=$1 [L,QSA]
|
||||
|
||||
<IfModule mod_rewrite.c>
|
||||
RewriteEngine On
|
||||
DirectorySlash Off
|
||||
RewriteCond %{REQUEST_FILENAME} !-f
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteCond %{REQUEST_FILENAME} !-d [OR]
|
||||
RewriteCond %{REQUEST_URI} "(\.idea|\.git|src|test|core)(/.*)?"
|
||||
RewriteRule ^(.*)$ /index.php?site=$1 [L,QSA]
|
||||
</IfModule>
|
@ -1 +0,0 @@
|
||||
DENY FROM ALL;
|
@ -81,6 +81,7 @@ class Stats extends Request {
|
||||
$this->result["pageCount"] = $pageCount;
|
||||
$this->result["visitors"] = $visitorStatistics;
|
||||
$this->result["server"] = array(
|
||||
"version" => WEBBASE_VERSION,
|
||||
"server" => $_SERVER["SERVER_SOFTWARE"] ?? "Unknown",
|
||||
"memory_usage" => memory_get_usage(),
|
||||
"load_avg" => sys_getloadavg(),
|
||||
|
@ -128,8 +128,12 @@ class CreateDatabase {
|
||||
->addBool("active", true)
|
||||
->primaryKey("uid");
|
||||
|
||||
$queries[] = $sql->insert("Route", array("request", "action", "target"))
|
||||
->addRow("^/admin(/.*)?$", "dynamic", "\\Documents\\AdminDashboard");
|
||||
$queries[] = $sql->insert("Route", array("request", "action", "target", "extra"))
|
||||
->addRow("^/admin(/.*)?$", "dynamic", "\\Documents\\AdminDashboard", NULL)
|
||||
->addRow("^/register(/)?$", "dynamic", "\\Documents\\Account", "\\Views\\Account\\Register")
|
||||
->addRow("^/confirmEmail(/)?$", "dynamic", "\\Documents\\Account", "\\Views\\Account\\ConfirmEmail")
|
||||
->addRow("^/acceptInvite(/)?$", "dynamic", "\\Documents\\Account", "\\Views\\Account\\AcceptInvite")
|
||||
->addRow("^/$", "dynamic", "\\Documents\\Welcome", NULL);
|
||||
|
||||
return $queries;
|
||||
}
|
||||
|
60
core/Documents/Account.class.php
Normal file
60
core/Documents/Account.class.php
Normal file
@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace Documents {
|
||||
|
||||
use Documents\Account\AccountBody;
|
||||
use Documents\Account\AccountHead;
|
||||
use Elements\Document;
|
||||
use Objects\User;
|
||||
|
||||
class Account extends Document {
|
||||
public function __construct(User $user, ?string $view) {
|
||||
parent::__construct($user, AccountHead::class, AccountBody::class, $view);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace Documents\Account {
|
||||
|
||||
use Elements\Head;
|
||||
use Elements\SimpleBody;
|
||||
|
||||
class AccountHead extends Head {
|
||||
|
||||
public function __construct($document) {
|
||||
parent::__construct($document);
|
||||
}
|
||||
|
||||
protected function initSources() {
|
||||
|
||||
}
|
||||
|
||||
protected function initMetas() {
|
||||
return array();
|
||||
}
|
||||
|
||||
protected function initRawFields() {
|
||||
return array();
|
||||
}
|
||||
|
||||
protected function initTitle() {
|
||||
return "Account";
|
||||
}
|
||||
}
|
||||
|
||||
class AccountBody extends SimpleBody {
|
||||
|
||||
public function __construct($document) {
|
||||
parent::__construct($document);
|
||||
}
|
||||
|
||||
protected function getContent() {
|
||||
$view = $this->getDocument()->getView();
|
||||
if ($view === null) {
|
||||
return "The page you does not exist or is no longer valid. <a href='/'>Return to start page</a>";
|
||||
}
|
||||
|
||||
return $view->getCode();
|
||||
}
|
||||
}
|
||||
}
|
55
core/Documents/Welcome.class.php
Normal file
55
core/Documents/Welcome.class.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace Documents {
|
||||
|
||||
use Documents\Welcome\WelcomeBody;
|
||||
use Documents\Welcome\WelcomeHead;
|
||||
use Elements\Document;
|
||||
use Objects\User;
|
||||
|
||||
class Welcome extends Document {
|
||||
public function __construct(User $user, ?string $view) {
|
||||
parent::__construct($user, WelcomeHead::class, WelcomeBody::class, $view);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace Documents\Welcome {
|
||||
|
||||
use Elements\Head;
|
||||
use Elements\SimpleBody;
|
||||
|
||||
class WelcomeHead extends Head {
|
||||
|
||||
public function __construct($document) {
|
||||
parent::__construct($document);
|
||||
}
|
||||
|
||||
protected function initSources() {
|
||||
|
||||
}
|
||||
|
||||
protected function initMetas() {
|
||||
return array();
|
||||
}
|
||||
|
||||
protected function initRawFields() {
|
||||
return array();
|
||||
}
|
||||
|
||||
protected function initTitle() {
|
||||
return "Welcome";
|
||||
}
|
||||
}
|
||||
|
||||
class WelcomeBody extends SimpleBody {
|
||||
|
||||
public function __construct($document) {
|
||||
parent::__construct($document);
|
||||
}
|
||||
|
||||
protected function getContent() {
|
||||
return "Welcome!";
|
||||
}
|
||||
}
|
||||
}
|
@ -13,6 +13,7 @@ use \Driver\SQL\Column\DateTimeColumn;
|
||||
use Driver\SQL\Column\BoolColumn;
|
||||
use Driver\SQL\Column\JsonColumn;
|
||||
|
||||
use Driver\SQL\Condition\Regex;
|
||||
use Driver\SQL\Expression\Add;
|
||||
use Driver\SQL\Strategy\Strategy;
|
||||
use \Driver\SQL\Strategy\UpdateStrategy;
|
||||
@ -303,4 +304,16 @@ class MySQL extends SQL {
|
||||
public function getStatus() {
|
||||
return mysqli_stat($this->connection);
|
||||
}
|
||||
|
||||
protected function buildCondition($condition, &$params) {
|
||||
if($condition instanceof Regex) {
|
||||
$left = $condition->getLeftExp();
|
||||
$right = $condition->getRightExp();
|
||||
$left = ($left instanceof Column) ? $this->columnName($left->getName()) : $this->addValue($left, $params);
|
||||
$right = ($right instanceof Column) ? $this->columnName($right->getName()) : $this->addValue($right, $params);
|
||||
return $left . " REGEXP " . $right;
|
||||
} else {
|
||||
return parent::buildCondition($condition, $params);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ use \Driver\SQL\Column\DateTimeColumn;
|
||||
use Driver\SQL\Column\BoolColumn;
|
||||
use Driver\SQL\Column\JsonColumn;
|
||||
|
||||
use Driver\SQL\Condition\Regex;
|
||||
use Driver\SQL\Expression\Add;
|
||||
use Driver\SQL\Strategy\Strategy;
|
||||
use Driver\SQL\Strategy\UpdateStrategy;
|
||||
@ -301,4 +302,16 @@ class PostgreSQL extends SQL {
|
||||
|
||||
return ($statusTexts[$status] ?? "Unknown") . " (v$version)";
|
||||
}
|
||||
|
||||
protected function buildCondition($condition, &$params) {
|
||||
if($condition instanceof Regex) {
|
||||
$left = $condition->getLeftExp();
|
||||
$right = $condition->getRightExp();
|
||||
$left = ($left instanceof Column) ? $this->columnName($left->getName()) : $this->addValue($left, $params);
|
||||
$right = ($right instanceof Column) ? $this->columnName($right->getName()) : $this->addValue($right, $params);
|
||||
return $left . " ~ " . $right;
|
||||
} else {
|
||||
return parent::buildCondition($condition, $params);
|
||||
}
|
||||
}
|
||||
}
|
@ -332,12 +332,6 @@ abstract class SQL {
|
||||
}
|
||||
return implode(" AND ", $conditions);
|
||||
}
|
||||
} else if ($condition instanceof Regex) {
|
||||
$left = $condition->getLeftExp();
|
||||
$right = $condition->getRightExp();
|
||||
$left = ($left instanceof Column) ? $this->columnName($left->getName()) : $this->addValue($left, $params);
|
||||
$right = ($right instanceof Column) ? $this->columnName($right->getName()) : $this->addValue($right, $params);
|
||||
return $left . " REGEXP " . $right;
|
||||
} else {
|
||||
$this->lastError = "Unsupported condition type: " . get_class($condition);
|
||||
return false;
|
||||
|
@ -24,14 +24,15 @@ abstract class Document {
|
||||
public function getBody() { return $this->body; }
|
||||
public function getSQL() { return $this->user->getSQL(); }
|
||||
public function getUser() { return $this->user; }
|
||||
public function getView() { return $this->activeView; }
|
||||
|
||||
protected function sendHeaders() {
|
||||
header("X-Frame-Options: DENY");
|
||||
}
|
||||
public function getView() : ?View {
|
||||
|
||||
public static function createSearchableDocument($documentClass, $user) {
|
||||
return new $documentClass($user);
|
||||
$file = getClassPath($this->activeView);
|
||||
if(!file_exists($file) || !is_subclass_of($this->activeView, View::class)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return new $this->activeView($this);
|
||||
}
|
||||
|
||||
function getCode() {
|
||||
@ -47,9 +48,10 @@ abstract class Document {
|
||||
|
||||
$body = $this->body->getCode();
|
||||
$head = $this->head->getCode();
|
||||
$lang = $this->user->getLanguage()->getShortCode();
|
||||
|
||||
$html = "<!DOCTYPE html>";
|
||||
$html .= "<html>";
|
||||
$html .= "<html lang=\"$lang\">";
|
||||
$html .= $head;
|
||||
$html .= $body;
|
||||
$html .= "</html>";
|
||||
|
16
core/Elements/SimpleBody.class.php
Normal file
16
core/Elements/SimpleBody.class.php
Normal file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace Elements;
|
||||
|
||||
abstract class SimpleBody extends Body {
|
||||
public function __construct($document) {
|
||||
parent::__construct($document);
|
||||
}
|
||||
|
||||
public function getCode() {
|
||||
$content = $this->getContent();
|
||||
return parent::getCode() . "<body>$content</body>";
|
||||
}
|
||||
|
||||
protected abstract function getContent();
|
||||
}
|
@ -83,7 +83,7 @@ abstract class View extends StaticView {
|
||||
if($classes)
|
||||
$iconClass .= " $classes";
|
||||
|
||||
return "<i class=\"$iconClass\"></i>";
|
||||
return "<i class=\"$iconClass\" />";
|
||||
}
|
||||
|
||||
protected function createErrorText($text, $id="", $hidden=false) {
|
||||
|
21
core/Views/Account/AcceptInvite.class.php
Normal file
21
core/Views/Account/AcceptInvite.class.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Views\Account;
|
||||
|
||||
|
||||
use Elements\Document;
|
||||
use Elements\View;
|
||||
|
||||
class AcceptInvite extends View {
|
||||
|
||||
public function __construct(Document $document, $loadView = true) {
|
||||
parent::__construct($document, $loadView);
|
||||
}
|
||||
|
||||
public function getCode() {
|
||||
$html = parent::getCode();
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
21
core/Views/Account/ConfirmEmail.class.php
Normal file
21
core/Views/Account/ConfirmEmail.class.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Views\Account;
|
||||
|
||||
|
||||
use Elements\Document;
|
||||
use Elements\View;
|
||||
|
||||
class ConfirmEmail extends View {
|
||||
|
||||
public function __construct(Document $document, $loadView = true) {
|
||||
parent::__construct($document, $loadView);
|
||||
}
|
||||
|
||||
public function getCode() {
|
||||
$html = parent::getCode();
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
21
core/Views/Account/Register.class.php
Normal file
21
core/Views/Account/Register.class.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Views\Account;
|
||||
|
||||
|
||||
use Elements\Document;
|
||||
use Elements\View;
|
||||
|
||||
class Register extends View {
|
||||
|
||||
public function __construct(Document $document, $loadView = true) {
|
||||
parent::__construct($document, $loadView);
|
||||
}
|
||||
|
||||
public function getCode() {
|
||||
$html = parent::getCode();
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
<?php
|
||||
|
||||
define("WEBBASE_VERSION", "0.1.0-alpha");
|
||||
|
||||
function getSubclassesOf($parent) {
|
||||
$result = array();
|
||||
foreach (get_declared_classes() as $class) {
|
||||
|
2
js/admin.min.js
vendored
2
js/admin.min.js
vendored
File diff suppressed because one or more lines are too long
@ -198,6 +198,7 @@ export default class Overview extends React.Component {
|
||||
<Collapse isOpened={this.state.statusVisible}>
|
||||
<div className="card-body">
|
||||
<ul className={"list-unstyled"}>
|
||||
<li><b>Version</b>: {this.state.server.version}</li>
|
||||
<li><b>Server</b>: {this.state.server.server}</li>
|
||||
<li><b>Memory Usage</b>: {humanReadableSize(this.state.server.memory_usage)}</li>
|
||||
<li><b>Load Average</b>: { this.state.server.load_avg.join(" ") }</li>
|
||||
|
Loading…
Reference in New Issue
Block a user