Rev 172 Rev 185
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 $cacheResults = false; 501 var $cacheResults = false;
501 var $multiViews = false; 502 var $multiViews = false;
502 var $useEnscript = false; 503 var $useEnscript = false;
503 var $allowDownload = false; 504 var $allowDownload = false;
504 var $minDownloadLevel = 0; 505 var $minDownloadLevel = 0;
505 var $allowedExceptions = array(); 506 var $allowedExceptions = array();
506 var $disallowedExceptions = array(); 507 var $disallowedExceptions = array();
507 var $rss = true; 508 var $rss = true;
508 var $spaces = 8; 509 var $spaces = 8;
509 var $bugtraq = false; 510 var $bugtraq = false;
510 var $auth = ""; 511 var $auth = "";
511 512
512 var $templatePath = "./templates/Standard/"; 513 var $templatePath = "./templates/Standard/";
513 var $phpCompatPath = './include/PHP/Compat.php'; 514 var $phpCompatPath = './include/PHP/Compat.php';
514   515  
515 var $ignoreSvnMimeTypes = false; 516 var $ignoreSvnMimeTypes = false;
516 var $ignoreWebSVNContentTypes = false; 517 var $ignoreWebSVNContentTypes = false;
517   518  
518 var $subversionMajorVersion = ""; 519 var $subversionMajorVersion = "";
519 var $subversionMinorVersion = ""; 520 var $subversionMinorVersion = "";
520   521  
521 // Default character encodings 522 // Default character encodings
522 var $inputEnc = ""; // Encoding of output returned from command line 523 var $inputEnc = ""; // Encoding of output returned from command line
523 var $contentEnc = ""; // Encoding of repository content 524 var $contentEnc = ""; // Encoding of repository content
524 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
525   526  
526 var $quote = "'"; 527 var $quote = "'";
-   528 var $pathSeparator = ":";
527   529  
528 var $_repositories; 530 var $_repositories;
529   531  
530 // }}} 532 // }}}
531   533  
532 // {{{ __construct() 534 // {{{ __construct()
533   535  
534 function Config() 536 function Config()
535 { 537 {
536 } 538 }
537   539  
538 // }}} 540 // }}}
539   541  
540 // {{{ Repository configuration 542 // {{{ Repository configuration
541 543
542 function addRepository($name, $url, $group = NULL, $username = NULL, $password = NULL) 544 function addRepository($name, $url, $group = NULL, $username = NULL, $password = NULL)
543 { 545 {
544 $url = str_replace(DIRECTORY_SEPARATOR, "/", $url); 546 $url = str_replace(DIRECTORY_SEPARATOR, "/", $url);
545 547
546 if ($url{strlen($url) - 1} == "/") 548 if ($url{strlen($url) - 1} == "/")
547 $url = substr($url, 0, -1); 549 $url = substr($url, 0, -1);
548 550
549 $svnName = substr($url, strrpos($url, "/") + 1); 551 $svnName = substr($url, strrpos($url, "/") + 1);
550 $this->_repositories[] = new Repository($name, $svnName, $url, $group, $username, $password); 552 $this->_repositories[] = new Repository($name, $svnName, $url, $group, $username, $password);
551 } 553 }
552   554  
553 function getRepositories() 555 function getRepositories()
554 { 556 {
555 return $this->_repositories; 557 return $this->_repositories;
556 } 558 }
557   559  
558 function &findRepository($name) 560 function &findRepository($name)
559 { 561 {
560 foreach ($this->_repositories as $index => $rep) 562 foreach ($this->_repositories as $index => $rep)
561 { 563 {
562 if (strcmp($rep->getDisplayName(), $name) == 0) 564 if (strcmp($rep->getDisplayName(), $name) == 0)
563 { 565 {
564 $repref =& $this->_repositories[$index]; 566 $repref =& $this->_repositories[$index];
565 return $repref; 567 return $repref;
566 } 568 }
567 } 569 }
568 570
569 print "ERROR: Unable to find repository '$name'"; 571 print "ERROR: Unable to find repository '$name'";
570 exit; 572 exit;
571 } 573 }
572   574  
573 // }}} 575 // }}}
574   576  
575 // {{{ setServerIsWindows 577 // {{{ setServerIsWindows
576 // 578 //
577 // The server is running on Windows 579 // The server is running on Windows
578 580
579 function setServerIsWindows() 581 function setServerIsWindows()
580 { 582 {
581 $this->serverIsWindows = true; 583 $this->serverIsWindows = true;
582 584
583 // Try to set the input encoding intelligently 585 // Try to set the input encoding intelligently
584 586
585 $cp = 0; 587 $cp = 0;
586 if ($cp = @shell_exec("CHCP")) 588 if ($cp = @shell_exec("CHCP"))
587 { 589 {
588 $cp = trim(substr($cp, strpos($cp, ":") + 1)); 590 $cp = trim(substr($cp, strpos($cp, ":") + 1));
589 settype($cp, "integer"); 591 settype($cp, "integer");
590 } 592 }
591 593
592 // Use the most sensible default value if that failed 594 // Use the most sensible default value if that failed
593 if ($cp == 0) $cp = 850; 595 if ($cp == 0) $cp = 850;
594 596
595 // 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
596 // 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.
597 $this->setInputEncoding("CP$cp", "iso-8859-1"); 599 $this->setInputEncoding("CP$cp", "iso-8859-1");
598 600
599 // On Windows machines, use double quotes around command line parameters 601 // On Windows machines, use double quotes around command line parameters
600 -  
601 $this->quote = '"'; 602 $this->quote = '"';
-   603
-   604 // On Windows, semicolon separates path entries in a list rather than colon.
-   605 $this->pathSeparator = ";";
-   606 }
-   607
-   608 // }}}
-   609
-   610 // {{{ setPHPCompatEnabled
-   611 //
-   612 // Used for PHP4
-   613  
-   614 function setPHPCompatEnabled() {
-   615 $this->phpCompatEnabled = true;
-   616 }
-   617
-   618 function isPHPCompatEnabled() {
-   619 return $this->phpCompatEnabled;
602 } 620 }
603   621  
604 // }}} 622 // }}}
605   623  
606 // {{{ Caching 624 // {{{ Caching
607   625  
608 // setCachingOn 626 // setCachingOn
609 // 627 //
610 // Set result caching on 628 // Set result caching on
611 629
612 function setCachingOn() 630 function setCachingOn()
613 { 631 {
614 $this->cacheResults = true; 632 $this->cacheResults = true;
615 } 633 }
616   634  
617 function isCachingOn() 635 function isCachingOn()
618 { 636 {
619 return $this->cacheResults; 637 return $this->cacheResults;
620 } 638 }
621   639  
622 // }}} 640 // }}}
623   641  
624 // {{{ MultiViews 642 // {{{ MultiViews
625   643  
626 // useMultiViews 644 // useMultiViews
627 // 645 //
628 // Use MultiViews to access the repository 646 // Use MultiViews to access the repository
629 647
630 function useMultiViews() 648 function useMultiViews()
631 { 649 {
632 $this->multiViews = true; 650 $this->multiViews = true;
633 } 651 }
634   652  
635 function getUseMultiViews() 653 function getUseMultiViews()
636 { 654 {
637 return $this->multiViews; 655 return $this->multiViews;
638 } 656 }
639   657  
640 // }}} 658 // }}}
641   659  
642 // {{{ Enscript 660 // {{{ Enscript
643   661  
644 // useEnscript 662 // useEnscript
645 // 663 //
646 // Use Enscript to colourise listings 664 // Use Enscript to colourise listings
647 665
648 function useEnscript() 666 function useEnscript()
649 { 667 {
650 $this->useEnscript = true; 668 $this->useEnscript = true;
651 } 669 }
652   670  
653 function getUseEnscript() 671 function getUseEnscript()
654 { 672 {
655 return $this->useEnscript; 673 return $this->useEnscript;
656 } 674 }
657   675  
658 // }}} 676 // }}}
659   677  
660 // {{{ RSS 678 // {{{ RSS
661   679  
662 // offerRSS 680 // offerRSS
663 // 681 //
664 // Use Enscript to colourise listings 682 // Use Enscript to colourise listings
665 683
666 function hideRSS($myrep = 0) 684 function hideRSS($myrep = 0)
667 { 685 {
668 if (empty($myrep)) 686 if (empty($myrep))
669 $this->rss = false; 687 $this->rss = false;
670 else 688 else
671 { 689 {
672 $repo =& $this->findRepository($myrep); 690 $repo =& $this->findRepository($myrep);
673 $repo->hideRSS(); 691 $repo->hideRSS();
674 } 692 }
675 } 693 }
676   694  
677 function getHideRSS() 695 function getHideRSS()
678 { 696 {
679 return $this->rss; 697 return $this->rss;
680 } 698 }
681   699  
682 // }}} 700 // }}}
683   701  
684 // {{{ Downloads 702 // {{{ Downloads
685   703  
686 // allowDownload 704 // allowDownload
687 // 705 //
688 // Allow download of tarballs 706 // Allow download of tarballs
689 707
690 function allowDownload($myrep = 0) 708 function allowDownload($myrep = 0)
691 { 709 {
692 if (empty($myrep)) 710 if (empty($myrep))
693 $this->allowDownload = true; 711 $this->allowDownload = true;
694 else 712 else
695 { 713 {
696 $repo =& $this->findRepository($myrep); 714 $repo =& $this->findRepository($myrep);
697 $repo->allowDownload(); 715 $repo->allowDownload();
698 } 716 }
699 } 717 }
700   718  
701 function disallowDownload($myrep = 0) 719 function disallowDownload($myrep = 0)
702 { 720 {
703 if (empty($myrep)) 721 if (empty($myrep))
704 $this->allowDownload = false; 722 $this->allowDownload = false;
705 else 723 else
706 { 724 {
707 $repo =& $this->findRepository($myrep); 725 $repo =& $this->findRepository($myrep);
708 $repo->disallowDownload(); 726 $repo->disallowDownload();
709 } 727 }
710 } 728 }
711   729  
712 function getAllowDownload() 730 function getAllowDownload()
713 { 731 {
714 return $this->allowDownload; 732 return $this->allowDownload;
715 } 733 }
716   734  
717 function setMinDownloadLevel($level, $myrep = 0) 735 function setMinDownloadLevel($level, $myrep = 0)
718 { 736 {
719 if (empty($myrep)) 737 if (empty($myrep))
720 $this->minDownloadLevel = $level; 738 $this->minDownloadLevel = $level;
721 else 739 else
722 { 740 {
723 $repo =& $this->findRepository($myrep); 741 $repo =& $this->findRepository($myrep);
724 $repo->setMinDownloadLevel($level); 742 $repo->setMinDownloadLevel($level);
725 } 743 }
726 } 744 }
727   745  
728 function getMinDownloadLevel() 746 function getMinDownloadLevel()
729 { 747 {
730 return $this->minDownloadLevel; 748 return $this->minDownloadLevel;
731 } 749 }
732   750  
733 function addAllowedDownloadException($path, $myrep = 0) 751 function addAllowedDownloadException($path, $myrep = 0)
734 { 752 {
735 if ($path{strlen($path) - 1} != "/") 753 if ($path{strlen($path) - 1} != "/")
736 $path .= "/"; 754 $path .= "/";
737 755
738 if (empty($myrep)) 756 if (empty($myrep))
739 $this->allowedExceptions[] = $path; 757 $this->allowedExceptions[] = $path;
740 else 758 else
741 { 759 {
742 $repo =& $this->findRepository($myrep); 760 $repo =& $this->findRepository($myrep);
743 $repo->addAllowedDownloadException($path); 761 $repo->addAllowedDownloadException($path);
744 } 762 }
745 } 763 }
746   764  
747 function addDisallowedDownloadException($path, $myrep = 0) 765 function addDisallowedDownloadException($path, $myrep = 0)
748 { 766 {
749 if ($path{strlen($path) - 1} != "/") 767 if ($path{strlen($path) - 1} != "/")
750 $path .= "/"; 768 $path .= "/";
751 769
752 if (empty($myrep)) 770 if (empty($myrep))
753 $this->disallowedExceptions[] = $path; 771 $this->disallowedExceptions[] = $path;
754 else 772 else
755 { 773 {
756 $repo =& $this->findRepository($myrep); 774 $repo =& $this->findRepository($myrep);
757 $repo->addDisallowedDownloadException($path); 775 $repo->addDisallowedDownloadException($path);
758 } 776 }
759 } 777 }
760 778
761 function findException($path, $exceptions) 779 function findException($path, $exceptions)
762 { 780 {
763 foreach ($exceptions As $key => $exc) 781 foreach ($exceptions As $key => $exc)
764 { 782 {
765 if (strncmp($exc, $path, strlen($exc)) == 0) 783 if (strncmp($exc, $path, strlen($exc)) == 0)
766 return true; 784 return true;
767 } 785 }
768 786
769 return false; 787 return false;
770 } 788 }
771 789
772 // }}} 790 // }}}
773   791  
774 // {{{ getURL 792 // {{{ getURL
775 // 793 //
776 // 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
777 795
778 function getURL($rep, $path, $op) 796 function getURL($rep, $path, $op)
779 { 797 {
780 $base = $_SERVER["SCRIPT_NAME"]; 798 $base = $_SERVER["SCRIPT_NAME"];
781 799
782 if ($this->multiViews) 800 if ($this->multiViews)
783 { 801 {
784 // Remove the .php 802 // Remove the .php
785 if (eregi(".php$", $base)) 803 if (eregi(".php$", $base))
786 { 804 {
787 // Remove the .php 805 // Remove the .php
788 $base = substr($base, 0, -4); 806 $base = substr($base, 0, -4);
789 } 807 }
790 808
791 if ($path && $path{0} != "/") $path = "/".$path; 809 if ($path && $path{0} != "/") $path = "/".$path;
792 810
793 $url = $base; 811 $url = $base;
794 812
795 if (is_object($rep)) 813 if (is_object($rep))
796 { 814 {
797 $url .= "/".$rep->getDisplayName().str_replace('%2F', '/', urlencode($path)); 815 $url .= "/".$rep->getDisplayName().str_replace('%2F', '/', urlencode($path));
798 816
799 if ($op != "dir" && $op != "file") 817 if ($op != "dir" && $op != "file")
800 $url .= "?op=$op&amp;"; 818 $url .= "?op=$op&amp;";
801 else 819 else
802 $url .= "?"; 820 $url .= "?";
803 } 821 }
804 822
805 return $url; 823 return $url;
806 } 824 }
807 else 825 else
808 { 826 {
809 switch ($op) 827 switch ($op)
810 { 828 {
811 case "dir": 829 case "dir":
812 $fname = "listing.php"; 830 $fname = "listing.php";
813 break; 831 break;
814 832
815 case "file": 833 case "file":
816 $fname = "filedetails.php"; 834 $fname = "filedetails.php";
817 break; 835 break;
818   836  
819 case "log": 837 case "log":
820 $fname = "log.php"; 838 $fname = "log.php";
821 break; 839 break;
822   840  
823 case "diff": 841 case "diff":
824 $fname = "diff.php"; 842 $fname = "diff.php";
825 break; 843 break;
826   844  
827 case "blame": 845 case "blame":
828 $fname = "blame.php"; 846 $fname = "blame.php";
829 break; 847 break;
830   848  
831 case "form": 849 case "form":
832 $fname = "form.php"; 850 $fname = "form.php";
833 break; 851 break;
834   852  
835 case "rss": 853 case "rss":
836 $fname = "rss.php"; 854 $fname = "rss.php";
837 break; 855 break;
838   856  
839 case "dl": 857 case "dl":
840 $fname = "dl.php"; 858 $fname = "dl.php";
841 break; 859 break;
842   860  
843 case "comp": 861 case "comp":
844 $fname = "comp.php"; 862 $fname = "comp.php";
845 break; 863 break;
846 } 864 }
847   865  
848 if ($rep == -1) 866 if ($rep == -1)
849 return $fname."?path=".urlencode($path)."&amp;"; 867 return $fname."?path=".urlencode($path)."&amp;";
850 else 868 else
851 return $fname."?repname=".urlencode($rep->getDisplayName())."&amp;path=".urlencode($path)."&amp;"; 869 return $fname."?repname=".urlencode($rep->getDisplayName())."&amp;path=".urlencode($path)."&amp;";
852 } 870 }
853 } 871 }
854   872  
855 // }}} 873 // }}}
856   874  
857 // {{{ Paths and Commands 875 // {{{ Paths and Commands
858   876  
859 // setPath 877 // setPath
860 // 878 //
861 // Set the location of the given path 879 // Set the location of the given path
862 880
863 function setPath(&$var, $path, $name, $params = "") 881 function setPath(&$var, $path, $name, $params = "")
864 { 882 {
865 $lastchar = substr($path, -1, 1); 883 $lastchar = substr($path, -1, 1);
866 $isDir = ($lastchar == DIRECTORY_SEPARATOR || 884 $isDir = ($lastchar == DIRECTORY_SEPARATOR ||
867 $lastchar == "/" || 885 $lastchar == "/" ||
868 $lastchar == "\\"); 886 $lastchar == "\\");
869 887
870 if (!$isDir) 888 if (!$isDir)
871 { 889 {
872 $path .= DIRECTORY_SEPARATOR; 890 $path .= DIRECTORY_SEPARATOR;
873 } 891 }
874   892  
875 // On a windows machine we need to put spaces around the entire command 893 // On a windows machine we need to put spaces around the entire command
876 // to allow for spaces in the path 894 // to allow for spaces in the path
877 if ($this->serverIsWindows) 895 if ($this->serverIsWindows)
878 $var = "\"$path$name\""; 896 $var = "\"$path$name\"";
879 else 897 else
880 $var = "$path$name"; 898 $var = "$path$name";
881 899
882 $var .= " ".$params; 900 $var .= " ".$params;
883 } 901 }
884   902  
885 // setSVNCommandPath 903 // setSVNCommandPath
886 // 904 //
887 // Define the location of the svn and svnlook commands 905 // Define the location of the svn and svnlook commands
888 906
889 function setSVNCommandPath($path) 907 function setSVNCommandPath($path)
890 { 908 {
891 $this->setPath($this->svn, $path, "svn", "--non-interactive --config-dir /tmp"); 909 $this->setPath($this->svn, $path, "svn", "--non-interactive --config-dir /tmp");
892 $this->setPath($this->svn_noparams, $path, "svn", " --config-dir /tmp"); 910 $this->setPath($this->svn_noparams, $path, "svn", " --config-dir /tmp");
893 $this->setPath($this->svnlook, $path, "svnlook"); 911 $this->setPath($this->svnlook, $path, "svnlook");
894 } 912 }
895 913
896 function getSvnCommand() 914 function getSvnCommand()
897 { 915 {
898 return $this->svn; 916 return $this->svn;
899 } 917 }
900   918  
901 function getCleanSvnCommand() 919 function getCleanSvnCommand()
902 { 920 {
903 return $this->svn_noparams; 921 return $this->svn_noparams;
904 } 922 }
905   923  
906 function getSvnlookCommand() 924 function getSvnlookCommand()
907 { 925 {
908 return $this->svnlook; 926 return $this->svnlook;
909 } 927 }
910 928
911 // setDiffPath 929 // setDiffPath
912 // 930 //
913 // Define the location of the diff command 931 // Define the location of the diff command
914 932
915 function setDiffPath($path) 933 function setDiffPath($path)
916 { 934 {
917 $this->setPath($this->diff, $path, "diff"); 935 $this->setPath($this->diff, $path, "diff");
918 } 936 }
919   937  
920 function getDiffCommand() 938 function getDiffCommand()
921 { 939 {
922 return $this->diff; 940 return $this->diff;
923 } 941 }
924   942  
925 // setEnscriptPath 943 // setEnscriptPath
926 // 944 //
927 // Define the location of the enscript command 945 // Define the location of the enscript command
928 946
929 function setEnscriptPath($path) 947 function setEnscriptPath($path)
930 { 948 {
931 $this->setPath($this->enscript, $path, "enscript"); 949 $this->setPath($this->enscript, $path, "enscript");
932 } 950 }
933   951  
934 function getEnscriptCommand() 952 function getEnscriptCommand()
935 { 953 {
936 return $this->enscript; 954 return $this->enscript;
937 } 955 }
938   956  
939 // setSedPath 957 // setSedPath
940 // 958 //
941 // Define the location of the sed command 959 // Define the location of the sed command
942 960
943 function setSedPath($path) 961 function setSedPath($path)
944 { 962 {
945 $this->setPath($this->sed, $path, "sed"); 963 $this->setPath($this->sed, $path, "sed");
946 } 964 }
947 965
948 function getSedCommand() 966 function getSedCommand()
949 { 967 {
950 return $this->sed; 968 return $this->sed;
951 } 969 }
952   970  
953 // setTarPath 971 // setTarPath
954 // 972 //
955 // Define the location of the tar command 973 // Define the location of the tar command
956 974
957 function setTarPath($path) 975 function setTarPath($path)
958 { 976 {
959 $this->setPath($this->tar, $path, "tar"); 977 $this->setPath($this->tar, $path, "tar");
960 } 978 }
961 979
962 function getTarCommand() 980 function getTarCommand()
963 { 981 {
964 return $this->tar; 982 return $this->tar;
965 } 983 }
966   984  
967 // setGzipPath 985 // setGzipPath
968 // 986 //
969 // Define the location of the GZip command 987 // Define the location of the GZip command
970 988
971 function setGzipPath($path) 989 function setGzipPath($path)
972 { 990 {
973 $this->setPath($this->gzip, $path, "gzip"); 991 $this->setPath($this->gzip, $path, "gzip");
974 } 992 }
975 993
976 function getGzipCommand() 994 function getGzipCommand()
977 { 995 {
978 return $this->gzip; 996 return $this->gzip;
979 } 997 }
980   998  
981 // Templates 999 // Templates
982 1000
983 function setTemplatePath($path, $myrep = 0) 1001 function setTemplatePath($path, $myrep = 0)
984 { 1002 {
985 if (empty($myrep)) 1003 if (empty($myrep))
986 { 1004 {
987 $lastchar = substr($path, -1, 1); 1005 $lastchar = substr($path, -1, 1);
988 if (!($lastchar == DIRECTORY_SEPARATOR || 1006 if (!($lastchar == DIRECTORY_SEPARATOR ||
989 $lastchar == '/' || 1007 $lastchar == '/' ||
990 $lastchar == '\\')) 1008 $lastchar == '\\'))
991 $path .= DIRECTORY_SEPARATOR; 1009 $path .= DIRECTORY_SEPARATOR;
992   1010  
993 $this->templatePath = $path; 1011 $this->templatePath = $path;
994 } 1012 }
995 else 1013 else
996 { 1014 {
997 $repo =& $this->findRepository($myrep); 1015 $repo =& $this->findRepository($myrep);
998 $repo->setTemplatePath($path); 1016 $repo->setTemplatePath($path);
999 } 1017 }
1000 } 1018 }
1001   1019  
1002 function getTemplatePath() 1020 function getTemplatePath()
1003 { 1021 {
1004 return $this->templatePath; 1022 return $this->templatePath;
1005 } 1023 }
1006   1024  
1007 // PHP Compat file (from PEAR) 1025 // PHP Compat file (from PEAR)
1008   1026  
1009 function setPHPCompatPath($path) 1027 function setPHPCompatPath($path)
1010 { 1028 {
1011 $this->setPath($this->phpCompatPath, $path, 'Compat.php'); 1029 $this->setPath($this->phpCompatPath, $path, 'Compat.php');
1012 } 1030 }
1013   1031  
1014 function getPHPCompatFile() 1032 function getPHPCompatFile()
1015 { 1033 {
1016 return trim($this->phpCompatPath); 1034 return trim($this->phpCompatPath);
1017 } 1035 }
1018   1036  
1019 // }}} 1037 // }}}
1020   1038  
1021 // {{{ parentPath 1039 // {{{ parentPath
1022 // 1040 //
1023 // Automatically set up the repositories based on a parent path 1041 // Automatically set up the repositories based on a parent path
1024 1042
1025 function parentPath($path, $group = NULL) 1043 function parentPath($path, $group = NULL)
1026 { 1044 {
1027 if ($handle = @opendir($path)) 1045 if ($handle = @opendir($path))
1028 { 1046 {
1029 // For each file... 1047 // For each file...
1030 while (false !== ($file = readdir($handle))) 1048 while (false !== ($file = readdir($handle)))
1031 { 1049 {
1032 // That's also a non hidden directory 1050 // That's also a non hidden directory
1033 if (is_dir($path.DIRECTORY_SEPARATOR.$file) && $file{0} != ".") 1051 if (is_dir($path.DIRECTORY_SEPARATOR.$file) && $file{0} != ".")
1034 { 1052 {
1035 // And that contains a db directory (in an attempt to not include 1053 // And that contains a db directory (in an attempt to not include
1036 // non svn repositories. 1054 // non svn repositories.
1037 1055
1038 if (is_dir($path.DIRECTORY_SEPARATOR.$file.DIRECTORY_SEPARATOR."db")) 1056 if (is_dir($path.DIRECTORY_SEPARATOR.$file.DIRECTORY_SEPARATOR."db"))
1039 { 1057 {
1040 // We add the repository to the list 1058 // We add the repository to the list
1041 $this->addRepository($file, "file:///".$path.DIRECTORY_SEPARATOR.$file, $group); 1059 $this->addRepository($file, "file:///".$path.DIRECTORY_SEPARATOR.$file, $group);
1042 } 1060 }
1043 } 1061 }
1044 } 1062 }
1045 closedir($handle); 1063 closedir($handle);
1046 } 1064 }
1047   1065  
1048 // Sort the repositories into alphabetical order 1066 // Sort the repositories into alphabetical order
1049 1067
1050 if (!empty($this->_repositories)) 1068 if (!empty($this->_repositories))
1051 usort($this->_repositories, "cmpReps"); 1069 usort($this->_repositories, "cmpReps");
1052 } 1070 }
1053   1071  
1054 // }}} 1072 // }}}
1055 1073
1056 // {{{ Encoding functions 1074 // {{{ Encoding functions
1057 1075
1058 function setInputEncoding($systemEnc) 1076 function setInputEncoding($systemEnc)
1059 { 1077 {
1060 $this->inputEnc = $systemEnc; 1078 $this->inputEnc = $systemEnc;
1061 1079
1062 if (!isset($this->contentEnc)) 1080 if (!isset($this->contentEnc))
1063 $this->contentEnc = $systemEnc; 1081 $this->contentEnc = $systemEnc;
1064 } 1082 }
1065 1083
1066 function getInputEncoding() 1084 function getInputEncoding()
1067 { 1085 {
1068 return $this->inputEnc; 1086 return $this->inputEnc;
1069 } 1087 }
1070   1088  
1071 function setContentEncoding($contentEnc, $myrep = 0) 1089 function setContentEncoding($contentEnc, $myrep = 0)
1072 { 1090 {
1073 if (empty($myrep)) 1091 if (empty($myrep))
1074 $this->contentEnc = $contentEnc; 1092 $this->contentEnc = $contentEnc;
1075 else 1093 else
1076 { 1094 {
1077 $repo =& $this->findRepository($myrep); 1095 $repo =& $this->findRepository($myrep);
1078 $repo->setContentEncoding($contentEnc); 1096 $repo->setContentEncoding($contentEnc);
1079 } 1097 }
1080 } 1098 }
1081 1099
1082 function getContentEncoding() 1100 function getContentEncoding()
1083 { 1101 {
1084 return $this->contentEnc; 1102 return $this->contentEnc;
1085 } 1103 }
1086   1104  
1087 // }}} 1105 // }}}
1088   1106  
1089 // {{{ Tab expansion functions 1107 // {{{ Tab expansion functions
1090 1108
1091 function expandTabsBy($sp, $myrep = 0) 1109 function expandTabsBy($sp, $myrep = 0)
1092 { 1110 {
1093 if (empty($myrep)) 1111 if (empty($myrep))
1094 $this->spaces = $sp; 1112 $this->spaces = $sp;
1095 else 1113 else
1096 { 1114 {
1097 $repo =& $this->findRepository($myrep); 1115 $repo =& $this->findRepository($myrep);
1098 $repo->expandTabsBy($sp); 1116 $repo->expandTabsBy($sp);
1099 } 1117 }
1100 } 1118 }
1101 1119
1102 function getExpandTabsBy() 1120 function getExpandTabsBy()
1103 { 1121 {
1104 return $this->spaces; 1122 return $this->spaces;
1105 } 1123 }
1106   1124  
1107 // }}} 1125 // }}}
1108   1126  
1109 // {{{ Misc settings 1127 // {{{ Misc settings
1110 1128
1111 function ignoreSvnMimeTypes() 1129 function ignoreSvnMimeTypes()
1112 { 1130 {
1113 $this->ignoreSvnMimeTypes = true; 1131 $this->ignoreSvnMimeTypes = true;
1114 } 1132 }
1115   1133  
1116 function getIgnoreSvnMimeTypes() 1134 function getIgnoreSvnMimeTypes()
1117 { 1135 {
1118 return $this->ignoreSvnMimeTypes; 1136 return $this->ignoreSvnMimeTypes;
1119 } 1137 }
1120   1138  
1121 function ignoreWebSVNContentTypes() 1139 function ignoreWebSVNContentTypes()
1122 { 1140 {
1123 $this->ignoreWebSVNContentTypes = true; 1141 $this->ignoreWebSVNContentTypes = true;
1124 } 1142 }
1125   1143  
1126 function getIgnoreWebSVNContentTypes() 1144 function getIgnoreWebSVNContentTypes()
1127 { 1145 {
1128 return $this->ignoreWebSVNContentTypes; 1146 return $this->ignoreWebSVNContentTypes;
1129 } 1147 }
1130   1148  
1131 function useBugtraqProperties($myrep = 0) 1149 function useBugtraqProperties($myrep = 0)
1132 { 1150 {
1133 if (empty($myrep)) 1151 if (empty($myrep))
1134 $this->bugtraq = true; 1152 $this->bugtraq = true;
1135 else 1153 else
1136 { 1154 {
1137 $repo =& $this->findRepository($myrep); 1155 $repo =& $this->findRepository($myrep);
1138 $repo->useBugtraqProperties(); 1156 $repo->useBugtraqProperties();
1139 } 1157 }
1140 } 1158 }
1141 1159
1142 function getBugtraq() 1160 function getBugtraq()
1143 { 1161 {
1144 return $this->bugtraq; 1162 return $this->bugtraq;
1145 } 1163 }
1146   1164  
1147 function useAuthenticationFile($file, $myrep = 0) 1165 function useAuthenticationFile($file, $myrep = 0)
1148 { 1166 {
1149 if (empty($myrep)) 1167 if (empty($myrep))
1150 { 1168 {
1151 if (is_readable($file)) 1169 if (is_readable($file))
1152 $this->auth = new Authentication($file); 1170 $this->auth = new Authentication($file);
1153 else 1171 else
1154 { 1172 {
1155 echo "Unable to read authentication file '$file'"; 1173 echo "Unable to read authentication file '$file'";
1156 exit; 1174 exit;
1157 } 1175 }
1158 } 1176 }
1159 else 1177 else
1160 { 1178 {
1161 $repo =& $this->findRepository($myrep); 1179 $repo =& $this->findRepository($myrep);
1162 $repo->useAuthenticationFile($file); 1180 $repo->useAuthenticationFile($file);
1163 } 1181 }
1164 } 1182 }
1165 1183
1166 function &getAuth() 1184 function &getAuth()
1167 { 1185 {
1168 return $this->auth; 1186 return $this->auth;
1169 } 1187 }
1170   1188  
1171 function useTreeView() 1189 function useTreeView()
1172 { 1190 {
1173 $this->treeView = true; 1191 $this->treeView = true;
1174 } 1192 }
1175 1193
1176 function getUseTreeView() 1194 function getUseTreeView()
1177 { 1195 {
1178 return $this->treeView; 1196 return $this->treeView;
1179 } 1197 }
1180   1198  
1181 function useFlatView() 1199 function useFlatView()
1182 { 1200 {
1183 $this->treeView = false; 1201 $this->treeView = false;
1184 } 1202 }
1185   1203  
1186 function useTreeIndex($open) 1204 function useTreeIndex($open)
1187 { 1205 {
1188 $this->flatIndex = false; 1206 $this->flatIndex = false;
1189 $this->openTree = $open; 1207 $this->openTree = $open;
1190 } 1208 }
1191   1209  
1192 function getUseFlatIndex() 1210 function getUseFlatIndex()
1193 { 1211 {
1194 return $this->flatIndex; 1212 return $this->flatIndex;
1195 } 1213 }
1196   1214  
1197 function getOpenTree() 1215 function getOpenTree()
1198 { 1216 {
1199 return $this->openTree; 1217 return $this->openTree;
1200 } 1218 }
1201   1219  
1202 // setSubversionMajorVersion 1220 // setSubversionMajorVersion
1203 // 1221 //
1204 // Set subversion major version 1222 // Set subversion major version
1205 1223
1206 function setSubversionMajorVersion($subversionMajorVersion) 1224 function setSubversionMajorVersion($subversionMajorVersion)
1207 { 1225 {
1208 $this->subversionMajorVersion = $subversionMajorVersion; 1226 $this->subversionMajorVersion = $subversionMajorVersion;
1209 } 1227 }
1210   1228  
1211 function getSubversionMajorVersion() 1229 function getSubversionMajorVersion()
1212 { 1230 {
1213 return $this->subversionMajorVersion; 1231 return $this->subversionMajorVersion;
1214 } 1232 }
1215   1233  
1216 // setSubversionMinorVersion 1234 // setSubversionMinorVersion
1217 // 1235 //
1218 // Set subversion minor version 1236 // Set subversion minor version
1219 1237
1220 function setSubversionMinorVersion($subversionMinorVersion) 1238 function setSubversionMinorVersion($subversionMinorVersion)
1221 { 1239 {
1222 $this->subversionMinorVersion = $subversionMinorVersion; 1240 $this->subversionMinorVersion = $subversionMinorVersion;
1223 } 1241 }
1224 1242
1225 function getSubversionMinorVersion() 1243 function getSubversionMinorVersion()
1226 { 1244 {
1227 return $this->subversionMinorVersion; 1245 return $this->subversionMinorVersion;
1228 } 1246 }
1229   1247  
1230 // }}} 1248 // }}}
1231   1249  
1232 // {{{ Sort the repostories 1250 // {{{ Sort the repostories
1233 // 1251 //
1234 // This function sorts the repositories by group name. The contents of the 1252 // This function sorts the repositories by group name. The contents of the
1235 // group are left in there original order, which will either be sorted if the 1253 // group are left in there original order, which will either be sorted if the
1236 // group was added using the parentPath function, or defined for the order in 1254 // group was added using the parentPath function, or defined for the order in
1237 // which the repositories were included in the user's config file. 1255 // which the repositories were included in the user's config file.
1238 // 1256 //
1239 // Note that as of PHP 4.0.6 the usort command no longer preserves the order 1257 // Note that as of PHP 4.0.6 the usort command no longer preserves the order
1240 // of items that are considered equal (in our case, part of the same group). 1258 // of items that are considered equal (in our case, part of the same group).
1241 // The mergesort function preserves this order. 1259 // The mergesort function preserves this order.
1242 1260
1243 function sortByGroup() 1261 function sortByGroup()
1244 { 1262 {
1245 if (!empty($this->_repositories)) 1263 if (!empty($this->_repositories))
1246 mergesort($this->_repositories, "cmpGroups"); 1264 mergesort($this->_repositories, "cmpGroups");
1247 } 1265 }
1248   1266  
1249 // }}} 1267 // }}}
1250 } 1268 }
1251 ?> 1269 ?>