simple_blog/common/php/article.php
20xd6 5d7b4cc121 Add a size check before attempting to parse the author
The author file is now checked to insure it's non-zero before attempting
to parse it for the author who's byline will be displayed at the bottom
of the post.
2022-08-09 14:07:40 -04:00

51 lines
2.2 KiB
PHP

<?php
include_once ($_SERVER['DOCUMENT_ROOT'].'/common/php/md_read.php');
echo "<article id=\"article\">\n" . /* Adds the option to change the font size of the article text. */
"<div id=\"font_btns\">
Text Size:
<button id=\"btn_sml\" type=\"button\" onclick=\"font_set('small')\">a</button>
<button id=\"btn_mid\" type=\"button\" onclick=\"font_set('medium')\">A</button>
<button id=\"btn_lrg\" type=\"button\" onclick=\"font_set('25px')\">A</button>
</div><!--End of font_btns-->
<input type=\"button\" onclick=\"printDiv('print-content')\" title=\"Print this article\" value=\"Print\"/>
<div id=\"print-content\">\n
<nav class=\"jmenu\">
<label for=\"menu-btn\" class=\"jm-menu-btn\">Download</label>
<input type=\"checkbox\" id=\"menu-btn\" class=\"jm-menu-btn\"/>
<ul class=\"jm-collapse\">
</ul>
<li><a>PDF</a></li>
<li><a href=\"article.md\" title=\"Download \">MD</a></li>
</nav>
".
read_md("article.md") . "\n</article>";
echo "\n</div><!--End of print-content div-->\n";
echo("<nav class=\"jmenu\"><div class=\"pmenu\"><ul id=\"back_btn\"><li><a href='..'>Back</a></li></ul></div></nav>\n");
if (file_exists('author') && (filesize('author') != 0)){
$author_name_raw = fopen('author', 'r');
$author_name = fread($author_name_raw, filesize('author'));
$author_name = str_replace("\n", "", $author_name);
$byline_path = $_SERVER['DOCUMENT_ROOT'].'blog/authors/'.$author_name.'/byline.md';
if (file_exists($byline_path)){
echo "<div class =\"byline\">\n"
. read_md($byline_path)
."</div><!--End byline div-->\n";
} else {
echo "<h2>No byline</h2>";
echo "<p>$byline_path</p>";
}
fclose($author_name_raw);
}
if ($tag_data != NULL){
$page_tags = str_getcsv($tag_data);
natcasesort($page_tags);
echo "<div id=\"tags\"><h2>Tags</h2>\n<ul>\n";
foreach ($page_tags as $tag){
echo "<li><a href=\"/blog/by_tag/#" . $tag . "\">" . $tag . "</a></li>\n";
}
echo "</ul>\n</div>\n";
}
include_once ($_SERVER['DOCUMENT_ROOT'].'/common/php/modal.php');
?>