2024-05-25 09:41:27 +02:00
|
|
|
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
|
2019-06-19 14:14:10 +01:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
Controller to interact with the Clublog API
|
|
|
|
|
*/
|
|
|
|
|
|
2024-05-25 09:41:27 +02:00
|
|
|
class Clublog extends CI_Controller
|
|
|
|
|
{
|
2019-06-19 14:14:10 +01:00
|
|
|
|
2024-02-29 13:52:54 +01:00
|
|
|
function __construct()
|
|
|
|
|
{
|
|
|
|
|
parent::__construct();
|
2024-05-25 09:41:27 +02:00
|
|
|
|
2024-02-29 13:52:54 +01:00
|
|
|
if (ENVIRONMENT == 'maintenance' && $this->session->userdata('user_id') == '') {
|
2024-06-08 11:01:59 +02:00
|
|
|
echo __("Maintenance Mode is active. Try again later.")."\n";
|
2024-05-25 09:41:27 +02:00
|
|
|
redirect('dashboard');
|
2024-02-29 13:52:54 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-19 14:14:10 +01:00
|
|
|
// Show frontend if there is one
|
2024-05-25 09:41:27 +02:00
|
|
|
public function index()
|
|
|
|
|
{
|
|
|
|
|
// nothing to display
|
|
|
|
|
redirect('dashboard');
|
2019-06-19 14:14:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Upload ADIF to Clublog
|
2024-05-25 09:41:27 +02:00
|
|
|
public function upload()
|
|
|
|
|
{
|
|
|
|
|
|
2024-02-29 13:52:54 +01:00
|
|
|
$this->load->model('clublog_model');
|
2022-09-11 15:02:31 +02:00
|
|
|
|
2024-05-03 11:14:52 +02:00
|
|
|
// set the last run in cron table for the correct cron id
|
2024-04-22 23:32:34 +02:00
|
|
|
$this->load->model('cron_model');
|
2024-05-25 09:41:27 +02:00
|
|
|
$this->cron_model->set_last_run($this->router->class . '_' . $this->router->method);
|
2024-04-22 23:32:34 +02:00
|
|
|
|
2024-02-29 13:52:54 +01:00
|
|
|
$users = $this->clublog_model->get_clublog_users();
|
2022-09-11 15:02:31 +02:00
|
|
|
|
2024-05-25 09:41:27 +02:00
|
|
|
if (!empty($users)) {
|
|
|
|
|
foreach ($users as $user) {
|
|
|
|
|
$r = $this->clublog_model->uploadUser($user->user_id, $user->user_clublog_name, $user->user_clublog_password);
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2024-06-08 11:01:59 +02:00
|
|
|
$r = __("No user has configured Clublog.");
|
2022-09-11 15:02:31 +02:00
|
|
|
}
|
2024-05-25 09:41:27 +02:00
|
|
|
|
|
|
|
|
echo $r;
|
2022-09-11 15:02:31 +02:00
|
|
|
}
|
2019-10-05 19:26:07 +01:00
|
|
|
|
2024-05-09 08:18:38 +00:00
|
|
|
// Download ADIF from Clublog
|
2024-05-25 09:41:27 +02:00
|
|
|
public function download()
|
|
|
|
|
{
|
2024-05-09 06:02:17 +00:00
|
|
|
$this->load->model('clublog_model');
|
|
|
|
|
|
|
|
|
|
// set the last run in cron table for the correct cron id
|
|
|
|
|
$this->load->model('cron_model');
|
2024-05-25 09:41:27 +02:00
|
|
|
$this->cron_model->set_last_run($this->router->class . '_' . $this->router->method);
|
2024-05-09 06:02:17 +00:00
|
|
|
|
|
|
|
|
$users = $this->clublog_model->get_clublog_users();
|
|
|
|
|
|
2024-05-25 09:41:27 +02:00
|
|
|
if (!empty($users)) {
|
|
|
|
|
foreach ($users as $user) {
|
|
|
|
|
$r = $this->clublog_model->downloadUser($user->user_id, $user->user_clublog_name, $user->user_clublog_password);
|
2024-05-08 18:38:06 +00:00
|
|
|
}
|
2024-05-25 09:41:27 +02:00
|
|
|
} else {
|
2024-06-08 11:01:59 +02:00
|
|
|
$r = __("No user has configured Clublog.");
|
2024-05-08 18:38:06 +00:00
|
|
|
}
|
2019-06-19 14:48:06 +01:00
|
|
|
|
2024-05-25 09:41:27 +02:00
|
|
|
echo $r;
|
2019-06-19 16:42:04 +01:00
|
|
|
}
|
2019-06-19 18:03:48 +01:00
|
|
|
|
2024-05-25 09:41:27 +02:00
|
|
|
function markqso($station_id)
|
|
|
|
|
{
|
2019-10-05 19:26:07 +01:00
|
|
|
$clean_station_id = $this->security->xss_clean($station_id);
|
2019-06-20 15:21:05 +01:00
|
|
|
$this->load->model('clublog_model');
|
2019-10-05 19:26:07 +01:00
|
|
|
$this->clublog_model->mark_qsos_sent($clean_station_id);
|
2019-06-19 18:03:48 +01:00
|
|
|
}
|
2019-06-20 15:53:57 +01:00
|
|
|
|
2019-08-16 12:11:46 +01:00
|
|
|
// Find DXCC
|
2024-05-25 09:41:27 +02:00
|
|
|
function find_dxcc($callsign)
|
|
|
|
|
{
|
2019-10-05 19:26:07 +01:00
|
|
|
$clean_callsign = $this->security->xss_clean($callsign);
|
2019-08-16 12:11:46 +01:00
|
|
|
// Live lookup against Clublogs API
|
2024-05-25 09:41:27 +02:00
|
|
|
$url = "https://clublog.org/dxcc?call=" . $clean_callsign . "&api=608df94896cb9c5421ae748235492b43815610c9&full=1";
|
2019-08-16 12:11:46 +01:00
|
|
|
|
|
|
|
|
$json = file_get_contents($url);
|
|
|
|
|
$data = json_decode($json, TRUE);
|
|
|
|
|
|
|
|
|
|
// echo ucfirst(strtolower($data['Name']));
|
|
|
|
|
return $data;
|
|
|
|
|
}
|
2019-10-08 20:53:14 +01:00
|
|
|
}
|