2011-09-30 22:27:18 +01:00
|
|
|
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
|
|
|
|
|
|
class Backup extends CI_Controller {
|
2019-10-05 19:35:55 +01:00
|
|
|
function __construct()
|
|
|
|
|
{
|
|
|
|
|
parent::__construct();
|
|
|
|
|
}
|
2026-06-20 14:10:00 -07:00
|
|
|
|
2011-09-30 22:27:18 +01:00
|
|
|
/* User Facing Links to Backup URLs */
|
|
|
|
|
public function index()
|
|
|
|
|
{
|
2024-08-16 10:08:44 +02:00
|
|
|
if(!$this->user_model->authorize(99)) { $this->session->set_flashdata('error', __("You're not allowed to do that!")); redirect('dashboard'); }
|
2011-09-30 22:27:18 +01:00
|
|
|
|
2024-06-08 11:01:59 +02:00
|
|
|
$data['page_title'] = __("Backup");
|
2011-11-04 17:32:03 +00:00
|
|
|
|
2019-01-14 16:29:06 +00:00
|
|
|
$this->load->view('interface_assets/header', $data);
|
2011-09-30 22:27:18 +01:00
|
|
|
$this->load->view('backup/main');
|
2019-01-14 16:29:06 +00:00
|
|
|
$this->load->view('interface_assets/footer');
|
2011-09-30 22:27:18 +01:00
|
|
|
}
|
|
|
|
|
|
2011-10-01 19:35:23 +01:00
|
|
|
/* Gets all QSOs and Dumps them to logbook.adi */
|
2026-06-20 14:10:00 -07:00
|
|
|
public function adif($key = null){
|
2023-05-02 08:04:21 +02:00
|
|
|
if ($key == null) {
|
2024-08-16 10:08:44 +02:00
|
|
|
if(!$this->user_model->authorize(99)) { $this->session->set_flashdata('error', __("You're not allowed to do that!")); redirect('dashboard'); }
|
2023-05-02 08:04:21 +02:00
|
|
|
}
|
|
|
|
|
|
2024-08-14 13:29:07 +02:00
|
|
|
$clean_key = $this->security->xss_clean($key);
|
|
|
|
|
|
2011-09-30 22:27:18 +01:00
|
|
|
$this->load->helper('file');
|
2025-12-05 06:02:17 +00:00
|
|
|
$this->load->library('AdifHelper');
|
2011-09-30 22:27:18 +01:00
|
|
|
// Set memory limit to unlimited to allow heavy usage
|
|
|
|
|
ini_set('memory_limit', '-1');
|
2026-06-20 14:10:00 -07:00
|
|
|
|
2011-09-30 22:27:18 +01:00
|
|
|
$this->load->model('adif_data');
|
2025-12-05 06:02:17 +00:00
|
|
|
$filename = 'backup/logbook'. date('_Y_m_d_H_i_s') .'.adi';
|
2011-09-30 22:27:18 +01:00
|
|
|
|
2025-12-05 06:02:17 +00:00
|
|
|
header('Content-Type: text/plain; charset=utf-8');
|
|
|
|
|
header('Content-Disposition: attachment; filename="'.$filename.'"');
|
2011-09-30 22:27:18 +01:00
|
|
|
|
2025-12-05 06:02:17 +00:00
|
|
|
// Output ADIF header // No chance to use exportall-view any longer, because of chunking logic
|
2026-03-22 17:29:48 +01:00
|
|
|
echo $this->adifhelper->getAdifHeader($this->config->item('app_name'),$this->optionslib->get_option('version'), $this->optionslib->get_option('adif_version'));
|
2011-09-30 22:27:18 +01:00
|
|
|
|
2025-12-05 06:02:17 +00:00
|
|
|
// Stream QSOs in 5K chunks
|
|
|
|
|
$offset = 0;
|
|
|
|
|
$chunk_size = 5000;
|
2011-11-04 17:32:03 +00:00
|
|
|
|
2025-12-05 06:02:17 +00:00
|
|
|
do {
|
2026-06-20 14:10:00 -07:00
|
|
|
$qsos = $this->adif_data->export_all_chunked($clean_key, null, null, false, null, $offset, $chunk_size, true);
|
2025-12-05 06:02:17 +00:00
|
|
|
|
|
|
|
|
if ($qsos->num_rows() > 0) {
|
|
|
|
|
foreach ($qsos->result() as $qso) {
|
|
|
|
|
echo $this->adifhelper->getAdifLine($qso);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Free memory
|
|
|
|
|
$qsos->free_result();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$offset += $chunk_size;
|
|
|
|
|
} while ($qsos->num_rows() > 0);
|
2011-09-30 22:27:18 +01:00
|
|
|
|
2025-12-05 06:02:17 +00:00
|
|
|
exit;
|
2011-09-30 22:27:18 +01:00
|
|
|
}
|
2011-10-01 19:35:23 +01:00
|
|
|
|
|
|
|
|
/* Export the notes to XML */
|
2023-05-03 09:38:28 +02:00
|
|
|
public function notes($key = null) {
|
|
|
|
|
if ($key == null) {
|
2024-08-16 10:08:44 +02:00
|
|
|
if(!$this->user_model->authorize(99)) { $this->session->set_flashdata('error', __("You're not allowed to do that!")); redirect('dashboard'); }
|
2023-05-03 09:38:28 +02:00
|
|
|
}
|
|
|
|
|
|
2024-08-14 13:29:07 +02:00
|
|
|
$clean_key = $this->security->xss_clean($key);
|
|
|
|
|
|
2011-10-01 19:35:23 +01:00
|
|
|
$this->load->helper('file');
|
|
|
|
|
$this->load->model('note');
|
|
|
|
|
|
2024-08-14 13:29:07 +02:00
|
|
|
$data['list_note'] = $this->note->list_all($clean_key);
|
2023-05-03 09:38:28 +02:00
|
|
|
|
|
|
|
|
$data['filename'] = 'backup/notes'. date('_Y_m_d_H_i_s') .'.xml';
|
2011-10-01 19:35:23 +01:00
|
|
|
|
2023-05-03 09:38:28 +02:00
|
|
|
if ( ! write_file($data['filename'], $this->load->view('backup/notes', $data, true)))
|
2011-10-01 19:35:23 +01:00
|
|
|
{
|
2023-05-03 09:38:28 +02:00
|
|
|
$data['status'] = false;
|
2011-10-01 19:35:23 +01:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2023-05-03 09:38:28 +02:00
|
|
|
$data['status'] = true;
|
2011-10-01 19:35:23 +01:00
|
|
|
}
|
|
|
|
|
|
2024-06-08 11:01:59 +02:00
|
|
|
$data['page_title'] = __("Notes - Backup");
|
2011-11-04 17:32:03 +00:00
|
|
|
|
2019-01-14 16:29:06 +00:00
|
|
|
$this->load->view('interface_assets/header', $data);
|
2011-11-04 17:32:03 +00:00
|
|
|
$this->load->view('backup/notes_view');
|
2019-01-14 16:29:06 +00:00
|
|
|
$this->load->view('interface_assets/footer');
|
2011-10-01 19:35:23 +01:00
|
|
|
|
|
|
|
|
}
|
2011-09-30 22:27:18 +01:00
|
|
|
}
|
|
|
|
|
|
2023-05-02 08:04:21 +02:00
|
|
|
/* End of file Backup.php */
|