Changeset 8086 for branches/2.1
- Timestamp:
- Dec 11, 2010, 10:37:44 PM (13 years ago)
- Location:
- branches/2.1
- Files:
-
- 8 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 ?> -
branches/2.1/admin/include/languages.class.php
r6551 r8086 197 197 global $user; 198 198 199 $pem_category_id = 8; 199 $get_data = array( 200 'category_id' => 8, 201 'format' => 'php', 202 ); 200 203 201 204 // Retrieve PEM versions 202 205 $version = PHPWG_VERSION; 203 206 $versions_to_check = array(); 204 $url = PEM_URL . '/api/get_version_list.php ?category_id='.$pem_category_id.'&format=php';205 if (fetchRemote($url, $result ) and $pem_versions = @unserialize($result))207 $url = PEM_URL . '/api/get_version_list.php'; 208 if (fetchRemote($url, $result, $get_data, get_hosting_technical_details()) and $pem_versions = @unserialize($result)) 206 209 { 207 210 if (!preg_match('/^\d+\.\d+\.\d+/', $version)) … … 224 227 225 228 // Retrieve PEM languages infos 226 $url = PEM_URL . '/api/get_revision_list.php?category_id='.$pem_category_id.'&format=php&last_revision_only=true'; 227 $url .= '&version=' . implode(',', $versions_to_check); 228 $url .= '&lang='.$user['language']; 229 230 if (fetchRemote($url, $result)) 229 $url = PEM_URL . '/api/get_revision_list.php'; 230 $get_data = array_merge($get_data, array( 231 'last_revision_only' => 'true', 232 'version' => implode(',', $versions_to_check), 233 'lang' => $user['language'], 234 ) 235 ); 236 237 if (fetchRemote($url, $result, $get_data)) 231 238 { 232 239 $pem_languages = @unserialize($result); … … 259 266 if ($archive = tempnam( PHPWG_ROOT_PATH.'language', 'zip')) 260 267 { 261 $url = PEM_URL . '/download.php?rid=' . $revision; 262 $url .= '&origin=piwigo_' . $action; 263 264 if ($handle = @fopen($archive, 'wb') and fetchRemote($url, $handle)) 268 $url = PEM_URL . '/download.php'; 269 $get_data = array( 270 'rid' => $revision, 271 'origin' => 'piwigo_'.$action, 272 ); 273 274 if ($handle = @fopen($archive, 'wb') and fetchRemote($url, $handle, $get_data)) 265 275 { 266 276 fclose($handle); -
branches/2.1/admin/include/plugins.class.php
r6724 r8086 291 291 global $user; 292 292 293 $get_data = array( 294 'category_id' => 12, 295 'format' => 'php', 296 ); 297 293 298 // Retrieve PEM versions 294 299 $version = PHPWG_VERSION; 295 300 $versions_to_check = array(); 296 $url = PEM_URL . '/api/get_version_list.php ?category_id=12&format=php';297 if (fetchRemote($url, $result ) and $pem_versions = @unserialize($result))301 $url = PEM_URL . '/api/get_version_list.php'; 302 if (fetchRemote($url, $result, $get_data, get_hosting_technical_details()) and $pem_versions = @unserialize($result)) 298 303 { 299 304 if (!preg_match('/^\d+\.\d+\.\d+/', $version)) … … 326 331 327 332 // Retrieve PEM plugins infos 328 $url = PEM_URL . '/api/get_revision_list.php?category_id=12&format=php&last_revision_only=true'; 329 $url .= '&version=' . implode(',', $versions_to_check); 330 $url .= '&lang=' . substr($user['language'], 0, 2); 331 $url .= '&get_nb_downloads=true'; 333 $url = PEM_URL . '/api/get_revision_list.php'; 334 $get_data = array_merge($get_data, array( 335 'last_revision_only' => 'true', 336 'version' => implode(',', $versions_to_check), 337 'lang' => substr($user['language'], 0, 2), 338 'get_nb_downloads' => 'true', 339 ) 340 ); 332 341 333 342 if (!empty($plugins_to_check)) 334 343 { 335 $url .= $new ? '&extension_exclude=' : '&extension_include='; 336 $url .= implode(',', $plugins_to_check); 337 } 338 if (fetchRemote($url, $result)) 344 if ($new) 345 { 346 $get_data['extension_exclude'] = implode(',', $plugins_to_check); 347 } 348 else 349 { 350 $get_data['extension_include'] = implode(',', $plugins_to_check); 351 } 352 } 353 if (fetchRemote($url, $result, $get_data)) 339 354 { 340 355 $pem_plugins = @unserialize($result); … … 387 402 if ($archive = tempnam( PHPWG_PLUGINS_PATH, 'zip')) 388 403 { 389 $url = PEM_URL . '/download.php?rid=' . $revision; 390 $url .= '&origin=piwigo_' . $action; 391 392 if ($handle = @fopen($archive, 'wb') and fetchRemote($url, $handle)) 404 $url = PEM_URL . '/download.php'; 405 $get_data = array( 406 'rid' => $revision, 407 'origin' => 'piwigo_'.$action, 408 ); 409 410 if ($handle = @fopen($archive, 'wb') and fetchRemote($url, $handle, $get_data)) 393 411 { 394 412 fclose($handle); -
branches/2.1/admin/include/themes.class.php
r6551 r8086 448 448 global $user; 449 449 450 $pem_category_id = 10; 450 $get_data = array( 451 'category_id' => 10, 452 'format' => 'php', 453 ); 451 454 452 455 // Retrieve PEM versions 453 456 $version = PHPWG_VERSION; 454 457 $versions_to_check = array(); 455 $url = PEM_URL . '/api/get_version_list.php ?category_id='.$pem_category_id.'&format=php';456 if (fetchRemote($url, $result ) and $pem_versions = @unserialize($result))458 $url = PEM_URL . '/api/get_version_list.php'; 459 if (fetchRemote($url, $result, $get_data, get_hosting_technical_details()) and $pem_versions = @unserialize($result)) 457 460 { 458 461 if (!preg_match('/^\d+\.\d+\.\d+/', $version)) … … 485 488 486 489 // Retrieve PEM themes infos 487 $url = PEM_URL . '/api/get_revision_list.php?category_id='.$pem_category_id.'&format=php&last_revision_only=true'; 488 $url .= '&version=' . implode(',', $versions_to_check); 489 $url .= '&lang=' . substr($user['language'], 0, 2); 490 $url .= '&get_nb_downloads=true'; 490 $url = PEM_URL . '/api/get_revision_list.php'; 491 $get_data = array_merge($get_data, array( 492 'last_revision_only' => 'true', 493 'version' => implode(',', $versions_to_check), 494 'lang' => substr($user['language'], 0, 2), 495 'get_nb_downloads' => 'true', 496 ) 497 ); 491 498 492 499 if (!empty($themes_to_check)) 493 500 { 494 $url .= $new ? '&extension_exclude=' : '&extension_include='; 495 $url .= implode(',', $themes_to_check); 496 } 497 if (fetchRemote($url, $result)) 501 if ($new) 502 { 503 $get_data['extension_exclude'] = implode(',', $themes_to_check); 504 } 505 else 506 { 507 $get_data['extension_include'] = implode(',', $themes_to_check); 508 } 509 } 510 if (fetchRemote($url, $result, $get_data)) 498 511 { 499 512 $pem_themes = @unserialize($result); … … 547 560 if ($archive = tempnam( PHPWG_THEMES_PATH, 'zip')) 548 561 { 549 $url = PEM_URL . '/download.php?rid=' . $revision; 550 $url .= '&origin=piwigo_' . $action; 551 552 if ($handle = @fopen($archive, 'wb') and fetchRemote($url, $handle)) 562 $url = PEM_URL . '/download.php'; 563 $get_data = array( 564 'rid' => $revision, 565 'origin' => 'piwigo_'.$action, 566 ); 567 568 if ($handle = @fopen($archive, 'wb') and fetchRemote($url, $handle, $get_data)) 553 569 { 554 570 fclose($handle); -
branches/2.1/admin/site_manager.php
r6364 r8086 117 117 { 118 118 $clf_url = $url.'create_listing_file.php'; 119 $clf_url.= '?action=test'; 120 $clf_url.= '&version='.PHPWG_VERSION; 121 if (fetchRemote($clf_url, $result)) 119 $get_data = array( 120 'action' => 'test', 121 'version' => PHPWG_VERSION, 122 ); 123 if (fetchRemote($clf_url, $result, $get_data)) 122 124 { 123 125 $lines = explode("\r\n", $result); -
branches/2.1/include/config_default.inc.php
r6715 r8086 485 485 // gives an empty value '' to deactivate 486 486 $conf['show_php_errors'] = E_ALL; 487 488 // sends your hosting PHP and MySQL versions to piwigo.org as anonymously as 489 // possible, for statistics purpose. No personnal data are transmitted 490 $conf['send_hosting_technical_details'] = true; 487 491 488 492 // +-----------------------------------------------------------------------+ -
branches/2.1/include/functions_url.inc.php
r6410 r8086 90 90 * @return string 91 91 */ 92 function add_url_params($url, $params )92 function add_url_params($url, $params, $arg_separator='&' ) 93 93 { 94 94 if ( !empty($params) ) … … 101 101 { 102 102 $is_first = false; 103 $url .= ( strpos($url, '?')===false ) ? '?' : '&';103 $url .= ( strpos($url, '?')===false ) ? '?' : $arg_separator; 104 104 } 105 105 else 106 106 { 107 $url .= '&';107 $url .= $arg_separator; 108 108 } 109 109 $url .= $param;
Note: See TracChangeset
for help on using the changeset viewer.