Added function to update the cty db tables

pull/109/head
Peter Goodhall 2012-11-19 22:24:10 +00:00
rodzic 633b270f13
commit cfd307364c
5 zmienionych plików z 154222 dodań i 3 usunięć

Wyświetl plik

@ -16,7 +16,7 @@ $config['app_name'] = "Cloudlog";
$config['app_version'] = "0.1";
$config['directory'] = "logbook";
$config['callbook'] = "hamio"; // Options are hamio or qrz
$config['callbook'] = "qrz"; // Options are hamio or qrz
/*
|--------------------------------------------------------------------------

Wyświetl plik

@ -8,6 +8,9 @@ class adif extends CI_Controller {
{
parent::__construct();
$this->load->helper(array('form', 'url'));
$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'); }
}
/* Shows Export Views */
@ -138,5 +141,4 @@ class adif extends CI_Controller {
}
/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */
/* End of file adif.php */

Wyświetl plik

@ -0,0 +1,113 @@
<?php
class Update extends CI_Controller {
/*
Controls Updating Elements of Cloudlog
Functions:
dxcc
dxcc_exceptions
*/
public function index()
{
echo 'show fancy html page';
}
// Updates the DXCC
public function dxcc() {
// Set timeout to unlimited
set_time_limit(0);
// Load Database connectors
$this->load->model('dxcc');
// Load the cty file
$xml_data = simplexml_load_file("updates/cty.xml");
$this->dxcc->empty_table("dxcc");
echo "<h2>Prefix List</h2>";
foreach ($xml_data->prefixes as $prefixs) {
foreach ($prefixs->prefix as $callsign) {
echo $callsign->call." ".$callsign->entity;
if(!$callsign->cqz) {
$data = array(
'prefix' => (string) $callsign->call,
'name' => (string) $callsign->entity,
);
} else {
$data = array(
'prefix' => (string) $callsign->call,
'name' => (string) $callsign->entity,
'cqz' => $callsign->cqz,
'ituz' => $callsign->ituz,
'cont' => (string) $callsign->cont,
'long' => $callsign->long,
'lat' => $callsign->lat
);
}
$this->db->insert('dxcc', $data);
echo " Inserted <br />";
}
}
}
public function dxcc_exceptions()
{
set_time_limit(0);
// Load Database connectors
$this->load->model('dxcc');
// Load the cty file
$xml_data = simplexml_load_file("updates/cty.xml");
// empty table
$this->dxcc->empty_table("dxccexceptions");
echo "<h2>Exceptions</h2>";
foreach ($xml_data->exceptions as $exceptions) {
foreach ($exceptions->exception as $callsign) {
echo $callsign->call." ".$callsign->entity;
if(!$callsign->start) {
$data = array(
'prefix' => (string) $callsign->call,
'name' => (string) $callsign->entity,
'cqz' => $callsign->cqz,
'ituz' => $callsign->ituz,
'cont' => (string) $callsign->cont,
'long' => $callsign->long,
'lat' => $callsign->lat
);
} else {
$start = date('Y-m-d h:i', $timestamp);
$end = date('Y-m-d h:i', $timestamp);
$data = array(
'prefix' => (string) $callsign->call,
'name' => (string) $callsign->entity,
'cqz' => $callsign->cqz,
'ituz' => $callsign->ituz,
'cont' => (string) $callsign->cont,
'long' => $callsign->long,
'lat' => $callsign->lat,
'start' => $start,
'end' => $end
);
}
$this->db->insert('dxccexceptions', $data);
echo " Inserted <br />";
}
}
}
}
?>

Wyświetl plik

@ -36,5 +36,9 @@ class DXCC extends CI_Model {
return $query;
}
}
function empty_table($table) {
$this->db->empty_table($table);
}
}
?>

154100
updates/cty.xml 100644

Plik diff jest za duży Load Diff