3 * Verify compatibility level of current php install with php-xmlrpc lib
6 * @author Gaetano Giunta
7 * @copyright (C) 2006-2008 G. Giunta
8 * @license code licensed under the BSD License: http://phpxmlrpc.sourceforge.net/license.txt
11 // be backward compat up to version 4.0.5...
12 if (!function_exists('version_compare'))
14 // give an opportunity to user to specify where to include other files from
15 if(!defined('PHP_XMLRPC_COMPAT_DIR'))
17 define('PHP_XMLRPC_COMPAT_DIR',dirname(__FILE__).'/compat/');
19 include(PHP_XMLRPC_COMPAT_DIR.'version_compare.php');
22 function phpxmlrpc_verify_compat($mode='client')
26 if ($mode == 'server')
28 // test for php version
30 $tests['php_version'] = array();
31 $tests['php_version']['description'] = 'PHP version found: '.$ver.".\n\n";
32 if (version_compare($ver, '4') < 0)
34 $tests['php_version']['status'] = 0;
35 $tests['php_version']['description'] .= 'This version of PHP is not compatible with the PHP XMLRPC library. Please upgrade to 4.2 or later';
37 else if (version_compare($ver, '4.2') < 0)
39 $tests['php_version']['status'] = 1;
40 $tests['php_version']['description'] .= "This version of PHP is partially compatible with the PHP XMLRPC library.\nIn order to use the library, you will need to make sure the files from the compat directory are available on your server";
42 else if (version_compare($ver, '5.0.3') < 0)
44 $tests['php_version']['status'] = 1;
45 $tests['php_version']['description'] .= "This version of PHP is almost completely compatible with the PHP XMLRPC library.\nThe only unavailable function is automatic mapping of php functions to xmlrpc methods";
49 $tests['php_version']['status'] = 2;
50 $tests['php_version']['description'] .= 'This version of PHP is fully compatible with the PHP XMLRPC library';
54 $tests['zlib'] = array();
55 if (!function_exists('gzinflate'))
57 $tests['zlib']['status'] = 0;
58 $tests['zlib']['description'] = "The zlib extension is not enabled.\n\nYou will not be able to receive compressed requests or send compressed responses, unless using the cURL library (for 'HTTPS' and 'HTTP 1.1' connections)";
62 $tests['zlib']['status'] = 2;
63 $tests['zlib']['description'] = "The zlib extension is enabled.\n\nYou will be able to receive compressed requests and send compressed responses for the 'HTTP' protocol";
66 // test for diaply of php errors in xml reponse
67 if (ini_get('display_errors'))
69 if (intval(ini_get('error_reporting')) && E_NOTICE )
71 $tests['display_errors']['status'] = 1;
72 $tests['display_errors']['description'] = "Error reporting level includes E_NOTICE errors, and display_errors is set to ON.\n\nAny error, warning or notice raised while executing php code exposed as xmlrpc method will result in an invalid xmlrpc response";
76 $tests['display_errors']['status'] = 1;
77 $tests['display_errors']['description'] = "display_errors is set to ON.\n\nAny error raised while executing php code exposed as xmlrpc method will result in an invalid xmlrpc response";
85 // test for php version
87 $tests['php_version'] = array();
88 $tests['php_version']['description'] = 'PHP version found: '.$ver.".\n\n";
89 if (version_compare($ver, '4') < 0)
91 $tests['php_version']['status'] = 0;
92 $tests['php_version']['description'] .= 'This version of PHP is not compatible with the PHP XMLRPC library. Please upgrade to 4.2 or later';
94 else if (version_compare($ver, '4.2') < 0)
96 $tests['php_version']['status'] = 1;
97 $tests['php_version']['description'] .= "This version of PHP is partially compatible with the PHP XMLRPC library.\nIn order to use the library, you will need to make sure the files from the compat directory are available on your server";
101 $tests['php_version']['status'] = 2;
102 $tests['php_version']['description'] .= 'This version of PHP is fully compatible with the PHP XMLRPC library';
106 $tests['zlib'] = array();
107 if (!function_exists('gzinflate'))
109 $tests['zlib']['status'] = 0;
110 $tests['zlib']['description'] = "The zlib extension is not enabled.\n\nYou will not be able to send compressed requests or receive compressed responses, unless using the cURL library (for 'HTTPS' and 'HTTP 1.1' connections)";
114 $tests['zlib']['status'] = 2;
115 $tests['zlib']['description'] = "The zlib extension is enabled.\n\nYou will be able to send compressed requests and receive compressed responses for the 'HTTP' protocol";
119 $tests['curl'] = array();
120 if (!extension_loaded('curl'))
122 $tests['curl']['status'] = 0;
123 $tests['curl']['description'] = "The cURL extension is not enabled.\n\nYou will not be able to send and receive messages using 'HTTPS' and 'HTTP 1.1' protocols";
127 $info = curl_version();
128 $tests['curl']['status'] = 2;
129 $tests['curl']['description'] = "The cURL extension is enabled.\n\nYou will be able to send and receive messages using 'HTTPS' and 'HTTP 1.1' protocols";
130 if (version_compare($ver, '4.3.8') < 0)
132 $tests['curl']['status'] = 1;
133 $tests['curl']['description'] .= ".\nPlease note that the current cURL install does not support keep-alives";
135 if (!((is_string($info) && strpos($info, 'zlib') !== null) || isset($info['libz_version'])))
137 $tests['curl']['status'] = 1;
138 $tests['curl']['description'] .= ".\nPlease note that the current cURL install does not support compressed messages";
140 if (!((is_string($info) && strpos($info, 'OpenSSL') !== null) || isset($info['ssl_version'])))
142 $tests['curl']['status'] = 1;
143 $tests['curl']['description'] .= ".\nPlease note that the current cURL install does not support HTTPS connections";
152 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
153 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
155 <title>PHP XMLRPC compatibility assessment</title>
156 <style type="text/css">
157 body, html {background-color: white; font-family: Arial, Verdana, Geneva, sans-serif; font-size: small; }
158 table { border: 1px solid gray; padding: 0;}
159 thead { background-color: silver; color: black; }
160 td { margin: 0; padding: 0.5em; }
161 tbody td { border-top: 1px solid gray; }
162 .res0 { background-color: red; color: black; border-right: 1px solid gray; }
163 .res1 { background-color: yellow; color: black; border-right: 1px solid gray; }
164 .res2 { background-color: green; color: black; border-right: 1px solid gray; }
165 .result { white-space: pre; }
169 <h1>PHPXMLRPC compatibility assessment with the current PHP install</h1>
170 <h4>For phpxmlrpc version 2.0 or later</h4>
171 <h3>Server usage</h3>
172 <table cellspacing="0">
174 <tr><td>Test</td><td>Result</td></tr>
178 $res = phpxmlrpc_verify_compat('server');
179 foreach($res as $test => $result)
181 echo '<tr><td class="res'.$result['status'].'">'.htmlspecialchars($test).'</td><td class="result">'.htmlspecialchars($result['description'])."</td></tr>\n";
186 <h3>Client usage</h3>
187 <table cellspacing="0">
189 <tr><td>Test</td><td>Result</td></tr>
193 $res = phpxmlrpc_verify_compat('client');
194 foreach($res as $test => $result)
196 echo '<tr><td class="res'.$result['status'].'">'.htmlspecialchars($test).'</td><td class="result">'.htmlspecialchars($result['description'])."</td></tr>\n";