mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-22 18:27:16 +00:00
* config file for directory userdata * userdir for eqsl * change name to userdata * userdata for qsl * fix name on comment * add generic function file * remove model class on view, use generic function * Re-added forum link * add stations_id to eqsl functions * remove 'v' in Version Dialog * Update README.md added Link to demo instance * Update index.php * We should be MIT Conform * [Debug] Added information about when files were last updated, and links to update * Added custom data format * Remove leftover-index * Migration * Check if index is there * [LBA] Can disable maidenhead overlay * paths libary * Dev (#2) * Added Windows, MariaDB and PHP-Versions * Release 1.0 * Re-added forum link * add stations_id to eqsl functions * remove 'v' in Version Dialog * Update README.md added Link to demo instance * Update index.php * We should be MIT Conform * [Debug] Added information about when files were last updated, and links to update * Added custom data format * Remove leftover-index * Migration * Check if index is there * [LBA] Can disable maidenhead overlay --------- Co-authored-by: int2001 <joerg@dj7nt.de> Co-authored-by: Joerg (DJ7NT) <int2001@users.noreply.github.com> Co-authored-by: Andreas <6977712+AndreasK79@users.noreply.github.com> Co-authored-by: Christoph Kottke <dg0tm@darc.de> Co-authored-by: Florian (DF2ET) <github@florian-wolters.de> * [eQSL] only locations with a eQSL nickname should be displayed (#74) * only locations with a eQSL nickname should be displayed in the dropdown under eQSL Import * add proper error message * improve usability --------- Co-authored-by: Christoph Kottke <dg0tm@darc.de> * html fixes * show flashdata if no station has eqsl nick * removed openssl check, not required * accumulate stats language * multilanguage support * prettier * Prevent leaking data out of other station_location * moved qrg to first tab * Fix a PHP 8.1 deprecated bug. * [Contesting] Fix for table qso count * Fixed error when data was empty. Also clear table before inserting again. * Refactor to get the table to load * Need to clear datatable when session is deleted * Prevent Racecondition * Fixed a few null-checks which will fail on fresh accounts * Allow for longer gridsquare in station profile * Show IOTA/SOTA ref on station location tab * [LBA] Fixed mapping of selected QSOs * Trying to convert the QSO-Post to an ajax call PHP/Part * JS Part * Dev (#3) * Added Windows, MariaDB and PHP-Versions * Release 1.0 * Re-added forum link * add stations_id to eqsl functions * remove 'v' in Version Dialog * Update README.md added Link to demo instance * Update index.php * We should be MIT Conform * [Debug] Added information about when files were last updated, and links to update * Added custom data format * Remove leftover-index * Migration * Check if index is there * [LBA] Can disable maidenhead overlay * [eQSL] only locations with a eQSL nickname should be displayed (#74) * only locations with a eQSL nickname should be displayed in the dropdown under eQSL Import * add proper error message * improve usability --------- Co-authored-by: Christoph Kottke <dg0tm@darc.de> * html fixes * show flashdata if no station has eqsl nick * removed openssl check, not required * accumulate stats language * multilanguage support * prettier * Prevent leaking data out of other station_location * moved qrg to first tab * Fix a PHP 8.1 deprecated bug. * [Contesting] Fix for table qso count * Fixed error when data was empty. Also clear table before inserting again. * Refactor to get the table to load * Need to clear datatable when session is deleted * Prevent Racecondition * Fixed a few null-checks which will fail on fresh accounts * Allow for longer gridsquare in station profile * Show IOTA/SOTA ref on station location tab * [LBA] Fixed mapping of selected QSOs --------- Co-authored-by: int2001 <joerg@dj7nt.de> Co-authored-by: Joerg (DJ7NT) <int2001@users.noreply.github.com> Co-authored-by: Andreas <6977712+AndreasK79@users.noreply.github.com> Co-authored-by: Christoph Kottke <dg0tm@darc.de> Co-authored-by: Florian (DF2ET) <github@florian-wolters.de> Co-authored-by: dg0tm <schieberjunge@gmx.net> * First POC * Handling of AJAX result (started) * Change qso-save to ajax-return * Added notification and reloading of QSO-Table * JS-Part * Set Focus to qso after (successful) log * Resetting timers (successful) * Info is now shown / faded * Small adjustments * More Beauty * Make consequent use of SIG-References from station_profile * Delete application/views/welcome directory Leftovers. Security Flaw! * Update Dashboard.php Remove redir to welcome * Delete application/controllers/Welcome.php security flaw * Hint for 8.3. friendly Usertest * Update config.sample.php default should be commented out * [LBA] Checkbox to turn on/off path lines in map * Styling for pathlines-checkbox * [LBA] Checkbox tweaks * updated comment in config.php (sample and installer) * Removed popup regarding unsaved changes (wasn't functional at all) * Added locking for sending a qso twice * added spinner to save button * Also include SIG and SIG_INFO * [Logbook] Removed profiler * [LBA] Added fitbounds to map * [LBA] Added CQ Zone overlay * Make clearer that overview filters on logbook rather than locations * baesURL has a trailing slash already * active logbook hint * Update .gitignore added userdata * [LBA] ITU zone overlay * Minor wording * [LBA] Added custom mapping icons * [LBA] Path line follows icon color * [LBA] Added icon anchoring * [LBA] Added easyprint for easy map saving * [LBA] Added default colors when icon settings does not exist in db * Check refs before trimming them * [LBA] Fixed another default issue with markers and colors * Removed dangerous functions where User can accidently shift profiles * Rmoeve more unused leftovers from 1.0 to 2.0. * Header refactoring (#110) * splitted up header * resorted header menu * main rebuild * header behaviour hover * dropdown toggle rotate * fix case where landscape is small menu and portrait normal view * submenu thirdparty services * removed custom maps from the header * matching search bar * border * matched border to themes * [Custom Map] Removed code * [Gridmap] Broke map by accident. Thanks @phl0 for poke. * Optical support for SAT directions and elevation * [LBA] Added coordinates at the bottom of the map * Align numbers and arrows * Reset RST after saving via AJAX * Cfd export (#117) * Added CFD Export for toplist.darc.de to Wavelog --------- Co-authored-by: phl0 <github@florian-wolters.de> * special thx to contributors * tag 1.1 * typo --------- Co-authored-by: abarrau <hesky378@gmail.com> Co-authored-by: Andreas <6977712+AndreasK79@users.noreply.github.com> Co-authored-by: Christoph Kottke <dg0tm@darc.de> Co-authored-by: Joerg (DJ7NT) <int2001@users.noreply.github.com> Co-authored-by: int2001 <joerg@dj7nt.de> Co-authored-by: Florian (DF2ET) <github@florian-wolters.de> Co-authored-by: dg0tm <schieberjunge@gmx.net>
221 lines
7.1 KiB
PHP
221 lines
7.1 KiB
PHP
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
/*
|
|
Controller for QSL Cards
|
|
*/
|
|
|
|
class Qsl extends CI_Controller {
|
|
|
|
function __construct() {
|
|
parent::__construct();
|
|
$this->lang->load('qslcard');
|
|
$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'); }
|
|
}
|
|
|
|
// Default view when loading controller.
|
|
public function index() {
|
|
|
|
$this->load->model('qsl_model');
|
|
$folder_name = $this->qsl_model->get_imagePath('p');
|
|
$data['storage_used'] = sizeFormat(folderSize($folder_name));
|
|
|
|
// Render Page
|
|
$data['page_title'] = "QSL Cards";
|
|
$data['qslarray'] = $this->qsl_model->getQsoWithQslList();
|
|
|
|
$this->load->view('interface_assets/header', $data);
|
|
$this->load->view('qslcard/index');
|
|
$this->load->view('interface_assets/footer');
|
|
}
|
|
|
|
public function upload() {
|
|
// Render Page
|
|
$data['page_title'] = "Upload QSL Cards";
|
|
$this->load->view('interface_assets/header', $data);
|
|
$this->load->view('qslcard/upload');
|
|
$this->load->view('interface_assets/footer');
|
|
}
|
|
|
|
// Deletes QSL Card
|
|
public function delete() {
|
|
$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'); }
|
|
|
|
$id = $this->input->post('id');
|
|
$this->load->model('Qsl_model');
|
|
|
|
$path = $this->Qsl_model->get_imagePath('p');
|
|
$file = $this->Qsl_model->getFilename($id)->row();
|
|
$filename = $file->filename;
|
|
unlink($path.'/'.$filename);
|
|
|
|
$this->Qsl_model->deleteQsl($id);
|
|
}
|
|
|
|
public function uploadqsl() {
|
|
$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'); }
|
|
|
|
$qsoid = $this->input->post('qsoid');
|
|
|
|
if (isset($_FILES['qslcardfront']) && $_FILES['qslcardfront']['name'] != "" && $_FILES['qslcardfront']['error'] == 0)
|
|
{
|
|
$result['front'] = $this->uploadQslCardFront($qsoid);
|
|
} else {
|
|
$result['front']['status'] = '';
|
|
}
|
|
|
|
if (isset($_FILES['qslcardback']) && $_FILES['qslcardback']['name'] != "" && $_FILES['qslcardback']['error'] == 0)
|
|
{
|
|
$result['back'] = $this->uploadQslCardBack($qsoid);
|
|
} else {
|
|
$result['back']['status'] = '';
|
|
}
|
|
|
|
header("Content-type: application/json");
|
|
echo json_encode(['status' => $result]);
|
|
}
|
|
|
|
function uploadQslCardFront($qsoid) {
|
|
$this->load->model('Qsl_model');
|
|
$config['upload_path'] = $this->Qsl_model->get_imagePath('p');
|
|
$config['allowed_types'] = 'jpg|gif|png|jpeg|JPG|PNG';
|
|
$array = explode(".", $_FILES['qslcardfront']['name']);
|
|
$ext = end($array);
|
|
$config['file_name'] = $qsoid . '_' . time() . '.' . $ext;
|
|
|
|
$this->load->library('upload', $config);
|
|
|
|
if ( ! $this->upload->do_upload('qslcardfront')) {
|
|
// Upload of QSL card Failed
|
|
$error = array('error' => $this->upload->display_errors());
|
|
|
|
return $error;
|
|
}
|
|
else {
|
|
//Upload of QSL card was successful
|
|
$data = $this->upload->data();
|
|
|
|
// Now we need to insert info into database about file
|
|
$filename = $data['file_name'];
|
|
$insertid = $this->Qsl_model->saveQsl($qsoid, $filename);
|
|
|
|
$result['status'] = 'Success';
|
|
$result['insertid'] = $insertid;
|
|
$result['filename'] = $filename;
|
|
return $result;
|
|
}
|
|
}
|
|
|
|
function uploadQslCardBack($qsoid) {
|
|
$this->load->model('Qsl_model');
|
|
$config['upload_path'] = $this->Qsl_model->get_imagePath('p');
|
|
$config['allowed_types'] = 'jpg|gif|png|jpeg|JPG|PNG';
|
|
$array = explode(".", $_FILES['qslcardback']['name']);
|
|
$ext = end($array);
|
|
$config['file_name'] = $qsoid . '_' . time() . '.' . $ext;
|
|
|
|
$this->load->library('upload', $config);
|
|
|
|
if ( ! $this->upload->do_upload('qslcardback')) {
|
|
// Upload of QSL card Failed
|
|
$error = array('error' => $this->upload->display_errors());
|
|
|
|
return $error;
|
|
}
|
|
else {
|
|
//Upload of QSL card was successful
|
|
$data = $this->upload->data();
|
|
|
|
// Now we need to insert info into database about file
|
|
$filename = $data['file_name'];
|
|
$insertid = $this->Qsl_model->saveQsl($qsoid, $filename);
|
|
|
|
$result['status'] = 'Success';
|
|
$result['insertid'] = $insertid;
|
|
$result['filename'] = $filename;
|
|
return $result;
|
|
}
|
|
}
|
|
|
|
function loadSearchForm() {
|
|
$data['filename'] = $this->input->post('filename');
|
|
$this->load->view('qslcard/searchform', $data);
|
|
}
|
|
|
|
function searchQsos() {
|
|
$this->load->model('Qsl_model');
|
|
$callsign = $this->input->post('callsign');
|
|
|
|
$data['results'] = $this->Qsl_model->searchQsos($callsign);
|
|
$data['filename'] = $this->input->post('filename');
|
|
$this->load->view('qslcard/searchresult', $data);
|
|
}
|
|
|
|
function addQsoToQsl() {
|
|
$qsoid = $this->input->post('qsoid');
|
|
$filename = $this->input->post('filename');
|
|
|
|
$this->load->model('Qsl_model');
|
|
$insertid = $this->Qsl_model->addQsotoQsl($qsoid, $filename);
|
|
header("Content-type: application/json");
|
|
$result['status'] = 'Success';
|
|
$result['insertid'] = $insertid;
|
|
$result['filename'] = $filename;
|
|
echo json_encode($result);
|
|
}
|
|
|
|
function viewQsl() {
|
|
$cleanid = $this->security->xss_clean($this->input->post('id'));
|
|
$this->load->model('Qsl_model');
|
|
$data['qslimages'] = $this->Qsl_model->getQslForQsoId($cleanid);
|
|
$this->load->view('qslcard/qslcarousel', $data);
|
|
}
|
|
|
|
}
|
|
|
|
// Functions for storage, these need shifted to a libary to use across Wavelog
|
|
function folderSize($dir){
|
|
$count_size = 0;
|
|
$count = 0;
|
|
$dir_array = scandir($dir);
|
|
foreach($dir_array as $key=>$filename){
|
|
if($filename!=".." && $filename!="."){
|
|
if(is_dir($dir."/".$filename)){
|
|
$new_foldersize = foldersize($dir."/".$filename);
|
|
$count_size = $count_size+ $new_foldersize;
|
|
}else if(is_file($dir."/".$filename)){
|
|
$count_size = $count_size + filesize($dir."/".$filename);
|
|
$count++;
|
|
}
|
|
}
|
|
}
|
|
return $count_size;
|
|
}
|
|
|
|
function sizeFormat($bytes){
|
|
$kb = 1024;
|
|
$mb = $kb * 1024;
|
|
$gb = $mb * 1024;
|
|
$tb = $gb * 1024;
|
|
|
|
if (($bytes >= 0) && ($bytes < $kb)) {
|
|
return $bytes . ' B';
|
|
|
|
} elseif (($bytes >= $kb) && ($bytes < $mb)) {
|
|
return ceil($bytes / $kb) . ' KB';
|
|
|
|
} elseif (($bytes >= $mb) && ($bytes < $gb)) {
|
|
return ceil($bytes / $mb) . ' MB';
|
|
|
|
} elseif (($bytes >= $gb) && ($bytes < $tb)) {
|
|
return ceil($bytes / $gb) . ' GB';
|
|
|
|
} elseif ($bytes >= $tb) {
|
|
return ceil($bytes / $tb) . ' TB';
|
|
} else {
|
|
return $bytes . ' B';
|
|
}
|
|
}
|