Code Cleanup
This commit is contained in:
Generated
+4
-2
@@ -1,11 +1,13 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<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>
|
<serverData>
|
||||||
<paths name="Hostinger">
|
<paths name="Hostinger">
|
||||||
<serverdata>
|
<serverdata>
|
||||||
<mappings>
|
<mappings>
|
||||||
<mapping local="$PROJECT_DIR$" web="/" />
|
<mapping deploy="/" local="$PROJECT_DIR$" web="/" />
|
||||||
</mappings>
|
</mappings>
|
||||||
</serverdata>
|
</serverdata>
|
||||||
</paths>
|
</paths>
|
||||||
|
|||||||
@@ -4,11 +4,11 @@ require_once "../init.php";
|
|||||||
|
|
||||||
switch ($_REQUEST["action"]) {
|
switch ($_REQUEST["action"]) {
|
||||||
case "save":
|
case "save":
|
||||||
if(!empty($_POST['uri']) && !empty($_POST['content'])) {
|
if (!empty($_POST['uri']) && !empty($_POST['content'])) {
|
||||||
$_SESSION['core']->saveContent($_POST['uri'], $_POST['content']);
|
$_SESSION['core']->saveContent($_POST['uri'], $_POST['content']);
|
||||||
die("Page Updated.");
|
die("Page Updated.");
|
||||||
} else {
|
} else {
|
||||||
die('Unable to save page');
|
die('Unable to save page');
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
};
|
}
|
||||||
+43
-37
@@ -9,17 +9,19 @@ body {
|
|||||||
flex-flow: column;
|
flex-flow: column;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.pageContainer .controls {
|
.pageContainer .controls {
|
||||||
flex: 0 1 auto;
|
flex: 0 1 auto;
|
||||||
height:70px;
|
height: 70px;
|
||||||
background-color:#666666;
|
background-color: #666666;
|
||||||
border-bottom: 1px solid #1a1a1a;
|
border-bottom: 1px solid #1a1a1a;
|
||||||
-webkit-box-shadow: 0px 10px 13px -7px #000000, -1px -1px 15px 5px rgba(0,0,0,0);
|
-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);
|
box-shadow: 0px 10px 13px -7px #000000, -1px -1px 15px 5px rgba(0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
.pageContainer .frame {
|
.pageContainer .frame {
|
||||||
flex: 1 1 auto;
|
flex: 1 1 auto;
|
||||||
border:0;
|
border: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.controls .logo {
|
.controls .logo {
|
||||||
@@ -29,6 +31,7 @@ body {
|
|||||||
display: block;
|
display: block;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
}
|
}
|
||||||
|
|
||||||
.controls .buttonContainer {
|
.controls .buttonContainer {
|
||||||
width: 400px;
|
width: 400px;
|
||||||
margin: 18px auto;
|
margin: 18px auto;
|
||||||
@@ -45,52 +48,55 @@ body {
|
|||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.controls .buttonContainer li {
|
.controls .buttonContainer li {
|
||||||
display: inline;
|
display: inline;
|
||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.blueButton {
|
.blueButton {
|
||||||
box-shadow:inset 0px 0px 15px 3px #23395e;
|
box-shadow: inset 0px 0px 15px 3px #23395e;
|
||||||
background:linear-gradient(to bottom, #2e466e 5%, #415989 100%);
|
background: linear-gradient(to bottom, #2e466e 5%, #415989 100%);
|
||||||
background-color:#2e466e;
|
background-color: #2e466e;
|
||||||
border-radius:17px;
|
border-radius: 17px;
|
||||||
border:1px solid #1f2f47;
|
border: 1px solid #1f2f47;
|
||||||
display:inline-block;
|
display: inline-block;
|
||||||
cursor:pointer;
|
cursor: pointer;
|
||||||
color:#ffffff;
|
color: #ffffff;
|
||||||
font-family:Arial;
|
font-family: Arial;
|
||||||
font-size:15px;
|
font-size: 15px;
|
||||||
padding:6px 13px;
|
padding: 6px 13px;
|
||||||
text-decoration:none;
|
text-decoration: none;
|
||||||
text-shadow:0px 1px 0px #263666;
|
text-shadow: 0px 1px 0px #263666;
|
||||||
}
|
}
|
||||||
|
|
||||||
.blueButton:hover {
|
.blueButton:hover {
|
||||||
background:linear-gradient(to bottom, #415989 5%, #2e466e 100%);
|
background: linear-gradient(to bottom, #415989 5%, #2e466e 100%);
|
||||||
background-color:#415989;
|
background-color: #415989;
|
||||||
}
|
}
|
||||||
|
|
||||||
.greenButton {
|
.greenButton {
|
||||||
box-shadow:inset 0px 0px 15px 3px #3e7327;
|
box-shadow: inset 0px 0px 15px 3px #3e7327;
|
||||||
background:linear-gradient(to bottom, #77b55a 5%, #72b352 100%);
|
background: linear-gradient(to bottom, #77b55a 5%, #72b352 100%);
|
||||||
background-color:#77b55a;
|
background-color: #77b55a;
|
||||||
border-radius:17px;
|
border-radius: 17px;
|
||||||
border:1px solid #4b8f29;
|
border: 1px solid #4b8f29;
|
||||||
display:inline-block;
|
display: inline-block;
|
||||||
cursor:pointer;
|
cursor: pointer;
|
||||||
color:#ffffff;
|
color: #ffffff;
|
||||||
font-family:Arial;
|
font-family: Arial;
|
||||||
font-size:15px;
|
font-size: 15px;
|
||||||
padding:6px 13px;
|
padding: 6px 13px;
|
||||||
text-decoration:none;
|
text-decoration: none;
|
||||||
text-shadow:0px 1px 0px #5b8a3c;
|
text-shadow: 0px 1px 0px #5b8a3c;
|
||||||
}
|
}
|
||||||
|
|
||||||
.greenButton:hover {
|
.greenButton:hover {
|
||||||
background:linear-gradient(to bottom, #72b352 5%, #77b55a 100%);
|
background: linear-gradient(to bottom, #72b352 5%, #77b55a 100%);
|
||||||
background-color:#72b352;
|
background-color: #72b352;
|
||||||
}
|
}
|
||||||
|
|
||||||
.greenButton:active {
|
.greenButton:active {
|
||||||
position:relative;
|
position: relative;
|
||||||
top:1px;
|
top: 1px;
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -37,8 +37,8 @@ require_once "init.php";
|
|||||||
</div>
|
</div>
|
||||||
<iframe id="frameContainer" src="welcome.html" class="frame"></iframe>
|
<iframe id="frameContainer" src="welcome.html" class="frame"></iframe>
|
||||||
</div>
|
</div>
|
||||||
<!-- Modal -->
|
<!-- Modal -->
|
||||||
<div id="editModal" class="modal fade" role="dialog">
|
<div id="editModal" class="modal fade" role="dialog">
|
||||||
<div class="modal-dialog modal-lg">
|
<div class="modal-dialog modal-lg">
|
||||||
|
|
||||||
<!-- Modal content-->
|
<!-- Modal content-->
|
||||||
@@ -56,7 +56,7 @@ require_once "init.php";
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="/cms/js/cms.js"></script>
|
<script src="/cms/js/cms.js"></script>
|
||||||
|
|
||||||
|
|||||||
+14
-12
@@ -4,8 +4,8 @@
|
|||||||
* This will be used as well to write to the audit log once it has been implemented in code.
|
* This will be used as well to write to the audit log once it has been implemented in code.
|
||||||
*/
|
*/
|
||||||
$authentication = [
|
$authentication = [
|
||||||
"admin"=>"password",
|
"admin" => "password",
|
||||||
"editor"=>"password",
|
"editor" => "password",
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -14,23 +14,24 @@ $authentication = [
|
|||||||
session_start();
|
session_start();
|
||||||
require_once "neoCMSCore.php";
|
require_once "neoCMSCore.php";
|
||||||
|
|
||||||
if(empty($_SESSION["core"])) {
|
if (empty($_SESSION["core"])) {
|
||||||
$_SESSION["core"] = new neoCMSCore();
|
$_SESSION["core"] = new neoCMSCore();
|
||||||
$_SESSION["core"]->users=$authentication;
|
$_SESSION["core"]->users = $authentication;
|
||||||
}
|
}
|
||||||
if(!$_SESSION["core"]->isLoggedIn() && stripos($_SERVER['REQUEST_URI'],"/login")===FALSE){
|
if (!$_SESSION["core"]->isLoggedIn() && stripos($_SERVER['REQUEST_URI'], "/login") === FALSE) {
|
||||||
header('Location: /cms/login');
|
header('Location: /cms/login');
|
||||||
die("Redirecting to login..");
|
die("Redirecting to login..");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// str_starts_with compatibility for php 7
|
// str_starts_with compatibility for php 7
|
||||||
if(!function_exists('str_starts_with')) {
|
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
|
//str_starts_with(string $haystack, string $needle): bool
|
||||||
|
|
||||||
$strlen_needle = mb_strlen($needle);
|
$strlen_needle = mb_strlen($needle);
|
||||||
if(mb_substr($haystack,0,$strlen_needle)==$needle) {
|
if (mb_substr($haystack, 0, $strlen_needle) == $needle) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -38,17 +39,18 @@ if(!function_exists('str_starts_with')) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//str_ends_with compatibility for php 7
|
//str_ends_with compatibility for php 7
|
||||||
if(!function_exists('str_ends_with')) {
|
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
|
//str_starts_with(string $haystack, string $needle): bool
|
||||||
|
|
||||||
$strlen_needle = mb_strlen($needle);
|
$strlen_needle = mb_strlen($needle);
|
||||||
if(mb_substr($haystack,-$strlen_needle,$strlen_needle)==$needle) {
|
if (mb_substr($haystack, -$strlen_needle, $strlen_needle) == $needle) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$_SESSION["core"]->version='2.00';
|
$_SESSION["core"]->version = '2.00';
|
||||||
|
|
||||||
|
|||||||
+14
-8
@@ -1,16 +1,16 @@
|
|||||||
$(document).ready(function(){
|
$(document).ready(function () {
|
||||||
|
|
||||||
var currentDiv;
|
var currentDiv;
|
||||||
var iframeDoc;
|
var iframeDoc;
|
||||||
|
|
||||||
$('#frameContainer').on('load', function(){
|
$('#frameContainer').on('load', function () {
|
||||||
|
|
||||||
// Get the iframe document
|
// Get the iframe document
|
||||||
var iframe = document.getElementById('frameContainer');
|
var iframe = document.getElementById('frameContainer');
|
||||||
iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
|
iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
|
||||||
|
|
||||||
// Set up click handler on divs with class 'editable' in the iframe
|
// Set up click handler on divs with class 'editable' in the iframe
|
||||||
$(iframeDoc).find('.editable').css('cursor', 'pointer').click(function(event){
|
$(iframeDoc).find('.editable').css('cursor', 'pointer').click(function (event) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
currentDiv = $(this);
|
currentDiv = $(this);
|
||||||
@@ -37,9 +37,9 @@ $(document).ready(function(){
|
|||||||
automatic_uploads: true,
|
automatic_uploads: true,
|
||||||
images_reuse_filename: false,
|
images_reuse_filename: false,
|
||||||
images_upload_credentials: true,
|
images_upload_credentials: true,
|
||||||
force_br_newlines : false,
|
force_br_newlines: false,
|
||||||
force_p_newlines : false,
|
force_p_newlines: false,
|
||||||
forced_root_block : '',
|
forced_root_block: '',
|
||||||
setup: function (editor) {
|
setup: function (editor) {
|
||||||
editor.on('init', function (e) {
|
editor.on('init', function (e) {
|
||||||
editor.setContent(content);
|
editor.setContent(content);
|
||||||
@@ -51,7 +51,7 @@ $(document).ready(function(){
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#saveBtn').click(function(){
|
$('#saveBtn').click(function () {
|
||||||
// Get the data from TinyMCE
|
// Get the data from TinyMCE
|
||||||
var data = tinymce.get('editor').getContent();
|
var data = tinymce.get('editor').getContent();
|
||||||
|
|
||||||
@@ -70,6 +70,12 @@ $(document).ready(function(){
|
|||||||
});
|
});
|
||||||
|
|
||||||
$('#savePage').click(() => {
|
$('#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)
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
+38
-30
@@ -1,13 +1,25 @@
|
|||||||
<?php
|
<?php
|
||||||
class neoCMSCore {
|
|
||||||
|
|
||||||
public $auditEnabled=true;
|
class neoCMSCore
|
||||||
public $users=[];
|
{
|
||||||
public $loggedIn=false;
|
|
||||||
private $loggedInUser='';
|
|
||||||
public $version='2.0';
|
|
||||||
public function __construct() {
|
|
||||||
|
|
||||||
|
public $auditEnabled = true;
|
||||||
|
public $users = [];
|
||||||
|
public $loggedIn = false;
|
||||||
|
public $version = '2.0';
|
||||||
|
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,41 +27,37 @@ class neoCMSCore {
|
|||||||
* @param $value
|
* @param $value
|
||||||
* @return void
|
* @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);
|
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) {
|
public function isLoggedIn()
|
||||||
$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;
|
return $this->loggedIn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isLoggedIn() {
|
public function getLoggedinUser()
|
||||||
return $this->loggedIn;
|
{
|
||||||
}
|
|
||||||
|
|
||||||
public function getLoggedinUser() {
|
|
||||||
return $this->loggedInUser;
|
return $this->loggedInUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function saveContent($uri,$content) {
|
public function saveContent($uri, $content)
|
||||||
$this->writeAudit("Content for ".$uri." was saved.");
|
{
|
||||||
$uri=str_replace("../","./",$uri);
|
$this->writeAudit("Content for " . $uri . " was saved.");
|
||||||
|
$uri = str_replace("../", "./", $uri);
|
||||||
|
|
||||||
//check to see if we're dealing with a default (index.htm{l}) page
|
//check to see if we're dealing with a default (index.htm{l}) page
|
||||||
if(str_ends_with($uri,"/") || $uri=='/') {
|
if (str_ends_with($uri, "/") || $uri == '/') {
|
||||||
if(file_exists($_SERVER['DOCUMENT_ROOT'].$uri.'index.htm')) {
|
if (file_exists($_SERVER['DOCUMENT_ROOT'] . $uri . 'index.htm')) {
|
||||||
$uri=$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';
|
||||||
$uri=$uri.'/index.html';
|
|
||||||
} else {
|
} else {
|
||||||
die('Unknown default file:'.$uri);
|
die('Unknown default file:' . $uri);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
file_put_contents($_SERVER['DOCUMENT_ROOT'].$uri,$content);
|
file_put_contents($_SERVER['DOCUMENT_ROOT'] . $uri, $content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+4
-4
@@ -3,21 +3,21 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>Welcome to Our Application</title>
|
<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>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<header>
|
<header>
|
||||||
<img src="/cms/img/welcomeLogo.png" alt="Application Logo" class="logo">
|
<img alt="Application Logo" class="logo" src="/cms/img/welcomeLogo.png">
|
||||||
</header>
|
</header>
|
||||||
<main>
|
<main>
|
||||||
<h1>Welcome to NeoCMS</h1>
|
<h1>Welcome to NeoCMS</h1>
|
||||||
<p>Put some content in here</p>
|
<p>Put some content in here</p>
|
||||||
<p class="editable">
|
<p class="editable">
|
||||||
This box is editable!<br />
|
This box is editable!<br/>
|
||||||
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
||||||
Quisque sit amet accumsan tortor. Itaque earum rerum hic tenetur a sapiente delectus.
|
Quisque sit amet accumsan tortor. Itaque earum rerum hic tenetur a sapiente delectus.
|
||||||
</p>
|
</p>
|
||||||
<a href="/" class="button">Get Started with your website</a>
|
<a class="button" href="/">Get Started with your website</a>
|
||||||
</main>
|
</main>
|
||||||
<footer>
|
<footer>
|
||||||
<p>© 2024 Andy Dixon</p>
|
<p>© 2024 Andy Dixon</p>
|
||||||
|
|||||||
+3
-3
@@ -4,8 +4,8 @@
|
|||||||
<title>Iframe Content</title>
|
<title>Iframe Content</title>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="editable">This is editable content 1.</div>
|
<div class="editable">This is editable content 1.</div>
|
||||||
<div class="editable">This is editable content 2.</div>
|
<div class="editable">This is editable content 2.</div>
|
||||||
<div class="editable">This is editable content 3.</div>
|
<div class="editable">This is editable content 3.</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
Reference in New Issue
Block a user