This repository has been archived on 2022-02-10. You can view files and clone it, but cannot push or open issues or pull requests.
rangitaki/rcc/res/get_posts.php
mmk2410 6e6e26ad26 Delete Posts
Edit Posts
Back to blog
2015-12-06 15:19:16 +01:00

25 lines
540 B
PHP

<?php
/**
* User: mmk2410
* Date: 12/6/15
*
* Error Codes:
* 901 No blog given as get argument
* 921 No blog with the given name available
*/
$blog = $_GET["blog"];
if (!isset($blog)) {
echo "901";
} else if (!file_exists("./../../blogs/$blog.md")) {
echo "921";
} else {
$posts = array();
$i = 0;
foreach (scandir("./../../articles/$blog/") as $article) {
if (substr($article, -3) == ".md") {
$posts[$i] = $article;
$i++;
}
}
print json_encode($posts);
}