2013-01-18 18:41:00 +01:00
< ? php
2019-03-04 13:12:01 +01:00
/**
2019-07-02 14:17:53 +02:00
* General setup .
*
* @ category Setup
* @ package Pandora FMS
* @ subpackage Opensource
* @ version 1.0 . 0
* @ license See below
*
2019-03-04 13:12:01 +01:00
* ______ ___ _______ _______ ________
* | __ \ .-----.--.--.--| |.-----.----.-----. | ___ | | | __ |
* | __ /| _ | | _ || _ | _ | _ | | ___ | | __ |
* | ___ | | ___ . _ | __ | __ | _____ || _____ | __ | | ___ . _ | | ___ | | __ | _ | __ | _______ |
*
* ============================================================================
* Copyright ( c ) 2005 - 2019 Artica Soluciones Tecnologicas
* Please see http :// pandorafms . org for full contribution list
* This program is free software ; you can redistribute it and / or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation for version 2.
* This program is distributed in the hope that it will be useful ,
* but WITHOUT ANY WARRANTY ; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
* GNU General Public License for more details .
* ============================================================================
*/
2013-01-18 18:41:00 +01:00
2019-07-02 14:17:53 +02:00
// File begin.
/**
* Return sounds path .
*
* @ return string Path .
*/
function get_sounds ()
{
global $config ;
$return = [];
$files = scandir ( $config [ 'homedir' ] . '/include/sounds' );
foreach ( $files as $file ) {
if ( strstr ( $file , 'wav' ) !== false ) {
$return [ 'include/sounds/' . $file ] = $file ;
}
}
2013-01-18 18:41:00 +01:00
2019-07-02 14:17:53 +02:00
return $return ;
}
2013-01-18 18:41:00 +01:00
2019-07-02 14:17:53 +02:00
// Begin.
2013-01-18 18:41:00 +01:00
global $config ;
2019-07-02 14:17:53 +02:00
2019-01-30 16:18:44 +01:00
check_login ();
2013-01-18 18:41:00 +01:00
2019-09-12 15:37:16 +02:00
if ( is_ajax ()) {
enterprise_include_once ( 'include/functions_cron.php' );
$test_address = get_parameter ( 'test_address' , '' );
2019-10-21 17:36:26 +02:00
$res = enterprise_hook (
'send_email_attachment' ,
[
$test_address ,
__ ( 'This is an email test sent from Pandora FMS. If you can read this, your configuration works.' ),
__ ( 'Testing Pandora FMS email' ),
null ,
]
);
2019-09-12 15:37:16 +02:00
echo $res ;
2019-10-21 17:36:26 +02:00
// Exit after ajax response.
exit ();
2019-09-12 15:37:16 +02:00
}
2015-06-25 10:07:53 +02:00
$table = new StdClass ();
$table -> class = 'databox filters' ;
2016-08-26 12:41:34 +02:00
$table -> id = 'setup_general' ;
2013-01-18 18:41:00 +01:00
$table -> width = '100%' ;
2019-01-30 16:18:44 +01:00
$table -> data = [];
$table -> size = [];
2013-01-18 18:41:00 +01:00
$table -> size [ 0 ] = '30%' ;
2015-07-14 15:59:39 +02:00
$table -> style [ 0 ] = 'font-weight:bold' ;
2013-01-18 18:41:00 +01:00
$table -> size [ 1 ] = '70%' ;
2019-06-10 09:43:27 +02:00
$table_mail_conf = new stdClass ();
$table_mail_conf -> width = '100%' ;
$table_mail_conf -> class = 'databox filters' ;
$table_mail_conf -> data = [];
$table_mail_conf -> style [ 0 ] = 'font-weight: bold' ;
2013-01-18 18:41:00 +01:00
// Current config["language"] could be set by user, not taken from global setup !
2019-07-02 14:17:53 +02:00
$current_system_lang = db_get_sql (
'SELECT `value` FROM tconfig WHERE `token` = "language"'
);
2013-01-18 18:41:00 +01:00
2019-01-30 16:18:44 +01:00
if ( $current_system_lang == '' ) {
$current_system_lang = 'en' ;
2013-01-18 18:41:00 +01:00
}
2019-07-02 14:17:53 +02:00
$i = 0 ;
2013-01-18 18:41:00 +01:00
2019-07-02 14:17:53 +02:00
$table -> data [ $i ][ 0 ] = __ ( 'Language code' );
$table -> data [ $i ++ ][ 1 ] = html_print_select_from_sql (
2019-01-30 16:18:44 +01:00
'SELECT id_language, name FROM tlanguage' ,
'language' ,
$current_system_lang ,
'' ,
'' ,
'' ,
true
);
2013-01-18 18:41:00 +01:00
2020-05-29 11:37:06 +02:00
$table -> data [ $i ][ 0 ] = __ ( 'Remote config directory' );
2019-07-02 14:17:53 +02:00
$table -> data [ $i ++ ][ 1 ] = html_print_input_text ( 'remote_config' , io_safe_output ( $config [ 'remote_config' ]), '' , 30 , 100 , true );
2018-06-12 15:46:05 +02:00
2020-05-29 11:37:06 +02:00
$table -> data [ $i ][ 0 ] = __ ( 'Phantomjs bin directory' );
2019-07-02 14:17:53 +02:00
$table -> data [ $i ++ ][ 1 ] = html_print_input_text ( 'phantomjs_bin' , io_safe_output ( $config [ 'phantomjs_bin' ]), '' , 30 , 100 , true );
2018-06-12 15:46:05 +02:00
2019-07-02 14:17:53 +02:00
$table -> data [ $i ][ 0 ] = __ ( 'Auto login (hash) password' );
$table -> data [ $i ++ ][ 1 ] = html_print_input_password ( 'loginhash_pwd' , io_output_password ( $config [ 'loginhash_pwd' ]), '' , 15 , 15 , true );
2013-01-18 18:41:00 +01:00
2019-07-02 14:17:53 +02:00
$table -> data [ $i ][ 0 ] = __ ( 'Time source' );
2019-01-30 16:18:44 +01:00
$sources [ 'system' ] = __ ( 'System' );
$sources [ 'sql' ] = __ ( 'Database' );
2019-07-02 14:17:53 +02:00
$table -> data [ $i ++ ][ 1 ] = html_print_select ( $sources , 'timesource' , $config [ 'timesource' ], '' , '' , '' , true );
2013-01-18 18:41:00 +01:00
2019-07-02 14:17:53 +02:00
$table -> data [ $i ][ 0 ] = __ ( 'Automatic check for updates' );
$table -> data [ $i ++ ][ 1 ] = html_print_checkbox_switch ( 'autoupdate' , 1 , $config [ 'autoupdate' ], true );
2019-01-17 17:28:23 +01:00
2019-02-06 16:11:46 +01:00
echo " <div id='dialog' title=' " . __ ( 'Enforce https Information' ) . " ' style='display:none;'> " ;
echo " <p style='text-align: center;'> " . __ ( 'If SSL is not properly configured you will lose access to ' ) . get_product_name () . __ ( ' Console' ) . '</p>' ;
echo '</div>' ;
2013-01-18 18:41:00 +01:00
2019-07-02 14:17:53 +02:00
$table -> data [ $i ][ 0 ] = __ ( 'Enforce https' );
$table -> data [ $i ++ ][ 1 ] = html_print_checkbox_switch_extended ( 'https' , 1 , $config [ 'https' ], false , '' , '' , true );
2013-01-18 18:41:00 +01:00
2019-07-02 14:17:53 +02:00
$table -> data [ $i ][ 0 ] = __ ( 'Use cert of SSL' );
$table -> data [ $i ++ ][ 1 ] = html_print_checkbox_switch_extended ( 'use_cert' , 1 , $config [ 'use_cert' ], false , '' , '' , true );
2016-08-26 12:41:34 +02:00
2019-07-02 14:17:53 +02:00
$table -> rowstyle [ $i ] = 'display: none;' ;
$table -> rowid [ $i ] = 'ssl-path-tr' ;
2020-05-29 11:37:06 +02:00
$table -> data [ $i ][ 0 ] = __ ( 'Path of SSL Cert.' );
2019-07-02 14:17:53 +02:00
$table -> data [ $i ++ ][ 1 ] = html_print_input_text ( 'cert_path' , io_safe_output ( $config [ 'cert_path' ]), '' , 50 , 255 , true );
2016-08-26 12:41:34 +02:00
2020-05-29 11:37:06 +02:00
$table -> data [ $i ][ 0 ] = __ ( 'Attachment store' );
2019-07-02 14:17:53 +02:00
$table -> data [ $i ++ ][ 1 ] = html_print_input_text ( 'attachment_store' , io_safe_output ( $config [ 'attachment_store' ]), '' , 50 , 255 , true );
2013-01-18 18:41:00 +01:00
2019-07-02 14:17:53 +02:00
$table -> data [ $i ][ 0 ] = __ ( 'IP list with API access' );
2019-01-30 16:18:44 +01:00
if ( isset ( $_POST [ 'list_ACL_IPs_for_API' ])) {
$list_ACL_IPs_for_API = get_parameter_post ( 'list_ACL_IPs_for_API' );
} else {
$list_ACL_IPs_for_API = get_parameter_get ( 'list_ACL_IPs_for_API' , implode ( " \n " , $config [ 'list_ACL_IPs_for_API' ]));
2013-01-18 18:41:00 +01:00
}
2019-01-30 16:18:44 +01:00
2019-07-02 14:17:53 +02:00
$table -> data [ $i ++ ][ 1 ] = html_print_textarea ( 'list_ACL_IPs_for_API' , 2 , 25 , $list_ACL_IPs_for_API , 'style="height: 50px; width: 300px"' , true );
2013-01-18 18:41:00 +01:00
2020-05-29 11:37:06 +02:00
$table -> data [ $i ][ 0 ] = __ ( 'API password' );
2019-07-02 14:17:53 +02:00
$table -> data [ $i ++ ][ 1 ] = html_print_input_password ( 'api_password' , io_output_password ( $config [ 'api_password' ]), '' , 25 , 255 , true );
2013-01-18 18:41:00 +01:00
2019-07-02 14:17:53 +02:00
$table -> data [ $i ][ 0 ] = __ ( 'Enable GIS features' );
$table -> data [ $i ++ ][ 1 ] = html_print_checkbox_switch ( 'activate_gis' , 1 , $config [ 'activate_gis' ], true );
2013-01-18 18:41:00 +01:00
2019-07-02 14:17:53 +02:00
$table -> data [ $i ][ 0 ] = __ ( 'Enable Netflow' );
2014-06-04 19:09:30 +02:00
$rbt_disabled = false ;
2014-06-05 14:06:03 +02:00
if ( strtoupper ( substr ( PHP_OS , 0 , 3 )) == 'WIN' ) {
2019-01-30 16:18:44 +01:00
$rbt_disabled = true ;
2014-06-04 19:09:30 +02:00
}
2013-05-06 18:39:41 +02:00
2019-07-02 14:17:53 +02:00
$table -> data [ $i ++ ][ 1 ] = html_print_checkbox_switch_extended ( 'activate_netflow' , 1 , $config [ 'activate_netflow' ], $rbt_disabled , '' , '' , true );
2019-02-06 16:11:46 +01:00
2019-07-02 14:17:53 +02:00
$table -> data [ $i ][ 0 ] = __ ( 'Enable Network Traffic Analyzer' );
$table -> data [ $i ++ ][ 1 ] = html_print_switch (
2019-03-01 13:38:48 +01:00
[
'name' => 'activate_nta' ,
'value' => $config [ 'activate_nta' ],
]
);
2019-01-30 16:18:44 +01:00
$zone_name = [
'Africa' => __ ( 'Africa' ),
'America' => __ ( 'America' ),
'Antarctica' => __ ( 'Antarctica' ),
'Arctic' => __ ( 'Arctic' ),
'Asia' => __ ( 'Asia' ),
'Atlantic' => __ ( 'Atlantic' ),
'Australia' => __ ( 'Australia' ),
'Europe' => __ ( 'Europe' ),
'Indian' => __ ( 'Indian' ),
'Pacific' => __ ( 'Pacific' ),
'UTC' => __ ( 'UTC' ),
];
2013-01-18 18:41:00 +01:00
$zone_selected = get_parameter ( 'zone' );
2019-01-30 16:18:44 +01:00
if ( $zone_selected == '' ) {
if ( $config [ 'timezone' ] != '' ) {
$zone_array = explode ( '/' , $config [ 'timezone' ]);
$zone_selected = $zone_array [ 0 ];
} else {
$zone_selected = 'Europe' ;
}
2013-01-18 18:41:00 +01:00
}
$timezones = timezone_identifiers_list ();
foreach ( $timezones as $timezone ) {
2019-01-30 16:18:44 +01:00
if ( strpos ( $timezone , $zone_selected ) !== false ) {
$timezone_n [ $timezone ] = $timezone ;
}
2013-01-18 18:41:00 +01:00
}
2020-05-29 11:37:06 +02:00
$table -> data [ $i ][ 0 ] = __ ( 'Timezone setup' );
2019-07-02 14:17:53 +02:00
$table -> data [ $i ][ 1 ] = html_print_input_text_extended (
2019-01-30 16:18:44 +01:00
'timezone_text' ,
$config [ 'timezone' ],
'text-timezone_text' ,
'' ,
25 ,
25 ,
false ,
'' ,
'readonly' ,
true
);
2019-07-02 14:17:53 +02:00
$table -> data [ $i ][ 1 ] .= '<a id="change_timezone">' . html_print_image ( 'images/pencil.png' , true , [ 'title' => __ ( 'Change timezone' )]) . '</a>' ;
$table -> data [ $i ][ 1 ] .= ' ' . html_print_select ( $zone_name , 'zone' , $zone_selected , 'show_timezone();' , '' , '' , true );
$table -> data [ $i ++ ][ 1 ] .= ' ' . html_print_select ( $timezone_n , 'timezone' , $config [ 'timezone' ], '' , '' , '' , true );
2013-01-18 18:41:00 +01:00
$sounds = get_sounds ();
2019-07-02 14:17:53 +02:00
$table -> data [ $i ][ 0 ] = __ ( 'Sound for Alert fired' );
$table -> data [ $i ][ 1 ] = html_print_select ( $sounds , 'sound_alert' , $config [ 'sound_alert' ], 'replaySound(\'alert\');' , '' , '' , true );
$table -> data [ $i ][ 1 ] .= ' <a href="javascript: toggleButton(\'alert\');">' . html_print_image ( 'images/control_play_col.png' , true , [ 'id' => 'button_sound_alert' , 'style' => 'vertical-align: middle;' , 'width' => '16' , 'title' => __ ( 'Play sound' )]) . '</a>' ;
$table -> data [ $i ++ ][ 1 ] .= '<div id="layer_sound_alert"></div>' ;
$table -> data [ $i ][ 0 ] = __ ( 'Sound for Monitor critical' );
$table -> data [ $i ][ 1 ] = html_print_select ( $sounds , 'sound_critical' , $config [ 'sound_critical' ], 'replaySound(\'critical\');' , '' , '' , true );
$table -> data [ $i ][ 1 ] .= ' <a href="javascript: toggleButton(\'critical\');">' . html_print_image ( 'images/control_play_col.png' , true , [ 'id' => 'button_sound_critical' , 'style' => 'vertical-align: middle;' , 'width' => '16' , 'title' => __ ( 'Play sound' )]) . '</a>' ;
$table -> data [ $i ++ ][ 1 ] .= '<div id="layer_sound_critical"></div>' ;
$table -> data [ $i ][ 0 ] = __ ( 'Sound for Monitor warning' );
$table -> data [ $i ][ 1 ] = html_print_select ( $sounds , 'sound_warning' , $config [ 'sound_warning' ], 'replaySound(\'warning\');' , '' , '' , true );
$table -> data [ $i ][ 1 ] .= ' <a href="javascript: toggleButton(\'warning\');">' . html_print_image ( 'images/control_play_col.png' , true , [ 'id' => 'button_sound_warning' , 'style' => 'vertical-align: middle;' , 'width' => '16' , 'title' => __ ( 'Play sound' )]) . '</a>' ;
$table -> data [ $i ++ ][ 1 ] .= '<div id="layer_sound_warning"></div>' ;
$table -> data [ $i ][ 0 ] = __ ( 'Public URL' );
$table -> data [ $i ++ ][ 1 ] = html_print_input_text ( 'public_url' , $config [ 'public_url' ], '' , 40 , 255 , true );
2013-01-18 18:41:00 +01:00
2019-07-02 14:17:53 +02:00
$table -> data [ $i ][ 0 ] = __ ( 'Force use Public URL' );
$table -> data [ $i ++ ][ 1 ] = html_print_switch (
[
'name' => 'force_public_url' ,
'value' => $config [ 'force_public_url' ],
]
);
echo " <div id='force_public_url_dialog' title=' " . __ ( 'Enforce public URL usage information' ) . " ' style='display:none;'> " ;
echo " <p style='text-align: center;'> " . __ ( 'If public URL is not properly configured you will lose access to ' ) . get_product_name () . __ ( ' Console' ) . '</p>' ;
echo '</div>' ;
$table -> data [ $i ][ 0 ] = __ ( 'Public URL host exclusions' );
$table -> data [ $i ++ ][ 1 ] = html_print_textarea ( 'public_url_exclusions' , 2 , 25 , $config [ 'public_url_exclusions' ], 'style="height: 50px; width: 300px"' , true );
2013-01-18 18:41:00 +01:00
2019-07-02 14:17:53 +02:00
$table -> data [ $i ][ 0 ] = __ ( 'Referer security' );
$table -> data [ $i ++ ][ 1 ] = html_print_checkbox_switch ( 'referer_security' , 1 , $config [ 'referer_security' ], true );
2019-01-30 16:18:44 +01:00
2019-07-02 14:17:53 +02:00
$table -> data [ $i ][ 0 ] = __ ( 'Event storm protection' );
$table -> data [ $i ++ ][ 1 ] = html_print_checkbox_switch ( 'event_storm_protection' , 1 , $config [ 'event_storm_protection' ], true );
2019-01-30 16:18:44 +01:00
2020-05-29 11:37:06 +02:00
$table -> data [ $i ][ 0 ] = __ ( 'Command Snapshot' );
2019-07-02 14:17:53 +02:00
$table -> data [ $i ++ ][ 1 ] = html_print_checkbox_switch ( 'command_snapshot' , 1 , $config [ 'command_snapshot' ], true );
2020-05-29 11:37:06 +02:00
$table -> data [ $i ][ 0 ] = __ ( 'Server logs directory' );
2019-07-02 14:17:53 +02:00
$table -> data [ $i ++ ][ 1 ] = html_print_input_text (
2019-01-30 16:18:44 +01:00
'server_log_dir' ,
$config [ 'server_log_dir' ],
'' ,
50 ,
255 ,
true
);
2020-05-29 11:37:06 +02:00
$table -> data [ $i ][ 0 ] = __ ( 'Log size limit in system logs viewer extension' );
2019-07-02 14:17:53 +02:00
$table -> data [ $i ++ ][ 1 ] = html_print_input_text (
2019-01-30 16:18:44 +01:00
'max_log_size' ,
$config [ 'max_log_size' ],
'' ,
10 ,
255 ,
true
) . html_print_label ( ' x1000' , 'max_log_size' , true );
$modes_tutorial = [
'full' => __ ( 'Full mode' ),
'on_demand' => __ ( 'On demand' ),
'expert' => __ ( 'Expert' ),
];
2020-05-29 11:37:06 +02:00
$table -> data [ $i ][ 0 ] = __ ( 'Tutorial mode' );
2019-07-02 14:17:53 +02:00
$table -> data [ $i ++ ][ 1 ] = html_print_select (
2019-01-30 16:18:44 +01:00
$modes_tutorial ,
'tutorial_mode' ,
$config [ 'tutorial_mode' ],
'' ,
'' ,
0 ,
true
);
$config [ 'past_planned_downtimes' ] = isset ( $config [ 'past_planned_downtimes' ]) ? $config [ 'past_planned_downtimes' ] : 1 ;
2020-05-29 11:37:06 +02:00
$table -> data [ $i ][ 0 ] = __ ( 'Allow create planned downtimes in the past' );
2019-07-02 14:17:53 +02:00
$table -> data [ $i ++ ][ 1 ] = html_print_checkbox_switch ( 'past_planned_downtimes' , 1 , $config [ 'past_planned_downtimes' ], true );
2019-01-30 16:18:44 +01:00
2020-05-29 11:37:06 +02:00
$table -> data [ $i ][ 0 ] = __ ( 'Limit for bulk operations' );
2019-07-02 14:17:53 +02:00
$table -> data [ $i ++ ][ 1 ] = html_print_input_text (
2019-01-30 16:18:44 +01:00
'limit_parameters_massive' ,
$config [ 'limit_parameters_massive' ],
'' ,
10 ,
10 ,
true
);
2015-02-04 11:18:34 +01:00
2019-07-02 14:17:53 +02:00
$table -> data [ $i ][ 0 ] = __ ( 'Include agents manually disabled' );
$table -> data [ $i ++ ][ 1 ] = html_print_checkbox_switch ( 'include_agents' , 1 , $config [ 'include_agents' ], true );
2016-07-04 15:46:56 +02:00
2020-05-29 11:37:06 +02:00
$table -> data [ $i ][ 0 ] = __ ( 'Audit log directory' );
2019-07-02 14:17:53 +02:00
$table -> data [ $i ++ ][ 1 ] = html_print_input_text ( 'auditdir' , io_safe_output ( $config [ 'auditdir' ]), '' , 30 , 100 , true );
2016-07-04 15:46:56 +02:00
2019-07-02 14:17:53 +02:00
$table -> data [ $i ][ 0 ] = __ ( 'Set alias as name by default in agent creation' );
$table -> data [ $i ++ ][ 1 ] = html_print_checkbox_switch ( 'alias_as_name' , 1 , $config [ 'alias_as_name' ], true );
2017-09-08 12:11:15 +02:00
2020-05-29 11:37:06 +02:00
$table -> data [ $i ][ 0 ] = __ ( 'Unique IP' );
2019-07-02 14:17:53 +02:00
$table -> data [ $i ++ ][ 1 ] = html_print_checkbox_switch ( 'unique_ip' , 1 , $config [ 'unique_ip' ], true );
2019-01-09 16:20:24 +01:00
2013-01-18 18:41:00 +01:00
echo '<form id="form_setup" method="post" action="index.php?sec=gsetup&sec2=godmode/setup/setup&section=general&pure=' . $config [ 'pure' ] . '">' ;
2019-01-30 16:18:44 +01:00
echo '<fieldset>' ;
echo '<legend>' . __ ( 'General options' ) . '</legend>' ;
2013-01-18 18:41:00 +01:00
2019-01-30 16:18:44 +01:00
html_print_input_hidden ( 'update_config' , 1 );
html_print_table ( $table );
2013-01-18 18:41:00 +01:00
2019-06-10 09:43:27 +02:00
$encryption = [
'ssl' => 'SSL/TLS' ,
'sslv2' => 'SSLv2' ,
'sslv3' => 'SSLv3' ,
'tls' => 'STARTTLS' ,
];
echo '</fieldset>' ;
echo '<fieldset>' ;
echo '<legend>' . __ ( 'Mail configuration' ) . '</legend>' ;
2019-09-12 15:37:16 +02:00
$table_mail_conf -> data [ 0 ][ 0 ] = __ ( 'From address' );
2019-06-10 09:43:27 +02:00
$table_mail_conf -> data [ 0 ][ 1 ] = html_print_input_text ( 'email_from_dir' , $config [ 'email_from_dir' ], '' , 30 , 100 , true );
$table_mail_conf -> data [ 1 ][ 0 ] = __ ( 'From name' );
$table_mail_conf -> data [ 1 ][ 2 ] = html_print_input_text ( 'email_from_name' , $config [ 'email_from_name' ], '' , 30 , 100 , true );
2019-09-10 11:38:02 +02:00
$table_mail_conf -> data [ 2 ][ 0 ] = __ ( 'SMTP Server' );
2019-06-10 09:43:27 +02:00
$table_mail_conf -> data [ 2 ][ 1 ] = html_print_input_text ( 'email_smtpServer' , $config [ 'email_smtpServer' ], '' , 30 , 100 , true );
2019-09-10 11:38:02 +02:00
$table_mail_conf -> data [ 3 ][ 0 ] = __ ( 'SMTP Port' );
2019-06-10 09:43:27 +02:00
$table_mail_conf -> data [ 3 ][ 1 ] = html_print_input_text ( 'email_smtpPort' , $config [ 'email_smtpPort' ], '' , 30 , 100 , true );
$table_mail_conf -> data [ 4 ][ 0 ] = __ ( 'Encryption' );
$table_mail_conf -> data [ 4 ][ 1 ] = html_print_select ( $encryption , 'email_encryption' , $config [ 'email_encryption' ], '' , __ ( 'none' ), 0 , true );
$table_mail_conf -> data [ 5 ][ 0 ] = __ ( 'Email user' );
$table_mail_conf -> data [ 5 ][ 1 ] = html_print_input_text ( 'email_username' , $config [ 'email_username' ], '' , 30 , 100 , true );
$table_mail_conf -> data [ 6 ][ 0 ] = __ ( 'Email password' );
$table_mail_conf -> data [ 6 ][ 1 ] = html_print_input_password ( 'email_password' , io_output_password ( $config [ 'email_password' ]), '' , 30 , 100 , true );
2019-09-12 15:37:16 +02:00
$uniqid = uniqid ();
2020-05-29 11:37:06 +02:00
$table_mail_conf -> data [ 7 ][ 0 ] = html_print_button ( __ ( 'Email test' ), 'email_test_dialog' , false , " show_email_test(' $uniqid '); " , 'class="sub next"' , true );
2019-09-12 15:37:16 +02:00
print_email_test_modal_window ( $uniqid );
2019-06-10 09:43:27 +02:00
html_print_input_hidden ( 'update_config' , 1 );
html_print_table ( $table_mail_conf );
2019-09-12 15:37:16 +02:00
2019-10-21 17:36:26 +02:00
echo '</fieldset>' ;
echo '<fieldset>' ;
2013-01-18 18:41:00 +01:00
echo '<div class="action-buttons" style="width: ' . $table -> width . '">' ;
2019-01-30 16:18:44 +01:00
html_print_submit_button ( __ ( 'Update' ), 'update_button' , false , 'class="sub upd"' );
2013-01-18 18:41:00 +01:00
echo '</div>' ;
echo '</form>' ;
2019-09-12 15:37:16 +02:00
// Print the modal window for the summary of each alerts group
function print_email_test_modal_window ( $id )
{
// Email config table.
$table_mail_test = new stdClass ();
$table_mail_test -> width = '100%' ;
$table_mail_test -> class = 'databox filters' ;
$table_mail_test -> data = [];
$table_mail_test -> style [ 0 ] = 'font-weight: bold' ;
$table_mail_test -> colspan [ 1 ][ 0 ] = 2 ;
2020-05-29 11:37:06 +02:00
$table_mail_test -> data [ 0 ][ 0 ] = __ ( 'Address' );
2019-09-12 15:37:16 +02:00
$table_mail_test -> data [ 0 ][ 1 ] = html_print_input_text ( 'email_test_address' , '' , '' , 40 , 100 , true );
$table_mail_test -> data [ 1 ][ 0 ] = html_print_button ( __ ( 'Send' ), 'email_test' , false , '' , 'class="sub next"' , true ) . '  <span id="email_test_sent_message" style="display:none;">Email sent</span><span id="email_test_failure_message" style="display:none;">Email could not been sent</span>' ;
echo '<div id="email_test_' . $id . '" title="' . __ ( 'Check mail configuration' ) . '" style="display:none">' . html_print_table ( $table_mail_test , true ) . '</div>' ;
}
2013-01-18 18:41:00 +01:00
?>
< script type = " text/javascript " >
function toggleButton ( type ) {
2019-01-30 16:18:44 +01:00
if ( $ ( " #button_sound_ " + type ) . attr ( 'src' ) == 'images/control_pause_col.png' ) {
$ ( " #button_sound_ " + type ) . attr ( 'src' , 'images/control_play_col.png' );
$ ( '#layer_sound_' + type ) . html ( " " );
}
else {
$ ( " #button_sound_ " + type ) . attr ( 'src' , 'images/control_pause_col.png' );
$ ( '#layer_sound_' + type ) . html ( " <audio src=' " + $ ( " #sound_ " + type ) . val () + " ' autoplay='true' hidden='true' loop='true'> " );
}
2013-01-18 18:41:00 +01:00
}
function replaySound ( type ) {
2019-01-30 16:18:44 +01:00
if ( $ ( " #button_sound_ " + type ) . attr ( 'src' ) == 'images/control_pause_col.png' ) {
$ ( '#layer_sound_' + type ) . html ( " " );
$ ( '#layer_sound_' + type ) . html ( " <audio src=' " + $ ( " #sound_ " + type ) . val () + " ' autoplay='true' hidden='true' loop='true'> " );
}
2013-01-18 18:41:00 +01:00
}
function show_timezone () {
2019-01-30 16:18:44 +01:00
zone = $ ( " #zone " ) . val ();
$ . ajax ({
type : " POST " ,
url : " ajax.php " ,
data : " page=<?php echo $_GET['sec2'] ; ?>&select_timezone=1&zone= " + zone ,
dataType : " json " ,
success : function ( data ) {
$ ( " #timezone " ) . empty ();
jQuery . each ( data , function ( id , value ) {
timezone = value ;
$ ( " select[name='timezone'] " ) . append ( $ ( " <option> " ) . val ( timezone ) . html ( timezone ));
});
}
});
2013-01-18 18:41:00 +01:00
}
2019-09-12 15:37:16 +02:00
function show_email_test ( id ) {
$ ( '#email_test_sent_message' ) . hide ();
$ ( '#email_test_failure_message' ) . hide ();
$ ( " #email_test_ " + id ) . dialog ({
resizable : true ,
draggable : true ,
modal : true ,
height : 175 ,
width : 450 ,
overlay : {
opacity : 0.5 ,
background : " black "
}
});
}
function perform_email_test () {
var test_address = $ ( '#text-email_test_address' ) . val ();
$ . ajax ({
type : " POST " ,
url : " ajax.php " ,
data : " page=godmode/setup/setup_general&test_address= " + test_address ,
dataType : " html " ,
success : function ( data ) {
$ ( '#email_test_sent_message' ) . show ();
},
error : function () {
$ ( '#email_test_failure_message' ) . show ();
},
});
}
2013-01-18 18:41:00 +01:00
$ ( document ) . ready ( function () {
2018-05-09 13:12:03 +02:00
2019-01-30 16:18:44 +01:00
$ ( " #zone " ) . attr ( " hidden " , true );
$ ( " #timezone " ) . attr ( " hidden " , true );
2018-05-09 13:12:03 +02:00
2019-01-30 16:18:44 +01:00
$ ( " #change_timezone " ) . click ( function () {
$ ( " #zone " ) . attr ( " hidden " , false );
$ ( " #timezone " ) . attr ( " hidden " , false );
});
2018-12-07 15:12:09 +01:00
2019-02-26 12:04:18 +01:00
if ( $ ( " input[name=use_cert] " ) . is ( ':checked' )) {
2019-07-02 14:17:53 +02:00
$ ( '#ssl-path-tr' ) . show ();
2019-02-26 12:04:18 +01:00
}
2019-02-15 14:56:20 +01:00
2019-01-30 16:18:44 +01:00
$ ( " input[name=use_cert] " ) . change ( function () {
2019-02-06 16:11:46 +01:00
if ( $ ( this ) . is ( " :checked " ) )
2019-07-02 14:17:53 +02:00
$ ( '#ssl-path-tr' ) . show ();
2019-01-30 16:18:44 +01:00
else
2019-07-02 14:17:53 +02:00
$ ( '#ssl-path-tr' ) . hide ();
2019-01-17 17:28:23 +01:00
2019-01-30 16:18:44 +01:00
});
2019-02-06 16:11:46 +01:00
$ ( " input[name=https] " ) . change ( function (){
if ( $ ( " input[name=https] " ) . prop ( 'checked' )) {
2019-07-02 14:17:53 +02:00
$ ( " #dialog " ) . dialog ({
2019-02-06 16:11:46 +01:00
modal : true ,
2019-07-02 14:17:53 +02:00
width : 500 ,
buttons : [
{
class : 'ui-widget ui-state-default ui-corner-all ui-button-text-only sub upd submit-next' ,
text : " <?php echo __('OK'); ?> " ,
click : function (){
$ ( this ) . dialog ( " close " );
}
2019-02-06 16:11:46 +01:00
}
2019-07-02 14:17:53 +02:00
]
2019-02-06 16:11:46 +01:00
});
}
})
2013-01-18 18:41:00 +01:00
2019-07-02 14:17:53 +02:00
$ ( " input[name=force_public_url] " ) . change ( function (){
if ( $ ( " input[name=force_public_url] " ) . prop ( 'checked' )) {
$ ( " #force_public_url_dialog " ) . dialog ({
modal : true ,
width : 500 ,
buttons : [
{
class : 'ui-widget ui-state-default ui-corner-all ui-button-text-only sub upd submit-next' ,
text : " <?php echo __('OK'); ?> " ,
click : function (){
$ ( this ) . dialog ( " close " );
}
}
]
});
2019-01-30 16:18:44 +01:00
}
2019-07-02 14:17:53 +02:00
})
2019-09-12 15:37:16 +02:00
$ ( 'input#button-email_test' ) . click ( perform_email_test );
2013-01-18 18:41:00 +01:00
});
</ script >