Example #1
0
/**
 * Gather information from the server, database engine, and PHP interpreter.
 *
 * @return array A list of pseudo-variables and values that will replace them in the HTML template.
 */
function sucuriscan_server_info()
{
    global $wpdb;
    $template_variables = array('ServerInfo.Variables' => '');
    $info_vars = array('Plugin_version' => SUCURISCAN_VERSION, 'Plugin_checksum' => SUCURISCAN_PLUGIN_CHECKSUM, 'Last_filesystem_scan' => SucuriScanFSScanner::get_filesystem_runtime(true), 'Datetime_and_Timezone' => '', 'Operating_system' => sprintf('%s (%d Bit)', PHP_OS, PHP_INT_SIZE * 8), 'Server' => 'Unknown', 'Developer_mode' => 'OFF', 'Memory_usage' => 'N/A', 'MySQL_version' => '0.0', 'SQL_mode' => 'Not set', 'PHP_version' => PHP_VERSION);
    $info_vars['Datetime_and_Timezone'] = sprintf('%s (GMT %s)', SucuriScan::current_datetime(), get_option('gmt_offset'));
    if (defined('WP_DEBUG') && WP_DEBUG) {
        $info_vars['Developer_mode'] = 'ON';
    }
    if (function_exists('memory_get_usage')) {
        $info_vars['Memory_usage'] = round(memory_get_usage() / 1024 / 1024, 2) . ' MB';
    }
    if (isset($_SERVER['SERVER_SOFTWARE'])) {
        $info_vars['Server'] = SucuriScan::escape($_SERVER['SERVER_SOFTWARE']);
    }
    if ($wpdb) {
        $info_vars['MySQL_version'] = $wpdb->get_var('SELECT VERSION() AS version');
        $mysql_info = $wpdb->get_results('SHOW VARIABLES LIKE "sql_mode"');
        if (is_array($mysql_info) && !empty($mysql_info[0]->Value)) {
            $info_vars['SQL_mode'] = $mysql_info[0]->Value;
        }
    }
    $field_names = array('safe_mode', 'expose_php', 'allow_url_fopen', 'memory_limit', 'upload_max_filesize', 'post_max_size', 'max_execution_time', 'max_input_time');
    foreach ($field_names as $php_flag) {
        $php_flag_value = SucuriScan::ini_get($php_flag);
        $php_flag_name = 'PHP_' . $php_flag;
        $info_vars[$php_flag_name] = $php_flag_value ? $php_flag_value : 'N/A';
    }
    $counter = 0;
    foreach ($info_vars as $var_name => $var_value) {
        $css_class = $counter % 2 == 0 ? '' : 'alternate';
        $var_name = str_replace('_', chr(32), $var_name);
        $template_variables['ServerInfo.Variables'] .= SucuriScanTemplate::get_snippet('infosys-serverinfo', array('ServerInfo.CssClass' => $css_class, 'ServerInfo.Title' => $var_name, 'ServerInfo.Value' => $var_value));
        $counter += 1;
    }
    return SucuriScanTemplate::get_section('infosys-serverinfo', $template_variables);
}
Example #2
0
/**
 * Gather information from the server, database engine, and PHP interpreter.
 *
 * @return array A list of pseudo-variables and values that will replace them in the HTML template.
 */
function sucuriscan_server_info()
{
    global $wpdb;
    $template_variables = array('ServerInfo.Variables' => '');
    $info_vars = array('Plugin_version' => SUCURISCAN_VERSION, 'Plugin_checksum' => SUCURISCAN_PLUGIN_CHECKSUM, 'Last_filesystem_scan' => SucuriScanFSScanner::get_filesystem_runtime(true), 'Using_CloudProxy' => 'Unknown', 'Support_Reverse_Proxy' => 'Unknown', 'Host_Address' => 'Unknown', 'HTTP_Host' => 'Unknown', 'Host_Name' => 'Unknown', 'Site_URL' => 'Unknown', 'Top_Level_Domain' => 'Unknown', 'Remote_Address' => SucuriScan::get_remote_addr(), 'Remote_Address_Header' => SucuriScan::get_remote_addr_header(), 'Operating_system' => sprintf('%s (%d Bit)', PHP_OS, PHP_INT_SIZE * 8), 'Server' => 'Unknown', 'Developer_mode' => 'OFF', 'Memory_usage' => 'N/A', 'MySQL_version' => '0.0', 'SQL_mode' => 'Not set', 'PHP_version' => PHP_VERSION);
    $proxy_info = SucuriScan::is_behind_cloudproxy(true);
    $reverse_proxy = SucuriScan::support_reverse_proxy();
    $info_vars['HTTP_Host'] = $proxy_info['http_host'];
    $info_vars['Host_Name'] = $proxy_info['host_name'];
    $info_vars['Host_Address'] = $proxy_info['host_addr'];
    $info_vars['Site_URL'] = SucuriScan::get_domain();
    $info_vars['Top_Level_Domain'] = SucuriScan::get_domain(true);
    $info_vars['Using_CloudProxy'] = $proxy_info['status'] ? 'Yes' : 'No';
    $info_vars['Support_Reverse_Proxy'] = $reverse_proxy ? 'Yes' : 'No';
    if (defined('WP_DEBUG') && WP_DEBUG) {
        $info_vars['Developer_mode'] = 'ON';
    }
    if (function_exists('memory_get_usage')) {
        $info_vars['Memory_usage'] = round(memory_get_usage() / 1024 / 1024, 2) . ' MB';
    }
    if (isset($_SERVER['SERVER_SOFTWARE'])) {
        $info_vars['Server'] = SucuriScan::escape($_SERVER['SERVER_SOFTWARE']);
    }
    if ($wpdb) {
        $info_vars['MySQL_version'] = $wpdb->get_var('SELECT VERSION() AS version');
        $mysql_info = $wpdb->get_results('SHOW VARIABLES LIKE "sql_mode"');
        if (is_array($mysql_info) && !empty($mysql_info[0]->Value)) {
            $info_vars['SQL_mode'] = $mysql_info[0]->Value;
        }
    }
    $field_names = array('safe_mode', 'expose_php', 'allow_url_fopen', 'memory_limit', 'upload_max_filesize', 'post_max_size', 'max_execution_time', 'max_input_time');
    foreach ($field_names as $php_flag) {
        $php_flag_value = SucuriScan::ini_get($php_flag);
        $php_flag_name = 'PHP_' . $php_flag;
        $info_vars[$php_flag_name] = $php_flag_value ? $php_flag_value : 'N/A';
    }
    $counter = 0;
    foreach ($info_vars as $var_name => $var_value) {
        $css_class = $counter % 2 == 0 ? '' : 'alternate';
        $var_name = str_replace('_', chr(32), $var_name);
        $template_variables['ServerInfo.Variables'] .= SucuriScanTemplate::get_snippet('infosys-serverinfo', array('ServerInfo.CssClass' => $css_class, 'ServerInfo.Title' => $var_name, 'ServerInfo.Value' => $var_value));
        $counter += 1;
    }
    return SucuriScanTemplate::get_section('infosys-serverinfo', $template_variables);
}