Changeset 4216 for extensions/piwigopress/PiwigoPress_get.php
- Timestamp:
- Nov 5, 2009, 11:15:41 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/piwigopress/PiwigoPress_get.php
r4125 r4216 19 19 $pwg_prev_host = $host; 20 20 $mode = $pwg_mode; 21 // $mode = 'ch'; // Forcing a test '' all, 'fs' fsockopen, 'ch' cURL21 // $mode = 'ch'; // Forcing a test '' all, 'fs' fsockopen, 'ch' cURL 22 22 23 23 // 1 - The simplest solution: file_get_contents … … 34 34 } 35 35 if ( $mode == '' ) $mode = 'fs'; 36 if ( $pwg_mode == '' ) $pwg_mode = 'fs'; 36 if ( $pwg_mode == '' ) $pwg_mode = 'fs'; // Remind it 37 37 // 2 - Often accepted access: fsockopen 38 38 if ($mode == 'fs') { … … 56 56 } 57 57 } 58 $return["stat"] = 'failed';59 $pwg_mode = 'failed';60 return serialize($return);61 58 62 // Not active cURL right now 63 if ( $pwg_mode == 'fs' ) $pwg_mode = 'ch'; 59 if ( $pwg_mode == 'fs' ) $pwg_mode = 'ch'; // Remind it 64 60 // 3 - Sometime another solution: curl_exec 65 61 // See http://fr2.php.net/manual/en/curl.installation.php 66 62 if (function_exists('curl_init') and $pwg_mode == 'ch') { 67 63 $ch = @curl_init(); 64 @curl_setopt($ch, CURLOPT_URL, $url); 65 @curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout); 68 66 @curl_setopt($ch, CURLOPT_TIMEOUT, $timeout); 69 @curl_setopt($ch, CURLOPT_URL, $url);70 67 @curl_setopt($ch, CURLOPT_HEADER, 1); 71 68 @curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0'); … … 76 73 $status = @curl_getinfo($ch, CURLINFO_HTTP_CODE); 77 74 @curl_close($value); 78 if ($value !== false and $status >= 200 and $status < 400) 79 $value = substr($value, $header_length); 75 if ($value !== false and $status >= 200 and $status < 400) { 76 $value = substr($value, $header_length); 77 // echo '<br/>-ch- ('. $value . ') <br/>'; 78 return $value; 79 } 80 else $pwg_mode = 'failed'; // Sorry but remind it as well 80 81 } 81 82 82 83 // No other solutions 83 84 $return["stat"] = 'failed'; 84 echo '<br/>- pwg_get_contents: failed on file_get, fsockopen and cURL processes<br/>'; 85 $pwg_mode = 'failed'; 85 // echo '<br/>- pwg_get_contents: failed on file_get, fsockopen and cURL processes<br/>'; 86 86 return serialize($return); 87 87 }
Note: See TracChangeset
for help on using the changeset viewer.