From b321abbdb98e6ad18eb827478a25709a7ea95832 Mon Sep 17 00:00:00 2001 From: phl0 Date: Tue, 11 Oct 2022 09:16:06 +0200 Subject: [PATCH 1/2] Allow for skipping (non mandatory) ADIF headers --- application/libraries/Adif_parser.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/application/libraries/Adif_parser.php b/application/libraries/Adif_parser.php index 968d19f4..8b6f4cec 100644 --- a/application/libraries/Adif_parser.php +++ b/application/libraries/Adif_parser.php @@ -27,12 +27,13 @@ class ADIF_Parser public function initialize() //this function locates the { - $pos = mb_stripos(mb_strtoupper($this->data, "UTF-8"), "", 0, "UTF-8"); + $pos = mb_stripos(mb_strtoupper($this->data, "UTF-8"), "", 0, "UTF-8"); if($pos == false) //did we find the end of headers? { - echo "Error: Adif_Parser Already Initialized or No in ADIF File"; - return 0; + // Just skip if we did not find (optional) headers + $pos = 0; + goto noheaders; }; //get headers @@ -102,8 +103,12 @@ class ADIF_Parser $this->i++; }; + $this->i = $pos+5; //iterate past the + + // Skip to here in case we did not find headers + noheaders: if($this->i >= mb_strlen($this->data, "UTF-8")) //is this the end of the file? { echo "Error: ADIF File Does Not Contain Any QSOs"; @@ -208,4 +213,4 @@ class ADIF_Parser } } -?> \ No newline at end of file +?> From bdda911db26a114688ccf4ca34c3ea4094f6b23b Mon Sep 17 00:00:00 2001 From: phl0 Date: Tue, 11 Oct 2022 09:20:12 +0200 Subject: [PATCH 2/2] Fix indent --- application/libraries/Adif_parser.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/libraries/Adif_parser.php b/application/libraries/Adif_parser.php index 8b6f4cec..7368f7c5 100644 --- a/application/libraries/Adif_parser.php +++ b/application/libraries/Adif_parser.php @@ -32,7 +32,7 @@ class ADIF_Parser if($pos == false) //did we find the end of headers? { // Just skip if we did not find (optional) headers - $pos = 0; + $pos = 0; goto noheaders; };