From 206f94f5dbfcd5997397992970305aec3d4e3c2f Mon Sep 17 00:00:00 2001 From: 20xd6 <20xd6@airmail.cc> Date: Wed, 27 Jul 2022 22:11:36 -0400 Subject: [PATCH 1/4] Fix variable being tested for empty file in PR #21 --- blog/by_tag/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blog/by_tag/index.php b/blog/by_tag/index.php index 9966a89..2230a2d 100755 --- a/blog/by_tag/index.php +++ b/blog/by_tag/index.php @@ -5,7 +5,7 @@ echo "

Posts by Tag

"; echo "
"; function read_tags($tags_file){ - if (filesize($tags_vile) == 0){ + if (filesize($tags_file) == 0){ echo "
\n
"; return; } From 5016fa8ce8cec83eef9b44c6e8f8730a1f9313d4 Mon Sep 17 00:00:00 2001 From: 20xd6 <20xd6@airmail.cc> Date: Sun, 31 Jul 2022 17:10:41 -0400 Subject: [PATCH 2/4] Cleanup header.php Cleanup debugging code for issue #10 --- common/php/header.php | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/common/php/header.php b/common/php/header.php index dc7a0cf..8069b2f 100644 --- a/common/php/header.php +++ b/common/php/header.php @@ -2,20 +2,11 @@ Date: Tue, 9 Aug 2022 14:07:40 -0400 Subject: [PATCH 3/4] 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); 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 4/4] 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" . read_md($byline_path) ."
\n"; - } else { - echo "

No byline

"; - echo "

$byline_path

"; } fclose($author_name_raw); }