Rev 185 Rev 3925
1 <?php 1 <?php
2 # vim:et:ts=3:sts=3:sw=3:fdm=marker: 2 # vim:et:ts=3:sts=3:sw=3:fdm=marker:
3   3  
4 // WebSVN - Subversion repository viewing via the web using PHP 4 // WebSVN - Subversion repository viewing via the web using PHP
5 // Copyright © 2004-2006 Tim Armes, Matt Sicker 5 // Copyright © 2004-2006 Tim Armes, Matt Sicker
6 // 6 //
7 // This program is free software; you can redistribute it and/or modify 7 // This program is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by 8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation; either version 2 of the License, or 9 // the Free Software Foundation; either version 2 of the License, or
10 // (at your option) any later version. 10 // (at your option) any later version.
11 // 11 //
12 // This program is distributed in the hope that it will be useful, 12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of 13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details. 15 // GNU General Public License for more details.
16 // 16 //
17 // You should have received a copy of the GNU General Public License 17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software 18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 19 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // 20 //
21 // -- 21 // --
22 // 22 //
23 // configclass.inc4 23 // configclass.inc4
24 // 24 //
25 // General class for handling configuration options 25 // General class for handling configuration options
26   26  
27 require_once("include/command.inc"); 27 require_once("include/command.inc");
28 require_once("include/auth.inc"); 28 require_once("include/auth.inc");
29 require_once("include/version.inc"); 29 require_once("include/version.inc");
30   30  
31 // Auxillary functions used to sort repositories by name/group 31 // Auxillary functions used to sort repositories by name/group
32   32  
33 // {{{ cmpReps($a, $b) 33 // {{{ cmpReps($a, $b)
34   34  
35 function cmpReps($a, $b) 35 function cmpReps($a, $b)
36 { 36 {
37 // First, sort by group 37 // First, sort by group
38 $g = strcasecmp($a->group, $b->group); 38 $g = strcasecmp($a->group, $b->group);
39 if ($g) 39 if ($g)
40 return $g; 40 return $g;
41 41
42 // Same group? Sort by name 42 // Same group? Sort by name
43 return strcasecmp($a->name, $b->name); 43 return strcasecmp($a->name, $b->name);
44 } 44 }
45   45  
46 // }}} 46 // }}}
47   47  
48 // {{{ cmpGroups($a, $b) 48 // {{{ cmpGroups($a, $b)
49   49  
50 function cmpGroups($a, $b) 50 function cmpGroups($a, $b)
51 { 51 {
52 $g = strcasecmp($a->group, $b->group); 52 $g = strcasecmp($a->group, $b->group);
53 if ($g) 53 if ($g)
54 return $g; 54 return $g;
55 55
56 return 0; 56 return 0;
57 } 57 }
58   58  
59 // }}} 59 // }}}
60   60  
61 // {{{ mergesort(&$array, [$cmp_function]) 61 // {{{ mergesort(&$array, [$cmp_function])
62   62  
63 function mergesort(&$array, $cmp_function = 'strcmp') 63 function mergesort(&$array, $cmp_function = 'strcmp')
64 { 64 {
65 // Arrays of size < 2 require no action 65 // Arrays of size < 2 require no action
66 66
67 if (count($array) < 2) 67 if (count($array) < 2)
68 return; 68 return;
69 69
70 // Split the array in half 70 // Split the array in half
71 $halfway = count($array) / 2; 71 $halfway = count($array) / 2;
72 $array1 = array_slice($array, 0, $halfway); 72 $array1 = array_slice($array, 0, $halfway);
73 $array2 = array_slice($array, $halfway); 73 $array2 = array_slice($array, $halfway);
74 74
75 // Recurse to sort the two halves 75 // Recurse to sort the two halves
76 mergesort($array1, $cmp_function); 76 mergesort($array1, $cmp_function);
77 mergesort($array2, $cmp_function); 77 mergesort($array2, $cmp_function);
78 78
79 // If all of $array1 is <= all of $array2, just append them. 79 // If all of $array1 is <= all of $array2, just append them.
80 if (call_user_func($cmp_function, end($array1), $array2[0]) < 1) 80 if (call_user_func($cmp_function, end($array1), $array2[0]) < 1)
81 { 81 {
82 $array = array_merge($array1, $array2); 82 $array = array_merge($array1, $array2);
83 return; 83 return;
84 } 84 }
85 85
86 // Merge the two sorted arrays into a single sorted array 86 // Merge the two sorted arrays into a single sorted array
87 $array = array(); 87 $array = array();
88 $ptr1 = $ptr2 = 0; 88 $ptr1 = $ptr2 = 0;
89 while ($ptr1 < count($array1) && $ptr2 < count($array2)) 89 while ($ptr1 < count($array1) && $ptr2 < count($array2))
90 { 90 {
91 if (call_user_func($cmp_function, $array1[$ptr1], $array2[$ptr2]) < 1) 91 if (call_user_func($cmp_function, $array1[$ptr1], $array2[$ptr2]) < 1)
92 { 92 {
93 $array[] = $array1[$ptr1++]; 93 $array[] = $array1[$ptr1++];
94 } 94 }
95 else 95 else
96 { 96 {
97 $array[] = $array2[$ptr2++]; 97 $array[] = $array2[$ptr2++];
98 } 98 }
99 } 99 }
100 100
101 // Merge the remainder 101 // Merge the remainder
102 while ($ptr1 < count($array1)) $array[] = $array1[$ptr1++]; 102 while ($ptr1 < count($array1)) $array[] = $array1[$ptr1++];
103 while ($ptr2 < count($array2)) $array[] = $array2[$ptr2++]; 103 while ($ptr2 < count($array2)) $array[] = $array2[$ptr2++];
104 104
105 return; 105 return;
106 } 106 }
107   107  
108 // }}} 108 // }}}
109   109  
110 // A Repository configuration class 110 // A Repository configuration class
111   111  
112 Class Repository 112 Class Repository
113 { 113 {
114 // {{{ Properties 114 // {{{ Properties
115   115  
116 var $name; 116 var $name;
117 var $svnName; 117 var $svnName;
118 var $path; 118 var $path;
119 var $group; 119 var $group;
120 var $username; 120 var $username;
121 var $password; 121 var $password;
122 122
123 // Local configuration options must start off unset 123 // Local configuration options must start off unset
124 124
125 var $allowDownload; 125 var $allowDownload;
126 var $minDownloadLevel; 126 var $minDownloadLevel;
127 var $allowedExceptions = array(); 127 var $allowedExceptions = array();
128 var $disallowedExceptions = array(); 128 var $disallowedExceptions = array();
129 var $rss; 129 var $rss;
130 var $spaces; 130 var $spaces;
131 var $ignoreSvnMimeTypes; 131 var $ignoreSvnMimeTypes;
132 var $ignoreWebSVNContentTypes; 132 var $ignoreWebSVNContentTypes;
133 var $bugtraq; 133 var $bugtraq;
134 var $auth; 134 var $auth;
135 var $contentEnc; 135 var $contentEnc;
136 var $templatePath; 136 var $templatePath;
137   137  
138 // }}} 138 // }}}
139   139  
140 // {{{ __construct($name, $svnName, $path, [$group, [$username, [$password]]]) 140 // {{{ __construct($name, $svnName, $path, [$group, [$username, [$password]]])
141   141  
142 function Repository($name, $svnName, $path, $group = NULL, $username = NULL, $password = NULL) 142 function Repository($name, $svnName, $path, $group = NULL, $username = NULL, $password = NULL)
143 { 143 {
144 $this->name = $name; 144 $this->name = $name;
145 $this->svnName = $svnName; 145 $this->svnName = $svnName;
146 $this->path = $path; 146 $this->path = $path;
147 $this->group = $group; 147 $this->group = $group;
148 $this->username = $username; 148 $this->username = $username;
149 $this->password = $password; 149 $this->password = $password;
150 } 150 }
151   151  
152 // }}} 152 // }}}
153   153  
154 // {{{ getDisplayName() 154 // {{{ getDisplayName()
155   155  
156 function getDisplayName() 156 function getDisplayName()
157 { 157 {
158 if(!empty($this->group)) 158 if(!empty($this->group))
159 return $this->group.".".$this->name; 159 return $this->group.".".$this->name;
160 else 160 else
161 return $this->name; 161 return $this->name;
162 } 162 }
163   163  
164 // }}} 164 // }}}
165   165  
166 // {{{ svnParams 166 // {{{ svnParams
167   167  
168 function svnParams() 168 function svnParams()
169 { 169 {
170 if (!empty($this->username)) 170 if (!empty($this->username))
171 return " --username ".$this->username." --password ".$this->password." "; 171 return " --username ".$this->username." --password ".$this->password." ";
172 else 172 else
173 return " "; 173 return " ";
174 } 174 }
175   175  
176 // }}} 176 // }}}
177   177  
178 // Local configuration accessors 178 // Local configuration accessors
179 179
180 // {{{ RSS Feed 180 // {{{ RSS Feed
181 181
182 function hideRSS() 182 function hideRSS()
183 { 183 {
184 $this->rss = false; 184 $this->rss = false;
185 } 185 }
186   186  
187 function showRSS() 187 function showRSS()
188 { 188 {
189 $this->rss = true; 189 $this->rss = true;
190 } 190 }
191   191  
192 function getHideRSS() 192 function getHideRSS()
193 { 193 {
194 global $config; 194 global $config;
195   195  
196 if (isset($this->rss)) 196 if (isset($this->rss))
197 return $this->rss; 197 return $this->rss;
198 198
199 return $config->getHideRSS(); 199 return $config->getHideRSS();
200 } 200 }
201   201  
202 // }}} 202 // }}}
203 203
204 // {{{ Download 204 // {{{ Download
205 205
206 function allowDownload() 206 function allowDownload()
207 { 207 {
208 $this->allowDownload = true; 208 $this->allowDownload = true;
209 } 209 }
210   210  
211 function disallowDownload() 211 function disallowDownload()
212 { 212 {
213 $this->allowDownload = false; 213 $this->allowDownload = false;
214 } 214 }
215 215
216 function getAllowDownload() 216 function getAllowDownload()
217 { 217 {
218 global $config; 218 global $config;
219   219  
220 if (isset($this->allowDownload)) 220 if (isset($this->allowDownload))
221 return $this->allowDownload; 221 return $this->allowDownload;
222 222
223 return $config->getAllowDownload(); 223 return $config->getAllowDownload();
224 } 224 }
225   225  
226 function setMinDownloadLevel($level) 226 function setMinDownloadLevel($level)
227 { 227 {
228 $this->minDownloadLevel = $level; 228 $this->minDownloadLevel = $level;
229 } 229 }
230   230  
231 function getMinDownloadLevel() 231 function getMinDownloadLevel()
232 { 232 {
233 global $config; 233 global $config;
234   234  
235 if (isset($this->minDownloadLevel)) 235 if (isset($this->minDownloadLevel))
236 return $this->minDownloadLevel; 236 return $this->minDownloadLevel;
237 237
238 return $config->getMinDownloadLevel(); 238 return $config->getMinDownloadLevel();
239 } 239 }
240 240
241 function addAllowedDownloadException($path) 241 function addAllowedDownloadException($path)
242 { 242 {
243 if ($path{strlen($path) - 1} != "/") 243 if ($path{strlen($path) - 1} != "/")
244 $path .= "/"; 244 $path .= "/";
245 245
246 $this->allowedExceptions[] = $path; 246 $this->allowedExceptions[] = $path;
247 } 247 }
248 248
249 function addDisallowedDownloadException($path) 249 function addDisallowedDownloadException($path)
250 { 250 {
251 if ($path{strlen($path) - 1} != "/") 251 if ($path{strlen($path) - 1} != "/")
252 $path .= "/"; 252 $path .= "/";
253 253
254 $this->disallowedExceptions[] = $path; 254 $this->disallowedExceptions[] = $path;
255 } 255 }
256   256  
257 function isDownloadAllowed($path) 257 function isDownloadAllowed($path)
258 { 258 {
259 global $config; 259 global $config;
260 260
261 // Check global download option 261 // Check global download option
262 if (!$this->getAllowDownload()) 262 if (!$this->getAllowDownload())
263 return false; 263 return false;
264 264
265 // Check with access module 265 // Check with access module
266 if (!$this->hasUnrestrictedReadAccess($path)) 266 if (!$this->hasUnrestrictedReadAccess($path))
267 return false; 267 return false;
268 268
269 $subs = explode("/", $path); 269 $subs = explode("/", $path);
270 $level = count($subs) - 2; 270 $level = count($subs) - 2;
271 if ($level >= $this->getMinDownloadLevel()) 271 if ($level >= $this->getMinDownloadLevel())
272 { 272 {
273 // Level OK, search for disallowed exceptions 273 // Level OK, search for disallowed exceptions
274 274
275 if ($config->findException($path, $this->disallowedExceptions)) 275 if ($config->findException($path, $this->disallowedExceptions))
276 return false; 276 return false;
277 277
278 if ($config->findException($path, $config->disallowedExceptions)) 278 if ($config->findException($path, $config->disallowedExceptions))
279 return false; 279 return false;
280 280
281 return true; 281 return true;
282 } 282 }
283 else 283 else
284 { 284 {
285 // Level not OK, search for disallowed exceptions 285 // Level not OK, search for disallowed exceptions
286   286  
287 if ($config->findException($path, $this->allowedExceptions)) 287 if ($config->findException($path, $this->allowedExceptions))
288 return true; 288 return true;
289 289
290 if ($config->findException($path, $config->allowedExceptions)) 290 if ($config->findException($path, $config->allowedExceptions))
291 return true; 291 return true;
292 292
293 return false; 293 return false;
294 } 294 }
295 } 295 }
296   296  
297 // }}} 297 // }}}
298   298  
299 // {{{ Templates 299 // {{{ Templates
300   300  
301 function setTemplatePath($path) 301 function setTemplatePath($path)
302 { 302 {
303 $lastchar = substr($path, -1, 1); 303 $lastchar = substr($path, -1, 1);
304 if (!($lastchar == DIRECTORY_SEPARATOR || 304 if (!($lastchar == DIRECTORY_SEPARATOR ||
305 $lastchar == '/' || 305 $lastchar == '/' ||
306 $lastchar == '\\')) 306 $lastchar == '\\'))
307 $path .= DIRECTORY_SEPARATOR; 307 $path .= DIRECTORY_SEPARATOR;
308   308  
309 $this->templatePath = $path; 309 $this->templatePath = $path;
310 } 310 }
311   311  
312 function getTemplatePath() 312 function getTemplatePath()
313 { 313 {
314 global $config; 314 global $config;
315 if (!empty($this->templatePath)) 315 if (!empty($this->templatePath))
316 return $this->templatePath; 316 return $this->templatePath;
317 else 317 else
318 return $config->getTemplatePath(); 318 return $config->getTemplatePath();
319 } 319 }
320   320  
321 // }}} 321 // }}}
322   322  
323 // {{{ Tab expansion 323 // {{{ Tab expansion
324 324
325 function expandTabsBy($sp) 325 function expandTabsBy($sp)
326 { 326 {
327 $this->spaces = $sp; 327 $this->spaces = $sp;
328 } 328 }
329 329
330 function getExpandTabsBy() 330 function getExpandTabsBy()
331 { 331 {
332 global $config; 332 global $config;
333   333  
334 if (isset($this->spaces)) 334 if (isset($this->spaces))
335 return $this->spaces; 335 return $this->spaces;
336 336
337 return $config->getExpandTabsBy(); 337 return $config->getExpandTabsBy();
338 } 338 }
339   339  
340 // }}} 340 // }}}
341   341  
342 // {{{ MIME-Type Handing 342 // {{{ MIME-Type Handing
343 343
344 function ignoreSvnMimeTypes() 344 function ignoreSvnMimeTypes()
345 { 345 {
346 $this->ignoreSvnMimeTypes = true; 346 $this->ignoreSvnMimeTypes = true;
347 } 347 }
348   348  
349 function useSvnMimeTypes() 349 function useSvnMimeTypes()
350 { 350 {
351 $this->ignoreSvnMimeTypes = false; 351 $this->ignoreSvnMimeTypes = false;
352 } 352 }
353   353  
354 function getIgnoreSvnMimeTypes() 354 function getIgnoreSvnMimeTypes()
355 { 355 {
356 global $config; 356 global $config;
357   357  
358 if (isset($this->ignoreSvnMimeTypes)) 358 if (isset($this->ignoreSvnMimeTypes))
359 return $this->ignoreSvnMimeTypes; 359 return $this->ignoreSvnMimeTypes;
360 360
361 return $config->getIgnoreSvnMimeTypes(); 361 return $config->getIgnoreSvnMimeTypes();
362 } 362 }
363   363  
364 function ignoreWebSVNContentTypes() 364 function ignoreWebSVNContentTypes()
365 { 365 {
366 $this->ignoreWebSVNContentTypes = true; 366 $this->ignoreWebSVNContentTypes = true;
367 } 367 }
368   368  
369 function useWebSVNContentTypes() 369 function useWebSVNContentTypes()
370 { 370 {
371 $this->ignoreWebSVNContentTypes = false; 371 $this->ignoreWebSVNContentTypes = false;
372 } 372 }
373   373  
374 function getIgnoreWebSVNContentTypes() 374 function getIgnoreWebSVNContentTypes()
375 { 375 {
376 global $config; 376 global $config;
377   377  
378 if (isset($this->ignoreWebSVNContentTypes)) 378 if (isset($this->ignoreWebSVNContentTypes))
379 return $this->ignoreWebSVNContentTypes; 379 return $this->ignoreWebSVNContentTypes;
380 380
381 return $config->getIgnoreWebSVNContentTypes(); 381 return $config->getIgnoreWebSVNContentTypes();
382 } 382 }
383   383  
384 // }}} 384 // }}}
385 385
386 // {{{ Issue Tracking 386 // {{{ Issue Tracking
387 387
388 function useBugtraqProperties() 388 function useBugtraqProperties()
389 { 389 {
390 $this->bugtraq = true; 390 $this->bugtraq = true;
391 } 391 }
392   392  
393 function ignoreBugtraqProperties() 393 function ignoreBugtraqProperties()
394 { 394 {
395 $this->bugtraq = false; 395 $this->bugtraq = false;
396 } 396 }
397   397  
398 function getBugtraq() 398 function getBugtraq()
399 { 399 {
400 global $config; 400 global $config;
401   401  
402 if (isset($this->bugtraq)) 402 if (isset($this->bugtraq))
403 return $this->bugtraq; 403 return $this->bugtraq;
404 404
405 return $config->getBugtraq(); 405 return $config->getBugtraq();
406 } 406 }
407   407  
408 // }}} 408 // }}}
409 409
410 // {{{ Encodings 410 // {{{ Encodings
411 411
412 function setContentEncoding($contentEnc) 412 function setContentEncoding($contentEnc)
413 { 413 {
414 $this->contentEnc = $contentEnc; 414 $this->contentEnc = $contentEnc;
415 } 415 }
416   416  
417 function getContentEncoding() 417 function getContentEncoding()
418 { 418 {
419 global $config; 419 global $config;
420   420  
421 if (isset($this->contentEnc)) 421 if (isset($this->contentEnc))
422 return $this->contentEnc; 422 return $this->contentEnc;
423 423
424 return $config->getContentEncoding(); 424 return $config->getContentEncoding();
425 } 425 }
426   426  
427 // }}} 427 // }}}
428   428  
429 // {{{ Authentication 429 // {{{ Authentication
430 430
431 function useAuthenticationFile($file) 431 function useAuthenticationFile($file)
432 { 432 {
433 if (is_readable($file)) 433 if (is_readable($file))
434 $this->auth =& new Authentication($file); 434 $this->auth =& new Authentication($file);
435 else 435 else
436 die('Unable to read authentication file "'.$file.'"'); 436 die('Unable to read authentication file "'.$file.'"');
437 } 437 }
438   438  
439 function hasReadAccess($path, $checkSubFolders = false) 439 function hasReadAccess($path, $checkSubFolders = false)
440 { 440 {
441 global $config; 441 global $config;
442   442  
443 $a = null; 443 $a = null;
444 if (isset($this->auth)) 444 if (isset($this->auth))
445 $a =& $this->auth; 445 $a =& $this->auth;
446 else 446 else
447 $a =& $config->getAuth(); 447 $a =& $config->getAuth();
448 448
449 if (!empty($a)) 449 if (!empty($a))
450 return $a->hasReadAccess($this->svnName, $path, $checkSubFolders); 450 return $a->hasReadAccess($this->svnName, $path, $checkSubFolders);
451 451
452 // No auth file - free access... 452 // No auth file - free access...
453 return true; 453 return true;
454 } 454 }
455   455  
456 function hasUnrestrictedReadAccess($path) 456 function hasUnrestrictedReadAccess($path)
457 { 457 {
458 global $config; 458 global $config;
459   459  
460 $a = null; 460 $a = null;
461 if (isset($this->auth)) 461 if (isset($this->auth))
462 $a =& $this->auth; 462 $a =& $this->auth;
463 else 463 else
464 $a =& $config->getAuth(); 464 $a =& $config->getAuth();
465 465
466 if (!empty($a)) 466 if (!empty($a))
467 return $a->hasUnrestrictedReadAccess($this->svnName, $path); 467 return $a->hasUnrestrictedReadAccess($this->svnName, $path);
468 468
469 // No auth file - free access... 469 // No auth file - free access...
470 return true; 470 return true;
471 } 471 }
472   472  
473 // }}} 473 // }}}
474   474  
475 } 475 }
476   476  
477 // The general configuration class 477 // The general configuration class
478   478  
479 Class Config 479 Class Config
480 { 480 {
481 // {{{ Properties 481 // {{{ Properties
482   482  
483 // Tool path locations 483 // Tool path locations
484   484  
485 var $svnlook = "svnlook"; 485 var $svnlook = "svnlook";
486 var $svn = "svn --non-interactive --config-dir /tmp"; 486 var $svn = "svn --non-interactive --config-dir /tmp";
487 var $svn_noparams = "svn --config-dir /tmp"; 487 var $svn_noparams = "svn --config-dir /tmp";
488 var $diff = "diff"; 488 var $diff = "diff";
489 var $enscript ="enscript"; 489 var $enscript ="enscript";
490 var $sed = "sed"; 490 var $sed = "sed";
491 var $gzip = "gzip"; 491 var $gzip = "gzip";
492 var $tar = "tar"; 492 var $tar = "tar";
493 493
494 // Other configuration items 494 // Other configuration items
495 495
496 var $treeView = true; 496 var $treeView = true;
497 var $flatIndex = true; 497 var $flatIndex = true;
498 var $openTree = false; 498 var $openTree = false;
499 var $serverIsWindows = false; 499 var $serverIsWindows = false;
500 var $phpCompatEnabled = false; 500 var $phpCompatEnabled = false;
501 var $cacheResults = false; 501 var $cacheResults = false;
502 var $multiViews = false; 502 var $multiViews = false;
503 var $useEnscript = false; 503 var $useEnscript = false;
504 var $allowDownload = false; 504 var $allowDownload = false;
505 var $minDownloadLevel = 0; 505 var $minDownloadLevel = 0;
506 var $allowedExceptions = array(); 506 var $allowedExceptions = array();
507 var $disallowedExceptions = array(); 507 var $disallowedExceptions = array();
508 var $rss = true; 508 var $rss = true;
509 var $spaces = 8; 509 var $spaces = 8;
510 var $bugtraq = false; 510 var $bugtraq = false;
511 var $auth = ""; 511 var $auth = "";
512 512
513 var $templatePath = "./templates/Standard/"; 513 var $templatePath = "./templates/Standard/";
514 var $phpCompatPath = './include/PHP/Compat.php'; 514 var $phpCompatPath = './include/PHP/Compat.php';
515   515  
516 var $ignoreSvnMimeTypes = false; 516 var $ignoreSvnMimeTypes = false;
517 var $ignoreWebSVNContentTypes = false; 517 var $ignoreWebSVNContentTypes = false;
518   518  
519 var $subversionMajorVersion = ""; 519 var $subversionMajorVersion = "";
520 var $subversionMinorVersion = ""; 520 var $subversionMinorVersion = "";
521   521  
522 // Default character encodings 522 // Default character encodings
523 var $inputEnc = ""; // Encoding of output returned from command line 523 var $inputEnc = ""; // Encoding of output returned from command line
524 var $contentEnc = ""; // Encoding of repository content 524 var $contentEnc = ""; // Encoding of repository content
525 var $outputEnc = "UTF-8"; // Encoding of web page. Now forced to UTF-8 525 var $outputEnc = "UTF-8"; // Encoding of web page. Now forced to UTF-8
526   526  
527 var $quote = "'"; 527 var $quote = "'";
528 var $pathSeparator = ":"; 528 var $pathSeparator = ":";
529   529  
530 var $_repositories; 530 var $_repositories;
531   531  
532 // }}} 532 // }}}
533   533  
534 // {{{ __construct() 534 // {{{ __construct()
535   535  
536 function Config() 536 function Config()
537 { 537 {
538 } 538 }
539   539  
540 // }}} 540 // }}}
541   541  
542 // {{{ Repository configuration 542 // {{{ Repository configuration
543 543
544 function addRepository($name, $url, $group = NULL, $username = NULL, $password = NULL) 544 function addRepository($name, $url, $group = NULL, $username = NULL, $password = NULL)
545 { 545 {
546 $url = str_replace(DIRECTORY_SEPARATOR, "/", $url); 546 $url = str_replace(DIRECTORY_SEPARATOR, "/", $url);
547 547
548 if ($url{strlen($url) - 1} == "/") 548 if ($url{strlen($url) - 1} == "/")
549 $url = substr($url, 0, -1); 549 $url = substr($url, 0, -1);
550 550
551 $svnName = substr($url, strrpos($url, "/") + 1); 551 $svnName = substr($url, strrpos($url, "/") + 1);
552 $this->_repositories[] = new Repository($name, $svnName, $url, $group, $username, $password); 552 $this->_repositories[] = new Repository($name, $svnName, $url, $group, $username, $password);
553 } 553 }
554   554  
555 function getRepositories() 555 function getRepositories()
556 { 556 {
557 return $this->_repositories; 557 return $this->_repositories;
558 } 558 }
559   559  
560 function &findRepository($name) 560 function &findRepository($name)
561 { 561 {
562 foreach ($this->_repositories as $index => $rep) 562 foreach ($this->_repositories as $index => $rep)
563 { 563 {
564 if (strcmp($rep->getDisplayName(), $name) == 0) 564 if (strcmp($rep->getDisplayName(), $name) == 0)
565 { 565 {
566 $repref =& $this->_repositories[$index]; 566 $repref =& $this->_repositories[$index];
567 return $repref; 567 return $repref;
568 } 568 }
569 } 569 }
570 570
571 print "ERROR: Unable to find repository '$name'"; 571 print "ERROR: Unable to find repository '$name'";
572 exit; 572 exit;
573 } 573 }
574   574  
575 // }}} 575 // }}}
576   576  
577 // {{{ setServerIsWindows 577 // {{{ setServerIsWindows
578 // 578 //
579 // The server is running on Windows 579 // The server is running on Windows
580 580
581 function setServerIsWindows() 581 function setServerIsWindows()
582 { 582 {
583 $this->serverIsWindows = true; 583 $this->serverIsWindows = true;
584 584
585 // Try to set the input encoding intelligently 585 // Try to set the input encoding intelligently
586 586
587 $cp = 0; 587 $cp = 0;
588 if ($cp = @shell_exec("CHCP")) 588 if ($cp = @shell_exec("CHCP"))
589 { 589 {
590 $cp = trim(substr($cp, strpos($cp, ":") + 1)); 590 $cp = trim(substr($cp, strpos($cp, ":") + 1));
591 settype($cp, "integer"); 591 settype($cp, "integer");
592 } 592 }
593 593
594 // Use the most sensible default value if that failed 594 // Use the most sensible default value if that failed
595 if ($cp == 0) $cp = 850; 595 if ($cp == 0) $cp = 850;
596 596
597 // We assume, as a default, that the encoding of the repository contents is 597 // We assume, as a default, that the encoding of the repository contents is
598 // in iso-8859-1, to be compatible with compilers and the like. 598 // in iso-8859-1, to be compatible with compilers and the like.
599 $this->setInputEncoding("CP$cp", "iso-8859-1"); 599 $this->setInputEncoding("CP$cp", "iso-8859-1");
600 600
601 // On Windows machines, use double quotes around command line parameters 601 // On Windows machines, use double quotes around command line parameters
602 $this->quote = '"'; 602 $this->quote = '"';
603 603
604 // On Windows, semicolon separates path entries in a list rather than colon. 604 // On Windows, semicolon separates path entries in a list rather than colon.
605 $this->pathSeparator = ";"; 605 $this->pathSeparator = ";";
606 } 606 }
607 607
608 // }}} 608 // }}}
609 609
610 // {{{ setPHPCompatEnabled 610 // {{{ setPHPCompatEnabled
611 // 611 //
612 // Used for PHP4 612 // Used for PHP4
613   613  
614 function setPHPCompatEnabled() { 614 function setPHPCompatEnabled() {
615 $this->phpCompatEnabled = true; 615 $this->phpCompatEnabled = true;
616 } 616 }
617 617
618 function isPHPCompatEnabled() { 618 function isPHPCompatEnabled() {
619 return $this->phpCompatEnabled; 619 return $this->phpCompatEnabled;
620 } 620 }
621   621  
622 // }}} 622 // }}}
623   623  
624 // {{{ Caching 624 // {{{ Caching
625   625  
626 // setCachingOn 626 // setCachingOn
627 // 627 //
628 // Set result caching on 628 // Set result caching on
629 629
630 function setCachingOn() 630 function setCachingOn()
631 { 631 {
632 $this->cacheResults = true; 632 $this->cacheResults = true;
633 } 633 }
634   634  
635 function isCachingOn() 635 function isCachingOn()
636 { 636 {
637 return $this->cacheResults; 637 return $this->cacheResults;
638 } 638 }
639   639  
640 // }}} 640 // }}}
641   641  
642 // {{{ MultiViews 642 // {{{ MultiViews
643   643  
644 // useMultiViews 644 // useMultiViews
645 // 645 //
646 // Use MultiViews to access the repository 646 // Use MultiViews to access the repository
647 647
648 function useMultiViews() 648 function useMultiViews()
649 { 649 {
650 $this->multiViews = true; 650 $this->multiViews = true;
651 } 651 }
652   652  
653 function getUseMultiViews() 653 function getUseMultiViews()
654 { 654 {
655 return $this->multiViews; 655 return $this->multiViews;
656 } 656 }
657   657  
658 // }}} 658 // }}}
659   659  
660 // {{{ Enscript 660 // {{{ Enscript
661   661  
662 // useEnscript 662 // useEnscript
663 // 663 //
664 // Use Enscript to colourise listings 664 // Use Enscript to colourise listings
665 665
666 function useEnscript() 666 function useEnscript()
667 { 667 {
668 $this->useEnscript = true; 668 $this->useEnscript = true;
669 } 669 }
670   670  
671 function getUseEnscript() 671 function getUseEnscript()
672 { 672 {
673 return $this->useEnscript; 673 return $this->useEnscript;
674 } 674 }
675   675  
676 // }}} 676 // }}}
677   677  
678 // {{{ RSS 678 // {{{ RSS
679   679  
680 // offerRSS 680 // offerRSS
681 // 681 //
682 // Use Enscript to colourise listings 682 // Use Enscript to colourise listings
683 683
684 function hideRSS($myrep = 0) 684 function hideRSS($myrep = 0)
685 { 685 {
686 if (empty($myrep)) 686 if (empty($myrep))
687 $this->rss = false; 687 $this->rss = false;
688 else 688 else
689 { 689 {
690 $repo =& $this->findRepository($myrep); 690 $repo =& $this->findRepository($myrep);
691 $repo->hideRSS(); 691 $repo->hideRSS();
692 } 692 }
693 } 693 }
694   694  
695 function getHideRSS() 695 function getHideRSS()
696 { 696 {
697 return $this->rss; 697 return $this->rss;
698 } 698 }
699   699  
700 // }}} 700 // }}}
701   701  
702 // {{{ Downloads 702 // {{{ Downloads
703   703  
704 // allowDownload 704 // allowDownload
705 // 705 //
706 // Allow download of tarballs 706 // Allow download of tarballs
707 707
708 function allowDownload($myrep = 0) 708 function allowDownload($myrep = 0)
709 { 709 {
710 if (empty($myrep)) 710 if (empty($myrep))
711 $this->allowDownload = true; 711 $this->allowDownload = true;
712 else 712 else
713 { 713 {
714 $repo =& $this->findRepository($myrep); 714 $repo =& $this->findRepository($myrep);
715 $repo->allowDownload(); 715 $repo->allowDownload();
716 } 716 }
717 } 717 }
718   718  
719 function disallowDownload($myrep = 0) 719 function disallowDownload($myrep = 0)
720 { 720 {
721 if (empty($myrep)) 721 if (empty($myrep))
722 $this->allowDownload = false; 722 $this->allowDownload = false;
723 else 723 else
724 { 724 {
725 $repo =& $this->findRepository($myrep); 725 $repo =& $this->findRepository($myrep);
726 $repo->disallowDownload(); 726 $repo->disallowDownload();
727 } 727 }
728 } 728 }
729   729  
730 function getAllowDownload() 730 function getAllowDownload()
731 { 731 {
732 return $this->allowDownload; 732 return $this->allowDownload;
733 } 733 }
734   734  
735 function setMinDownloadLevel($level, $myrep = 0) 735 function setMinDownloadLevel($level, $myrep = 0)
736 { 736 {
737 if (empty($myrep)) 737 if (empty($myrep))
738 $this->minDownloadLevel = $level; 738 $this->minDownloadLevel = $level;
739 else 739 else
740 { 740 {
741 $repo =& $this->findRepository($myrep); 741 $repo =& $this->findRepository($myrep);
742 $repo->setMinDownloadLevel($level); 742 $repo->setMinDownloadLevel($level);
743 } 743 }
744 } 744 }
745   745  
746 function getMinDownloadLevel() 746 function getMinDownloadLevel()
747 { 747 {
748 return $this->minDownloadLevel; 748 return $this->minDownloadLevel;
749 } 749 }
750   750  
751 function addAllowedDownloadException($path, $myrep = 0) 751 function addAllowedDownloadException($path, $myrep = 0)
752 { 752 {
753 if ($path{strlen($path) - 1} != "/") 753 if ($path{strlen($path) - 1} != "/")
754 $path .= "/"; 754 $path .= "/";
755 755
756 if (empty($myrep)) 756 if (empty($myrep))
757 $this->allowedExceptions[] = $path; 757 $this->allowedExceptions[] = $path;
758 else 758 else
759 { 759 {
760 $repo =& $this->findRepository($myrep); 760 $repo =& $this->findRepository($myrep);
761 $repo->addAllowedDownloadException($path); 761 $repo->addAllowedDownloadException($path);
762 } 762 }
763 } 763 }
764   764  
765 function addDisallowedDownloadException($path, $myrep = 0) 765 function addDisallowedDownloadException($path, $myrep = 0)
766 { 766 {
767 if ($path{strlen($path) - 1} != "/") 767 if ($path{strlen($path) - 1} != "/")
768 $path .= "/"; 768 $path .= "/";
769 769
770 if (empty($myrep)) 770 if (empty($myrep))
771 $this->disallowedExceptions[] = $path; 771 $this->disallowedExceptions[] = $path;
772 else 772 else
773 { 773 {
774 $repo =& $this->findRepository($myrep); 774 $repo =& $this->findRepository($myrep);
775 $repo->addDisallowedDownloadException($path); 775 $repo->addDisallowedDownloadException($path);
776 } 776 }
777 } 777 }
778 778
779 function findException($path, $exceptions) 779 function findException($path, $exceptions)
780 { 780 {
781 foreach ($exceptions As $key => $exc) 781 foreach ($exceptions As $key => $exc)
782 { 782 {
783 if (strncmp($exc, $path, strlen($exc)) == 0) 783 if (strncmp($exc, $path, strlen($exc)) == 0)
784 return true; 784 return true;
785 } 785 }
786 786
787 return false; 787 return false;
788 } 788 }
789 789
790 // }}} 790 // }}}
791   791  
792 // {{{ getURL 792 // {{{ getURL
793 // 793 //
794 // Get the URL to a path name based on the current config 794 // Get the URL to a path name based on the current config
795 795
796 function getURL($rep, $path, $op) 796 function getURL($rep, $path, $op)
797 { 797 {
798 $base = $_SERVER["SCRIPT_NAME"]; 798 $base = $_SERVER["SCRIPT_NAME"];
799 799
800 if ($this->multiViews) 800 if ($this->multiViews)
801 { 801 {
802 // Remove the .php 802 // Remove the .php
803 if (eregi(".php$", $base)) 803 if (eregi(".php$", $base))
804 { 804 {
805 // Remove the .php 805 // Remove the .php
806 $base = substr($base, 0, -4); 806 $base = substr($base, 0, -4);
807 } 807 }
808 808
809 if ($path && $path{0} != "/") $path = "/".$path; 809 if ($path && $path{0} != "/") $path = "/".$path;
810 810
811 $url = $base; 811 $url = $base;
812 812
813 if (is_object($rep)) 813 if (is_object($rep))
814 { 814 {
815 $url .= "/".$rep->getDisplayName().str_replace('%2F', '/', urlencode($path)); 815 $url .= "/".$rep->getDisplayName().str_replace('%2F', '/', urlencode($path));
816 816
817 if ($op != "dir" && $op != "file") 817 if ($op != "dir" && $op != "file")
818 $url .= "?op=$op&amp;"; 818 $url .= "?op=$op&amp;";
819 else 819 else
820 $url .= "?"; 820 $url .= "?";
821 } 821 }
822 822
823 return $url; 823 return $url;
824 } 824 }
825 else 825 else
826 { 826 {
827 switch ($op) 827 switch ($op)
828 { 828 {
829 case "dir": 829 case "dir":
830 $fname = "listing.php"; 830 $fname = "listing.php";
831 break; 831 break;
832 832
833 case "file": 833 case "file":
834 $fname = "filedetails.php"; 834 $fname = "filedetails.php";
835 break; 835 break;
836   836  
837 case "log": 837 case "log":
838 $fname = "log.php"; 838 $fname = "log.php";
839 break; 839 break;
840   840  
841 case "diff": 841 case "diff":
842 $fname = "diff.php"; 842 $fname = "diff.php";
843 break; 843 break;
844   844  
845 case "blame": 845 case "blame":
846 $fname = "blame.php"; 846 $fname = "blame.php";
847 break; 847 break;
848   848  
849 case "form": 849 case "form":
850 $fname = "form.php"; 850 $fname = "form.php";
851 break; 851 break;
852   852  
853 case "rss": 853 case "rss":
854 $fname = "rss.php"; 854 $fname = "rss.php";
855 break; 855 break;
856   856  
857 case "dl": 857 case "dl":
858 $fname = "dl.php"; 858 $fname = "dl.php";
859 break; 859 break;
860   860  
861 case "comp": 861 case "comp":
862 $fname = "comp.php"; 862 $fname = "comp.php";
863 break; 863 break;
864 } 864 }
865   865  
866 if ($rep == -1) 866 # if ($rep == -1)
-   867 if (!is_object($rep))
867 return $fname."?path=".urlencode($path)."&amp;"; 868 return $fname."?path=".urlencode($path)."&amp;";
868 else 869 else
869 return $fname."?repname=".urlencode($rep->getDisplayName())."&amp;path=".urlencode($path)."&amp;"; 870 return $fname."?repname=".urlencode($rep->getDisplayName())."&amp;path=".urlencode($path)."&amp;";
870 } 871 }
871 } 872 }
872   873  
873 // }}} 874 // }}}
874   875  
875 // {{{ Paths and Commands 876 // {{{ Paths and Commands
876   877  
877 // setPath 878 // setPath
878 // 879 //
879 // Set the location of the given path 880 // Set the location of the given path
880 881
881 function setPath(&$var, $path, $name, $params = "") 882 function setPath(&$var, $path, $name, $params = "")
882 { 883 {
883 $lastchar = substr($path, -1, 1); 884 $lastchar = substr($path, -1, 1);
884 $isDir = ($lastchar == DIRECTORY_SEPARATOR || 885 $isDir = ($lastchar == DIRECTORY_SEPARATOR ||
885 $lastchar == "/" || 886 $lastchar == "/" ||
886 $lastchar == "\\"); 887 $lastchar == "\\");
887 888
888 if (!$isDir) 889 if (!$isDir)
889 { 890 {
890 $path .= DIRECTORY_SEPARATOR; 891 $path .= DIRECTORY_SEPARATOR;
891 } 892 }
892   893  
893 // On a windows machine we need to put spaces around the entire command 894 // On a windows machine we need to put spaces around the entire command
894 // to allow for spaces in the path 895 // to allow for spaces in the path
895 if ($this->serverIsWindows) 896 if ($this->serverIsWindows)
896 $var = "\"$path$name\""; 897 $var = "\"$path$name\"";
897 else 898 else
898 $var = "$path$name"; 899 $var = "$path$name";
899 900
900 $var .= " ".$params; 901 $var .= " ".$params;
901 } 902 }
902   903  
903 // setSVNCommandPath 904 // setSVNCommandPath
904 // 905 //
905 // Define the location of the svn and svnlook commands 906 // Define the location of the svn and svnlook commands
906 907
907 function setSVNCommandPath($path) 908 function setSVNCommandPath($path)
908 { 909 {
909 $this->setPath($this->svn, $path, "svn", "--non-interactive --config-dir /tmp"); 910 $this->setPath($this->svn, $path, "svn", "--non-interactive --config-dir /tmp");
910 $this->setPath($this->svn_noparams, $path, "svn", " --config-dir /tmp"); 911 $this->setPath($this->svn_noparams, $path, "svn", " --config-dir /tmp");
911 $this->setPath($this->svnlook, $path, "svnlook"); 912 $this->setPath($this->svnlook, $path, "svnlook");
912 } 913 }
913 914
914 function getSvnCommand() 915 function getSvnCommand()
915 { 916 {
916 return $this->svn; 917 return $this->svn;
917 } 918 }
918   919  
919 function getCleanSvnCommand() 920 function getCleanSvnCommand()
920 { 921 {
921 return $this->svn_noparams; 922 return $this->svn_noparams;
922 } 923 }
923   924  
924 function getSvnlookCommand() 925 function getSvnlookCommand()
925 { 926 {
926 return $this->svnlook; 927 return $this->svnlook;
927 } 928 }
928 929
929 // setDiffPath 930 // setDiffPath
930 // 931 //
931 // Define the location of the diff command 932 // Define the location of the diff command
932 933
933 function setDiffPath($path) 934 function setDiffPath($path)
934 { 935 {
935 $this->setPath($this->diff, $path, "diff"); 936 $this->setPath($this->diff, $path, "diff");
936 } 937 }
937   938  
938 function getDiffCommand() 939 function getDiffCommand()
939 { 940 {
940 return $this->diff; 941 return $this->diff;
941 } 942 }
942   943  
943 // setEnscriptPath 944 // setEnscriptPath
944 // 945 //
945 // Define the location of the enscript command 946 // Define the location of the enscript command
946 947
947 function setEnscriptPath($path) 948 function setEnscriptPath($path)
948 { 949 {
949 $this->setPath($this->enscript, $path, "enscript"); 950 $this->setPath($this->enscript, $path, "enscript");
950 } 951 }
951   952  
952 function getEnscriptCommand() 953 function getEnscriptCommand()
953 { 954 {
954 return $this->enscript; 955 return $this->enscript;
955 } 956 }
956   957  
957 // setSedPath 958 // setSedPath
958 // 959 //
959 // Define the location of the sed command 960 // Define the location of the sed command
960 961
961 function setSedPath($path) 962 function setSedPath($path)
962 { 963 {
963 $this->setPath($this->sed, $path, "sed"); 964 $this->setPath($this->sed, $path, "sed");
964 } 965 }
965 966
966 function getSedCommand() 967 function getSedCommand()
967 { 968 {
968 return $this->sed; 969 return $this->sed;
969 } 970 }
970   971  
971 // setTarPath 972 // setTarPath
972 // 973 //
973 // Define the location of the tar command 974 // Define the location of the tar command
974 975
975 function setTarPath($path) 976 function setTarPath($path)
976 { 977 {
977 $this->setPath($this->tar, $path, "tar"); 978 $this->setPath($this->tar, $path, "tar");
978 } 979 }
979 980
980 function getTarCommand() 981 function getTarCommand()
981 { 982 {
982 return $this->tar; 983 return $this->tar;
983 } 984 }
984   985  
985 // setGzipPath 986 // setGzipPath
986 // 987 //
987 // Define the location of the GZip command 988 // Define the location of the GZip command
988 989
989 function setGzipPath($path) 990 function setGzipPath($path)
990 { 991 {
991 $this->setPath($this->gzip, $path, "gzip"); 992 $this->setPath($this->gzip, $path, "gzip");
992 } 993 }
993 994
994 function getGzipCommand() 995 function getGzipCommand()
995 { 996 {
996 return $this->gzip; 997 return $this->gzip;
997 } 998 }
998   999  
999 // Templates 1000 // Templates
1000 1001
1001 function setTemplatePath($path, $myrep = 0) 1002 function setTemplatePath($path, $myrep = 0)
1002 { 1003 {
1003 if (empty($myrep)) 1004 if (empty($myrep))
1004 { 1005 {
1005 $lastchar = substr($path, -1, 1); 1006 $lastchar = substr($path, -1, 1);
1006 if (!($lastchar == DIRECTORY_SEPARATOR || 1007 if (!($lastchar == DIRECTORY_SEPARATOR ||
1007 $lastchar == '/' || 1008 $lastchar == '/' ||
1008 $lastchar == '\\')) 1009 $lastchar == '\\'))
1009 $path .= DIRECTORY_SEPARATOR; 1010 $path .= DIRECTORY_SEPARATOR;
1010   1011  
1011 $this->templatePath = $path; 1012 $this->templatePath = $path;
1012 } 1013 }
1013 else 1014 else
1014 { 1015 {
1015 $repo =& $this->findRepository($myrep); 1016 $repo =& $this->findRepository($myrep);
1016 $repo->setTemplatePath($path); 1017 $repo->setTemplatePath($path);
1017 } 1018 }
1018 } 1019 }
1019   1020  
1020 function getTemplatePath() 1021 function getTemplatePath()
1021 { 1022 {
1022 return $this->templatePath; 1023 return $this->templatePath;
1023 } 1024 }
1024   1025  
1025 // PHP Compat file (from PEAR) 1026 // PHP Compat file (from PEAR)
1026   1027  
1027 function setPHPCompatPath($path) 1028 function setPHPCompatPath($path)
1028 { 1029 {
1029 $this->setPath($this->phpCompatPath, $path, 'Compat.php'); 1030 $this->setPath($this->phpCompatPath, $path, 'Compat.php');
1030 } 1031 }
1031   1032  
1032 function getPHPCompatFile() 1033 function getPHPCompatFile()
1033 { 1034 {
1034 return trim($this->phpCompatPath); 1035 return trim($this->phpCompatPath);
1035 } 1036 }
1036   1037  
1037 // }}} 1038 // }}}
1038   1039  
1039 // {{{ parentPath 1040 // {{{ parentPath
1040 // 1041 //
1041 // Automatically set up the repositories based on a parent path 1042 // Automatically set up the repositories based on a parent path
1042 1043
1043 function parentPath($path, $group = NULL) 1044 function parentPath($path, $group = NULL)
1044 { 1045 {
1045 if ($handle = @opendir($path)) 1046 if ($handle = @opendir($path))
1046 { 1047 {
1047 // For each file... 1048 // For each file...
1048 while (false !== ($file = readdir($handle))) 1049 while (false !== ($file = readdir($handle)))
1049 { 1050 {
1050 // That's also a non hidden directory 1051 // That's also a non hidden directory
1051 if (is_dir($path.DIRECTORY_SEPARATOR.$file) && $file{0} != ".") 1052 if (is_dir($path.DIRECTORY_SEPARATOR.$file) && $file{0} != ".")
1052 { 1053 {
1053 // And that contains a db directory (in an attempt to not include 1054 // And that contains a db directory (in an attempt to not include
1054 // non svn repositories. 1055 // non svn repositories.
1055 1056
1056 if (is_dir($path.DIRECTORY_SEPARATOR.$file.DIRECTORY_SEPARATOR."db")) 1057 if (is_dir($path.DIRECTORY_SEPARATOR.$file.DIRECTORY_SEPARATOR."db"))
1057 { 1058 {
1058 // We add the repository to the list 1059 // We add the repository to the list
1059 $this->addRepository($file, "file:///".$path.DIRECTORY_SEPARATOR.$file, $group); 1060 $this->addRepository($file, "file:///".$path.DIRECTORY_SEPARATOR.$file, $group);
1060 } 1061 }
1061 } 1062 }
1062 } 1063 }
1063 closedir($handle); 1064 closedir($handle);
1064 } 1065 }
1065   1066  
1066 // Sort the repositories into alphabetical order 1067 // Sort the repositories into alphabetical order
1067 1068
1068 if (!empty($this->_repositories)) 1069 if (!empty($this->_repositories))
1069 usort($this->_repositories, "cmpReps"); 1070 usort($this->_repositories, "cmpReps");
1070 } 1071 }
1071   1072  
1072 // }}} 1073 // }}}
1073 1074
1074 // {{{ Encoding functions 1075 // {{{ Encoding functions
1075 1076
1076 function setInputEncoding($systemEnc) 1077 function setInputEncoding($systemEnc)
1077 { 1078 {
1078 $this->inputEnc = $systemEnc; 1079 $this->inputEnc = $systemEnc;
1079 1080
1080 if (!isset($this->contentEnc)) 1081 if (!isset($this->contentEnc))
1081 $this->contentEnc = $systemEnc; 1082 $this->contentEnc = $systemEnc;
1082 } 1083 }
1083 1084
1084 function getInputEncoding() 1085 function getInputEncoding()
1085 { 1086 {
1086 return $this->inputEnc; 1087 return $this->inputEnc;
1087 } 1088 }
1088   1089  
1089 function setContentEncoding($contentEnc, $myrep = 0) 1090 function setContentEncoding($contentEnc, $myrep = 0)
1090 { 1091 {
1091 if (empty($myrep)) 1092 if (empty($myrep))
1092 $this->contentEnc = $contentEnc; 1093 $this->contentEnc = $contentEnc;
1093 else 1094 else
1094 { 1095 {
1095 $repo =& $this->findRepository($myrep); 1096 $repo =& $this->findRepository($myrep);
1096 $repo->setContentEncoding($contentEnc); 1097 $repo->setContentEncoding($contentEnc);
1097 } 1098 }
1098 } 1099 }
1099 1100
1100 function getContentEncoding() 1101 function getContentEncoding()
1101 { 1102 {
1102 return $this->contentEnc; 1103 return $this->contentEnc;
1103 } 1104 }
1104   1105  
1105 // }}} 1106 // }}}
1106   1107  
1107 // {{{ Tab expansion functions 1108 // {{{ Tab expansion functions
1108 1109
1109 function expandTabsBy($sp, $myrep = 0) 1110 function expandTabsBy($sp, $myrep = 0)
1110 { 1111 {
1111 if (empty($myrep)) 1112 if (empty($myrep))
1112 $this->spaces = $sp; 1113 $this->spaces = $sp;
1113 else 1114 else
1114 { 1115 {
1115 $repo =& $this->findRepository($myrep); 1116 $repo =& $this->findRepository($myrep);
1116 $repo->expandTabsBy($sp); 1117 $repo->expandTabsBy($sp);
1117 } 1118 }
1118 } 1119 }
1119 1120
1120 function getExpandTabsBy() 1121 function getExpandTabsBy()
1121 { 1122 {
1122 return $this->spaces; 1123 return $this->spaces;
1123 } 1124 }
1124   1125  
1125 // }}} 1126 // }}}
1126   1127  
1127 // {{{ Misc settings 1128 // {{{ Misc settings
1128 1129
1129 function ignoreSvnMimeTypes() 1130 function ignoreSvnMimeTypes()
1130 { 1131 {
1131 $this->ignoreSvnMimeTypes = true; 1132 $this->ignoreSvnMimeTypes = true;
1132 } 1133 }
1133   1134  
1134 function getIgnoreSvnMimeTypes() 1135 function getIgnoreSvnMimeTypes()
1135 { 1136 {
1136 return $this->ignoreSvnMimeTypes; 1137 return $this->ignoreSvnMimeTypes;
1137 } 1138 }
1138   1139  
1139 function ignoreWebSVNContentTypes() 1140 function ignoreWebSVNContentTypes()
1140 { 1141 {
1141 $this->ignoreWebSVNContentTypes = true; 1142 $this->ignoreWebSVNContentTypes = true;
1142 } 1143 }
1143   1144  
1144 function getIgnoreWebSVNContentTypes() 1145 function getIgnoreWebSVNContentTypes()
1145 { 1146 {
1146 return $this->ignoreWebSVNContentTypes; 1147 return $this->ignoreWebSVNContentTypes;
1147 } 1148 }
1148   1149  
1149 function useBugtraqProperties($myrep = 0) 1150 function useBugtraqProperties($myrep = 0)
1150 { 1151 {
1151 if (empty($myrep)) 1152 if (empty($myrep))
1152 $this->bugtraq = true; 1153 $this->bugtraq = true;
1153 else 1154 else
1154 { 1155 {
1155 $repo =& $this->findRepository($myrep); 1156 $repo =& $this->findRepository($myrep);
1156 $repo->useBugtraqProperties(); 1157 $repo->useBugtraqProperties();
1157 } 1158 }
1158 } 1159 }
1159 1160
1160 function getBugtraq() 1161 function getBugtraq()
1161 { 1162 {
1162 return $this->bugtraq; 1163 return $this->bugtraq;
1163 } 1164 }
1164   1165  
1165 function useAuthenticationFile($file, $myrep = 0) 1166 function useAuthenticationFile($file, $myrep = 0)
1166 { 1167 {
1167 if (empty($myrep)) 1168 if (empty($myrep))
1168 { 1169 {
1169 if (is_readable($file)) 1170 if (is_readable($file))
1170 $this->auth = new Authentication($file); 1171 $this->auth = new Authentication($file);
1171 else 1172 else
1172 { 1173 {
1173 echo "Unable to read authentication file '$file'"; 1174 echo "Unable to read authentication file '$file'";
1174 exit; 1175 exit;
1175 } 1176 }
1176 } 1177 }
1177 else 1178 else
1178 { 1179 {
1179 $repo =& $this->findRepository($myrep); 1180 $repo =& $this->findRepository($myrep);
1180 $repo->useAuthenticationFile($file); 1181 $repo->useAuthenticationFile($file);
1181 } 1182 }
1182 } 1183 }
1183 1184
1184 function &getAuth() 1185 function &getAuth()
1185 { 1186 {
1186 return $this->auth; 1187 return $this->auth;
1187 } 1188 }
1188   1189  
1189 function useTreeView() 1190 function useTreeView()
1190 { 1191 {
1191 $this->treeView = true; 1192 $this->treeView = true;
1192 } 1193 }
1193 1194
1194 function getUseTreeView() 1195 function getUseTreeView()
1195 { 1196 {
1196 return $this->treeView; 1197 return $this->treeView;
1197 } 1198 }
1198   1199  
1199 function useFlatView() 1200 function useFlatView()
1200 { 1201 {
1201 $this->treeView = false; 1202 $this->treeView = false;
1202 } 1203 }
1203   1204  
1204 function useTreeIndex($open) 1205 function useTreeIndex($open)
1205 { 1206 {
1206 $this->flatIndex = false; 1207 $this->flatIndex = false;
1207 $this->openTree = $open; 1208 $this->openTree = $open;
1208 } 1209 }
1209   1210  
1210 function getUseFlatIndex() 1211 function getUseFlatIndex()
1211 { 1212 {
1212 return $this->flatIndex; 1213 return $this->flatIndex;
1213 } 1214 }
1214   1215  
1215 function getOpenTree() 1216 function getOpenTree()
1216 { 1217 {
1217 return $this->openTree; 1218 return $this->openTree;
1218 } 1219 }
1219   1220  
1220 // setSubversionMajorVersion 1221 // setSubversionMajorVersion
1221 // 1222 //
1222 // Set subversion major version 1223 // Set subversion major version
1223 1224
1224 function setSubversionMajorVersion($subversionMajorVersion) 1225 function setSubversionMajorVersion($subversionMajorVersion)
1225 { 1226 {
1226 $this->subversionMajorVersion = $subversionMajorVersion; 1227 $this->subversionMajorVersion = $subversionMajorVersion;
1227 } 1228 }
1228   1229  
1229 function getSubversionMajorVersion() 1230 function getSubversionMajorVersion()
1230 { 1231 {
1231 return $this->subversionMajorVersion; 1232 return $this->subversionMajorVersion;
1232 } 1233 }
1233   1234  
1234 // setSubversionMinorVersion 1235 // setSubversionMinorVersion
1235 // 1236 //
1236 // Set subversion minor version 1237 // Set subversion minor version
1237 1238
1238 function setSubversionMinorVersion($subversionMinorVersion) 1239 function setSubversionMinorVersion($subversionMinorVersion)
1239 { 1240 {
1240 $this->subversionMinorVersion = $subversionMinorVersion; 1241 $this->subversionMinorVersion = $subversionMinorVersion;
1241 } 1242 }
1242 1243
1243 function getSubversionMinorVersion() 1244 function getSubversionMinorVersion()
1244 { 1245 {
1245 return $this->subversionMinorVersion; 1246 return $this->subversionMinorVersion;
1246 } 1247 }
1247   1248  
1248 // }}} 1249 // }}}
1249   1250  
1250 // {{{ Sort the repostories 1251 // {{{ Sort the repostories
1251 // 1252 //
1252 // This function sorts the repositories by group name. The contents of the 1253 // This function sorts the repositories by group name. The contents of the
1253 // group are left in there original order, which will either be sorted if the 1254 // group are left in there original order, which will either be sorted if the
1254 // group was added using the parentPath function, or defined for the order in 1255 // group was added using the parentPath function, or defined for the order in
1255 // which the repositories were included in the user's config file. 1256 // which the repositories were included in the user's config file.
1256 // 1257 //
1257 // Note that as of PHP 4.0.6 the usort command no longer preserves the order 1258 // Note that as of PHP 4.0.6 the usort command no longer preserves the order
1258 // of items that are considered equal (in our case, part of the same group). 1259 // of items that are considered equal (in our case, part of the same group).
1259 // The mergesort function preserves this order. 1260 // The mergesort function preserves this order.
1260 1261
1261 function sortByGroup() 1262 function sortByGroup()
1262 { 1263 {
1263 if (!empty($this->_repositories)) 1264 if (!empty($this->_repositories))
1264 mergesort($this->_repositories, "cmpGroups"); 1265 mergesort($this->_repositories, "cmpGroups");
1265 } 1266 }
1266   1267  
1267 // }}} 1268 // }}}
1268 } 1269 }
1269 ?> 1270 ?>