[ADIF import] Import speedup with minor modifications in Adif_parser.
这个提交包含在:
父节点
47e8adda89
当前提交
665050ba6f
共有 1 个文件被更改,包括 9 次插入 和 14 次删除
|
|
@ -19,10 +19,11 @@ class ADIF_Parser
|
||||||
{
|
{
|
||||||
|
|
||||||
var $data; //the adif data
|
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 $i; //the iterator
|
||||||
var $current_line; //stores information about the current qso
|
|
||||||
var $headers = array();
|
var $headers = array();
|
||||||
|
|
||||||
public function initialize() //this function locates the <EOH>
|
public function initialize() //this function locates the <EOH>
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
@ -108,6 +109,8 @@ class ADIF_Parser
|
||||||
echo "Error: ADIF File Does Not Contain Any QSOs";
|
echo "Error: ADIF File Does Not Contain Any QSOs";
|
||||||
return 0;
|
return 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$this->datasplit = preg_split("/<eor>/i", substr($this->data, $this->i));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -176,23 +179,15 @@ class ADIF_Parser
|
||||||
};
|
};
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//finds the next record in the file
|
//finds the next record in the file
|
||||||
public function get_record()
|
public function get_record()
|
||||||
{
|
{
|
||||||
if($this->i >= strlen($this->data))
|
if($this->currentarray >= count($this->datasplit))
|
||||||
{
|
{
|
||||||
return array(); //return nothing
|
return array(); //return nothing
|
||||||
};
|
};
|
||||||
$end = stripos($this->data, "<eor>", $this->i);
|
return $this->record_to_array($this->datasplit[$this->currentarray++]); //process and return output
|
||||||
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)
|
public function get_header($key)
|
||||||
|
|
@ -204,6 +199,6 @@ class ADIF_Parser
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
正在加载…
在新工单中引用