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