only load Qra Lib if it isn't already, flooding log

This commit is contained in:
HB9HIL
2024-07-15 05:59:47 +02:00
parent 117d523e3b
commit c9db79e4d9
10 changed files with 85 additions and 41 deletions

View File

@@ -639,7 +639,9 @@ class API extends CI_Controller {
}
function qralatlng($qra) {
$this->load->library('Qra');
if(!$this->load->is_loaded('Qra')) {
$this->load->library('Qra');
}
$latlng = $this->qra->qra2latlong($qra);
return $latlng;
}

View File

@@ -27,7 +27,9 @@ class Dashboard extends CI_Controller
// Calculate Lat/Lng from Locator to use on Maps
if ($this->session->userdata('user_locator')) {
$this->load->library('qra');
if(!$this->load->is_loaded('Qra')) {
$this->load->library('Qra');
}
$qra_position = $this->qra->qra2latlong($this->session->userdata('user_locator'));
if ($qra_position) {

View File

@@ -32,7 +32,9 @@ class Kmlexport extends CI_Controller {
$this->load->model('user_model');
if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); }
// Load Libraries
$this->load->library('qra');
if(!$this->load->is_loaded('Qra')) {
$this->load->library('Qra');
}
$this->load->helper('file');
// Load Database connections

View File

@@ -39,7 +39,9 @@ class Logbook extends CI_Controller {
// Calculate Lat/Lng from Locator to use on Maps
if($this->session->userdata('user_locator')) {
$this->load->library('qra');
if(!$this->load->is_loaded('Qra')) {
$this->load->library('Qra');
}
$qra_position = $this->qra->qra2latlong($this->session->userdata('user_locator'));
if (isset($qra_position[0]) and isset($qra_position[1])) {
$data['qra'] = "set";
@@ -581,7 +583,9 @@ class Logbook extends CI_Controller {
$this->load->model('user_model');
if(!$this->user_model->authorize($this->config->item('auth_mode'))) { return; }
$this->load->library('qra');
if(!$this->load->is_loaded('Qra')) {
$this->load->library('Qra');
}
$this->load->library('subdivisions');
$this->load->model('logbook_model');
@@ -1098,7 +1102,9 @@ class Logbook extends CI_Controller {
function searchbearing() {
$locator = xss_clean($this->input->post('grid'));
$station_id = xss_clean($this->input->post('stationProfile'));
$this->load->library('Qra');
if(!$this->load->is_loaded('Qra')) {
$this->load->library('Qra');
}
if($locator != null) {
if (isset($station_id)) {
@@ -1137,7 +1143,9 @@ class Logbook extends CI_Controller {
function searchdistance() {
$locator = xss_clean($this->input->post('grid'));
$station_id = xss_clean($this->input->post('stationProfile'));
$this->load->library('Qra');
if(!$this->load->is_loaded('Qra')) {
$this->load->library('Qra');
}
if($locator != null) {
if (isset($station_id)) {
@@ -1167,38 +1175,42 @@ class Logbook extends CI_Controller {
/* return station bearing */
function bearing($locator, $unit = 'M', $station_id = null) {
if(!$this->load->is_loaded('Qra')) {
$this->load->library('Qra');
}
if($locator != null) {
if (isset($station_id)) {
// be sure that station belongs to user
$this->load->model('Stations');
if (!$this->Stations->check_station_is_accessible($station_id)) {
return "";
}
// get station profile
$station_profile = $this->Stations->profile_clean($station_id);
// get locator
$mylocator = $station_profile->station_gridsquare;
} else if($this->session->userdata('user_locator') != null){
$mylocator = $this->session->userdata('user_locator');
} else {
$mylocator = $this->config->item('locator');
if($locator != null) {
if (isset($station_id)) {
// be sure that station belongs to user
$this->load->model('Stations');
if (!$this->Stations->check_station_is_accessible($station_id)) {
return "";
}
$bearing = $this->qra->bearing($mylocator, $locator, $unit);
// get station profile
$station_profile = $this->Stations->profile_clean($station_id);
return $bearing;
// get locator
$mylocator = $station_profile->station_gridsquare;
} else if($this->session->userdata('user_locator') != null){
$mylocator = $this->session->userdata('user_locator');
} else {
$mylocator = $this->config->item('locator');
}
return "";
$bearing = $this->qra->bearing($mylocator, $locator, $unit);
return $bearing;
}
return "";
}
/* return distance */
function distance($locator, $station_id = null) {
$distance = 0;
$this->load->library('Qra');
if(!$this->load->is_loaded('Qra')) {
$this->load->library('Qra');
}
if($locator != null) {
if (isset($station_id)) {
@@ -1226,14 +1238,18 @@ class Logbook extends CI_Controller {
}
function qralatlng($qra) {
$this->load->library('Qra');
if(!$this->load->is_loaded('Qra')) {
$this->load->library('Qra');
}
$latlng = $this->qra->qra2latlong($qra);
return $latlng;
}
function qralatlngjson() {
$qra = xss_clean($this->input->post('qra'));
$this->load->library('Qra');
if(!$this->load->is_loaded('Qra')) {
$this->load->library('Qra');
}
$latlng = $this->qra->qra2latlong($qra);
print json_encode($latlng);
}

View File

@@ -410,7 +410,9 @@ class Logbookadvanced extends CI_Controller {
}
public function calculate($qso, $locator1, $locator2, $measurement_base, $var_dist, $custom_date_format) {
$this->load->library('Qra');
if(!$this->load->is_loaded('Qra')) {
$this->load->library('Qra');
}
$this->load->model('logbook_model');
$data['distance'] = $this->qra->distance($locator1, $locator2, $measurement_base) . $var_dist;
@@ -440,7 +442,9 @@ class Logbookadvanced extends CI_Controller {
}
public function calculateCoordinates($qso, $lat, $long, $mygrid, $measurement_base, $var_dist, $custom_date_format) {
$this->load->library('Qra');
if(!$this->load->is_loaded('Qra')) {
$this->load->library('Qra');
}
$this->load->model('logbook_model');
$latlng1 = $this->qra->qra2latlong($mygrid);

View File

@@ -45,7 +45,9 @@ class Qrbcalc extends CI_Controller {
break;
}
$this->load->library('Qra');
if(!$this->load->is_loaded('Qra')) {
$this->load->library('Qra');
}
$data['result'] = $this->qra->bearing($locator1, $locator2, $measurement_base);
$data['distance'] = $this->qra->distance($locator1, $locator2, $measurement_base) . $var_dist;

View File

@@ -148,7 +148,9 @@ class Visitor extends CI_Controller {
public function map() {
$this->load->model('logbook_model');
$this->load->library('qra');
if(!$this->load->is_loaded('Qra')) {
$this->load->library('Qra');
}
$slug = $this->security->xss_clean($this->uri->segment(3));
@@ -453,7 +455,9 @@ class Visitor extends CI_Controller {
public function mapqsos() {
$this->load->model('visitor_model');
$this->load->library('qra');
if(!$this->load->is_loaded('Qra')) {
$this->load->library('Qra');
}
$slug = $this->security->xss_clean($this->input->post('slug'));
$qsocount = $this->security->xss_clean($this->input->post('qsocount')) == '' ? '100' : $this->security->xss_clean($this->input->post('qsocount'));
@@ -496,7 +500,9 @@ class Visitor extends CI_Controller {
}
public function calculate($qso, $locator1, $locator2, $user_default_confirmation) {
$this->load->library('Qra');
if(!$this->load->is_loaded('Qra')) {
$this->load->library('Qra');
}
$this->load->model('logbook_model');
$latlng1 = $this->qra->qra2latlong($locator1);
@@ -514,7 +520,9 @@ class Visitor extends CI_Controller {
}
public function calculateCoordinates($qso, $lat, $long, $mygrid, $user_default_confirmation) {
$this->load->library('Qra');
if(!$this->load->is_loaded('Qra')) {
$this->load->library('Qra');
}
$this->load->model('logbook_model');
$latlng1 = $this->qra->qra2latlong($mygrid);

View File

@@ -128,7 +128,9 @@ class Distances_model extends CI_Model
// It builds an array, which has 50km intervals, then inputs each length into the correct spot
// The function returns a json-encoded array.
function plot($qsoArray, $gridsquare, $measurement_base) {
$this->load->library('Qra');
if(!$this->load->is_loaded('Qra')) {
$this->load->library('Qra');
}
$stationgrid = strtoupper($gridsquare[0]); // We use only the first entered gridsquare from the active profile
if (strlen($stationgrid) == 4) $stationgrid .= 'MM'; // adding center of grid if only 4 digits are specified

View File

@@ -4682,7 +4682,9 @@ function lotw_last_qsl_date($user_id) {
$count = 0;
if ($query->num_rows() > 0){
print("Affected QSOs: ".$this->db->affected_rows()." <br />");
$this->load->library('Qra');
if(!$this->load->is_loaded('Qra')) {
$this->load->library('Qra');
}
foreach ($query->result() as $row) {
$distance = $this->qra->distance($row->station_gridsquare, $row->COL_GRIDSQUARE, 'K');
$data = array(
@@ -4934,7 +4936,9 @@ function lotw_last_qsl_date($user_id) {
// [JSON PLOT] return array for plot qso for map //
public function get_plot_array_for_map($qsos_result, $isVisitor=false) {
$this->load->library('qra');
if(!$this->load->is_loaded('Qra')) {
$this->load->library('Qra');
}
$json["markers"] = array();

View File

@@ -572,7 +572,9 @@ class Logbookadvanced_model extends CI_Model {
$query = $this->db->query($sql, array($value, $value2, $frequencyBand, $frequencyBandRx, json_decode($ids, true), $this->session->userdata('user_id')));
} else if ($column == 'COL_GRIDSQUARE') {
$this->load->library('Qra');
if(!$this->load->is_loaded('Qra')) {
$this->load->library('Qra');
}
$latlng=$this->qra->qra2latlong(trim(xss_clean($value) ?? ''));
if ($latlng[1] ?? '--' != '--') {
if (strpos(trim(xss_clean($value) ?? ''), ',') !== false) {