From 595848f9dbf9fda650ca1809f94702043dbc0f79 Mon Sep 17 00:00:00 2001 From: pdontthink Date: Thu, 6 May 2004 19:28:17 +0000 Subject: [PATCH] Split out functionality that gathers system specs git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@7392 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- plugins/bug_report/bug_report.php | 108 +------------------- plugins/bug_report/setup.php | 5 +- plugins/bug_report/show_system_specs.php | 33 ++++++ plugins/bug_report/system_specs.php | 124 +++++++++++++++++++++++ 4 files changed, 166 insertions(+), 104 deletions(-) create mode 100644 plugins/bug_report/show_system_specs.php create mode 100644 plugins/bug_report/system_specs.php diff --git a/plugins/bug_report/bug_report.php b/plugins/bug_report/bug_report.php index d7c890c9..f75d69fc 100644 --- a/plugins/bug_report/bug_report.php +++ b/plugins/bug_report/bug_report.php @@ -30,34 +30,8 @@ require_once(SM_PATH . 'functions/forms.php'); displayPageHeader($color, 'None'); -/** - * converts array to string - * - * @param array $array array that has to be displayed - * @return string - * @access private - */ -function Show_Array($array) { - $str = ''; - foreach ($array as $key => $value) { - if ($key != 0 || $value != '') { - $str .= " * $key = $value\n"; - } - } - if ($str == '') { - return " * Nothing listed\n"; - } - return $str; -} - -$browscap = ini_get('browscap'); -if(!empty($browscap)) { - $browser = get_browser(); -} - -sqgetGlobalVar('HTTP_USER_AGENT', $HTTP_USER_AGENT, SQ_SERVER); -if ( ! sqgetGlobalVar('HTTP_USER_AGENT', $HTTP_USER_AGENT, SQ_SERVER) ) - $HTTP_USER_AGENT="Browser information is not available."; +include_once(SM_PATH . 'plugins/bug_report/system_specs.php'); +global $body; $body_top = "I subscribe to the squirrelmail-users mailing list.\n" . " [ ] True - No need to CC me when replying\n" . @@ -72,81 +46,9 @@ $body_top = "I subscribe to the squirrelmail-users mailing list.\n" . "I can reproduce the bug by:\n\n\n" . "(Optional) I got bored and found the bug occurs in:\n\n\n" . "(Optional) I got really bored and here's a fix:\n\n\n" . - "----------------------------------------------\n" . - "\nMy browser information:\n" . - ' '.$HTTP_USER_AGENT . "\n" ; - if(isset($browser)) { - $body_top .= " get_browser() information (List)\n" . - Show_Array((array) $browser); - } - $body_top .= "\nMy web server information:\n" . - " PHP Version " . phpversion() . "\n" . - " PHP Extensions (List)\n" . - Show_Array(get_loaded_extensions()) . - "\nSquirrelMail-specific information:\n" . - " Version: $version\n" . - " Plugins (List)\n" . - Show_Array($plugins); -if (isset($ldap_server) && $ldap_server[0] && ! extension_loaded('ldap')) { - $warning = 1; - $warnings['ldap'] = "LDAP server defined in SquirrelMail config, " . - "but the module is not loaded in PHP"; - $corrections['ldap'][] = "Reconfigure PHP with the option '--with-ldap'"; - $corrections['ldap'][] = "Then recompile PHP and reinstall"; - $corrections['ldap'][] = "-- OR --"; - $corrections['ldap'][] = "Reconfigure SquirrelMail to not use LDAP"; -} - -$body = "\nMy IMAP server information:\n" . - " Server type: $imap_server_type\n"; -$imap_stream = fsockopen ($imapServerAddress, $imapPort, $error_number, $error_string); -$server_info = fgets ($imap_stream, 1024); -if ($imap_stream) { - // SUPRESS HOST NAME - $list = explode(' ', $server_info); - $list[2] = '[HIDDEN]'; - $server_info = implode(' ', $list); - $body .= " Server info: $server_info"; - fputs ($imap_stream, "a001 CAPABILITY\r\n"); - $read = fgets($imap_stream, 1024); - $list = explode(' ', $read); - array_shift($list); - array_shift($list); - $read = implode(' ', $list); - $body .= " Capabilities: $read"; - fputs ($imap_stream, "a002 LOGOUT\r\n"); - fclose($imap_stream); -} else { - $body .= " Unable to connect to IMAP server to get information.\n"; - $warning = 1; - $warnings['imap'] = "Unable to connect to IMAP server"; - $corrections['imap'][] = "Make sure you specified the correct mail server"; - $corrections['imap'][] = "Make sure the mail server is running IMAP, not POP"; - $corrections['imap'][] = "Make sure the server responds to port $imapPort"; -} -$warning_html = ''; -$warning_num = 0; -if (isset($warning) && $warning) { - foreach ($warnings as $key => $value) { - if ($warning_num == 0) { - $body_top .= "WARNINGS WERE REPORTED WITH YOUR SETUP:\n"; - $body_top = "WARNINGS WERE REPORTED WITH YOUR SETUP -- SEE BELOW\n\n$body_top"; - $warning_html = "

Warnings were reported with your setup:

\n
\n"; - } - $warning_num ++; - $warning_html .= "
$value
\n"; - $body_top .= "\n$value\n"; - foreach ($corrections[$key] as $corr_val) { - $body_top .= " * $corr_val\n"; - $warning_html .= "
* $corr_val
\n"; - } - } - $warning_html .= "
\n

$warning_num warning(s) reported.

\n
\n"; - $body_top .= "\n$warning_num warning(s) reported.\n"; - $body_top .= "----------------------------------------------\n"; -} - -$body = htmlspecialchars($body_top . $body); + "----------------------------------------------\n\n"; + +$body = htmlspecialchars($body_top) . $body; ?>
diff --git a/plugins/bug_report/setup.php b/plugins/bug_report/setup.php index cba06385..793f0e70 100644 --- a/plugins/bug_report/setup.php +++ b/plugins/bug_report/setup.php @@ -85,6 +85,9 @@ function bug_report_options() { echo ' checked'; } echo ' /> ' . _("Show button in toolbar") . "\n"; + + echo '' . + '' . _("Show system specs") . ''; } -?> \ No newline at end of file +?> diff --git a/plugins/bug_report/show_system_specs.php b/plugins/bug_report/show_system_specs.php new file mode 100644 index 00000000..83e22b03 --- /dev/null +++ b/plugins/bug_report/show_system_specs.php @@ -0,0 +1,33 @@ + + + +
+
+
+
+ + diff --git a/plugins/bug_report/system_specs.php b/plugins/bug_report/system_specs.php new file mode 100644 index 00000000..6e1c1bb5 --- /dev/null +++ b/plugins/bug_report/system_specs.php @@ -0,0 +1,124 @@ + $value) { + if ($key != 0 || $value != '') { + $str .= " * $key = $value\n"; + } + } + if ($str == '') { + return " * Nothing listed\n"; + } + return $str; +} + +$browscap = ini_get('browscap'); +if(!empty($browscap)) { + $browser = get_browser(); +} + +sqgetGlobalVar('HTTP_USER_AGENT', $HTTP_USER_AGENT, SQ_SERVER); +if ( ! sqgetGlobalVar('HTTP_USER_AGENT', $HTTP_USER_AGENT, SQ_SERVER) ) + $HTTP_USER_AGENT="Browser information is not available."; + +$body_top = "My browser information:\n" . + ' '.$HTTP_USER_AGENT . "\n" ; + if(isset($browser)) { + $body_top .= " get_browser() information (List)\n" . + Show_Array((array) $browser); + } + $body_top .= "\nMy web server information:\n" . + " PHP Version " . phpversion() . "\n" . + " PHP Extensions (List)\n" . + Show_Array(get_loaded_extensions()) . + "\nSquirrelMail-specific information:\n" . + " Version: $version\n" . + " Plugins (List)\n" . + Show_Array($plugins); +if (isset($ldap_server) && $ldap_server[0] && ! extension_loaded('ldap')) { + $warning = 1; + $warnings['ldap'] = "LDAP server defined in SquirrelMail config, " . + "but the module is not loaded in PHP"; + $corrections['ldap'][] = "Reconfigure PHP with the option '--with-ldap'"; + $corrections['ldap'][] = "Then recompile PHP and reinstall"; + $corrections['ldap'][] = "-- OR --"; + $corrections['ldap'][] = "Reconfigure SquirrelMail to not use LDAP"; +} + +$body = "\nMy IMAP server information:\n" . + " Server type: $imap_server_type\n"; +$imap_stream = fsockopen ($imapServerAddress, $imapPort, $error_number, $error_string); +$server_info = fgets ($imap_stream, 1024); +if ($imap_stream) { + // SUPRESS HOST NAME + $list = explode(' ', $server_info); + $list[2] = '[HIDDEN]'; + $server_info = implode(' ', $list); + $body .= " Server info: $server_info"; + fputs ($imap_stream, "a001 CAPABILITY\r\n"); + $read = fgets($imap_stream, 1024); + $list = explode(' ', $read); + array_shift($list); + array_shift($list); + $read = implode(' ', $list); + $body .= " Capabilities: $read"; + fputs ($imap_stream, "a002 LOGOUT\r\n"); + fclose($imap_stream); +} else { + $body .= " Unable to connect to IMAP server to get information.\n"; + $warning = 1; + $warnings['imap'] = "Unable to connect to IMAP server"; + $corrections['imap'][] = "Make sure you specified the correct mail server"; + $corrections['imap'][] = "Make sure the mail server is running IMAP, not POP"; + $corrections['imap'][] = "Make sure the server responds to port $imapPort"; +} +$warning_html = ''; +$warning_num = 0; +if (isset($warning) && $warning) { + foreach ($warnings as $key => $value) { + if ($warning_num == 0) { + $body_top .= "WARNINGS WERE REPORTED WITH YOUR SETUP:\n"; + $body_top = "WARNINGS WERE REPORTED WITH YOUR SETUP -- SEE BELOW\n\n$body_top"; + $warning_html = "

Warnings were reported with your setup:

\n
\n"; + } + $warning_num ++; + $warning_html .= "
$value
\n"; + $body_top .= "\n$value\n"; + foreach ($corrections[$key] as $corr_val) { + $body_top .= " * $corr_val\n"; + $warning_html .= "
* $corr_val
\n"; + } + } + $warning_html .= "
\n

$warning_num warning(s) reported.

\n
\n"; + $body_top .= "\n$warning_num warning(s) reported.\n"; + $body_top .= "----------------------------------------------\n"; +} + +$body = htmlspecialchars($body_top . $body); + +?> -- 2.25.1