kopia lustrzana https://github.com/magicbug/Cloudlog
Merge pull request #2739 from int2001/clublog_rt_fix
Clublog Realtime Upload (push to CL on QSO-Save)pull/2745/head
commit
7351fe58fa
|
@ -22,7 +22,7 @@ $config['migration_enabled'] = TRUE;
|
|||
|
|
||||
*/
|
||||
|
||||
$config['migration_version'] = 154;
|
||||
$config['migration_version'] = 155;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
|
@ -137,73 +137,6 @@ class Clublog extends CI_Controller {
|
|||
}
|
||||
|
||||
|
||||
public function realtime($username) {
|
||||
$clean_username = $this->security->xss_clean($username);
|
||||
|
||||
$this->load->model('stations');
|
||||
$this->load->model('clublog_model');
|
||||
|
||||
$clublog_info = $this->clublog_model->get_clublog_auth_info($clean_username);
|
||||
|
||||
if(!isset($clublog_info['user_name'])) {
|
||||
echo "Username unknown";
|
||||
exit;
|
||||
}
|
||||
|
||||
$station_profiles = $this->stations->all_with_count();
|
||||
|
||||
// if station profiles exist
|
||||
if($station_profiles->num_rows()){
|
||||
// Loop through station profiles
|
||||
foreach ($station_profiles->result() as $station_row)
|
||||
{
|
||||
// if the station profile has more than 1 qso
|
||||
if($station_row->qso_total > 0) {
|
||||
$myqsos = $this->clublog_model->get_last_five($station_row->station_id);
|
||||
|
||||
foreach ($myqsos->result() as $qso)
|
||||
{
|
||||
$data['qso'] = $qso;
|
||||
$adif_string = $this->load->view('adif/data/clublog_realtime', $data, true);
|
||||
|
||||
// initialise the curl request
|
||||
$request = curl_init('https://clublog.org/realtime.php');
|
||||
|
||||
curl_setopt($request, CURLOPT_POST, true);
|
||||
curl_setopt(
|
||||
$request,
|
||||
CURLOPT_POSTFIELDS,
|
||||
array(
|
||||
'email' => $clublog_info['user_clublog_name'],
|
||||
'password' => $clublog_info['user_clublog_password'],
|
||||
'callsign' => $station_row->station_callsign,
|
||||
'adif' => $adif_string,
|
||||
'api' => "a11c3235cd74b88212ce726857056939d52372bd",
|
||||
));
|
||||
|
||||
// output the response
|
||||
curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
|
||||
$response = curl_exec($request);
|
||||
$info = curl_getinfo($request);
|
||||
|
||||
// If Clublog Accepts mark the QSOs
|
||||
if (preg_match('/\bOK\b/', $response)) {
|
||||
echo "QSOs uploaded and Logbook QSOs marked as sent to Clublog<br>";
|
||||
|
||||
$this->clublog_model->mark_qso_sent($qso->COL_PRIMARY_KEY);
|
||||
echo "Clublog upload for ".$station_row->station_callsign."<br>";
|
||||
} else {
|
||||
echo "Error ".$response."<br>";
|
||||
}
|
||||
curl_close ($request);
|
||||
}
|
||||
} else {
|
||||
echo "No QSOs to upload";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Find DXCC
|
||||
function find_dxcc($callsign) {
|
||||
$clean_callsign = $this->security->xss_clean($callsign);
|
||||
|
|
|
@ -106,5 +106,6 @@ $lang['station_location_oqrs_email_alert'] = "OQRS Email alert";
|
|||
$lang['station_location_oqrs_email_hint'] = "Make sure email is set up under admin and global options.";
|
||||
$lang['station_location_oqrs_text'] = "OQRS Text";
|
||||
$lang['station_location_oqrs_text_hint'] = "Some info you want to add regarding QSL'ing.";
|
||||
$lang['station_location_clublog_realtime_upload']='ClubLog Realtime Upload';
|
||||
|
||||
|
||||
|
|
|
@ -106,5 +106,6 @@ $lang['station_location_oqrs_email_alert'] = "OQRS Email alert";
|
|||
$lang['station_location_oqrs_email_hint'] = "Make sure email is set up under admin and global options.";
|
||||
$lang['station_location_oqrs_text'] = "OQRS Text";
|
||||
$lang['station_location_oqrs_text_hint'] = "Some info you want to add regarding QSL'ing.";
|
||||
$lang['station_location_clublog_realtime_upload']='ClubLog Realtime Upload';
|
||||
|
||||
|
||||
|
|
|
@ -106,5 +106,6 @@ $lang['station_location_oqrs_email_alert'] = "OQRS Email alert";
|
|||
$lang['station_location_oqrs_email_hint'] = "Make sure email is set up under admin and global options.";
|
||||
$lang['station_location_oqrs_text'] = "OQRS Text";
|
||||
$lang['station_location_oqrs_text_hint'] = "Some info you want to add regarding QSL'ing.";
|
||||
$lang['station_location_clublog_realtime_upload']='ClubLog Realtime Upload';
|
||||
|
||||
|
||||
|
|
|
@ -106,5 +106,6 @@ $lang['station_location_oqrs_email_alert'] = "OQRS Email alert";
|
|||
$lang['station_location_oqrs_email_hint'] = "Make sure email is set up under admin and global options.";
|
||||
$lang['station_location_oqrs_text'] = "OQRS Text";
|
||||
$lang['station_location_oqrs_text_hint'] = "Some info you want to add regarding QSL'ing.";
|
||||
$lang['station_location_clublog_realtime_upload']='ClubLog Realtime Upload';
|
||||
|
||||
|
||||
|
|
|
@ -106,5 +106,4 @@ $lang['station_location_oqrs_email_alert'] = "OQRS Email alert";
|
|||
$lang['station_location_oqrs_email_hint'] = "Make sure email is set up under admin and global options.";
|
||||
$lang['station_location_oqrs_text'] = "OQRS Text";
|
||||
$lang['station_location_oqrs_text_hint'] = "Some info you want to add regarding QSL'ing.";
|
||||
|
||||
|
||||
$lang['station_location_clublog_realtime_upload']='ClubLog Realtime Upload';
|
||||
|
|
|
@ -106,5 +106,6 @@ $lang['station_location_oqrs_email_alert'] = "OQRS Email alert";
|
|||
$lang['station_location_oqrs_email_hint'] = "Make sure email is set up under admin and global options.";
|
||||
$lang['station_location_oqrs_text'] = "OQRS Text";
|
||||
$lang['station_location_oqrs_text_hint'] = "Some info you want to add regarding QSL'ing.";
|
||||
$lang['station_location_clublog_realtime_upload']='ClubLog Realtime Upload';
|
||||
|
||||
|
||||
|
|
|
@ -106,5 +106,6 @@ $lang['station_location_oqrs_email_alert'] = "OQRS Email alert";
|
|||
$lang['station_location_oqrs_email_hint'] = "Make sure email is set up under admin and global options.";
|
||||
$lang['station_location_oqrs_text'] = "OQRS Text";
|
||||
$lang['station_location_oqrs_text_hint'] = "Some info you want to add regarding QSL'ing.";
|
||||
$lang['station_location_clublog_realtime_upload']='ClubLog Realtime Upload';
|
||||
|
||||
|
||||
|
|
|
@ -106,6 +106,4 @@ $lang['station_location_oqrs_email_alert'] = "OQRS Email Benachrichtigung";
|
|||
$lang['station_location_oqrs_email_hint'] = "Stelle sicher, dass du E-Mail unter Admin/Globale Optionen konfiguriert hast.";
|
||||
$lang['station_location_oqrs_text'] = "OQRS Text";
|
||||
$lang['station_location_oqrs_text_hint'] = "Einige Informationen, die du zum QSL-Vorgang hinzufügen möchtest.";
|
||||
|
||||
|
||||
|
||||
$lang['station_location_clublog_realtime_upload']='ClubLog Realtime Upload';
|
||||
|
|
|
@ -106,5 +106,6 @@ $lang['station_location_oqrs_email_alert'] = "OQRS Email alert";
|
|||
$lang['station_location_oqrs_email_hint'] = "Make sure email is set up under admin and global options.";
|
||||
$lang['station_location_oqrs_text'] = "OQRS Text";
|
||||
$lang['station_location_oqrs_text_hint'] = "Some info you want to add regarding QSL'ing.";
|
||||
$lang['station_location_clublog_realtime_upload']='ClubLog Realtime Upload';
|
||||
|
||||
|
||||
|
|
|
@ -106,5 +106,6 @@ $lang['station_location_oqrs_email_alert'] = "OQRS Email alert";
|
|||
$lang['station_location_oqrs_email_hint'] = "Make sure email is set up under admin and global options.";
|
||||
$lang['station_location_oqrs_text'] = "OQRS Text";
|
||||
$lang['station_location_oqrs_text_hint'] = "Some info you want to add regarding QSL'ing.";
|
||||
$lang['station_location_clublog_realtime_upload']='ClubLog Realtime Upload';
|
||||
|
||||
|
||||
|
|
|
@ -106,5 +106,6 @@ $lang['station_location_oqrs_email_alert'] = "OQRS Email alert";
|
|||
$lang['station_location_oqrs_email_hint'] = "Make sure email is set up under admin and global options.";
|
||||
$lang['station_location_oqrs_text'] = "OQRS Text";
|
||||
$lang['station_location_oqrs_text_hint'] = "Some info you want to add regarding QSL'ing.";
|
||||
$lang['station_location_clublog_realtime_upload']='ClubLog Realtime Upload';
|
||||
|
||||
|
||||
|
|
|
@ -106,5 +106,4 @@ $lang['station_location_oqrs_email_alert'] = "Оповещение о OQRS о е
|
|||
$lang['station_location_oqrs_email_hint'] = "Убедитесь, что емэйл сконфигурирован администратором в общих настройках.";
|
||||
$lang['station_location_oqrs_text'] = "Текст OQRS";
|
||||
$lang['station_location_oqrs_text_hint'] = "Информация, которую вы хотите добавить, касающаяся QSL.";
|
||||
|
||||
|
||||
$lang['station_location_clublog_realtime_upload']='ClubLog Realtime Upload';
|
||||
|
|
|
@ -106,5 +106,6 @@ $lang['station_location_oqrs_email_alert'] = "OQRS Email alert";
|
|||
$lang['station_location_oqrs_email_hint'] = "Make sure email is set up under admin and global options.";
|
||||
$lang['station_location_oqrs_text'] = "OQRS Text";
|
||||
$lang['station_location_oqrs_text_hint'] = "Some info you want to add regarding QSL'ing.";
|
||||
$lang['station_location_clublog_realtime_upload']='ClubLog Realtime Upload';
|
||||
|
||||
|
||||
|
|
|
@ -106,5 +106,6 @@ $lang['station_location_oqrs_email_alert'] = "OQRS Email alert";
|
|||
$lang['station_location_oqrs_email_hint'] = "Make sure email is set up under admin and global options.";
|
||||
$lang['station_location_oqrs_text'] = "OQRS Text";
|
||||
$lang['station_location_oqrs_text_hint'] = "Some info you want to add regarding QSL'ing.";
|
||||
$lang['station_location_clublog_realtime_upload']='ClubLog Realtime Upload';
|
||||
|
||||
|
||||
|
|
|
@ -106,5 +106,6 @@ $lang['station_location_oqrs_email_alert'] = "OQRS Email alert";
|
|||
$lang['station_location_oqrs_email_hint'] = "Make sure email is set up under admin and global options.";
|
||||
$lang['station_location_oqrs_text'] = "OQRS Text";
|
||||
$lang['station_location_oqrs_text_hint'] = "Some info you want to add regarding QSL'ing.";
|
||||
$lang['station_location_clublog_realtime_upload']='ClubLog Realtime Upload';
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
defined('BASEPATH') or exit('No direct script access allowed');
|
||||
|
||||
class Migration_add_clublog_realtime extends CI_Migration
|
||||
{
|
||||
public function up()
|
||||
{
|
||||
$fields = array(
|
||||
'clublogrealtime TINYINT NOT NULL DEFAULT 0 AFTER `webadifrealtime`',
|
||||
);
|
||||
|
||||
if (!$this->db->field_exists('clublogrealtime', 'station_profile')) {
|
||||
$this->dbforge->add_column('station_profile', $fields);
|
||||
}
|
||||
}
|
||||
|
||||
public function down()
|
||||
{
|
||||
|
||||
if ($this->db->field_exists('clublogrealtime', 'station_profile')) {
|
||||
$this->dbforge->drop_column('station_profile', 'clublogrealtime');
|
||||
}
|
||||
}
|
||||
}
|
|
@ -565,6 +565,20 @@ class Logbook_model extends CI_Model {
|
|||
if (!$skipexport) {
|
||||
|
||||
|
||||
$result = $this->exists_clublog_credentials($data['station_id']);
|
||||
if (isset($result->ucp) && isset($result->ucn) && (($result->ucp ?? '') != '') && (($result->ucn ?? '') != '') && ($result->clublogrealtime == 1)) {
|
||||
$CI =& get_instance();
|
||||
$CI->load->library('AdifHelper');
|
||||
$qso = $this->get_qso($last_id,true)->result();
|
||||
|
||||
$adif = $CI->adifhelper->getAdifLine($qso[0]);
|
||||
$result = $this->push_qso_to_clublog($result->ucn, $result->ucp, $data['COL_STATION_CALLSIGN'], $adif);
|
||||
if ( ($result['status'] == 'OK') || ( ($result['status'] == 'error') || ($result['status'] == 'duplicate') || ($result['status'] == 'auth_error') )){
|
||||
$this->mark_clublog_qsos_sent($last_id);
|
||||
}
|
||||
}
|
||||
|
||||
$result = '';
|
||||
$result = $this->exists_hrdlog_code($data['station_id']);
|
||||
// Push qso to hrdlog if code is set, and realtime upload is enabled, and we're not importing an adif-file
|
||||
if (isset($result->hrdlog_code) && $result->hrdlogrealtime == 1) {
|
||||
|
@ -619,9 +633,9 @@ class Logbook_model extends CI_Model {
|
|||
*/
|
||||
function exists_hrdlog_code($station_id) {
|
||||
$sql = 'select hrdlog_code, hrdlogrealtime from station_profile
|
||||
where station_id = ' . $station_id;
|
||||
where station_id = ?';
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
$query = $this->db->query($sql,$station_id);
|
||||
|
||||
$result = $query->row();
|
||||
|
||||
|
@ -632,14 +646,32 @@ class Logbook_model extends CI_Model {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Function checks if a Clublog Credebtials exists in the table with the given station id
|
||||
*/
|
||||
function exists_clublog_credentials($station_id) {
|
||||
$sql = 'select auth.user_clublog_name ucn, auth.user_clublog_password ucp, prof.clublogrealtime from '.$this->config->item('auth_table').' auth inner join station_profile prof on (auth.user_id=prof.user_id) where prof.station_id = ? and prof.clublogrealtime=1';
|
||||
|
||||
$query = $this->db->query($sql, $station_id);
|
||||
|
||||
$result = $query->row();
|
||||
|
||||
if ($result) {
|
||||
return $result;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Function checks if a QRZ API Key exists in the table with the given station id
|
||||
*/
|
||||
function exists_qrz_api_key($station_id) {
|
||||
$sql = 'select qrzapikey, qrzrealtime from station_profile
|
||||
where station_id = ' . $station_id;
|
||||
where station_id = ?';
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
$query = $this->db->query($sql, $station_id);
|
||||
|
||||
$result = $query->row();
|
||||
|
||||
|
@ -654,21 +686,54 @@ class Logbook_model extends CI_Model {
|
|||
/*
|
||||
* Function checks if a WebADIF API Key exists in the table with the given station id
|
||||
*/
|
||||
function exists_webadif_api_key($station_id) {
|
||||
$sql = 'select webadifapikey, webadifapiurl, webadifrealtime from station_profile
|
||||
where station_id = ' . $station_id;
|
||||
function exists_webadif_api_key($station_id) {
|
||||
$sql = 'select webadifapikey, webadifapiurl, webadifrealtime from station_profile
|
||||
where station_id = ?';
|
||||
|
||||
$query = $this->db->query($sql);
|
||||
$query = $this->db->query($sql, $station_id);
|
||||
|
||||
$result = $query->row();
|
||||
$result = $query->row();
|
||||
|
||||
if ($result) {
|
||||
return $result;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if ($result) {
|
||||
return $result;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function push_qso_to_clublog($cl_username, $cl_password, $station_callsign, $adif) {
|
||||
|
||||
// initialise the curl request
|
||||
$returner=[];
|
||||
$request = curl_init('https://clublog.org/realtime.php');
|
||||
|
||||
curl_setopt($request, CURLOPT_POST, true);
|
||||
curl_setopt(
|
||||
$request,
|
||||
CURLOPT_POSTFIELDS,
|
||||
array(
|
||||
'email' => $cl_username,
|
||||
'password' => $cl_password,
|
||||
'callsign' => $station_callsign,
|
||||
'adif' => $adif,
|
||||
'api' => "a11c3235cd74b88212ce726857056939d52372bd",
|
||||
));
|
||||
|
||||
// output the response
|
||||
curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
|
||||
$response = curl_exec($request);
|
||||
$info = curl_getinfo($request);
|
||||
|
||||
// If Clublog Accepts mark the QSOs
|
||||
if (preg_match('/\bOK\b/', $response)) {
|
||||
$returner['status']='OK';
|
||||
} else {
|
||||
$returner['status']=$response;
|
||||
}
|
||||
curl_close ($request);
|
||||
return ($returner);
|
||||
}
|
||||
|
||||
/*
|
||||
* Function uploads a QSO to HRDLog with the API given.
|
||||
|
@ -795,6 +860,24 @@ class Logbook_model extends CI_Model {
|
|||
return $response === 200;
|
||||
}
|
||||
|
||||
/*
|
||||
* Function marks QSOs as uploaded to Clublog
|
||||
* $primarykey is the unique id for that QSO in the logbook
|
||||
*/
|
||||
function mark_clublog_qsos_sent($primarykey) {
|
||||
$data = array(
|
||||
'COL_CLUBLOG_QSO_UPLOAD_DATE' => date("Y-m-d H:i:s", strtotime("now")),
|
||||
'COL_CLUBLOG_QSO_UPLOAD_STATUS' => 'Y',
|
||||
);
|
||||
|
||||
$this->db->where('COL_PRIMARY_KEY', $primarykey);
|
||||
|
||||
$this->db->update($this->config->item('table_name'), $data);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Function marks QSOs as uploaded to HRDLog.
|
||||
* $primarykey is the unique id for that QSO in the logbook
|
||||
|
|
|
@ -103,6 +103,7 @@ class Stations extends CI_Model {
|
|||
'eqslqthnickname' => xss_clean($this->input->post('eqslnickname', true)),
|
||||
'hrdlog_code' => xss_clean($this->input->post('hrdlog_code', true)),
|
||||
'hrdlogrealtime' => xss_clean($this->input->post('hrdlogrealtime', true)),
|
||||
'clublogrealtime' => xss_clean($this->input->post('clublogrealtime', true)),
|
||||
'qrzapikey' => xss_clean($this->input->post('qrzapikey', true)),
|
||||
'qrzrealtime' => xss_clean($this->input->post('qrzrealtime', true)),
|
||||
'oqrs' => xss_clean($this->input->post('oqrs', true)),
|
||||
|
@ -146,6 +147,7 @@ class Stations extends CI_Model {
|
|||
'eqslqthnickname' => xss_clean($this->input->post('eqslnickname', true)),
|
||||
'hrdlog_code' => xss_clean($this->input->post('hrdlog_code', true)),
|
||||
'hrdlogrealtime' => xss_clean($this->input->post('hrdlogrealtime', true)),
|
||||
'clublogrealtime' => xss_clean($this->input->post('clublogrealtime', true)),
|
||||
'qrzapikey' => xss_clean($this->input->post('qrzapikey', true)),
|
||||
'qrzrealtime' => xss_clean($this->input->post('qrzrealtime', true)),
|
||||
'oqrs' => xss_clean($this->input->post('oqrs', true)),
|
||||
|
|
|
@ -249,6 +249,13 @@
|
|||
<small id="eqslhelp" class="form-text text-muted"><?php echo lang("station_location_eqsl_hint"); ?></small>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label for="clublogrealtime"><?php echo lang("station_location_clublog_realtime_upload"); ?></label>
|
||||
<select class="form-select" id="clublogrealtime" name="clublogrealtime">
|
||||
<option value="1"><?php echo lang("general_word_yes"); ?></option>
|
||||
<option value="0" selected><?php echo lang("general_word_no"); ?></option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="mb-3 col-sm-6">
|
||||
|
|
|
@ -379,6 +379,22 @@
|
|||
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md">
|
||||
<div class="card">
|
||||
<h5 class="card-header">ClubLog</h5> <!-- This does not need Multilanguage Support -->
|
||||
<div class="card-body">
|
||||
<div class="mb-3">
|
||||
<label for="clublogrealtime"><?php echo lang("station_location_clublog_realtime_upload"); ?></label>
|
||||
<select class="form-select" id="clublogrealtime" name="clublogrealtime">
|
||||
<option value="1" <?php if ($my_station_profile->clublogrealtime == 1) { echo " selected =\"selected\""; } ?>><?php echo lang("general_word_yes"); ?></option>
|
||||
<option value="0" <?php if ($my_station_profile->clublogrealtime == 0) { echo " selected =\"selected\""; } ?>><?php echo lang("general_word_no"); ?></option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="col-md">
|
||||
<div class="card">
|
||||
<h5 class="card-header">HRDLog.net</h5> <!-- This does not need Multilanguage Support -->
|
||||
|
|
Ładowanie…
Reference in New Issue