Changeset 2900 for trunk/admin/include/functions.php
- Timestamp:
- Nov 23, 2008, 12:33:17 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/include/functions.php
r2892 r2900 1949 1949 function fetchRemote($src, &$dest, $user_agent='Piwigo', $step=0) 1950 1950 { 1951 // After 3 redirections, return false 1952 if ($step > 3) return false; 1953 1954 // Initialize $dest 1951 1955 is_resource($dest) or $dest = ''; 1952 1956 … … 1956 1960 $ch = @curl_init(); 1957 1961 @curl_setopt($ch, CURLOPT_URL, $src); 1958 @curl_setopt($ch, CURLOPT_HEADER, 0);1962 @curl_setopt($ch, CURLOPT_HEADER, 1); 1959 1963 @curl_setopt($ch, CURLOPT_USERAGENT, $user_agent); 1960 is_resource($dest) ? 1961 @curl_setopt($ch, CURLOPT_FILE, $dest): 1962 @curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 1964 @curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 1963 1965 $content = @curl_exec($ch); 1966 $header_length = @curl_getinfo($ch, CURLINFO_HEADER_SIZE); 1964 1967 @curl_close($ch); 1965 1968 if ($content !== false) 1966 1969 { 1967 is_resource($dest) or $dest = $content; 1970 if (preg_match('/Location:\s+?(.+)/', substr($content, 0, $header_length), $m)) 1971 { 1972 return fetchRemote($m[1], $dest, $user_agent, $step+1); 1973 } 1974 $content = substr($content, $header_length); 1975 is_resource($dest) ? @fwrite($dest, $content) : $dest = $content; 1968 1976 return true; 1969 1977 } … … 1982 1990 1983 1991 // Try fsockopen to read remote file 1984 if ($step > 3)1985 {1986 return false;1987 }1988 1989 1992 $src = parse_url($src); 1990 1993 $host = $src['host'];
Note: See TracChangeset
for help on using the changeset viewer.