@@ -27,6 +27,16 @@ public function register() {
2727
2828 public $ type = 'gitweb ' ;
2929
30+ public function url_get_auth ($ url , $ user , $ pass ) {
31+ if (strlen ($ user ) > 0 && strlen ($ pass ) > 0 ) {
32+ $ urlParts = preg_split ("/: \\/ \\// " , $ url );
33+ $ urlWithCredentials = $ urlParts [0 ] . ":// " . $ user . ": " . $ pass . "@ " .$ urlParts [1 ];
34+ return file_get_contents ($ urlWithCredentials );
35+ } else {
36+ return url_get ($ url );
37+ }
38+ }
39+
3040 public function show_type () {
3141 return plugin_lang_get ( 'gitweb ' );
3242 }
@@ -69,6 +79,8 @@ public function url_diff( $p_repo, $p_changeset, $p_file ) {
6979 public function update_repo_form ( $ p_repo ) {
7080 $ t_gitweb_root = null ;
7181 $ t_gitweb_project = null ;
82+ $ t_gitweb_user = null ;
83+ $ t_gitweb_pass = null ;
7284
7385 if ( isset ( $ p_repo ->info ['gitweb_root ' ] ) ) {
7486 $ t_gitweb_root = $ p_repo ->info ['gitweb_root ' ];
@@ -78,13 +90,21 @@ public function update_repo_form( $p_repo ) {
7890 $ t_gitweb_project = $ p_repo ->info ['gitweb_project ' ];
7991 }
8092
93+ if ( isset ( $ p_repo ->info ['gitweb_user ' ] ) ) {
94+ $ t_gitweb_user = $ p_repo ->info ['gitweb_user ' ];
95+ }
96+
97+ if ( isset ( $ p_repo ->info ['gitweb_pass ' ] ) ) {
98+ $ t_gitweb_pass = $ p_repo ->info ['gitweb_pass ' ];
99+ }
100+
101+
81102 if ( isset ( $ p_repo ->info ['master_branch ' ] ) ) {
82103 $ t_master_branch = $ p_repo ->info ['master_branch ' ];
83104 } else {
84105 $ t_master_branch = 'master ' ;
85106 }
86107?>
87-
88108<div class="field-container">
89109 <label><span><?php echo plugin_lang_get ( 'gitweb_root ' ) ?> </span></label>
90110 <span class="input">
@@ -101,6 +121,22 @@ public function update_repo_form( $p_repo ) {
101121 <span class="label-style"></span>
102122</div>
103123
124+ <div class="field-container">
125+ <label><span><?php echo plugin_lang_get ( 'gitweb_user ' ) ?> </span></label>
126+ <span class="input">
127+ <input name="gitweb_user" maxlength="250" size="40" value="<?php echo string_attribute ( $ t_gitweb_user ) ?> "/>
128+ </span>
129+ <span class="label-style"></span>
130+ </div>
131+
132+ <div class="field-container">
133+ <label><span><?php echo plugin_lang_get ( 'gitweb_pass ' ) ?> </span></label>
134+ <span class="input">
135+ <input name="gitweb_pass" maxlength="250" size="40" value="<?php echo string_attribute ( $ t_gitweb_pass ) ?> "/>
136+ </span>
137+ <span class="label-style"></span>
138+ </div>
139+
104140<div class="field-container">
105141 <label><span><?php echo plugin_lang_get ( 'master_branch ' ) ?> </span></label>
106142 <span class="input">
@@ -115,10 +151,14 @@ public function update_repo_form( $p_repo ) {
115151 public function update_repo ( $ p_repo ) {
116152 $ f_gitweb_root = gpc_get_string ( 'gitweb_root ' );
117153 $ f_gitweb_project = gpc_get_string ( 'gitweb_project ' );
154+ $ f_gitweb_user = gpc_get_string ( 'gitweb_user ' );
155+ $ f_gitweb_pass = gpc_get_string ( 'gitweb_pass ' );
118156 $ f_master_branch = gpc_get_string ( 'master_branch ' );
119157
120158 $ p_repo ->info ['gitweb_root ' ] = $ f_gitweb_root ;
121159 $ p_repo ->info ['gitweb_project ' ] = $ f_gitweb_project ;
160+ $ p_repo ->info ['gitweb_user ' ] = $ f_gitweb_user ;
161+ $ p_repo ->info ['gitweb_pass ' ] = $ f_gitweb_pass ;
122162 $ p_repo ->info ['master_branch ' ] = $ f_master_branch ;
123163
124164 return $ p_repo ;
@@ -165,7 +205,7 @@ public function import_full( $p_repo ) {
165205 else
166206 {
167207 $ t_heads_url = $ this ->uri_base ( $ p_repo ) . 'a=heads ' ;
168- $ t_branches_input = url_get ( $ t_heads_url );
208+ $ t_branches_input = $ this -> url_get_auth ( $ t_heads_url, $ p_repo -> info [ ' gitweb_user ' ], $ p_repo -> info [ ' gitweb_pass ' ] );
169209
170210 $ t_branches_input = str_replace ( array ("\r" , "\n" , '< ' , '> ' , ' ' ), array ('' , '' , '< ' , '> ' , ' ' ), $ t_branches_input );
171211
@@ -238,7 +278,7 @@ private function import_commits( $p_repo, $p_uri_base, $p_commit_ids, $p_branch=
238278 # Handle branch names with '+' character
239279 $ t_fixed_id = str_replace ('+ ' , '%2B ' , $ t_commit_id );
240280 $ t_commit_url = $ this ->uri_base ( $ p_repo ) . 'a=commit;h= ' . $ t_fixed_id ;
241- $ t_input = url_get ( $ t_commit_url );
281+ $ t_input = $ this -> url_get_auth ( $ t_commit_url, $ p_repo -> info [ ' gitweb_user ' ], $ p_repo -> info [ ' gitweb_pass ' ] );
242282
243283 if ( !$ t_input ) {
244284 echo "failed. \n" ;
0 commit comments