Changeset 2901


Ignore:
Timestamp:
Nov 23, 2008, 12:34:58 AM (16 years ago)
Author:
patdenice
Message:

merge -c2900 from trunk to branch 2.0.

  • 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.
Location:
branches/2.0
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/2.0/admin/include/functions.php

    r2893 r2901  
    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'];
  • branches/2.0/admin/include/functions_upgrade.php

    r2885 r2901  
    142142  }
    143143
    144   if (version_compare($current_release, '1.5.0', '<'))
     144  if (version_compare($current_release, '2.0', '<'))
     145  {
     146    $username = utf8_decode($username);
     147    $password = utf8_decode($password);
     148  }
     149
     150  if (version_compare($current_release, '1.5', '<'))
    145151  {
    146152    $query = '
     
    167173  }
    168174
    169   if ($row['password'] != $conf['pass_convert']($_POST['password']))
     175  if ($row['password'] != $conf['pass_convert']($password))
    170176  {
    171177    array_push($page['errors'], l10n('invalid_pwd'));
  • branches/2.0/include/functions_session.inc.php

    r2885 r2901  
    132132{
    133133  $query = '
    134 UPDATE '.SESSIONS_TABLE.'
    135   SET expiration = now(),
    136   data = \''.$data.'\'
    137   WHERE id = \''.get_remote_addr_session_hash().$session_id.'\'
    138 ;';
    139   pwg_query($query);
    140   if ( mysql_affected_rows()>0 )
    141   {
    142     return true;
    143   }
    144   $query = '
    145 INSERT INTO '.SESSIONS_TABLE.'
     134REPLACE INTO '.SESSIONS_TABLE.'
    146135  (id,data,expiration)
    147136  VALUES(\''.get_remote_addr_session_hash().$session_id.'\',\''.$data.'\',now())
Note: See TracChangeset for help on using the changeset viewer.