Fixes for uploading modified QSOs to QRZ.com

pull/530/head
AndreasK79 2020-06-04 21:56:32 +02:00
rodzic 0c11f4e9a7
commit 13c66289b4
2 zmienionych plików z 13 dodań i 5 usunięć

Wyświetl plik

@ -54,14 +54,19 @@ class Qrz extends CI_Controller {
* Adif is build for each qso, and then uploaded, one at a time
*/
function mass_upload_qsos($station_id, $qrz_api_key) {
$i = 0;
$data['qsos'] = $this->logbook_model->get_qrz_qsos($station_id);
if ($data['qsos']) {
foreach ($data['qsos'] as $qso) {
$adif = $this->logbook_model->create_adif_from_data($qso);
$result = $this->logbook_model->push_qso_to_qrz($qrz_api_key, $adif);
if ($qso['COL_QRZCOM_QSO_UPLOAD_STATUS'] == 'M') {
$result = $this->logbook_model->push_qso_to_qrz($qrz_api_key, $adif, true);
} else {
$result = $this->logbook_model->push_qso_to_qrz($qrz_api_key, $adif);
}
if ($result) {
$this->markqso($qso['COL_PRIMARY_KEY']);
$i++;
@ -112,7 +117,6 @@ class Qrz extends CI_Controller {
header('Content-type: application/json');
if ($i = $this->mass_upload_qsos($postData['station_id'], $qrz_api_key)) {
$stationinfo = $this->stations->stations_with_qrz_api_key();
$info = $stationinfo->result();

Wyświetl plik

@ -360,13 +360,17 @@ class Logbook_model extends CI_Model {
* Function uploads a QSO to QRZ with the API given.
* $adif contains a line with the QSO in the ADIF format. QSO ends with an <eor>
*/
function push_qso_to_qrz($apikey, $adif) {
function push_qso_to_qrz($apikey, $adif, $replaceoption = false) {
$url = 'http://logbook.qrz.com/api'; // TODO: Move this to database
$post_data['KEY'] = $apikey;
$post_data['ACTION'] = 'INSERT';
$post_data['ADIF'] = $adif;
if ($replaceoption) {
$post_data['OPTION'] = 'REPLACE';
}
$ch = curl_init( $url );
curl_setopt( $ch, CURLOPT_POST, true);
curl_setopt( $ch, CURLOPT_POSTFIELDS, $post_data);
@ -376,7 +380,7 @@ class Logbook_model extends CI_Model {
$content = curl_exec($ch);
if ($content){
if (stristr($content,'RESULT=OK')) {
if (stristr($content,'RESULT=OK') || stristr($content,'RESULT=REPLACE')) {
return true;
}
else {