forked from Adleraci/adlerka.top
Merge remote-tracking branch 'origin/main'
This commit is contained in:
commit
287eb99b98
@ -70,6 +70,9 @@ async function handlePageResponse(data) {
|
||||
if (data.Navigation) {
|
||||
navbar.innerHTML = data.Navigation;
|
||||
}
|
||||
if (data.PageTitle) {
|
||||
document.title = data.PageTitle;
|
||||
}
|
||||
|
||||
if (data.Page) {
|
||||
pageArea.innerHTML = data.Page;
|
||||
@ -181,7 +184,7 @@ async function togglearticlecreate(){
|
||||
}
|
||||
|
||||
async function renderarticles(){
|
||||
let template = document.querySelector('template[data-template-name="article"]').content.toString();
|
||||
let template = document.querySelector('template[data-template-name="article"]').innerHTML;
|
||||
let articles = await doAction(
|
||||
"/newsarticle",
|
||||
{
|
||||
@ -193,7 +196,7 @@ async function renderarticles(){
|
||||
);
|
||||
|
||||
let articleout = "";
|
||||
for (const article of articles) {
|
||||
for (const article of articles.Articles) {
|
||||
articleout += template.replace("__TEMPLATE_ARTICLE_TITLE__", article.Title).replace("__TEMPLATE_ARTICLE_AUTHOR__", article.WrittenByName).replace("__TEMPLATE_ARTICLE_DATE__", article.WrittenAt).replace("__TEMPLATE_ARTICLE_BODY__", article.Body)
|
||||
}
|
||||
document.getElementById("articleslist").innerHTML = articleout;
|
||||
@ -213,17 +216,26 @@ async function submitarticle(){
|
||||
"Nastala chyba pri pridávaní článku",
|
||||
false
|
||||
);
|
||||
togglearticlecreate();
|
||||
await togglearticlecreate();
|
||||
}
|
||||
|
||||
async function articleInit(){
|
||||
let articleContainerElement = document.getElementById("articlecreatecontainer");
|
||||
let articleCreateOpenElement = document.getElementById("articlecreateopen");
|
||||
articleContainerElement.addEventListener("keyup", function (ev) {
|
||||
if(ev.which === 27){
|
||||
if(ev.key === "Escape"){
|
||||
togglearticlecreate();
|
||||
}
|
||||
})
|
||||
PageIntervals.push(setInterval(renderarticles, 300000));
|
||||
document.getElementById("articleprivilegeinput").setAttribute("max", UserInfo.Privileges);
|
||||
if(UserInfo.Privileges < 2){
|
||||
articleContainerElement.style.display = "none";
|
||||
articleCreateOpenElement.style.display = "none";
|
||||
}
|
||||
else{
|
||||
articleCreateOpenElement.style.display = "inline-block";
|
||||
}
|
||||
}
|
||||
|
||||
async function onPageLoad() {
|
||||
@ -247,7 +259,7 @@ async function onPageLoad() {
|
||||
if (currentSite === "home" && currentPage === "account" && isLoggedIn()) {
|
||||
await showDashboardGreeting();
|
||||
}
|
||||
if (currentSite === "news" && currentPage === "index" && isLoggedIn()) {
|
||||
if (currentSite === "news" && currentPage === "index") {
|
||||
await articleInit();
|
||||
}
|
||||
}
|
||||
|
@ -342,11 +342,22 @@ header a,
|
||||
input, textarea {
|
||||
background-color: var(--third-bg);
|
||||
border: 2px solid var(--primary);
|
||||
border-radius: 50px;
|
||||
}
|
||||
|
||||
input::placeholder, textarea::placeholder{
|
||||
color: var(--primary-text);
|
||||
}
|
||||
|
||||
input{
|
||||
border-radius: 25px;
|
||||
}
|
||||
|
||||
textarea{
|
||||
border-radius: 10px;
|
||||
}
|
||||
|
||||
button {
|
||||
border-radius: 50px;
|
||||
border-radius: 25px;
|
||||
border: 2px solid var(--primary);
|
||||
background: var(--third-bg);
|
||||
color: var(--primary-text);
|
||||
@ -368,14 +379,12 @@ button:hover {
|
||||
}
|
||||
|
||||
header.ye-span:hover + body{
|
||||
background: url('/assets/images/ye.jpg') !important;
|
||||
background-repeat: repeat !important;
|
||||
background: url('/assets/images/ye.jpg') repeat !important;
|
||||
background-size: 10% !important;
|
||||
}
|
||||
|
||||
body:has(.ye-span:hover) {
|
||||
background: url('/assets/images/ye.jpg') !important;
|
||||
background-repeat: repeat !important;
|
||||
background: url('/assets/images/ye.jpg') repeat !important;
|
||||
background-size: 10% !important;
|
||||
}
|
||||
|
||||
@ -384,6 +393,17 @@ body:has(.ye-span:hover) {
|
||||
border: 5px solid var(--primary);
|
||||
z-index: 5;
|
||||
margin: auto;
|
||||
padding: 40px;
|
||||
background-color: var(--primary-bg);
|
||||
border-radius: 50px;
|
||||
}
|
||||
|
||||
#articlecreate > * {
|
||||
margin: 10px 0;
|
||||
}
|
||||
|
||||
#articlecreateopen {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#articlecreatecontainer{
|
||||
@ -399,6 +419,30 @@ body:has(.ye-span:hover) {
|
||||
backdrop-filter: blur(2px);
|
||||
}
|
||||
|
||||
|
||||
.hidden {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
div#articleslist{
|
||||
width: 80vw;
|
||||
left: 10vw;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
div#articleslist > article > div.articleinfo > *{
|
||||
width: fit-content;
|
||||
}
|
||||
|
||||
div#articleslist > article > div.articleinfo{
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
}
|
||||
|
||||
div#articleslist>article{
|
||||
border: 4px solid var(--primary);
|
||||
}
|
||||
|
||||
a.navsite_link.active:after{
|
||||
|
||||
}
|
@ -89,11 +89,10 @@ function verifyPassword($userID, $password): bool
|
||||
function UpdateSession(): void
|
||||
{
|
||||
global $mysqli;
|
||||
$stmt = $mysqli->prepare("SELECT ID, FirstName, LastName, Nickname, Email, MinecraftNick, PrivilegeLevel, LastLoginAt, LoginCount, ClassID, FavoriteColor FROM Users WHERE ID = ? AND isActivated = 1");
|
||||
$stmt = $mysqli->prepare("SELECT FirstName, LastName, Nickname, Email, MinecraftNick, PrivilegeLevel, LastLoginAt, LoginCount, ClassID, FavoriteColor FROM Users WHERE ID = ? AND isActivated = 1");
|
||||
$stmt->bind_param("i", $_SESSION["ID"]);
|
||||
$stmt->execute();
|
||||
|
||||
$id = 0;
|
||||
$first_name = "";
|
||||
$last_name = "";
|
||||
$nickname = "";
|
||||
@ -104,11 +103,9 @@ function UpdateSession(): void
|
||||
$favorite_color = 0;
|
||||
$lastLoginAt = null;
|
||||
$loginCount = 0;
|
||||
$stmt->bind_result($id, $first_name, $last_name, $nickname, $email, $minecraft_nickname, $privilege_level, $lastLoginAt, $loginCount, $class_id, $favorite_color);
|
||||
$stmt->bind_result($first_name, $last_name, $nickname, $email, $minecraft_nickname, $privilege_level, $lastLoginAt, $loginCount, $class_id, $favorite_color);
|
||||
$stmt->fetch();
|
||||
$stmt->close();
|
||||
|
||||
$_SESSION["id"] = $id;
|
||||
$_SESSION["first_name"] = $first_name;
|
||||
$_SESSION["last_name"] = $last_name;
|
||||
$_SESSION["nickname"] = $nickname;
|
||||
|
@ -12,6 +12,7 @@
|
||||
'endpoint_dir' => 'endpoints/',
|
||||
'page_dir' => 'pages/',
|
||||
'protocol' => 'https://',
|
||||
'site_prefix' => 'Adlerka',
|
||||
'permissions' => [
|
||||
'logged_out' => 1,
|
||||
'logged_in_default' => 2,
|
||||
@ -26,6 +27,9 @@
|
||||
'default_permissions' => 255,
|
||||
|
||||
],
|
||||
'newsarticle' => [
|
||||
'default_permissions' => 255,
|
||||
],
|
||||
'seo' => [
|
||||
'author' => 'Tím AdlerkaTop',
|
||||
'description' => 'Toto je neoficiánla študentská stránka pre Adlerku, kde môžete nájsť plno zaujímavostí.',
|
||||
|
@ -27,7 +27,7 @@ function inlineLocalStylesFromHref($inputString): string
|
||||
// Minify the CSS content
|
||||
$cssContent = minifyCss($cssContent);
|
||||
|
||||
return "<style>{$cssContent}</style>";
|
||||
return "<style>$cssContent</style>";
|
||||
}, $inputString);
|
||||
}
|
||||
|
||||
@ -41,7 +41,7 @@ function inlineScriptFromSrc($inputString): string
|
||||
|
||||
// Minify the JavaScript content
|
||||
$jsContent = minifyJs($jsContent);
|
||||
return "<script>{$jsContent}</script>";
|
||||
return "<script>$jsContent</script>";
|
||||
}, $inputString);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
<?php
|
||||
|
||||
function getNewsArticles() :array
|
||||
{
|
||||
global $mysqli;
|
||||
@ -7,9 +6,7 @@ function getNewsArticles() :array
|
||||
$output = ["Status" => "Fail"]; // Default Status is "Fail"
|
||||
|
||||
$articles = [];
|
||||
if (isLoggedIn()) {
|
||||
$stmt = $mysqli->prepare("SELECT NewsArticles.ID, NewsArticles.WrittenAt, NewsArticles.WrittenBy, NewsArticles.Title, NewsArticles.Body, NewsArticles.FileList, Users.Nickname FROM NewsArticles INNER JOIN Users ON NewsArticles.WrittenBy = Users.ID; ");
|
||||
|
||||
$stmt = $mysqli->prepare("SELECT NewsArticles.ID, NewsArticles.WrittenAt, NewsArticles.WrittenBy, NewsArticles.Title, NewsArticles.Body, NewsArticles.FileList, Users.Nickname FROM NewsArticles INNER JOIN Users ON NewsArticles.WrittenBy = Users.ID WHERE NewsArticles.PrivilegeLevel <= ?;");
|
||||
$id = 0;
|
||||
$writtenAt = "";
|
||||
$writtenBy = 0;
|
||||
@ -18,6 +15,7 @@ function getNewsArticles() :array
|
||||
$filelist = 0;
|
||||
$writtenByName = "";
|
||||
|
||||
$stmt->bind_param("i", $_SESSION["privilege_level"]);
|
||||
$stmt->bind_result($id, $writtenAt, $writtenBy, $title, $body, $filelist, $writtenByName);
|
||||
|
||||
$stmt->execute();
|
||||
@ -38,24 +36,29 @@ function getNewsArticles() :array
|
||||
$output["Articles"] = $articles;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
function addNewsArticle($title="Nazov", $body="Obsah") :array
|
||||
function addNewsArticle($title="Nazov", $body="Obsah", $privilegeLevel=0) :array
|
||||
{
|
||||
global $mysqli;
|
||||
global $routerConfig;
|
||||
|
||||
|
||||
if ($privilegeLevel == 0){
|
||||
$privilegeLevel = $routerConfig['newsarticle']['default_permissions'];
|
||||
}
|
||||
|
||||
$output = ["Status" => "Fail"]; // Default Status is "Fail"
|
||||
if (isLoggedIn()) {
|
||||
$query = $mysqli->prepare("INSERT INTO NewsArticles (WrittenBy, Title, Body, FileList) VALUES (?, ?, ?, 0);");
|
||||
$query->bind_param("iss", $_SESSION["id"], htmlspecialchars($title), htmlspecialchars($body));
|
||||
if (isLoggedIn() && $privilegeLevel <= $_SESSION["privilege_level"]) {
|
||||
$query = $mysqli->prepare("INSERT INTO NewsArticles (WrittenBy, Title, Body, FileList, PrivilegeLevel) VALUES (?, ?, ?, 0, ?);");
|
||||
$minpriv = intval($privilegeLevel);
|
||||
$query->bind_param("issi", $_SESSION["ID"], htmlspecialchars($title), htmlspecialchars($body), $minpriv);
|
||||
$query->execute();
|
||||
if ($query->affected_rows > 0) {
|
||||
$output["Status"] = "Success";
|
||||
}
|
||||
$query->close();
|
||||
}
|
||||
$query->close();
|
||||
return $output;
|
||||
}
|
23
lib/page.php
23
lib/page.php
@ -40,6 +40,10 @@ function renderPage($page_name = null, $site_name = null): array
|
||||
$site_name = $routerRequest["site_name"];
|
||||
}
|
||||
|
||||
$site_title = str_replace("_", " ", $site_name);
|
||||
|
||||
$site_title = ucfirst($site_title);
|
||||
|
||||
if(!$page_name){
|
||||
$page_name = $routerRequest["page_name"];
|
||||
}
|
||||
@ -109,10 +113,20 @@ function renderPage($page_name = null, $site_name = null): array
|
||||
$page = "";
|
||||
}
|
||||
|
||||
if(!empty($pageMetadata["parameters"]["page_title"])){
|
||||
$page_title = $pageMetadata["parameters"]["page_title"];
|
||||
}
|
||||
else{
|
||||
$page_title = $page_name;
|
||||
}
|
||||
|
||||
$page_title = $routerConfig['site_prefix'] . " " . $site_title . " " . $page_title;
|
||||
|
||||
return [
|
||||
"PageContent" => $page,
|
||||
"PageName" => $page_name,
|
||||
"SiteName" => $site_name,
|
||||
"PageTitle" => $page_title,
|
||||
];
|
||||
|
||||
}
|
||||
@ -130,12 +144,7 @@ function getPage($site_name_in = null, $page_name_in = null): string
|
||||
|
||||
$footer = file_get_contents($routerConfig["template_dir"] . "footer.html");
|
||||
|
||||
if(!empty($pageMetadata["parameters"]["page_title"])){
|
||||
$page_title = $pageMetadata["parameters"]["page_title"];
|
||||
}
|
||||
else{
|
||||
$page_title = $page_name;
|
||||
}
|
||||
$page_title = $page_tmp["PageTitle"];
|
||||
$dynamic_style = doDynamicStyling();
|
||||
$dynamic_script_data = [
|
||||
"currentPage" => $page_name,
|
||||
@ -143,6 +152,7 @@ function getPage($site_name_in = null, $page_name_in = null): string
|
||||
"currentTitle" => $page_title,
|
||||
"defaultPage" => $routerConfig["default_page"],
|
||||
"defaultSite" => $routerConfig["default_site"],
|
||||
"UserInfo_Privileges" => $_SESSION["privilege_level"],
|
||||
];
|
||||
if(isLoggedIn()){
|
||||
$dynamic_script_data += [
|
||||
@ -214,5 +224,6 @@ function getPageEndpoint($page_name, $site_name) :array
|
||||
"Status" => "Success",
|
||||
"Page" => $page_tmp["PageContent"],
|
||||
"PageLocation" => $page_location,
|
||||
"PageTitle" => $page_tmp["PageTitle"],
|
||||
];
|
||||
}
|
@ -35,7 +35,8 @@ function generateSitemap(): void{
|
||||
$page_required_permission = $routerConfig["page"]["default_permissions"];
|
||||
}
|
||||
} elseif ($page_file_tmp[1] == "php") {
|
||||
$page_required_permission = getDynamicPermission($page_file_path);
|
||||
$pageMetadata = getDynamicMetadata($page_file_path);
|
||||
$page_required_permission = getDynamicPermission($pageMetadata);
|
||||
} else {
|
||||
$page_required_permission = $routerConfig["page"]["default_permissions"];
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
<!--suppress HtmlUnknownTag, HtmlUnknownTag -->
|
||||
<page minimal_permission_level="1" secret="no" page_title="Domov"></page>
|
||||
<header>
|
||||
<h1 class="title">Vitaj, na tejto úžasnej stránke</h1>
|
||||
|
@ -1,3 +1,4 @@
|
||||
<!--suppress HtmlUnknownTag, HtmlUnknownTag -->
|
||||
<page minimal_permission_level="1" secret="no" page_title="Memes"></page>
|
||||
<header>
|
||||
<h1 class="title">Adlerka Memes</h1>
|
||||
|
@ -15,13 +15,14 @@ if($articles_tmp['Status'] == "Success"){
|
||||
}
|
||||
|
||||
$articleTemplate = file_get_contents($routerConfig["template_dir"] . "newsArticle.html");
|
||||
$output = str_replace("__TEMPLATE_FOR_ARTICLE_CONTENT__", $articleTemplate, $output);
|
||||
foreach ($articles as $article){
|
||||
$articleTitle = htmlspecialchars($article["Title"]);
|
||||
$articleBody = htmlspecialchars($article["Body"]);
|
||||
$articleFileList = $article["FileList"];
|
||||
$articleWrittenBy = $article["WrittenBy"];
|
||||
$articleWrittenAt = htmlspecialchars($article["WrittenAt"]);
|
||||
$articleWrittenByName = htmlspecialchars($article["Nickname"]);
|
||||
$articleWrittenByName = htmlspecialchars($article["WrittenByName"]);
|
||||
|
||||
$articleTemplate = str_replace("__TEMPLATE_ARTICLE_TITLE__", $articleTitle, $articleTemplate);
|
||||
$articleTemplate = str_replace("__TEMPLATE_ARTICLE_AUTHOR__", $articleWrittenByName, $articleTemplate);
|
||||
@ -31,14 +32,13 @@ foreach ($articles as $article){
|
||||
$articles_out .= $articleTemplate;
|
||||
}
|
||||
|
||||
$output = str_replace("__TEMPLATE_FOR_ARTICLE_CONTENT__", $articleTemplate, $output);
|
||||
$output = str_replace("__TEMPLATE__ARTICLES_HERE__", $articles_out, $output);
|
||||
|
||||
return [
|
||||
"output" => $output,
|
||||
"parameters" =>
|
||||
[
|
||||
"minimal_permission_level" => 2,
|
||||
"minimal_permission_level" => 1,
|
||||
"secret" => "no",
|
||||
"page_title" => "Novinky"
|
||||
]
|
||||
|
@ -1,3 +1,4 @@
|
||||
<!--suppress HtmlUnknownTag, HtmlUnknownTag -->
|
||||
<page minimal_permission_level="2" secret="no" page_title="Zošit"></page>
|
||||
<header>
|
||||
<h1 class="title">Adlerka Zošit</h1>
|
||||
|
@ -1,3 +1,4 @@
|
||||
<!--suppress HtmlUnknownTag, HtmlUnknownTag -->
|
||||
<page minimal_permission_level="1" secret="no" page_title="Domov"></page>
|
||||
<header>
|
||||
<h1 class="title">Vitaj na oficiálnej AdlerkaSMP stránke</h1>
|
||||
|
@ -1,2 +1,3 @@
|
||||
<page minimal_permission_level="1" secret="no" page_title="AdlerkaSMP info"></page>
|
||||
<!--suppress HtmlUnknownTag, HtmlUnknownTag -->
|
||||
<page minimal_permission_level="1" secret="no" page_title="Info"></page>
|
||||
<h1>Vitaj na oficiálnej stránke Informácii o AdlerkaSMP</h1>
|
@ -1,8 +1,9 @@
|
||||
<article>
|
||||
<h2 class='newstitle'>__TEMPLATE_ARTICLE_TITLE__</h2>
|
||||
<br>
|
||||
<p class='newsauthor'>__TEMPLATE_ARTICLE_AUTHOR__</p>
|
||||
<p class='newsdate'>__TEMPLATE_ARTICLE_DATE__</p>
|
||||
<div class="articleinfo">
|
||||
<p class='newsauthor'><i class="ri-user-line"></i>__TEMPLATE_ARTICLE_AUTHOR__</p>
|
||||
<p class='newsdate'><i class="ri-calendar-line"></i>__TEMPLATE_ARTICLE_DATE__</p>
|
||||
</div>
|
||||
<hr>
|
||||
<div class='newsbody'>
|
||||
__TEMPLATE_ARTICLE_BODY__
|
||||
|
@ -17,6 +17,7 @@
|
||||
<div id="articlecreate">
|
||||
<input type="text" placeholder="Article Title" id="articletitleinput"><br>
|
||||
<textarea id="articlebodyinput" placeholder="Article Body" rows="20" cols="80"></textarea><br>
|
||||
<input type="number" id="articleprivilegeinput" min="1" value="1" step="1"><br>
|
||||
<button id="articlesubmit" onclick="submitarticle()">Add</button>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -10,7 +10,7 @@
|
||||
__TEMPLATE__DYNAMIC__STYLE__
|
||||
<script async src="https://umami.brn.systems/script.js" data-website-id="95e93885-5c19-4cab-ba9b-2f746a316a2a"></script>
|
||||
<script async src="/assets/script.js"></script>
|
||||
<title>Adlerka __TEMPLATE_PAGE_TITLE__</title>
|
||||
<title>__TEMPLATE_PAGE_TITLE__</title>
|
||||
__TEMPLATE_SEO_STUFF__
|
||||
</head>
|
||||
<body>
|
||||
|
Loading…
Reference in New Issue
Block a user