From 5d7b4cc121f9fba3c7731feabb6600b36bdd0561 Mon Sep 17 00:00:00 2001 From: 20xd6 <20xd6@airmail.cc> Date: Tue, 9 Aug 2022 14:07:40 -0400 Subject: [PATCH] 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. --- common/php/article.php | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/common/php/article.php b/common/php/article.php index cf7ca4c..b2f3fdd 100644 --- a/common/php/article.php +++ b/common/php/article.php @@ -22,20 +22,20 @@ echo "\n\n"; echo("\n"); - if (file_exists('author')){ - $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 "
\n" - . read_md($byline_path) - ."
\n"; - } else { - echo "

No byline

"; - echo "

$byline_path

"; - } - fclose($author_name_raw); + 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 "
\n" + . read_md($byline_path) + ."
\n"; + } else { + echo "

No byline

"; + echo "

$byline_path

"; + } + fclose($author_name_raw); } if ($tag_data != NULL){ $page_tags = str_getcsv($tag_data);