Added a bit better error handling. Writing errors to logfile now, if turned on in config.
这个提交包含在:
父节点
ddfb3f5958
当前提交
cea2cb3ea8
共有 2 个文件被更改,包括 15 次插入 和 6 次删除
|
|
@ -36,7 +36,7 @@ class Qrz extends CI_Controller {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
echo "No station_id's with a QRZ API Key found";
|
echo "No station_id's with a QRZ API Key found";
|
||||||
log_message('info', "No station_id's with a QRZ API Key found");
|
log_message('error', "No station_id's with a QRZ API Key found");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -67,9 +67,12 @@ class Qrz extends CI_Controller {
|
||||||
$result = $this->logbook_model->push_qso_to_qrz($qrz_api_key, $adif);
|
$result = $this->logbook_model->push_qso_to_qrz($qrz_api_key, $adif);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($result) {
|
if ($result['status'] == 'OK') {
|
||||||
$this->markqso($qso['COL_PRIMARY_KEY']);
|
$this->markqso($qso['COL_PRIMARY_KEY']);
|
||||||
$i++;
|
$i++;
|
||||||
|
} else {
|
||||||
|
log_message('error', 'QRZ upload failed for qso: ' .$adif);
|
||||||
|
log_message('error', 'QRZ upload failed with the following message: ' .$result['message']);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $i;
|
return $i;
|
||||||
|
|
|
||||||
|
|
@ -328,7 +328,8 @@ class Logbook_model extends CI_Model {
|
||||||
// Push qso to qrz if apikey is set
|
// Push qso to qrz if apikey is set
|
||||||
if ($apikey = $this->exists_qrz_api_key($data['station_id'])) {
|
if ($apikey = $this->exists_qrz_api_key($data['station_id'])) {
|
||||||
$adif = $this->create_adif_from_data($data);
|
$adif = $this->create_adif_from_data($data);
|
||||||
IF ($this->push_qso_to_qrz($apikey, $adif)) {
|
$result = $this->push_qso_to_qrz($apikey, $adif);
|
||||||
|
IF ($result['status'] == 'OK') {
|
||||||
$data['COL_QRZCOM_QSO_UPLOAD_STATUS'] = 'Y';
|
$data['COL_QRZCOM_QSO_UPLOAD_STATUS'] = 'Y';
|
||||||
$data['COL_QRZCOM_QSO_UPLOAD_DATE'] = date("Y-m-d H:i:s", strtotime("now"));
|
$data['COL_QRZCOM_QSO_UPLOAD_DATE'] = date("Y-m-d H:i:s", strtotime("now"));
|
||||||
}
|
}
|
||||||
|
|
@ -382,14 +383,19 @@ class Logbook_model extends CI_Model {
|
||||||
$content = curl_exec($ch);
|
$content = curl_exec($ch);
|
||||||
if ($content){
|
if ($content){
|
||||||
if (stristr($content,'RESULT=OK') || stristr($content,'RESULT=REPLACE')) {
|
if (stristr($content,'RESULT=OK') || stristr($content,'RESULT=REPLACE')) {
|
||||||
return true;
|
$result['status'] = 'OK';
|
||||||
|
return $result;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return false;
|
$result['status'] = 'error';
|
||||||
|
$result['message'] = $content;
|
||||||
|
return $result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(curl_errno($ch)){
|
if(curl_errno($ch)){
|
||||||
return false;
|
$result['status'] = 'error';
|
||||||
|
$result['message'] = 'Curl error: '. curl_errno($ch);
|
||||||
|
return $result;
|
||||||
}
|
}
|
||||||
curl_close($ch);
|
curl_close($ch);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
正在加载…
在新工单中引用