Code Cleanup

This commit is contained in:
Andy Dixon
2024-10-03 08:07:53 +01:00
committed by Andy Dixon
parent d161239cf1
commit a1f2d18cf0
9 changed files with 136 additions and 112 deletions
+14 -12
View File
@@ -4,8 +4,8 @@
* This will be used as well to write to the audit log once it has been implemented in code.
*/
$authentication = [
"admin"=>"password",
"editor"=>"password",
"admin" => "password",
"editor" => "password",
];
/**
@@ -14,23 +14,24 @@ $authentication = [
session_start();
require_once "neoCMSCore.php";
if(empty($_SESSION["core"])) {
if (empty($_SESSION["core"])) {
$_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');
die("Redirecting to login..");
}
// str_starts_with compatibility for php 7
if(!function_exists('str_starts_with')) {
function str_starts_with($haystack,$needle) {
if (!function_exists('str_starts_with')) {
function str_starts_with($haystack, $needle)
{
//str_starts_with(string $haystack, string $needle): bool
$strlen_needle = mb_strlen($needle);
if(mb_substr($haystack,0,$strlen_needle)==$needle) {
if (mb_substr($haystack, 0, $strlen_needle) == $needle) {
return true;
}
return false;
@@ -38,17 +39,18 @@ 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) {
if (!function_exists('str_ends_with')) {
function str_ends_with($haystack, $needle)
{
//str_starts_with(string $haystack, string $needle): bool
$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 false;
}
}
$_SESSION["core"]->version='2.00';
$_SESSION["core"]->version = '2.00';