3 * Verify compatibility level of current php install with php-xmlrpc lib
6 * @author Gaetano Giunta
7 * @copyright (C) 2006-2009 G. Giunta
8 * @license code licensed under the BSD License: http://phpxmlrpc.sourceforge.net/license.txt
10 * @todo add a test for php output buffering?
13 function phpxmlrpc_verify_compat($mode='client')
17 if ($mode == 'server')
19 // test for php version
21 $tests['php_version'] = array();
22 $tests['php_version']['description'] = 'PHP version found: '.$ver.".\n\n";
23 if (version_compare($ver, '5') < 0)
25 $tests['php_version']['status'] = 0;
26 $tests['php_version']['description'] .= 'This version of PHP is not compatible with this release of the PHP XMLRPC library. Please upgrade to php 5 or later';
28 else if (version_compare($ver, '5.0.3') < 0)
30 $tests['php_version']['status'] = 1;
31 $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";
35 $tests['php_version']['status'] = 2;
36 $tests['php_version']['description'] .= 'This version of PHP is fully compatible with the PHP XMLRPC library';
40 $tests['zlib'] = array();
41 if (!function_exists('gzinflate'))
43 $tests['zlib']['status'] = 0;
44 $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)";
48 $tests['zlib']['status'] = 2;
49 $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";
52 // test for dispaly of php errors in xml reponse
53 if (ini_get('display_errors'))
55 if (intval(ini_get('error_reporting')) && E_NOTICE )
57 $tests['display_errors']['status'] = 1;
58 $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";
62 $tests['display_errors']['status'] = 1;
63 $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";
71 // test for php version
73 $tests['php_version'] = array();
74 $tests['php_version']['description'] = 'PHP version found: '.$ver.".\n\n";
75 if (version_compare($ver, '5') < 0)
77 $tests['php_version']['status'] = 0;
78 $tests['php_version']['description'] .= 'This version of PHP is not compatible with the PHP XMLRPC library. Please upgrade to 5.0 or later';
82 $tests['php_version']['status'] = 2;
83 $tests['php_version']['description'] .= 'This version of PHP is fully compatible with the PHP XMLRPC library';
87 $tests['zlib'] = array();
88 if (!function_exists('gzinflate'))
90 $tests['zlib']['status'] = 0;
91 $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)";
95 $tests['zlib']['status'] = 2;
96 $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";
100 $tests['curl'] = array();
101 if (!extension_loaded('curl'))
103 $tests['curl']['status'] = 0;
104 $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";
108 $info = curl_version();
109 $tests['curl']['status'] = 2;
110 $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";
111 if (version_compare($ver, '4.3.8') < 0)
113 $tests['curl']['status'] = 1;
114 $tests['curl']['description'] .= ".\nPlease note that the current cURL install does not support keep-alives";
116 if (!((is_string($info) && strpos($info, 'zlib') !== null) || isset($info['libz_version'])))
118 $tests['curl']['status'] = 1;
119 $tests['curl']['description'] .= ".\nPlease note that the current cURL install does not support compressed messages";
121 if (!((is_string($info) && strpos($info, 'OpenSSL') !== null) || isset($info['ssl_version'])))
123 $tests['curl']['status'] = 1;
124 $tests['curl']['description'] .= ".\nPlease note that the current cURL install does not support HTTPS connections";
133 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
134 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
136 <title>PHP XMLRPC compatibility assessment</title>
137 <style type="text/css">
138 body, html {background-color: white; font-family: Arial, Verdana, Geneva, sans-serif; font-size: small; }
139 table { border: 1px solid gray; padding: 0;}
140 thead { background-color: silver; color: black; }
141 td { margin: 0; padding: 0.5em; }
142 tbody td { border-top: 1px solid gray; }
143 .res0 { background-color: red; color: black; border-right: 1px solid gray; }
144 .res1 { background-color: yellow; color: black; border-right: 1px solid gray; }
145 .res2 { background-color: green; color: black; border-right: 1px solid gray; }
146 .result { white-space: pre; }
150 <h1>PHPXMLRPC compatibility assessment with the current PHP install</h1>
151 <h4>For phpxmlrpc version 3.0 or later</h4>
152 <h3>Server usage</h3>
153 <table cellspacing="0">
155 <tr><td>Test</td><td>Result</td></tr>
159 $res = phpxmlrpc_verify_compat('server');
160 foreach($res as $test => $result)
162 echo '<tr><td class="res'.$result['status'].'">'.htmlspecialchars($test).'</td><td class="result">'.htmlspecialchars($result['description'])."</td></tr>\n";
167 <h3>Client usage</h3>
168 <table cellspacing="0">
170 <tr><td>Test</td><td>Result</td></tr>
174 $res = phpxmlrpc_verify_compat('client');
175 foreach($res as $test => $result)
177 echo '<tr><td class="res'.$result['status'].'">'.htmlspecialchars($test).'</td><td class="result">'.htmlspecialchars($result['description'])."</td></tr>\n";