From c6c7dd5cd80377acac5d41fb945416e85d06abc5 Mon Sep 17 00:00:00 2001 From: Peter Goodhall Date: Mon, 7 Dec 2020 19:41:55 +0000 Subject: [PATCH] Revert "Merge pull request #725 from AndreasK79/adif_import_speedup" This reverts commit 62b8d024b6dd753e9485a865098f0da98b5a0f78, reversing changes made to b18777318de04b1675d9b41b56996ed1a897fe87. --- application/libraries/Adif_parser.php | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/application/libraries/Adif_parser.php b/application/libraries/Adif_parser.php index 4725e10a..fbf99f1b 100644 --- a/application/libraries/Adif_parser.php +++ b/application/libraries/Adif_parser.php @@ -19,11 +19,10 @@ class ADIF_Parser { var $data; //the adif data - var $datasplit; // one line is one QSO in the array - var $currentarray = 0; // current place in the array var $i; //the iterator + var $current_line; //stores information about the current qso var $headers = array(); - + public function initialize() //this function locates the { @@ -109,8 +108,6 @@ class ADIF_Parser echo "Error: ADIF File Does Not Contain Any QSOs"; return 0; }; - - $this->datasplit = preg_split("//i", substr($this->data, $this->i)); return 1; } @@ -179,15 +176,23 @@ class ADIF_Parser }; return $return; } - + + //finds the next record in the file public function get_record() { - if($this->currentarray >= count($this->datasplit)) + if($this->i >= strlen($this->data)) { return array(); //return nothing }; - return $this->record_to_array($this->datasplit[$this->currentarray++]); //process and return output + $end = stripos($this->data, "", $this->i); + if($end == false) //is this the end? + { + return array(); //return nothing + }; + $record = substr($this->data, $this->i, $end-$this->i); + $this->i = $end+5; + return $this->record_to_array($record); //process and return output } public function get_header($key) @@ -199,6 +204,6 @@ class ADIF_Parser return NULL; } } - + } ?> \ No newline at end of file