Clublog-RT-Upload

This commit is contained in:
int2001
2023-11-27 12:55:16 +00:00
parent fd6559fb8a
commit 032e77957f
2 changed files with 98 additions and 79 deletions

View File

@@ -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);