| 
									
										
										
										
											2025-08-29 17:59:42 +08:00
										 |  |  | <?php if (! defined('BASEPATH')) exit('No direct script access allowed'); | 
					
						
							| 
									
										
										
										
											2011-09-21 21:30:01 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-29 17:59:42 +08:00
										 |  |  | class adif extends CI_Controller | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2011-09-21 21:30:01 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* Controls ADIF Import/Export Functions */ | 
					
						
							| 
									
										
										
										
											2014-09-26 06:09:44 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-20 06:28:05 +08:00
										 |  |  | 	function __construct() | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		parent::__construct(); | 
					
						
							|  |  |  | 		$this->load->helper(array('form', 'url')); | 
					
						
							| 
									
										
										
										
											2014-09-26 06:09:44 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-11-20 06:24:10 +08:00
										 |  |  | 		$this->load->model('user_model'); | 
					
						
							| 
									
										
										
										
											2025-08-29 17:59:42 +08:00
										 |  |  | 		if (!$this->user_model->authorize(2)) { | 
					
						
							|  |  |  | 			$this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); | 
					
						
							|  |  |  | 			redirect('dashboard'); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2011-11-20 06:28:05 +08:00
										 |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-21 21:30:01 +08:00
										 |  |  | 	/* Shows Export Views */ | 
					
						
							| 
									
										
										
										
											2025-08-29 17:59:42 +08:00
										 |  |  | 	public function export() | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2011-11-05 01:32:03 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		$data['page_title'] = "ADIF Export"; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-25 06:42:01 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-09 02:42:03 +08:00
										 |  |  | 		$this->load->view('interface_assets/header', $data); | 
					
						
							| 
									
										
										
										
											2011-09-21 21:30:01 +08:00
										 |  |  | 		$this->load->view('adif/main'); | 
					
						
							| 
									
										
										
										
											2019-07-09 02:42:03 +08:00
										 |  |  | 		$this->load->view('interface_assets/footer'); | 
					
						
							| 
									
										
										
										
											2011-09-21 21:30:01 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2014-09-26 06:09:44 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-21 21:30:01 +08:00
										 |  |  | 	// Export all QSO Data in ASC Order of Date.
 | 
					
						
							|  |  |  | 	public function exportall() | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2011-09-24 01:15:47 +08:00
										 |  |  | 		// Set memory limit to unlimited to allow heavy usage
 | 
					
						
							|  |  |  | 		ini_set('memory_limit', '-1'); | 
					
						
							| 
									
										
										
										
											2014-09-26 06:09:44 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-21 21:30:01 +08:00
										 |  |  | 		$this->load->model('adif_data'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$data['qsos'] = $this->adif_data->export_all(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-08 21:47:25 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-21 21:30:01 +08:00
										 |  |  | 		$this->load->view('adif/data/exportall', $data); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2014-09-26 06:09:44 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-08 00:58:23 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	// Export all QSO Data in ASC Order of Date.
 | 
					
						
							|  |  |  | 	public function exportsat() | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		// Set memory limit to unlimited to allow heavy usage
 | 
					
						
							|  |  |  | 		ini_set('memory_limit', '-1'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$this->load->model('adif_data'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-08 22:47:03 +08:00
										 |  |  | 		$data['qsos'] = $this->adif_data->sat_all(); | 
					
						
							| 
									
										
										
										
											2019-04-08 22:36:23 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		$this->load->view('adif/data/exportsat', $data); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	// Export all QSO Data in ASC Order of Date.
 | 
					
						
							|  |  |  | 	public function exportsatlotw() | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		// Set memory limit to unlimited to allow heavy usage
 | 
					
						
							|  |  |  | 		ini_set('memory_limit', '-1'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$this->load->model('adif_data'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$data['qsos'] = $this->adif_data->satellte_lotw(); | 
					
						
							| 
									
										
										
										
											2019-01-08 00:58:23 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		$this->load->view('adif/data/exportsat', $data); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-29 17:59:42 +08:00
										 |  |  | 	public function export_custom() | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2011-09-24 01:15:47 +08:00
										 |  |  | 		// Set memory limit to unlimited to allow heavy usage
 | 
					
						
							|  |  |  | 		ini_set('memory_limit', '-1'); | 
					
						
							| 
									
										
										
										
											2014-09-26 06:09:44 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-21 21:30:01 +08:00
										 |  |  | 		$this->load->model('adif_data'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-09 03:20:05 +08:00
										 |  |  | 		$station_id = $this->security->xss_clean($this->input->post('station_profile')); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-23 15:22:37 +08:00
										 |  |  | 		// Used for exporting QSOs not previously exported to LoTW
 | 
					
						
							| 
									
										
										
										
											2025-08-29 17:59:42 +08:00
										 |  |  | 		if ($this->input->post('exportLotw') == 1) { | 
					
						
							|  |  |  | 			$exportLotw = true; | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			$exportLotw = false; | 
					
						
							| 
									
										
										
										
											2020-11-18 01:35:48 +08:00
										 |  |  | 		} | 
					
						
							| 
									
										
										
										
											2021-03-09 03:20:05 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		$data['qsos'] = $this->adif_data->export_custom($this->input->post('from'), $this->input->post('to'), $station_id, $exportLotw); | 
					
						
							| 
									
										
										
										
											2014-09-26 06:09:44 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-18 01:35:48 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-09-21 21:30:01 +08:00
										 |  |  | 		$this->load->view('adif/data/exportall', $data); | 
					
						
							| 
									
										
										
										
											2014-09-26 06:09:44 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-11-18 01:35:48 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-04-01 14:43:08 +08:00
										 |  |  | 		if ($this->input->post('markLotw') == 1) { | 
					
						
							| 
									
										
										
										
											2025-08-29 17:59:42 +08:00
										 |  |  | 			foreach ($data['qsos']->result() as $qso) { | 
					
						
							|  |  |  | 				$this->adif_data->mark_lotw_sent($qso->COL_PRIMARY_KEY); | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2020-04-01 14:43:08 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-29 17:59:42 +08:00
										 |  |  | 	public function mark_lotw() | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		// Set memory limit to unlimited to allow heavy usage
 | 
					
						
							|  |  |  | 		ini_set('memory_limit', '-1'); | 
					
						
							| 
									
										
										
										
											2020-04-01 14:43:08 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-09 03:20:05 +08:00
										 |  |  | 		$station_id = $this->security->xss_clean($this->input->post('station_profile')); | 
					
						
							| 
									
										
										
										
											2025-08-29 17:59:42 +08:00
										 |  |  | 		$this->load->model('adif_data'); | 
					
						
							| 
									
										
										
										
											2020-04-01 14:43:08 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-29 17:59:42 +08:00
										 |  |  | 		$data['qsos'] = $this->adif_data->export_custom($this->input->post('from'), $this->input->post('to'), $station_id); | 
					
						
							| 
									
										
										
										
											2020-04-01 14:43:08 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-29 17:59:42 +08:00
										 |  |  | 		foreach ($data['qsos']->result() as $qso) { | 
					
						
							|  |  |  | 			$this->adif_data->mark_lotw_sent($qso->COL_PRIMARY_KEY); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2020-04-01 14:43:08 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-29 17:59:42 +08:00
										 |  |  | 		$this->load->view('adif/mark_lotw', $data); | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2011-09-21 21:30:01 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-05 12:57:29 +08:00
										 |  |  | 	public function export_lotw() | 
					
						
							|  |  |  | 	{ | 
					
						
							|  |  |  | 		// Set memory limit to unlimited to allow heavy usage
 | 
					
						
							|  |  |  | 		ini_set('memory_limit', '-1'); | 
					
						
							| 
									
										
										
										
											2014-09-26 06:09:44 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-03-05 12:57:29 +08:00
										 |  |  | 		$this->load->model('adif_data'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$data['qsos'] = $this->adif_data->export_lotw(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$this->load->view('adif/data/exportall', $data); | 
					
						
							| 
									
										
										
										
											2014-09-26 06:09:44 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-29 17:59:42 +08:00
										 |  |  | 		foreach ($data['qsos']->result() as $qso) { | 
					
						
							| 
									
										
										
										
											2013-03-07 13:31:19 +08:00
										 |  |  | 			$this->adif_data->mark_lotw_sent($qso->COL_PRIMARY_KEY); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2013-03-05 12:57:29 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2014-09-26 06:09:44 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-29 17:59:42 +08:00
										 |  |  | 	public function index() | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2019-08-20 05:25:50 +08:00
										 |  |  | 		$this->load->model('stations'); | 
					
						
							| 
									
										
										
										
											2019-09-25 06:42:01 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-10-21 04:49:05 +08:00
										 |  |  | 		$data['page_title'] = "ADIF Import / Export"; | 
					
						
							| 
									
										
										
										
											2019-06-30 07:06:24 +08:00
										 |  |  | 		$data['max_upload'] = ini_get('upload_max_filesize'); | 
					
						
							| 
									
										
										
										
											2019-09-25 06:42:01 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-11-16 02:46:20 +08:00
										 |  |  | 		$data['station_profile'] = $this->stations->all_of_user(); | 
					
						
							| 
									
										
										
										
											2025-08-29 17:59:42 +08:00
										 |  |  | 		$active_station_id = $this->stations->find_active(); | 
					
						
							|  |  |  | 		$station_profile = $this->stations->profile($active_station_id); | 
					
						
							| 
									
										
										
										
											2019-09-25 06:42:01 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		$data['active_station_info'] = $station_profile->row(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-06-30 07:06:24 +08:00
										 |  |  | 		$this->load->view('interface_assets/header', $data); | 
					
						
							|  |  |  | 		$this->load->view('adif/import'); | 
					
						
							|  |  |  | 		$this->load->view('interface_assets/footer'); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-29 17:59:42 +08:00
										 |  |  | 	public function import() | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2019-08-20 05:25:50 +08:00
										 |  |  | 		$this->load->model('stations'); | 
					
						
							| 
									
										
										
										
											2021-11-16 02:46:20 +08:00
										 |  |  | 		$data['station_profile'] = $this->stations->all_of_user(); | 
					
						
							| 
									
										
										
										
											2025-08-29 17:59:42 +08:00
										 |  |  | 		log_message("debug", "Started ADIF Import"); | 
					
						
							| 
									
										
										
										
											2014-09-26 06:09:44 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-29 17:59:42 +08:00
										 |  |  | 		$active_station_id = $this->stations->find_active(); | 
					
						
							|  |  |  | 		$station_profile = $this->stations->profile($active_station_id); | 
					
						
							| 
									
										
										
										
											2019-09-25 06:42:01 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		$data['active_station_info'] = $station_profile->row(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2011-11-20 06:28:05 +08:00
										 |  |  | 		$data['page_title'] = "ADIF Import"; | 
					
						
							| 
									
										
										
										
											2023-10-17 22:19:05 +08:00
										 |  |  | 		$data['tab'] = "adif"; | 
					
						
							| 
									
										
										
										
											2011-11-20 06:28:05 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-12-18 15:41:17 +08:00
										 |  |  | 		$config['upload_path'] = './uploads/'; | 
					
						
							| 
									
										
										
										
											2016-02-13 00:31:29 +08:00
										 |  |  | 		$config['allowed_types'] = 'adi|ADI|adif|ADIF'; | 
					
						
							| 
									
										
										
										
											2011-11-20 06:28:05 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 		$this->load->library('upload', $config); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-29 17:59:42 +08:00
										 |  |  | 		if (! $this->upload->do_upload()) { | 
					
						
							| 
									
										
										
										
											2011-11-20 06:28:05 +08:00
										 |  |  | 			$data['error'] = $this->upload->display_errors(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-05-16 23:19:56 +08:00
										 |  |  | 			$data['max_upload'] = ini_get('upload_max_filesize'); | 
					
						
							| 
									
										
										
										
											2019-05-16 23:03:52 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-01-14 03:11:46 +08:00
										 |  |  | 			$this->load->view('interface_assets/header', $data); | 
					
						
							| 
									
										
										
										
											2023-10-17 22:19:05 +08:00
										 |  |  | 			$this->load->view('adif/import', $data); | 
					
						
							| 
									
										
										
										
											2019-01-14 03:11:46 +08:00
										 |  |  | 			$this->load->view('interface_assets/footer'); | 
					
						
							| 
									
										
										
										
											2023-07-20 02:18:03 +08:00
										 |  |  | 		} else { | 
					
						
							|  |  |  | 			if ($this->stations->check_station_is_accessible($this->input->post('station_profile'))) { | 
					
						
							|  |  |  | 				$data = array('upload_data' => $this->upload->data()); | 
					
						
							|  |  |  | 				ini_set('memory_limit', '-1'); | 
					
						
							|  |  |  | 				set_time_limit(0); | 
					
						
							| 
									
										
										
										
											2011-11-20 06:28:05 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-20 02:18:03 +08:00
										 |  |  | 				$this->load->model('logbook_model'); | 
					
						
							| 
									
										
										
										
											2011-11-20 06:28:05 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-20 02:18:03 +08:00
										 |  |  | 				$this->load->library('adif_parser'); | 
					
						
							| 
									
										
										
										
											2011-11-20 06:28:05 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-29 17:59:42 +08:00
										 |  |  | 				$this->adif_parser->load_from_file('./uploads/' . $data['upload_data']['file_name']); | 
					
						
							|  |  |  | 				unlink('./uploads/' . $data['upload_data']['file_name']); | 
					
						
							|  |  |  | 				$data['upload_data'] = '';	// free memory
 | 
					
						
							| 
									
										
										
										
											2011-11-20 06:28:05 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-20 02:18:03 +08:00
										 |  |  | 				$this->adif_parser->initialize(); | 
					
						
							|  |  |  | 				$custom_errors = ""; | 
					
						
							| 
									
										
										
										
											2025-08-29 17:59:42 +08:00
										 |  |  | 				$alladif = []; | 
					
						
							|  |  |  | 				while ($record = $this->adif_parser->get_record()) { | 
					
						
							|  |  |  | 					if (count($record) == 0) { | 
					
						
							| 
									
										
										
										
											2023-07-20 02:18:03 +08:00
										 |  |  | 						break; | 
					
						
							|  |  |  | 					}; | 
					
						
							| 
									
										
										
										
											2025-08-29 17:59:42 +08:00
										 |  |  | 					array_push($alladif, $record); | 
					
						
							| 
									
										
										
										
											2011-11-20 06:28:05 +08:00
										 |  |  | 				}; | 
					
						
							| 
									
										
										
										
											2025-08-29 17:59:42 +08:00
										 |  |  | 				$record = '';	// free memory
 | 
					
						
							|  |  |  | 				$custom_errors = $this->logbook_model->import_bulk($alladif, $this->input->post('station_profile'), $this->input->post('skipDuplicate'), $this->input->post('markClublog'), $this->input->post('markLotw'), $this->input->post('dxccAdif'), $this->input->post('markQrz'), $this->input->post('markHrd'), true, $this->input->post('operatorName'), false, $this->input->post('skipStationCheck')); | 
					
						
							| 
									
										
										
										
											2023-07-20 02:18:03 +08:00
										 |  |  | 			} else { | 
					
						
							| 
									
										
										
										
											2025-08-29 17:59:42 +08:00
										 |  |  | 				$custom_errors = 'Station Profile not valid for User'; | 
					
						
							| 
									
										
										
										
											2023-07-20 02:18:03 +08:00
										 |  |  | 			} | 
					
						
							| 
									
										
										
										
											2011-11-20 06:28:05 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-03-09 03:20:05 +08:00
										 |  |  | 			$data['adif_errors'] = $custom_errors; | 
					
						
							| 
									
										
										
										
											2023-10-16 15:34:29 +08:00
										 |  |  | 			$data['skip_dupes'] = $this->input->post('skipDuplicate'); | 
					
						
							| 
									
										
										
										
											2019-10-22 00:41:21 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-29 17:59:42 +08:00
										 |  |  | 			log_message("debug", "Finished ADIF Import"); | 
					
						
							| 
									
										
										
										
											2011-11-20 06:28:05 +08:00
										 |  |  | 			$data['page_title'] = "ADIF Imported"; | 
					
						
							| 
									
										
										
										
											2019-01-14 03:11:46 +08:00
										 |  |  | 			$this->load->view('interface_assets/header', $data); | 
					
						
							| 
									
										
										
										
											2011-11-20 06:28:05 +08:00
										 |  |  | 			$this->load->view('adif/import_success'); | 
					
						
							| 
									
										
										
										
											2019-01-14 03:11:46 +08:00
										 |  |  | 			$this->load->view('interface_assets/footer'); | 
					
						
							| 
									
										
										
										
											2011-11-20 06:28:05 +08:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2023-10-17 22:19:05 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-29 17:59:42 +08:00
										 |  |  | 	public function dcl() | 
					
						
							|  |  |  | 	{ | 
					
						
							| 
									
										
										
										
											2023-10-17 22:19:05 +08:00
										 |  |  | 		$this->load->model('stations'); | 
					
						
							|  |  |  | 		$data['station_profile'] = $this->stations->all_of_user(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$data['page_title'] = "DCL Import"; | 
					
						
							|  |  |  | 		$data['tab'] = "dcl"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$config['upload_path'] = './uploads/'; | 
					
						
							|  |  |  | 		$config['allowed_types'] = 'adi|ADI|adif|ADIF'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 		$this->load->library('upload', $config); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-29 17:59:42 +08:00
										 |  |  | 		if (! $this->upload->do_upload()) { | 
					
						
							| 
									
										
										
										
											2023-10-17 22:19:05 +08:00
										 |  |  | 			$data['error'] = $this->upload->display_errors(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			$data['max_upload'] = ini_get('upload_max_filesize'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			$this->load->view('interface_assets/header', $data); | 
					
						
							|  |  |  | 			$this->load->view('adif/import', $data); | 
					
						
							|  |  |  | 			$this->load->view('interface_assets/footer'); | 
					
						
							|  |  |  | 		} else { | 
					
						
							|  |  |  | 			$data = array('upload_data' => $this->upload->data()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			ini_set('memory_limit', '-1'); | 
					
						
							|  |  |  | 			set_time_limit(0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			$this->load->model('logbook_model'); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 			$this->load->library('adif_parser'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-08-29 17:59:42 +08:00
										 |  |  | 			$this->adif_parser->load_from_file('./uploads/' . $data['upload_data']['file_name']); | 
					
						
							| 
									
										
										
										
											2023-10-17 22:19:05 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 			$this->adif_parser->initialize(); | 
					
						
							| 
									
										
										
										
											2023-10-18 17:31:15 +08:00
										 |  |  | 			$error_count = array(0, 0, 0); | 
					
						
							| 
									
										
										
										
											2023-10-17 22:19:05 +08:00
										 |  |  | 			$custom_errors = ""; | 
					
						
							| 
									
										
										
										
											2025-08-29 17:59:42 +08:00
										 |  |  | 			while ($record = $this->adif_parser->get_record()) { | 
					
						
							|  |  |  | 				if (count($record) == 0) { | 
					
						
							| 
									
										
										
										
											2023-10-17 22:19:05 +08:00
										 |  |  | 					break; | 
					
						
							|  |  |  | 				}; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 				$dok_result = $this->logbook_model->update_dok($record, $this->input->post('ignoreAmbiguous'), $this->input->post('onlyConfirmed'), $this->input->post('overwriteDok')); | 
					
						
							|  |  |  | 				if (!empty($dok_result)) { | 
					
						
							| 
									
										
										
										
											2023-10-18 17:31:15 +08:00
										 |  |  | 					switch ($dok_result[0]) { | 
					
						
							| 
									
										
										
										
											2025-08-29 17:59:42 +08:00
										 |  |  | 						case 0: | 
					
						
							|  |  |  | 							$error_count[0]++; | 
					
						
							|  |  |  | 							break; | 
					
						
							|  |  |  | 						case 1: | 
					
						
							|  |  |  | 							$custom_errors .= $dok_result[1]; | 
					
						
							|  |  |  | 							$error_count[1]++; | 
					
						
							|  |  |  | 							break; | 
					
						
							|  |  |  | 						case 2: | 
					
						
							|  |  |  | 							$custom_errors .= $dok_result[1]; | 
					
						
							|  |  |  | 							$error_count[2]++; | 
					
						
							| 
									
										
										
										
											2023-10-17 22:19:05 +08:00
										 |  |  | 					} | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			}; | 
					
						
							| 
									
										
										
										
											2025-08-29 17:59:42 +08:00
										 |  |  | 			unlink('./uploads/' . $data['upload_data']['file_name']); | 
					
						
							| 
									
										
										
										
											2023-10-17 22:19:05 +08:00
										 |  |  | 			$data['dcl_error_count'] = $error_count; | 
					
						
							|  |  |  | 			$data['dcl_errors'] = $custom_errors; | 
					
						
							|  |  |  | 			$data['page_title'] = "DCL Data Imported"; | 
					
						
							|  |  |  | 			$this->load->view('interface_assets/header', $data); | 
					
						
							|  |  |  | 			$this->load->view('adif/dcl_success'); | 
					
						
							|  |  |  | 			$this->load->view('interface_assets/footer'); | 
					
						
							|  |  |  | 		} | 
					
						
							| 
									
										
										
										
											2025-08-29 17:59:42 +08:00
										 |  |  | 	} | 
					
						
							| 
									
										
										
										
											2011-09-21 21:30:01 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-09-26 06:09:44 +08:00
										 |  |  | /* End of file adif.php */ |