2023-06-17 20:41:31 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
function scan_for_posts() {
|
|
|
|
$s = scandir(__DIR__ . '/../posts/', SCANDIR_SORT_DESCENDING);
|
|
|
|
$output = array();
|
|
|
|
foreach ($s as $f) {
|
|
|
|
if(count(str_split($f)) >= 4)
|
|
|
|
$output[] = $f;
|
|
|
|
}
|
|
|
|
return $output;
|
|
|
|
}
|
|
|
|
|
2023-10-06 14:14:32 +00:00
|
|
|
function generate_post_list($limit = -1, $page = 0) {
|
2023-06-17 20:41:31 +00:00
|
|
|
$events = scan_for_posts();
|
|
|
|
$output = "";
|
|
|
|
if ($limit == -1) {
|
|
|
|
foreach ($events as $event) {
|
|
|
|
$lines = file(__DIR__ . '/../posts/' . $event);
|
|
|
|
$title = $lines[0];
|
|
|
|
$desc = $lines[1];
|
|
|
|
$date = $lines[2];
|
|
|
|
$signatur = $lines[3];
|
|
|
|
$output .= '<div class="eventblock"><h3>'.$signatur.'<br>'.$date.'</h3><a href="?page=blog&id='.str_replace('.md', '', $event).'"><h2>'.$title.'</h2><p>'.$desc.'</p></a></div>';
|
|
|
|
}
|
|
|
|
} else {
|
2023-10-06 14:14:32 +00:00
|
|
|
$start_index = $page * $limit;
|
|
|
|
$end_index = $start_index + $limit;
|
|
|
|
if($end_index > count($events))
|
|
|
|
$end_index = count($events);
|
|
|
|
for ($i = $start_index; $i < $end_index; $i++) {
|
2023-06-17 20:41:31 +00:00
|
|
|
$lines = file(__DIR__ . '/../posts/' . $events[$i]);
|
|
|
|
$title = $lines[0];
|
|
|
|
$desc = $lines[1];
|
|
|
|
$date = $lines[2];
|
|
|
|
$signatur = $lines[3];
|
|
|
|
$output .= '<div class="eventblock"><h3 class="a">'.$signatur.'</h3><h3 class="b">'.$date.'</h3><a href="?page=blog&id='.str_replace('.md', '', $events[$i]).'"><h2>'.$title.'</h2><p>'.$desc.'</p></a></div>';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return $output;
|
|
|
|
}
|
|
|
|
|
|
|
|
function get_post_content($id) {
|
|
|
|
$lines = file(__DIR__ . '/../posts/' . str_replace('.', '', $id) . '.md');
|
|
|
|
$output = "";
|
|
|
|
for ($i = 5; $i < count($lines); $i++)
|
|
|
|
$output .= $lines[$i] . "\n";
|
|
|
|
return $output;
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|