Changeset 369969
- Timestamp:
- 04/07/2011 08:04:04 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gts-translation/tags/1.1.5/wordpress/GtsPluginWordpress.php
r369686 r369969 496 496 global $wp_version; 497 497 $locale_name = com_gts_Language::get_by_code( $language )->wordpressLocaleName; 498 $svn_url = "http://svn.automattic.com/wordpress-i18n/$locale_name"; 498 499 $svn_host = 'svn.automattic.com'; 500 $svn_url = "/wordpress-i18n/$locale_name"; 499 501 $svn_messages_dir = "messages" . ( $domain != "default" ? "/$domain" : ""); 500 502 … … 503 505 } 504 506 505 $tags = @file_get_contents( "$svn_url/tags/" ); 507 $tags_fp = $this->url_get_stream( $svn_host, 80, "$svn_url/tags/" ); 508 $tags = @stream_get_contents( $tags_fp ); 509 @fclose( $tags_fp ); 510 506 511 if( $tags ) { 507 512 … … 531 536 532 537 foreach ( $prioritized_versions as $version ) { 533 if( $this->download_mofile_to_i18n_dir( "$svn_url/tags/$version/$svn_messages_dir/$locale_name.mo", $domain, $version, "$locale_name.mo" ) ) {538 if( $this->download_mofile_to_i18n_dir( $svn_host, "$svn_url/tags/$version/$svn_messages_dir/$locale_name.mo", $domain, $version, "$locale_name.mo" ) ) { 534 539 return TRUE; 535 540 } … … 538 543 } 539 544 540 return $this->download_mofile_to_i18n_dir( "$svn_url/trunk/$svn_messages_dir/$locale_name.mo", $domain, "0.0", "$locale_name.mo" );541 } 542 543 544 function download_mofile_to_i18n_dir( $svn_ url, $dirname, $version, $filename ) {545 546 $i18n_base = GTS_I18N_DIR . "/$version/$dirname /";547 548 $mo_stream = @fopen( $svn_url, 'r');545 return $this->download_mofile_to_i18n_dir( $svn_host, "$svn_url/trunk/$svn_messages_dir/$locale_name.mo", $domain, "0.0", "$locale_name.mo" ); 546 } 547 548 549 function download_mofile_to_i18n_dir( $svn_host, $svn_url, $dirname, $version, $filename ) { 550 551 $i18n_base = GTS_I18N_DIR . "/$version/$dirname"; 552 553 $mo_stream = $this->url_get_stream( $svn_host, 80, $svn_url ); 549 554 if( !$mo_stream ) { 550 555 return FALSE; … … 567 572 568 573 return TRUE; 574 } 575 576 577 // this is a workaround to deal with hosts where file_get_contents doesn't work for URLs 578 // due to security constraints... 579 function url_get_stream( $host, $port, $url ) { 580 581 $fp = @fsockopen( $host, $port ); 582 583 if( $fp ) { 584 @fwrite( $fp, "GET $url HTTP/1.1\r\n" ); 585 @fwrite( $fp, "Host: $host\r\n" ); 586 @fwrite( $fp, "\r\n" ); 587 588 // in our ghetto wire impl, we'll ignore headers. when we come across 589 // the first blank \r\n, we'll return the result. 590 while ( $str = @fgets( $fp, 4096) ) { 591 if ( $str == "\r\n" ) { 592 return $fp; 593 } 594 } 595 } 596 597 return $fp; 569 598 } 570 599 … … 1279 1308 define( 'GTS_PLUGIN_URL', trailingslashit( WP_PLUGIN_URL ) . basename( GTS_PLUGIN_DIR) ); 1280 1309 1281 define( 'GTS_I18N_DIR', GTS_PLUGIN_DIR . '/i18n/' );1310 define( 'GTS_I18N_DIR', GTS_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'i18n' ); 1282 1311 1283 1312 $plugin_data = get_file_data( GTS_PLUGIN_DIR . DIRECTORY_SEPARATOR . 'Gts.php', array( 'Name' => 'Plugin Name', 'Version' => 'Version' ) );
Note: See TracChangeset
for help on using the changeset viewer.