Added code to import lotw-useractivity.csv for displaying if users on lotw

The csv can be imported by using /index.php/lotw/load_users need to impliment frontend next
pull/296/head
Peter Goodhall 2019-06-16 14:31:23 +01:00
rodzic ec5c356cc0
commit 6cfbf774cb
4 zmienionych plików z 96 dodań i 1 usunięć

Wyświetl plik

@ -21,7 +21,7 @@ $config['migration_enabled'] = TRUE;
| be upgraded / downgraded to.
|
*/
$config['migration_version'] = 15;
$config['migration_version'] = 16;
/*
|--------------------------------------------------------------------------

Wyświetl plik

@ -294,4 +294,38 @@ class Lotw extends CI_Controller {
}
}
/*
Load the ARRL LOTW User Activity CSV into LOTW User Table for cross checking when logging
*/
function load_users() {
set_time_limit(0);
$this->load->model('lotw_user');
$row = 1;
if (($handle = fopen("https://lotw.arrl.org/lotw-user-activity.csv", "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$num = count($data);
$row++;
if(isset($data[2])) {
$callsign = $data[0];
$upload_date = $data[1]." ".$data[2];
$this->lotw_user->add_lotwuser($callsign, $upload_date);
}
}
fclose($handle);
}
}
/*
Check if callsign is an active LOTW user and return whether its true or not
*/
function lotw_usercheck($callsign) {
$this->load->model('lotw_user');
}
} // end class

Wyświetl plik

@ -0,0 +1,33 @@
<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Migration_lotwusers extends CI_Migration {
public function up()
{
$this->dbforge->add_field(array(
'id' => array(
'type' => 'INT',
'constraint' => 5,
'unsigned' => TRUE,
'auto_increment' => TRUE
),
'callsign' => array(
'type' => 'VARCHAR',
'constraint' => '100',
),
'upload_date' => array(
'type' => 'datetime',
'null' => TRUE,
),
));
$this->dbforge->add_key('id', TRUE);
$this->dbforge->create_table('lotw_userlist');
}
public function down()
{
$this->dbforge->drop_table('lotw_userlist');
}
}

Wyświetl plik

@ -0,0 +1,28 @@
<?php
class Lotw_user extends CI_Model {
function __construct()
{
// Call the Model constructor
parent::__construct();
}
function empty_table($table) {
$this->db->empty_table($table);
}
function add_lotwuser($callsign, $date) {
$data = array(
'callsign' => $callsign,
'upload_date' => $date
);
$this->db->insert('lotw_userlist', $data);
}
}
?>