| 1 | <?php |
| 2 | /** |
| 3 | * This gathers system specification details for use with bug reporting |
| 4 | * and anyone else who needs it. |
| 5 | * |
| 6 | * Copyright (c) 1999-2005 The SquirrelMail Project Team |
| 7 | * Licensed under the GNU GPL. For full terms see the file COPYING. |
| 8 | * |
| 9 | * This is a standard SquirrelMail 1.2 API for plugins. |
| 10 | * |
| 11 | * @version $Id$ |
| 12 | * @package plugins |
| 13 | * @subpackage bug_report |
| 14 | */ |
| 15 | |
| 16 | /** |
| 17 | * load required libraries |
| 18 | */ |
| 19 | include_once(SM_PATH . 'include/validate.php'); |
| 20 | include_once(SM_PATH . 'functions/imap.php'); |
| 21 | global $body, $username; |
| 22 | |
| 23 | |
| 24 | /** |
| 25 | * converts array to string |
| 26 | * |
| 27 | * @param array $array array that has to be displayed |
| 28 | * @return string |
| 29 | * @access private |
| 30 | */ |
| 31 | function Show_Array($array) { |
| 32 | $str = ''; |
| 33 | foreach ($array as $key => $value) { |
| 34 | if ($key != 0 || $value != '') { |
| 35 | $str .= " * $key = $value\n"; |
| 36 | } |
| 37 | } |
| 38 | if ($str == '') { |
| 39 | return " * Nothing listed\n"; |
| 40 | } |
| 41 | return $str; |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * converts plugin's array to string and adds version numbers |
| 46 | * @return string preformated text with installed plugin's information |
| 47 | * @access private |
| 48 | */ |
| 49 | function br_show_plugins() { |
| 50 | global $plugins; |
| 51 | $str = ''; |
| 52 | if (is_array($plugins) && $plugins!=array()) { |
| 53 | foreach ($plugins as $key => $value) { |
| 54 | if ($key != 0 || $value != '') { |
| 55 | $str .= " * $key = $value"; |
| 56 | // add plugin version |
| 57 | if (function_exists($value . '_version')) { |
| 58 | $str.= ' ' . call_user_func($value . '_version'); |
| 59 | } |
| 60 | $str.="\n"; |
| 61 | } |
| 62 | } |
| 63 | // compatibility plugin can be used without need to enable it in sm config |
| 64 | if (file_exists(SM_PATH . 'plugins/compatibility/setup.php') |
| 65 | && ! in_array('compatibility',$plugins)) { |
| 66 | $str.= ' * compatibility'; |
| 67 | include_once(SM_PATH . 'plugins/compatibility/setup.php'); |
| 68 | if (function_exists('compatibility_version')) { |
| 69 | $str.= ' ' . call_user_func('compatibility_version'); |
| 70 | } |
| 71 | $str.="\n"; |
| 72 | } |
| 73 | } |
| 74 | if ($str == '') { |
| 75 | return " * Nothing listed\n"; |
| 76 | } |
| 77 | return $str; |
| 78 | } |
| 79 | |
| 80 | $browscap = ini_get('browscap'); |
| 81 | if(!empty($browscap)) { |
| 82 | $browser = get_browser(); |
| 83 | } |
| 84 | |
| 85 | sqgetGlobalVar('HTTP_USER_AGENT', $HTTP_USER_AGENT, SQ_SERVER); |
| 86 | if ( ! sqgetGlobalVar('HTTP_USER_AGENT', $HTTP_USER_AGENT, SQ_SERVER) ) |
| 87 | $HTTP_USER_AGENT="Browser information is not available."; |
| 88 | |
| 89 | $body_top = "My browser information:\n" . |
| 90 | ' '.$HTTP_USER_AGENT . "\n" ; |
| 91 | if(isset($browser)) { |
| 92 | $body_top .= " get_browser() information (List)\n" . |
| 93 | Show_Array((array) $browser); |
| 94 | } |
| 95 | $body_top .= "\nMy web server information:\n" . |
| 96 | " PHP Version " . phpversion() . "\n" . |
| 97 | " PHP Extensions (List)\n" . |
| 98 | Show_Array(get_loaded_extensions()) . |
| 99 | "\nSquirrelMail-specific information:\n" . |
| 100 | " Version: $version\n" . |
| 101 | " Plugins (List)\n" . |
| 102 | br_show_plugins(); |
| 103 | if (isset($ldap_server) && $ldap_server[0] && ! extension_loaded('ldap')) { |
| 104 | $warning = 1; |
| 105 | $warnings['ldap'] = "LDAP server defined in SquirrelMail config, " . |
| 106 | "but the module is not loaded in PHP"; |
| 107 | $corrections['ldap'][] = "Reconfigure PHP with the option '--with-ldap'"; |
| 108 | $corrections['ldap'][] = "Then recompile PHP and reinstall"; |
| 109 | $corrections['ldap'][] = "-- OR --"; |
| 110 | $corrections['ldap'][] = "Reconfigure SquirrelMail to not use LDAP"; |
| 111 | } |
| 112 | |
| 113 | $body = "\nMy IMAP server information:\n" . |
| 114 | " Server type: $imap_server_type\n"; |
| 115 | |
| 116 | $imapServerAddress = sqimap_get_user_server($imapServerAddress, $username); |
| 117 | $imap_stream = sqimap_create_stream($imapServerAddress, $imapPort, $use_imap_tls); |
| 118 | if ($imap_stream) { |
| 119 | $body.= ' Capabilities: '; |
| 120 | if ($imap_capabilities = sqimap_capability($imap_stream)) { |
| 121 | foreach ($imap_capabilities as $capability => $value) { |
| 122 | $body.= $capability . (is_bool($value) ? ' ' : "=$value "); |
| 123 | } |
| 124 | } |
| 125 | $body.="\n"; |
| 126 | sqimap_logout($imap_stream); |
| 127 | } else { |
| 128 | $body .= " Unable to connect to IMAP server to get information.\n"; |
| 129 | $warning = 1; |
| 130 | $warnings['imap'] = "Unable to connect to IMAP server"; |
| 131 | $corrections['imap'][] = "Make sure you specified the correct mail server"; |
| 132 | $corrections['imap'][] = "Make sure the mail server is running IMAP, not POP"; |
| 133 | $corrections['imap'][] = "Make sure the server responds to port $imapPort"; |
| 134 | } |
| 135 | $warning_html = ''; |
| 136 | $warning_num = 0; |
| 137 | if (isset($warning) && $warning) { |
| 138 | foreach ($warnings as $key => $value) { |
| 139 | if ($warning_num == 0) { |
| 140 | $body_top .= "WARNINGS WERE REPORTED WITH YOUR SETUP:\n"; |
| 141 | $body_top = "WARNINGS WERE REPORTED WITH YOUR SETUP -- SEE BELOW\n\n$body_top"; |
| 142 | $warning_html = "<h1>Warnings were reported with your setup:</h1>\n<dl>\n"; |
| 143 | } |
| 144 | $warning_num ++; |
| 145 | $warning_html .= "<dt><b>$value</b></dt>\n"; |
| 146 | $body_top .= "\n$value\n"; |
| 147 | foreach ($corrections[$key] as $corr_val) { |
| 148 | $body_top .= " * $corr_val\n"; |
| 149 | $warning_html .= "<dd>* $corr_val</dd>\n"; |
| 150 | } |
| 151 | } |
| 152 | $warning_html .= "</dl>\n<p>$warning_num warning(s) reported.</p>\n<hr />\n"; |
| 153 | $body_top .= "\n$warning_num warning(s) reported.\n"; |
| 154 | $body_top .= "----------------------------------------------\n"; |
| 155 | } |
| 156 | |
| 157 | $body = htmlspecialchars($body_top . $body); |
| 158 | |
| 159 | ?> |