Changeset 2880

Show
Ignore:
Timestamp:
11/15/08 22:10:05 (5 years ago)
Author:
patdenice
Message:

- Add fetchRemote function which allow to retrieve datas over HTTP protocol using cURL method, file_get_contents function or fsockopen method. This allow to retrieve datas or files even if allow_url_fopen is deactivated.
- Use fetchRemote function in plugins manager and in latest version checking.
- Add german translations for upgrade.lang.php.
- Remove empty line at the end of pclzip.lib.php.
- Change display of deactivated plugins after upgrade.

Location:
trunk
Files:
13 modified

Legend:

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

    r2777 r2880  
    19231923} 
    19241924 
     1925/** 
     1926 * Retrieve data from external URL 
     1927 * 
     1928 * @param string $src: URL 
     1929 * @param global $dest: can be a file ressource or string 
     1930 * @return bool 
     1931 */ 
     1932function fetchRemote($src, &$dest, $user_agent='Piwigo', $step=0) 
     1933{ 
     1934  is_resource($dest) or $dest = ''; 
     1935 
     1936  // Try curl to read remote file 
     1937  if (function_exists('curl_init')) 
     1938  { 
     1939    $ch = @curl_init(); 
     1940    @curl_setopt($ch, CURLOPT_URL, $src); 
     1941    @curl_setopt($ch, CURLOPT_HEADER, 0); 
     1942    @curl_setopt($ch, CURLOPT_USERAGENT, $user_agent); 
     1943    is_resource($dest) ? 
     1944      @curl_setopt($ch, CURLOPT_FILE, $dest): 
     1945      @curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
     1946    $content = @curl_exec($ch); 
     1947    @curl_close($ch); 
     1948    if ($content !== false) 
     1949    { 
     1950      is_resource($dest) or $dest = $content; 
     1951      return true; 
     1952    } 
     1953  } 
     1954 
     1955  // Try file_get_contents to read remote file 
     1956  if (ini_get('allow_url_fopen')) 
     1957  { 
     1958    $content = @file_get_contents($src); 
     1959    if ($content !== false) 
     1960    { 
     1961      is_resource($dest) ? @fwrite($dest, $content) : $dest = $content; 
     1962      return true; 
     1963    } 
     1964  } 
     1965 
     1966  // Try fsockopen to read remote file 
     1967  if ($step > 3) 
     1968  { 
     1969    return false; 
     1970  } 
     1971 
     1972  $src = parse_url($src); 
     1973  $host = $src['host']; 
     1974  $path = isset($src['path']) ? $src['path'] : '/'; 
     1975  $path .= isset($src['query']) ? '?'.$src['query'] : ''; 
     1976   
     1977  if (($s = @fsockopen($host,80,$errno,$errstr,5)) === false) 
     1978  { 
     1979    return false; 
     1980  } 
     1981 
     1982  fwrite($s, 
     1983    "GET ".$path." HTTP/1.0\r\n" 
     1984    ."Host: ".$host."\r\n" 
     1985    ."User-Agent: ".$user_agent."\r\n" 
     1986    ."Accept: */*\r\n" 
     1987    ."\r\n" 
     1988  ); 
     1989 
     1990  $i = 0; 
     1991  $in_content = false; 
     1992  while (!feof($s)) 
     1993  { 
     1994    $line = fgets($s); 
     1995 
     1996    if (rtrim($line,"\r\n") == '' && !$in_content) 
     1997    { 
     1998      $in_content = true; 
     1999      $i++; 
     2000      continue; 
     2001    } 
     2002    if ($i == 0) 
     2003    { 
     2004      if (!preg_match('/HTTP\/(\\d\\.\\d)\\s*(\\d+)\\s*(.*)/',rtrim($line,"\r\n"), $m)) 
     2005      { 
     2006        fclose($s); 
     2007        return false; 
     2008      } 
     2009      $status = (integer) $m[2]; 
     2010      if ($status < 200 || $status >= 400) 
     2011      { 
     2012        fclose($s); 
     2013        return false; 
     2014      } 
     2015    } 
     2016    if (!$in_content) 
     2017    { 
     2018      if (preg_match('/Location:\s+?(.+)$/',rtrim($line,"\r\n"),$m)) 
     2019      { 
     2020        fclose($s); 
     2021        return fetchRemote(trim($m[1]),$dest,$user_agent,$step+1); 
     2022      } 
     2023      $i++; 
     2024      continue; 
     2025    } 
     2026    is_resource($dest) ? @fwrite($dest, $line) : $dest .= $line; 
     2027    $i++; 
     2028  } 
     2029  fclose($s); 
     2030  return true; 
     2031} 
     2032 
    19252033?> 
  • trunk/admin/include/functions_upgrade.php

    r2838 r2880  
    128128 
    129129    array_push($page['infos'], 
    130       l10n('deactivated plugins') . '<pre>' . implode(', ', $plugins) . '</pre>'); 
     130      l10n('deactivated plugins').'<br /><br /><i>'.implode(', ', $plugins).'</i><br />'); 
    131131  } 
    132132} 
  • trunk/admin/include/plugins.class.php

    r2701 r2880  
    269269    $versions_to_check = array(); 
    270270    $url = PEM_URL . '/api/get_version_list.php?category_id=12&format=php'; 
    271     if ($source = @file_get_contents($url) 
    272       and $pem_versions = @unserialize($source)) 
     271    if (fetchRemote($url, $result) and $pem_versions = @unserialize($result)) 
    273272    { 
    274273      if (!preg_match('/^\d+\.\d+\.\d+/', $version)) 
     
    309308      $url .= implode(',', $plugins_to_check); 
    310309    } 
    311     if ($source = @file_get_contents($url)) 
    312     { 
    313       $pem_plugins = @unserialize($source); 
     310    if (fetchRemote($url, $result)) 
     311    { 
     312      $pem_plugins = @unserialize($result); 
    314313      if (!is_array($pem_plugins)) 
    315314      { 
     
    322321      return true; 
    323322    } 
     323    return false; 
    324324  } 
    325325   
     
    358358      $url = PEM_URL . '/download.php?rid=' . $revision; 
    359359      $url .= '&origin=piwigo_' . $action; 
    360       if (@copy($url, $archive)) 
    361       { 
     360 
     361      if ($handle = @fopen($archive, 'wb') and fetchRemote($url, $handle)) 
     362      { 
     363        fclose($handle); 
    362364        include(PHPWG_ROOT_PATH.'admin/include/pclzip.lib.php'); 
    363365        $zip = new PclZip($archive); 
  • trunk/admin/intro.php

    r2529 r2880  
    4343if (isset($_GET['action']) and 'check_upgrade' == $_GET['action']) 
    4444{ 
    45   if (!ini_get('allow_url_fopen')) 
     45  if (!fetchRemote(PHPWG_URL.'/latest_version', $result)) 
    4646  { 
    47     array_push( 
    48       $page['errors'], 
    49       l10n('Unable to check for upgrade since allow_url_fopen is disabled.') 
    50       ); 
     47    array_push($page['errors'], l10n('Unable to check for upgrade.')); 
    5148  } 
    5249  else 
    5350  { 
    5451    $versions = array('current' => PHPWG_VERSION); 
    55     $lines = @file(PHPWG_URL.'/latest_version'); 
     52    $lines = @explode("\r\n", $result); 
    5653 
    5754    // if the current version is a BSF (development branch) build, we check 
  • trunk/admin/plugins_new.php

    r2652 r2880  
    9090// |                     start template output                             | 
    9191// +-----------------------------------------------------------------------+ 
    92 if (!ini_get('allow_url_fopen')) 
    93 { 
    94   array_push($page['errors'], l10n('Unable to retrieve server informations since allow_url_fopen is disabled.')); 
    95 } 
    96 elseif ($plugins->get_server_plugins(true)) 
     92if ($plugins->get_server_plugins(true)) 
    9793{ 
    9894  $plugins->sort_server_plugins($order); 
  • trunk/admin/plugins_update.php

    r2652 r2880  
    9898// |                     start template output                             | 
    9999// +-----------------------------------------------------------------------+ 
    100 if (!ini_get('allow_url_fopen')) 
    101 { 
    102   array_push($page['errors'], l10n('Unable to connect to PEM server since allow_url_fopen is disabled.')); 
    103 } 
    104 elseif ($plugins->get_server_plugins()) 
     100if ($plugins->get_server_plugins()) 
    105101{ 
    106102  foreach($plugins->fs_plugins as $plugin_id => $fs_plugin) 
  • trunk/language/de_DE/admin.lang.php

    r2715 r2880  
    178178$lang['The %d following tag were deleted'] = 'Der folgende Tag wurde gelöscht'; 
    179179$lang['The %d following tags were deleted'] = 'Die folgenden %d Tags wurden gestrichen'; 
    180 $lang['Unable to check for upgrade since allow_url_fopen is disabled.'] = 'Unmöglich die neueste Version, die Funktion allow_url_fopen deaktiviert ist.'; 
     180$lang['Unable to check for upgrade.'] = 'Unmöglich die neueste Version.'; 
    181181$lang['Uninstall'] = 'Deinstallieren'; 
    182182$lang['Use default sort order']='Verwenden Sie die Sortierung der Bilder Standard (definiert in der Konfigurationsdatei)'; 
  • trunk/language/de_DE/upgrade.lang.php

    r2863 r2880  
    2222// +-----------------------------------------------------------------------+ 
    2323 
    24 /* TODO */ 
    2524$lang['Upgrade'] = 'Upgrade'; 
    26 $lang['introduction message'] = 'This page proposes to upgrade your database corresponding to your old version of Piwigo to the current version. 
    27 The upgrade assistant thinks you are currently running a <strong>release %s</strong> (or equivalent).'; 
    28 $lang['Upgrade from %s to %s'] = 'Upgrade from version %s to %s'; 
    29 $lang['Statistics'] = 'Statistics'; 
    30 $lang['total upgrade time'] = 'total upgrade time'; 
    31 $lang['total SQL time'] = 'total SQL time'; 
    32 $lang['SQL queries'] = 'SQL queries'; 
    33 $lang['Upgrade informations'] = 'Upgrade informations'; 
    34 $lang['perform a maintenance check'] = 'Perform a maintenance check in [Administration>Specials>Maintenance] if you encounter any problem.'; 
    35 $lang['deactivated plugins'] = 'As a precaution, following plugins have been deactivated. You must check for plugins upgrade before reactiving them:'; 
    36 $lang['upgrade login message'] = 'Only administrator can run upgrade: please sign in below.'; 
    37 $lang['You do not have access rights to run upgrade'] = 'You do not have access rights to run upgrade'; 
    38 $lang['in include/mysql.inc.php, before ?>, insert:'] = 'In <i>include/mysql.inc.php</i>, before <b>?></b>, insert:'; 
     25$lang['introduction message'] = 'Diese Seite schlägt vor aktualisieren Ihre Datenbank von Ihre alte Version von Piwigo auf die aktuelle Version. 
     26Der Upgrade-Assistent denkt Sie derzeit ein <strong>Freigabe %s</strong> (oder gleichwertig).'; 
     27$lang['Upgrade from %s to %s'] = 'Upgrade von Version %s bis %s'; 
     28$lang['Statistics'] = 'Statistik'; 
     29$lang['total upgrade time'] = 'insgesamt Upgrade-Zeit'; 
     30$lang['total SQL time'] = 'insgesamt SQL-Zeit'; 
     31$lang['SQL queries'] = 'SQL-Abfragen'; 
     32$lang['Upgrade informations'] = 'Upgrade-Informationen'; 
     33$lang['perform a maintenance check'] = 'Führen Sie einen Wartungs-Check am [Administration> Specials> Wartung], wenn Sie auf ein Problem stoßen'; 
     34$lang['deactivated plugins'] = 'Als Vorsichtsmaßnahme folgenden Plugins wurden deaktiviert. Sie müssen prüfen, ob Plugins aktualisieren, bevor sie reactiving:'; 
     35$lang['upgrade login message'] = 'Nur Administrator können Upgrade ausführen : Bitte melden Sie sich an unter.'; 
     36$lang['You do not have access rights to run upgrade'] = 'Sie haben nicht das Recht auf Zugang zum Upgrade ausführen'; 
     37$lang['in include/mysql.inc.php, before ?>, insert:'] = 'In <i>include/mysql.inc.php</i>, vor <b>?></b>, wird Folgendes eingefügt:'; 
    3938 
    4039// Upgrade informations from upgrade_1.3.1.php 
    41 $lang['all sub-categories of private categories become private'] = 'All sub-categories of private categories become private'; 
    42 $lang['user permissions and group permissions have been erased'] = 'User permissions and group permissions have been erased'; 
    43 $lang['only thumbnails prefix and webmaster mail saved'] = 'Only thumbnails prefix and webmaster mail address have been saved from previous configuration'; 
     40$lang['all sub-categories of private categories become private'] = 'Alle Unter-Kategorien von privaten Gruppen wirden privaten'; 
     41$lang['user permissions and group permissions have been erased'] = 'Benutzer und Gruppen Berechtigungen wurden gelöscht'; 
     42$lang['only thumbnails prefix and webmaster mail saved'] = 'Nur Miniaturansichten Präfix und Webmaster Mail-Adresse gespeichert wurden aus früheren Konfiguration'; 
    4443 
    4544?> 
  • trunk/language/en_UK/admin.lang.php

    r2678 r2880  
    178178$lang['The %d following tag were deleted'] = 'The following tag were deleted'; 
    179179$lang['The %d following tags were deleted'] = 'The %d following tags were deleted'; 
    180 $lang['Unable to check for upgrade since allow_url_fopen is disabled.'] = 'Unable to check for upgrade since allow_url_fopen is disabled.'; 
     180$lang['Unable to check for upgrade.'] = 'Unable to check for upgrade.'; 
    181181$lang['Uninstall'] = 'Uninstall'; 
    182182$lang['Use default sort order']='Use the default image sort order (defined in the configuration file)'; 
  • trunk/language/es_ES/admin.lang.php

    r2822 r2880  
    178178$lang['The %d following tag were deleted'] = 'El tag siguiente ha sido suprimido'; 
    179179$lang['The %d following tags were deleted'] = 'Los %d tags siguientes han sido suprimidos'; 
    180 $lang['Unable to check for upgrade since allow_url_fopen is disabled.'] = 'Imposible conocer la última versión cat la función allow_url_fopen es desactivada.'; 
     180$lang['Unable to check for upgrade.'] = 'Imposible conocer la última versión.'; 
    181181$lang['Uninstall'] = 'Desinstalar'; 
    182182$lang['Use default sort order']='Utilizar la orden de selección de las imágenes por defecto (definido en el fichero de configuración)'; 
  • trunk/language/fr_FR/admin.lang.php

    r2678 r2880  
    178178$lang['The %d following tag were deleted'] = 'Le tag suivant a été supprimé'; 
    179179$lang['The %d following tags were deleted'] = 'Les %d tags suivants ont été supprimés'; 
    180 $lang['Unable to check for upgrade since allow_url_fopen is disabled.'] = 'Impossible de connaître la dernière version car la fonction allow_url_fopen est désactivée.'; 
     180$lang['Unable to check for upgrade.'] = 'Impossible de connaître la dernière version.'; 
    181181$lang['Uninstall'] = 'Désinstaller'; 
    182182$lang['Use default sort order']='Utiliser l\'ordre de tri des images par défaut (défini dans le fichier de configuration)'; 
  • trunk/language/it_IT/admin.lang.php

    r2873 r2880  
    178178$lang['The %d following tag were deleted'] = 'Il tag seguente è stato cancellato'; 
    179179$lang['The %d following tags were deleted'] = 'I %d tags seguenti sono stati cancellati'; 
    180 $lang['Unable to check for upgrade since allow_url_fopen is disabled.'] = 'Non è stato possibile identificare l\'ultima versione a causa della funzione allow_url_fopen tuttora disattiva.'; 
     180$lang['Unable to check for upgrade.'] = 'Non è stato possibile identificare l\'ultima versione.'; 
    181181$lang['Uninstall'] = 'Disinstallare'; 
    182182$lang['Use default sort order']='Usare l\'ordinamento delle immagini di defaut (cosi come definito nel file di configurazione)'; 
  • trunk/language/nl_NL/admin.lang.php

    r2685 r2880  
    178178$lang['The %d following tag were deleted'] = 'De volgende tag is verwijderd'; 
    179179$lang['The %d following tags were deleted'] = 'De %d volgende tags zijn verwijderd'; 
    180 $lang['Unable to check for upgrade since allow_url_fopen is disabled.'] = 'Onnmoglijk om een controlle te doen voor een upgrade omdat allow_url_fopen is uitgeschakeld.'; 
     180$lang['Unable to check for upgrade.'] = 'Onnmoglijk om een controlle te doen voor een upgrade.'; 
    181181$lang['Uninstall'] = 'Deinstalleren'; 
    182182$lang['Use default sort order']='Gebruik de standaard sortering (defineerd in de configuratie file)';