Changeset 2752267
- Timestamp:
- 07/05/2022 10:07:51 PM (4 years ago)
- File:
-
- 1 edited
-
linkworth-wp-plugin/trunk/LinkWorth_WordPress.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
linkworth-wp-plugin/trunk/LinkWorth_WordPress.php
r2750802 r2752267 308 308 } 309 309 310 function get_contents( $url ) 311 { 312 global $lw_debug_information; 313 314 $lw_debug_information .= 'get_contents() running - '.$url.'++'; 315 316 if( !empty( $url ) ) 317 { 318 $curl_handle = curl_init(); 319 curl_setopt( $curl_handle, CURLOPT_URL, $url ); 320 curl_setopt( $curl_handle, CURLOPT_CONNECTTIMEOUT, 30 ); 321 curl_setopt( $curl_handle, CURLOPT_RETURNTRANSFER, true ); 322 323 if( @ini_get('open_basedir') == '' && @ini_get('safe_mode') == 'Off' ) 324 { 325 curl_setopt( $curl_handle, CURLOPT_FOLLOWLOCATION, true ); 326 curl_setopt( $curl_handle, CURLOPT_MAXREDIRS, 2 ); 327 } 328 329 if( curl_exec( $curl_handle ) === false ) 330 { 331 $curl_error = 'Curl error: ' . curl_error( $curl_handle ); 332 } 333 334 $string = curl_exec( $curl_handle ); 335 curl_close( $curl_handle ); 336 } 337 338 if( isset( $_GET['debug'] ) ) 339 { 340 if( !empty( $curl_error ) ) 341 { 342 $lw_debug_information .= $curl_error.'++'; 343 } 344 345 if( empty( $string ) ) 346 { 347 $lw_debug_information .= 'get_contents() empty++'; 348 } 349 } 350 351 return $string; 352 } 310 function get_contents($url) 311 { 312 global $lw_debug_information; 313 314 $string = ''; 315 $wp_remote_get_error = ''; 316 317 $lw_debug_information .= 'get_contents() running - '.$url.'++'; 318 319 if (!empty($url)) { 320 321 $response = wp_remote_get($url); 322 $http_code = wp_remote_retrieve_response_code($response); 323 324 if ($http_code == '200') { 325 326 $string = wp_remote_retrieve_body($response); 327 328 } else { 329 330 $wp_remote_get_error = 'get_contents() error: ' . wp_remote_retrieve_header($response, 'status'); 331 } 332 } 333 334 if (isset($_GET['debug'])) { 335 336 if (!empty($wp_remote_get_error)) { 337 338 $lw_debug_information .= $wp_remote_get_error.'++'; 339 } 340 341 if (empty($string)) { 342 343 $lw_debug_information .= 'get_contents() empty++'; 344 } 345 } 346 347 return $string; 348 } 353 349 354 350 // --------------------------------------------------------------------------------------- … … 651 647 } 652 648 653 if( function_exists( ' curl_init' ) )649 if( function_exists( 'wp_remote_get' ) ) 654 650 { 655 651 $support_array['can_get_ads'] = 1;
Note: See TracChangeset
for help on using the changeset viewer.