Changeset 2881 for branches/2.0/admin
- Timestamp:
- Nov 15, 2008, 10:11:58 PM (16 years ago)
- Location:
- branches/2.0/admin
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.0/admin/include/functions.php
r2776 r2881 1923 1923 } 1924 1924 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 */ 1932 function 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 1925 2033 ?> -
branches/2.0/admin/include/functions_upgrade.php
r2839 r2881 128 128 129 129 array_push($page['infos'], 130 l10n('deactivated plugins') . '<pre>' . implode(', ', $plugins) . '</pre>');130 l10n('deactivated plugins').'<br /><br /><i>'.implode(', ', $plugins).'</i><br />'); 131 131 } 132 132 } -
branches/2.0/admin/include/plugins.class.php
r2701 r2881 269 269 $versions_to_check = array(); 270 270 $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)) 273 272 { 274 273 if (!preg_match('/^\d+\.\d+\.\d+/', $version)) … … 309 308 $url .= implode(',', $plugins_to_check); 310 309 } 311 if ( $source = @file_get_contents($url))312 { 313 $pem_plugins = @unserialize($ source);310 if (fetchRemote($url, $result)) 311 { 312 $pem_plugins = @unserialize($result); 314 313 if (!is_array($pem_plugins)) 315 314 { … … 322 321 return true; 323 322 } 323 return false; 324 324 } 325 325 … … 358 358 $url = PEM_URL . '/download.php?rid=' . $revision; 359 359 $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); 362 364 include(PHPWG_ROOT_PATH.'admin/include/pclzip.lib.php'); 363 365 $zip = new PclZip($archive); -
branches/2.0/admin/intro.php
r2529 r2881 43 43 if (isset($_GET['action']) and 'check_upgrade' == $_GET['action']) 44 44 { 45 if (! ini_get('allow_url_fopen'))45 if (!fetchRemote(PHPWG_URL.'/latest_version', $result)) 46 46 { 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.')); 51 48 } 52 49 else 53 50 { 54 51 $versions = array('current' => PHPWG_VERSION); 55 $lines = @ file(PHPWG_URL.'/latest_version');52 $lines = @explode("\r\n", $result); 56 53 57 54 // if the current version is a BSF (development branch) build, we check -
branches/2.0/admin/plugins_new.php
r2652 r2881 90 90 // | start template output | 91 91 // +-----------------------------------------------------------------------+ 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)) 92 if ($plugins->get_server_plugins(true)) 97 93 { 98 94 $plugins->sort_server_plugins($order); -
branches/2.0/admin/plugins_update.php
r2652 r2881 98 98 // | start template output | 99 99 // +-----------------------------------------------------------------------+ 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()) 100 if ($plugins->get_server_plugins()) 105 101 { 106 102 foreach($plugins->fs_plugins as $plugin_id => $fs_plugin)
Note: See TracChangeset
for help on using the changeset viewer.