forked from Adleraci/adlerka.top
Do some maintenance with phpstorm
This commit is contained in:
parent
ec725fd689
commit
02d480d31a
@ -11,9 +11,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
body {
|
body {
|
||||||
background: linear-gradient(127deg, var(--secondary-bg), var(--primary-bg));
|
background: linear-gradient(127deg, var(--secondary-bg), var(--primary-bg)) no-repeat fixed;
|
||||||
background-repeat: no-repeat;
|
|
||||||
background-attachment: fixed;
|
|
||||||
background-size: cover;
|
background-size: cover;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
@ -29,28 +27,9 @@ nav {
|
|||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
padding: 1.2rem 1rem;
|
padding: 1.2rem 1rem;
|
||||||
background-color: rgba(0, 0, 0, 0.2);
|
background-color: rgba(0, 0, 0, 0.2);
|
||||||
-webkit-box-shadow: 0px 20px 28px 0px rgba(0,0,0,0.2);
|
-webkit-box-shadow: 0 20px 28px 0 rgba(0,0,0,0.2);
|
||||||
-moz-box-shadow: 0px 20px 28px 0px rgba(0,0,0,0.2);
|
-moz-box-shadow: 0 20px 28px 0 rgba(0,0,0,0.2);
|
||||||
box-shadow: 0px 20px 28px 0px rgba(0,0,0,0.2);
|
box-shadow: 0 20px 28px 0 rgba(0,0,0,0.2);
|
||||||
}
|
|
||||||
|
|
||||||
nav #login {
|
|
||||||
color: var(--primary-text);
|
|
||||||
text-decoration: none;
|
|
||||||
background-color: #2a9dd6;
|
|
||||||
padding: 0.35rem 0.65rem;
|
|
||||||
transition: all 0.3s ease;
|
|
||||||
border-radius: 15px;
|
|
||||||
}
|
|
||||||
|
|
||||||
nav #login:hover, nav #login.active{
|
|
||||||
transition: all 0.3s ease;
|
|
||||||
background-color: var(--primary-hover);
|
|
||||||
color: var(--primary-text);
|
|
||||||
}
|
|
||||||
|
|
||||||
nav #login:hover::after, nav #login.active::after {
|
|
||||||
width: 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ul {
|
ul {
|
||||||
@ -89,11 +68,6 @@ li a:hover::after {
|
|||||||
width: 85%;
|
width: 85%;
|
||||||
}
|
}
|
||||||
|
|
||||||
li a:hover, li a.active {
|
|
||||||
color: var(--primary);
|
|
||||||
transition: all 0.3s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
.wrapper-404 {
|
.wrapper-404 {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
@ -162,7 +136,6 @@ header hr {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.navpage_list{
|
.navpage_list{
|
||||||
margin-top: 8px;
|
|
||||||
background-color: var(--third-bg);
|
background-color: var(--third-bg);
|
||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
display: flex;
|
display: flex;
|
||||||
@ -178,11 +151,6 @@ header hr {
|
|||||||
border: 4px solid var(--primary-hover) ;
|
border: 4px solid var(--primary-hover) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
a.navpage_link{
|
|
||||||
padding: 0;
|
|
||||||
margin: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
li.navpage_item{
|
li.navpage_item{
|
||||||
padding-left: 20px;
|
padding-left: 20px;
|
||||||
padding-right: 20px;
|
padding-right: 20px;
|
||||||
|
24
index.php
24
index.php
@ -1,11 +1,21 @@
|
|||||||
<?php
|
<?php
|
||||||
require "secrets/config.php";
|
/** @noinspection PhpIncludeInspection */
|
||||||
require "lib/navpages.php";
|
require_once "secrets/config.php";
|
||||||
require "lib/routing.php";
|
require_once "lib/navpages.php";
|
||||||
|
require_once "lib/routing.php";
|
||||||
|
|
||||||
session_set_cookie_params(0, '/', ".$domain.$tld", true, true);
|
$routerConfig = array();
|
||||||
|
$routerRequest = array();
|
||||||
|
|
||||||
|
loadRouterConfig();
|
||||||
|
if(initRouter()) {
|
||||||
|
/** @noinspection PhpArrayIsAlwaysEmptyInspection */
|
||||||
|
session_set_cookie_params(0, '/', "." . $routerRequest["domain"] . "." . $routerRequest["tld"], true, true);
|
||||||
session_start();
|
session_start();
|
||||||
|
/** @noinspection PhpArrayIsAlwaysEmptyInspection */
|
||||||
|
echo getPage($routerRequest["page_name"]);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
echo getPage($routerConfig);
|
|
||||||
|
|
||||||
?>
|
|
@ -19,13 +19,13 @@ function doLogin(){
|
|||||||
$nickname = "";
|
$nickname = "";
|
||||||
$pwdhash = "";
|
$pwdhash = "";
|
||||||
$mcnick = "";
|
$mcnick = "";
|
||||||
$isadmin = false;
|
|
||||||
/* bind variables to prepared statement */
|
/* bind variables to prepared statement */
|
||||||
$stmt->bind_result($idcko, $fname, $lname, $nickname, $pwdhash, $mcnick, $isadmin);
|
$stmt->bind_result($idcko, $fname, $lname, $nickname, $pwdhash, $mcnick, false);
|
||||||
|
|
||||||
$found = false;
|
|
||||||
/* fetch values */
|
/* fetch values */
|
||||||
while ($stmt->fetch()) {
|
$found = false;
|
||||||
|
if($stmt->num_rows() > 0){
|
||||||
|
$stmt->fetch();
|
||||||
if (password_verify($pass, $pwdhash)){
|
if (password_verify($pass, $pwdhash)){
|
||||||
$_SESSION["ID"] = $idcko;
|
$_SESSION["ID"] = $idcko;
|
||||||
$_SESSION["first_name"] = $fname;
|
$_SESSION["first_name"] = $fname;
|
||||||
@ -33,14 +33,9 @@ function doLogin(){
|
|||||||
$_SESSION["nickname"] = $nickname;
|
$_SESSION["nickname"] = $nickname;
|
||||||
$_SESSION["email"] = $email;
|
$_SESSION["email"] = $email;
|
||||||
$_SESSION["mcnick"] = $mcnick;
|
$_SESSION["mcnick"] = $mcnick;
|
||||||
$_SESSION["isadmin"] = $isadmin;
|
$_SESSION["isadmin"] = false;
|
||||||
$found = true;
|
$found = true;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
else{
|
|
||||||
$found = false;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
$stmt->close();
|
$stmt->close();
|
||||||
if($found){
|
if($found){
|
||||||
@ -76,7 +71,7 @@ function doRegister(){
|
|||||||
$password = $_POST["password"];
|
$password = $_POST["password"];
|
||||||
$minecraftNick = $_POST["minecraftnick"];
|
$minecraftNick = $_POST["minecraftnick"];
|
||||||
$activationToken = $_POST["activationtoken"];
|
$activationToken = $_POST["activationtoken"];
|
||||||
if (!empty($firstName) && !empty($lastName) && !empty($nickname) && !empty($email) && !empty($password) && !empty($activationToken)){
|
if (!empty($firstName) && !empty($lastName) && !empty($nickname) && !empty($email) && !empty($password)) {
|
||||||
$passwordHash = password_hash($password, PASSWORD_DEFAULT);
|
$passwordHash = password_hash($password, PASSWORD_DEFAULT);
|
||||||
|
|
||||||
$stmt = $mysqli->prepare("UPDATE Users SET FirstName = ?, LastName = ?, Nickname = ?, Email = ?, PasswordHash = ?, MinecraftNick = ?, isAdmin = 0, isActivated = 1 WHERE isActivated = 0 AND ActivationToken = ?");
|
$stmt = $mysqli->prepare("UPDATE Users SET FirstName = ?, LastName = ?, Nickname = ?, Email = ?, PasswordHash = ?, MinecraftNick = ?, isAdmin = 0, isActivated = 1 WHERE isActivated = 0 AND ActivationToken = ?");
|
||||||
@ -88,6 +83,6 @@ function doRegister(){
|
|||||||
$stmt->close();
|
$stmt->close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
echo json_encode($status);
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -1,44 +1,50 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
function generateNavigation($static_page_dir, $protocol, $subdomain, $domain, $tld, $default_page, $page_name)
|
function generateNavigation()
|
||||||
{
|
{
|
||||||
|
global $routerConfig;
|
||||||
|
global $routerRequest;
|
||||||
|
|
||||||
$navsite_template = '<li class="navsite_item"><a href="__LOCATION__" __CLASS__>__NAME__</a><ul class="navpage_list">__NAVPAGES__</ul></li>';
|
$navsite_template = '<li class="navsite_item"><a href="__LOCATION__" __CLASS__>__NAME__</a><ul class="navpage_list">__NAVPAGES__</ul></li>';
|
||||||
$navpage_template = '<li class="navpage_item"><a href="__LOCATION__" __CLASS__>__NAME__</a></li>';
|
$navpage_template = '<li class="navpage_item"><a href="__LOCATION__" __CLASS__>__NAME__</a></li>';
|
||||||
|
|
||||||
$site_dirs = array_diff(scandir($static_page_dir), array('.', '..'));
|
$site_dirs = array_diff(scandir($routerConfig["static_page_dir"]), array('.', '..'));
|
||||||
|
|
||||||
$nav_out = "";
|
$nav_out = "";
|
||||||
|
|
||||||
foreach ($site_dirs as $site_dir) {
|
foreach ($site_dirs as $site_dir) {
|
||||||
$pages_dir = array_diff(scandir("$static_page_dir$site_dir"), array('.', '..'));
|
$pages_dir = array_diff(scandir($routerConfig["static_page_dir"] . $site_dir), array('.', '..'));
|
||||||
|
|
||||||
$navsite = $navsite_template;
|
$navsite = $navsite_template;
|
||||||
$site_class = "class=\"navsite_link\"";
|
|
||||||
$site_name = str_replace("_", " ", $site_dir);
|
$site_name = str_replace("_", " ", $site_dir);
|
||||||
if ($site_name == "global") {
|
if ($site_name == "global") {
|
||||||
$site_name = "misc";
|
$site_name = "misc";
|
||||||
$site_dir = $default_page;
|
$site_dir = $routerConfig["default_page"];
|
||||||
}
|
}
|
||||||
$site_location = "$protocol$site_dir.$domain.$tld/$default_page";
|
$site_location = $routerRequest["protocol"] . $site_dir . "." . $routerRequest["domain"] . "." . $routerRequest["tld"] . "/" . $routerConfig["default_page"];
|
||||||
$navsite = str_replace("__CLASS__", $site_class, $navsite);
|
|
||||||
$navsite = str_replace("__LOCATION__", $site_location, $navsite);
|
|
||||||
$navsite = str_replace("__NAME__", ucfirst($site_name), $navsite);
|
|
||||||
|
|
||||||
if ($subdomain == $site_dir) {
|
if ($routerRequest["subdomain"] == $site_dir) {
|
||||||
//this is the current page
|
//this is the current page
|
||||||
$site_class = "class=\"navsite_link active\"";
|
$site_class = "class=\"navsite_link active\"";
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
|
$site_class = "class=\"navsite_link\"";
|
||||||
|
}
|
||||||
|
|
||||||
|
$navsite = str_replace("__CLASS__", $site_class, $navsite);
|
||||||
|
$navsite = str_replace("__LOCATION__", $site_location, $navsite);
|
||||||
|
$navsite = str_replace("__NAME__", ucfirst($site_name), $navsite);
|
||||||
|
|
||||||
$navpages = "";
|
$navpages = "";
|
||||||
foreach ($pages_dir as $page_dir) {
|
foreach ($pages_dir as $page_dir) {
|
||||||
$page_dir = explode(".", $page_dir)[0];
|
$page_dir = explode(".", $page_dir)[0];
|
||||||
$navpage = $navpage_template;
|
$navpage = $navpage_template;
|
||||||
$page_class = "class=\"navpage_link\"";
|
$page_class = "class=\"navpage_link\"";
|
||||||
if ($subdomain == $site_dir && $page_name == $page_dir) {
|
if ($routerRequest["subdomain"] == $site_dir && $routerRequest["page_name"] == $page_dir) {
|
||||||
$page_class = "class=\"navpage_link active\"";
|
$page_class = "class=\"navpage_link active\"";
|
||||||
}
|
}
|
||||||
|
|
||||||
$page_location = "$protocol$site_dir.$domain.$tld/$page_dir";
|
$page_location = $routerRequest["protocol"] . $site_dir . "." . $routerRequest["domain"] . "." . $routerRequest["tld"] . "/" . $page_dir;
|
||||||
|
|
||||||
$page_name = str_replace("_", " ", $page_dir);
|
$page_name = str_replace("_", " ", $page_dir);
|
||||||
$page_name = explode(".", $page_name)[0];
|
$page_name = explode(".", $page_name)[0];
|
||||||
@ -55,4 +61,4 @@ function generateNavigation($static_page_dir, $protocol, $subdomain, $domain, $t
|
|||||||
return $nav_out;
|
return $nav_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
||||||
|
@ -1,74 +1,90 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
function getProtocol(){
|
function getProtocol(){
|
||||||
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && !empty($_SERVER['HTTP_X_FORWARDED_PROTO'])) {
|
if (!empty($_SERVER['HTTP_X_FORWARDED_PROTO'])) {
|
||||||
return "https://";
|
return "https://";
|
||||||
} else {
|
} else {
|
||||||
|
/** @noinspection HttpUrlsUsage */
|
||||||
return "http://";
|
return "http://";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPage($routerConfig){
|
function initRouter(){
|
||||||
$default_page = "domov";
|
global $routerRequest;
|
||||||
|
global $routerConfig;
|
||||||
|
|
||||||
$default_site = "home";
|
$routerRequest["protocol"] = getProtocol();
|
||||||
|
$routerRequest["requestAddress"] = array_slice(explode('.', $_SERVER['HTTP_HOST']), -3, 3); //get the last 3 elements
|
||||||
|
|
||||||
$template_dir = "templates/";
|
$needsRedirect = false;
|
||||||
|
|
||||||
$static_page_dir = "pages/";
|
if(count($routerRequest["requestAddress"]) < 3){
|
||||||
|
// Root domain accessed directly
|
||||||
|
$needsRedirect = true;
|
||||||
|
} else {
|
||||||
|
$routerRequest["subdomain"] = basename($routerRequest["requestAddress"][0]);
|
||||||
|
$routerRequest["domain"] = basename($routerRequest["requestAddress"][1]);
|
||||||
|
$routerRequest["tld"] = basename($routerRequest["requestAddress"][2]);
|
||||||
|
|
||||||
$dynamic_page_dir = "dynamic/";
|
$routerRequest["page_name"] = basename($_SERVER["QUERY_STRING"]);
|
||||||
|
|
||||||
$subdomain = basename(explode('.', $_SERVER['HTTP_HOST'])[0]);
|
if (empty($routerRequest["page_name"])){
|
||||||
$domain = basename(explode('.', $_SERVER['HTTP_HOST'])[1]);
|
$needsRedirect = true;
|
||||||
$tld = basename(explode('.', $_SERVER['HTTP_HOST'])[2]);
|
}
|
||||||
$page_name = basename($_SERVER["QUERY_STRING"]);
|
|
||||||
$protocol = getProtocol();
|
|
||||||
|
|
||||||
if (empty($tld)){
|
|
||||||
header("Location: $protocol$default_site.$subdomain.$domain/$default_page");
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($page_name)){
|
if ($needsRedirect) {
|
||||||
header("Location: $protocol$subdomain.$domain.$tld/$default_page");
|
$redirectAddress = implode('.', $routerRequest["requestAddress"]);
|
||||||
return;
|
header("Location: " . $routerRequest["protocol"] . $redirectAddress . "/" . $routerConfig["default_page"]);
|
||||||
|
}
|
||||||
|
return !$needsRedirect;
|
||||||
}
|
}
|
||||||
$page_dir = "pages/";
|
|
||||||
|
|
||||||
$dynamic_page_file = $page_dir . $subdomain . "/" . $page_name . ".php";
|
function renderDynamicPage($page_file)
|
||||||
$page_file = $page_dir . $subdomain . "/" . $page_name . ".html";
|
{
|
||||||
|
require_once $page_file;
|
||||||
|
return render();
|
||||||
|
}
|
||||||
|
|
||||||
$dynamic_page_file_global = $page_dir . "global/" . $page_name . ".php";
|
function getPage($page_name = null){
|
||||||
$page_file_global = $page_dir . "global/" . $page_name . ".html";
|
global $routerConfig;
|
||||||
|
global $routerRequest;
|
||||||
|
|
||||||
$skeleton = file_get_contents($template_dir . "skeleton.html");
|
if(!$page_name){
|
||||||
$nav = file_get_contents($template_dir . "nav.html");
|
$page_name = $routerRequest["page_name"];
|
||||||
|
}
|
||||||
|
|
||||||
|
$dynamic_page_file = $routerRequest["page_dir"] . $routerRequest["subdomain"] . "/" . $page_name . ".php";
|
||||||
|
$page_file = $routerRequest["page_dir"] . $routerRequest["subdomain"] . "/" . $page_name . ".html";
|
||||||
|
|
||||||
|
$dynamic_page_file_global = $routerRequest["page_dir"] . "global/" . $page_name . ".php";
|
||||||
|
$page_file_global = $routerRequest["page_dir"] . "global/" . $page_name . ".html";
|
||||||
|
|
||||||
|
$skeleton = file_get_contents($routerConfig["template_dir"] . "skeleton.html");
|
||||||
|
$nav = file_get_contents($routerConfig["template_dir"] . "nav.html");
|
||||||
|
|
||||||
if (file_exists($dynamic_page_file_global)){
|
if (file_exists($dynamic_page_file_global)){
|
||||||
$page = include_once $dynamic_page_file_global;
|
$page = renderDynamicPage($dynamic_page_file_global);
|
||||||
}
|
}
|
||||||
elseif (file_exists($page_file_global)){
|
elseif (file_exists($page_file_global)){
|
||||||
$page = file_get_contents($page_file_global);
|
$page = file_get_contents($page_file_global);
|
||||||
}
|
}
|
||||||
elseif (file_exists($dynamic_page_file)){
|
elseif (file_exists($dynamic_page_file)){
|
||||||
$page = include_once $dynamic_page_file;
|
$page = renderDynamicPage($dynamic_page_file);
|
||||||
}
|
}
|
||||||
elseif (file_exists($page_file)){
|
elseif (file_exists($page_file)){
|
||||||
$page = file_get_contents($page_file);
|
$page = file_get_contents($page_file);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$page = file_get_contents($template_dir . "404.html");
|
$page = file_get_contents($routerConfig["template_dir"] . "404.html");
|
||||||
}
|
}
|
||||||
$navpages = generateNavigation($static_page_dir, $protocol, $subdomain, $domain, $tld, $default_page, $page_name);
|
$navpages = generateNavigation();
|
||||||
|
|
||||||
$nav = str_replace("__NAV_PAGES__", $navpages, $nav);
|
$nav = str_replace("__NAV_PAGES__", $navpages, $nav);
|
||||||
|
|
||||||
$out = $skeleton;
|
$out = $skeleton;
|
||||||
$out = str_replace("__TEMPLATE__NAV__", $nav, $out);
|
$out = str_replace("__TEMPLATE__NAV__", $nav, $out);
|
||||||
$out = str_replace("__TEMPLATE__PAGE__", $page, $out);
|
$out = str_replace("__TEMPLATE__PAGE__", $page, $out);
|
||||||
$out = str_replace("__TEMPLATE_PAGE_NAME__", $page_name, $out);
|
return str_replace("__TEMPLATE_PAGE_NAME__", $page_name, $out);
|
||||||
return $out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
@ -1,7 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
$template_dir = "templates/";
|
require_once "lib/routing.php";
|
||||||
|
|
||||||
|
function render()
|
||||||
|
{
|
||||||
|
global $routerConfig;
|
||||||
$diddoAjax = true;
|
$diddoAjax = true;
|
||||||
|
|
||||||
switch ($_POST["action"]) {
|
switch ($_POST["action"]) {
|
||||||
@ -20,20 +23,18 @@ switch($_POST["action"]){
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($diddoAjax) {
|
if ($diddoAjax) {
|
||||||
return; // dont use templates on ajax calls
|
exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
||||||
if ($_SESSION["ID"] > 0) {
|
if ($_SESSION["ID"] > 0) {
|
||||||
$account_template = file_get_contents($template_dir . "account.html");
|
$account_template = file_get_contents($routerConfig["template_dir"] . "account.html");
|
||||||
echo $account_template;
|
echo $account_template;
|
||||||
}
|
} else {
|
||||||
else{
|
$login_template = file_get_contents($routerConfig["template_dir"] . "login.html");
|
||||||
$login_template = file_get_contents($template_dir . "login.html");
|
|
||||||
echo $login_template;
|
echo $login_template;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ob_get_clean();
|
return ob_get_clean();
|
||||||
|
}
|
||||||
?>
|
|
@ -1,5 +1,7 @@
|
|||||||
<form method="post">
|
<form method="post">
|
||||||
<input type="email" name="email">
|
<label for="login_email">Email:</label><br>
|
||||||
<input type="password" name="password">
|
<input id="login_email" type="email" name="email"><br>
|
||||||
|
<label for="login_password">Password</label><br>
|
||||||
|
<input id="login_password" type="password" name="password"><br>
|
||||||
<input type="submit">
|
<input type="submit">
|
||||||
</form>
|
</form>
|
@ -1,5 +1,5 @@
|
|||||||
<nav>
|
<nav>
|
||||||
<div class="logo"><img class="standard-logo" src="http://www.adlerka.sk/wp-content/uploads/2021/09/Logo_text_Adlerka_modro_cerveno_biele-e1652431356820.png" title="Adlerka"></div>
|
<div class="logo"><img alt="Adlerka logo" class="standard-logo" src="https://www.adlerka.sk/wp-content/uploads/2021/09/Logo_text_Adlerka_modro_cerveno_biele-e1652431356820.png" title="Adlerka"></div>
|
||||||
<ul class="navsite_list">
|
<ul class="navsite_list">
|
||||||
__NAV_PAGES__
|
__NAV_PAGES__
|
||||||
</ul>
|
</ul>
|
||||||
|
Loading…
Reference in New Issue
Block a user