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 1/2] 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"; - } else { - 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"; + } else { + echo "$byline_path
"; + } + fclose($author_name_raw); } if ($tag_data != NULL){ $page_tags = str_getcsv($tag_data); From 470773721a7160e198a140e699655902e012be35 Mon Sep 17 00:00:00 2001 From: 20xd6 <20xd6@airmail.cc> Date: Tue, 9 Aug 2022 14:10:44 -0400 Subject: [PATCH 2/2] Stop parsing if the author isn't found --- common/php/article.php | 3 --- 1 file changed, 3 deletions(-) diff --git a/common/php/article.php b/common/php/article.php index b2f3fdd..050fb85 100644 --- a/common/php/article.php +++ b/common/php/article.php @@ -31,9 +31,6 @@ echo " \n"; - } else { - echo "$byline_path
"; } fclose($author_name_raw); }