verify_compat.php
7.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
<?php
/**
* Verify compatibility level of current php install with php-xmlrpc lib
*
* @version $Id: verify_compat.php,v 1.4 2006/08/07 15:42:35 ggiunta Exp $
* @copyright G. Giunta (C) 2006
* @author Gaetano Giunta
*/
// be backward compat up to version 4.0.5...
if (!function_exists('version_compare'))
{
// give an opportunity to user to specify where to include other files from
if(!defined('PHP_XMLRPC_COMPAT_DIR'))
{
define('PHP_XMLRPC_COMPAT_DIR',dirname(__FILE__).'/compat/');
}
include(PHP_XMLRPC_COMPAT_DIR.'version_compare.php');
}
function phpxmlrpc_verify_compat($mode='client')
{
$tests = array();
if ($mode == 'server')
{
// test for php version
$ver = phpversion();
$tests['php_version'] = array();
$tests['php_version']['description'] = 'PHP version found: '.$ver.".\n\n";
if (version_compare($ver, '4') < 0)
{
$tests['php_version']['status'] = 0;
$tests['php_version']['description'] .= 'This version of PHP is not compatible with the PHP XMLRPC library. Please upgrade to 4.2 or later';
}
else if (version_compare($ver, '4.2') < 0)
{
$tests['php_version']['status'] = 1;
$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";
}
else if (version_compare($ver, '5.0.3') < 0)
{
$tests['php_version']['status'] = 1;
$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";
}
else
{
$tests['php_version']['status'] = 2;
$tests['php_version']['description'] .= 'This version of PHP is fully compatible with the PHP XMLRPC library';
}
// test for zlib
$tests['zlib'] = array();
if (!function_exists('gzinflate'))
{
$tests['zlib']['status'] = 0;
$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)";
}
else
{
$tests['zlib']['status'] = 2;
$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";
}
// test for diaply of php errors in xml reponse
if (ini_get('display_errors'))
{
if (intval(ini_get('error_reporting')) && E_NOTICE )
{
$tests['display_errors']['status'] = 1;
$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";
}
else
{
$tests['display_errors']['status'] = 1;
$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";
}
}
}
else
{
// test for php version
$ver = phpversion();
$tests['php_version'] = array();
$tests['php_version']['description'] = 'PHP version found: '.$ver.".\n\n";
if (version_compare($ver, '4') < 0)
{
$tests['php_version']['status'] = 0;
$tests['php_version']['description'] .= 'This version of PHP is not compatible with the PHP XMLRPC library. Please upgrade to 4.2 or later';
}
else if (version_compare($ver, '4.2') < 0)
{
$tests['php_version']['status'] = 1;
$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";
}
else
{
$tests['php_version']['status'] = 2;
$tests['php_version']['description'] .= 'This version of PHP is fully compatible with the PHP XMLRPC library';
}
// test for zlib
$tests['zlib'] = array();
if (!function_exists('gzinflate'))
{
$tests['zlib']['status'] = 0;
$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)";
}
else
{
$tests['zlib']['status'] = 2;
$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";
}
// test for CURL
$tests['curl'] = array();
if (!extension_loaded('curl'))
{
$tests['curl']['status'] = 0;
$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";
}
else
{
$info = curl_version();
$tests['curl']['status'] = 2;
$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";
if (version_compare($ver, '4.3.8') < 0)
{
$tests['curl']['status'] = 1;
$tests['curl']['description'] .= ".\nPlease note that the current cURL install does not support keep-alives";
}
if (!((is_string($info) && strpos($info, 'zlib') !== null) || isset($info['libz_version'])))
{
$tests['curl']['status'] = 1;
$tests['curl']['description'] .= ".\nPlease note that the current cURL install does not support compressed messages";
}
if (!((is_string($info) && strpos($info, 'OpenSSL') !== null) || isset($info['ssl_version'])))
{
$tests['curl']['status'] = 1;
$tests['curl']['description'] .= ".\nPlease note that the current cURL install does not support HTTPS connections";
}
}
}
return $tests;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title>PHP XMLRPC compatibility assessment</title>
<style type="text/css">
body, html {background-color: white; font-family: Arial, Verdana, Geneva, sans-serif; font-size: small; }
table { border: 1px solid gray; padding: 0;}
thead { background-color: silver; color: black; }
td { margin: 0; padding: 0.5em; }
tbody td { border-top: 1px solid gray; }
.res0 { background-color: red; color: black; border-right: 1px solid gray; }
.res1 { background-color: yellow; color: black; border-right: 1px solid gray; }
.res2 { background-color: green; color: black; border-right: 1px solid gray; }
.result { white-space: pre; }
</style>
</head>
<body>
<h1>PHPXMLRPC compatibility assessment with the current PHP install</h1>
<h4>For phpxmlrpc version 2.0 or later</h4>
<h3>Server usage</h3>
<table cellspacing="0">
<thead>
<tr><td>Test</td><td>Result</td></tr>
</thead>
<tbody>
<?php
$res = phpxmlrpc_verify_compat('server');
foreach($res as $test => $result)
{
echo '<tr><td class="res'.$result['status'].'">'.htmlspecialchars($test).'</td><td class="result">'.htmlspecialchars($result['description'])."</td></tr>\n";
}
?>
</tbody>
</table>
<h3>Client usage</h3>
<table cellspacing="0">
<thead>
<tr><td>Test</td><td>Result</td></tr>
</thead>
<tbody>
<?php
$res = phpxmlrpc_verify_compat('client');
foreach($res as $test => $result)
{
echo '<tr><td class="res'.$result['status'].'">'.htmlspecialchars($test).'</td><td class="result">'.htmlspecialchars($result['description'])."</td></tr>\n";
}
?>
</tbody>
</table>
</body>
</html>