Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
lewmilburn committed Apr 29, 2024
1 parent b12a4d3 commit efb4119
Show file tree
Hide file tree
Showing 14 changed files with 115 additions and 82 deletions.
76 changes: 2 additions & 74 deletions .idea/php.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Plugins/ControlPanel/Assets/ChkValues.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php $Checksum['CoreSettings'] = '6a7e19f4cb2b923c5b6d023ad71c79ad0cf7b22d6b0b27e494cc099530905369030fe278301e6dd94df30c5c6f44951044ee6397c73c9d57d1809a5baf2f26ea'; $Checksum['CoreDeveloper'] = 'd8ac0d6566de0980d2853e6b8e403e533cc2b8dd3b37e54f2f2883300302973f887aefee47c12bd8c28533c6ca741bb82a018288c782a623f990698dd4455f88';
<?php $Checksum['CoreSettings'] = '1016dd99a95446af7cbfc00b99ec8102c86d76da54515cbed96cccfa9c43d4167db5be5b234ddf82c4162d138545d5a0944b53c55f3ce3f1510b95c2eba2b25d'; $Checksum['CoreDeveloper'] = 'd8ac0d6566de0980d2853e6b8e403e533cc2b8dd3b37e54f2f2883300302973f887aefee47c12bd8c28533c6ca741bb82a018288c782a623f990698dd4455f88';
1 change: 1 addition & 0 deletions Plugins/ControlPanel/Assets/Languages/en-gb.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"Join": "Join",
"Loaded": "Loaded",
"Login": "Login",
"NoPages": "No pages.",
"Pages": "Pages",
"Password": "Password",
"Plugin_About": "About the Plugin",
Expand Down
6 changes: 6 additions & 0 deletions Plugins/ControlPanel/CPRouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ private function Panel(bool $Authenticated): void
private function Settings(bool $HasPermission): void
{
if ($HasPermission) {
$this->Router->GET(CPURL_PANEL.CPURL_PAGES, '../Plugins/ControlPanel/Views/Pages.php');
$this->Router->GET(CPURL_PANEL.CPURL_PLUGINS, '../Plugins/ControlPanel/Views/Plugins.php');
$this->Router->GET(CPURL_PANEL.CPURL_USERS, '../Plugins/ControlPanel/Views/Users.php');
global $SaturnPlugins;
Expand All @@ -93,6 +94,11 @@ private function Pages(bool $HasPermission): void
{
if ($HasPermission) {
$this->Router->GET(CPURL_PANEL.CPURL_EDIT, '../Plugins/ControlPanel/Views/Edit.php');
$DBMS = new DBMS();
$Pages = $DBMS->Select('*', 'pages', '1', 'all:assoc');
foreach ($Pages as $Page) {
$this->Router->GET(CPURL_PANEL.CPURL_EDIT.'/'.$Page['id'], '../Plugins/ControlPanel/Views/Edit.php');
}
} else {
$this->Router->GET(CPURL_PANEL.CPURL_EDIT, CPPAGE_NOACCESS);
}
Expand Down
1 change: 1 addition & 0 deletions Plugins/ControlPanel/CPURLs.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
const CPURL_EDIT = '/edit';
const CPURL_PLUGINS = '/plugins';
const CPURL_USERS = '/users';
const CPURL_PAGES = '/pages';

const CPPAGE_NOACCESS = '../Plugins/ControlPanel/Views/NoAccess.php';
const CPPAGE_LOGIN = '../Plugins/ControlPanel/Views/Login.php';
Expand Down
39 changes: 39 additions & 0 deletions Plugins/ControlPanel/Views/Pages.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php
use Saturn\HookManager\Actions;
use Saturn\PluginManager\PluginManifest;
require_once __DIR__ . '/Include/Security.php';
?><!DOCTYPE html>
<html lang="<?= WEBSITE_LANGUAGE; ?>">
<head>
<title><?= __CP('Pages'); ?> - <?= WEBSITE_NAME ?> <?= __CP('ControlPanel'); ?></title>
<?php require_once __DIR__ . '/Include/Header.php'; ?>
</head>
<body class="body">
<?php require_once __DIR__ . '/Include/Navigation.php'; ?>
<main class="main">
<h1 class="text-header-nopt"><?= __CP('Pages'); ?></h1>
<?php $Actions = new Actions(); $Actions->Run('ControlPanel.PagesListStart'); ?>
<div class="grid grid-cols-1 gap-2">
<?php
$DBMS = new \Saturn\DatabaseManager\DBMS();
$Pages = $DBMS->Query('SELECT * FROM `'.DB_PREFIX.'pages` WHERE 1');
if ($Pages->num_rows != 0) {
$Pages = $Pages->fetch_all(MYSQLI_ASSOC);
foreach ($Pages as $Page) {
?>
<a class="grid-item-link grid-padding relative" href="<?= SATURN_ROOT; ?><?= CPURL_PANEL; ?><?= CPURL_EDIT; ?>/<?= $Page['id']; ?>">
<h2 class="text-3xl font-bold"><?= $Page['title']; ?></h2>
<p class="pb-2">
<strong><?= $Page['url']; ?></strong>
</p>
</a>
<?php }} else { ?>
<p><?= __CP('NoPages'); ?></p>
<?php } ?>
</div>
<?php $Actions = new Actions(); $Actions->Run('ControlPanel.PagesListEnd'); ?>
</main>

<script src="<?= SATURN_ROOT; ?>/Plugins/ControlPanel/Assets/JS/Console.js"></script>
</body>
</html>
5 changes: 4 additions & 1 deletion Plugins/ControlPanel/Views/Panel.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@
<?php $Actions = new Actions(); $Actions->Run('ControlPanel.DashboardContentStart'); ?>
<div class="grid-block">
<div class="grid-item grid-padding">
<span id="PageCount">...</span> Pages
<span id="PageCount">0</span> Pages
</div>
</div>

<?php if ($Permissions->HasPermission(['administrator','panel_settings'],'OR')) { ?>
<h2 class="text-subheader"><?= __CP('Settings'); ?></h2>
<div class="grid-block">
<a href="<?= SATURN_ROOT; ?>/panel/pages" class="grid-item-link grid-padding">
<?= __CP('Pages'); ?>
</a>
<a href="<?= SATURN_ROOT; ?>/panel/plugins" class="grid-item-link grid-padding">
<?= __CP('Plugins'); ?>
</a>
Expand Down
14 changes: 14 additions & 0 deletions Processes/DefaultViews/Page.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php
use Saturn\DatabaseManager\DBMS;
$DBMS = new DBMS();
$Page = $DBMS->Query("SELECT * FROM `".DB_PREFIX."pages` WHERE `url` = '".$DBMS->Escape($_SERVER['REQUEST_URI'])."';");
$PageData = $Page->fetch_object();
?><!DOCTYPE html>
<html>
<head>
<title><?= $PageData->title; ?></title>
</head>
<body>
<?= $PageData->content; ?>
</body>
</html>
5 changes: 5 additions & 0 deletions Processes/Saturn/DatabaseManager/DBMS.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ public function Select(string $What, string $From, string|null $Where, string $A
return $this->Database->Select($What, DB_PREFIX.$From, $Where, $Action, $Order, $Limit);
}

public function Query(string $Query)
{
return $this->Database->Query($Query);
}

public function Insert(string $Into, string|null $Columns, string|null $Values): array|object|int|null
{
return $this->Database->Insert(DB_PREFIX.$Into, $Columns, $Values);
Expand Down
5 changes: 5 additions & 0 deletions Processes/Saturn/DatabaseManager/MySQLiDB.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,9 @@ public function Insert(string $Into, string $Columns, string $Values): array|obj
{
return $this->MySQLi->query('INSERT INTO `'.$Into.'` ('.$Columns.') VALUES ('.$Values.')');
}

public function Query($Query)
{
return $this->MySQLi->query($Query);
}
}
8 changes: 3 additions & 5 deletions Processes/Saturn/RouteManager/RouteMain.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@ public function __construct(Router $Router)

public function Register(): void
{
if (WEBSITE_MODE == 0 /*|| (WEBSITE_MODE == 1 && AUTH)*/) {
// Homepage
$this->Router->GET('/', 'DefaultViews/NoHomepage.php');
} elseif (WEBSITE_MODE == 1) {
$this->Router->GET('/', 'DefaultViews/Maintenance.php');
if (WEBSITE_MODE == 1) {
require_once __DIR__ . '/../../DefaultViews/Maintenance.php';
exit;
}
}
}
29 changes: 29 additions & 0 deletions Processes/Saturn/RouteManager/RoutePages.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace Saturn\RouteManager;

use Saturn\DatabaseManager\DBMS;
use Saturn\HTTP\Router;

class RoutePages
{
public Router $Router;

public function __construct(Router $Router)
{
$this->Router = $Router;
}

public function Register(): void
{
$DBMS = new DBMS();
$Page = $DBMS->Query("SELECT * FROM `".DB_PREFIX."pages` WHERE `url` = '".$DBMS->Escape($_SERVER['REQUEST_URI'])."';");

if ($Page !== NULL && $Page->num_rows !== 0) {
$this->Router->GET($DBMS->Escape($_SERVER['REQUEST_URI']), 'DefaultViews/Page.php');
} elseif ($DBMS->Escape($_SERVER['REQUEST_URI']) === '/') {
require_once __DIR__ . '/../../DefaultViews/NoHomepage.php';
exit;
}
}
}
4 changes: 4 additions & 0 deletions Processes/Saturn/RouteManager/Routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ public function Register(): void
$RouteAPI = new RouteAPI($Router);
$RouteAPI->Register();

require_once __DIR__.'/RoutePages.php';
$RoutePages = new RoutePages($Router);
$RoutePages->Register();

echo '404 - Page not found.';
}
}
2 changes: 1 addition & 1 deletion Settings/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
const DB_PASS = '';
const DB_PORT = 3306;
const DB_CHARSET = 'utf8mb4';
const DB_PREFIX = 'Saturn_';
const DB_PREFIX = 'saturn_';
const DB_OPTIONS = [
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
Expand Down

0 comments on commit efb4119

Please sign in to comment.