Use compatibility_info() function if at all possible instead of compatibility_version()
[squirrelmail.git] / plugins / bug_report / system_specs.php
index c270de148dafd4d75432c7dfb4ff09b8ad9fcc38..8a46a45e084c5eafb305b87ff3972b0661894d2d 100644 (file)
@@ -1,23 +1,29 @@
 <?php
 /**
 <?php
 /**
- * This gathers system specification details for use with bug reporting
+ * This script gathers system specification details for use with bug reporting
  * and anyone else who needs it.
  *
  * and anyone else who needs it.
  *
- * Copyright (c) 1999-2004 The SquirrelMail development team
- * Licensed under the GNU GPL. For full terms see the file COPYING.
- *
- * This is a standard Squirrelmail-1.2 API for plugins.
- *
+ * @copyright &copy; 1999-2007 The SquirrelMail Project Team
+ * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  * @version $Id$
  * @package plugins
  * @subpackage bug_report
  */
 
  * @version $Id$
  * @package plugins
  * @subpackage bug_report
  */
 
+/**
+ * do not allow to call this file directly
+ */
+if ((isset($_SERVER['SCRIPT_FILENAME']) && $_SERVER['SCRIPT_FILENAME'] == __FILE__) ||
+     (isset($HTTP_SERVER_SERVER['SCRIPT_FILENAME']) && $HTTP_SERVER_SERVER['SCRIPT_FILENAME'] == __FILE__) ) {
+    header("Location: ../../src/login.php");
+    die();
+}
+
 /**
  * load required libraries
  */
 /**
  * load required libraries
  */
-include_once(SM_PATH . 'include/validate.php');
-global $body;
+include_once(SM_PATH . 'functions/imap_general.php');
+
 
 
 /**
 
 
 /**
@@ -40,6 +46,58 @@ function Show_Array($array) {
     return $str;
 }
 
     return $str;
 }
 
+/**
+ * converts plugin's array to string and adds version numbers
+ * @return string preformated text with installed plugin's information
+ * @access private
+ */
+function br_show_plugins() {
+    global $plugins;
+    $str = '';
+    if (is_array($plugins) && $plugins!=array()) {
+        foreach ($plugins as $key => $value) {
+            if ($key != 0 || $value != '') {
+                $str .= "    * $key = $value";
+                // add plugin version
+                $version_found = FALSE;
+                if (function_exists($value . '_info')) {
+                    $info = call_user_func($value . '_info');
+                    if (!empty($info['version'])) {
+                        $str .= ' ' . $info['version'];
+                        $version_found = TRUE;
+                    }
+                }
+                if (!$version_found && function_exists($value . '_version')) {
+                    $str.= ' ' . call_user_func($value . '_version');
+                }
+                $str.="\n";
+            }
+        }
+        // compatibility plugin can be used without need to enable it in sm config
+        if (file_exists(SM_PATH . 'plugins/compatibility/setup.php')
+            && ! in_array('compatibility',$plugins)) {
+            $str.= '    * compatibility';
+            include_once(SM_PATH . 'plugins/compatibility/setup.php');
+            $version_found = FALSE;
+            if (function_exists('compatibility_info')) {
+                $info = compatibility_info();
+                if (!empty($info['version'])) {
+                    $str .= ' ' . $info['version'];
+                    $version_found = TRUE;
+                }
+            }
+            if (!$version_found && function_exists('compatibility_version')) {
+                $str.= ' ' . compatibility_version();
+            }
+            $str.="\n";
+        }
+    }
+    if ($str == '') {
+        return "    * Nothing listed\n";
+    }
+    return $str;
+}
+
 $browscap = ini_get('browscap');
 if(!empty($browscap)) {
     $browser = get_browser();
 $browscap = ini_get('browscap');
 if(!empty($browscap)) {
     $browser = get_browser();
@@ -62,7 +120,7 @@ $body_top = "My browser information:\n" .
             "\nSquirrelMail-specific information:\n" .
             "  Version:  $version\n" .
             "  Plugins (List)\n" .
             "\nSquirrelMail-specific information:\n" .
             "  Version:  $version\n" .
             "  Plugins (List)\n" .
-            Show_Array($plugins);
+            br_show_plugins();
 if (isset($ldap_server) && $ldap_server[0] && ! extension_loaded('ldap')) {
     $warning = 1;
     $warnings['ldap'] = "LDAP server defined in SquirrelMail config, " .
 if (isset($ldap_server) && $ldap_server[0] && ! extension_loaded('ldap')) {
     $warning = 1;
     $warnings['ldap'] = "LDAP server defined in SquirrelMail config, " .
@@ -75,23 +133,18 @@ if (isset($ldap_server) && $ldap_server[0] && ! extension_loaded('ldap')) {
 
 $body = "\nMy IMAP server information:\n" .
             "  Server type:  $imap_server_type\n";
 
 $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);
+
+$imapServerAddress = sqimap_get_user_server($imapServerAddress, $username);
+$imap_stream = sqimap_create_stream($imapServerAddress, $imapPort, $use_imap_tls);
 if ($imap_stream) {
 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);
+    $body.= '  Capabilities: ';
+    if ($imap_capabilities = sqimap_capability($imap_stream)) {
+        foreach ($imap_capabilities as $capability => $value) {
+            $body.= $capability . (is_bool($value) ? ' ' : "=$value ");
+        }
+    }
+    $body.="\n";
+    sqimap_logout($imap_stream);
 } else {
     $body .= "  Unable to connect to IMAP server to get information.\n";
     $warning = 1;
 } else {
     $body .= "  Unable to connect to IMAP server to get information.\n";
     $warning = 1;
@@ -117,11 +170,9 @@ if (isset($warning) && $warning) {
             $warning_html .= "<dd>* $corr_val</dd>\n";
         }
     }
             $warning_html .= "<dd>* $corr_val</dd>\n";
         }
     }
-    $warning_html .= "</dl>\n<p>$warning_num warning(s) reported.</p>\n<hr>\n";
+    $warning_html .= "</dl>\n<p>$warning_num warning(s) reported.</p>\n<hr />\n";
     $body_top .= "\n$warning_num warning(s) reported.\n";
     $body_top .= "----------------------------------------------\n";
 }
 
 $body = htmlspecialchars($body_top . $body);
     $body_top .= "\n$warning_num warning(s) reported.\n";
     $body_top .= "----------------------------------------------\n";
 }
 
 $body = htmlspecialchars($body_top . $body);
-
-?>