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