prefix}livehelp_requests"); wp_redirect('admin.php?page=' . strtolower('activeHelper_liveHelp_serverSettings') . '&cleared'); exit; } $activeHelper_liveHelp['stats'] = array(); $activeHelper_liveHelp['stats']['requests'] = $wpdb->get_var("select count(*) from {$wpdb->prefix}livehelp_requests"); $activeHelper_liveHelp['stats']['chat-sessions'] = $wpdb->get_var("select count(*) from {$wpdb->prefix}livehelp_sessions"); $activeHelper_liveHelp['stats']['messages'] = $wpdb->get_var("select count(*) from {$wpdb->prefix}livehelp_messages"); $_POST['connection_timeout'] = !empty($_POST['connection_timeout']) ? (int) $_POST['connection_timeout'] : 60; $_POST['keep_alive_timeout'] = !empty($_POST['keep_alive_timeout']) ? (int) $_POST['keep_alive_timeout'] : 30; $_POST['guest_login_timeout'] = !empty($_POST['guest_login_timeout']) ? (int) $_POST['guest_login_timeout'] : 60; $_POST['chat_refresh_rate'] = !empty($_POST['chat_refresh_rate']) ? (int) $_POST['chat_refresh_rate'] : 6; $_POST['sound_alert_new_message'] = !empty($_POST['sound_alert_new_message']) ? (int) $_POST['sound_alert_new_message'] : 1; include($activeHelper_liveHelp['importDir'] . '/constants.php'); if (!isset($_POST['submit'])) { $_POST = array( 'connection_timeout' => $connection_timeout, 'keep_alive_timeout' => $keep_alive_timeout, 'guest_login_timeout' => $guest_login_timeout, 'chat_refresh_rate' => $chat_refresh_rate, 'sound_alert_new_message' => $sound_alert_new_message, 'sound_alert_new_pro_msg' => $sound_alert_new_pro_msg, 'status_indicator_img_type' => $status_indicator_img_type, 'invitation_position' => $invitation_position, ); return; } // $settingsFile = $activeHelper_liveHelp['importDir'] . '/constants.php'; $fhandle = fopen($settingsFile, "r"); $content = fread($fhandle, filesize($settingsFile)); $content = str_replace('$connection_timeout = ' . $connection_timeout . ';', '$connection_timeout = ' . $_POST['connection_timeout'] . ';', $content); $content = str_replace('$keep_alive_timeout = ' . $keep_alive_timeout . ';', '$keep_alive_timeout = ' . $_POST['keep_alive_timeout'] . ';', $content); $content = str_replace('$guest_login_timeout= ' . $guest_login_timeout . ';', '$guest_login_timeout= ' . $_POST['guest_login_timeout'] . ';', $content); $content = str_replace('$chat_refresh_rate = ' . $chat_refresh_rate . ';', '$chat_refresh_rate = ' . $_POST['chat_refresh_rate'] . ';', $content); $content = str_replace('$sound_alert_new_message = ' . $sound_alert_new_message . ';', '$sound_alert_new_message = ' . $_POST['sound_alert_new_message'] . ';', $content); $content = str_replace('$sound_alert_new_pro_msg =' . $sound_alert_new_pro_msg . ';', '$sound_alert_new_pro_msg =' . $_POST['sound_alert_new_pro_msg'] . ';', $content); $content = str_replace('$status_indicator_img_type = "' . $status_indicator_img_type . '";', '$status_indicator_img_type = "' . $_POST['status_indicator_img_type'] . '";', $content); $content = str_replace('$invitation_position = "' . $invitation_position . '";', '$invitation_position = "' . $_POST['invitation_position'] . '";', $content); $fhandle = fopen($settingsFile, "w"); fwrite($fhandle, $content); fclose($fhandle); wp_redirect('admin.php?page=' . strtolower('activeHelper_liveHelp_serverSettings') . '&update'); exit; } function activeHelper_liveHelp_serverSettings() { global $wpdb, $activeHelper_liveHelp; $tabindex = 1; echo '

LiveHelp ยป ' . __('Server settings', 'activehelper_livehelp') . ' ' . __('reset settings', 'activehelper_livehelp') . ' ' . __('clear up requests', 'activehelper_livehelp') . '

'; if (isset($_GET['update'])) echo '

' . sprintf(__('The %s were successfully updated.', 'activehelper_livehelp'), __('server settings', 'activehelper_livehelp')) . '

'; if (isset($_GET['cleared'])) echo '

' . sprintf(__('The %s were successfully cleared.', 'activehelper_livehelp'), __('requests', 'activehelper_livehelp')) . '

'; echo '

' . __('Update', 'activehelper_livehelp') . '


' . __('Server settings', 'activehelper_livehelp') . '


' . __('General stats', 'activehelper_livehelp') . '

' . sprintf(__('Total number of request: %s', 'activehelper_livehelp'), $activeHelper_liveHelp['stats']['requests']) . '

' . sprintf(__('Total number of chat sessions: %s', 'activehelper_livehelp'), $activeHelper_liveHelp['stats']['chat-sessions']) . '

' . sprintf(__('Total number of messages: %s', 'activehelper_livehelp'), $activeHelper_liveHelp['stats']['messages']) . '


'; echo '
'; }