Code Cleanup
This commit is contained in:
Generated
+4
-2
@@ -1,11 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="PublishConfigData" remoteFilesAllowedToDisappearOnAutoupload="false">
|
||||
<component name="PublishConfigData" deleteMissingItems="true" createEmptyFolders="true" remoteFilesAllowedToDisappearOnAutoupload="false" confirmBeforeUploading="false" confirmBeforeDeletion="false">
|
||||
<option name="confirmBeforeDeletion" value="false" />
|
||||
<option name="confirmBeforeUploading" value="false" />
|
||||
<serverData>
|
||||
<paths name="Hostinger">
|
||||
<serverdata>
|
||||
<mappings>
|
||||
<mapping local="$PROJECT_DIR$" web="/" />
|
||||
<mapping deploy="/" local="$PROJECT_DIR$" web="/" />
|
||||
</mappings>
|
||||
</serverdata>
|
||||
</paths>
|
||||
|
||||
@@ -11,4 +11,4 @@ switch ($_REQUEST["action"]) {
|
||||
die('Unable to save page');
|
||||
}
|
||||
break;
|
||||
};
|
||||
}
|
||||
@@ -9,6 +9,7 @@ body {
|
||||
flex-flow: column;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.pageContainer .controls {
|
||||
flex: 0 1 auto;
|
||||
height: 70px;
|
||||
@@ -17,6 +18,7 @@ body {
|
||||
-webkit-box-shadow: 0px 10px 13px -7px #000000, -1px -1px 15px 5px rgba(0, 0, 0, 0);
|
||||
box-shadow: 0px 10px 13px -7px #000000, -1px -1px 15px 5px rgba(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
.pageContainer .frame {
|
||||
flex: 1 1 auto;
|
||||
border: 0;
|
||||
@@ -29,6 +31,7 @@ body {
|
||||
display: block;
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.controls .buttonContainer {
|
||||
width: 400px;
|
||||
margin: 18px auto;
|
||||
@@ -45,6 +48,7 @@ body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.controls .buttonContainer li {
|
||||
display: inline;
|
||||
margin-right: 10px;
|
||||
@@ -86,10 +90,12 @@ body {
|
||||
text-decoration: none;
|
||||
text-shadow: 0px 1px 0px #5b8a3c;
|
||||
}
|
||||
|
||||
.greenButton:hover {
|
||||
background: linear-gradient(to bottom, #72b352 5%, #77b55a 100%);
|
||||
background-color: #72b352;
|
||||
}
|
||||
|
||||
.greenButton:active {
|
||||
position: relative;
|
||||
top: 1px;
|
||||
|
||||
+4
-2
@@ -26,7 +26,8 @@ if(!$_SESSION["core"]->isLoggedIn() && stripos($_SERVER['REQUEST_URI'],"/login")
|
||||
|
||||
// str_starts_with compatibility for php 7
|
||||
if (!function_exists('str_starts_with')) {
|
||||
function str_starts_with($haystack,$needle) {
|
||||
function str_starts_with($haystack, $needle)
|
||||
{
|
||||
//str_starts_with(string $haystack, string $needle): bool
|
||||
|
||||
$strlen_needle = mb_strlen($needle);
|
||||
@@ -39,7 +40,8 @@ if(!function_exists('str_starts_with')) {
|
||||
|
||||
//str_ends_with compatibility for php 7
|
||||
if (!function_exists('str_ends_with')) {
|
||||
function str_ends_with($haystack,$needle) {
|
||||
function str_ends_with($haystack, $needle)
|
||||
{
|
||||
//str_starts_with(string $haystack, string $needle): bool
|
||||
|
||||
$strlen_needle = mb_strlen($needle);
|
||||
|
||||
+7
-1
@@ -70,6 +70,12 @@ $(document).ready(function(){
|
||||
});
|
||||
|
||||
$('#savePage').click(() => {
|
||||
$.post("./controller/",{action:"save",uri:$('#frameContainer').contents().get(0).location.pathname,content:new XMLSerializer().serializeToString($('#frameContainer').contents().get(0))},function(data){alert(data)});
|
||||
$.post("./controller/", {
|
||||
action: "save",
|
||||
uri: $('#frameContainer').contents().get(0).location.pathname,
|
||||
content: new XMLSerializer().serializeToString($('#frameContainer').contents().get(0))
|
||||
}, function (data) {
|
||||
alert(data)
|
||||
});
|
||||
});
|
||||
});
|
||||
+24
-16
@@ -1,13 +1,25 @@
|
||||
<?php
|
||||
class neoCMSCore {
|
||||
|
||||
class neoCMSCore
|
||||
{
|
||||
|
||||
public $auditEnabled = true;
|
||||
public $users = [];
|
||||
public $loggedIn = false;
|
||||
private $loggedInUser='';
|
||||
public $version = '2.0';
|
||||
public function __construct() {
|
||||
private $loggedInUser = '';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function login($username, $password)
|
||||
{
|
||||
$this->loggedIn = (!empty($this->users[$username]) && $this->users[$username] == $password);
|
||||
if ($this->loggedIn) $this->loggedInUser = $username;
|
||||
$this->writeAudit("User login for " . $username . " was " . ($this->loggedIn ? "successful" : "denied due to incorrect credentials") . " from " . $_SERVER['REMOTE_ADDR']);
|
||||
return $this->loggedIn;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -15,27 +27,24 @@ class neoCMSCore {
|
||||
* @param $value
|
||||
* @return void
|
||||
*/
|
||||
public function writeAudit($value) {
|
||||
public function writeAudit($value)
|
||||
{
|
||||
if ($this->auditEnabled)
|
||||
file_put_contents(__DIR__ . "/" . date('y-m-d-') . "audit.txt", date('Y-m-d H:i:s') . "\t" . $this->loggedInUser . "\t" . trim($value) . "\n", FILE_APPEND);
|
||||
}
|
||||
|
||||
public function login($username, $password) {
|
||||
$this->loggedIn=(!empty($this->users[$username]) && $this->users[$username]==$password);
|
||||
if($this->loggedIn) $this->loggedInUser=$username;
|
||||
$this->writeAudit("User login for ".$username." was ".($this->loggedIn?"successful":"denied due to incorrect credentials")." from ".$_SERVER['REMOTE_ADDR']);
|
||||
public function isLoggedIn()
|
||||
{
|
||||
return $this->loggedIn;
|
||||
}
|
||||
|
||||
public function isLoggedIn() {
|
||||
return $this->loggedIn;
|
||||
}
|
||||
|
||||
public function getLoggedinUser() {
|
||||
public function getLoggedinUser()
|
||||
{
|
||||
return $this->loggedInUser;
|
||||
}
|
||||
|
||||
public function saveContent($uri,$content) {
|
||||
public function saveContent($uri, $content)
|
||||
{
|
||||
$this->writeAudit("Content for " . $uri . " was saved.");
|
||||
$uri = str_replace("../", "./", $uri);
|
||||
|
||||
@@ -43,8 +52,7 @@ class neoCMSCore {
|
||||
if (str_ends_with($uri, "/") || $uri == '/') {
|
||||
if (file_exists($_SERVER['DOCUMENT_ROOT'] . $uri . 'index.htm')) {
|
||||
$uri = $uri . '/index.htm';
|
||||
}
|
||||
elseif(file_exists($_SERVER['DOCUMENT_ROOT'].$uri.'index.html')) {
|
||||
} elseif (file_exists($_SERVER['DOCUMENT_ROOT'] . $uri . 'index.html')) {
|
||||
$uri = $uri . '/index.html';
|
||||
} else {
|
||||
die('Unknown default file:' . $uri);
|
||||
|
||||
+3
-3
@@ -3,11 +3,11 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Welcome to Our Application</title>
|
||||
<link rel="stylesheet" href="/cms/css/welcome.style.css">
|
||||
<link href="/cms/css/welcome.style.css" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<img src="/cms/img/welcomeLogo.png" alt="Application Logo" class="logo">
|
||||
<img alt="Application Logo" class="logo" src="/cms/img/welcomeLogo.png">
|
||||
</header>
|
||||
<main>
|
||||
<h1>Welcome to NeoCMS</h1>
|
||||
@@ -17,7 +17,7 @@
|
||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||
Quisque sit amet accumsan tortor. Itaque earum rerum hic tenetur a sapiente delectus.
|
||||
</p>
|
||||
<a href="/" class="button">Get Started with your website</a>
|
||||
<a class="button" href="/">Get Started with your website</a>
|
||||
</main>
|
||||
<footer>
|
||||
<p>© 2024 Andy Dixon</p>
|
||||
|
||||
Reference in New Issue
Block a user