Merge pull request #2392 from int2001/tidyup
removed a lot of unused (and dangerous) functions
这个提交包含在:
当前提交
8a8abcf466
共有 11 个文件被更改,包括 33 次插入 和 682 次删除
|
|
@ -151,262 +151,8 @@ class API extends CI_Controller {
|
|||
}
|
||||
}
|
||||
|
||||
// FUNCTION: search()
|
||||
// Handle search requests
|
||||
/*
|
||||
Okay, so here's how it works in a nutshell...
|
||||
|
||||
*******************************************************************
|
||||
Because this is effectively just a filter between the query string
|
||||
and a MySQL statement, if done wrong we're just asking for pain.
|
||||
|
||||
DO NOT alter any of the filtering statements without fully
|
||||
understanding what you're doing. CodeIgniter provides some
|
||||
protection against unwanted characters in the query string, but
|
||||
this should in no way be relied upon for safety.
|
||||
*******************************************************************
|
||||
|
||||
Example query:-
|
||||
.../search/query[Call~M0*(and)(Locator~I*(or)Locator~J*)]/limit[10]/fields[distinct(Call),Locator]/order[Call(asc)]
|
||||
|
||||
There's four parts to this query, separated with forward slashes. It's effectively a heavily-sanitised
|
||||
MySQL query, hence the hideous search and replace code blocks below.
|
||||
|
||||
FIELDS
|
||||
------
|
||||
Straightforward - input is sanitised and passed on - in the example, this ends up as "DISTINCT (Call),Locator",
|
||||
which is then the first argument to 'SELECT'
|
||||
|
||||
QUERY
|
||||
-----
|
||||
This forms the 'WHERE' clause.
|
||||
|
||||
* '(and)' and '(or)' are expanded out to ' AND ' and ' OR '
|
||||
* Parentheses are preserved
|
||||
* '~' is expanded out to ' LIKE '
|
||||
* '*' is translated to '%'
|
||||
* Values are encapsulated in quote marks
|
||||
|
||||
So in the example, this translates to "WHERE Call LIKE 'M0%' AND (Locator LIKE 'I%' OR Locator LIKE 'J%')"
|
||||
|
||||
ORDER
|
||||
-----
|
||||
Sanitised, so our example ends up as "ORDER BY Call ASC".
|
||||
|
||||
LIMIT
|
||||
-----
|
||||
Straightforward - what's between the square brackets is passed as an argument to 'LIMIT'
|
||||
|
||||
Finally, once this has been done, each field name is translated to the MySQL column name.
|
||||
*/
|
||||
function search()
|
||||
{
|
||||
// Load the API and Logbook models
|
||||
$this->load->model('api_model');
|
||||
$this->load->model('logbook_model');
|
||||
$this->load->model('user_model');
|
||||
|
||||
$arguments = $this->_retrieve();
|
||||
print_r($arguments);
|
||||
return;
|
||||
|
||||
if((!$this->user_model->authorize(3)) && ($this->api_model->authorize($arguments['key']) == 0)) {
|
||||
$this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard');
|
||||
}
|
||||
|
||||
$this->api_model->update_last_used($obj['key']);
|
||||
|
||||
// Retrieve the arguments from the query string
|
||||
$data['data']['format'] = $arguments['format'];
|
||||
|
||||
// Call the parser within the API model to build the query
|
||||
$query = $this->api_model->select_parse($arguments);
|
||||
|
||||
// Execute the query, and retrieve the results
|
||||
$s = $this->logbook_model->api_search_query($query);
|
||||
$a = 0;
|
||||
|
||||
// Print query results using original column names and exit
|
||||
if ($arguments['format'] == 'original'){
|
||||
$results = array();
|
||||
foreach($s['results']->result() as $row){
|
||||
//print_r($row);
|
||||
array_push($results, $row);
|
||||
}
|
||||
|
||||
print json_encode($results);
|
||||
return;
|
||||
}
|
||||
|
||||
if(isset($s['results'])) {
|
||||
$results = $s['results'];
|
||||
|
||||
// Cycle through the results, and translate between MySQL column names
|
||||
// and more friendly, descriptive names
|
||||
if($results->num_rows() != 0)
|
||||
{
|
||||
foreach ($results->result() as $row) {
|
||||
$record = (array)$row;
|
||||
$r[$a]['rid'] = $a;
|
||||
while (list($key, $val) = each($record)) {
|
||||
$r[$a][$this->api_model->name($key)] = $val;
|
||||
}
|
||||
$a++;
|
||||
}
|
||||
// Add the result record to the main results array
|
||||
$data['data']['search_Result']['results'] = $r;
|
||||
}
|
||||
else
|
||||
{
|
||||
// We've got no results, so make this empty for completeness
|
||||
$data['data']['search_Result']['results'] = "";
|
||||
}
|
||||
} else {
|
||||
$data['data']['error'] = $s['error'];
|
||||
$data['data']['search_Result']['results'] = "";
|
||||
}
|
||||
|
||||
// Add some debugging information to the XML output
|
||||
$data['data']['queryInfo']['call'] = "search";
|
||||
$data['data']['queryInfo']['dbQuery'] = $s['query'];
|
||||
$data['data']['queryInfo']['numResults'] = $a;
|
||||
$data['data']['queryInfo']['executionTime'] = $s['time'];
|
||||
|
||||
// Load the XML output view
|
||||
$this->load->view('api/index', $data);
|
||||
}
|
||||
|
||||
/*
|
||||
* version of search that is callable internally
|
||||
* $arguments is an array of columns to query
|
||||
*/
|
||||
function api_search($arguments){
|
||||
// Load the API and Logbook models
|
||||
$this->load->model('api_model');
|
||||
$this->load->model('logbook_model');
|
||||
$this->load->model('user_model');
|
||||
|
||||
if((!$this->user_model->authorize(3)) && ($this->api_model->authorize($arguments['key']) == 0)) {
|
||||
$this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard');
|
||||
}
|
||||
|
||||
$this->api_model->update_last_used($obj['key']);
|
||||
|
||||
// Retrieve the arguments from the query string
|
||||
$data['data']['format'] = $arguments['format'];
|
||||
|
||||
// Call the parser within the API model to build the query
|
||||
$query = $this->api_model->select_parse($arguments);
|
||||
|
||||
// Execute the query, and retrieve the results
|
||||
$s = $this->logbook_model->api_search_query($query);
|
||||
return $s;
|
||||
}
|
||||
|
||||
function validate()
|
||||
{
|
||||
// Load the API and Logbook models
|
||||
$this->load->model('api_model');
|
||||
$this->load->model('logbook_model');
|
||||
|
||||
// Retrieve the arguments from the query string
|
||||
$arguments = $this->_retrieve();
|
||||
|
||||
// Add some debugging information to the XML output
|
||||
$data['data'] = $arguments;
|
||||
$data['data']['queryInfo']['call'] = "validate";
|
||||
$data['data']['queryInfo']['dbQuery'] = "";
|
||||
$data['data']['queryInfo']['numResults'] = 1;
|
||||
$data['data']['queryInfo']['executionTime'] = 0;
|
||||
|
||||
$data['data']['validate_Result']['results'] = array(0 => array('Result' => $this->api_model->authorize($arguments['key'])));
|
||||
|
||||
$this->load->view('api/index', $data);
|
||||
}
|
||||
|
||||
function add()
|
||||
{
|
||||
// Load the API and Logbook models
|
||||
$this->load->model('api_model');
|
||||
$this->load->model('logbook_model');
|
||||
$this->load->model('user_model');
|
||||
if(!$this->user_model->authorize(3)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); }
|
||||
|
||||
// Retrieve the arguments from the query string
|
||||
$arguments = $this->_retrieve();
|
||||
|
||||
// Call the parser within the API model to build the query
|
||||
$query = $this->api_model->insert_parse($arguments);
|
||||
|
||||
# Check for guessable fields
|
||||
if(!isset($query['COL_TIME_ON']))
|
||||
{
|
||||
$query['COL_TIME_ON'] = date("Y-m-d H:i:s", time());
|
||||
}
|
||||
if(!isset($query['COL_TIME_OFF']))
|
||||
{
|
||||
$query['COL_TIME_OFF'] = date("Y-m-d H:i:s", time());
|
||||
}
|
||||
|
||||
$data['data']['queryInfo']['dbQuery'] = "";
|
||||
$data['data']['queryInfo']['executionTime'] = 0;
|
||||
|
||||
if(!isset($query['COL_CALL'])) {
|
||||
$data['data']['add_Result']['results'] = array(0 => array('Result' => 'EMISSINGCALL'));
|
||||
} else {
|
||||
$s = $this->logbook_model->api_insert_query($query);
|
||||
$data['data']['queryInfo']['dbQuery'] = $s['query'];
|
||||
$data['data']['queryInfo']['executionTime'] = $s['time'];
|
||||
|
||||
$data['data']['add_Result']['results'] = array(0 => array('Result' => $s['result_string']));
|
||||
}
|
||||
|
||||
// Add some debugging information to the XML output
|
||||
$data['data']['queryInfo']['call'] = "add";
|
||||
$data['data']['queryInfo']['numResults'] = 0;
|
||||
|
||||
$this->load->view('api/index', $data);
|
||||
}
|
||||
|
||||
// FUNCTION: _retrieve()
|
||||
// Pull the search query arguments from the query string
|
||||
private function _retrieve()
|
||||
{
|
||||
// This whole function could probably have been done in one line... if this was Perl.
|
||||
$arguments = array();
|
||||
|
||||
// Retrieve each arguments
|
||||
$query = preg_grep("/^query=(.*)$/", $this->uri->segments);
|
||||
$limit = preg_grep("/^limit=(.*)$/", $this->uri->segments);
|
||||
$order = preg_grep("/^order=(.*)$/", $this->uri->segments);
|
||||
$fields = preg_grep("/^fields=(.*)$/", $this->uri->segments);
|
||||
$format = preg_grep("/^format=(.*)$/", $this->uri->segments);
|
||||
$key = preg_grep("/^key=(.*)$/", $this->uri->segments);
|
||||
|
||||
// Strip each argument
|
||||
$arguments['query'] = substr(array_pop($query), 6);
|
||||
$arguments['query'] = substr($arguments['query'], 0, strlen($arguments['query']));
|
||||
$arguments['limit'] = substr(array_pop($limit), 6);
|
||||
$arguments['limit'] = substr($arguments['limit'], 0, strlen($arguments['limit']));
|
||||
$arguments['order'] = substr(array_pop($order), 6);
|
||||
$arguments['order'] = substr($arguments['order'], 0, strlen($arguments['order']));
|
||||
$arguments['fields'] = substr(array_pop($fields), 7);
|
||||
$arguments['fields'] = substr($arguments['fields'], 0, strlen($arguments['fields']));
|
||||
$arguments['format'] = substr(array_pop($format), 7);
|
||||
$arguments['format'] = substr($arguments['format'], 0, strlen($arguments['format']));
|
||||
$arguments['key'] = substr(array_pop($key), 4);
|
||||
$arguments['key'] = substr($arguments['key'], 0, strlen($arguments['key']));
|
||||
|
||||
// By default, assume XML for the format if not otherwise set
|
||||
if($arguments['format'] == "") {
|
||||
$arguments['format'] = "xml";
|
||||
}
|
||||
|
||||
// Return the arguments
|
||||
return $arguments;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
*
|
||||
* Function: QSO
|
||||
* Task: allows passing of ADIF data to Cloudlog
|
||||
|
|
@ -482,11 +228,19 @@ class API extends CI_Controller {
|
|||
$obj = json_decode(file_get_contents("php://input"), true);
|
||||
if ($obj === NULL) {
|
||||
echo json_encode(['status' => 'failed', 'reason' => "wrong JSON"]);
|
||||
return;
|
||||
}
|
||||
|
||||
if(!isset($obj['key']) || $this->api_model->authorize($obj['key']) == 0) {
|
||||
http_response_code(401);
|
||||
echo json_encode(['status' => 'failed', 'reason' => "missing api key"]);
|
||||
return;
|
||||
}
|
||||
|
||||
if(!isset($obj['logbook_public_slug']) || !isset($obj['callsign'])) {
|
||||
http_response_code(401);
|
||||
echo json_encode(['status' => 'failed', 'reason' => "missing fields"]);
|
||||
return;
|
||||
}
|
||||
|
||||
if($obj['logbook_public_slug'] != "" && $obj['callsign'] != "") {
|
||||
|
|
@ -562,6 +316,12 @@ class API extends CI_Controller {
|
|||
echo json_encode(['status' => 'failed', 'reason' => "missing api key"]);
|
||||
}
|
||||
|
||||
if(!isset($obj['logbook_public_slug']) || !isset($obj['grid'])) {
|
||||
http_response_code(401);
|
||||
echo json_encode(['status' => 'failed', 'reason' => "missing fields"]);
|
||||
return;
|
||||
}
|
||||
|
||||
if($obj['logbook_public_slug'] != "" && $obj['grid'] != "") {
|
||||
|
||||
$logbook_slug = $obj['logbook_public_slug'];
|
||||
|
|
|
|||
|
|
@ -97,37 +97,6 @@ class Awards extends CI_Controller {
|
|||
|
||||
}
|
||||
|
||||
public function dok_details_ajax(){
|
||||
$a = $this->security->xss_clean($this->input->post());
|
||||
$q = "";
|
||||
foreach ($a as $key => $value) {
|
||||
$q .= $key."=".$value.("(and)");
|
||||
}
|
||||
$q = substr($q, 0, strlen($q)-13);
|
||||
|
||||
$arguments["query"] = $q;
|
||||
$arguments["fields"] = '';
|
||||
$arguments["format"] = "json";
|
||||
$arguments["limit"] = '';
|
||||
$arguments["order"] = '';
|
||||
$arguments["join_station_profile"] = true;
|
||||
|
||||
// Load the API and Logbook models
|
||||
$this->load->model('api_model');
|
||||
$this->load->model('logbook_model');
|
||||
|
||||
// Call the parser within the API model to build the query
|
||||
$query = $this->api_model->select_parse($arguments);
|
||||
|
||||
// Execute the query, and retrieve the results
|
||||
$data = $this->logbook_model->api_search_query($query);
|
||||
|
||||
// Render Page
|
||||
$data['page_title'] = "Log View - DOK";
|
||||
$data['filter'] = str_replace("(and)", ", ", $q);
|
||||
$this->load->view('awards/details', $data);
|
||||
}
|
||||
|
||||
public function dxcc () {
|
||||
$this->load->model('dxcc');
|
||||
$this->load->model('modes');
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ class Csv extends CI_Controller {
|
|||
public function index() {
|
||||
$this->load->model('user_model');
|
||||
|
||||
if(!$this->user_model->authorize(99)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); }
|
||||
if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); }
|
||||
|
||||
$this->load->model('modes');
|
||||
$this->load->model('logbook_model');
|
||||
|
|
@ -26,8 +26,11 @@ class Csv extends CI_Controller {
|
|||
}
|
||||
|
||||
public function export() {
|
||||
$this->load->model('csv_model');
|
||||
$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'); }
|
||||
|
||||
$this->load->model('csv_model');
|
||||
// Parameters
|
||||
$station_id = $this->security->xss_clean($this->input->post('station_profile'));
|
||||
$band = $this->security->xss_clean($this->input->post('band'));
|
||||
|
|
|
|||
|
|
@ -4,8 +4,7 @@ class Dxatlas extends CI_Controller {
|
|||
|
||||
public function index() {
|
||||
$this->load->model('user_model');
|
||||
|
||||
if(!$this->user_model->authorize(99)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); }
|
||||
if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); }
|
||||
|
||||
$this->load->model('modes');
|
||||
$this->load->model('logbook_model');
|
||||
|
|
@ -26,6 +25,9 @@ class Dxatlas extends CI_Controller {
|
|||
}
|
||||
|
||||
public function export() {
|
||||
$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'); }
|
||||
|
||||
$this->load->model('dxatlas_model');
|
||||
|
||||
// Parameters
|
||||
|
|
@ -45,6 +47,8 @@ class Dxatlas extends CI_Controller {
|
|||
}
|
||||
|
||||
function generateFiles($wkdArray, $cfmArray, $band) {
|
||||
$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'); }
|
||||
|
||||
$gridCfmArray = [];
|
||||
$gridWkdArray = [];
|
||||
|
|
@ -100,6 +104,8 @@ class Dxatlas extends CI_Controller {
|
|||
}
|
||||
|
||||
function makeZip($gridWkdString, $gridCfmString, $band) {
|
||||
$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'); }
|
||||
$zipFileName = 'dxatlas_gridsquares_'. $band . '.zip';
|
||||
// Prepare File
|
||||
$file = tempnam("tmp", "zip");
|
||||
|
|
|
|||
|
|
@ -1,21 +0,0 @@
|
|||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Export extends CI_Controller {
|
||||
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->load->model('user_model');
|
||||
if(!$this->user_model->authorize(99)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); }
|
||||
|
||||
$data['page_title'] = "Data Export";
|
||||
|
||||
$this->load->view('interface_assets/header', $data);
|
||||
$this->load->view('export/index');
|
||||
$this->load->view('interface_assets/footer');
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* End of file welcome.php */
|
||||
/* Location: ./application/controllers/welcome.php */
|
||||
|
|
@ -13,9 +13,9 @@ class Kmlexport extends CI_Controller {
|
|||
$this->load->model('user_model');
|
||||
$this->load->model('modes');
|
||||
$this->load->model('logbook_model');
|
||||
$this->load->model('bands');
|
||||
$this->load->model('bands');
|
||||
|
||||
if(!$this->user_model->authorize(99)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); }
|
||||
if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); }
|
||||
|
||||
$data['worked_bands'] = $this->bands->get_worked_bands(); // Used in the view for band select
|
||||
$data['modes'] = $this->modes->active(); // Used in the view for mode select
|
||||
|
|
@ -29,6 +29,8 @@ class Kmlexport extends CI_Controller {
|
|||
}
|
||||
|
||||
public function export() {
|
||||
$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'); }
|
||||
// Load Libraries
|
||||
$this->load->library('qra');
|
||||
$this->load->helper('file');
|
||||
|
|
|
|||
|
|
@ -1,114 +0,0 @@
|
|||
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Unconfirmed_Entity_Slots extends CI_Controller {
|
||||
|
||||
function __construct()
|
||||
{
|
||||
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'); }
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->load->model('user_model');
|
||||
if(!$this->user_model->authorize(99)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); }
|
||||
|
||||
$data['page_title'] = "Showing unconfirmed Entities with Slots";
|
||||
|
||||
$this->load->view('interface_assets/header', $data);
|
||||
$this->load->view('uncfmd_entity_slots/index');
|
||||
$this->load->view('interface_assets/footer');
|
||||
|
||||
}
|
||||
|
||||
public function exportadif()
|
||||
{
|
||||
// Set memory limit to unlimited to allow heavy usage
|
||||
ini_set('memory_limit', '-1');
|
||||
|
||||
$this->load->model('adif_data');
|
||||
|
||||
$data['qsos'] = $this->adif_data->export_printrequested();
|
||||
|
||||
$this->load->view('adif/data/exportall', $data);
|
||||
}
|
||||
|
||||
public function exportcsv()
|
||||
{
|
||||
// Set memory limit to unlimited to allow heavy usage
|
||||
ini_set('memory_limit', '-1');
|
||||
|
||||
$this->load->model('logbook_model');
|
||||
|
||||
$myData = $this->logbook_model->get_qsos_for_printing();
|
||||
|
||||
// file name
|
||||
$filename = 'qsl_export.csv';
|
||||
header("Content-Description: File Transfer");
|
||||
header("Content-Disposition: attachment; filename=$filename");
|
||||
header("Content-Type: application/csv;charset=iso-8859-1");
|
||||
|
||||
// file creation
|
||||
$file = fopen('php://output', 'w');
|
||||
|
||||
$header = array("STATION_CALLSIGN",
|
||||
"COL_CALL",
|
||||
"COL_QSL_VIA",
|
||||
"COL_TIME_ON",
|
||||
"COL_MODE",
|
||||
"COL_FREQ",
|
||||
"COL_BAND",
|
||||
"COL_RST_SENT",
|
||||
"COL_SAT_NAME",
|
||||
"COL_SAT_MODE",
|
||||
"COL_QSL_RCVD",
|
||||
"COL_COMMENT",
|
||||
"COL_ROUTING",
|
||||
"ADIF",
|
||||
"ENTITY");
|
||||
|
||||
fputcsv($file, $header);
|
||||
|
||||
foreach ($myData->result() as $qso) {
|
||||
fputcsv($file,
|
||||
array($qso->STATION_CALLSIGN,
|
||||
str_replace("0", "Ø", $qso->COL_CALL),
|
||||
$qso->COL_QSL_VIA!=""?"Via ".str_replace("0", "Ø", $qso->COL_QSL_VIA):"",
|
||||
$qso->COL_TIME_ON,
|
||||
$qso->COL_MODE,
|
||||
$qso->COL_FREQ,
|
||||
$qso->COL_BAND,
|
||||
$qso->COL_RST_SENT,
|
||||
$qso->COL_SAT_NAME,
|
||||
$qso->COL_SAT_MODE,
|
||||
$qso->COL_QSL_RCVD =='Y'?'TNX QSL':'PSE QSL',
|
||||
$qso->COL_COMMENT,
|
||||
$qso->COL_ROUTING,
|
||||
$qso->ADIF,
|
||||
$qso->ENTITY));
|
||||
}
|
||||
|
||||
fclose($file);
|
||||
exit;
|
||||
}
|
||||
|
||||
function qsl_printed() {
|
||||
$this->load->model('qslprint_model');
|
||||
$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'); }
|
||||
|
||||
// Update Logbook to Mark Paper Card Received
|
||||
|
||||
$this->qslprint_model->mark_qsos_printed();
|
||||
|
||||
$this->session->set_flashdata('notice', 'QSOs are marked as sent via buro');
|
||||
|
||||
redirect('logbook');
|
||||
}
|
||||
}
|
||||
|
||||
/* End of file Qslprint.php */
|
||||
/* Location: ./application/controllers/Qslprint.php */
|
||||
|
|
@ -183,190 +183,6 @@ class API_Model extends CI_Model {
|
|||
return 0;
|
||||
}
|
||||
|
||||
function insert_parse($arguments)
|
||||
{
|
||||
# $q = "INSERT INTO ".$this->config->item('table_name');
|
||||
|
||||
$f = explode(",", $arguments['query']);
|
||||
$r = $this->_insert_field_translate($f);
|
||||
|
||||
return $r;
|
||||
}
|
||||
|
||||
// FUNCTION: string select_parse(array $arguments)
|
||||
// Converts an array of arguments into a MySQL query string
|
||||
// See documentation for search() under the API controller for more details
|
||||
function select_parse($arguments)
|
||||
{
|
||||
// Initialise our string
|
||||
$q = "SELECT ";
|
||||
|
||||
// Cycle through the fields, converting friendly names to MySQL column names
|
||||
if($arguments['fields'] != "") {
|
||||
$field = "";
|
||||
$fields = explode(",", $arguments['fields']);
|
||||
foreach ($fields as $f) {
|
||||
if($field != "") {
|
||||
$field .= ",";
|
||||
}
|
||||
// Add field to the query, with '++' placeholders for later translation
|
||||
$field .= "++$f++";
|
||||
}
|
||||
// Handle any DISTINCT arguments
|
||||
$field = str_replace("++distinct(", "DISTINCT(++", $field);
|
||||
$field = str_replace(")++", "++)", $field);
|
||||
// Add the MySQL column name to the query
|
||||
$q .= $field." ";
|
||||
} else {
|
||||
// If no fields are specified, display all fields
|
||||
$q .= "* ";
|
||||
}
|
||||
|
||||
// Append the table we're pulling data from
|
||||
$q .= "FROM ".$this->config->item('table_name');
|
||||
if (isset($arguments["join_station_profile"]) && $arguments["join_station_profile"]) {
|
||||
$q .= " INNER JOIN station_profile ON ".$this->config->item('table_name').".station_id = station_profile.station_id";
|
||||
}
|
||||
|
||||
// Parse the 'query' string, which is converted into a standard MySQL 'WHERE'
|
||||
// clause.
|
||||
// $s and $r can be refactored into single array definitions, but during
|
||||
// development it's easier to list them in this way for quick reference.
|
||||
|
||||
if($arguments['query'] != "")
|
||||
{
|
||||
$q .= " WHERE ";
|
||||
$q = $this->_query_parse($q, $arguments['query']);
|
||||
}
|
||||
|
||||
// Parse any order arguments
|
||||
if($arguments['order'] != "")
|
||||
{
|
||||
$q .= " ORDER BY ";
|
||||
|
||||
$s = null;
|
||||
$r = null;
|
||||
$s[0] = '/(/';
|
||||
$s[1] = '/)/';
|
||||
$s[2] = '/([a-zA-Z0-9\-\_]+)([,\(]{1}|$)/';
|
||||
$s[3] = '/\(asc\)/';
|
||||
$s[4] = '/\(desc\)/';
|
||||
$s[5] = '/,$/';
|
||||
$s[6] = '/\[/';
|
||||
$s[7] = '/\]/';
|
||||
|
||||
$r[0] = '(';
|
||||
$r[1] = ')';
|
||||
$r[2] = '++$1++ $2';
|
||||
$r[3] = ' ASC ';
|
||||
$r[4] = ' DESC ';
|
||||
$r[5] = '';
|
||||
$r[6] = '';
|
||||
$r[7] = '';
|
||||
|
||||
$q .= preg_replace($s, $r, $arguments['order']);
|
||||
|
||||
}
|
||||
|
||||
$q = $this->_select_field_translate($q);
|
||||
|
||||
// Parse any limit arguments
|
||||
if($arguments['limit'] != "")
|
||||
{
|
||||
// Add the limit arguments, removing any characters other than numbers and commas
|
||||
$q .= " LIMIT " . preg_replace(array("/[^0-9\,]/","/,$/"), "", $arguments['limit']);
|
||||
}
|
||||
else
|
||||
{
|
||||
// If no limit argument is given, default to the first 20 results
|
||||
$q .= " LIMIT 0,20";
|
||||
}
|
||||
|
||||
return $q;
|
||||
}
|
||||
|
||||
private function _query_parse($q, $qs)
|
||||
{
|
||||
if($qs != "")
|
||||
{
|
||||
$s = null;
|
||||
$r = null;
|
||||
// (and), becomes ' AND '
|
||||
$s[0] = '/(and)/';
|
||||
// (or), becomes ' OR '
|
||||
$s[1] = '/(or)/';
|
||||
// <, >, [ and ] all translated from their urlencoded forms
|
||||
$s[2] = '/%3C/';
|
||||
$s[3] = '/%3E/';
|
||||
$s[4] = '/%5B/';
|
||||
$s[5] = '/%5D/';
|
||||
// FieldName=, which becomes '++FieldName++ = '
|
||||
$s[6] = '/([a-zA-Z0-9\-\_\*\(\)\=\~]+)=/';
|
||||
// =Value, which becomes '= 'Value''
|
||||
$s[7] = '/=([a-zA-Z0-9\-\_\*\(\)\=\~]+)/';
|
||||
// now(), which becomes 'UNIX_TIMESTAMP(NOW())'
|
||||
$s[8] = '/now()/';
|
||||
// (, and ), which are translated to their non-HTML entity forms,
|
||||
// and with added padding
|
||||
$s[9] = '/(/';
|
||||
$s[10] = '/)/';
|
||||
// FieldName~, becomes '++FieldName++ LIKE~'
|
||||
$s[11] = '/([a-zA-Z0-9\-\_\*\(\)\=\~]+)~/';
|
||||
// ~Value, becomes ' 'Value''
|
||||
$s[12] = '/~([a-zA-Z0-9\-\_\*\(\)\=\~]+)/';
|
||||
// *, which becomes '%'
|
||||
$s[13] = '/\*/';
|
||||
|
||||
$r[0] = ' AND ';
|
||||
$r[1] = ' OR ';
|
||||
$r[2] = ' < ';
|
||||
$r[3] = ' > ';
|
||||
// Strip out square brackets
|
||||
$r[4] = '';
|
||||
$r[5] = '';
|
||||
$r[6] = '++$1++ =';
|
||||
$r[7] = '= \'$1\'';
|
||||
$r[8] = 'UNIX_TIMESTAMP(NOW())';
|
||||
$r[9] = '( ';
|
||||
$r[10] = ' )';
|
||||
$r[11] = '++$1++ LIKE~';
|
||||
$r[12] = ' \'$1\'';
|
||||
$r[13] = '%';
|
||||
|
||||
// Bulk replace everything
|
||||
$q .= preg_replace($s, $r, $qs);
|
||||
}
|
||||
|
||||
return $q;
|
||||
}
|
||||
|
||||
private function _select_field_translate($q)
|
||||
{
|
||||
// Do search/replace on field names, to convert from friendly names
|
||||
// to MySQL column names
|
||||
|
||||
foreach($this->_columnName as $key => $val) {
|
||||
$q = str_replace("++".$val['Name']."++", $key, $q);
|
||||
}
|
||||
|
||||
|
||||
|
||||
return $q;
|
||||
}
|
||||
|
||||
private function _insert_field_translate($q)
|
||||
{
|
||||
// Do search/replace on field names, to convert from friendly names
|
||||
// to MySQL column names
|
||||
$r = array();
|
||||
|
||||
foreach($q as $key => $val) {
|
||||
$f = explode('=', $val);
|
||||
$r[$this->column($f[0])] = $f[1];
|
||||
}
|
||||
|
||||
return $r;
|
||||
}
|
||||
|
||||
// ARRAY: $_columnName
|
||||
// An array matching MySQL column names to friendly names, descriptions and types
|
||||
|
|
|
|||
|
|
@ -2629,30 +2629,6 @@ class Logbook_model extends CI_Model {
|
|||
}
|
||||
}
|
||||
|
||||
function api_search_query($query) {
|
||||
$time_start = microtime(true);
|
||||
$results = $this->db->query($query);
|
||||
if(!$results) {
|
||||
return array('query' => $query, 'error' => $this->db->_error_number(), 'time' => 0);
|
||||
}
|
||||
$time_end = microtime(true);
|
||||
$time = round($time_end - $time_start, 4);
|
||||
|
||||
return array('query' => $query, 'results' => $results, 'time' => $time);
|
||||
}
|
||||
|
||||
function api_insert_query($query) {
|
||||
$time_start = microtime(true);
|
||||
$results = $this->db->insert($this->config->item('table_name'), $query);
|
||||
if(!$results) {
|
||||
return array('query' => $query, 'error' => $this->db->_error_number(), 'time' => 0);
|
||||
}
|
||||
$time_end = microtime(true);
|
||||
$time = round($time_end - $time_start, 4);
|
||||
|
||||
return array('query' => $this->db->queries[2], 'result_string' => $results, 'time' => $time);
|
||||
}
|
||||
|
||||
/* Delete QSO based on the QSO ID */
|
||||
function delete($id) {
|
||||
if ($this->check_qso_is_accessible($id)) {
|
||||
|
|
|
|||
|
|
@ -1,12 +0,0 @@
|
|||
<div id="container">
|
||||
<h2><?php echo $page_title; ?></h2>
|
||||
|
||||
<p>Below are all the exportable data options available in Cloudlog</p>
|
||||
|
||||
<h3>Data Types</h3>
|
||||
|
||||
<ul>
|
||||
<li><a href="<?php echo site_url('kml'); ?>">All QSOs as KML</a></li>
|
||||
<li><a href="<?php echo site_url('adif/export'); ?>">ADIF Export</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
@ -1860,40 +1860,6 @@ $(document).ready(function(){
|
|||
</script>
|
||||
<?php } ?>
|
||||
|
||||
|
||||
<?php if ($this->uri->segment(2) == "dok") { ?>
|
||||
<script>
|
||||
function displayDokContacts(dok, band) {
|
||||
var baseURL= "<?php echo base_url();?>";
|
||||
$.ajax({
|
||||
url: baseURL + 'index.php/awards/dok_details_ajax',
|
||||
type: 'post',
|
||||
data: {'DOK': dok,
|
||||
'Band': band
|
||||
},
|
||||
success: function(html) {
|
||||
BootstrapDialog.show({
|
||||
title: 'QSO Data',
|
||||
size: BootstrapDialog.SIZE_WIDE,
|
||||
cssClass: 'qso-dok-dialog',
|
||||
nl2br: false,
|
||||
message: html,
|
||||
onshown: function(dialog) {
|
||||
$('[data-toggle="tooltip"]').tooltip();
|
||||
},
|
||||
buttons: [{
|
||||
label: 'Close',
|
||||
action: function (dialogItself) {
|
||||
dialogItself.close();
|
||||
}
|
||||
}]
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ($this->uri->segment(2) == "iota") { ?>
|
||||
<script>
|
||||
|
||||
|
|
|
|||
正在加载…
在新工单中引用