diff --git a/Source/Source.php b/Source/Source.php index d4ddc2c..613f720 100644 --- a/Source/Source.php +++ b/Source/Source.php @@ -16,7 +16,7 @@ $this->name = plugin_lang_get( 'title' ); $this->description = plugin_lang_get( 'description' ); - $this->version = '0.15'; + $this->version = '0.16'; $this->requires = array( 'MantisCore' => '1.2.0', 'Meta' => '0.1', diff --git a/Source/SourceIntegration.php b/Source/SourceIntegration.php index 5ef92bf..c5fb628 100644 --- a/Source/SourceIntegration.php +++ b/Source/SourceIntegration.php @@ -6,7 +6,7 @@ final class SourceIntegrationPlugin extends MantisPlugin { function register() { $this->name = plugin_lang_get( 'title', 'Source' ); - $this->version = '0.15'; + $this->version = '0.16'; } function hooks() { diff --git a/Source/pages/import.php b/Source/pages/import.php new file mode 100644 index 0000000..38228ff --- /dev/null +++ b/Source/pages/import.php @@ -0,0 +1,95 @@ +import_error = false; + while( true ) { + + # import the next batch of changesets + $t_changesets = $t_vcs->import_latest( $t_repo ); + + # check for errors + if ( !is_array( $t_changesets ) ) { + $t_repo->import_error = true; + break; + } + + # if no more entries, we're done + if ( count( $t_changesets ) < 1 ) { + break; + } + + Source_Process_Changesets( $t_changesets ); + } +} + diff --git a/Source/pages/repo_import_latest.php b/Source/pages/repo_import_latest.php index a576093..fe45b41 100644 --- a/Source/pages/repo_import_latest.php +++ b/Source/pages/repo_import_latest.php @@ -3,118 +3,23 @@ # Copyright (c) 2010 John Reese # Licensed under the MIT license -$t_address = $_SERVER['REMOTE_ADDR']; -$t_valid = false; -$t_remote = true; - helper_begin_long_process(); -# Always allow the same machine to import -if ( '127.0.0.1' == $t_address || '127.0.1.1' == $t_address - || 'localhost' == $t_address || '::1' == $t_address ) { - $t_valid = true; -} - -# Check for allowed remote IP/URL addresses -if ( !$t_valid && ON == plugin_config_get( 'remote_imports' ) ) { - $t_import_urls = unserialize( plugin_config_get( 'import_urls' ) ); - preg_match( '/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/', $t_address, $t_address_matches ); - - foreach ( $t_import_urls as $t_url ) { - if ( $t_valid ) break; - - $t_url = trim( $t_url ); - - if ( preg_match( '/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/', $t_url, $t_remote_matches ) ) { # IP - if ( $t_url == $t_address ) { - $t_valid = true; - break; - } - - $t_match = true; - for( $i = 1; $i <= 4; $i++ ) { - if ( $t_remote_matches[$i] == '0' || $t_address_matches[$i] == $t_remote_matches[$i] ) { - } else { - $t_match = false; - break; - } - } - - $t_valid = $t_match; - - } else { - $t_ip = gethostbyname( $t_url ); - if ( $t_ip == $t_address ) { - $t_valid = true; - break; - } - } - } -} - -# Allow a logged-in user to import -if ( !$t_valid && auth_is_user_authenticated() && !current_user_is_anonymous() ) { - form_security_validate( 'plugin_Source_repo_import_latest' ); - access_ensure_global_level( plugin_config_get( 'manage_threshold' ) ); - helper_ensure_confirmed( plugin_lang_get( 'ensure_import_latest' ), plugin_lang_get( 'import_latest' ) ); - - $t_valid = true; - $t_remote = false; -} - -# Not validated by this point gets the boot! -if ( !$t_valid ) { - die( plugin_lang_get( 'invalid_import_url' ) ); -} +form_security_validate( 'plugin_Source_repo_import_latest' ); +access_ensure_global_level( plugin_config_get( 'manage_threshold' ) ); +helper_ensure_confirmed( plugin_lang_get( 'ensure_import_latest' ), plugin_lang_get( 'import_latest' ) ); $f_repo_id = strtolower( gpc_get_string( 'id' ) ); -# Load an array of repositories to be imported -if ( $f_repo_id == 'all' ) { - $t_repos = SourceRepo::load_all(); +$t_repo_id = (int) $f_repo_id; +$t_repos = array( SourceRepo::load( $t_repo_id ) ); -} elseif ( is_numeric( $f_repo_id ) ) { - $t_repo_id = (int) $f_repo_id; - $t_repos = array( SourceRepo::load( $t_repo_id ) ); -} +$t_repo = array_shift( $t_repos ); +$t_vcs = SourceVCS::repo( $t_repo ); -# Loop through all repos to be imported -foreach ( $t_repos as $t_repo ) { - $t_vcs = SourceVCS::repo( $t_repo ); +$t_repo->pre_stats = $t_repo->stats(); - if ( !$t_remote ) { - $t_repo->pre_stats = $t_repo->stats(); - } - - # keep checking for more changesets to import - $t_repo->import_error = false; - while( true ) { - - # import the next batch of changesets - $t_changesets = $t_vcs->import_latest( $t_repo ); - - # check for errors - if ( !is_array( $t_changesets ) ) { - $t_repo->import_error = true; - break; - } - - # if no more entries, we're done - if ( count( $t_changesets ) < 1 ) { - break; - } - - Source_Process_Changesets( $t_changesets ); - } - - if ( !$t_remote ) { - $t_repo->post_stats = $t_repo->stats(); - } -} - -# Display output to the user -if ( !$t_remote ) { - html_page_top(); +html_page_top(); ?>
@@ -124,42 +29,58 @@ - +import_error = false; +while( true ) { + + # import the next batch of changesets + $t_changesets = $t_vcs->import_latest( $t_repo ); + + # check for errors + if ( !is_array( $t_changesets ) ) { + $t_repo->import_error = true; + break; + } + + # if no more entries, we're done + if ( count( $t_changesets ) < 1 ) { + break; + } + + Source_Process_Changesets( $t_changesets ); +} + +$t_repo->post_stats = $t_repo->stats(); +?> + > name ) ?> import_error ) { - echo plugin_lang_get( 'import_latest_failed' ), '
'; - } +if ( $t_repo->import_error ) { + echo plugin_lang_get( 'import_latest_failed' ), '
'; +} - $t_stats = $t_repo->post_stats; - $t_stats['changesets'] -= $t_repo->pre_stats['changesets']; - $t_stats['files'] -= $t_repo->pre_stats['files']; - $t_stats['bugs'] -= $t_repo->pre_stats['bugs']; +$t_stats = $t_repo->post_stats; +$t_stats['changesets'] -= $t_repo->pre_stats['changesets']; +$t_stats['files'] -= $t_repo->pre_stats['files']; +$t_stats['bugs'] -= $t_repo->pre_stats['bugs']; - echo sprintf( plugin_lang_get( 'import_stats' ), $t_stats['changesets'], $t_stats['files'], $t_stats['bugs'] ); +echo sprintf( plugin_lang_get( 'import_stats' ), $t_stats['changesets'], $t_stats['files'], $t_stats['bugs'] ); ?> - -id, plugin_lang_get( 'back_repo' ) ); - } -?> +id, plugin_lang_get( 'back_repo' ) ) ?> name = plugin_lang_get( 'title' ); $this->description = plugin_lang_get( 'description' ); - $this->version = '0.14'; + $this->version = '0.16'; $this->requires = array( 'MantisCore' => '1.2.0', - 'Source' => '0.14', + 'Source' => '0.16', 'Meta' => '0.1', ); diff --git a/SourceGitweb/SourceGitweb.php b/SourceGitweb/SourceGitweb.php index 4a13dee..635f75b 100644 --- a/SourceGitweb/SourceGitweb.php +++ b/SourceGitweb/SourceGitweb.php @@ -14,10 +14,10 @@ $this->name = plugin_lang_get( 'title' ); $this->description = plugin_lang_get( 'description' ); - $this->version = '0.14'; + $this->version = '0.16'; $this->requires = array( 'MantisCore' => '1.2.0', - 'Source' => '0.14', + 'Source' => '0.16', 'Meta' => '0.1', ); diff --git a/SourceSFSVN/SourceSFSVN.php b/SourceSFSVN/SourceSFSVN.php index a620119..06d6e6b 100644 --- a/SourceSFSVN/SourceSFSVN.php +++ b/SourceSFSVN/SourceSFSVN.php @@ -12,11 +12,11 @@ $this->name = lang_get( 'plugin_SourceSFSVN_title' ); $this->description = lang_get( 'plugin_SourceSFSVN_description' ); - $this->version = '0.14'; + $this->version = '0.16'; $this->requires = array( 'MantisCore' => '1.2.0', - 'Source' => '0.14', - 'SourceSVN' => '0.14', + 'Source' => '0.16', + 'SourceSVN' => '0.16', ); $this->author = 'John Reese'; diff --git a/SourceSVN/SourceSVN.php b/SourceSVN/SourceSVN.php index 4fe1b51..c150cfe 100644 --- a/SourceSVN/SourceSVN.php +++ b/SourceSVN/SourceSVN.php @@ -12,10 +12,10 @@ $this->name = lang_get( 'plugin_SourceSVN_title' ); $this->description = lang_get( 'plugin_SourceSVN_description' ); - $this->version = '0.14'; + $this->version = '0.16'; $this->requires = array( 'MantisCore' => '1.2.0', - 'Source' => '0.14', + 'Source' => '0.16', ); $this->author = 'John Reese'; diff --git a/SourceWebSVN/SourceWebSVN.php b/SourceWebSVN/SourceWebSVN.php index 6b48732..4839068 100644 --- a/SourceWebSVN/SourceWebSVN.php +++ b/SourceWebSVN/SourceWebSVN.php @@ -12,11 +12,11 @@ $this->name = lang_get( 'plugin_SourceWebSVN_title' ); $this->description = lang_get( 'plugin_SourceWebSVN_description' ); - $this->version = '0.14'; + $this->version = '0.16'; $this->requires = array( 'MantisCore' => '1.2.0', - 'Source' => '0.14', - 'SourceSVN' => '0.14', + 'Source' => '0.16', + 'SourceSVN' => '0.16', ); $this->author = 'John Reese';