2020-12-12 22:03:42 +00:00
< ? php if ( ! defined ( 'BASEPATH' )) exit ( 'No direct script access allowed' );
/*
Handles Displaying of information for station tools .
*/
class Options extends CI_Controller {
2025-03-27 11:17:42 +00:00
function __construct () {
2020-12-12 22:03:42 +00:00
parent :: __construct ();
$this -> load -> helper ( array ( 'form' , 'url' ));
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' ); }
2020-12-22 12:33:28 +00:00
}
2021-08-09 15:10:37 +02:00
2026-06-02 09:29:55 +02:00
// Default /options redirects to the appearance tab
2025-03-27 11:17:42 +00:00
function index () {
2026-06-02 09:29:55 +02:00
redirect ( 'options/appearance' );
2020-12-13 16:55:10 +00:00
}
2021-08-09 15:10:37 +02:00
2020-12-13 16:59:08 +00:00
// function used to display the /appearance url
2020-12-13 16:55:10 +00:00
function appearance () {
2021-01-31 13:41:46 +00:00
2024-06-06 21:32:42 +02:00
$data [ 'page_title' ] = __ ( " Wavelog Options " );
$data [ 'sub_heading' ] = __ ( " Appearance " );
2026-06-02 09:29:55 +02:00
$data [ 'active_tab' ] = 'appearance' ;
2020-12-13 16:55:10 +00:00
2021-08-09 15:10:37 +02:00
$this -> load -> model ( 'Themes_model' );
$data [ 'themes' ] = $this -> Themes_model -> getThemes ();
2020-12-13 16:55:10 +00:00
$this -> load -> view ( 'interface_assets/header' , $data );
$this -> load -> view ( 'options/appearance' );
$this -> load -> view ( 'interface_assets/footer' );
2025-03-27 11:17:42 +00:00
}
2020-12-12 22:03:42 +00:00
2020-12-13 16:59:08 +00:00
// Handles saving the appreance options to the options system.
2020-12-13 16:55:10 +00:00
function appearance_save () {
2021-01-31 13:41:46 +00:00
2024-06-06 21:32:42 +02:00
$data [ 'page_title' ] = __ ( " Wavelog Options " );
$data [ 'sub_heading' ] = __ ( " Appearance " );
2026-06-02 09:29:55 +02:00
$data [ 'active_tab' ] = 'appearance' ;
2020-12-13 16:59:08 +00:00
2020-12-13 16:55:10 +00:00
$this -> load -> helper ( array ( 'form' , 'url' ));
$this -> load -> library ( 'form_validation' );
$this -> form_validation -> set_rules ( 'theme' , 'theme' , 'required' );
2025-03-27 11:17:42 +00:00
if ( $this -> form_validation -> run () == FALSE ) {
2020-12-13 16:55:10 +00:00
$this -> load -> view ( 'interface_assets/header' , $data );
$this -> load -> view ( 'options/appearance' );
$this -> load -> view ( 'interface_assets/footer' );
2025-03-27 11:17:42 +00:00
} else {
2020-12-13 16:59:08 +00:00
// Update theme choice within the options system
2022-03-25 16:14:51 +00:00
$theme_update_status = $this -> optionslib -> update ( 'theme' , $this -> input -> post ( 'theme' ), 'yes' );
2020-12-13 16:55:10 +00:00
2020-12-13 16:59:08 +00:00
// If theme update is complete set a flashsession with a success note
2020-12-13 16:55:10 +00:00
if ( $theme_update_status == TRUE ) {
2024-06-06 21:32:42 +02:00
$this -> session -> set_flashdata ( 'success' , __ ( " Options saved " ));
2020-12-13 16:55:10 +00:00
}
2020-12-13 16:59:08 +00:00
2023-04-29 18:44:35 +02:00
// Update logbook map within the options system
$logbook_map_update_status = $this -> optionslib -> update ( 'logbook_map' , $this -> input -> post ( 'logbookMap' ), 'yes' );
// If logbook map update is complete set a flashsession with a success note
if ( $logbook_map_update_status == TRUE ) {
2024-06-06 21:32:42 +02:00
$this -> session -> set_flashdata ( 'success' , __ ( " Options saved " ));
2023-04-29 18:44:35 +02:00
}
2024-05-25 16:08:57 +02:00
// Update public maps within the options system
$public_maps_update_status = $this -> optionslib -> update ( 'public_maps' , $this -> input -> post ( 'publicMaps' ), 'yes' );
// If the option was saved successfully set a flashsession with success note
if ( $public_maps_update_status == TRUE ) {
2024-06-06 21:32:42 +02:00
$this -> session -> set_flashdata ( 'success' , __ ( " Options saved " ));
2024-05-25 16:08:57 +02:00
}
2024-09-04 17:02:47 -07:00
2024-05-25 16:08:57 +02:00
// Update public github button within the options system
2024-01-25 02:39:50 +01:00
$public_github_button_update_status = $this -> optionslib -> update ( 'public_github_button' , $this -> input -> post ( 'publicGithubButton' ), 'yes' );
2021-01-31 13:41:46 +00:00
2024-05-25 16:08:57 +02:00
// If the option was saved successfully set a flashsession with success note
2024-01-25 02:39:50 +01:00
if ( $public_github_button_update_status == TRUE ) {
2024-06-06 21:32:42 +02:00
$this -> session -> set_flashdata ( 'success' , __ ( " Options saved " ));
2024-01-25 02:39:50 +01:00
}
2021-01-31 13:41:46 +00:00
2024-09-03 19:18:37 -07:00
// Update public login button within the options system
$public_login_button_update_status = $this -> optionslib -> update ( 'public_login_button' , $this -> input -> post ( 'publicLoginButton' ), 'yes' );
// If the option was saved successfully set a flashsession with success note
if ( $public_login_button_update_status == TRUE ) {
$this -> session -> set_flashdata ( 'success' , __ ( " Options saved " ));
}
2020-12-13 16:59:08 +00:00
// Redirect back to /appearance
2020-12-13 16:55:10 +00:00
redirect ( '/options/appearance' );
}
2025-03-27 11:17:42 +00:00
}
2020-12-12 22:03:42 +00:00
2023-07-18 15:45:56 +00:00
// function used to display the /dxcluster url
2025-03-27 11:17:42 +00:00
function hon () {
$data [ 'page_title' ] = __ ( " Wavelog Options " );
$data [ 'sub_heading' ] = __ ( " Hams Of Note " );
2026-06-02 09:29:55 +02:00
$data [ 'active_tab' ] = 'hon' ;
2025-03-27 11:17:42 +00:00
$this -> load -> view ( 'interface_assets/header' , $data );
$this -> load -> view ( 'options/hon' );
$this -> load -> view ( 'interface_assets/footer' );
}
// Handles saving the DXCluster options to the options system.
function hon_save () {
2023-07-18 15:45:56 +00:00
2025-03-27 11:17:42 +00:00
$data [ 'page_title' ] = __ ( " Wavelog Options " );
$data [ 'sub_heading' ] = __ ( " Hams Of Note " );
2026-06-02 09:29:55 +02:00
$data [ 'active_tab' ] = 'hon' ;
2025-03-27 11:17:42 +00:00
$this -> load -> helper ( array ( 'form' , 'url' ));
$this -> load -> library ( 'form_validation' );
$this -> form_validation -> set_rules ( 'hon_url' , 'URL for Hams Of Note ' , 'valid_url' );
if ( $this -> form_validation -> run () == FALSE ) {
2023-07-18 15:45:56 +00:00
$this -> load -> view ( 'interface_assets/header' , $data );
2025-03-27 11:17:42 +00:00
$this -> load -> view ( 'options/hon' );
2023-07-18 15:45:56 +00:00
$this -> load -> view ( 'interface_assets/footer' );
2025-03-27 11:17:42 +00:00
} else {
$hon_url_update = $this -> optionslib -> update ( 'hon_url' , $this -> input -> post ( 'hon_url' ), 'yes' );
if ( $hon_url_update == TRUE ) {
2025-03-31 06:50:25 +02:00
$this -> session -> set_flashdata ( 'success' , __ ( " Hams-Of-Note URL changed to " ) . $this -> input -> post ( 'hon_url' , true ));
2025-03-27 11:17:42 +00:00
}
redirect ( '/options/hon' );
}
}
function dxcluster () {
$data [ 'page_title' ] = __ ( " Wavelog Options " );
$data [ 'sub_heading' ] = __ ( " DXCluster " );
2026-06-02 09:29:55 +02:00
$data [ 'active_tab' ] = 'dxcluster' ;
2025-03-27 11:17:42 +00:00
$this -> load -> view ( 'interface_assets/header' , $data );
$this -> load -> view ( 'options/dxcluster' );
$this -> load -> view ( 'interface_assets/footer' );
2023-07-18 15:45:56 +00:00
}
// Handles saving the DXCluster options to the options system.
function dxcluster_save () {
2024-06-06 21:32:42 +02:00
$data [ 'page_title' ] = __ ( " Wavelog Options " );
$data [ 'sub_heading' ] = __ ( " DXCluster " );
2026-06-02 09:29:55 +02:00
$data [ 'active_tab' ] = 'dxcluster' ;
2023-07-18 15:45:56 +00:00
$this -> load -> helper ( array ( 'form' , 'url' ));
$this -> load -> library ( 'form_validation' );
$this -> form_validation -> set_rules ( 'dxcache_url' , 'URL of DXCache' , 'valid_url' );
2023-07-21 11:46:16 +00:00
$this -> form_validation -> set_rules ( 'dxcluster_maxage' , 'Max Age of Spots' , 'required' );
$this -> form_validation -> set_rules ( 'dxcluster_decont' , 'de continent' , 'required' );
2023-07-18 15:45:56 +00:00
if ( $this -> form_validation -> run () == FALSE ) {
$this -> load -> view ( 'interface_assets/header' , $data );
$this -> load -> view ( 'options/dxcluster' );
$this -> load -> view ( 'interface_assets/footer' );
} else {
2023-07-21 11:46:16 +00:00
$dxcluster_decont_update = $this -> optionslib -> update ( 'dxcluster_decont' , $this -> input -> post ( 'dxcluster_decont' ), 'yes' );
if ( $dxcluster_decont_update == TRUE ) {
2024-06-06 21:32:42 +02:00
$this -> session -> set_flashdata ( 'success' , __ ( " de continent changed to " ) . $this -> input -> post ( 'dxcluster_decont' ));
2023-07-21 11:46:16 +00:00
}
2023-07-24 08:44:42 +00:00
$dxcluster_maxage_update = $this -> optionslib -> update ( 'dxcluster_maxage' , $this -> input -> post ( 'dxcluster_maxage' ), 'yes' );
2023-07-21 11:46:16 +00:00
if ( $dxcluster_maxage_update == TRUE ) {
2024-06-06 21:32:42 +02:00
$this -> session -> set_flashdata ( 'success' , __ ( " Maximum age of spots changed to " ) . $this -> input -> post ( 'dxcluster_maxage' ));
2023-07-21 11:46:16 +00:00
}
2023-07-18 15:45:56 +00:00
$dxcache_url_update = $this -> optionslib -> update ( 'dxcache_url' , $this -> input -> post ( 'dxcache_url' ), 'yes' );
if ( $dxcache_url_update == TRUE ) {
2024-06-06 21:32:42 +02:00
$this -> session -> set_flashdata ( 'success' , __ ( " DXCluster Cache URL changed to " ) . $this -> input -> post ( 'dxcache_url' ));
2023-07-18 15:45:56 +00:00
}
redirect ( '/options/dxcluster' );
}
}
2025-03-27 11:17:42 +00:00
// function used to display the /radio url
function radio () {
2021-08-09 15:10:37 +02:00
2025-03-27 11:17:42 +00:00
$data [ 'page_title' ] = __ ( " Wavelog Options " );
$data [ 'sub_heading' ] = __ ( " Radio Settings " );
2026-06-02 09:29:55 +02:00
$data [ 'active_tab' ] = 'radio' ;
2021-08-09 15:10:37 +02:00
2025-03-27 11:17:42 +00:00
$this -> load -> view ( 'interface_assets/header' , $data );
$this -> load -> view ( 'options/radios' );
$this -> load -> view ( 'interface_assets/footer' );
}
2021-05-03 14:50:33 +01:00
// Handles saving the radio options to the options system.
function radio_save () {
2024-06-06 21:32:42 +02:00
$data [ 'page_title' ] = __ ( " Wavelog Options " );
$data [ 'sub_heading' ] = __ ( " Radio Settings " );
2026-06-02 09:29:55 +02:00
$data [ 'active_tab' ] = 'radio' ;
2021-05-03 14:50:33 +01:00
$this -> load -> helper ( array ( 'form' , 'url' ));
$this -> load -> library ( 'form_validation' );
$this -> form_validation -> set_rules ( 'radioTimeout' , 'radioTimeout' , 'required' );
if ( $this -> form_validation -> run () == FALSE )
{
$this -> load -> view ( 'interface_assets/header' , $data );
$this -> load -> view ( 'options/radios' );
$this -> load -> view ( 'interface_assets/footer' );
}
else
{
// Update theme choice within the options system
2022-06-29 13:08:08 +02:00
$radioTimeout_update = $this -> optionslib -> update ( 'cat_timeout_interval' , $this -> input -> post ( 'radioTimeout' ), 'yes' );
2021-05-03 14:50:33 +01:00
// If theme update is complete set a flashsession with a success note
if ( $radioTimeout_update == TRUE ) {
2024-06-06 21:32:42 +02:00
$this -> session -> set_flashdata ( 'success' , __ ( " Radio Timeout Warning changed to " ) . $this -> input -> post ( 'radioTimeout' ) . ' seconds' );
2021-05-03 14:50:33 +01:00
}
// Redirect back to /appearance
redirect ( '/options/radio' );
}
2025-03-27 11:17:42 +00:00
}
2021-05-03 14:50:33 +01:00
2022-01-19 14:26:36 +00:00
// function used to display the /appearance url
function email () {
2024-06-06 21:32:42 +02:00
$data [ 'page_title' ] = __ ( " Wavelog Options " );
$data [ 'sub_heading' ] = __ ( " Email " );
2026-06-02 09:29:55 +02:00
$data [ 'active_tab' ] = 'email' ;
2022-01-19 14:26:36 +00:00
$this -> load -> view ( 'interface_assets/header' , $data );
$this -> load -> view ( 'options/email' );
$this -> load -> view ( 'interface_assets/footer' );
2025-03-27 11:17:42 +00:00
}
2022-01-19 14:26:36 +00:00
// Handles saving the radio options to the options system.
function email_save () {
2025-03-27 11:17:42 +00:00
$data [ 'page_title' ] = __ ( " Wavelog Options " );
$data [ 'sub_heading' ] = __ ( " Email " );
2026-06-02 09:29:55 +02:00
$data [ 'active_tab' ] = 'email' ;
2025-03-27 11:17:42 +00:00
$this -> load -> helper ( array ( 'form' , 'url' ));
$this -> load -> library ( 'form_validation' );
$this -> form_validation -> set_rules ( 'emailProtocol' , 'Email Protocol' , 'required' );
if ( $this -> form_validation -> run () == FALSE )
{
$this -> load -> view ( 'interface_assets/header' , $data );
$this -> load -> view ( 'options/email' );
$this -> load -> view ( 'interface_assets/footer' );
}
else
{
// Update emailProtocol choice within the options system
$emailProtocolupdate = $this -> optionslib -> update ( 'emailProtocol' , $this -> input -> post ( 'emailProtocol' ), 'yes' );
// Update smtpEncryption choice within the options system
$smtpEncryptionupdate = $this -> optionslib -> update ( 'smtpEncryption' , $this -> input -> post ( 'smtpEncryption' ), 'yes' );
// Update email sender name within the options system
$emailSenderName_value = $this -> input -> post ( 'emailSenderName' );
if ( empty ( $emailSenderName_value )) {
$emailSenderName_value = 'Wavelog' ;
2022-01-19 14:26:36 +00:00
}
2025-03-27 11:17:42 +00:00
$emailSenderNameupdate = $this -> optionslib -> update ( 'emailSenderName' , $emailSenderName_value , 'yes' );
2022-01-19 14:26:36 +00:00
2025-03-27 11:17:42 +00:00
// Update email address choice within the options system
$emailAddressupdate = $this -> optionslib -> update ( 'emailAddress' , $this -> input -> post ( 'emailAddress' ), 'yes' );
2022-01-19 14:26:36 +00:00
2025-03-27 11:17:42 +00:00
// Update smtpHost choice within the options system
$smtpHostupdate = $this -> optionslib -> update ( 'smtpHost' , $this -> input -> post ( 'smtpHost' ), 'yes' );
2022-01-19 14:26:36 +00:00
2025-03-27 11:17:42 +00:00
// Update smtpPort choice within the options system
$smtpPortupdate = $this -> optionslib -> update ( 'smtpPort' , $this -> input -> post ( 'smtpPort' ), 'yes' );
// Update smtpUsername choice within the options system
$smtpUsernameupdate = $this -> optionslib -> update ( 'smtpUsername' , $this -> input -> post ( 'smtpUsername' ), 'yes' );
// Update smtpPassword choice within the options system
$smtpPasswordupdate = $this -> optionslib -> update ( 'smtpPassword' , $this -> input -> post ( 'smtpPassword' ), 'yes' );
// Check if all updates are successful
$updateSuccessful = $emailProtocolupdate &&
$smtpEncryptionupdate &&
$emailSenderNameupdate &&
$emailAddressupdate &&
$smtpHostupdate &&
$smtpPortupdate &&
$smtpUsernameupdate &&
$smtpPasswordupdate ;
// Set flash session based on update success
if ( $updateSuccessful ) {
$this -> session -> set_flashdata ( 'success' , __ ( " The settings were saved successfully. " ));
} else {
2026-06-08 16:01:34 +02:00
$this -> session -> set_flashdata ( 'saveFailed' , __ ( " Something went wrong with saving the settings. Try again. " ));
2022-01-19 14:26:36 +00:00
}
2025-03-27 11:17:42 +00:00
// Redirect back to /email
redirect ( '/options/email' );
2022-01-19 14:26:36 +00:00
}
2025-03-27 11:17:42 +00:00
}
2022-01-19 14:26:36 +00:00
2023-11-21 21:03:48 +01:00
function sendTestMail () {
2023-11-21 12:12:53 +01:00
$id = $this -> session -> userdata ( 'user_id' );
$email = $this -> user_model -> get_user_email_by_id ( $id );
if ( $email != " " ) {
$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' ),
2023-11-22 14:51:45 +01:00
'crlf' => " \r \n " ,
'newline' => " \r \n "
2023-11-21 12:12:53 +01:00
);
$this -> email -> initialize ( $config );
}
2024-10-28 10:49:59 +01:00
$message = $this -> email -> load ( 'email/testmail' , NULL );
2023-11-21 12:12:53 +01:00
$this -> email -> from ( $this -> optionslib -> get_option ( 'emailAddress' ), $this -> optionslib -> get_option ( 'emailSenderName' ));
$this -> email -> to ( $email );
2024-10-28 12:37:31 +01:00
$this -> email -> subject ( $message [ 'subject' ]);
$this -> email -> message ( $message [ 'body' ]);
2023-11-21 12:12:53 +01:00
if ( ! $this -> email -> send ()){
2026-06-08 16:01:34 +02:00
$this -> session -> set_flashdata ( 'testmailFailed' , __ ( " Testmail failed. Something went wrong. " ));
2023-11-21 12:12:53 +01:00
} else {
2026-06-08 16:01:34 +02:00
$this -> session -> set_flashdata ( 'testmailSuccess' , __ ( " Testmail sent. Email settings seem to be correct. " ));
2023-11-21 12:12:53 +01:00
}
2023-11-21 21:03:48 +01:00
} else {
2026-06-08 16:01:34 +02:00
$this -> session -> set_flashdata ( 'testmailFailed' , __ ( " Testmail failed. Something went wrong. " ));
2023-11-21 12:12:53 +01:00
}
2025-03-27 11:17:42 +00:00
2023-11-21 21:03:48 +01:00
redirect ( '/options/email' );
2023-11-21 12:12:53 +01:00
}
2024-12-06 14:17:49 +01:00
// function used to display the /maptiles url in global options
function maptiles () {
$data [ 'page_title' ] = __ ( " Wavelog Options " );
$data [ 'sub_heading' ] = __ ( " Maptiles Server " );
2026-06-02 09:29:55 +02:00
$data [ 'active_tab' ] = 'maptiles' ;
2024-12-06 14:17:49 +01:00
$data [ 'maptile_server_url' ] = $this -> optionslib -> get_option ( 'map_tile_server' ) ? ? 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png' ;
$data [ 'maptile_server_url_dark' ] = $this -> optionslib -> get_option ( 'map_tile_server_dark' ) ? ? 'https://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}{r}.png' ;
$data [ 'subdomain_system' ] = $this -> optionslib -> get_option ( 'map_tile_subdomains' ) ? ? 'abc' ;
$map_tile_server_copyright = $this -> optionslib -> get_option ( 'map_tile_server_copyright' ) ? ? 'Map data © <a href="https://www.openstreetmap.org/">OpenStreetMap</a>' ;
preg_match ( '/<a href="([^"]+)">([^<]+)<\/a>/' , $map_tile_server_copyright , $matches );
2024-12-09 08:07:44 +01:00
$data [ 'copyright_url' ] = $matches [ 1 ] ? ? 'https://www.openstreetmap.org/' ;
$data [ 'copyright_text' ] = $matches [ 2 ] ? ? 'OpenStreetMap' ;
2024-12-06 14:17:49 +01:00
$this -> load -> view ( 'interface_assets/header' , $data );
$this -> load -> view ( 'options/maptiles' );
$this -> load -> view ( 'interface_assets/footer' );
}
// Handles saving the Maptiles options to the options system.
function maptiles_save () {
$data [ 'page_title' ] = __ ( " Wavelog Options " );
$data [ 'sub_heading' ] = __ ( " Maptiles Server " );
$this -> load -> helper ( array ( 'form' , 'url' ));
$this -> load -> library ( 'form_validation' );
$this -> form_validation -> set_rules ( 'maptile_server_url' , 'URL of Maptile Server' , 'required' );
$this -> form_validation -> set_rules ( 'maptile_server_url_dark' , 'URL of Dark Maptile Server' , 'required' );
$this -> form_validation -> set_rules ( 'subdomain_system' , 'Subdomains for Loadbalancing' , 'required' );
$this -> form_validation -> set_rules ( 'copyright_url' , 'URL for Copyright' , 'required' );
$this -> form_validation -> set_rules ( 'copyright_text' , 'Text for Copyright' , 'required' );
if ( $this -> form_validation -> run () == FALSE ) {
2024-12-09 08:07:44 +01:00
$this -> maptiles ();
2025-03-27 11:17:42 +00:00
2024-12-06 14:17:49 +01:00
} else {
$saved = false ;
2024-12-06 16:08:02 +01:00
if ( $this -> input -> post ( 'reset_defaults' ) == '1' ) {
$map_tile_server_copyright = 'Map data © <a href="https://www.openstreetmap.org/">OpenStreetMap</a>' ;
$saved = $this -> optionslib -> update ( 'map_tile_server' , 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png' , 'yes' );
$saved = $this -> optionslib -> update ( 'map_tile_server_dark' , 'https://{s}.basemaps.cartocdn.com/dark_all/{z}/{x}/{y}{r}.png' , 'yes' );
$saved = $this -> optionslib -> update ( 'map_tile_subdomains' , 'abc' , 'yes' );
} else {
$map_tile_server_copyright = 'Map data © <a href="' . $this -> input -> post ( 'copyright_url' , true ) . '">' . $this -> input -> post ( 'copyright_text' , true ) . '</a>' ;
$saved = $this -> optionslib -> update ( 'map_tile_server' , $this -> input -> post ( 'maptile_server_url' , true ), 'yes' );
$saved = $this -> optionslib -> update ( 'map_tile_server_dark' , $this -> input -> post ( 'maptile_server_url_dark' , true ), 'yes' );
$saved = $this -> optionslib -> update ( 'map_tile_subdomains' , $this -> input -> post ( 'subdomain_system' , true ), 'yes' );
}
2024-12-06 14:17:49 +01:00
$saved = $this -> optionslib -> update ( 'map_tile_server_copyright' , $map_tile_server_copyright , 'yes' );
// Also clean up static map images
if ( ! $this -> load -> is_loaded ( 'staticmap_model' )) {
$this -> load -> model ( 'staticmap_model' );
}
if ( ! $this -> load -> is_loaded ( 'stations' )) {
$this -> load -> model ( 'stations' );
}
$station_ids = explode ( ',' , $this -> stations -> all_station_ids_of_user ());
foreach ( $station_ids as $station_id ) {
$this -> staticmap_model -> remove_static_map_image ( $station_id );
log_message ( 'debug' , 'Removed static map image for station ID ' . $station_id );
}
// also remove the tilecache
$cachepath = $this -> config -> item ( 'cache_path' ) == '' ? APPPATH . 'cache/' : $this -> config -> item ( 'cache_path' );
2025-03-27 11:17:42 +00:00
$cacheDir = $cachepath . " tilecache/ " ;
2024-12-06 14:17:49 +01:00
$tilecache_warning = false ;
if ( function_usable ( 'exec' )) {
try {
if ( is_dir ( $cacheDir )) {
exec ( 'rm -rf ' . $cacheDir );
}
} catch ( \Throwable $th ) {
$tilecache_warning = true ;
}
} else {
$tilecache_warning = true ;
}
if ( $tilecache_warning ) {
$this -> session -> set_flashdata ( 'warning' , sprintf ( __ ( " Maptile cache could not be removed. Delete the folder manually. Path: %s " ), str_replace ( FCPATH , '' , $cacheDir )));
log_message ( 'debug' , 'Maptile cache could not be removed. Delete the folder manually. Path: ' . str_replace ( FCPATH , '' , $cacheDir ));
}
if ( $saved == true ) {
$this -> session -> set_flashdata ( 'success' , __ ( " Maptile Options saved! " ));
} else {
$this -> session -> set_flashdata ( 'error' , __ ( " Maptile Options could not be saved! " ));
log_message ( 'error' , 'Maptile Options could not be saved!' );
}
redirect ( '/options/maptiles' );
}
}
2023-12-03 09:37:39 +01:00
// function used to display the /version_dialog url
function version_dialog () {
2024-06-06 21:32:42 +02:00
$data [ 'page_title' ] = __ ( " Wavelog Options " );
$data [ 'sub_heading' ] = __ ( " Version Info Settings " );
2026-06-02 09:29:55 +02:00
$data [ 'active_tab' ] = 'version_dialog' ;
2023-12-03 09:37:39 +01:00
$this -> load -> view ( 'interface_assets/header' , $data );
$this -> load -> view ( 'options/version_dialog' );
$this -> load -> view ( 'interface_assets/footer' );
2025-03-27 11:17:42 +00:00
}
2023-12-03 09:37:39 +01:00
function version_dialog_save () {
2024-06-06 21:32:42 +02:00
$data [ 'page_title' ] = __ ( " Wavelog Options " );
$data [ 'sub_heading' ] = __ ( " Version Info Settings " );
2023-12-03 09:37:39 +01:00
$this -> load -> helper ( array ( 'form' , 'url' ));
2023-12-04 20:44:26 +01:00
$version_dialog_header_update = $this -> optionslib -> update ( 'version_dialog_header' , $this -> input -> post ( 'version_dialog_header' ), 'yes' );
if ( $version_dialog_header_update == TRUE ) {
2026-06-08 16:01:34 +02:00
$this -> session -> set_flashdata ( 'success0' , __ ( " Version Info Header changed to " ) . " " . " ' " . $this -> input -> post ( 'version_dialog_header' ) . " ' " );
2023-12-04 20:44:26 +01:00
}
$version_dialog_mode_update = $this -> optionslib -> update ( 'version_dialog' , $this -> input -> post ( 'version_dialog_mode' ), 'yes' );
if ( $version_dialog_mode_update == TRUE ) {
2026-06-08 16:01:34 +02:00
$this -> session -> set_flashdata ( 'success1' , __ ( " Version Info Mode changed to " ) . " " . " ' " . $this -> input -> post ( 'version_dialog_mode' ) . " ' " );
2023-12-03 09:37:39 +01:00
}
2025-04-28 11:46:28 +02:00
if ( $this -> input -> post ( 'version_dialog_mode' ) == " both " || $this -> input -> post ( 'version_dialog_mode' ) == " custom_text " ) {
2023-12-04 20:44:26 +01:00
$version_dialog_custom_text_update = $this -> optionslib -> update ( 'version_dialog_text' , $this -> input -> post ( 'version_dialog_custom_text' ), 'yes' );
if ( $version_dialog_custom_text_update == TRUE ) {
2026-06-08 16:01:34 +02:00
$this -> session -> set_flashdata ( 'success2' , __ ( " Version Info Custom Text saved! " ));
2023-12-03 09:37:39 +01:00
}
}
redirect ( '/options/version_dialog' );
2025-03-27 11:17:42 +00:00
2023-12-03 09:37:39 +01:00
}
2023-12-04 23:02:53 +01:00
function version_dialog_show_to_all () {
$update_vd_confirmation_to_false = $this -> user_options_model -> set_option_at_all_users ( 'version_dialog' , 'confirmed' , array ( 'boolean' => 'false' ));
if ( $update_vd_confirmation_to_false == TRUE ) {
2026-06-08 16:01:34 +02:00
$this -> session -> set_flashdata ( 'success_trigger' , __ ( " Version Info will be shown to all users again " ));
2023-12-04 23:02:53 +01:00
}
redirect ( '/options/version_dialog' );
}
function version_dialog_show_to_none () {
$update_vd_confirmation_to_true = $this -> user_options_model -> set_option_at_all_users ( 'version_dialog' , 'confirmed' , array ( 'boolean' => 'true' ));
if ( $update_vd_confirmation_to_true == TRUE ) {
2026-06-08 16:01:34 +02:00
$this -> session -> set_flashdata ( 'success_trigger' , __ ( " Version Info will not be shown to any user " ));
2023-12-04 23:02:53 +01:00
}
redirect ( '/options/version_dialog' );
}
2021-02-10 10:56:04 +00:00
}