Merge pull request #694 from jsb2092/master
Added support for lookups in services for more detailed information when logged in
这个提交包含在:
当前提交
fa1bb549ee
共有 5 个文件被更改,包括 143 次插入 和 101 次删除
|
|
@ -155,38 +155,8 @@ class Logbook extends CI_Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($this->config->item('callbook') == "qrz" && $this->config->item('qrz_username') != null && $this->config->item('qrz_password') != null)
|
$callbook = $this->logbook_model->loadCallBook($callsign, $this->config->item('use_fullname'));
|
||||||
{
|
|
||||||
// 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'));
|
|
||||||
$this->session->set_userdata('qrz_session_key', $qrz_session_key);
|
|
||||||
}
|
|
||||||
|
|
||||||
$callbook = $this->qrz->search($callsign, $this->session->userdata('qrz_session_key'));
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($this->config->item('callbook') == "hamqth" && $this->config->item('hamqth_username') != null && $this->config->item('hamqth_password') != null)
|
|
||||||
{
|
|
||||||
// Load the HamQTH library
|
|
||||||
$this->load->library('hamqth');
|
|
||||||
|
|
||||||
if(!$this->session->userdata('hamqth_session_key')) {
|
|
||||||
$hamqth_session_key = $this->hamqth->session($this->config->item('hamqth_username'), $this->config->item('hamqth_password'));
|
|
||||||
$this->session->set_userdata('hamqth_session_key', $hamqth_session_key);
|
|
||||||
}
|
|
||||||
|
|
||||||
$callbook = $this->hamqth->search($callsign, $this->session->userdata('hamqth_session_key'));
|
|
||||||
|
|
||||||
// If HamQTH session has expired, start a new session and retry the search.
|
|
||||||
if($callbook['error'] == "Session does not exist or expired") {
|
|
||||||
$hamqth_session_key = $this->hamqth->session($this->config->item('hamqth_username'), $this->config->item('hamqth_password'));
|
|
||||||
$this->session->set_userdata('hamqth_session_key', $hamqth_session_key);
|
|
||||||
$callbook = $this->hamqth->search($callsign, $this->session->userdata('hamqth_session_key'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($callbook))
|
if (isset($callbook))
|
||||||
{
|
{
|
||||||
|
|
@ -553,8 +523,14 @@ class Logbook extends CI_Controller {
|
||||||
$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= $this->qrz->search($id, $this->session->userdata('qrz_session_key'), $this->config->item('use_fullname'));
|
||||||
|
|
||||||
$data['callsign'] = $this->qrz->search($id, $this->session->userdata('qrz_session_key'));
|
if (empty($data['callsign']))
|
||||||
|
{
|
||||||
|
$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 = $this->qrz->search($id, $this->session->userdata('qrz_session_key'), $this->config->item('use_fullname'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// There's no hamli integration? Disabled for now.
|
// There's no hamli integration? Disabled for now.
|
||||||
|
|
@ -611,7 +587,7 @@ class Logbook extends CI_Controller {
|
||||||
$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'), $this->config->item('use_fullname'));
|
||||||
} else {
|
} else {
|
||||||
// Lookup using hamli
|
// Lookup using hamli
|
||||||
$this->load->library('hamli');
|
$this->load->library('hamli');
|
||||||
|
|
|
||||||
|
|
@ -56,9 +56,10 @@ class Hamqth {
|
||||||
|
|
||||||
public function search($callsign, $key)
|
public function search($callsign, $key)
|
||||||
{
|
{
|
||||||
|
$data = null;
|
||||||
|
try {
|
||||||
// URL to the XML Source
|
// URL to the XML Source
|
||||||
$xml_feed_url = 'https://www.hamqth.com/xml.php?id='.$key.'&callsign='.$callsign.'&prg=cloudlog';
|
$xml_feed_url = 'https://www.hamqth.com/xml.php?id=' . $key . '&callsign=' . $callsign . '&prg=cloudlog';
|
||||||
|
|
||||||
// CURL Functions
|
// CURL Functions
|
||||||
$ch = curl_init();
|
$ch = curl_init();
|
||||||
|
|
@ -70,27 +71,29 @@ class Hamqth {
|
||||||
|
|
||||||
// Create XML object
|
// Create XML object
|
||||||
$xml = simplexml_load_string($xml);
|
$xml = simplexml_load_string($xml);
|
||||||
|
if (empty($xml)) return;
|
||||||
|
|
||||||
// Return Required Fields
|
// Return Required Fields
|
||||||
$data['callsign'] = (string) $xml->search->callsign;
|
$data['callsign'] = (string)$xml->search->callsign;
|
||||||
$data['name'] = (string) $xml->search->nick;
|
$data['name'] = (string)$xml->search->nick;
|
||||||
$data['gridsquare'] = (string) $xml->search->grid;
|
$data['gridsquare'] = (string)$xml->search->grid;
|
||||||
$data['city'] = (string) $xml->search->adr_city;
|
$data['city'] = (string)$xml->search->adr_city;
|
||||||
$data['lat'] = (string) $xml->search->latitude;
|
$data['lat'] = (string)$xml->search->latitude;
|
||||||
$data['long'] = (string) $xml->search->longitude;
|
$data['long'] = (string)$xml->search->longitude;
|
||||||
$data['iota'] = (string) $xml->search->iota;
|
$data['iota'] = (string)$xml->search->iota;
|
||||||
$data['us_state'] = (string) $xml->search->us_state;
|
$data['us_state'] = (string)$xml->search->us_state;
|
||||||
$data['us_county'] = (string) $xml->search->us_county;
|
$data['us_county'] = (string)$xml->search->us_county;
|
||||||
$data['error'] = (string) $xml->session->error;
|
$data['error'] = (string)$xml->session->error;
|
||||||
|
|
||||||
if($xml->search->country == "United States") {
|
if ($xml->search->country == "United States") {
|
||||||
$data['state'] = (string) $xml->search->us_state;
|
$data['state'] = (string)$xml->search->us_state;
|
||||||
$data['us_county'] = (string) $xml->search->us_county;
|
$data['us_county'] = (string)$xml->search->us_county;
|
||||||
} else {
|
} else {
|
||||||
$data['state'] = null;
|
$data['state'] = null;
|
||||||
$data['us_county'] = null;
|
$data['us_county'] = null;
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -54,11 +54,12 @@ class Qrz {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function search($callsign, $key)
|
public function search($callsign, $key, $use_fullname)
|
||||||
{
|
{
|
||||||
|
$data = null;
|
||||||
|
try {
|
||||||
// URL to the XML Source
|
// URL to the XML Source
|
||||||
$xml_feed_url = 'http://xmldata.qrz.com/xml/current/?s='.$key.';callsign='.$callsign.'';
|
$xml_feed_url = 'http://xmldata.qrz.com/xml/current/?s=' . $key . ';callsign=' . $callsign . '';
|
||||||
|
|
||||||
// CURL Functions
|
// CURL Functions
|
||||||
$ch = curl_init();
|
$ch = curl_init();
|
||||||
|
|
@ -70,26 +71,34 @@ class Qrz {
|
||||||
|
|
||||||
// Create XML object
|
// Create XML object
|
||||||
$xml = simplexml_load_string($xml);
|
$xml = simplexml_load_string($xml);
|
||||||
|
if (empty($xml)) return;
|
||||||
|
|
||||||
// Return Required Fields
|
// Return Required Fields
|
||||||
$data['callsign'] = (string) $xml->Callsign->call;
|
$data['callsign'] = (string)$xml->Callsign->call;
|
||||||
$data['name'] = (string) $xml->Callsign->fname;
|
|
||||||
$data['gridsquare'] = (string) $xml->Callsign->grid;
|
|
||||||
$data['city'] = (string) $xml->Callsign->addr2;
|
|
||||||
$data['lat'] = (string) $xml->Callsign->lat;
|
|
||||||
$data['long'] = (string) $xml->Callsign->lon;
|
|
||||||
$data['iota'] = (string) $xml->Callsign->iota;
|
|
||||||
$data['qslmgr'] = (string) $xml->Callsign->qslmgr;
|
|
||||||
|
|
||||||
if($xml->Callsign->country == "United States") {
|
if ($use_fullname === true) {
|
||||||
$data['state'] = (string) $xml->Callsign->state;
|
$data['name'] = (string)$xml->Callsign->fname. ' ' . (string)$xml->Callsign->name;
|
||||||
$data['us_county'] = (string) $xml->Callsign->county;
|
} else {
|
||||||
|
$data['name'] = (string)$xml->Callsign->fname;
|
||||||
|
}
|
||||||
|
$data['name'] = trim($data['name']);
|
||||||
|
$data['gridsquare'] = (string)$xml->Callsign->grid;
|
||||||
|
$data['city'] = (string)$xml->Callsign->addr2;
|
||||||
|
$data['lat'] = (string)$xml->Callsign->lat;
|
||||||
|
$data['long'] = (string)$xml->Callsign->lon;
|
||||||
|
$data['iota'] = (string)$xml->Callsign->iota;
|
||||||
|
$data['qslmgr'] = (string)$xml->Callsign->qslmgr;
|
||||||
|
|
||||||
|
if ($xml->Callsign->country == "United States") {
|
||||||
|
$data['state'] = (string)$xml->Callsign->state;
|
||||||
|
$data['us_county'] = (string)$xml->Callsign->county;
|
||||||
} else {
|
} else {
|
||||||
$data['state'] = null;
|
$data['state'] = null;
|
||||||
$data['us_county'] = null;
|
$data['us_county'] = null;
|
||||||
}
|
}
|
||||||
|
} finally {
|
||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1594,7 +1594,7 @@ class Logbook_model extends CI_Model {
|
||||||
$entity = $this->get_entity($record['dxcc']);
|
$entity = $this->get_entity($record['dxcc']);
|
||||||
$dxcc = array($record['dxcc'], $entity['name']);
|
$dxcc = array($record['dxcc'], $entity['name']);
|
||||||
} else {
|
} else {
|
||||||
$dxcc = NULL;
|
$dxcc = $this->check_dxcc_table($record['call'], $time_off);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$dxcc = $this->check_dxcc_table($record['call'], $time_off);
|
$dxcc = $this->check_dxcc_table($record['call'], $time_off);
|
||||||
|
|
@ -1607,8 +1607,10 @@ class Logbook_model extends CI_Model {
|
||||||
if(isset($record['country'])) {
|
if(isset($record['country'])) {
|
||||||
$country = $record['country'];
|
$country = $record['country'];
|
||||||
} else {
|
} else {
|
||||||
|
if (isset($dxcc[1])) {
|
||||||
$country = ucwords(strtolower($dxcc[1]));
|
$country = ucwords(strtolower($dxcc[1]));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// RST recevied
|
// RST recevied
|
||||||
if(isset($record['rst_rcvd'])) {
|
if(isset($record['rst_rcvd'])) {
|
||||||
|
|
@ -2337,6 +2339,54 @@ class Logbook_model extends CI_Model {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function loadCallBook($callsign, $use_fullname=false)
|
||||||
|
{
|
||||||
|
$callbook = null;
|
||||||
|
try {
|
||||||
|
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'));
|
||||||
|
$this->session->set_userdata('qrz_session_key', $qrz_session_key);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$callbook = $this->qrz->search($callsign, $this->session->userdata('qrz_session_key'), $use_fullname);
|
||||||
|
|
||||||
|
// if we got nothing, it's probably because our session key is invalid, try again
|
||||||
|
if (!isset($callbook['callsign']))
|
||||||
|
{
|
||||||
|
$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'), $use_fullname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->config->item('callbook') == "hamqth" && $this->config->item('hamqth_username') != null && $this->config->item('hamqth_password') != null) {
|
||||||
|
// Load the HamQTH library
|
||||||
|
$this->load->library('hamqth');
|
||||||
|
|
||||||
|
if (!$this->session->userdata('hamqth_session_key')) {
|
||||||
|
$hamqth_session_key = $this->hamqth->session($this->config->item('hamqth_username'), $this->config->item('hamqth_password'));
|
||||||
|
$this->session->set_userdata('hamqth_session_key', $hamqth_session_key);
|
||||||
|
}
|
||||||
|
|
||||||
|
$callbook = $this->hamqth->search($callsign, $this->session->userdata('hamqth_session_key'));
|
||||||
|
|
||||||
|
// If HamQTH session has expired, start a new session and retry the search.
|
||||||
|
if ($callbook['error'] == "Session does not exist or expired") {
|
||||||
|
$hamqth_session_key = $this->hamqth->session($this->config->item('hamqth_username'), $this->config->item('hamqth_password'));
|
||||||
|
$this->session->set_userdata('hamqth_session_key', $hamqth_session_key);
|
||||||
|
$callbook = $this->hamqth->search($callsign, $this->session->userdata('hamqth_session_key'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
return $callbook;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public function update_all_station_ids() {
|
public function update_all_station_ids() {
|
||||||
|
|
||||||
|
|
@ -2464,4 +2514,6 @@ function validateADIFDate($date, $format = 'Ymd')
|
||||||
$d = DateTime::createFromFormat($format, $date);
|
$d = DateTime::createFromFormat($format, $date);
|
||||||
return $d && $d->format($format) == $date;
|
return $d && $d->format($format) == $date;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -40,10 +40,12 @@ $config['display_freq'] = false;
|
||||||
|
|
|
|
||||||
| 'qrz_username' QRZ.com user login
|
| 'qrz_username' QRZ.com user login
|
||||||
| 'qrz_password' QRZ.com user password
|
| 'qrz_password' QRZ.com user password
|
||||||
|
| 'use_fullname' Get full names from QRZ, may not be GDPR compliant
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$config['qrz_username'] = "";
|
$config['qrz_username'] = "";
|
||||||
$config['qrz_password'] = "";
|
$config['qrz_password'] = "";
|
||||||
|
$config['use_fullname'] = false;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
正在加载…
在新工单中引用