/** * Autodetect API Connection Handler */ function oa_social_login_admin_autodetect_api_connection_handler() { //Check AJAX Nonce check_ajax_referer('oa_social_login_ajax_nonce'); //Check if CURL is available if (oa_social_login_check_curl_available()) { //Check CURL HTTPS - Port 443 if (oa_social_login_check_curl(true) === true) { echo 'success_autodetect_api_curl_https'; die; } elseif (oa_social_login_check_curl(false) === true) { echo 'success_autodetect_api_curl_http'; die; } else { echo 'error_autodetect_api_curl_ports_blocked'; die; } } elseif (oa_social_login_check_fsockopen_available()) { //Check FSOCKOPEN HTTPS - Port 443 if (oa_social_login_check_fsockopen(true) == true) { echo 'success_autodetect_api_fsockopen_https'; die; } elseif (oa_social_login_check_fsockopen(false) == true) { echo 'success_autodetect_api_fsockopen_http'; die; } else { echo 'error_autodetect_api_fsockopen_ports_blocked'; die; } } //No working handler found echo 'error_autodetect_api_no_handler'; die; }
/** * Check if CURL is available and can be used to connect to OneAll */ function oa_social_login_check_curl($secure = true) { if (oa_social_login_check_curl_available()) { $result = oa_social_login_curl_request(($secure ? 'https' : 'http') . '://www.oneall.com/ping.html'); if (is_object($result) and property_exists($result, 'http_code') and $result->http_code == 200) { if (property_exists($result, 'http_data')) { if (strtolower($result->http_data) == 'ok') { return true; } } } } return false; }