Skip to content

Commit

Permalink
2.6.8
Browse files Browse the repository at this point in the history
  • Loading branch information
magicbug authored Apr 5, 2024
2 parents 5f9d33c + bb64d68 commit d2bb80f
Show file tree
Hide file tree
Showing 67 changed files with 1,146 additions and 405 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
/images/eqsl_card_images/*.jpg
/updates/clublog_scp.txt
/assets/qslcard/*
/assets/sstvimages/*
/assets/js/sections/custom.js
.idea/*
.DS_Store
Expand Down
13 changes: 13 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"cSpell.words": [
"callsign",
"cloudlog",
"hamradio",
"qslcard",
"sstv",
"sstvimages",
"sstvtable",
"SUBMODE",
"userdata"
]
}
2 changes: 1 addition & 1 deletion application/config/migration.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
|
*/

$config['migration_version'] = 174;
$config['migration_version'] = 176;

/*
|--------------------------------------------------------------------------
Expand Down
48 changes: 2 additions & 46 deletions application/controllers/Eqsl.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ function __construct() {
public function index() {

$this->lang->load('qslcard');
$this->load->helper('storage');
$folder_name = "images/eqsl_card_images";
$data['storage_used'] = $this->sizeFormat($this->folderSize($folder_name));
$data['storage_used'] = sizeFormat(folderSize($folder_name));


// Render Page
Expand Down Expand Up @@ -749,49 +750,4 @@ function uploadUser($userid, $username, $password) {
$status = $this->uploadQso($adif, $qsl);
}
}

// Functions for storage, these need shifted to a libary to use across Cloudlog
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 = $this->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';
}
}

} // end class
2 changes: 1 addition & 1 deletion application/controllers/Labels.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ function makeMultiQsoLabel($qsos, $pdf, $numberofqsos, $offset, $orientation, $g
$qso_data[] = [
'time' => $qso->COL_TIME_ON,
'band' => $qso->COL_BAND,
'mode' => $qso->COL_MODE,
'mode' => (($qso->COL_SUBMODE ?? '') == '') ? $qso->COL_MODE : $qso->COL_SUBMODE,
'rst' => $qso->COL_RST_SENT,
'mygrid' => $qso->station_gridsquare,
'via' => $qso->COL_QSL_VIA,
Expand Down
2 changes: 2 additions & 0 deletions application/controllers/Logbook.php
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,9 @@ function view($id) {
}

$this->load->model('Qsl_model');
$this->load->model('Sstv_model');
$data['qslimages'] = $this->Qsl_model->getQslForQsoId($id);
$data['sstvimages'] = $this->Sstv_model->getSstvForQsoId($id);
$data['primary_subdivision'] = $this->subdivisions->get_primary_subdivision_name($data['query']->result()[0]->COL_DXCC);
$data['secondary_subdivision'] = $this->subdivisions->get_secondary_subdivision_name($data['query']->result()[0]->COL_DXCC);
$data['max_upload'] = ini_get('upload_max_filesize');
Expand Down
48 changes: 2 additions & 46 deletions application/controllers/Qsl.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function __construct() {

// Default view when loading controller.
public function index() {

$this->load->helper('storage'); // Load the storage helper
$folder_name = "assets/qslcard";
$data['storage_used'] = sizeFormat(folderSize($folder_name));

Expand Down Expand Up @@ -181,48 +181,4 @@ function viewQsl() {
$this->load->view('qslcard/qslcarousel', $data);
}

}

// Functions for storage, these need shifted to a libary to use across Cloudlog
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';
}
}
}
4 changes: 2 additions & 2 deletions application/controllers/Sattimers.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ public function index() {
$footerData['scripts'] = [
'assets/js/sections/sattimers.js?'
];
$url = 'https://www.df2et.de/tevel/api2.php?grid='.strtoupper($this->stations->find_gridsquare());
$data['gridsquare'] = substr(strtoupper($this->stations->find_gridsquare()), 0, 6);
$url = 'https://www.df2et.de/tevel/api2.php?grid=' . $data['gridsquare'];
$json = file_get_contents($url);
$data['activations'] = json_decode($json, true)['data'];
$data['gridsquare'] = strtoupper($this->stations->find_gridsquare());

$data['page_title'] = "Satellite Timers";

Expand Down
111 changes: 111 additions & 0 deletions application/controllers/Sstv.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/*
Controller for SSTV Images
*/

class Sstv extends CI_Controller {

function __construct() {
parent::__construct();
$this->lang->load('sstv');
$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->helper('storage');
$folder_name = "assets/sstvimages";
$data['storage_used'] = sizeFormat(folderSize($folder_name));

// Render Page
$data['page_title'] = "SSTV Images";

$this->load->model('sstv_model');
$data['sstvArray'] = $this->sstv_model->getQsoWithSstvImageList();

$this->load->view('interface_assets/header', $data);
$this->load->view('sstv/index');
$this->load->view('interface_assets/footer');
}

public function uploadSSTV() {
$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'); }

if (!file_exists('./assets/sstvimages')) {
mkdir('./assets/sstvimages', 0755, true);
}
$qsoid = $this->input->post('qsoid');

$results = array();
if (isset($_FILES['sstvimages']) && $_FILES['sstvimages']['error'][0] == 0)
{
for($i=0; $i<count($_FILES['sstvimages']['name']); $i++) {
$file = array(
'name' => $_FILES['sstvimages']['name'][$i],
'type' => $_FILES['sstvimages']['type'][$i],
'tmp_name' => $_FILES['sstvimages']['tmp_name'][$i],
'error' => $_FILES['sstvimages']['error'][$i],
'size' => $_FILES['sstvimages']['size'][$i]
);
$result = $this->uploadSSTVImage($qsoid, $file);
array_push($results, $result);
}
}

header("Content-type: application/json");
echo json_encode($results);
}

function uploadSSTVImage($qsoid, $file) {
$config['upload_path'] = './assets/sstvimages';
$config['allowed_types'] = 'jpg|gif|png|jpeg|JPG|PNG|bmp';
$array = explode(".", $file['name']);
$ext = end($array);
$config['file_name'] = $qsoid . '.sstv.' . '_' . time() . '.' . $ext;

$this->load->library('upload', $config);

$_FILES['sstvimage'] = $file;
if ( ! $this->upload->do_upload('sstvimage')) {
// Upload of SSTV image Failed
$error = array('error' => $this->upload->display_errors());

return $error;
}
else {
// Load database queries
$this->load->model('Sstv_model');

//Upload of SSTV image was successful
$data = $this->upload->data();

// Now we need to insert info into database about file
$filename = $data['file_name'];
$insertid = $this->Sstv_model->saveSstvImages($qsoid, $filename);

$result['status'] = 'Success';
$result['insertid'] = $insertid;
$result['filename'] = $filename;
return $result;
}
}


// Deletes SSTV Image
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('Sstv_model');

$path = './assets/sstvimages/';
$file = $this->Sstv_model->getSSTVFilename($id)->row();
$filename = $file->filename;
unlink($path.$filename);

$this->Sstv_model->deleteSstv($id);
}
}
36 changes: 34 additions & 2 deletions application/controllers/Visitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,37 @@ public function index($public_slug = NULL)

$this->load->model('logbook_model');

// load config and init pagination
$this->load->library('pagination');

//Pagination config
$config['base_url'] = base_url().'index.php/visitor/'. $public_slug . '/index';
$config['total_rows'] = $this->logbook_model->total_qsos($logbooks_locations_array);
$config['per_page'] = '25';
$config['num_links'] = $this->logbook_model->total_qsos($logbooks_locations_array) / 25;
$config['full_tag_open'] = '<ul class="pagination">';
$config['full_tag_close'] = '</ul>';
$config['attributes'] = ['class' => 'page-link'];
$config['first_link'] = false;
$config['last_link'] = false;
$config['first_tag_open'] = '<li class="page-item">';
$config['first_tag_close'] = '</li>';
$config['prev_link'] = '&laquo';
$config['prev_tag_open'] = '<li class="page-item">';
$config['prev_tag_close'] = '</li>';
$config['next_link'] = '&raquo';
$config['next_tag_open'] = '<li class="page-item">';
$config['next_tag_close'] = '</li>';
$config['last_tag_open'] = '<li class="page-item">';
$config['last_tag_close'] = '</li>';
$config['cur_tag_open'] = '<li class="page-item active"><a href="#" class="page-link">';
$config['cur_tag_close'] = '<span class="visually-hidden">(current)</span></a></li>';
$config['num_tag_open'] = '<li class="page-item">';
$config['num_tag_close'] = '</li>';

$this->pagination->initialize($config);


// Public visitor so no QRA to setup
$data['qra'] = "none";

Expand Down Expand Up @@ -107,8 +138,9 @@ public function index($public_slug = NULL)

$data['total_lotw_sent'] = $QSLStatsBreakdownArray['LoTW_Sent'];
$data['total_lotw_rcvd'] = $QSLStatsBreakdownArray['LoTW_Received'];

$data['last_five_qsos'] = $this->logbook_model->get_last_qsos('18', $logbooks_locations_array);

// Show paginated results
$data['results'] = $this->logbook_model->get_qsos($config['per_page'], $this->uri->segment(4), $logbooks_locations_array);

$data['page_title'] = "Dashboard";
$data['slug'] = $public_slug;
Expand Down
44 changes: 44 additions & 0 deletions application/helpers/storage_helper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

if (!function_exists('folderSize')) {
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;
}
}

if (!function_exists('sizeFormat')) {
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';
}
}
}
Loading

0 comments on commit d2bb80f

Please sign in to comment.