48 lines
1.6 KiB
PHP
48 lines
1.6 KiB
PHP
|
<?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;
|
||
|
}
|
||
|
|
||
|
function generate_post_list($limit = -1) {
|
||
|
$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 {
|
||
|
if($limit > count($events))
|
||
|
$limit = count($events);
|
||
|
for ($i = 0; $i < $limit; $i++) {
|
||
|
$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;
|
||
|
}
|
||
|
|
||
|
?>
|