From e9fdc07b93aefc28ff26818b4229f647c6d5bd96 Mon Sep 17 00:00:00 2001 From: Corby Krick Date: Sun, 3 Nov 2013 13:15:25 -0600 Subject: [PATCH] Works now if QSLs are not waiting to be downloaded --- application/controllers/eqsl.php | 93 ++++++++++++++++------------- application/views/eqsl/analysis.php | 14 ++++- 2 files changed, 63 insertions(+), 44 deletions(-) diff --git a/application/controllers/eqsl.php b/application/controllers/eqsl.php index 83acd718..9e47ce67 100644 --- a/application/controllers/eqsl.php +++ b/application/controllers/eqsl.php @@ -28,57 +28,63 @@ class eqsl extends CI_Controller { $this->adif_parser->initialize(); - $table = ""; - - while($record = $this->adif_parser->get_record()) + $records = $this->adif_parser->get_record(); + + if (count($records) > 0) { - /*if(count($record) == 0) + $table = "
"; + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; + while($record = $this->adif_parser->get_record()) { - break; - }; - */ - $time_on = 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. - - // 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['eqsl_rcvd_mark']; - } - - $status = $this->logbook_model->import_check($time_on, $record['call'], $record['band']); - if ($status == "Found") - { - $dupe = $this->logbook_model->eqsl_dupe_check($time_on, $record['call'], $record['band'], $config['eqsl_rcvd_mark']); - if ($dupe == false) + $time_on = 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. + + // If we have a positive match from LoTW, record it in the DB according to the user's preferences + if ($record['qsl_sent'] == "Y") { - $eqsl_status = $this->logbook_model->eqsl_update($time_on, $record['call'], $record['band'], $config['eqsl_rcvd_mark']); + $record['qsl_sent'] = $config['eqsl_rcvd_mark']; + } + + $status = $this->logbook_model->import_check($time_on, $record['call'], $record['band']); + 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 received an eQSL for this QSO."; + } } else { - $eqsl_status = "Already received an eQSL for this QSO."; + $eqsl_status = "QSO not found"; } + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; + $table .= ""; } - else - { - $eqsl_status = "QSO not found"; - } - $table .= ""; - $table .= ""; - $table .= ""; - $table .= ""; - $table .= ""; - $table .= ""; - $table .= ""; - }; + + $table .= "
DateCallModeLog StatuseQSL Status
".$time_on."".$record['call']."".$record['mode']."QSO Record: ".$status."eQSL Record: ".$eqsl_status."
".$time_on."".$record['call']."".$record['mode']."QSO Record: ".$status."eQSL Record: ".$eqsl_status."
"; + $data['eqsl_results_table'] = $table; + + } - $table .= ""; - - //unlink($filepath); - - $data['eqsl_table'] = $table; + unlink($filepath); $data['page_title'] = "eQSL Import Information"; $this->load->view('layout/header', $data); @@ -163,7 +169,7 @@ class eqsl extends CI_Controller { } else { - if (stristr($result, "Your ADIF log file has been built")) + if (stristr($input, "Your ADIF log file has been built")) { // Get all the links on the page and grab the URL for the ADI file. $regexp = "]*href=(\"??)([^\" >]*?)\\1[^>]*>(.*)<\/a>"; @@ -173,6 +179,7 @@ class eqsl extends CI_Controller { // Look for the link that has the .adi file, and download it to $file 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); diff --git a/application/views/eqsl/analysis.php b/application/views/eqsl/analysis.php index a010a3ba..18ce724e 100644 --- a/application/views/eqsl/analysis.php +++ b/application/views/eqsl/analysis.php @@ -1,6 +1,18 @@

- +load->view('layout/messages'); ?> + +The following QSOs have been received from eQSL.cc

"; + echo $eqsl_results_table; + } + else + { + echo "

There are no QSO confirmations waiting for you at eQSL.cc

"; + } +?>