Skip to content

Commit

Permalink
Its time for 2.4.1 with bug fixes and new features
Browse files Browse the repository at this point in the history
  • Loading branch information
magicbug authored Apr 6, 2023
2 parents 7218961 + e22bc4e commit 8654e9e
Show file tree
Hide file tree
Showing 41 changed files with 1,501 additions and 125 deletions.
6 changes: 5 additions & 1 deletion .htaccess.sample
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
# $config['index_page'] = '';

RewriteEngine On

RewriteCond %{REQUEST_URI} ^/backup/$
RewriteRule ^(.*)$ /index.php?/$1 [L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /index.php?/$1 [L]
RewriteRule ^(.*)$ /index.php?/$1 [L]
2 changes: 1 addition & 1 deletion application/config/config.sample.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/

$config['app_name'] = "Cloudlog";
$config['app_version'] = "2.3.3";
$config['app_version'] = "2.4.1";
$config['directory'] = "logbook";

$config['callbook'] = "hamqth"; // Options are hamqth or qrz
Expand Down
2 changes: 1 addition & 1 deletion application/config/lotw.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

/*
|--------------------------------------------------------------------------
| Folder location for storing P12 certficiate files on the system
| Folder location for storing P12 certificate files on the system
|--------------------------------------------------------------------------
|
| This folder must be outside of your www root for security reasons
Expand Down
2 changes: 1 addition & 1 deletion application/config/migration.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
| be upgraded / downgraded to.
|
*/
$config['migration_version'] = 114;
$config['migration_version'] = 116;

/*
|--------------------------------------------------------------------------
Expand Down
155 changes: 154 additions & 1 deletion application/controllers/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ function search()
$this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard');
}

$this->api_model->update_last_used($obj['key']);

// Retrieve the arguments from the query string
$data['data']['format'] = $arguments['format'];

Expand Down Expand Up @@ -295,6 +297,8 @@ function api_search($arguments){
$this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard');
}

$this->api_model->update_last_used($obj['key']);

// Retrieve the arguments from the query string
$data['data']['format'] = $arguments['format'];

Expand Down Expand Up @@ -432,6 +436,7 @@ function qso() {
die();
}

$this->api_model->update_last_used($obj['key']);

if($obj['type'] == "adif" && $obj['string'] != "") {
// Load the logbook model for adding QSO records
Expand Down Expand Up @@ -466,6 +471,152 @@ function qso() {

}

// API function to check if a callsign is in the logbook already
function logbook_check_callsign() {
header('Content-type: application/json');

$this->load->model('api_model');

// Decode JSON and store
$obj = json_decode(file_get_contents("php://input"), true);
if ($obj === NULL) {
echo json_encode(['status' => 'failed', 'reason' => "wrong JSON"]);
}

if(!isset($obj['key']) || $this->api_model->authorize($obj['key']) == 0) {
http_response_code(401);
echo json_encode(['status' => 'failed', 'reason' => "missing api key"]);
}

if($obj['logbook_public_slug'] != "" && $obj['callsign'] != "") {

$logbook_slug = $obj['logbook_public_slug'];
$callsign = $obj['callsign'];

// If $obj['band'] exists
if(isset($obj['band'])) {
$band = $obj['band'];
} else {
$band = null;
}

$this->load->model('logbooks_model');

if($this->logbooks_model->public_slug_exists($logbook_slug)) {
$logbook_id = $this->logbooks_model->public_slug_exists_logbook_id($logbook_slug);
if($logbook_id != false)
{
// Get associated station locations for mysql queries
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($logbook_id);

if (!$logbooks_locations_array) {
// Logbook not found
http_response_code(404);
echo json_encode(['status' => 'failed', 'reason' => "Empty Logbook"]);
die();
}
} else {
// Logbook not found
http_response_code(404);
echo json_encode(['status' => 'failed', 'reason' => $logbook_slug." has no associated station locations"]);
die();
}
// Search Logbook for callsign
$this->load->model('logbook_model');

$result = $this->logbook_model->check_if_callsign_worked_in_logbook($callsign, $logbooks_locations_array, $band);

http_response_code(201);
if($result > 0)
{
echo json_encode(['callsign' => $callsign, 'result' => 'Found']);
} else {
echo json_encode(['callsign' => $callsign, 'result' => 'Not Found']);
}
} else {
// Logbook not found
http_response_code(404);
echo json_encode(['status' => 'failed', 'reason' => "logbook not found"]);
die();
}

}

}

// API function to check if a grid is in the logbook already
function logbook_check_grid() {
header('Content-type: application/json');

$this->load->model('api_model');

// Decode JSON and store
$obj = json_decode(file_get_contents("php://input"), true);
if ($obj === NULL) {
echo json_encode(['status' => 'failed', 'reason' => "wrong JSON"]);
}

if(!isset($obj['key']) || $this->api_model->authorize($obj['key']) == 0) {
http_response_code(401);
echo json_encode(['status' => 'failed', 'reason' => "missing api key"]);
}

if($obj['logbook_public_slug'] != "" && $obj['grid'] != "") {

$logbook_slug = $obj['logbook_public_slug'];
$grid = $obj['grid'];

// If $obj['band'] exists
if(isset($obj['band'])) {
$band = $obj['band'];
} else {
$band = null;
}

$this->load->model('logbooks_model');

if($this->logbooks_model->public_slug_exists($logbook_slug)) {
$logbook_id = $this->logbooks_model->public_slug_exists_logbook_id($logbook_slug);
if($logbook_id != false)
{
// Get associated station locations for mysql queries
$logbooks_locations_array = $this->logbooks_model->list_logbook_relationships($logbook_id);

if (!$logbooks_locations_array) {
// Logbook not found
http_response_code(404);
echo json_encode(['status' => 'failed', 'reason' => "Empty Logbook"]);
die();
}
} else {
// Logbook not found
http_response_code(404);
echo json_encode(['status' => 'failed', 'reason' => $logbook_slug." has no associated station locations"]);
die();
}
// Search Logbook for callsign
$this->load->model('logbook_model');

$result = $this->logbook_model->check_if_grid_worked_in_logbook($grid, $logbooks_locations_array, $band);

http_response_code(201);
if($result > 0)
{
echo json_encode(['gridsquare' => strtoupper($grid), 'result' => 'Found']);
} else {
echo json_encode(['gridsquare' => strtoupper($grid), 'result' => 'Not Found']);
}
} else {
// Logbook not found
http_response_code(404);
echo json_encode(['status' => 'failed', 'reason' => "logbook not found"]);
die();
}

}

}

function country_worked($dxcc_num, $band, $mode = NULL) {
$this->load->model('api_model');

Expand Down Expand Up @@ -500,6 +651,8 @@ function radio() {
die();
}

$this->api_model->update_last_used($obj['key']);

$user_id = $this->api_model->key_userid($obj['key']);

// Store Result to Database
Expand Down Expand Up @@ -688,4 +841,4 @@ function qralatlng($qra) {
$latlng = $this->qra->qra2latlong($qra);
return $latlng;
}
}
}
16 changes: 8 additions & 8 deletions application/controllers/Lotw.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,23 +153,23 @@ public function do_cert_upload()
}

// Check to see if certificate is already in the system
$new_certficiate = $this->LotwCert->find_cert($info['issued_callsign'], $dxcc, $this->session->userdata('user_id'));
$new_certificate = $this->LotwCert->find_cert($info['issued_callsign'], $dxcc, $this->session->userdata('user_id'));

if($new_certficiate == 0) {
if($new_certificate == 0) {
// New Certificate Store in Database

// Store Certificate Data into MySQL
$this->LotwCert->store_certificate($this->session->userdata('user_id'), $info['issued_callsign'], $dxcc, $info['validFrom'], $info['validTo_Date'], $info['qso-first-date'], $info['qso-end-date'], $info['pem_key'], $info['general_cert']);

// Cert success flash message
$this->session->set_flashdata('Success', $info['issued_callsign'].' Certficiate Imported.');
$this->session->set_flashdata('Success', $info['issued_callsign'].' Certificate Imported.');
} else {
// Certficiate is in the system time to update
// Certificate is in the system time to update

$this->LotwCert->update_certficiate($this->session->userdata('user_id'), $info['issued_callsign'], $dxcc, $info['validFrom'], $info['validTo_Date'], $info['pem_key'], $info['general_cert']);
$this->LotwCert->update_certificate($this->session->userdata('user_id'), $info['issued_callsign'], $dxcc, $info['validFrom'], $info['validTo_Date'], $info['pem_key'], $info['general_cert']);

// Cert success flash message
$this->session->set_flashdata('Success', $info['issued_callsign'].' Certficiate Updated.');
$this->session->set_flashdata('Success', $info['issued_callsign'].' Certificate Updated.');

}

Expand Down Expand Up @@ -378,9 +378,9 @@ public function delete_cert($cert_id) {

$this->load->model('LotwCert');

$this->LotwCert->delete_certficiate($this->session->userdata('user_id'), $cert_id);
$this->LotwCert->delete_certificate($this->session->userdata('user_id'), $cert_id);

$this->session->set_flashdata('Success', 'Certficiate Deleted.');
$this->session->set_flashdata('Success', 'Certificate Deleted.');

redirect('/lotw/');
}
Expand Down
1 change: 1 addition & 0 deletions application/controllers/Timeline.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public function index()
}

public function details() {
$this->load->model('logbook_model');
$this->load->model('timeline_model');

$querystring = str_replace('"', "", $this->input->post("Querystring"));
Expand Down
Loading

0 comments on commit 8654e9e

Please sign in to comment.