Cloudlog/application/controllers/User.php

971 wiersze
38 KiB
PHP
Czysty Zwykły widok Historia

2011-08-18 00:31:15 +00:00
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class User extends CI_Controller {
function __construct()
{
parent::__construct();
$this->lang->load(array(
'account',
'lotw',
'eqsl',
'admin',
));
}
2011-08-18 00:31:15 +00:00
public function index()
{
$this->load->model('user_model');
2011-08-19 16:12:13 +00:00
if(!$this->user_model->authorize(99)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); }
2011-08-18 00:31:15 +00:00
$data['results'] = $this->user_model->users();
$data['page_title'] = $this->lang->line('admin_user_accounts');
2011-11-04 17:32:03 +00:00
$this->load->view('interface_assets/header', $data);
2011-11-04 17:32:03 +00:00
$this->load->view('user/main');
$this->load->view('interface_assets/footer');
2011-08-18 00:31:15 +00:00
}
function add() {
$this->load->model('user_model');
2011-08-19 16:12:13 +00:00
if(!$this->user_model->authorize(99)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); }
$data['existing_languages'] = $this->find();
$this->load->model('bands');
2011-08-18 00:31:15 +00:00
$this->load->library('form_validation');
$this->form_validation->set_rules('user_name', 'Username', 'required');
$this->form_validation->set_rules('user_email', 'E-mail', 'required');
$this->form_validation->set_rules('user_password', 'Password', 'required');
$this->form_validation->set_rules('user_type', 'Type', 'required');
$this->form_validation->set_rules('user_firstname', 'First name', 'required');
$this->form_validation->set_rules('user_lastname', 'Last name', 'required');
$this->form_validation->set_rules('user_callsign', 'Callsign', 'required');
$this->form_validation->set_rules('user_locator', 'Locator', 'required');
2022-10-27 13:18:50 +00:00
$this->form_validation->set_rules('user_locator', 'Locator', 'callback_check_locator');
$this->form_validation->set_rules('user_timezone', 'Timezone', 'required');
2023-12-17 18:16:23 +00:00
$data['user_add'] = true;
$data['user_form_action'] = site_url('user/add');
$data['bands'] = $this->bands->get_user_bands();
// Get themes list
$data['themes'] = $this->user_model->getThemes();
// Get timezones
$data['timezones'] = $this->user_model->timezones();
$data['language'] = 'english';
2011-08-18 00:31:15 +00:00
if ($this->form_validation->run() == FALSE) {
2011-11-04 17:32:03 +00:00
$data['page_title'] = "Add User";
$data['measurement_base'] = $this->config->item('measurement_base');
2011-11-04 17:32:03 +00:00
$this->load->view('interface_assets/header', $data);
if($this->input->post('user_name')) {
$data['user_name'] = $this->input->post('user_name');
$data['user_email'] = $this->input->post('user_email');
$data['user_password'] = $this->input->post('user_password');
$data['user_type'] = $this->input->post('user_type');
$data['user_firstname'] = $this->input->post('user_firstname');
$data['user_lastname'] = $this->input->post('user_lastname');
$data['user_callsign'] = $this->input->post('user_callsign');
$data['user_locator'] = $this->input->post('user_locator');
$data['user_timezone'] = $this->input->post('user_timezone');
$data['user_measurement_base'] = $this->input->post('user_measurement_base');
$data['user_stylesheet'] = $this->input->post('user_stylesheet');
$data['user_qth_lookup'] = $this->input->post('user_qth_lookup');
$data['user_sota_lookup'] = $this->input->post('user_sota_lookup');
$data['user_wwff_lookup'] = $this->input->post('user_wwff_lookup');
2023-05-01 19:14:30 +00:00
$data['user_pota_lookup'] = $this->input->post('user_pota_lookup');
$data['user_show_notes'] = $this->input->post('user_show_notes');
$data['user_column1'] = $this->input->post('user_column1');
$data['user_column2'] = $this->input->post('user_column2');
$data['user_column3'] = $this->input->post('user_column3');
$data['user_column4'] = $this->input->post('user_column4');
$data['user_column5'] = $this->input->post('user_column5');
2022-07-03 09:39:05 +00:00
$data['user_show_profile_image'] = $this->input->post('user_show_profile_image');
2022-11-24 23:22:31 +00:00
$data['user_previous_qsl_type'] = $this->input->post('user_previous_qsl_type');
$data['user_amsat_status_upload'] = $this->input->post('user_amsat_status_upload');
$data['user_mastodon_url'] = $this->input->post('user_mastodon_url');
$data['user_default_band'] = $this->input->post('user_default_band');
$data['user_default_confirmation'] = ($this->input->post('user_default_confirmation_qsl') !== null ? 'Q' : '').($this->input->post('user_default_confirmation_lotw') !== null ? 'L' : '').($this->input->post('user_default_confirmation_eqsl') !== null ? 'E' : '').($this->input->post('user_default_confirmation_qrz') !== null ? 'Z' : '');
Add option to log QSO end times separately Squashed commit of the following: commit 595f620d9ea32cde52cd8094c9ba928b2242ebce Author: phl0 <github@florian-wolters.de> Date: Wed Nov 1 13:58:05 2023 +0100 Update languages commit f670a0605923e3e3e50548cdc6872afce620d2bb Author: phl0 <github@florian-wolters.de> Date: Wed Nov 1 13:55:04 2023 +0100 Added user option for enabling QSO end time logging commit 36d9a95ebbebb6cdcdd382d1460dd858b425e1c7 Merge: 54d5bb53 352931b1 Author: phl0 <github@florian-wolters.de> Date: Wed Nov 1 12:18:39 2023 +0100 Merge branch 'dev' into qsoTime commit 54d5bb535bfe820feb617b2c7205733af7b9f91d Author: phl0 <github@florian-wolters.de> Date: Fri Oct 27 10:14:58 2023 +0200 start/end times for other languages commit c5f6bb0cab5dd3b38d1d74ec1a666c82a71929d6 Author: phl0 <github@florian-wolters.de> Date: Fri Oct 27 10:14:42 2023 +0200 Hide end time if only differs in seconds as we only display minutes anyway ... commit d519d88604bf1730a1c2e0631a6047326fa57a56 Author: phl0 <github@florian-wolters.de> Date: Fri Oct 27 10:14:29 2023 +0200 use start as end time if end is not set separately commit f2588ad1321df63d6840f33c05700f55eb681f9c Author: phl0 <github@florian-wolters.de> Date: Fri Oct 27 10:13:43 2023 +0200 reset timers on form reset commit 2b7ee4e48c27d0373e74a362f5c5d18d3616cd1e Author: phl0 <github@florian-wolters.de> Date: Fri Oct 27 10:13:27 2023 +0200 Strip seconds from session time variable commit e0c35aa0cfaf2569c1e9254d287a98251a771593 Author: phl0 <github@florian-wolters.de> Date: Fri Oct 27 10:13:11 2023 +0200 Adapt contest logging commit 5368ef25f3a59756654092767c863684775f4483 Author: phl0 <github@florian-wolters.de> Date: Fri Oct 27 10:12:50 2023 +0200 Make date field a little smaller commit ad2d7e756c101a387b4449ee0fcbfcbaac286d28 Author: phl0 <github@florian-wolters.de> Date: Fri Oct 27 10:12:30 2023 +0200 Add button to reset start time commit f56e031946ef80978857da4f49629a51bb98ad57 Author: phl0 <github@florian-wolters.de> Date: Fri Oct 27 10:11:09 2023 +0200 Copy start to end time on focus out commit b741d0428deac43efe33f8bf22943c09a994c271 Author: phl0 <github@florian-wolters.de> Date: Fri Oct 27 10:10:45 2023 +0200 Only min and sec for post QSO template commit 77314edd31be56469d1355b95287e580e8414d8b Author: phl0 <github@florian-wolters.de> Date: Fri Oct 27 10:08:49 2023 +0200 Basics for QSO end time logging
2023-11-01 13:24:13 +00:00
$data['user_qso_end_times'] = $this->input->post('user_qso_end_times');
2023-11-04 17:31:46 +00:00
$data['user_quicklog'] = $this->input->post('user_quicklog');
2023-11-05 11:29:59 +00:00
$data['user_quicklog_enter'] = $this->input->post('user_quicklog_enter');
$data['user_hamsat_key'] = $this->input->post('user_hamsat_key');
$data['user_hamsat_workable_only'] = $this->input->post('user_hamsat_workable_only');
$data['language'] = $this->input->post('language');
2023-12-17 18:16:23 +00:00
$this->load->view('user/edit', $data);
} else {
2023-12-17 18:16:23 +00:00
$this->load->view('user/edit', $data);
}
$this->load->view('interface_assets/footer');
} else {
switch($this->user_model->add($this->input->post('user_name'),
$this->input->post('user_password'),
$this->input->post('user_email'),
$this->input->post('user_type'),
$this->input->post('user_firstname'),
$this->input->post('user_lastname'),
$this->input->post('user_callsign'),
$this->input->post('user_locator'),
$this->input->post('user_timezone'),
$this->input->post('user_measurement_base'),
$this->input->post('user_date_format'),
$this->input->post('user_stylesheet'),
$this->input->post('user_qth_lookup'),
$this->input->post('user_sota_lookup'),
$this->input->post('user_wwff_lookup'),
2023-05-01 19:14:30 +00:00
$this->input->post('user_pota_lookup'),
$this->input->post('user_show_notes'),
$this->input->post('user_column1'),
$this->input->post('user_column2'),
$this->input->post('user_column3'),
$this->input->post('user_column4'),
$this->input->post('user_column5'),
2022-11-24 23:22:31 +00:00
$this->input->post('user_show_profile_image'),
$this->input->post('user_previous_qsl_type'),
$this->input->post('user_amsat_status_upload'),
$this->input->post('user_mastodon_url'),
$this->input->post('user_default_band'),
($this->input->post('user_default_confirmation_qsl') !== null ? 'Q' : '').($this->input->post('user_default_confirmation_lotw') !== null ? 'L' : '').($this->input->post('user_default_confirmation_eqsl') !== null ? 'E' : '').($this->input->post('user_default_confirmation_qrz') !== null ? 'Z' : ''),
Add option to log QSO end times separately Squashed commit of the following: commit 595f620d9ea32cde52cd8094c9ba928b2242ebce Author: phl0 <github@florian-wolters.de> Date: Wed Nov 1 13:58:05 2023 +0100 Update languages commit f670a0605923e3e3e50548cdc6872afce620d2bb Author: phl0 <github@florian-wolters.de> Date: Wed Nov 1 13:55:04 2023 +0100 Added user option for enabling QSO end time logging commit 36d9a95ebbebb6cdcdd382d1460dd858b425e1c7 Merge: 54d5bb53 352931b1 Author: phl0 <github@florian-wolters.de> Date: Wed Nov 1 12:18:39 2023 +0100 Merge branch 'dev' into qsoTime commit 54d5bb535bfe820feb617b2c7205733af7b9f91d Author: phl0 <github@florian-wolters.de> Date: Fri Oct 27 10:14:58 2023 +0200 start/end times for other languages commit c5f6bb0cab5dd3b38d1d74ec1a666c82a71929d6 Author: phl0 <github@florian-wolters.de> Date: Fri Oct 27 10:14:42 2023 +0200 Hide end time if only differs in seconds as we only display minutes anyway ... commit d519d88604bf1730a1c2e0631a6047326fa57a56 Author: phl0 <github@florian-wolters.de> Date: Fri Oct 27 10:14:29 2023 +0200 use start as end time if end is not set separately commit f2588ad1321df63d6840f33c05700f55eb681f9c Author: phl0 <github@florian-wolters.de> Date: Fri Oct 27 10:13:43 2023 +0200 reset timers on form reset commit 2b7ee4e48c27d0373e74a362f5c5d18d3616cd1e Author: phl0 <github@florian-wolters.de> Date: Fri Oct 27 10:13:27 2023 +0200 Strip seconds from session time variable commit e0c35aa0cfaf2569c1e9254d287a98251a771593 Author: phl0 <github@florian-wolters.de> Date: Fri Oct 27 10:13:11 2023 +0200 Adapt contest logging commit 5368ef25f3a59756654092767c863684775f4483 Author: phl0 <github@florian-wolters.de> Date: Fri Oct 27 10:12:50 2023 +0200 Make date field a little smaller commit ad2d7e756c101a387b4449ee0fcbfcbaac286d28 Author: phl0 <github@florian-wolters.de> Date: Fri Oct 27 10:12:30 2023 +0200 Add button to reset start time commit f56e031946ef80978857da4f49629a51bb98ad57 Author: phl0 <github@florian-wolters.de> Date: Fri Oct 27 10:11:09 2023 +0200 Copy start to end time on focus out commit b741d0428deac43efe33f8bf22943c09a994c271 Author: phl0 <github@florian-wolters.de> Date: Fri Oct 27 10:10:45 2023 +0200 Only min and sec for post QSO template commit 77314edd31be56469d1355b95287e580e8414d8b Author: phl0 <github@florian-wolters.de> Date: Fri Oct 27 10:08:49 2023 +0200 Basics for QSO end time logging
2023-11-01 13:24:13 +00:00
$this->input->post('user_qso_end_times'),
2023-11-04 17:31:46 +00:00
$this->input->post('user_quicklog'),
2023-11-05 11:29:59 +00:00
$this->input->post('user_quicklog_enter'),
$this->input->post('language'),
$this->input->post('user_hamsat_key'),
2024-03-13 16:44:52 +00:00
$this->input->post('user_hamsat_workable_only')
)) {
2011-08-19 16:12:13 +00:00
// Check for errors
case EUSERNAMEEXISTS:
$data['username_error'] = 'Username <b>'.$this->input->post('user_name').'</b> already in use!';
break;
case EEMAILEXISTS:
$data['email_error'] = 'E-mail address <b>'.$this->input->post('user_email').'</b> already in use!';
break;
case EPASSWORDINVALID:
$data['password_error'] = 'Invalid password!';
break;
// All okay, return to user screen
case OK:
$this->session->set_flashdata('notice', 'User '.$this->input->post('user_name').' added');
redirect('user');
return;
}
2011-11-04 17:32:03 +00:00
$data['page_title'] = "Users";
$this->load->view('interface_assets/header', $data);
2011-08-19 16:12:13 +00:00
$data['user_name'] = $this->input->post('user_name');
$data['user_email'] = $this->input->post('user_email');
$data['user_password'] = $this->input->post('user_password');
$data['user_type'] = $this->input->post('user_type');
$data['user_firstname'] = $this->input->post('user_firstname');
$data['user_lastname'] = $this->input->post('user_lastname');
$data['user_callsign'] = $this->input->post('user_callsign');
$data['user_locator'] = $this->input->post('user_locator');
$data['user_measurement_base'] = $this->input->post('user_measurement_base');
$data['user_stylesheet'] = $this->input->post('user_stylesheet');
$data['user_qth_lookup'] = $this->input->post('user_qth_lookup');
$data['user_sota_lookup'] = $this->input->post('user_sota_lookup');
$data['user_wwff_lookup'] = $this->input->post('user_wwff_lookup');
2023-05-01 19:14:30 +00:00
$data['user_pota_lookup'] = $this->input->post('user_pota_lookup');
$data['user_show_notes'] = $this->input->post('user_show_notes');
$data['user_column1'] = $this->input->post('user_column1');
$data['user_column2'] = $this->input->post('user_column2');
$data['user_column3'] = $this->input->post('user_column3');
$data['user_column4'] = $this->input->post('user_column4');
$data['user_column5'] = $this->input->post('user_column5');
2022-07-03 09:39:05 +00:00
$data['user_show_profile_image'] = $this->input->post('user_show_profile_image');
2022-11-24 23:22:31 +00:00
$data['user_previous_qsl_type'] = $this->input->post('user_previous_qsl_type');
$data['user_amsat_status_upload'] = $this->input->post('user_amsat_status_upload');
$data['user_mastodon_url'] = $this->input->post('user_mastodon_url');
$data['user_default_band'] = $this->input->post('user_default_band');
$data['user_default_confirmation'] = ($this->input->post('user_default_confirmation_qsl') !== null ? 'Q' : '').($this->input->post('user_default_confirmation_lotw') !== null ? 'L' : '').($this->input->post('user_default_confirmation_eqsl') !== null ? 'E' : '').($this->input->post('user_default_confirmation_qrz') !== null ? 'Z' : '');
Add option to log QSO end times separately Squashed commit of the following: commit 595f620d9ea32cde52cd8094c9ba928b2242ebce Author: phl0 <github@florian-wolters.de> Date: Wed Nov 1 13:58:05 2023 +0100 Update languages commit f670a0605923e3e3e50548cdc6872afce620d2bb Author: phl0 <github@florian-wolters.de> Date: Wed Nov 1 13:55:04 2023 +0100 Added user option for enabling QSO end time logging commit 36d9a95ebbebb6cdcdd382d1460dd858b425e1c7 Merge: 54d5bb53 352931b1 Author: phl0 <github@florian-wolters.de> Date: Wed Nov 1 12:18:39 2023 +0100 Merge branch 'dev' into qsoTime commit 54d5bb535bfe820feb617b2c7205733af7b9f91d Author: phl0 <github@florian-wolters.de> Date: Fri Oct 27 10:14:58 2023 +0200 start/end times for other languages commit c5f6bb0cab5dd3b38d1d74ec1a666c82a71929d6 Author: phl0 <github@florian-wolters.de> Date: Fri Oct 27 10:14:42 2023 +0200 Hide end time if only differs in seconds as we only display minutes anyway ... commit d519d88604bf1730a1c2e0631a6047326fa57a56 Author: phl0 <github@florian-wolters.de> Date: Fri Oct 27 10:14:29 2023 +0200 use start as end time if end is not set separately commit f2588ad1321df63d6840f33c05700f55eb681f9c Author: phl0 <github@florian-wolters.de> Date: Fri Oct 27 10:13:43 2023 +0200 reset timers on form reset commit 2b7ee4e48c27d0373e74a362f5c5d18d3616cd1e Author: phl0 <github@florian-wolters.de> Date: Fri Oct 27 10:13:27 2023 +0200 Strip seconds from session time variable commit e0c35aa0cfaf2569c1e9254d287a98251a771593 Author: phl0 <github@florian-wolters.de> Date: Fri Oct 27 10:13:11 2023 +0200 Adapt contest logging commit 5368ef25f3a59756654092767c863684775f4483 Author: phl0 <github@florian-wolters.de> Date: Fri Oct 27 10:12:50 2023 +0200 Make date field a little smaller commit ad2d7e756c101a387b4449ee0fcbfcbaac286d28 Author: phl0 <github@florian-wolters.de> Date: Fri Oct 27 10:12:30 2023 +0200 Add button to reset start time commit f56e031946ef80978857da4f49629a51bb98ad57 Author: phl0 <github@florian-wolters.de> Date: Fri Oct 27 10:11:09 2023 +0200 Copy start to end time on focus out commit b741d0428deac43efe33f8bf22943c09a994c271 Author: phl0 <github@florian-wolters.de> Date: Fri Oct 27 10:10:45 2023 +0200 Only min and sec for post QSO template commit 77314edd31be56469d1355b95287e580e8414d8b Author: phl0 <github@florian-wolters.de> Date: Fri Oct 27 10:08:49 2023 +0200 Basics for QSO end time logging
2023-11-01 13:24:13 +00:00
$data['user_qso_end_times'] = $this->input->post('user_qso_end_times');
2023-11-04 17:31:46 +00:00
$data['user_quicklog'] = $this->input->post('user_quicklog');
2023-11-05 11:29:59 +00:00
$data['user_quicklog_enter'] = $this->input->post('user_quicklog_enter');
$data['language'] = $this->input->post('language');
2023-12-17 18:16:23 +00:00
$this->load->view('user/edit', $data);
$this->load->view('interface_assets/footer');
2011-08-18 00:31:15 +00:00
}
}
function find() {
$existing_langs = array();
$lang_path = APPPATH.'language';
$results = scandir($lang_path);
foreach ($results as $result) {
if ($result === '.' or $result === '..') continue;
if (is_dir(APPPATH.'language' . '/' . $result)) {
$dirs[] = $result;
}
}
return $dirs;
}
2011-08-18 00:31:15 +00:00
function edit() {
$this->load->model('user_model');
if ( ($this->session->userdata('user_id') == '') || ((!$this->user_model->authorize(99)) && ($this->session->userdata('user_id') != $this->uri->segment(3))) ) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); }
2011-08-18 00:31:15 +00:00
$query = $this->user_model->get_by_id($this->uri->segment(3));
$data['existing_languages'] = $this->find();
$this->load->model('bands');
2011-08-18 00:31:15 +00:00
$this->load->library('form_validation');
$this->form_validation->set_rules('user_name', 'Username', 'required|xss_clean');
$this->form_validation->set_rules('user_email', 'E-mail', 'required|xss_clean');
if($this->session->userdata('user_type') == 99)
{
$this->form_validation->set_rules('user_type', 'Type', 'required|xss_clean');
}
$this->form_validation->set_rules('user_firstname', 'First name', 'required|xss_clean');
$this->form_validation->set_rules('user_lastname', 'Last name', 'required|xss_clean');
$this->form_validation->set_rules('user_callsign', 'Callsign', 'trim|required|xss_clean');
2022-10-27 13:18:50 +00:00
$this->form_validation->set_rules('user_locator', 'Locator', 'callback_check_locator');
$this->form_validation->set_rules('user_timezone', 'Timezone', 'required');
2011-08-18 00:31:15 +00:00
2023-12-17 18:16:23 +00:00
$data['user_form_action'] = site_url('user/edit')."/".$this->uri->segment(3);;
$data['bands'] = $this->bands->get_user_bands();
// Get themes list
$data['themes'] = $this->user_model->getThemes();
// Get timezones
$data['timezones'] = $this->user_model->timezones();
2011-08-18 00:31:15 +00:00
if ($this->form_validation->run() == FALSE)
{
2011-11-04 17:32:03 +00:00
$data['page_title'] = "Edit User";
$q = $query->row();
$data['id'] = $q->user_id;
if($this->input->post('user_name', true)) {
$data['user_name'] = $this->input->post('user_name', true);
} else {
$data['user_name'] = $q->user_name;
}
if($this->input->post('user_email', true)) {
$data['user_email'] = $this->input->post('user_email', true);
} else {
$data['user_email'] = $q->user_email;
}
if($this->input->post('user_password', true)) {
$data['user_password'] = $this->input->post('user_password',true);
} else {
$data['user_password'] = $q->user_password;
}
if($this->input->post('user_type', true)) {
$data['user_type'] = $this->input->post('user_type',true);
} else {
$data['user_type'] = $q->user_type;
2011-08-19 16:12:13 +00:00
}
if($this->input->post('user_callsign', true)) {
$data['user_callsign'] = $this->input->post('user_callsign', true);
} else {
$data['user_callsign'] = $q->user_callsign;
}
if($this->input->post('user_locator', true)) {
$data['user_locator'] = $this->input->post('user_locator', true);
} else {
$data['user_locator'] = $q->user_locator;
}
if($this->input->post('user_firstname', true)) {
$data['user_firstname'] = $this->input->post('user_firstname', true);
} else {
$data['user_firstname'] = $q->user_firstname;
}
if($this->input->post('user_lastname', true)) {
$data['user_lastname'] = $this->input->post('user_lastname', true);
} else {
$data['user_lastname'] = $q->user_lastname;
}
if($this->input->post('user_callsign', true)) {
$data['user_callsign'] = $this->input->post('user_callsign', true);
} else {
$data['user_callsign'] = $q->user_callsign;
}
if($this->input->post('user_locator', true)) {
$data['user_locator'] = $this->input->post('user_locator', true);
} else {
$data['user_locator'] = $q->user_locator;
}
if($this->input->post('user_timezone')) {
$data['user_timezone'] = $this->input->post('user_timezone', true);
} else {
$data['user_timezone'] = $q->user_timezone;
}
if($this->input->post('user_lotw_name')) {
$data['user_lotw_name'] = $this->input->post('user_lotw_name', true);
} else {
$data['user_lotw_name'] = $q->user_lotw_name;
}
if($this->input->post('user_clublog_name')) {
$data['user_clublog_name'] = $this->input->post('user_clublog_name', true);
} else {
$data['user_clublog_name'] = $q->user_clublog_name;
}
if($this->input->post('user_clublog_password')) {
$data['user_clublog_password'] = $this->input->post('user_clublog_password', true);
} else {
$data['user_clublog_password'] = $q->user_clublog_password;
}
if($this->input->post('user_lotw_password')) {
$data['user_lotw_password'] = $this->input->post('user_lotw_password', true);
} else {
$data['user_lotw_password'] = $q->user_lotw_password;
}
if($this->input->post('user_eqsl_name')) {
$data['user_eqsl_name'] = $this->input->post('user_eqsl_name', true);
} else {
$data['user_eqsl_name'] = $q->user_eqsl_name;
}
if($this->input->post('user_eqsl_password')) {
$data['user_eqsl_password'] = $this->input->post('user_eqsl_password', true);
} else {
$data['user_eqsl_password'] = $q->user_eqsl_password;
}
if($this->input->post('user_measurement_base')) {
$data['user_measurement_base'] = $this->input->post('user_measurement_base', true);
} else {
$data['user_measurement_base'] = $q->user_measurement_base;
}
if($this->input->post('user_date_format')) {
$data['user_date_format'] = $this->input->post('user_date_format', true);
} else {
$data['user_date_format'] = $q->user_date_format;
}
2020-09-23 08:59:49 +00:00
if($this->input->post('language')) {
$data['language'] = $this->input->post('language', true);
} else {
$data['language'] = $q->language;
}
if($this->input->post('user_stylesheet')) {
$data['user_stylesheet'] = $this->input->post('user_stylesheet', true);
} else {
$data['user_stylesheet'] = $q->user_stylesheet;
}
if($this->input->post('user_qth_lookup')) {
$data['user_qth_lookup'] = $this->input->post('user_qth_lookup', true);
} else {
$data['user_qth_lookup'] = $q->user_qth_lookup;
}
if($this->input->post('user_sota_lookup')) {
$data['user_sota_lookup'] = $this->input->post('user_sota_lookup', true);
} else {
$data['user_sota_lookup'] = $q->user_sota_lookup;
}
if($this->input->post('user_wwff_lookup')) {
$data['user_wwff_lookup'] = $this->input->post('user_wwff_lookup', true);
} else {
$data['user_wwff_lookup'] = $q->user_wwff_lookup;
}
2023-05-01 19:14:30 +00:00
if($this->input->post('user_pota_lookup')) {
$data['user_pota_lookup'] = $this->input->post('user_pota_lookup', true);
} else {
$data['user_pota_lookup'] = $q->user_pota_lookup;
}
if($this->input->post('user_show_notes')) {
$data['user_show_notes'] = $this->input->post('user_show_notes', true);
} else {
$data['user_show_notes'] = $q->user_show_notes;
}
Add option to log QSO end times separately Squashed commit of the following: commit 595f620d9ea32cde52cd8094c9ba928b2242ebce Author: phl0 <github@florian-wolters.de> Date: Wed Nov 1 13:58:05 2023 +0100 Update languages commit f670a0605923e3e3e50548cdc6872afce620d2bb Author: phl0 <github@florian-wolters.de> Date: Wed Nov 1 13:55:04 2023 +0100 Added user option for enabling QSO end time logging commit 36d9a95ebbebb6cdcdd382d1460dd858b425e1c7 Merge: 54d5bb53 352931b1 Author: phl0 <github@florian-wolters.de> Date: Wed Nov 1 12:18:39 2023 +0100 Merge branch 'dev' into qsoTime commit 54d5bb535bfe820feb617b2c7205733af7b9f91d Author: phl0 <github@florian-wolters.de> Date: Fri Oct 27 10:14:58 2023 +0200 start/end times for other languages commit c5f6bb0cab5dd3b38d1d74ec1a666c82a71929d6 Author: phl0 <github@florian-wolters.de> Date: Fri Oct 27 10:14:42 2023 +0200 Hide end time if only differs in seconds as we only display minutes anyway ... commit d519d88604bf1730a1c2e0631a6047326fa57a56 Author: phl0 <github@florian-wolters.de> Date: Fri Oct 27 10:14:29 2023 +0200 use start as end time if end is not set separately commit f2588ad1321df63d6840f33c05700f55eb681f9c Author: phl0 <github@florian-wolters.de> Date: Fri Oct 27 10:13:43 2023 +0200 reset timers on form reset commit 2b7ee4e48c27d0373e74a362f5c5d18d3616cd1e Author: phl0 <github@florian-wolters.de> Date: Fri Oct 27 10:13:27 2023 +0200 Strip seconds from session time variable commit e0c35aa0cfaf2569c1e9254d287a98251a771593 Author: phl0 <github@florian-wolters.de> Date: Fri Oct 27 10:13:11 2023 +0200 Adapt contest logging commit 5368ef25f3a59756654092767c863684775f4483 Author: phl0 <github@florian-wolters.de> Date: Fri Oct 27 10:12:50 2023 +0200 Make date field a little smaller commit ad2d7e756c101a387b4449ee0fcbfcbaac286d28 Author: phl0 <github@florian-wolters.de> Date: Fri Oct 27 10:12:30 2023 +0200 Add button to reset start time commit f56e031946ef80978857da4f49629a51bb98ad57 Author: phl0 <github@florian-wolters.de> Date: Fri Oct 27 10:11:09 2023 +0200 Copy start to end time on focus out commit b741d0428deac43efe33f8bf22943c09a994c271 Author: phl0 <github@florian-wolters.de> Date: Fri Oct 27 10:10:45 2023 +0200 Only min and sec for post QSO template commit 77314edd31be56469d1355b95287e580e8414d8b Author: phl0 <github@florian-wolters.de> Date: Fri Oct 27 10:08:49 2023 +0200 Basics for QSO end time logging
2023-11-01 13:24:13 +00:00
if($this->input->post('user_qso_end_times')) {
$data['user_qso_end_times'] = $this->input->post('user_qso_end_times', true);
} else {
$data['user_qso_end_times'] = $q->user_qso_end_times;
}
2023-11-04 17:31:46 +00:00
if($this->input->post('user_quicklog')) {
$data['user_quicklog'] = $this->input->post('user_quicklog', true);
} else {
$data['user_quicklog'] = $q->user_quicklog;
}
2023-11-05 11:29:59 +00:00
if($this->input->post('user_quicklog_enter')) {
$data['user_quicklog_enter'] = $this->input->post('user_quicklog_enter', true);
} else {
$data['user_quicklog_enter'] = $q->user_quicklog_enter;
}
2022-07-03 09:39:05 +00:00
if($this->input->post('user_show_profile_image')) {
$data['user_show_profile_image'] = $this->input->post('user_show_profile_image', false);
} else {
2022-07-03 09:39:05 +00:00
$data['user_show_profile_image'] = $q->user_show_profile_image;
}
2022-11-24 23:22:31 +00:00
if($this->input->post('user_previous_qsl_type')) {
$data['user_previous_qsl_type'] = $this->input->post('user_previous_qsl_type', false);
} else {
$data['user_previous_qsl_type'] = $q->user_previous_qsl_type;
}
if($this->input->post('user_amsat_status_upload')) {
$data['user_amsat_status_upload'] = $this->input->post('user_amsat_status_upload', false);
} else {
$data['user_amsat_status_upload'] = $q->user_amsat_status_upload;
}
if($this->input->post('user_mastodon_url')) {
$data['user_mastodon_url'] = $this->input->post('user_mastodon_url', false);
} else {
$data['user_mastodon_url'] = $q->user_mastodon_url;
}
if($this->input->post('user_default_band')) {
$data['user_default_band'] = $this->input->post('user_default_band', false);
} else {
$data['user_default_band'] = $q->user_default_band;
}
if($this->input->post('user_default_confirmation')) {
$data['user_default_confirmation'] = ($this->input->post('user_default_confirmation_qsl') !== null ? 'Q' : '').($this->input->post('user_default_confirmation_lotw') !== null ? 'L' : '').($this->input->post('user_default_confirmation_eqsl') !== null ? 'E' : '').($this->input->post('user_default_confirmation_qrz') !== null ? 'Z' : '');
} else {
$data['user_default_confirmation'] = $q->user_default_confirmation;
}
if($this->input->post('user_column1')) {
$data['user_column1'] = $this->input->post('user_column1', true);
} else {
$data['user_column1'] = $q->user_column1;
}
if($this->input->post('user_column2')) {
$data['user_column2'] = $this->input->post('user_column2', true);
} else {
$data['user_column2'] = $q->user_column2;
}
if($this->input->post('user_column3')) {
$data['user_column3'] = $this->input->post('user_column3', true);
} else {
$data['user_column3'] = $q->user_column3;
}
if($this->input->post('user_column4')) {
$data['user_column4'] = $this->input->post('user_column4', true);
} else {
$data['user_column4'] = $q->user_column4;
}
if($this->input->post('user_column5')) {
$data['user_column5'] = $this->input->post('user_column5', true);
} else {
$data['user_column5'] = $q->user_column5;
}
if($this->input->post('user_winkey')) {
$data['user_winkey'] = $this->input->post('user_winkey', true);
} else {
$data['user_winkey'] = $q->winkey;
}
2024-03-11 18:31:23 +00:00
$this->load->model('user_options_model');
$hamsat_user_object = $this->user_options_model->get_options('hamsat')->result();
if($this->input->post('user_hamsat_key', true)) {
$data['user_hamsat_key'] = $this->input->post('user_hamsat_key', true);
} else {
// get $q->hamsat_key if its set if not null
2024-03-11 18:31:23 +00:00
if(isset($hamsat_user_object[0]->option_value)) {
$data['user_hamsat_key'] = $hamsat_user_object[0]->option_value;
} else {
$data['user_hamsat_key'] = "";
}
}
if($this->input->post('user_hamsat_workable_only')) {
$data['user_hamsat_workable_only'] = $this->input->post('user_hamsat_workable_only', false);
} else {
2024-03-11 18:31:23 +00:00
if(isset($hamsat_user_object[1]->option_value)) {
$data['user_hamsat_workable_only'] = $hamsat_user_object[1]->option_value;
} else {
$data['user_hamsat_workable_only'] = "";
}
}
2023-11-30 17:11:22 +00:00
// [MAP Custom] GET user options //
$this->load->model('user_options_model');
$options_object = $this->user_options_model->get_options('map_custom')->result();
if (count($options_object)>0) {
foreach ($options_object as $row) {
if ($row->option_name=='icon') {
$option_value = json_decode($row->option_value,true);
foreach ($option_value as $ktype => $vtype) {
if($this->input->post('user_map_'.$row->option_key.'_icon')) {
$data['user_map_'.$row->option_key.'_'.$ktype] = $this->input->post('user_map_'.$row->option_key.'_'.$ktype, true);
} else {
$data['user_map_'.$row->option_key.'_'.$ktype] = $vtype;
}
}
} else {
$data['user_map_'.$row->option_name.'_'.$row->option_key] = $row->option_value;
}
}
} else {
$data['user_map_qso_icon'] = "fas fa-dot-circle";
$data['user_map_qso_color'] = "#FF0000";
$data['user_map_station_icon'] = "0";
$data['user_map_station_color'] = "#0000FF";
$data['user_map_qsoconfirm_icon'] = "0";
$data['user_map_qsoconfirm_color'] = "#00AA00";
$data['user_map_gridsquare_show'] = "0";
}
$data['map_icon_select'] = array(
'station'=>array('0', 'fas fa-home', 'fas fa-broadcast-tower', 'fas fa-user', 'fas fa-dot-circle' ),
'qso'=>array('fas fa-broadcast-tower', 'fas fa-user', 'fas fa-dot-circle' ),
'qsoconfirm'=>array('0', 'fas fa-broadcast-tower', 'fas fa-user', 'fas fa-dot-circle', 'fas fa-check-circle' ));
$this->load->view('interface_assets/header', $data);
2011-08-19 16:12:13 +00:00
$this->load->view('user/edit', $data);
$this->load->view('interface_assets/footer');
} else {
2011-08-19 16:12:13 +00:00
unset($data);
switch($this->user_model->edit($this->input->post())) {
2011-08-19 16:12:13 +00:00
// Check for errors
case EUSERNAMEEXISTS:
2019-10-05 18:35:55 +00:00
$data['username_error'] = 'Username <b>'.$this->input->post('user_name', true).'</b> already in use!';
2011-08-19 16:12:13 +00:00
break;
case EEMAILEXISTS:
2019-10-05 18:35:55 +00:00
$data['email_error'] = 'E-mail address <b>'.$this->input->post('user_email', true).'</b> already in use!';
2011-08-19 16:12:13 +00:00
break;
case EPASSWORDINVALID:
$data['password_error'] = 'Invalid password!';
break;
// All okay, return to user screen
case OK:
if ($this->session->userdata('user_id') == $this->uri->segment(3)) { // Editing own User? Set cookie!
$cookie= array(
'name' => 'language',
'value' => $this->input->post('language', true),
'expire' => time()+1000,
'secure' => FALSE
);
$this->input->set_cookie($cookie);
}
2019-10-05 18:35:55 +00:00
if($this->session->userdata('user_id') == $this->input->post('id', true)) {
2023-11-30 17:11:22 +00:00
// [MAP Custom] ADD to user options //
$array_icon = array('station','qso','qsoconfirm');
foreach ($array_icon as $icon) {
$data_options['user_map_'.$icon.'_icon'] = xss_clean($this->input->post('user_map_'.$icon.'_icon', true));
$data_options['user_map_'.$icon.'_color'] = xss_clean($this->input->post('user_map_'.$icon.'_color', true));
}
$this->load->model('user_options_model');
if (!empty($data_options['user_map_qso_icon'])) {
foreach ($array_icon as $icon) {
$json = json_encode(array('icon'=>$data_options['user_map_'.$icon.'_icon'], 'color'=>$data_options['user_map_'.$icon.'_color']));
$this->user_options_model->set_option('map_custom','icon',array($icon=>$json));
}
$this->user_options_model->set_option('map_custom','gridsquare',array('show'=>xss_clean($this->input->post('user_map_gridsquare_show', true))));
} else {
$this->user_options_model->del_option('map_custom','icon');
$this->user_options_model->del_option('map_custom','gridsquare');
}
$this->session->set_flashdata('success', lang('account_user').' '.$this->input->post('user_name', true).' '.lang('account_word_edited'));
redirect('user/edit/'.$this->uri->segment(3));
} else {
$this->session->set_flashdata('success', lang('account_user').' '.$this->input->post('user_name', true).' '.lang('account_word_edited'));
redirect('user');
}
2011-08-19 16:12:13 +00:00
return;
}
2011-11-04 17:32:03 +00:00
$data['page_title'] = "Edit User";
$this->load->view('interface_assets/header', $data);
$data['user_name'] = $this->input->post('user_name', true);
$data['user_email'] = $this->input->post('user_email', true);
$data['user_password'] = $this->input->post('user_password', true);
$data['user_type'] = $this->input->post('user_type', true);
$data['user_firstname'] = $this->input->post('user_firstname', true);
$data['user_lastname'] = $this->input->post('user_lastname', true);
$data['user_callsign'] = $this->input->post('user_callsign', true);
$data['user_locator'] = $this->input->post('user_locator', true);
$data['user_timezone'] = $this->input->post('user_timezone', true);
$data['user_stylesheet'] = $this->input->post('user_stylesheet');
$data['user_qth_lookup'] = $this->input->post('user_qth_lookup');
$data['user_sota_lookup'] = $this->input->post('user_sota_lookup');
$data['user_wwff_lookup'] = $this->input->post('user_wwff_lookup');
2023-05-01 19:14:30 +00:00
$data['user_pota_lookup'] = $this->input->post('user_pota_lookup');
$data['user_show_notes'] = $this->input->post('user_show_notes');
$data['user_column1'] = $this->input->post('user_column1');
$data['user_column2'] = $this->input->post('user_column2');
$data['user_column3'] = $this->input->post('user_column3');
$data['user_column4'] = $this->input->post('user_column4');
$data['user_column4'] = $this->input->post('user_column4');
$data['user_column5'] = $this->input->post('user_column5');
2022-07-03 09:39:05 +00:00
$data['user_show_profile_image'] = $this->input->post('user_show_profile_image');
2022-11-24 23:22:31 +00:00
$data['user_previous_qsl_type'] = $this->input->post('user_previous_qsl_type');
$data['user_amsat_status_upload'] = $this->input->post('user_amsat_status_upload');
$data['user_mastodon_url'] = $this->input->post('user_mastodon_url');
$data['user_default_band'] = $this->input->post('user_default_band');
$data['user_default_confirmation'] = ($this->input->post('user_default_confirmation_qsl') !== null ? 'Q' : '').($this->input->post('user_default_confirmation_lotw') !== null ? 'L' : '').($this->input->post('user_default_confirmation_eqsl') !== null ? 'E' : '').($this->input->post('user_default_confirmation_qrz') !== null ? 'Z' : '');
Add option to log QSO end times separately Squashed commit of the following: commit 595f620d9ea32cde52cd8094c9ba928b2242ebce Author: phl0 <github@florian-wolters.de> Date: Wed Nov 1 13:58:05 2023 +0100 Update languages commit f670a0605923e3e3e50548cdc6872afce620d2bb Author: phl0 <github@florian-wolters.de> Date: Wed Nov 1 13:55:04 2023 +0100 Added user option for enabling QSO end time logging commit 36d9a95ebbebb6cdcdd382d1460dd858b425e1c7 Merge: 54d5bb53 352931b1 Author: phl0 <github@florian-wolters.de> Date: Wed Nov 1 12:18:39 2023 +0100 Merge branch 'dev' into qsoTime commit 54d5bb535bfe820feb617b2c7205733af7b9f91d Author: phl0 <github@florian-wolters.de> Date: Fri Oct 27 10:14:58 2023 +0200 start/end times for other languages commit c5f6bb0cab5dd3b38d1d74ec1a666c82a71929d6 Author: phl0 <github@florian-wolters.de> Date: Fri Oct 27 10:14:42 2023 +0200 Hide end time if only differs in seconds as we only display minutes anyway ... commit d519d88604bf1730a1c2e0631a6047326fa57a56 Author: phl0 <github@florian-wolters.de> Date: Fri Oct 27 10:14:29 2023 +0200 use start as end time if end is not set separately commit f2588ad1321df63d6840f33c05700f55eb681f9c Author: phl0 <github@florian-wolters.de> Date: Fri Oct 27 10:13:43 2023 +0200 reset timers on form reset commit 2b7ee4e48c27d0373e74a362f5c5d18d3616cd1e Author: phl0 <github@florian-wolters.de> Date: Fri Oct 27 10:13:27 2023 +0200 Strip seconds from session time variable commit e0c35aa0cfaf2569c1e9254d287a98251a771593 Author: phl0 <github@florian-wolters.de> Date: Fri Oct 27 10:13:11 2023 +0200 Adapt contest logging commit 5368ef25f3a59756654092767c863684775f4483 Author: phl0 <github@florian-wolters.de> Date: Fri Oct 27 10:12:50 2023 +0200 Make date field a little smaller commit ad2d7e756c101a387b4449ee0fcbfcbaac286d28 Author: phl0 <github@florian-wolters.de> Date: Fri Oct 27 10:12:30 2023 +0200 Add button to reset start time commit f56e031946ef80978857da4f49629a51bb98ad57 Author: phl0 <github@florian-wolters.de> Date: Fri Oct 27 10:11:09 2023 +0200 Copy start to end time on focus out commit b741d0428deac43efe33f8bf22943c09a994c271 Author: phl0 <github@florian-wolters.de> Date: Fri Oct 27 10:10:45 2023 +0200 Only min and sec for post QSO template commit 77314edd31be56469d1355b95287e580e8414d8b Author: phl0 <github@florian-wolters.de> Date: Fri Oct 27 10:08:49 2023 +0200 Basics for QSO end time logging
2023-11-01 13:24:13 +00:00
$data['user_qso_end_times'] = $this->input->post('user_qso_end_times');
2023-11-04 17:31:46 +00:00
$data['user_quicklog'] = $this->input->post('user_quicklog');
2023-11-05 11:29:59 +00:00
$data['user_quicklog_enter'] = $this->input->post('user_quicklog_enter');
$data['language'] = $this->input->post('language');
$data['user_winkey'] = $this->input->post('user_winkey');
$data['user_hamsat_key'] = $this->input->post('user_hamsat_key');
$data['user_hamsat_workable_only'] = $this->input->post('user_hamsat_workable_only');
2011-11-04 17:32:03 +00:00
$this->load->view('user/edit');
$this->load->view('interface_assets/footer');
2011-08-18 00:31:15 +00:00
}
2011-08-19 16:12:13 +00:00
}
function profile() {
$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'); }
$query = $this->user_model->get_by_id($this->session->userdata('user_id'));
$q = $query->row();
$data['page_title'] = "Profile";
$data['user_name'] = $q->user_name;
$data['user_type'] = $q->user_type;
$data['user_email'] = $q->user_email;
$data['user_firstname'] = $q->user_firstname;
$data['user_lastname'] = $q->user_lastname;
$data['user_callsign'] = $q->user_callsign;
$data['user_locator'] = $q->user_locator;
2011-11-04 17:32:03 +00:00
$this->load->view('interface_assets/header', $data);
2011-11-04 17:32:03 +00:00
$this->load->view('user/profile');
$this->load->view('interface_assets/footer');
}
2011-08-19 16:12:13 +00:00
function delete() {
$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'); }
$query = $this->user_model->get_by_id($this->uri->segment(3));
$this->load->library('form_validation');
$this->form_validation->set_rules('id', 'user_id', 'required');
$data = $query->row();
if ($this->form_validation->run() == FALSE)
{
2011-11-04 17:32:03 +00:00
$this->load->view('interface_assets/header', $data);
2011-11-04 17:32:03 +00:00
$this->load->view('user/delete');
$this->load->view('interface_assets/footer');
2011-08-19 16:12:13 +00:00
}
2011-08-18 00:31:15 +00:00
else
{
2011-08-19 16:12:13 +00:00
if($this->user_model->delete($data->user_id))
{
$this->session->set_flashdata('notice', 'User deleted');
redirect('user');
} else {
$this->session->set_flashdata('notice', '<b>Database error:</b> Could not delete user!');
redirect('user');
}
2011-08-18 00:31:15 +00:00
}
}
function login() {
// Check our version and run any migrations
$this->load->library('Migration');
$this->migration->current();
2011-08-18 00:31:15 +00:00
$this->load->model('user_model');
$query = $this->user_model->get($this->input->post('user_name', true));
2011-08-18 00:31:15 +00:00
$this->load->library('form_validation');
$this->form_validation->set_rules('user_name', 'Username', 'required');
$this->form_validation->set_rules('user_password', 'Password', 'required');
2013-03-24 21:42:36 +00:00
$data['user'] = $query->row();
2011-11-04 17:32:03 +00:00
if ($this->form_validation->run() == FALSE) {
$data['page_title'] = "Login";
$this->load->view('interface_assets/mini_header', $data);
2011-11-04 17:32:03 +00:00
$this->load->view('user/login');
$this->load->view('interface_assets/footer');
} else {
2011-08-18 00:31:15 +00:00
if($this->user_model->login() == 1) {
$this->session->set_flashdata('notice', 'User logged in');
2013-03-24 21:42:36 +00:00
$this->user_model->update_session($data['user']->user_id);
2024-01-01 01:08:12 +00:00
$this->user_model->set_last_login($data['user']->user_id);
$cookie= array(
'name' => 'language',
'value' => $data['user']->language,
'expire' => time()+1000,
'secure' => FALSE
);
$this->input->set_cookie($cookie);
2011-08-18 00:31:15 +00:00
redirect('dashboard');
} else {
$this->session->set_flashdata('error', 'Incorrect username or password!');
2011-08-18 00:31:15 +00:00
redirect('user/login');
}
}
}
function logout() {
$this->load->model('user_model');
$user_name = $this->session->userdata('user_name');
$this->user_model->clear_session();
$this->session->set_flashdata('notice', 'User '.$user_name.' logged out.');
redirect('dashboard');
}
/**
* Function: forgot_password
*
* Allows users to input an email address and a password will be sent to that address.
*
*/
function forgot_password() {
$this->load->helper(array('form', 'url'));
$this->load->library('form_validation');
$this->form_validation->set_rules('email', 'Email', 'required');
if ($this->form_validation->run() == FALSE)
{
$data['page_title'] = "Forgot Password";
$this->load->view('interface_assets/mini_header', $data);
$this->load->view('user/forgot_password');
$this->load->view('interface_assets/footer');
}
else
{
// Check email address exists
$this->load->model('user_model');
$check_email = $this->user_model->check_email_address($this->input->post('email', true));
if($check_email == TRUE) {
// Generate password reset code 50 characters long
$this->load->helper('string');
$reset_code = random_string('alnum', 50);
$this->user_model->set_password_reset_code($this->input->post('email', true), $reset_code);
// Send email with reset code
$this->data['reset_code'] = $reset_code;
$this->load->library('email');
if($this->optionslib->get_option('emailProtocol') == "smtp") {
$config = Array(
'protocol' => $this->optionslib->get_option('emailProtocol'),
2023-11-21 09:22:14 +00:00
'smtp_crypto' => $this->optionslib->get_option('smtpEncryption'),
'smtp_host' => $this->optionslib->get_option('smtpHost'),
'smtp_port' => $this->optionslib->get_option('smtpPort'),
'smtp_user' => $this->optionslib->get_option('smtpUsername'),
'smtp_pass' => $this->optionslib->get_option('smtpPassword'),
2023-11-22 13:51:45 +00:00
'crlf' => "\r\n",
'newline' => "\r\n"
);
$this->email->initialize($config);
}
$message = $this->load->view('email/forgot_password', $this->data, TRUE);
2023-06-17 07:03:00 +00:00
$this->email->from($this->optionslib->get_option('emailAddress'), $this->optionslib->get_option('emailSenderName'));
$this->email->to($this->input->post('email', true));
$this->email->subject('Cloudlog Account Password Reset');
$this->email->message($message);
if (! $this->email->send())
{
// Redirect to login page with message
$this->session->set_flashdata('warning', 'Email settings are incorrect.');
redirect('user/login');
} else {
// Redirect to login page with message
$this->session->set_flashdata('notice', 'Password Reset Processed.');
redirect('user/login');
}
} else {
// No account found just return to login page
$this->session->set_flashdata('notice', 'Password Reset Processed.');
redirect('user/login');
}
}
}
2024-01-01 00:01:10 +00:00
2024-01-01 01:44:03 +00:00
// Send an E-Mail to the user. Function is similar to forgot_password()
2024-01-01 00:01:10 +00:00
function admin_send_passwort_reset() {
$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'); }
$query = $this->user_model->get_by_id($this->uri->segment(3));
$this->load->library('form_validation');
$this->form_validation->set_rules('id', 'user_id', 'required');
$data = $query->row();
if ($this->form_validation->run() != FALSE)
{
$this->session->set_flashdata('notice', 'Something went wrong! User has no user_id.');
redirect('user');
}
else
{
// Check email address exists
$this->load->model('user_model');
$check_email = $this->user_model->check_email_address($data->user_email);
if($check_email == TRUE) {
// Generate password reset code 50 characters long
$this->load->helper('string');
$reset_code = random_string('alnum', 50);
$this->user_model->set_password_reset_code(($data->user_email), $reset_code);
// Send email with reset code and first Name of the User
$this->data['reset_code'] = $reset_code;
2024-02-08 05:13:03 +00:00
$this->data['user_firstname'] = $data->user_firstname; // We can call the user by their first name in the E-Mail
2024-01-01 11:49:24 +00:00
$this->data['user_callsign'] = $data->user_callsign;
$this->data['user_name'] = $data->user_name;
2024-01-01 00:01:10 +00:00
$this->load->library('email');
if($this->optionslib->get_option('emailProtocol') == "smtp") {
$config = Array(
'protocol' => $this->optionslib->get_option('emailProtocol'),
'smtp_crypto' => $this->optionslib->get_option('smtpEncryption'),
'smtp_host' => $this->optionslib->get_option('smtpHost'),
'smtp_port' => $this->optionslib->get_option('smtpPort'),
'smtp_user' => $this->optionslib->get_option('smtpUsername'),
'smtp_pass' => $this->optionslib->get_option('smtpPassword'),
'crlf' => "\r\n",
'newline' => "\r\n"
);
$this->email->initialize($config);
}
$message = $this->load->view('email/admin_reset_password', $this->data, TRUE);
$this->email->from($this->optionslib->get_option('emailAddress'), $this->optionslib->get_option('emailSenderName'));
$this->email->to($data->user_email);
$this->email->subject('Cloudlog Account Password Reset');
$this->email->message($message);
if (! $this->email->send())
{
// Redirect to user page with message
2024-01-01 00:30:40 +00:00
$this->session->set_flashdata('danger', lang('admin_email_settings_incorrect'));
2024-01-01 00:01:10 +00:00
redirect('user');
} else {
// Redirect to user page with message
2024-01-01 00:30:40 +00:00
$this->session->set_flashdata('success', lang('admin_password_reset_processed'));
2024-01-01 00:01:10 +00:00
redirect('user');
}
} else {
// No account found just return to user page
2024-01-01 00:30:40 +00:00
$this->session->set_flashdata('danger', 'Nothing done. No user found.');
2024-01-01 00:01:10 +00:00
redirect('user');
}
}
}
function reset_password($reset_code = NULL)
{
$data['reset_code'] = $reset_code;
if($reset_code != NULL) {
$this->load->helper(array('form', 'url'));
$this->load->library('form_validation');
$this->form_validation->set_rules('password', 'Password', 'required');
$this->form_validation->set_rules('password_confirm', 'Password Confirmation', 'required|matches[password]');
if ($this->form_validation->run() == FALSE)
{
$data['page_title'] = "Reset Password";
$this->load->view('interface_assets/mini_header', $data);
$this->load->view('user/reset_password');
$this->load->view('interface_assets/footer');
}
else
{
// Lets reset the password!
$this->load->model('user_model');
$this->user_model->reset_password($this->input->post('password', true), $reset_code);
$this->session->set_flashdata('notice', 'Password Reset.');
redirect('user/login');
}
} else {
redirect('user/login');
}
}
2022-10-27 13:18:50 +00:00
function check_locator($grid) {
$grid = $this->input->post('user_locator');
// Allow empty locator
if (preg_match('/^$/', $grid)) return true;
// Allow 6-digit locator
if (preg_match('/^[A-Ra-r]{2}[0-9]{2}[A-Za-z]{2}$/', $grid)) return true;
// Allow 4-digit locator
else if (preg_match('/^[A-Ra-r]{2}[0-9]{2}$/', $grid)) return true;
// Allow 4-digit grid line
else if (preg_match('/^[A-Ra-r]{2}[0-9]{2},[A-Ra-r]{2}[0-9]{2}$/', $grid)) return true;
// Allow 4-digit grid corner
else if (preg_match('/^[A-Ra-r]{2}[0-9]{2},[A-Ra-r]{2}[0-9]{2},[A-Ra-r]{2}[0-9]{2},[A-Ra-r]{2}[0-9]{2}$/', $grid)) return true;
// Allow 2-digit locator
else if (preg_match('/^[A-Ra-r]{2}$/', $grid)) return true;
// Allow 8-digit locator
else if (preg_match('/^[A-Ra-r]{2}[0-9]{2}[A-Za-z]{2}[0-9]{2}$/', $grid)) return true;
else {
$this->form_validation->set_message('check_locator', 'Please check value for grid locator ('.strtoupper($grid).').');
return false;
}
}
}