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

这个提交包含在:
Graham McIntire 2014-06-06 16:46:38 -05:00
父节点 58913ff03e
当前提交 6ea51800a9
共有 3 个文件被更改,包括 111 次插入111 次删除

查看文件

@ -9,14 +9,14 @@
| 'app_name' Name of the App 'Cloudlog' | 'app_name' Name of the App 'Cloudlog'
| 'app_version' Set by the dev team. | 'app_version' Set by the dev team.
| 'directory' directory where cloudlog is installed eg "logger" | '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_name'] = "Cloudlog";
$config['app_version'] = "0.1"; $config['app_version'] = "0.1";
$config['directory'] = "logbook"; $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 | 'table_name' SQL table where log can be found
| 'locator' Default locator used to calculate bearings/distance | '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['table_name'] = "TABLE_HRD_CONTACTS_V01";
$config['locator'] = ""; $config['locator'] = "";
$config['display_freq'] = true; $config['display_freq'] = true;
/* /*
@ -39,7 +39,7 @@ $config['display_freq'] = true;
| |
| 'use_auth' False turns all authentication off, best used when setting up | 'use_auth' False turns all authentication off, best used when setting up
| 'auth_table' MySQL Database Table defaults "users" | '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 | 2 = editor, 3 = api user, 99 = owner
| 'auth_level[]' Defines level titles | 'auth_level[]' Defines level titles
*/ */

查看文件

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

查看文件

@ -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) public function callsign($callsign)
{ {
ini_set ('display_errors', 1); 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 = @file_get_contents($jsonurl,0,null,null);
$json_output = json_decode($json); $json_output = json_decode($json);
if(isset($json_output)) { if(isset($json_output)) {
foreach ($json_output as $name => $callsign) { foreach ($json_output as $name => $callsign) {
if(isset($name)) { if(isset($name)) {
$data['callsign'] = strtoupper($name); $data['callsign'] = strtoupper($name);
} else { } else {
$data['callsign'] = $callsign; $data['callsign'] = $callsign;
} }
if (isset($callsign->first_name)) { if (isset($callsign->first_name)) {
$data['name'] = $callsign->first_name; $data['name'] = $callsign->first_name;
} else { } else {
$data['name'] = ""; $data['name'] = "";
} }
if(isset($callsign->gridsquare)) { if(isset($callsign->gridsquare)) {
$data['gridsquare'] = $callsign->gridsquare; $data['gridsquare'] = $callsign->gridsquare;
} else { } else {
$data['gridsquare'] = ""; $data['gridsquare'] = "";
} }
if(isset($callsign->city)) { if(isset($callsign->city)) {
$data['city'] = ucfirst(strtolower(($callsign->city))); $data['city'] = ucfirst(strtolower(($callsign->city)));
} else { } else {
$data['city'] = ""; $data['city'] = "";
} }
if (isset($callsign->latitude)) { if (isset($callsign->latitude)) {
$data['lat'] = ucfirst($callsign->latitude); $data['lat'] = ucfirst($callsign->latitude);
} else { } else {
$data['lat'] = ""; $data['lat'] = "";
} }
if (isset($callsign->longitude)) { if (isset($callsign->longitude)) {
$data['long'] = ucfirst($callsign->longitude); $data['long'] = ucfirst($callsign->longitude);
} else { } else {
$data['long'] = ""; $data['long'] = "";
} }
return $data; return $data;
} }
} }
} }
} }
/* End of file hamio.php */ /* End of file hamli.php */