Skip to content

Commit 9c38604

Browse files
committed
Check for existence of all functions in cURL test script, not just curl_init()
1 parent d6e7ea8 commit 9c38604

File tree

1 file changed

+32
-6
lines changed

1 file changed

+32
-6
lines changed

lkt-curl-functionality-checker.php

+32-6
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,42 @@
2727
echo 'PASS'.PHP_EOL.PHP_EOL;
2828
} else {
2929
echo 'FAIL'.PHP_EOL.PHP_EOL;
30-
echo get_limited_func_str(true).PHP_EOL;
30+
echo get_limited_func_str('installed');
3131
exit;
3232
}
3333

34-
echo 'Checking for the existence of the curl_init() function...';
35-
if (function_exists('curl_init')) {
34+
echo 'Checking for the existence of all required cURL functions...';
35+
$funcs = array(
36+
'curl_init',
37+
'curl_setopt_array',
38+
'curl_exec',
39+
'curl_getinfo',
40+
'curl_multi_init',
41+
'curl_multi_add_handle',
42+
'curl_multi_exec',
43+
'curl_multi_select',
44+
'curl_multi_getcontent',
45+
'curl_multi_remove_handle',
46+
'curl_close',
47+
);
48+
$funcs_exist = array();
49+
$funcs_not_exist = array();
50+
foreach ($funcs as $func) {
51+
if (function_exists($func)) {
52+
$funcs_exist[] = $func;
53+
} else $funcs_not_exist[] = $func;
54+
}
55+
if (!$funcs_not_exist) {
3656
echo 'PASS'.PHP_EOL.PHP_EOL;
3757
} else {
3858
echo 'FAIL'.PHP_EOL.PHP_EOL;
39-
echo get_limited_func_str(true).PHP_EOL;
59+
echo 'Link Tools functionality will be limited because not all of the required functions from the Client URL Library (cURL) are available.'.PHP_EOL.PHP_EOL;
60+
if ($funcs_exist) {
61+
echo 'The following cURL functions are available: '.implode('(), ', $funcs_exist).'().'.PHP_EOL.PHP_EOL;
62+
}
63+
echo 'The following cURL functions are not available: '.implode('(), ', $funcs_not_exist).'().'.PHP_EOL.PHP_EOL;
64+
echo 'Probably, these unavailable functions have been disabled by your host, in which case, you could contact your host to have them enabled if possible.'.PHP_EOL.PHP_EOL;
65+
echo 'For more details on the cURL library, please see here: <https://www.php.net/manual/en/book.curl.php>.';
4066
exit;
4167
}
4268

@@ -208,6 +234,6 @@ function do_failure($ch, $err_msgs) {
208234
echo 'The curl_error() function reports: '.curl_error($ch).PHP_EOL.PHP_EOL;
209235
}
210236

211-
function get_limited_func_str($for_not_installed = false) {
212-
return 'Link Tools functionality will be limited because the Client URL Library (cURL) does not appear to be '.($for_not_installed ? 'installed' : 'functioning correctly').'. For more details on this library, please see here: <https://www.php.net/manual/en/book.curl.php>.'.PHP_EOL;
237+
function get_limited_func_str($error_wording = 'functioning correctly') {
238+
return 'Link Tools functionality will be limited because the Client URL Library (cURL) does not appear to be '.$error_wording.'. For more details on this library, please see here: <https://www.php.net/manual/en/book.curl.php>.'.PHP_EOL;
213239
}

0 commit comments

Comments
 (0)