Compare commits
22
Commits
9af5f50135
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
98edad5bf7 | ||
|
|
91de0f1462 | ||
|
|
dfdcd992ad | ||
|
|
f7c6276a7a | ||
|
|
0138a14c29 | ||
|
|
2ecc79c714 | ||
|
|
ee40846bd6 | ||
|
|
7beef3a1d5 | ||
|
|
3b47e0ed71 | ||
|
|
8d576a497b | ||
|
|
54eee2416a | ||
|
|
c18c80d732 | ||
|
|
a0d302daec | ||
|
|
20a8afa9ce | ||
|
|
d85fe1b75c | ||
|
|
ccd2a2776a | ||
|
|
5d3962bba4 | ||
|
|
e782ea5979 | ||
|
|
9a99c31d47 | ||
|
|
d50443b10a | ||
|
|
b244b625ab | ||
|
|
2311c98257 |
@@ -42,7 +42,7 @@ class Mail {
|
||||
return mail($to, $subject, $message, $headers);
|
||||
}
|
||||
|
||||
public static function sendMail(string $subject, string $message, string $from = '', string $to = ''): bool
|
||||
public static function sendMail(string $subject, string $message, string $to = '', string $from = ''): bool
|
||||
{
|
||||
if ($to == '') {
|
||||
$to = self::$to;
|
||||
|
||||
+35
-101
@@ -40,15 +40,8 @@ class Router {
|
||||
|
||||
// Process basic routes
|
||||
foreach (self::$routes as $route) {
|
||||
// If route does not match the base url
|
||||
if ($route[0] != $path) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// ["/example/my-page", "ExampleController", "action", "" : ["view", "title", "description"]],
|
||||
self::addBasicRoute(['GET', 'POST'], $route);
|
||||
|
||||
break;
|
||||
self::addRoute(['GET', 'POST'], $route);
|
||||
}
|
||||
|
||||
self::createNavigation();
|
||||
@@ -81,13 +74,13 @@ class Router {
|
||||
* DELETE /route/{id} destroyAction
|
||||
*/
|
||||
|
||||
self::addRoute(['GET'], [$route, $controller, 'indexAction']);
|
||||
self::addRoute(['GET'], [$route . '/create', $controller, 'createAction']);
|
||||
self::addRoute(['POST'], [$route, $controller, 'storeAction']);
|
||||
self::addRoute(['GET'], [$route . '/[i:id]', $controller, 'showAction', ['id']]);
|
||||
self::addRoute(['GET'], [$route . '/[i:id]/edit', $controller, 'editAction', ['id']]);
|
||||
self::addRoute(['PUT', 'PATCH'], [$route . '/[i:id]', $controller, 'updateAction', ['id']]);
|
||||
self::addRoute(['DELETE'], [$route . '/[i:id]', $controller, 'destroyAction', ['id']]);
|
||||
self::addRoute(['GET'], [$route, $controller, 'index']);
|
||||
self::addRoute(['GET'], [$route . '/create', $controller, 'create']);
|
||||
self::addRoute(['POST'], [$route, $controller, 'store']);
|
||||
self::addRoute(['GET'], [$route . '/[i:id]', $controller, 'show']);
|
||||
self::addRoute(['GET'], [$route . '/[i:id]/edit', $controller, 'edit']);
|
||||
self::addRoute(['PUT', 'PATCH'], [$route . '/[i:id]', $controller, 'update']);
|
||||
self::addRoute(['DELETE'], [$route . '/[i:id]', $controller, 'destroy']);
|
||||
}
|
||||
|
||||
//-------------------------------------//
|
||||
@@ -146,7 +139,7 @@ class Router {
|
||||
$url = '/' . $section[$page['section_id']] . '/' . $page['page'];
|
||||
|
||||
// Add route
|
||||
self::$routes[] = [$url, 'PageController', 'route', $page['id']];
|
||||
self::$routes[] = [$url, 'PageController', 'route', [$page['id']]];
|
||||
}
|
||||
|
||||
// Cache sections and pages
|
||||
@@ -156,109 +149,53 @@ class Router {
|
||||
|
||||
protected static function addRoute(array $method = [], array $data = []): void
|
||||
{
|
||||
if (!_exists($method) || !_exists($data)) {
|
||||
if (!_exists($method) || !_exists($data) || count($data) < 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
$route = $data[0] ?? '';
|
||||
$controller = $data[1] ?? '';
|
||||
$action = $data[2] ?? '';
|
||||
$param = $data[3] ?? [];
|
||||
if ($route == '' || $controller == '' || $action == '') {
|
||||
$route = $data[0] ?? null;
|
||||
$controller = $data[1] ?? null;
|
||||
$action = $data[2] ?? null;
|
||||
$parameters = $data[3] ?? [];
|
||||
|
||||
if (!$route || !$controller || !is_array($parameters)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Create Klein route
|
||||
self::$router->respond($method, $route, function($request, $response, $service)
|
||||
use($controller, $action, $param) {
|
||||
self::$router->respond($method, $route, function($request, $response, $service) use($controller, $action, $parameters) {
|
||||
|
||||
// Create new Controller object
|
||||
$controller = '\App\Controllers\\' . $controller;
|
||||
$controller = new $controller(self::$router);
|
||||
|
||||
$stillValid = true;
|
||||
// Complete action variable
|
||||
if (!$action) {
|
||||
$action = 'indexAction';
|
||||
}
|
||||
else {
|
||||
$action .= 'Action';
|
||||
}
|
||||
|
||||
// If method does not exist in object
|
||||
if (!method_exists($controller, $action)) {
|
||||
$stillValid = false;
|
||||
return $controller->throw404();
|
||||
}
|
||||
|
||||
// If no valid permissions
|
||||
if ($controller->getAdminSection() &&
|
||||
$controller->getLoggedIn() == false) {
|
||||
$stillValid = false;
|
||||
if ($controller->getAdminSection() && !$controller->getLoggedIn()) {
|
||||
return $controller->throw404();
|
||||
}
|
||||
|
||||
// Get URL parameters
|
||||
$namedParameters = array_filter($request->paramsNamed()->all(), 'is_string', ARRAY_FILTER_USE_KEY);
|
||||
$namedParameters = array_values($namedParameters);
|
||||
|
||||
// Append URL parameters to the hard-coded parameters
|
||||
array_push($parameters, ...$namedParameters);
|
||||
|
||||
// Call Controller action
|
||||
if ($stillValid) {
|
||||
|
||||
// Loop through params
|
||||
$params = [];
|
||||
foreach ($param as $name) {
|
||||
$params[] = $request->param($name);
|
||||
}
|
||||
|
||||
return $controller->{$action}(...$params);
|
||||
}
|
||||
else {
|
||||
$controller->throw404();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected static function addBasicRoute(array $method = [], array $route = []): void
|
||||
{
|
||||
if (!_exists($method) || !_exists($route)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Create Klein route
|
||||
self::$router->respond($method, $route[0], function() use($route) {
|
||||
|
||||
// Create new Controller object
|
||||
$controller = '\App\Controllers\\' . $route[1];
|
||||
$controller = new $controller(self::$router);
|
||||
|
||||
// Complete action variable
|
||||
if ($route[2] == '') {
|
||||
$route[2] = 'indexAction';
|
||||
}
|
||||
else {
|
||||
$route[2] .= 'Action';
|
||||
}
|
||||
|
||||
$stillValid = true;
|
||||
|
||||
// If method does not exist in object
|
||||
if (!method_exists($controller, $route[2])) {
|
||||
$stillValid = false;
|
||||
}
|
||||
|
||||
// If no valid permissions
|
||||
if ($controller->getAdminSection() &&
|
||||
$controller->getLoggedIn() == false) {
|
||||
$stillValid = false;
|
||||
}
|
||||
|
||||
// Call Controller action
|
||||
if ($stillValid) {
|
||||
if (is_array($route[3])) {
|
||||
return $controller->{$route[2]}(
|
||||
$route[3][0] ?? '',
|
||||
$route[3][1] ?? '',
|
||||
$route[3][2] ?? ''
|
||||
);
|
||||
}
|
||||
else if ($route[3] != '') {
|
||||
return $controller->{$route[2]}($route[3]);
|
||||
}
|
||||
else {
|
||||
return $controller->{$route[2]}();
|
||||
}
|
||||
}
|
||||
else {
|
||||
$controller->throw404();
|
||||
}
|
||||
return $controller->{$action}(...$parameters);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -348,6 +285,3 @@ class Router {
|
||||
}
|
||||
|
||||
Router::_init();
|
||||
|
||||
// @Todo
|
||||
// - combine addRoute and addBasicroute functionality
|
||||
|
||||
@@ -41,7 +41,7 @@ class User {
|
||||
$user = UserModel::search(['username' => $username]);
|
||||
|
||||
$success = false;
|
||||
if ($user->exists() && $user->failed_login_attempt <= 2) {
|
||||
if ($user->exists() && $user->loginAllowed()) {
|
||||
$saltPassword = $user->salt . $password;
|
||||
if (password_verify($saltPassword, $user->password)) {
|
||||
$success = true;
|
||||
|
||||
@@ -0,0 +1,161 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Http;
|
||||
|
||||
class Http {
|
||||
|
||||
private string $bodyContent;
|
||||
|
||||
private string $bodyFormat;
|
||||
|
||||
private array $options = [];
|
||||
|
||||
//-------------------------------------//
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public function delete(string $url, $data = []): Response
|
||||
{
|
||||
return $this->send('DELETE', $url, [
|
||||
$this->bodyFormat => $data
|
||||
]);
|
||||
}
|
||||
|
||||
public function get(string $url, $query = null): Response
|
||||
{
|
||||
return $this->send('GET', $url, [
|
||||
'query' => $query
|
||||
]);
|
||||
}
|
||||
|
||||
public function patch(string $url, array $data = []): Response
|
||||
{
|
||||
return $this->send('PATCH', $url, [
|
||||
$this->bodyFormat => $data
|
||||
]);
|
||||
}
|
||||
|
||||
public function put(string $url, array $data = []): Response
|
||||
{
|
||||
return $this->send('PUT', $url, [
|
||||
$this->bodyFormat => $data
|
||||
]);
|
||||
}
|
||||
|
||||
public function post(string $url, array $data = []): Response
|
||||
{
|
||||
return $this->send('POST', $url, [
|
||||
$this->bodyFormat => $data
|
||||
]);
|
||||
}
|
||||
|
||||
//-------------------------------------//
|
||||
|
||||
public function accept(string $contentType): Http
|
||||
{
|
||||
return $this->withHeaders(['Accept' => $contentType]);
|
||||
}
|
||||
|
||||
public function acceptJson(): Http
|
||||
{
|
||||
return $this->accept('application/json');
|
||||
}
|
||||
|
||||
public function asForm(): Http
|
||||
{
|
||||
return $this->bodyFormat('form_params')
|
||||
->contentType('application/x-www-form-urlencoded');
|
||||
}
|
||||
|
||||
public function asJson(): Http
|
||||
{
|
||||
return $this->bodyFormat('json')
|
||||
->contentType('application/json');
|
||||
}
|
||||
|
||||
public function bodyFormat(string $format): Http
|
||||
{
|
||||
$this->bodyFormat = $format;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function contentType(string $type): Http
|
||||
{
|
||||
return $this->withHeaders(['Content-Type' => $type]);
|
||||
}
|
||||
|
||||
public function withBody(string $content, string $contentType): Http
|
||||
{
|
||||
$this->bodyFormat('body');
|
||||
|
||||
$this->bodyContent = $content;
|
||||
|
||||
$this->contentType($contentType);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function withHeaders(array $headers): Http
|
||||
{
|
||||
$this->options = array_merge_recursive($this->options, [
|
||||
'headers' => $headers,
|
||||
]);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function withToken(string $token): Http
|
||||
{
|
||||
$this->withHeaders(['Authorization' => 'Bearer ' . trim($token)]);
|
||||
return $this;
|
||||
}
|
||||
|
||||
//-------------------------------------//
|
||||
|
||||
public function send(string $method, string $url, array $options = []): Response
|
||||
{
|
||||
// Format headers
|
||||
$headers = [];
|
||||
if (_exists($this->options, 'headers')) {
|
||||
foreach ($this->options['headers'] as $key => $value) {
|
||||
$headers[] = "$key: $value";
|
||||
}
|
||||
}
|
||||
|
||||
// Fill body content
|
||||
switch ($this->bodyFormat) {
|
||||
case 'body':
|
||||
break;
|
||||
case 'json':
|
||||
if (_exists($options, 'json')) {
|
||||
$this->bodyContent = json_encode($options['json']);
|
||||
}
|
||||
break;
|
||||
case 'form_params':
|
||||
if (_exists($options, 'form_params')) {
|
||||
$this->bodyContent = http_build_query($options['form_params']);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Send HTTP request
|
||||
$curl = curl_init();
|
||||
curl_setopt($curl, CURLOPT_URL, $url);
|
||||
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
|
||||
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $this->bodyContent);
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
||||
$response = curl_exec($curl);
|
||||
curl_close($curl);
|
||||
|
||||
// On failed requests
|
||||
if (!$response) {
|
||||
$response = '';
|
||||
}
|
||||
|
||||
return new Response($response);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Http;
|
||||
|
||||
class Response {
|
||||
|
||||
private string $response;
|
||||
|
||||
public function __construct(string $response)
|
||||
{
|
||||
$this->response = $response;
|
||||
}
|
||||
|
||||
//-------------------------------------//
|
||||
|
||||
public function body(): string
|
||||
{
|
||||
return $this->response;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Classes\Config;
|
||||
use App\Model\BlogModel;
|
||||
|
||||
class BlogController extends PageController {
|
||||
|
||||
public function searchAction(): void
|
||||
{
|
||||
$archived = $this->router->request()->param('archived', 0);
|
||||
$search = $this->router->request()->param('search', '');
|
||||
$posts = $this->search($search, $archived);
|
||||
|
||||
$this->defineHelpers();
|
||||
|
||||
// AJAX search request will only render the posts partial
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||
$this->router->service()->partial($this->views . '/partials/blog-posts.php', ['posts' => $posts]);
|
||||
return;
|
||||
}
|
||||
|
||||
$this->router->service()->posts = $posts;
|
||||
$this->router->service()->search = $search;
|
||||
$this->router->service()->injectView = $this->views . '/partials/blog-posts.php';
|
||||
parent::view('blog', 'Blog');
|
||||
}
|
||||
|
||||
public function rssAction(): void
|
||||
{
|
||||
date_default_timezone_set('Europe/Amsterdam');
|
||||
|
||||
$xml = new \SimpleXMLElement('<rss version="2.0"/>');
|
||||
$channel = $xml->addChild('channel');
|
||||
$channel->addChild('title', 'Rick's Webpage');
|
||||
$channel->addChild('link', Config::c('APP_URL'));
|
||||
$channel->addChild('description', 'Recent content on Rick's Webpage.');
|
||||
$channel->addChild('language', 'en-us');
|
||||
$channel->addChild('lastBuildDate', date('D, d M Y H:i:s O'));
|
||||
|
||||
// Fetch all non-archived blog posts
|
||||
$search = $this->router->request()->param('search', '');
|
||||
$posts = $this->search($search, 0);
|
||||
|
||||
foreach ($posts as $post) {
|
||||
$link = Config::c('APP_URL') . '/' . $post['section'] . '/' . $post['page'];
|
||||
$date = (new \DateTime($post['created_at']))->format('D, d M Y H:i:s O');
|
||||
|
||||
$item = $channel->addChild('item');
|
||||
$item->addChild('title', $post['title']);
|
||||
$item->addChild('link', $link);
|
||||
$item->addChild('description', $post['content']);
|
||||
$item->addChild('pubDate', $date);
|
||||
$item->addChild('guid', $link);
|
||||
}
|
||||
|
||||
header('content-type: text/xml; charset=UTF-8');
|
||||
$dom = new \DOMDocument("1.0");
|
||||
$dom->preserveWhiteSpace = false;
|
||||
$dom->formatOutput = true;
|
||||
$dom->loadXML($xml->asXML());
|
||||
print $dom->saveXML();
|
||||
}
|
||||
|
||||
//-------------------------------------//
|
||||
|
||||
private function search(string $query = '', int $archived = 0): ?array
|
||||
{
|
||||
return BlogModel::selectAll(
|
||||
'blog_post.*, media.filename, media.extension, page.page, section.section, log.created_at', '
|
||||
LEFT JOIN media ON blog_post.media_id = media.id
|
||||
LEFT JOIN page ON blog_post.page_id = page.id
|
||||
LEFT JOIN section ON page.section_id = section.id
|
||||
LEFT JOIN log ON blog_post.log_id = log.id
|
||||
WHERE blog_post.archived = :archived AND
|
||||
(blog_post.content LIKE :query OR
|
||||
blog_post.title LIKE :query OR
|
||||
blog_post.tag LIKE :query)
|
||||
', [
|
||||
[':archived', "$archived", \PDO::PARAM_INT],
|
||||
[':query', "%$query%", \PDO::PARAM_STR]
|
||||
]);
|
||||
}
|
||||
|
||||
private function defineHelpers(): void
|
||||
{
|
||||
$this->router->service()->prettyTimestamp = function (string $timestamp): string {
|
||||
$date = date_create($timestamp);
|
||||
$date = date_format($date, 'd M Y');
|
||||
return "<u class=\"text-decoration-none text-reset\" title=\"{$timestamp}\">{$date}</u>";
|
||||
};
|
||||
|
||||
$this->router->service()->tags = function (string $tags): string {
|
||||
$result = "";
|
||||
|
||||
// Remove empty elements via array_filter()
|
||||
$splitTags = array_filter(explode(':', $tags), function ($tag) {
|
||||
return !empty(trim($tag));
|
||||
});
|
||||
|
||||
foreach ($splitTags as $key => $tag) {
|
||||
$result .= $tag;
|
||||
$result .= (($key === array_key_last($splitTags)) ? '' : ', ');
|
||||
}
|
||||
|
||||
return $result;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -3,21 +3,86 @@
|
||||
namespace App\Controllers;
|
||||
|
||||
use App\Classes\Config;
|
||||
use App\Classes\Http\Http;
|
||||
use App\Classes\Session;
|
||||
use App\Model\ConfigModel;
|
||||
|
||||
class CacheController extends PageController {
|
||||
|
||||
/**
|
||||
* Maximum amount of files that can be purged on a single request
|
||||
*/
|
||||
public static int $purgeLimit = 30;
|
||||
|
||||
public function cacheAction(): void
|
||||
{
|
||||
$config = $this->getConfigValues();
|
||||
|
||||
$this->router->service()->config = $config;
|
||||
$this->router->service()->csrfToken = Session::token();
|
||||
$this->router->service()->purgeUrl = $this->url . '/purge';
|
||||
$this->router->service()->toggleUrl = $this->url . '/toggle';
|
||||
parent::view();
|
||||
}
|
||||
|
||||
public function developmentAction(): void
|
||||
public function purgeAction(): void
|
||||
{
|
||||
if (Config::c('CLOUDFLARE_ENABLED') != '1') {
|
||||
if (!$this->validatePostRequest()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$token = Config::c('CLOUDFLARE_TOKEN');
|
||||
$zone = Config::c('CLOUDFLARE_ZONE');
|
||||
|
||||
$url = "https://api.cloudflare.com/client/v4/zones/$zone/purge_cache";
|
||||
|
||||
if (!_exists($_POST, 'type')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$bodies = [];
|
||||
switch($_POST['type']) {
|
||||
case 'css-js':
|
||||
$body = self::generateUrls(['css', 'js']);
|
||||
$chunks = array_chunk($body['files'], self::$purgeLimit);
|
||||
foreach($chunks as $chunk) {
|
||||
$bodies[]['files'] = $chunk;
|
||||
}
|
||||
break;
|
||||
case 'fonts-images':
|
||||
$body = self::generateUrls(['fonts', 'img', 'media']);
|
||||
$chunks = array_chunk($body['files'], self::$purgeLimit);
|
||||
foreach($chunks as $chunk) {
|
||||
$bodies[]['files'] = $chunk;
|
||||
}
|
||||
break;
|
||||
case 'all':
|
||||
$bodies[] = ['purge_everything' => true];
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
$response = null;
|
||||
foreach($bodies as $body) {
|
||||
$response = (new Http)->withToken($token)
|
||||
->asJson()
|
||||
->acceptJson()
|
||||
->post($url, $body);
|
||||
if (empty($response->body())
|
||||
|| !json_decode($response->body(), true)['success']) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($response) {
|
||||
echo $response->body();
|
||||
}
|
||||
}
|
||||
|
||||
public function toggleAction(): void
|
||||
{
|
||||
if (!$this->validatePostRequest()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -25,38 +90,55 @@ class CacheController extends PageController {
|
||||
$zone = Config::c('CLOUDFLARE_ZONE');
|
||||
|
||||
$url = "https://api.cloudflare.com/client/v4/zones/$zone/settings/development_mode";
|
||||
$headers = [
|
||||
"Authorization: Bearer $token",
|
||||
"Content-Type: application/json"
|
||||
];
|
||||
|
||||
$config = $this->getConfigValues();
|
||||
$currentState = $config['CLOUDFLARE_DEVELOPMENT_MODE_ENABLED'];
|
||||
|
||||
$newState = $currentState == '1' ? 'off' : 'on';
|
||||
$data = '{"value": "' . $newState . '"}';
|
||||
$response = (new Http)->withToken($token)
|
||||
->asJson()
|
||||
->acceptJson()
|
||||
->patch($url, [
|
||||
'value' => $currentState == '1' ? 'off' : 'on',
|
||||
]);
|
||||
|
||||
$curl = curl_init();
|
||||
curl_setopt($curl, CURLOPT_URL, $url);
|
||||
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
|
||||
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
|
||||
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, 'PATCH');
|
||||
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
|
||||
// curl_setopt($curl, CURLINFO_HEADER_OUT, 1);
|
||||
$this->saveConfigValues($response->body());
|
||||
|
||||
$response = curl_exec($curl);
|
||||
// $info = curl_getinfo($curl, CURLINFO_HEADER_OUT);
|
||||
|
||||
curl_close($curl);
|
||||
|
||||
$this->saveConfigValues($response);
|
||||
|
||||
echo $response;
|
||||
// echo $info;
|
||||
echo $response->body();
|
||||
}
|
||||
|
||||
//-------------------------------------//
|
||||
|
||||
private function validatePostRequest(): bool
|
||||
{
|
||||
if ($_SERVER['REQUEST_METHOD'] == 'GET') {
|
||||
parent::throw404();
|
||||
}
|
||||
|
||||
if (Config::c('CLOUDFLARE_ENABLED') != '1') {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!Session::validateToken($_POST)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static function generateUrls(array $directories): array
|
||||
{
|
||||
$result = [];
|
||||
|
||||
foreach ($directories as $directory) {
|
||||
$files = array_diff(scandir($directory), ['..', '.']);
|
||||
foreach ($files as $file) {
|
||||
$result['files'][] = Config::c('APP_URL') . "/$directory/$file";
|
||||
}
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
private static function getConfigValues(): array
|
||||
{
|
||||
$result = [];
|
||||
|
||||
@@ -43,7 +43,7 @@ class LoginController extends PageController {
|
||||
}
|
||||
else {
|
||||
$user = User::getUser('', $_POST['username']);
|
||||
if ($user->exists() && $user->failed_login_attempt >= 5) {
|
||||
if ($user->exists() && !$user->loginAllowed()) {
|
||||
$this->setAlert('danger', 'User has been blocked.');
|
||||
}
|
||||
else {
|
||||
@@ -151,7 +151,7 @@ class LoginController extends PageController {
|
||||
<a href='$resetUrl'>$resetUrl</a>
|
||||
";
|
||||
|
||||
if (Mail::send($subject, $message, $user->email)) {
|
||||
if (Mail::sendMail($subject, $message, $user->email)) {
|
||||
$this->setAlert('success', 'Successfully requested password reset.');
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Model;
|
||||
|
||||
class BlogModel extends Model {
|
||||
|
||||
protected $table = 'blog_post';
|
||||
|
||||
}
|
||||
+1
-1
@@ -98,7 +98,7 @@ abstract class Model {
|
||||
protected static function query(string $query, array $parameters = [],
|
||||
$type = ':'): ?array
|
||||
{
|
||||
if (substr_count($query, $type) != count($parameters)) {
|
||||
if ($type == '?' && substr_count($query, $type) != count($parameters)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,5 +3,18 @@
|
||||
namespace App\Model;
|
||||
|
||||
class UserModel extends Model {
|
||||
|
||||
protected $table = 'user';
|
||||
|
||||
//-------------------------------------//
|
||||
|
||||
public function loginAllowed(): bool
|
||||
{
|
||||
if (property_exists($this, 'failed_login_attempt') && $this->failed_login_attempt < 5) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<?php
|
||||
|
||||
use \App\Classes\Config;
|
||||
use \App\Classes\Config;
|
||||
?>
|
||||
<div class="content shadow p-4 mb-4">
|
||||
<h3 class="mb-4">Cache</h3>
|
||||
@@ -23,7 +22,8 @@ use \App\Classes\Config;
|
||||
</div>
|
||||
<div class="col-3 col-md-2 col-lg-2 col-xl-2">
|
||||
<div class="d-flex justify-content-center">
|
||||
<button id="" class="btn btn-dark">Purge</button>
|
||||
<a class="js-purge btn btn-dark" href="<?= $this->purgeUrl; ?>"
|
||||
data-type="css-js" data-token="<?= $this->csrfToken; ?>">Purge</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -35,7 +35,8 @@ use \App\Classes\Config;
|
||||
</div>
|
||||
<div class="col-3 col-md-2 col-lg-2 col-xl-2">
|
||||
<div class="d-flex justify-content-center">
|
||||
<button id="" class="btn btn-danger">Purge</button>
|
||||
<a class="js-purge btn btn-danger" href="<?= $this->purgeUrl; ?>"
|
||||
data-type="fonts-images" data-token="<?= $this->csrfToken; ?>">Purge</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -47,7 +48,8 @@ use \App\Classes\Config;
|
||||
</div>
|
||||
<div class="col-3 col-md-2 col-lg-2 col-xl-2">
|
||||
<div class="d-flex justify-content-center">
|
||||
<button id="" class="btn btn-danger">Purge</button>
|
||||
<a class="js-purge btn btn-danger" href="<?= $this->purgeUrl; ?>"
|
||||
data-type="all" data-token="<?= $this->csrfToken; ?>">Purge</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -72,11 +74,10 @@ use \App\Classes\Config;
|
||||
<div class="col-3 col-md-2 col-lg-2 col-xl-2">
|
||||
<div class="d-flex justify-content-center">
|
||||
<input type="checkbox" id="development-mode"
|
||||
data-href="<?= $this->toggleUrl; ?>" data-token="<?= $this->csrfToken; ?>"
|
||||
<?= $this->config['CLOUDFLARE_DEVELOPMENT_MODE_ENABLED'] ? 'checked' : ''; ?>>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<div class="pb-5"></div>
|
||||
</div>
|
||||
|
||||
@@ -45,7 +45,10 @@
|
||||
|
||||
<select name="<?= $name; ?>" class="custom-select" <?= $required; ?>>
|
||||
<?php foreach($this->dropdownData[$key] as $dropdownKey => $value) { ?>
|
||||
<option value="<?= $dropdownKey; ?>"><?= $value; ?></option>
|
||||
<option value="<?= $dropdownKey; ?>"
|
||||
<?= ($dropdownKey == 0) ? 'disabled selected' : ''; ?>>
|
||||
<?= $value; ?>
|
||||
</option>
|
||||
<?php } ?>
|
||||
</select>
|
||||
|
||||
@@ -56,8 +59,6 @@
|
||||
|
||||
<input type="hidden" name="_token" value="<?= $this->csrfToken; ?>" />
|
||||
</form>
|
||||
|
||||
<div class="pb-5"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
<select name="<?= $name; ?>" class="custom-select" <?= $required; ?>>
|
||||
<?php foreach($this->dropdownData[$key] as $dropdownKey => $value) { ?>
|
||||
<option value="<?= $dropdownKey; ?>"
|
||||
<?= ($dropdownKey == 0) ? 'disabled' : ''; ?>
|
||||
<?= $this->model->$name == $dropdownKey ? 'selected' : ''; ?>>
|
||||
<?= $value; ?>
|
||||
</option>
|
||||
@@ -61,8 +62,6 @@
|
||||
|
||||
<input type="hidden" name="_token" value="<?= $this->csrfToken; ?>" />
|
||||
</form>
|
||||
|
||||
<div class="pb-5"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -64,8 +64,6 @@
|
||||
<a class="btn btn-dark" href="<?= $this->url ?>/create">New <?= $this->title; ?></a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="pb-5"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -33,8 +33,6 @@
|
||||
<?php } ?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<div class="pb-5"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -8,6 +8,4 @@
|
||||
<?= !empty($this->user->last_name) ? ' ' . $this->user->last_name : ''; ?>
|
||||
</h3>
|
||||
</div>
|
||||
|
||||
<div class="pb-5"></div>
|
||||
</div>
|
||||
|
||||
@@ -84,7 +84,6 @@
|
||||
|
||||
<?= $this->partial('../app/views/partials/pagination.php'); ?>
|
||||
|
||||
<div class="pb-5"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -28,6 +28,4 @@
|
||||
|
||||
<div id="syntax-parse"><pre class="line-numbers mb-4"><code class=""></code></pre></div>
|
||||
<textarea id="syntax-parse-copy" class="admin-hidden"></textarea>
|
||||
|
||||
<div class="pb-5"></div>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
<div class="row mt-4">
|
||||
<?php $size = $this->sideContent ? '8' : '12'; ?>
|
||||
<div class="col-12 col-md-<?= $size; ?> col-lg-<?= $size; ?>">
|
||||
|
||||
<div class="input-group mb-4">
|
||||
<input type="text" name="blog-search" id="js-blog-search" class="form-control"
|
||||
autofocus="" placeholder="Search" value="<?= $this->search; ?>" onfocus="this.select();" data-url="<?= $this->url; ?>">
|
||||
<div class="input-group-append">
|
||||
<button type="button" id="js-blog-search-button" class="btn btn-dark"><i class="fa fa-search"></i> Search</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="blog-posts">
|
||||
<?= $this->partial($this->injectView); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -17,10 +17,6 @@
|
||||
<?php if ($this->injectView != '') { ?>
|
||||
<?= $this->partial($this->injectView); ?>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ($key === array_key_last($this->contents)) { ?>
|
||||
<div class="pb-5"></div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
@@ -3,6 +3,4 @@
|
||||
<p>Error <strong>404</strong>.</p>
|
||||
<p>requested URL <?= $_SERVER["REQUEST_URI"] ?> was not found on this server.</p>
|
||||
</div>
|
||||
|
||||
<div class="pb-5"></div>
|
||||
</div>
|
||||
|
||||
@@ -9,18 +9,18 @@
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<meta name="description" content="<?= $this->metaDescription; ?>">
|
||||
|
||||
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
|
||||
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/4.6.2/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N" crossorigin="anonymous">
|
||||
|
||||
<?php if ($this->adminSection) { ?>
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.59.4/codemirror.min.css" rel="stylesheet" integrity="sha384-K/FfhVUneW5TdId1iTRDHsOHhLGHoJekcX6UThyJhMRctwRxlL3XmSnTeWX2k3Qe" crossorigin="anonymous">
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.59.4/theme/tomorrow-night-eighties.min.css" rel="stylesheet" integrity="sha384-zTCWZYMg963D68otcZCn2SQ2SBwih+lCwYxWqvx6xH8/Wt6+NN+giHIvcMpN4cPD" crossorigin="anonymous">
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.9/codemirror.min.css" rel="stylesheet" integrity="sha384-zaeBlB/vwYsDRSlFajnDd7OydJ0cWk+c2OWybl3eSUf6hW2EbhlCsQPqKr3gkznT" crossorigin="anonymous">
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.9/theme/tomorrow-night-eighties.min.css" rel="stylesheet" integrity="sha384-zTCWZYMg963D68otcZCn2SQ2SBwih+lCwYxWqvx6xH8/Wt6+NN+giHIvcMpN4cPD" crossorigin="anonymous">
|
||||
|
||||
<link href="https://cdn.jsdelivr.net/npm/summernote@0.8.15/dist/summernote-bs4.min.css" rel="stylesheet" integrity="sha384-JNFvp1YkK/DsvVg1KxCYX/jfLcrqFkwUE1+4kt+Zpkhvfeetb13H+j2ZZhrTJwRy" crossorigin="anonymous">
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.20/summernote-bs4.min.css" rel="stylesheet" integrity="sha384-hqv27sxmxAI2L4eughLkUpjS75/Z3/hg9DOWIl0PJWE4B6GJqM2Kx72ZPoQzsUpF" crossorigin="anonymous">
|
||||
<?php } ?>
|
||||
|
||||
<link href="https://cdn.jsdelivr.net/npm/prismjs@1.22.0/themes/prism-tomorrow.min.css" rel="stylesheet" integrity="sha384-rG0ypOerdVJPawfZS6juq8t8GVE9oCCPJbOXV/bF+e61zYW9Ib6u9WwSbTOK6CKA" crossorigin="anonymous">
|
||||
<link href="https://cdn.jsdelivr.net/npm/prismjs@1.22.0/plugins/line-numbers/prism-line-numbers.min.css" rel="stylesheet" integrity="sha384-n3/UuPVL3caytud/opHXuyFoezGp2oAUB0foYaCAIs2QwGv/nV0kULHS2WAaJuxR" crossorigin="anonymous">
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/themes/prism-tomorrow.min.css" rel="stylesheet" integrity="sha384-wFjoQjtV1y5jVHbt0p35Ui8aV8GVpEZkyF99OXWqP/eNJDU93D3Ugxkoyh6Y2I4A" crossorigin="anonymous">
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/line-numbers/prism-line-numbers.min.css" rel="stylesheet" integrity="sha384-nUkTNLI8COlMCRJ0FHIdX76If83145OTCLUx4gQyfnO0gGeO/sD9czGEUBxtkcUv" crossorigin="anonymous">
|
||||
|
||||
<link href="<?= Config::c('APP_URL'); ?>/css/style.css" rel="stylesheet">
|
||||
|
||||
|
||||
@@ -22,6 +22,4 @@
|
||||
<br>
|
||||
<a href="<?= Config::c('APP_URL'); ?>/reset-password">Forgot password</a>?
|
||||
<?php } ?>
|
||||
|
||||
<div class="pb-5"></div>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
use App\Classes\Config;
|
||||
?>
|
||||
<?php foreach ($this->posts as $post) { ?>
|
||||
<a class="clear" href="<?= Config::c('APP_URL') . '/' . $post['section'] . '/' . $post['page']; ?>">
|
||||
<div class="content shadow p-4 mb-4" style="min-height: 0;">
|
||||
<div class="row">
|
||||
<div class="col-12 <?= _exists($post, 'media_id') ? 'col-md-9' : ''; ?>">
|
||||
<div class="d-flex flex-wrap align-items-baseline">
|
||||
<h4 class="mr-3"><strong><?= $post['title']; ?></strong></h4>
|
||||
<small class="mb-2 text-muted"><?= ($this->prettyTimestamp)($post['created_at']); ?></small>
|
||||
</div>
|
||||
<p>
|
||||
<?= $post['content']; ?>
|
||||
</p>
|
||||
<?php if (_exists($post, 'tag')) { ?>
|
||||
<small>
|
||||
<i>tags: <?= ($this->tags)($post['tag']); ?></i>
|
||||
</small>
|
||||
<div class="d-md-none mb-3"></div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php if (_exists($post, 'media_id')) { ?>
|
||||
<div class="col-12 col-md-3">
|
||||
<img src="<?= Config::c('APP_URL'). '/media/' . $post['filename'] . '.' . $post['extension']; ?>"
|
||||
loading="lazy" class="w-100" style="height: 125px; object-fit: cover;">
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
<?php } ?>
|
||||
@@ -2,10 +2,8 @@
|
||||
use App\Classes\Config;
|
||||
?>
|
||||
|
||||
<footer class="mb-4">
|
||||
<div class="row">
|
||||
<div class="col-12 col-lg-12">
|
||||
<footer class="row mb-2">
|
||||
<div class="col-12">
|
||||
© <?= date('Y'); ?> Rick van Vonderen
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
@@ -48,6 +48,9 @@
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="https://gitlab.com/riyyi" target="_blank"><i class="fa fa-gitlab"></i> GitLab</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" href="https://linkedin.com/in/rickvanvonderen" target="_blank">Linked <i class="fa fa-linkedin-square"></i></a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
|
||||
@@ -1,27 +1,26 @@
|
||||
<?php
|
||||
use App\Classes\Config;
|
||||
?>
|
||||
<script src="https://code.jquery.com/jquery-3.4.1.min.js" integrity="sha384-vk5WoKIaW/vJyUAd9n/wmopsmNhiy+L2Z+SBxGYnUkunIxVxAv/UtMOhba/xskxh" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
|
||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.1/jquery.min.js" integrity="sha384-i61gTtaoovXtAbKjo903+O55Jkn2+RtzHtvNez+yI49HAASvznhe9sZyjaSHTau9" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/4.6.2/js/bootstrap.bundle.min.js" integrity="sha384-Fy6S3B9q64WdZWQUiU+q4/2Lc9npb8tCaSX9FK7E8HnRr0Jz8D6OP9dO5Vg3Q9ct" crossorigin="anonymous"></script>
|
||||
<?php if ($this->adminSection) { ?>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.59.4/codemirror.min.js" integrity="sha384-v0AyVIspkm1uirQ6Nsmr90ScryXAWf+xv0DlNrNo1BkSY3sqr7tsUKLZyTMHqy2G" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.59.4/mode/clike/clike.min.js" integrity="sha384-7LfH34Nu+Rz2rkqh9L9Okzi17vt5/sX9YZvMjHgRhwH94EdtzCaQ5SpIkXfn80/2" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.59.4/mode/xml/xml.min.js" integrity="sha384-Fohp26Rl1xXN67RS6nTZ+s+DEgvUoMZGBTzPuAwW/tjDMtaL27W3b4Irtxtf9KPw" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.59.4/mode/javascript/javascript.min.js" integrity="sha384-QPVXEBl5e4kOafHL/KBYAhkf9c7iaD6svR+RGt92QYCbdJiKcmfC4weMMPLif77e" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.59.4/mode/css/css.min.js" integrity="sha384-3UHVlVGKahbp3CTUk/YC+ICeNAx8Na6vIIrmH18NimXtGR/zF4Ce4F1d+gNPFh9a" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.59.4/mode/htmlmixed/htmlmixed.min.js" integrity="sha384-C4oV1iL5nO+MmIRm+JoD2sZ03wIafv758LRO92kyg7AFvpvn8oQAra4g3mrw5+53" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.59.4/mode/php/php.min.js" integrity="sha384-WFPjfiKs+lVB1vp9fq9wEhsgi/5Z86jVLyaGMe2wnxa/3o8SEUCySeqglAaRqxnI" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.59.4/mode/shell/shell.min.js" integrity="sha384-VzBcr5K83ctjdWufr/bGFmHLB7LbEhdN5dhKWvE3Q/H5Qfvz9dKPJgfHXeaq74da" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.59.4/mode/python/python.min.js" integrity="sha384-Wh2d9/yLlLvOQErKI4FDPRJXSklc6GlymSMyq37kJcVmfB73bJ33OqA2TpVHBisf" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.59.4/keymap/vim.min.js" integrity="sha384-MTJMQ129Rzid0TmDEIKZomitzagfahspgvwEWmm1s2ReXw8Evv5NTVf77JlmAOOM" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.9/codemirror.min.js" integrity="sha384-CYXtjHe/lDQEYXvQVyIBaQsJ/mSdH193+qSBy4GHEQJX4qN2LAHI/vrze0AC73We" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.9/mode/clike/clike.min.js" integrity="sha384-PgWELdtHCInKQO7E0Iuj74Ih+ksuRESaj8vjQhxDVdAhhqdnfmhOsQUy/cBFASN/" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.9/mode/xml/xml.min.js" integrity="sha384-xPpkMo5nDgD98fIcuRVYhxkZV6/9Y4L8s3p0J5c4MxgJkyKJ8BJr+xfRkq7kn6Tw" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.9/mode/javascript/javascript.min.js" integrity="sha384-kmQrbJf09Uo1WRLMDVGoVG3nM6F48frIhcj7f3FDUjeRzsiHwyBWDjMUIttnIeAf" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.9/mode/css/css.min.js" integrity="sha384-fpeIC2FZuPmw7mIsTvgB5BNc8QVxQC/nWg2W+CgPYOAiBiYVuHe2E8HiTWHBMIJQ" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.9/mode/htmlmixed/htmlmixed.min.js" integrity="sha384-xYIbc5F55vPi7pb/lUnFj3wu24HlpAMZdtBHkNrb2YhPzJV3pX7+eqXT2PXSNMrw" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.9/mode/php/php.min.js" integrity="sha384-1FUwPY2kaZKXw258/9CYBSS+zcc3CPggxE1zLjmYYiOdkcOw3KcXH5VNJWWbjw2U" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.9/mode/shell/shell.min.js" integrity="sha384-dmPRq54XNtYnlnAo7QrwJnZNa5r0JP5gU8z4H0686Cgz37qrR2jmNaDHUXyMI4wn" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.9/mode/python/python.min.js" integrity="sha384-anASZwLFwg9fpwvqs21eRCiI1Jxce0cbRF4W0KPN+4qrqlFGnByppUAMd6GeZb+A" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.65.9/keymap/vim.min.js" integrity="sha384-DlidtUdSavEUghGXpIXr2aM++HC3RMLDux675TC5dNunOL7pRBxKkrrkfarvcL8z" crossorigin="anonymous"></script>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/summernote@0.8.15/dist/summernote-bs4.min.js" integrity="sha384-sH3/pYu1soe3hR5e4aLT8/9wusU2x7Xt10VNfJ6n0VbsUkmkPf+3jI7So6USyROv" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/summernote/0.8.20/summernote-bs4.min.js" integrity="sha384-tG37zJAk+EcUTn0PLQkIE5Bbmkuna7/Spxvd1GU2kyY8kKGX5V2K+qGitOvd5Sm1" crossorigin="anonymous"></script>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.22.0/components/prism-core.min.js" data-manual integrity="sha384-BhpFhn+hhQohKi2ygOAJsVKyJu2q+QYydLKC7rqeMZLyEJFQl1DZieRX4/WxKUsJ" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.22.0/plugins/autoloader/prism-autoloader.min.js" integrity="sha384-FIz0ezhzXpErvkjCsQ+74Je6cuWUBoVubidnSGt498wjjEBaAV27BAISa0/GaAFq" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.22.0/plugins/line-numbers/prism-line-numbers.min.js" integrity="sha384-xktrwc/DkME39VrlkNS1tFEeq/S0JFbc8J9Q8Bjx7Xy16Z3NnmUi+94RuffrOQZR" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/prismjs@1.22.0/plugins/highlight-keywords/prism-highlight-keywords.min.js" integrity="sha384-Rk2xv6YOAfQH8z3ZAK37pgnQihXfgkER8B5EYhoFc+mMNPzf+t7g2J9U74FAvy2T" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/components/prism-core.min.js" data-manual integrity="sha384-MXybTpajaBV0AkcBaCPT4KIvo0FzoCiWXgcihYsw4FUkEz0Pv3JGV6tk2G8vJtDc" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/autoloader/prism-autoloader.min.js" integrity="sha384-Uq05+JLko69eOiPr39ta9bh7kld5PKZoU+fF7g0EXTAriEollhZ+DrN8Q/Oi8J2Q" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/line-numbers/prism-line-numbers.min.js" integrity="sha384-6QJu8apxMmB9TiPVWzYKF5pRgKcz7snO0/QU+MrWmgBLECQjoa6erxX2VQ5t41Jd" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.29.0/plugins/highlight-keywords/prism-highlight-keywords.min.js" integrity="sha384-Wchy6vgUSGGGXWUpUsb15Y8wXgk4snlp96dF6c2GvaSQ3LeYP7778HuJUDJXg/so" crossorigin="anonymous"></script>
|
||||
|
||||
<script src="<?= Config::c('APP_URL'); ?>/js/app.js"></script>
|
||||
<?php } ?>
|
||||
|
||||
@@ -9,6 +9,4 @@
|
||||
<?php } ?>
|
||||
|
||||
<?= $this->partial($this->injectView); ?>
|
||||
|
||||
<div class="pb-5"></div>
|
||||
</div>
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
],
|
||||
"psr-4": {
|
||||
"App\\Classes\\": "app/classes/",
|
||||
"App\\Classes\\Http\\": "app/classes/http/",
|
||||
"App\\Controllers\\": "app/controllers/",
|
||||
"App\\Model\\": "app/model/",
|
||||
"App\\Traits\\": "app/traits/"
|
||||
|
||||
@@ -30,8 +30,7 @@ nav.shadow {
|
||||
|
||||
.content {
|
||||
position: relative;
|
||||
/* height: calc(100% - 56px); */
|
||||
min-height: calc(100vh - 80px);
|
||||
min-height: calc(100vh - 104px - .5rem);
|
||||
padding: 20px 20px 50px 20px;
|
||||
|
||||
background-color: #fff;
|
||||
@@ -58,6 +57,11 @@ nav.shadow {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
a.clear {
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
/* Anchor offset */
|
||||
h3 {
|
||||
position: relative;
|
||||
@@ -124,12 +128,6 @@ h3 span {
|
||||
/*----------------------------------------*/
|
||||
|
||||
footer {
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
width: calc(100% - 30px);
|
||||
height: 50px;
|
||||
padding-top: 10px;
|
||||
|
||||
text-align: center;
|
||||
color: #909090;
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
error_reporting(E_ALL);
|
||||
error_reporting(E_ALL & ~E_DEPRECATED);
|
||||
ini_set('display_errors', 1);
|
||||
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
+48
-1
@@ -229,6 +229,40 @@ $(document).ready(function() {
|
||||
|
||||
//------------------------------------------
|
||||
|
||||
$('.js-purge').on('click', function(event)
|
||||
{
|
||||
event.preventDefault();
|
||||
|
||||
if (!confirm('Are you sure you want to continue?')) {
|
||||
return;
|
||||
}
|
||||
|
||||
const purgeType = $(this).attr('data-type');
|
||||
const csrfToken = $(this).attr('data-token');
|
||||
|
||||
$.ajax({
|
||||
url: $(this).attr('href'),
|
||||
type: 'POST',
|
||||
data: { type: purgeType, _token: csrfToken },
|
||||
success: function(data)
|
||||
{
|
||||
if (data == '') {
|
||||
alert("Cache could not be purged!");
|
||||
return;
|
||||
}
|
||||
|
||||
const response = JSON.parse(data);
|
||||
if (response.success == false) {
|
||||
console.log(data);
|
||||
alert("Cache could not be purged!");
|
||||
return;
|
||||
}
|
||||
|
||||
alert("Cache has been purged.");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Developer mode
|
||||
$('#development-mode').on('click', function(e)
|
||||
{
|
||||
@@ -238,8 +272,20 @@ $(document).ready(function() {
|
||||
return;
|
||||
}
|
||||
|
||||
$.get('/admin/toggle-development-mode').done(function(data)
|
||||
const dataHref = $(this).attr('data-href');
|
||||
const csrfToken = $(this).attr('data-token');
|
||||
|
||||
$.ajax({
|
||||
url: dataHref,
|
||||
type: 'POST',
|
||||
data: { _token: csrfToken },
|
||||
success: function(data)
|
||||
{
|
||||
if (data == '') {
|
||||
alert("Development mode could not be enabled!");
|
||||
return;
|
||||
}
|
||||
|
||||
const response = JSON.parse(data);
|
||||
if (response.success == false) {
|
||||
console.log(data);
|
||||
@@ -258,6 +304,7 @@ $(document).ready(function() {
|
||||
}
|
||||
|
||||
alert("Development mode has been set to: '" + response.result.value + "'");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -12,6 +12,45 @@ $(document).ready(function() {
|
||||
return elementBottom > viewportTop && elementTop < viewportBottom;
|
||||
}
|
||||
|
||||
//------------------------------------------//
|
||||
// Blog search
|
||||
|
||||
function blogSearch(input)
|
||||
{
|
||||
var url = input.data("url");
|
||||
var search = input.val();
|
||||
window.location.href = url + '?search=' + encodeURIComponent(search);
|
||||
}
|
||||
|
||||
$("#js-blog-search").keydown(function(e) {
|
||||
if (e.key == 'Enter') {
|
||||
e.preventDefault();
|
||||
blogSearch($(this));
|
||||
}
|
||||
});
|
||||
|
||||
$("#js-blog-search-button").click(function() {
|
||||
blogSearch($("#js-blog-search"));
|
||||
});
|
||||
|
||||
$("#js-blog-search").on("input", function() {
|
||||
var url = $(this).data("url");
|
||||
var search = $(this).val();
|
||||
if (search.length == 0 || search.length >= 3) {
|
||||
fetch(url, {
|
||||
method: 'POST',
|
||||
body: 'search=' + encodeURIComponent(search),
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
}
|
||||
})
|
||||
.then(response => response.text())
|
||||
.then(data => {
|
||||
$("#blog-posts").empty().append(data);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
//------------------------------------------//
|
||||
|
||||
// Image hover mouseenter
|
||||
@@ -31,6 +70,12 @@ $(document).ready(function() {
|
||||
$("#img-hover").remove();
|
||||
});
|
||||
|
||||
// Image hover on click
|
||||
$(".js-img-hover").click(function() {
|
||||
var url = $(this).data("img-hover");
|
||||
window.open(url, '_blank');
|
||||
});
|
||||
|
||||
// Lazy load video's
|
||||
$(window).on('resize scroll', function() {
|
||||
$('.js-video').each(function(index) {
|
||||
|
||||
@@ -12,19 +12,22 @@ Router::resource('/admin/media', 'MediaController');
|
||||
|
||||
// Basic routes
|
||||
return [
|
||||
// URL, controller, action, view/title/description
|
||||
['/', 'IndexController', '', ''],
|
||||
['/img/captcha.jpg', 'IndexController', 'captcha', ''],
|
||||
['/robots.txt', 'IndexController', 'robots', ''],
|
||||
['/sitemap.xml', 'IndexController', 'sitemap', ''],
|
||||
// URL, controller, action, [view, title, description]
|
||||
['/', 'IndexController'],
|
||||
['/img/captcha.jpg', 'IndexController', 'captcha'],
|
||||
['/robots.txt', 'IndexController', 'robots'],
|
||||
['/sitemap.xml', 'IndexController', 'sitemap'],
|
||||
['/blog', 'BlogController', 'search'],
|
||||
['/blog.xml', 'BlogController', 'rss'],
|
||||
['/login', 'LoginController', 'login', ['', 'Sign in', '']],
|
||||
['/reset-password', 'LoginController', 'reset', ['', 'Reset password', '']],
|
||||
['/logout', 'LoginController', 'logout', ''],
|
||||
['/admin', 'AdminController', '', ''],
|
||||
['/admin/cache', 'CacheController', 'cache', ''],
|
||||
['/admin/toggle', 'AdminController', 'toggle', ''],
|
||||
['/admin/toggle-development-mode', 'CacheController', 'development', ''],
|
||||
['/admin/syntax-highlighting', 'AdminController', 'syntax', ''],
|
||||
['/logout', 'LoginController', 'logout'],
|
||||
['/admin', 'AdminController'],
|
||||
['/admin/cache', 'CacheController', 'cache'],
|
||||
['/admin/cache/purge', 'CacheController', 'purge'],
|
||||
['/admin/cache/toggle', 'CacheController', 'toggle'],
|
||||
['/admin/toggle', 'AdminController', 'toggle'],
|
||||
['/admin/syntax-highlighting', 'AdminController', 'syntax'],
|
||||
['/test', 'TestController', '', ''],
|
||||
// ["", "", "", ""],
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user