Improve file_get_contents(). Fixes #38.
This commit is contained in:
17
result.php
17
result.php
@@ -18,6 +18,21 @@ function display_error( $message, $action = null ) {
|
|||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function get_remote_file( $url ) {
|
||||||
|
if( function_exists( 'curl_init' ) ) {
|
||||||
|
$curl = curl_init();
|
||||||
|
curl_setopt( $curl, CURLOPT_URL, $url );
|
||||||
|
curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true );
|
||||||
|
$output = curl_exec( $curl );
|
||||||
|
curl_close( $curl );
|
||||||
|
return $output;
|
||||||
|
} elseif( ini_get( 'allow_url_fopen' ) ) {
|
||||||
|
return file_get_contents( $url );
|
||||||
|
} else {
|
||||||
|
display_error( yourls__( 'Your server doesn\'t support reCAPTCHA. Ask your host to install cURL or turn on allow_url_fopen.', 'isq_translation' ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( empty( $_REQUEST['url'] ) ) {
|
if ( empty( $_REQUEST['url'] ) ) {
|
||||||
display_error( yourls__( 'You haven\'t entered a URL to shorten.', 'isq_translation' ) );
|
display_error( yourls__( 'You haven\'t entered a URL to shorten.', 'isq_translation' ) );
|
||||||
};
|
};
|
||||||
@@ -42,7 +57,7 @@ if ( $antispam_method == 'user_login' ) {
|
|||||||
} else if ( $antispam_method == 'recaptcha' ) {
|
} else if ( $antispam_method == 'recaptcha' ) {
|
||||||
|
|
||||||
// Google reCAPTCHA is enabled
|
// Google reCAPTCHA is enabled
|
||||||
$recaptcha_data = file_get_contents('https://www.google.com/recaptcha/api/siteverify?secret=' . ISQ::$recaptcha['secret'] . '&response=' . $_REQUEST['g-recaptcha-response']);
|
$recaptcha_data = get_remote_file('https://www.google.com/recaptcha/api/siteverify?secret=' . ISQ::$recaptcha['secret'] . '&response=' . $_REQUEST['g-recaptcha-response']);
|
||||||
$recaptcha_json = json_decode($recaptcha_data, TRUE);
|
$recaptcha_json = json_decode($recaptcha_data, TRUE);
|
||||||
|
|
||||||
// What happens when the reCAPTCHA was completed incorrectly
|
// What happens when the reCAPTCHA was completed incorrectly
|
||||||
|
|||||||
Reference in New Issue
Block a user