get_client_version() public static method

public static get_client_version ( $client )
Example #1
0
 public function process()
 {
     global $wp_version;
     $mysql_vars = array('key_buffer_size' => true, 'max_allowed_packet' => false, 'max_connections' => false, 'query_cache_limit' => true, 'query_cache_size' => true, 'query_cache_type' => 'ON');
     if ($dbq = QM_Collectors::get('db_queries')) {
         foreach ($dbq->db_objects as $id => $db) {
             $variables = $db->get_results("\n\t\t\t\t\tSHOW VARIABLES\n\t\t\t\t\tWHERE Variable_name IN ( '" . implode("', '", array_keys($mysql_vars)) . "' )\n\t\t\t\t");
             if (is_resource($db->dbh)) {
                 # Old mysql extension
                 $extension = 'mysql';
             } else {
                 if (is_object($db->dbh)) {
                     # mysqli or PDO
                     $extension = get_class($db->dbh);
                 } else {
                     # Who knows?
                     $extension = null;
                 }
             }
             if (method_exists($db, 'db_version')) {
                 $server = $db->db_version();
             } else {
                 $server = null;
             }
             if (isset($db->use_mysqli) && $db->use_mysqli) {
                 $client = mysqli_get_client_version();
             } else {
                 if (preg_match('|[0-9]{1,2}\\.[0-9]{1,2}\\.[0-9]{1,2}|', mysql_get_client_info(), $matches)) {
                     $client = $matches[0];
                 } else {
                     $client = null;
                 }
             }
             if ($client) {
                 $client_version = implode('.', QM_Util::get_client_version($client));
                 $client_version = sprintf('%s (%s)', $client, $client_version);
             } else {
                 $client_version = null;
             }
             $info = array('extension' => $extension, 'server version' => $server, 'client version' => $client_version, 'user' => $db->dbuser, 'host' => $db->dbhost, 'database' => $db->dbname);
             $this->data['db'][$id] = array('info' => $info, 'vars' => $mysql_vars, 'variables' => $variables);
         }
     }
     $this->data['php']['version'] = phpversion();
     $this->data['php']['sapi'] = php_sapi_name();
     $this->data['php']['user'] = self::get_current_user();
     if (defined('HHVM_VERSION')) {
         $this->data['php']['hhvm'] = HHVM_VERSION;
     }
     foreach ($this->php_vars as $setting) {
         $this->data['php']['variables'][$setting]['after'] = ini_get($setting);
     }
     $this->data['php']['error_reporting'] = error_reporting();
     $this->data['wp'] = array('version' => $wp_version, 'WP_DEBUG' => self::format_bool_constant('WP_DEBUG'), 'WP_DEBUG_DISPLAY' => self::format_bool_constant('WP_DEBUG_DISPLAY'), 'WP_DEBUG_LOG' => self::format_bool_constant('WP_DEBUG_LOG'), 'SCRIPT_DEBUG' => self::format_bool_constant('SCRIPT_DEBUG'), 'WP_CACHE' => self::format_bool_constant('WP_CACHE'), 'CONCATENATE_SCRIPTS' => self::format_bool_constant('CONCATENATE_SCRIPTS'), 'COMPRESS_SCRIPTS' => self::format_bool_constant('COMPRESS_SCRIPTS'), 'COMPRESS_CSS' => self::format_bool_constant('COMPRESS_CSS'), 'WP_LOCAL_DEV' => self::format_bool_constant('WP_LOCAL_DEV'));
     if (is_multisite()) {
         $this->data['wp']['SUNRISE'] = self::format_bool_constant('SUNRISE');
     }
     $server = explode(' ', $_SERVER['SERVER_SOFTWARE']);
     $server = explode('/', reset($server));
     if (isset($server[1])) {
         $server_version = $server[1];
     } else {
         $server_version = null;
     }
     if (isset($_SERVER['SERVER_ADDR'])) {
         $address = $_SERVER['SERVER_ADDR'];
     } else {
         $address = null;
     }
     $this->data['server'] = array('name' => $server[0], 'version' => $server_version, 'address' => $address, 'host' => php_uname('n'));
 }
 /**
  * @dataProvider clientVersionData
  *
  */
 public function testClientVersion($client, $expected)
 {
     $ver = QM_Util::get_client_version($client);
     $this->assertEquals($expected, array_values($ver));
 }