3 * Verify compatibility level of current php install with php-xmlrpc lib
5 * @author Gaetano Giunta
6 * @copyright (C) 2006-2014 G. Giunta
7 * @license code licensed under the BSD License: http://phpxmlrpc.sourceforge.net/license.txt
9 * @todo add a test for php output buffering?
12 function phpxmlrpc_verify_compat($mode='client')
16 if ($mode == 'server')
18 // test for php version
20 $tests['php_version'] = array();
21 $tests['php_version']['description'] = 'PHP version found: '.$ver.".\n\n";
22 if (version_compare($ver, '5.1.0') < 0)
24 $tests['php_version']['status'] = 0;
25 $tests['php_version']['description'] .= 'This version of PHP is not compatible with this release of the PHP XMLRPC library. Please upgrade to php 5.1.0 or later';
29 $tests['php_version']['status'] = 2;
30 $tests['php_version']['description'] .= 'This version of PHP is fully compatible with the PHP XMLRPC library';
34 $tests['zlib'] = array();
35 if (!function_exists('gzinflate'))
37 $tests['zlib']['status'] = 0;
38 $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)";
42 $tests['zlib']['status'] = 2;
43 $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";
46 // test for dispaly of php errors in xml reponse
47 if (ini_get('display_errors'))
49 if (intval(ini_get('error_reporting')) && E_NOTICE )
51 $tests['display_errors']['status'] = 1;
52 $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";
56 $tests['display_errors']['status'] = 1;
57 $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";
65 // test for php version
67 $tests['php_version'] = array();
68 $tests['php_version']['description'] = 'PHP version found: '.$ver.".\n\n";
69 if (version_compare($ver, '5.1.0') < 0)
71 $tests['php_version']['status'] = 0;
72 $tests['php_version']['description'] .= 'This version of PHP is not compatible with the PHP XMLRPC library. Please upgrade to 5.1.0 or later';
76 $tests['php_version']['status'] = 2;
77 $tests['php_version']['description'] .= 'This version of PHP is fully compatible with the PHP XMLRPC library';
81 $tests['zlib'] = array();
82 if (!function_exists('gzinflate'))
84 $tests['zlib']['status'] = 0;
85 $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)";
89 $tests['zlib']['status'] = 2;
90 $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";
94 $tests['curl'] = array();
95 if (!extension_loaded('curl'))
97 $tests['curl']['status'] = 0;
98 $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";
102 $info = curl_version();
103 $tests['curl']['status'] = 2;
104 $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";
105 if (version_compare($ver, '4.3.8') < 0)
107 $tests['curl']['status'] = 1;
108 $tests['curl']['description'] .= ".\nPlease note that the current cURL install does not support keep-alives";
110 if (!((is_string($info) && strpos($info, 'zlib') !== null) || isset($info['libz_version'])))
112 $tests['curl']['status'] = 1;
113 $tests['curl']['description'] .= ".\nPlease note that the current cURL install does not support compressed messages";
115 if (!((is_string($info) && strpos($info, 'OpenSSL') !== null) || isset($info['ssl_version'])))
117 $tests['curl']['status'] = 1;
118 $tests['curl']['description'] .= ".\nPlease note that the current cURL install does not support HTTPS connections";
127 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
128 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
130 <title>PHP XMLRPC compatibility assessment</title>
131 <style type="text/css">
132 body, html {background-color: white; font-family: Arial, Verdana, Geneva, sans-serif; font-size: small; }
133 table { border: 1px solid gray; padding: 0;}
134 thead { background-color: silver; color: black; }
135 td { margin: 0; padding: 0.5em; }
136 tbody td { border-top: 1px solid gray; }
137 .res0 { background-color: red; color: black; border-right: 1px solid gray; }
138 .res1 { background-color: yellow; color: black; border-right: 1px solid gray; }
139 .res2 { background-color: green; color: black; border-right: 1px solid gray; }
140 .result { white-space: pre; }
144 <h1>PHPXMLRPC compatibility assessment with the current PHP install</h1>
145 <h4>For phpxmlrpc version 3.0 or later</h4>
146 <h3>Server usage</h3>
147 <table cellspacing="0">
149 <tr><td>Test</td><td>Result</td></tr>
153 $res = phpxmlrpc_verify_compat('server');
154 foreach($res as $test => $result)
156 echo '<tr><td class="res'.$result['status'].'">'.htmlspecialchars($test).'</td><td class="result">'.htmlspecialchars($result['description'])."</td></tr>\n";
161 <h3>Client usage</h3>
162 <table cellspacing="0">
164 <tr><td>Test</td><td>Result</td></tr>
168 $res = phpxmlrpc_verify_compat('client');
169 foreach($res as $test => $result)
171 echo '<tr><td class="res'.$result['status'].'">'.htmlspecialchars($test).'</td><td class="result">'.htmlspecialchars($result['description'])."</td></tr>\n";