Changeset 8086 for branches/2.1/admin/include/functions.php
- Timestamp:
- Dec 11, 2010, 10:37:44 PM (13 years ago)
- Location:
- branches/2.1
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.1
- Property svn:mergeinfo changed
/trunk merged: 8079-8080,8082-8084
- Property svn:mergeinfo changed
-
branches/2.1/admin/include/functions.php
r8023 r8086 1685 1685 * @return bool 1686 1686 */ 1687 function fetchRemote($src, &$dest, $ user_agent='Piwigo', $step=0)1687 function fetchRemote($src, &$dest, $get_data=array(), $post_data=array(), $user_agent='Piwigo', $step=0) 1688 1688 { 1689 1689 // Try to retrieve data from local file? … … 1702 1702 } 1703 1703 1704 // Send anonymous data to piwigo server1705 if ($_SERVER['HTTP_HOST'] != 'localhost' and $step==01706 and preg_match('#^http://(?:[a-z]+\.)?piwigo\.org#', $src))1707 {1708 global $conf;1709 1710 $src = add_url_params($src, array(1711 'uuid' => hash_hmac('md5', get_absolute_root_url(), $conf['secret_key']),1712 'os' => urlencode(PHP_OS),1713 'pwgversion' => urlencode(PHPWG_VERSION),1714 'phpversion' => urlencode(phpversion()),1715 'dbengine' => urlencode(DB_ENGINE),1716 'dbversion' => urlencode(pwg_get_db_version()),1717 )1718 );1719 $src = str_replace('&', '&', $src);1720 }1721 1722 1704 // After 3 redirections, return false 1723 1705 if ($step > 3) return false; 1706 1707 // Initialization 1708 $method = empty($post_data) ? 'GET' : 'POST'; 1709 $request = empty($post_data) ? '' : http_build_query($post_data, '', '&'); 1710 $src = add_url_params($src, $get_data, '&'); 1724 1711 1725 1712 // Initialize $dest … … 1734 1721 @curl_setopt($ch, CURLOPT_USERAGENT, $user_agent); 1735 1722 @curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 1723 if ($method == 'POST') 1724 { 1725 @curl_setopt($ch, CURLOPT_POST, 1); 1726 @curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); 1727 } 1736 1728 $content = @curl_exec($ch); 1737 1729 $header_length = @curl_getinfo($ch, CURLINFO_HEADER_SIZE); … … 1742 1734 if (preg_match('/Location:\s+?(.+)/', substr($content, 0, $header_length), $m)) 1743 1735 { 1744 return fetchRemote($m[1], $dest, $user_agent, $step+1);1736 return fetchRemote($m[1], $dest, array(), array(), $user_agent, $step+1); 1745 1737 } 1746 1738 $content = substr($content, $header_length); … … 1753 1745 if (ini_get('allow_url_fopen')) 1754 1746 { 1755 $content = @file_get_contents($src); 1747 $opts = array( 1748 'http' => array( 1749 'method' => $method, 1750 'content' => $request, 1751 'user_agent' => $user_agent, 1752 ) 1753 ); 1754 $context = @stream_context_create($opts); 1755 $content = @file_get_contents($src, false, $context); 1756 1756 if ($content !== false) 1757 1757 { … … 1772 1772 } 1773 1773 1774 fwrite($s, 1775 "GET ".$path." HTTP/1.0\r\n" 1776 ."Host: ".$host."\r\n" 1777 ."User-Agent: ".$user_agent."\r\n" 1778 ."Accept: */*\r\n" 1779 ."\r\n" 1780 ); 1774 $http_request = $method." ".$path." HTTP/1.0\r\n"; 1775 $http_request .= "Host: ".$host."\r\n"; 1776 $http_request .= "Content-Type: application/x-www-form-urlencoded;\r\n"; 1777 $http_request .= "Content-Length: ".strlen($request)."\r\n"; 1778 $http_request .= "User-Agent: ".$user_agent."\r\n"; 1779 $http_request .= "Accept: */*\r\n"; 1780 $http_request .= "\r\n"; 1781 $http_request .= $request; 1782 1783 fwrite($s, $http_request); 1781 1784 1782 1785 $i = 0; … … 1811 1814 { 1812 1815 fclose($s); 1813 return fetchRemote(trim($m[1]),$dest, $user_agent,$step+1);1816 return fetchRemote(trim($m[1]),$dest,array(),array(),$user_agent,$step+1); 1814 1817 } 1815 1818 $i++; … … 2024 2027 return $tag_ids; 2025 2028 } 2029 2030 function get_hosting_technical_details() 2031 { 2032 global $conf; 2033 2034 $details = array(); 2035 if ($conf['send_hosting_technical_details'] and $_SERVER['HTTP_HOST'] != 'localhost') 2036 { 2037 $details = array( 2038 'uuid' => hash_hmac('md5', get_absolute_root_url(), $conf['secret_key']), 2039 'os' => urlencode(PHP_OS), 2040 'pwgversion' => urlencode(PHPWG_VERSION), 2041 'phpversion' => urlencode(phpversion()), 2042 'dbengine' => urlencode(DB_ENGINE), 2043 'dbversion' => urlencode(pwg_get_db_version()), 2044 ); 2045 } 2046 2047 return $details; 2048 } 2026 2049 ?>
Note: See TracChangeset
for help on using the changeset viewer.