3 * Verify compatibility level of current php install with php-xmlrpc lib
5 * @author Gaetano Giunta
6 * @copyright (C) 2006-2013 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') < 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 or later';
27 else if (version_compare($ver, '5.0.3') < 0)
29 $tests['php_version']['status'] = 1;
30 $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";
34 $tests['php_version']['status'] = 2;
35 $tests['php_version']['description'] .= 'This version of PHP is fully compatible with the PHP XMLRPC library';
39 $tests['zlib'] = array();
40 if (!function_exists('gzinflate'))
42 $tests['zlib']['status'] = 0;
43 $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)";
47 $tests['zlib']['status'] = 2;
48 $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";
51 // test for dispaly of php errors in xml reponse
52 if (ini_get('display_errors'))
54 if (intval(ini_get('error_reporting')) && E_NOTICE )
56 $tests['display_errors']['status'] = 1;
57 $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";
61 $tests['display_errors']['status'] = 1;
62 $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";
70 // test for php version
72 $tests['php_version'] = array();
73 $tests['php_version']['description'] = 'PHP version found: '.$ver.".\n\n";
74 if (version_compare($ver, '5') < 0)
76 $tests['php_version']['status'] = 0;
77 $tests['php_version']['description'] .= 'This version of PHP is not compatible with the PHP XMLRPC library. Please upgrade to 5.0 or later';
81 $tests['php_version']['status'] = 2;
82 $tests['php_version']['description'] .= 'This version of PHP is fully compatible with the PHP XMLRPC library';
86 $tests['zlib'] = array();
87 if (!function_exists('gzinflate'))
89 $tests['zlib']['status'] = 0;
90 $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)";
94 $tests['zlib']['status'] = 2;
95 $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";
99 $tests['curl'] = array();
100 if (!extension_loaded('curl'))
102 $tests['curl']['status'] = 0;
103 $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";
107 $info = curl_version();
108 $tests['curl']['status'] = 2;
109 $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";
110 if (version_compare($ver, '4.3.8') < 0)
112 $tests['curl']['status'] = 1;
113 $tests['curl']['description'] .= ".\nPlease note that the current cURL install does not support keep-alives";
115 if (!((is_string($info) && strpos($info, 'zlib') !== null) || isset($info['libz_version'])))
117 $tests['curl']['status'] = 1;
118 $tests['curl']['description'] .= ".\nPlease note that the current cURL install does not support compressed messages";
120 if (!((is_string($info) && strpos($info, 'OpenSSL') !== null) || isset($info['ssl_version'])))
122 $tests['curl']['status'] = 1;
123 $tests['curl']['description'] .= ".\nPlease note that the current cURL install does not support HTTPS connections";
132 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
133 <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
135 <title>PHP XMLRPC compatibility assessment</title>
136 <style type="text/css">
137 body, html {background-color: white; font-family: Arial, Verdana, Geneva, sans-serif; font-size: small; }
138 table { border: 1px solid gray; padding: 0;}
139 thead { background-color: silver; color: black; }
140 td { margin: 0; padding: 0.5em; }
141 tbody td { border-top: 1px solid gray; }
142 .res0 { background-color: red; color: black; border-right: 1px solid gray; }
143 .res1 { background-color: yellow; color: black; border-right: 1px solid gray; }
144 .res2 { background-color: green; color: black; border-right: 1px solid gray; }
145 .result { white-space: pre; }
149 <h1>PHPXMLRPC compatibility assessment with the current PHP install</h1>
150 <h4>For phpxmlrpc version 3.0 or later</h4>
151 <h3>Server usage</h3>
152 <table cellspacing="0">
154 <tr><td>Test</td><td>Result</td></tr>
158 $res = phpxmlrpc_verify_compat('server');
159 foreach($res as $test => $result)
161 echo '<tr><td class="res'.$result['status'].'">'.htmlspecialchars($test).'</td><td class="result">'.htmlspecialchars($result['description'])."</td></tr>\n";
166 <h3>Client usage</h3>
167 <table cellspacing="0">
169 <tr><td>Test</td><td>Result</td></tr>
173 $res = phpxmlrpc_verify_compat('client');
174 foreach($res as $test => $result)
176 echo '<tr><td class="res'.$result['status'].'">'.htmlspecialchars($test).'</td><td class="result">'.htmlspecialchars($result['description'])."</td></tr>\n";