3 * Verify compatibility level of current php install with php-xmlrpc lib.
5 * @author Gaetano Giunta
6 * @copyright (C) 2006-2015 G. Giunta
7 * @license code licensed under the BSD License: see file license.txt
9 * @todo add a test for php output buffering?
12 function phpxmlrpc_verify_compat($mode = 'client')
16 if ($mode == 'server') {
17 // test for php version
19 $tests['php_version'] = array();
20 $tests['php_version']['description'] = 'PHP version found: ' . $ver . ".\n\n";
21 if (version_compare($ver, '5.3.0') < 0) {
22 $tests['php_version']['status'] = 0;
23 $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';
25 $tests['php_version']['status'] = 2;
26 $tests['php_version']['description'] .= 'This version of PHP is fully compatible with the PHP XMLRPC library';
30 $tests['zlib'] = array();
31 if (!function_exists('gzinflate')) {
32 $tests['zlib']['status'] = 0;
33 $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)";
35 $tests['zlib']['status'] = 2;
36 $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";
39 // test for dispaly of php errors in xml reponse
40 if (ini_get('display_errors')) {
41 if (intval(ini_get('error_reporting')) && E_NOTICE) {
42 $tests['display_errors']['status'] = 1;
43 $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";
45 $tests['display_errors']['status'] = 1;
46 $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";
51 // test for php version
53 $tests['php_version'] = array();
54 $tests['php_version']['description'] = 'PHP version found: ' . $ver . ".\n\n";
55 if (version_compare($ver, '5.3.0') < 0) {
56 $tests['php_version']['status'] = 0;
57 $tests['php_version']['description'] .= 'This version of PHP is not compatible with the PHP XMLRPC library. Please upgrade to 5.1.0 or later';
59 $tests['php_version']['status'] = 2;
60 $tests['php_version']['description'] .= 'This version of PHP is fully compatible with the PHP XMLRPC library';
64 $tests['zlib'] = array();
65 if (!function_exists('gzinflate')) {
66 $tests['zlib']['status'] = 0;
67 $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)";
69 $tests['zlib']['status'] = 2;
70 $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";
74 $tests['curl'] = array();
75 if (!extension_loaded('curl')) {
76 $tests['curl']['status'] = 0;
77 $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";
79 $info = curl_version();
80 $tests['curl']['status'] = 2;
81 $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";
82 if (version_compare($ver, '4.3.8') < 0) {
83 $tests['curl']['status'] = 1;
84 $tests['curl']['description'] .= ".\nPlease note that the current cURL install does not support keep-alives";
86 if (!((is_string($info) && strpos($info, 'zlib') !== null) || isset($info['libz_version']))) {
87 $tests['curl']['status'] = 1;
88 $tests['curl']['description'] .= ".\nPlease note that the current cURL install does not support compressed messages";
90 if (!((is_string($info) && strpos($info, 'OpenSSL') !== null) || isset($info['ssl_version']))) {
91 $tests['curl']['status'] = 1;
92 $tests['curl']['description'] .= ".\nPlease note that the current cURL install does not support HTTPS connections";
101 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
102 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
104 <title>PHP XMLRPC compatibility assessment</title>
105 <style type="text/css">
107 background-color: white;
108 font-family: Arial, Verdana, Geneva, sans-serif;
113 border: 1px solid gray;
118 background-color: silver;
128 border-top: 1px solid gray;
132 background-color: red;
134 border-right: 1px solid gray;
138 background-color: yellow;
140 border-right: 1px solid gray;
144 background-color: green;
146 border-right: 1px solid gray;
155 <h1>PHPXMLRPC compatibility assessment with the current PHP install</h1>
156 <h4>For phpxmlrpc version 4.0 or later</h4>
158 <h3>Server usage</h3>
159 <table cellspacing="0">
168 $res = phpxmlrpc_verify_compat('server');
169 foreach ($res as $test => $result) {
170 echo '<tr><td class="res' . $result['status'] . '">' . htmlspecialchars($test) . '</td><td class="result">' . htmlspecialchars($result['description']) . "</td></tr>\n";
175 <h3>Client usage</h3>
176 <table cellspacing="0">
185 $res = phpxmlrpc_verify_compat('client');
186 foreach ($res as $test => $result) {
187 echo '<tr><td class="res' . $result['status'] . '">' . htmlspecialchars($test) . '</td><td class="result">' . htmlspecialchars($result['description']) . "</td></tr>\n";