Ignore:
Timestamp:
Nov 23, 2008, 12:33:17 AM (15 years ago)
Author:
patdenice
Message:
  • Bug fixed: username or password with accented character are now accepted for upgrade.
  • Simplify query in pwg_session_write function.
  • Retrieve data with cURL method in fetchRemote function now work with forwarded URL.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/include/functions.php

    r2892 r2900  
    19491949function fetchRemote($src, &$dest, $user_agent='Piwigo', $step=0)
    19501950{
     1951  // After 3 redirections, return false
     1952  if ($step > 3) return false;
     1953
     1954  // Initialize $dest
    19511955  is_resource($dest) or $dest = '';
    19521956
     
    19561960    $ch = @curl_init();
    19571961    @curl_setopt($ch, CURLOPT_URL, $src);
    1958     @curl_setopt($ch, CURLOPT_HEADER, 0);
     1962    @curl_setopt($ch, CURLOPT_HEADER, 1);
    19591963    @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);
    19631965    $content = @curl_exec($ch);
     1966    $header_length = @curl_getinfo($ch, CURLINFO_HEADER_SIZE);
    19641967    @curl_close($ch);
    19651968    if ($content !== false)
    19661969    {
    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;
    19681976      return true;
    19691977    }
     
    19821990
    19831991  // Try fsockopen to read remote file
    1984   if ($step > 3)
    1985   {
    1986     return false;
    1987   }
    1988 
    19891992  $src = parse_url($src);
    19901993  $host = $src['host'];
Note: See TracChangeset for help on using the changeset viewer.