The import is getting closer to completion. Next will work on checking for +/- time_on.

这个提交包含在:
Corby Krick 2013-08-31 09:54:24 -05:00
父节点 d90facf293
当前提交 f1dc093bf6
共有 3 个文件被更改,包括 51 次插入24 次删除

查看文件

@ -38,14 +38,6 @@ class eqsl extends CI_Controller {
};
$time_on = date('Y-m-d', strtotime($record['qso_date'])) ." ".date('H:i', strtotime($record['time_on']));
$qsl_date = date('Y-m-d', strtotime($record['qslrdate'])) ." ".date('H:i', strtotime($record['qslrdate']));
if (isset($record['time_off'])) {
$time_off = date('Y-m-d', strtotime($record['qso_date'])) ." ".date('H:i', strtotime($record['time_off']));
} else {
$time_off = date('Y-m-d', strtotime($record['qso_date'])) ." ".date('H:i', strtotime($record['time_on']));
}
// The report from eQSL should only contain entries that have been confirmed via eQSL
// If there's a match for the QSO from the report in our log, it's confirmed via eQSL.
@ -53,21 +45,32 @@ class eqsl extends CI_Controller {
// If we have a positive match from LoTW, record it in the DB according to the user's preferences
if ($record['qsl_sent'] == "Y")
{
$record['qsl_sent'] = $config['lotw_rcvd_mark'];
$record['qsl_sent'] = $config['eqsl_rcvd_mark'];
}
$status = $this->logbook_model->import_check($time_on, $record['call'], $record['band']);
//////////////////////////////////////////////
$eqsl_status = $this->logbook_model->eqsl_update($time_on, $record['call'], $record['band'], $record['qsl_rcvd']);
if ($status == "Found")
{
$dupe = $this->logbook_model->eqsl_dupe_check($time_on, $record['call'], $record['band'], $config['eqsl_rcvd_mark']);
if ($dupe == false)
{
$eqsl_status = $this->logbook_model->eqsl_update($time_on, $record['call'], $record['band'], $config['eqsl_rcvd_mark']);
}
else
{
$eqsl_status = "Already recived an eQSL for this QSO.";
}
}
else
{
$eqsl_status = "QSO not found";
}
$table .= "<tr>";
$table .= "<td>".$time_on."</td>";
$table .= "<td>".$record['call']."</td>";
$table .= "<td>".$record['mode']."</td>";
$table .= "<td>".$record['qsl_rcvd']."</td>";
$table .= "<td>".$qsl_date."</td>";
$table .= "<td>QSO Record: ".$status."</td>";
$table .= "<td>eQSL Record: ".$lotw_status."</td>";
$table .= "<td>eQSL Record: ".$eqsl_status."</td>";
$table .= "<tr>";
};
@ -75,7 +78,7 @@ class eqsl extends CI_Controller {
unlink($filepath);
$data['lotw_table'] = $table;
$data['eqsl_table'] = $table;
$data['page_title'] = "eQSL ADIF Information";
$this->load->view('layout/header', $data);
@ -132,6 +135,11 @@ class eqsl extends CI_Controller {
// Adapted from Original PHP code by Chirp Internet: www.chirp.com.au
$input = @file_get_contents($eqsl_url) or die("Could not access file: $eqsl_url");
// We need to make sure the ADI file has been built before we download it.
// Look for "Your ADIF log file has been built"
// Get all the links on the page and grab the URL for the ADI file.
$regexp = "<a\s[^>]*href=(\"??)([^\" >]*?)\\1[^>]*>(.*)<\/a>";
if(preg_match_all("/$regexp/siU", $input, $matches)) {
foreach( $matches[2] as $match )
@ -140,14 +148,18 @@ class eqsl extends CI_Controller {
if (substr($match, -4, 4) == ".adi")
{
file_put_contents($file, file_get_contents("http://eqsl.cc/qslcard/" . $match));
ini_set('memory_limit', '-1');
$this->loadFromFile($file);
break;
}
// Produce and error if we don't find the link we need.
}
}
ini_set('memory_limit', '-1');
//$this->loadFromFile($file);
}
else
{

查看文件

@ -605,7 +605,7 @@ class Logbook_model extends CI_Model {
// http://www.eqsl.cc/qslcard/ImportADIF.txt
function eqsl_update($datetime, $callsign, $band, $qsl_status) {
$data = array(
'COL_EQSL_QSLRDATE' => CURRENT_TIMESTAMP, // eQSL doesn't give us a date, so let's use current
'COL_EQSL_QSLRDATE' => 'CURRENT_TIMESTAMP', // eQSL doesn't give us a date, so let's use current
'COL_EQSL_QSL_RCVD' => $qsl_status,
);
@ -631,17 +631,26 @@ class Logbook_model extends CI_Model {
return $row->COL_EQSL_QSLRDATE;
}
// Determine if we've already received an eQSL for this QSO.. this needs writing.
// Determine if we've already received an eQSL for this QSO
function eqsl_dupe_check($datetime, $callsign, $band, $qsl_status) {
$this->db->select('COL_LOTW_QSLRDATE');
$this->db->where('COL_LOTW_QSLRDATE IS NOT NULL');
$this->db->order_by("COL_LOTW_QSLRDATE", "desc");
$this->db->select('COL_EQSL_QSLRDATE');
$this->db->where('date_format(COL_TIME_ON, \'%Y-%m-%d %H:%i\') = "'.$datetime.'"');
$this->db->where('COL_CALL', $callsign);
$this->db->where('COL_BAND', $band);
$this->db->where('COL_EQSL_QSL_RCVD', $qsl_status);
$this->db->limit(1);
$query = $this->db->get($this->config->item('table_name'));
$row = $query->row();
return $row->COL_LOTW_QSLRDATE;
if ($row != null)
{
return true;
}
else
{
return false;
}
}
function import($record) {

查看文件

@ -0,0 +1,6 @@
<div id="container">
<h2><?php echo $page_title; ?></h2>
<?php echo $eqsl_table; ?>
</div>