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