Skip to content
This repository has been archived by the owner on Nov 28, 2023. It is now read-only.

Commit

Permalink
Added some blog features
Browse files Browse the repository at this point in the history
  • Loading branch information
Vilican committed Apr 27, 2019
1 parent f3c7ce8 commit 0de3ce2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
16 changes: 16 additions & 0 deletions core/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ function boxes() {
while($box = $boxes->fetch_assoc()) {
if ($box["access"] == 0 or $box["access"] <= $_SESSION["level"]) {
$box["content"] = str_ireplace("%usermenu%", user_menu(), $box["content"]);
$box["content"] = str_ireplace("%arthistory%", article_history(), $box["content"]);
$box_column .= '<div class="well">'. $box["content"] ."</div>";
}
}
Expand Down Expand Up @@ -113,6 +114,21 @@ function user_menu() {
return $menu;
}

function article_history() {
global $sys, $mysql;

$menu = "<p>Nejnovější články:</p>";
$articles = $mysql->query("SELECT `id`, `location`, `title` FROM `articles` WHERE `approved` = 1 ORDER BY `date` DESC LIMIT 5;");

while ($article = $articles->fetch_assoc()) {

$menu .= '<a href="index.php?p='. $article["location"] .'&id='. $article["id"] .'"><p class="list-group-item-heading">'. $article["title"] .'</p></a>';

}

return $menu;
}

function generate_csrf() {
$string = md5(openssl_random_pseudo_bytes(12));
$_SESSION["csrf"] = $string;
Expand Down
2 changes: 1 addition & 1 deletion logic/article.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
$article = $article->fetch_assoc();

$page["title"] = "Článek: " . $article["title"];
$page["content"] = '<p>Napsal '. id_to_user($article["username"]) .', '. date("j.n.Y G:i", strtotime($article["date"])) .'</p><hr>'. $article["text"];
$page["content"] = '<p>Napsal '. id_to_user($article["author"]) .', '. date("j.n.Y G:i", strtotime($article["date"])) .'</p><hr>'. $article["text"];

} while(0);

0 comments on commit 0de3ce2

Please sign in to comment.