Fix name change from ham.io to ham.li callsign lookup

pull/167/head
Graham McIntire 2014-06-06 16:46:38 -05:00
rodzic 58913ff03e
commit 6ea51800a9
3 zmienionych plików z 111 dodań i 111 usunięć

Wyświetl plik

@ -9,14 +9,14 @@
| 'app_name' Name of the App 'Cloudlog'
| 'app_version' Set by the dev team.
| 'directory' directory where cloudlog is installed eg "logger"
| 'callbook' Selects which Callbook lookup to use defaults "hamio" but supports "qrz"
| 'callbook' Selects which Callbook lookup to use defaults "hamli" but supports "qrz"
*/
$config['app_name'] = "Cloudlog";
$config['app_version'] = "0.1";
$config['directory'] = "logbook";
$config['callbook'] = "qrz"; // Options are hamio or qrz
$config['callbook'] = "qrz"; // Options are hamli or qrz
/*
|--------------------------------------------------------------------------
@ -25,11 +25,11 @@ $config['callbook'] = "qrz"; // Options are hamio or qrz
|
| 'table_name' SQL table where log can be found
| 'locator' Default locator used to calculate bearings/distance
| 'display_freq' Show or Hide frequnecy info
| 'display_freq' Show or Hide frequnecy info
*/
$config['table_name'] = "TABLE_HRD_CONTACTS_V01";
$config['locator'] = "";
$config['table_name'] = "TABLE_HRD_CONTACTS_V01";
$config['locator'] = "";
$config['display_freq'] = true;
/*
@ -39,7 +39,7 @@ $config['display_freq'] = true;
|
| 'use_auth' False turns all authentication off, best used when setting up
| 'auth_table' MySQL Database Table defaults "users"
| 'auth_mode' Minimum user level required 0 = anonymous, 1 = viewer,
| 'auth_mode' Minimum user level required 0 = anonymous, 1 = viewer,
| 2 = editor, 3 = api user, 99 = owner
| 'auth_level[]' Defines level titles
*/

Wyświetl plik

@ -23,9 +23,9 @@ class Logbook extends CI_Controller {
$config['full_tag_close'] = '';
$config['cur_tag_open'] = '<strong class="active"><a href="">';
$config['cur_tag_close'] = '</a></strong>';
$this->pagination->initialize($config);
//load the model and get results
$this->load->model('logbook_model');
$data['results'] = $this->logbook_model->get_qsos($config['per_page'],$this->uri->segment(3));
@ -36,20 +36,20 @@ class Logbook extends CI_Controller {
$qra_position = $this->qra->qra2latlong($this->session->userdata('user_locator'));
$data['qra'] = "set";
$data['qra_lat'] = $qra_position[0];
$data['qra_lng'] = $qra_position[1];
$data['qra_lng'] = $qra_position[1];
} else {
$data['qra'] = "none";
}
// load the view
$data['page_title'] = "Logbook";
$this->load->view('layout/header', $data);
$this->load->view('view_log/index');
$this->load->view('layout/footer');
}
/* Used to generate maps for displaying on /logbook/ */
@ -70,7 +70,7 @@ class Logbook extends CI_Controller {
echo ",";
}
if($row->COL_SAT_NAME != null) {
if($row->COL_SAT_NAME != null) {
echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."<br />Date/Time: ".$row->COL_TIME_ON."<br />SAT: ".$row->COL_SAT_NAME."<br />Mode: ".$row->COL_MODE."\",\"label\":\"".$row->COL_CALL."\"}";
} else {
echo "{\"lat\":\"".$stn_loc[0]."\",\"lng\":\"".$stn_loc[1]."\", \"html\":\"Callsign: ".$row->COL_CALL."<br />Date/Time: ".$row->COL_TIME_ON."<br />Band: ".$row->COL_BAND."<br />Mode: ".$row->COL_MODE."\",\"label\":\"".$row->COL_CALL."\"}";
@ -84,7 +84,7 @@ class Logbook extends CI_Controller {
FROM dxcc
WHERE prefix = SUBSTRING( \''.$row->COL_CALL.'\', 1, LENGTH( prefix ) )
ORDER BY LENGTH( prefix ) DESC
LIMIT 1
LIMIT 1
');
foreach ($query->result() as $dxcc) {
@ -100,19 +100,19 @@ class Logbook extends CI_Controller {
echo "]";
echo "}";
}
function view($id) {
$this->load->model('user_model');
if(!$this->user_model->authorize($this->config->item('auth_mode'))) { return; }
$this->load->library('qra');
$this->db->where('COL_PRIMARY_KEY', $id);
$this->db->where('COL_PRIMARY_KEY', $id);
$data['query'] = $this->db->get($this->config->item('table_name'));
$this->load->view('view_log/qso', $data);
}
function callsign_qra($qra) {
$this->load->model('user_model');
if(!$this->user_model->authorize($this->config->item('auth_mode'))) { return; }
@ -124,24 +124,24 @@ class Logbook extends CI_Controller {
} else {
if ($this->config->item('callbook') == "qrz" && $this->config->item('qrz_username') != null && $this->config->item('qrz_password') != null) {
// Lookup using QRZ
$this->load->library('qrz');
if(!$this->session->userdata('qrz_session_key')) {
$qrz_session_key = $this->qrz->session($this->config->item('qrz_username'), $this->config->item('qrz_password'));
$qrz_session_key = $this->qrz->session($this->config->item('qrz_username'), $this->config->item('qrz_password'));
$this->session->set_userdata('qrz_session_key', $qrz_session_key);
}
$callbook = $this->qrz->search($qra, $this->session->userdata('qrz_session_key'));
echo $callbook['gridsquare'];
} else {
// Lookup using hamio
$this->load->library('hamio');
$callbook = $this->hamio->callsign($qra);
echo $callbook['gridsquare'];
} else {
// Lookup using hamli
$this->load->library('hamli');
$callbook = $this->hamli->callsign($qra);
echo $callbook['gridsquare'];
}
}
}
@ -149,44 +149,44 @@ class Logbook extends CI_Controller {
function callsign_qth($callsign) {
if ($this->config->item('callbook') == "qrz" && $this->config->item('qrz_username') != null && $this->config->item('qrz_password') != null) {
// Lookup using QRZ
$this->load->library('qrz');
if(!$this->session->userdata('qrz_session_key')) {
$qrz_session_key = $this->qrz->session($this->config->item('qrz_username'), $this->config->item('qrz_password'));
$qrz_session_key = $this->qrz->session($this->config->item('qrz_username'), $this->config->item('qrz_password'));
$this->session->set_userdata('qrz_session_key', $qrz_session_key);
}
$callbook = $this->qrz->search($callsign, $this->session->userdata('qrz_session_key'));
echo $callbook['city'];
} else {
// Lookup using hamio
$this->load->library('hamio');
$callbook = $this->hamio->callsign($callsign);
echo $callbook['city'];
} else {
// Lookup using hamli
$this->load->library('hamli');
$callbook = $this->hamli->callsign($callsign);
echo $callbook['city'];
}
}
function callsign_iota($callsign) {
if ($this->config->item('callbook') == "qrz" && $this->config->item('qrz_username') != null && $this->config->item('qrz_password') != null) {
// Lookup using QRZ
$this->load->library('qrz');
if(!$this->session->userdata('qrz_session_key')) {
$qrz_session_key = $this->qrz->session($this->config->item('qrz_username'), $this->config->item('qrz_password'));
$qrz_session_key = $this->qrz->session($this->config->item('qrz_username'), $this->config->item('qrz_password'));
$this->session->set_userdata('qrz_session_key', $qrz_session_key);
}
$callbook = $this->qrz->search($callsign, $this->session->userdata('qrz_session_key'));
echo $callbook['iota'];
}
}
function callsign_name($callsign) {
$this->load->model('user_model');
if(!$this->user_model->authorize($this->config->item('auth_mode'))) { return; }
@ -198,36 +198,36 @@ class Logbook extends CI_Controller {
} else {
if ($this->config->item('callbook') == "qrz" && $this->config->item('qrz_username') != null && $this->config->item('qrz_password') != null) {
// Lookup using QRZ
$this->load->library('qrz');
if(!$this->session->userdata('qrz_session_key')) {
$qrz_session_key = $this->qrz->session($this->config->item('qrz_username'), $this->config->item('qrz_password'));
$qrz_session_key = $this->qrz->session($this->config->item('qrz_username'), $this->config->item('qrz_password'));
$this->session->set_userdata('qrz_session_key', $qrz_session_key);
}
$callbook = $this->qrz->search($callsign, $this->session->userdata('qrz_session_key'));
echo $callbook['name'];
} else {
// Lookup using hamio
$this->load->library('hamio');
$callbook = $this->hamio->callsign($callsign);
// Lookup using hamli
$this->load->library('hamli');
echo $callbook['name'];
$callbook = $this->hamli->callsign($callsign);
echo $callbook['name'];
}
}
}
function partial($id) {
$this->load->model('user_model');
if(!$this->user_model->authorize($this->config->item('auth_mode'))) { return; }
$this->db->like('COL_CALL', $id);
$this->db->order_by("COL_TIME_ON", "desc");
$this->db->like('COL_CALL', $id);
$this->db->order_by("COL_TIME_ON", "desc");
$this->db->limit(16);
$query = $this->db->get($this->config->item('table_name'));
if ($query->num_rows() > 0)
{
echo "<h2>QSOs Matches with ".strtoupper($id)."</h2>";
@ -257,85 +257,85 @@ class Logbook extends CI_Controller {
}
echo "</table>";
} else {
$this->load->library('hamio');
$data['callsign'] = $this->hamio->callsign($id);
$this->load->library('hamli');
$data['callsign'] = $this->hamli->callsign($id);
$data['id'] = strtoupper($id);
$this->load->view('search/result', $data);
}
}
function search_result($id) {
$this->load->model('user_model');
if(!$this->user_model->authorize($this->config->item('auth_mode'))) { return; }
$this->db->like('COL_CALL', $id);
$this->db->or_like('COL_GRIDSQUARE', $id);
$this->db->order_by("COL_TIME_ON", "desc");
$this->db->or_like('COL_GRIDSQUARE', $id);
$this->db->order_by("COL_TIME_ON", "desc");
$query = $this->db->get($this->config->item('table_name'));
if ($query->num_rows() > 0)
{
$data['results'] = $query;
$data['results'] = $query;
$this->load->view('search/result_search.php', $data);
} else {
$this->load->model('search');
$iota_search = $this->search->callsign_iota($id);
if ($iota_search->num_rows() > 0)
{
$data['results'] = $iota_search;
$data['results'] = $iota_search;
$this->load->view('search/result_search.php', $data);
} else {
if ($this->config->item('callbook') == "qrz" && $this->config->item('qrz_username') != null && $this->config->item('qrz_password') != null) {
// Lookup using QRZ
$this->load->library('qrz');
if(!$this->session->userdata('qrz_session_key')) {
$qrz_session_key = $this->qrz->session($this->config->item('qrz_username'), $this->config->item('qrz_password'));
$qrz_session_key = $this->qrz->session($this->config->item('qrz_username'), $this->config->item('qrz_password'));
$this->session->set_userdata('qrz_session_key', $qrz_session_key);
}
$data['callsign'] = $this->qrz->search($id, $this->session->userdata('qrz_session_key'));
} else {
// Lookup using hamio
$this->load->library('hamio');
$data['callsign'] = $this->hamio->callsign($id);
}
// Lookup using hamli
$this->load->library('hamli');
$data['callsign'] = $this->hamli->callsign($id);
}
$data['id'] = strtoupper($id);
$this->load->view('search/result', $data);
$this->load->view('search/result', $data);
}
}
}
// Find DXCC
function find_dxcc($callsign) {
$this->load->model('dxcc');
$dxccinfo = $this->dxcc->info($callsign);
$dxccinfo = $this->dxcc->info($callsign);
foreach ($dxccinfo->result() as $row)
{
echo ucfirst(strtolower($row->name));
}
}
/* return station bearing */
function bearing() {
$this->load->library('Qra');
if($this->uri->segment(3) != null) {
if($this->session->userdata('user_locator') != null){
$mylocator = $this->session->userdata('user_locator');
@ -344,8 +344,8 @@ class Logbook extends CI_Controller {
}
$bearing = $this->qra->bearing($mylocator, $this->uri->segment(3));
echo $bearing;
}
}
}
}
}

Wyświetl plik

@ -1,65 +1,65 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Hamio {
class Hamli {
/*
Communicates with the ham.io API functions
Communicates with the ham.li API functions
*/
public function callsign($callsign)
{
ini_set ('display_errors', 1);
$jsonurl = "http://search.ham.io/api/call/".$callsign;
$jsonurl = "http://search.ham.li/api/call/".$callsign;
$json = @file_get_contents($jsonurl,0,null,null);
$json_output = json_decode($json);
if(isset($json_output)) {
foreach ($json_output as $name => $callsign) {
if(isset($name)) {
$data['callsign'] = strtoupper($name);
} else {
$data['callsign'] = $callsign;
}
if (isset($callsign->first_name)) {
$data['name'] = $callsign->first_name;
if (isset($callsign->first_name)) {
$data['name'] = $callsign->first_name;
} else {
$data['name'] = "";
}
if(isset($callsign->gridsquare)) {
$data['gridsquare'] = $callsign->gridsquare;
} else {
$data['gridsquare'] = "";
}
if(isset($callsign->city)) {
$data['city'] = ucfirst(strtolower(($callsign->city)));
} else {
$data['city'] = "";
}
if (isset($callsign->latitude)) {
$data['lat'] = ucfirst($callsign->latitude);
} else {
$data['lat'] = "";
}
if (isset($callsign->longitude)) {
$data['long'] = ucfirst($callsign->longitude);
} else {
$data['long'] = "";
}
return $data;
}
}
}
}
/* End of file hamio.php */
/* End of file hamli.php */