From 172f4d80fe46939683acc596856f64fe0eeea9f5 Mon Sep 17 00:00:00 2001 From: Tom Slominski Date: Sat, 15 Apr 2017 20:42:25 +0100 Subject: [PATCH] Improve file_get_contents(). Fixes #38. --- result.php | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/result.php b/result.php index aa834c8..1233799 100644 --- a/result.php +++ b/result.php @@ -18,6 +18,21 @@ function display_error( $message, $action = null ) { 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'] ) ) { 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' ) { // 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); // What happens when the reCAPTCHA was completed incorrectly @@ -131,7 +146,7 @@ $dependencies[] = 'clipboard.js'; - +
@@ -162,19 +177,19 @@ $dependencies[] = 'clipboard.js'; if ( ISQ::$social['tumblr'] ) { echo ''; } - if ( ISQ::$social['linkedin'] ) { echo ''; } + if ( ISQ::$social['linkedin'] ) { echo ''; } if ( ISQ::$social['googleplus'] ) { echo ''; } - + if ( ISQ::$social['vk'] ) { echo ''; } - ?> + ?>

- +