Rev 185 Rev 388
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 // setup.inc 23 // setup.inc
24 // 24 //
25 // Global setup 25 // Global setup
26   26  
27 // --- DON'T CHANGE THIS FILE --- 27 // --- DON'T CHANGE THIS FILE ---
28 // 28 //
29 // User changes should be done in config.ini 29 // User changes should be done in config.ini
30   30  
31 // Include the configuration class 31 // Include the configuration class
32 require_once 'include/configclass.inc'; 32 require_once 'include/configclass.inc';
33   33  
34 // Create the config 34 // Create the config
35 $config = new Config; 35 $config = new Config;
36   36  
37 // Set up the default character encodings 37 // Set up the default character encodings
38 if (function_exists('iconv_get_encoding')) 38 if (function_exists('iconv_get_encoding'))
39 { 39 {
40 $config->setInputEncoding(iconv_get_encoding('input_encoding')); 40 $config->setInputEncoding(iconv_get_encoding('input_encoding'));
41 } 41 }
42   42  
43 // Define the language array 43 // Define the language array
44 $lang = array(); 44 $lang = array();
45 $langNames = array(); 45 $langNames = array();
46   46  
47 // Set up locwebsvnhttp 47 // Set up locwebsvnhttp
48 // Note: we will use nothing in MultiViews mode so that the URLs use the root 48 // Note: we will use nothing in MultiViews mode so that the URLs use the root
49 // directory by default. 49 // directory by default.
50 if (empty($locwebsvnhttp)) 50 if (empty($locwebsvnhttp))
51 $locwebsvnhttp = defined('WSVN_MULTIVIEWS') ? '' : '.'; 51 $locwebsvnhttp = defined('WSVN_MULTIVIEWS') ? '' : '.';
52   52  
53 if (empty($locwebsvnreal)) 53 if (empty($locwebsvnreal))
54 $locwebsvnreal = '.'; 54 $locwebsvnreal = '.';
55   55  
56 $vars['locwebsvnhttp'] = $locwebsvnhttp; 56 $vars['locwebsvnhttp'] = $locwebsvnhttp;
57   57  
58 // Include a default language file (must go before config.inc) 58 // Include a default language file (must go before config.inc)
59 require 'languages/english.inc'; 59 require 'languages/english.inc';
60   60  
61 // Get the user's personalised config (requires the locwebsvnhttp stuff above) 61 // Get the user's personalised config (requires the locwebsvnhttp stuff above)
62 require_once 'config.inc'; 62 require_once 'config.inc';
63   63  
64 // Load PHP_Compat if we're going to use it. This needs to be done after including config.inc (which contains 64 // Load PHP_Compat if we're going to use it. This needs to be done after including config.inc (which contains
65 // the setting) but before svnlook.inc (which requires util.inc, which contains PHP4-incompatible functions) 65 // the setting) but before svnlook.inc (which requires util.inc, which contains PHP4-incompatible functions)
66 if ($config->isPHPCompatEnabled()) { 66 if ($config->isPHPCompatEnabled()) {
67 require_once($config->getPHPCompatFile()); 67 require_once($config->getPHPCompatFile());
68 require_once 'include/php5compat.inc'; 68 require_once 'include/php5compat.inc';
69 } 69 }
70   70  
71 require_once 'include/svnlook.inc'; 71 require_once 'include/svnlook.inc';
72   72  
73 // Make sure that the input locale is set up correctly 73 // Make sure that the input locale is set up correctly
74 setlocale(LC_ALL, ''); 74 setlocale(LC_ALL, '');
75   75  
76 // {{{ Content-Type's 76 // {{{ Content-Type's
77 // Set up the default content-type extension handling 77 // Set up the default content-type extension handling
78   78  
79 $contentType = array ( 79 $contentType = array (
80   80  
81 '.dwg' => 'application/acad', // AutoCAD Drawing files 81 '.dwg' => 'application/acad', // AutoCAD Drawing files
82 '.DWG' => 'application/acad', // AutoCAD Drawing files 82 '.DWG' => 'application/acad', // AutoCAD Drawing files
83 '.arj' => 'application/arj', //   83 '.arj' => 'application/arj', //  
84 '.ccAD' => 'application/clariscad', // ClarisCAD files 84 '.ccAD' => 'application/clariscad', // ClarisCAD files
85 '.DRW' => 'application/drafting', // MATRA Prelude drafting 85 '.DRW' => 'application/drafting', // MATRA Prelude drafting
86 '.dxf' => 'application/dxf', // DXF (AutoCAD) 86 '.dxf' => 'application/dxf', // DXF (AutoCAD)
87 '.DXF' => 'application/dxf', // DXF (AutoCAD) 87 '.DXF' => 'application/dxf', // DXF (AutoCAD)
88 '.xl' => 'application/excel', // Microsoft Excel 88 '.xl' => 'application/excel', // Microsoft Excel
89 '.unv' => 'application/i-deas', //SDRC I-DEAS files 89 '.unv' => 'application/i-deas', //SDRC I-DEAS files
90 '.UNV' => 'application/i-deas', //SDRC I-DEAS files 90 '.UNV' => 'application/i-deas', //SDRC I-DEAS files
91 '.igs' => 'application/iges', // IGES graphics format 91 '.igs' => 'application/iges', // IGES graphics format
92 '.iges' => 'application/iges', // IGES graphics format 92 '.iges' => 'application/iges', // IGES graphics format
93 '.IGS' => 'application/iges', // IGES graphics format 93 '.IGS' => 'application/iges', // IGES graphics format
94 '.IGES' => 'application/iges', // IGES graphics format 94 '.IGES' => 'application/iges', // IGES graphics format
95 '.hqx' => 'application/mac-binhex40', // Macintosh BinHex format 95 '.hqx' => 'application/mac-binhex40', // Macintosh BinHex format
96 '.word' => 'application/msword', // Microsoft Word 96 '.word' => 'application/msword', // Microsoft Word
97 '.w6w' => 'application/msword', // Microsoft Word 97 '.w6w' => 'application/msword', // Microsoft Word
98 '.doc' => 'application/msword', // Microsoft Word 98 '.doc' => 'application/msword', // Microsoft Word
99 '.wri' => 'application/mswrite', // Microsoft Write 99 '.wri' => 'application/mswrite', // Microsoft Write
100 '.bin' => 'application/octet-stream', // Uninterpreted binary 100 '.bin' => 'application/octet-stream', // Uninterpreted binary
101 '.exe' => 'application/x-msdownload', // Windows EXE 101 '.exe' => 'application/x-msdownload', // Windows EXE
102 '.EXE' => 'application/x-msdownload', // Windows EXE 102 '.EXE' => 'application/x-msdownload', // Windows EXE
103 '.oda' => 'application/oda', //   103 '.oda' => 'application/oda', //  
104 '.pdf' => 'application/pdf', // PDF (Adobe Acrobat) 104 '.pdf' => 'application/pdf', // PDF (Adobe Acrobat)
105 '.ai' => 'application/postscript', // PostScript 105 '.ai' => 'application/postscript', // PostScript
106 '.PS' => 'application/postscript', // PostScript 106 '.PS' => 'application/postscript', // PostScript
107 '.ps' => 'application/postscript', // PostScript 107 '.ps' => 'application/postscript', // PostScript
108 '.eps' => 'application/postscript', // PostScript 108 '.eps' => 'application/postscript', // PostScript
109 '.prt' => 'application/pro_eng', // PTC Pro/ENGINEER 109 '.prt' => 'application/pro_eng', // PTC Pro/ENGINEER
110 '.PRT' => 'application/pro_eng', // PTC Pro/ENGINEER 110 '.PRT' => 'application/pro_eng', // PTC Pro/ENGINEER
111 '.part' => 'application/pro_eng', // PTC Pro/ENGINEER 111 '.part' => 'application/pro_eng', // PTC Pro/ENGINEER
112 '.rtf' => 'application/rtf', // Rich Text Format 112 '.rtf' => 'application/rtf', // Rich Text Format
113 '.set' => 'application/set', // SET (French CAD standard) 113 '.set' => 'application/set', // SET (French CAD standard)
114 '.SET' => 'application/set', // SET (French CAD standard) 114 '.SET' => 'application/set', // SET (French CAD standard)
115 '.stl' => 'application/sla', // Stereolithography 115 '.stl' => 'application/sla', // Stereolithography
116 '.STL' => 'application/sla', // Stereolithography 116 '.STL' => 'application/sla', // Stereolithography
117 '.SOL' => 'application/solids', // MATRA Prelude Solids 117 '.SOL' => 'application/solids', // MATRA Prelude Solids
118 '.stp' => 'application/STEP', // ISO-10303 STEP data files 118 '.stp' => 'application/STEP', // ISO-10303 STEP data files
119 '.STP' => 'application/STEP', // ISO-10303 STEP data files 119 '.STP' => 'application/STEP', // ISO-10303 STEP data files
120 '.step' => 'application/STEP', // ISO-10303 STEP data files 120 '.step' => 'application/STEP', // ISO-10303 STEP data files
121 '.STEP' => 'application/STEP', // ISO-10303 STEP data files 121 '.STEP' => 'application/STEP', // ISO-10303 STEP data files
-   122 '.svg' => 'application/svg', // Scalable Vector Graphics
122 '.vda' => 'application/vda', // VDA-FS Surface data 123 '.vda' => 'application/vda', // VDA-FS Surface data
123 '.VDA' => 'application/vda', // VDA-FS Surface data 124 '.VDA' => 'application/vda', // VDA-FS Surface data
124 '.dir' => 'application/x-director', // Macromedia Director 125 '.dir' => 'application/x-director', // Macromedia Director
125 '.dcr' => 'application/x-director', // Macromedia Director 126 '.dcr' => 'application/x-director', // Macromedia Director
126 '.dxr' => 'application/x-director', // Macromedia Director 127 '.dxr' => 'application/x-director', // Macromedia Director
127 '.mif' => 'application/x-mif', // FrameMaker MIF Format 128 '.mif' => 'application/x-mif', // FrameMaker MIF Format
128 '.csh' => 'application/x-csh', // C-shell script 129 '.csh' => 'application/x-csh', // C-shell script
129 '.dvi' => 'application/x-dvi', // TeX DVI 130 '.dvi' => 'application/x-dvi', // TeX DVI
130 '.gz' => 'application/x-gzip', // GNU Zip 131 '.gz' => 'application/x-gzip', // GNU Zip
131 '.gzip' => 'application/x-gzip', // GNU Zip 132 '.gzip' => 'application/x-gzip', // GNU Zip
132 '.hdf' => 'application/x-hdf', // ncSA HDF Data File 133 '.hdf' => 'application/x-hdf', // ncSA HDF Data File
133 '.latex' => 'application/x-latex', // LaTeX source 134 '.latex' => 'application/x-latex', // LaTeX source
134 '.nc' => 'application/x-netcdf', // Unidata netCDF 135 '.nc' => 'application/x-netcdf', // Unidata netCDF
135 '.cdf' => 'application/x-netcdf', // Unidata netCDF 136 '.cdf' => 'application/x-netcdf', // Unidata netCDF
136 '.sit' => 'application/x-stuffit', // Stiffut Archive 137 '.sit' => 'application/x-stuffit', // Stiffut Archive
137 '.tcl' => 'application/x-tcl', // TCL script 138 '.tcl' => 'application/x-tcl', // TCL script
138 '.texinfo' => 'application/x-texinfo', // Texinfo (Emacs) 139 '.texinfo' => 'application/x-texinfo', // Texinfo (Emacs)
139 '.texi' => 'application/x-texinfo', // Texinfo (Emacs) 140 '.texi' => 'application/x-texinfo', // Texinfo (Emacs)
140 '.t' => 'application/x-troff', // Troff 141 '.t' => 'application/x-troff', // Troff
141 '.tr' => 'application/x-troff', // Troff 142 '.tr' => 'application/x-troff', // Troff
142 '.roff' => 'application/x-troff', // Troff 143 '.roff' => 'application/x-troff', // Troff
143 '.man' => 'application/x-troff-man', // Troff with MAN macros 144 '.man' => 'application/x-troff-man', // Troff with MAN macros
144 '.me' => 'application/x-troff-me', // Troff with ME macros 145 '.me' => 'application/x-troff-me', // Troff with ME macros
145 '.ms' => 'application/x-troff-ms', // Troff with MS macros 146 '.ms' => 'application/x-troff-ms', // Troff with MS macros
146 '.src' => 'application/x-wais-source', // WAIS source 147 '.src' => 'application/x-wais-source', // WAIS source
147 '.bcpio' => 'application/x-bcpio', // Old binary CPIO 148 '.bcpio' => 'application/x-bcpio', // Old binary CPIO
148 '.cpio' => 'application/x-cpio', // POSIX CPIO 149 '.cpio' => 'application/x-cpio', // POSIX CPIO
149 '.gtar' => 'application/x-gtar', // GNU tar 150 '.gtar' => 'application/x-gtar', // GNU tar
150 '.shar' => 'application/x-shar', // Shell archive 151 '.shar' => 'application/x-shar', // Shell archive
151 '.sv4cpio' => 'application/x-sv4cpio', // SVR4 CPIO 152 '.sv4cpio' => 'application/x-sv4cpio', // SVR4 CPIO
152 '.sv4crc' => 'application/x-sv4crc', // SVR4 CPIO with CRC 153 '.sv4crc' => 'application/x-sv4crc', // SVR4 CPIO with CRC
153 '.tar' => 'application/x-tar', // 4.3BSD tar format 154 '.tar' => 'application/x-tar', // 4.3BSD tar format
154 '.ustar' => 'application/x-ustar', // POSIX tar format 155 '.ustar' => 'application/x-ustar', // POSIX tar format
155 '.hlp' => 'application/x-winhelp', // Windows Help 156 '.hlp' => 'application/x-winhelp', // Windows Help
156 '.zip' => 'application/zip', // ZIP archive 157 '.zip' => 'application/zip', // ZIP archive
157 '.au' => 'audio/basic', // Basic audio (usually m-law) 158 '.au' => 'audio/basic', // Basic audio (usually m-law)
158 '.snd' => 'audio/basic', // Basic audio (usually m-law) 159 '.snd' => 'audio/basic', // Basic audio (usually m-law)
159 '.aif' => 'audio/x-aiff', // AIFF audio 160 '.aif' => 'audio/x-aiff', // AIFF audio
160 '.aiff' => 'audio/x-aiff', // AIFF audio 161 '.aiff' => 'audio/x-aiff', // AIFF audio
161 '.aifc' => 'audio/x-aiff', // AIFF audio 162 '.aifc' => 'audio/x-aiff', // AIFF audio
162 '.ra' => 'audio/x-pn-realaudio', // RealAudio 163 '.ra' => 'audio/x-pn-realaudio', // RealAudio
163 '.ram' => 'audio/x-pn-realaudio', // RealAudio 164 '.ram' => 'audio/x-pn-realaudio', // RealAudio
164 '.rpm' => 'audio/x-pn-realaudio-plugin', // RealAudio (plug-in) 165 '.rpm' => 'audio/x-pn-realaudio-plugin', // RealAudio (plug-in)
165 '.wav' => 'audio/x-wav', // Windows WAVE audio 166 '.wav' => 'audio/x-wav', // Windows WAVE audio
166 '.mp3' => 'audio/x-mp3', // MP3 files 167 '.mp3' => 'audio/x-mp3', // MP3 files
167 '.gif' => 'image/gif', // gif image 168 '.gif' => 'image/gif', // gif image
168 '.ief' => 'image/ief', // Image Exchange Format 169 '.ief' => 'image/ief', // Image Exchange Format
169 '.jpg' => 'image/jpeg', // JPEG image 170 '.jpg' => 'image/jpeg', // JPEG image
170 '.JPG' => 'image/jpeg', // JPEG image 171 '.JPG' => 'image/jpeg', // JPEG image
171 '.JPE' => 'image/jpeg', // JPEG image 172 '.JPE' => 'image/jpeg', // JPEG image
172 '.jpe' => 'image/jpeg', // JPEG image 173 '.jpe' => 'image/jpeg', // JPEG image
173 '.JPEG' => 'image/jpeg', // JPEG image 174 '.JPEG' => 'image/jpeg', // JPEG image
174 '.jpeg' => 'image/jpeg', // JPEG image 175 '.jpeg' => 'image/jpeg', // JPEG image
175 '.pict' => 'image/pict', // Macintosh PICT 176 '.pict' => 'image/pict', // Macintosh PICT
176 '.tiff' => 'image/tiff', // TIFF image 177 '.tiff' => 'image/tiff', // TIFF image
177 '.tif' => 'image/tiff', // TIFF image 178 '.tif' => 'image/tiff', // TIFF image
178 '.ras' => 'image/x-cmu-raster', // CMU raster 179 '.ras' => 'image/x-cmu-raster', // CMU raster
179 '.pnm' => 'image/x-portable-anymap', // PBM Anymap format 180 '.pnm' => 'image/x-portable-anymap', // PBM Anymap format
180 '.pbm' => 'image/x-portable-bitmap', // PBM Bitmap format 181 '.pbm' => 'image/x-portable-bitmap', // PBM Bitmap format
181 '.pgm' => 'image/x-portable-graymap', // PBM Graymap format 182 '.pgm' => 'image/x-portable-graymap', // PBM Graymap format
182 '.ppm' => 'image/x-portable-pixmap', // PBM Pixmap format 183 '.ppm' => 'image/x-portable-pixmap', // PBM Pixmap format
183 '.rgb' => 'image/x-rgb', // RGB Image 184 '.rgb' => 'image/x-rgb', // RGB Image
184 '.xbm' => 'image/x-xbitmap', // X Bitmap 185 '.xbm' => 'image/x-xbitmap', // X Bitmap
185 '.xpm' => 'image/x-xpixmap', // X Pixmap 186 '.xpm' => 'image/x-xpixmap', // X Pixmap
186 '.xwd' => 'image/x-xwindowdump', // X Windows dump (xwd) format 187 '.xwd' => 'image/x-xwindowdump', // X Windows dump (xwd) format
187 '.zip' => 'multipart/x-zip', // PKZIP Archive 188 '.zip' => 'multipart/x-zip', // PKZIP Archive
188 '.gzip' => 'multipart/x-gzip', // GNU ZIP Archive 189 '.gzip' => 'multipart/x-gzip', // GNU ZIP Archive
189 '.mpeg' => 'video/mpeg', // MPEG video 190 '.mpeg' => 'video/mpeg', // MPEG video
190 '.mpg' => 'video/mpeg', // MPEG video 191 '.mpg' => 'video/mpeg', // MPEG video
191 '.MPG' => 'video/mpeg', // MPEG video 192 '.MPG' => 'video/mpeg', // MPEG video
192 '.MPE' => 'video/mpeg', // MPEG video 193 '.MPE' => 'video/mpeg', // MPEG video
193 '.mpe' => 'video/mpeg', // MPEG video 194 '.mpe' => 'video/mpeg', // MPEG video
194 '.MPEG' => 'video/mpeg', // MPEG video 195 '.MPEG' => 'video/mpeg', // MPEG video
195 '.mpeg' => 'video/mpeg', // MPEG video 196 '.mpeg' => 'video/mpeg', // MPEG video
196 '.qt' => 'video/quicktime', // QuickTime Video 197 '.qt' => 'video/quicktime', // QuickTime Video
197 '.mov' => 'video/quicktime', // QuickTime Video 198 '.mov' => 'video/quicktime', // QuickTime Video
198 '.avi' => 'video/msvideo', // Microsoft Windows Video 199 '.avi' => 'video/msvideo', // Microsoft Windows Video
199 '.movie' => 'video/x-sgi-movie', // SGI Movieplayer format 200 '.movie' => 'video/x-sgi-movie', // SGI Movieplayer format
200 '.wrl' => 'x-world/x-vrml', // VRML Worlds 201 '.wrl' => 'x-world/x-vrml', // VRML Worlds
201 '.odt' => 'application/vnd.oasis.opendocument.text', // OpenDocument Text 202 '.odt' => 'application/vnd.oasis.opendocument.text', // OpenDocument Text
202 '.ott' => 'application/vnd.oasis.opendocument.text-template', // OpenDocument Text Template 203 '.ott' => 'application/vnd.oasis.opendocument.text-template', // OpenDocument Text Template
203 '.ods' => 'application/vnd.oasis.opendocument.spreadsheet', // OpenDocument Spreadsheet 204 '.ods' => 'application/vnd.oasis.opendocument.spreadsheet', // OpenDocument Spreadsheet
204 '.ots' => 'application/vnd.oasis.opendocument.spreadsheet-template', // OpenDocument Spreadsheet Template 205 '.ots' => 'application/vnd.oasis.opendocument.spreadsheet-template', // OpenDocument Spreadsheet Template
205 '.odp' => 'application/vnd.oasis.opendocument.presentation', // OpenDocument Presentation 206 '.odp' => 'application/vnd.oasis.opendocument.presentation', // OpenDocument Presentation
206 '.otp' => 'application/vnd.oasis.opendocument.presentation-template', // OpenDocument Presentation Template 207 '.otp' => 'application/vnd.oasis.opendocument.presentation-template', // OpenDocument Presentation Template
207 '.odg' => 'application/vnd.oasis.opendocument.graphics', // OpenDocument Drawing 208 '.odg' => 'application/vnd.oasis.opendocument.graphics', // OpenDocument Drawing
208 '.otg' => 'application/vnd.oasis.opendocument.graphics-template', // OpenDocument Drawing Template 209 '.otg' => 'application/vnd.oasis.opendocument.graphics-template', // OpenDocument Drawing Template
209 '.odc' => 'application/vnd.oasis.opendocument.chart', // OpenDocument Chart 210 '.odc' => 'application/vnd.oasis.opendocument.chart', // OpenDocument Chart
210 '.otc' => 'application/vnd.oasis.opendocument.chart-template', // OpenDocument Chart Template 211 '.otc' => 'application/vnd.oasis.opendocument.chart-template', // OpenDocument Chart Template
211 '.odf' => 'application/vnd.oasis.opendocument.formula', // OpenDocument Formula 212 '.odf' => 'application/vnd.oasis.opendocument.formula', // OpenDocument Formula
212 '.otf' => 'application/vnd.oasis.opendocument.formula-template', // OpenDocument Formula Template 213 '.otf' => 'application/vnd.oasis.opendocument.formula-template', // OpenDocument Formula Template
213 '.odi' => 'application/vnd.oasis.opendocument.image', // OpenDocument Image 214 '.odi' => 'application/vnd.oasis.opendocument.image', // OpenDocument Image
214 '.oti' => 'application/vnd.oasis.opendocument.image-template', // OpenDocument Image Template 215 '.oti' => 'application/vnd.oasis.opendocument.image-template', // OpenDocument Image Template
215 '.odm' => 'application/vnd.oasis.opendocument.text-master', // OpenDocument Master Document 216 '.odm' => 'application/vnd.oasis.opendocument.text-master', // OpenDocument Master Document
216 '.oth' => 'application/vnd.oasis.opendocument.text-web', // HTML Document Template 217 '.oth' => 'application/vnd.oasis.opendocument.text-web', // HTML Document Template
217 '.odb' => 'application/vnd.oasis.opendocument.database', // OpenDocument Database 218 '.odb' => 'application/vnd.oasis.opendocument.database', // OpenDocument Database
218   219  
219 ); 220 );
220   221  
221 // }}} 222 // }}}
222   223  
223 // {{{ Enscript file extensions 224 // {{{ Enscript file extensions
224   225  
225 // List of extensions recognised by enscript. 226 // List of extensions recognised by enscript.
226   227  
227 $extEnscript = array 228 $extEnscript = array
228 ( 229 (
229 '.ada' => 'ada', 230 '.ada' => 'ada',
230 '.adb' => 'ada', 231 '.adb' => 'ada',
231 '.ads' => 'ada', 232 '.ads' => 'ada',
232 '.awk' => 'awk', 233 '.awk' => 'awk',
233 '.c' => 'c', 234 '.c' => 'c',
234 '.c++' => 'cpp', 235 '.c++' => 'cpp',
235 '.cc' => 'cpp', 236 '.cc' => 'cpp',
236 '.cpp' => 'cpp', 237 '.cpp' => 'cpp',
237 '.csh' => 'csh', 238 '.csh' => 'csh',
238 '.cxx' => 'cpp', 239 '.cxx' => 'cpp',
239 '.diff' => 'diffu', 240 '.diff' => 'diffu',
240 '.dpr' => 'delphi', 241 '.dpr' => 'delphi',
241 '.el' => 'elisp', 242 '.el' => 'elisp',
242 '.eps' => 'postscript', 243 '.eps' => 'postscript',
243 '.f' => 'fortran', 244 '.f' => 'fortran',
244 '.for' => 'fortran', 245 '.for' => 'fortran',
245 '.gs' => 'haskell', 246 '.gs' => 'haskell',
246 '.h' => 'c', 247 '.h' => 'c',
247 '.hpp' => 'cpp', 248 '.hpp' => 'cpp',
248 '.hs' => 'haskell', 249 '.hs' => 'haskell',
249 '.htm' => 'html', 250 '.htm' => 'html',
250 '.html' => 'html', 251 '.html' => 'html',
251 '.idl' => 'idl', 252 '.idl' => 'idl',
252 '.java' => 'java', 253 '.java' => 'java',
253 '.js' => 'javascript', 254 '.js' => 'javascript',
254 '.lgs' => 'haskell', 255 '.lgs' => 'haskell',
255 '.lhs' => 'haskell', 256 '.lhs' => 'haskell',
256 '.m' => 'objc', 257 '.m' => 'objc',
257 '.m4' => 'm4', 258 '.m4' => 'm4',
258 '.man' => 'nroff', 259 '.man' => 'nroff',
259 '.nr' => 'nroff', 260 '.nr' => 'nroff',
260 '.p' => 'pascal', 261 '.p' => 'pascal',
261 '.pas' => 'delphi', 262 '.pas' => 'delphi',
262 '.patch' => 'diffu', 263 '.patch' => 'diffu',
263 '.pkg' => 'sql', 264 '.pkg' => 'sql',
264 '.pl' => 'perl', 265 '.pl' => 'perl',
265 '.pm' => 'perl', 266 '.pm' => 'perl',
266 '.pp' => 'pascal', 267 '.pp' => 'pascal',
267 '.ps' => 'postscript', 268 '.ps' => 'postscript',
268 '.s' => 'asm', 269 '.s' => 'asm',
269 '.scheme' => 'scheme', 270 '.scheme' => 'scheme',
270 '.scm' => 'scheme', 271 '.scm' => 'scheme',
271 '.scr' => 'synopsys', 272 '.scr' => 'synopsys',
272 '.sh' => 'sh', 273 '.sh' => 'sh',
273 '.shtml' => 'html', 274 '.shtml' => 'html',
274 '.sql' => 'sql', 275 '.sql' => 'sql',
275 '.st' => 'states', 276 '.st' => 'states',
276 '.syn' => 'synopsys', 277 '.syn' => 'synopsys',
277 '.synth' => 'synopsys', 278 '.synth' => 'synopsys',
278 '.tcl' => 'tcl', 279 '.tcl' => 'tcl',
279 '.tex' => 'tex', 280 '.tex' => 'tex',
280 '.texi' => 'tex', 281 '.texi' => 'tex',
281 '.texinfo' => 'tex', 282 '.texinfo' => 'tex',
282 '.v' => 'verilog', 283 '.v' => 'verilog',
283 '.vba' => 'vba', 284 '.vba' => 'vba',
284 '.vh' => 'verilog', 285 '.vh' => 'verilog',
285 '.vhd' => 'vhdl', 286 '.vhd' => 'vhdl',
286 '.vhdl' => 'vhdl', 287 '.vhdl' => 'vhdl',
287 '.py' => 'python', 288 '.py' => 'python',
288 289
289 // The following are handled internally by WebSVN, since there's no 290 // The following are handled internally by WebSVN, since there's no
290 // support for them in Enscript 291 // support for them in Enscript
291 292
292 '.php' => 'php', 293 '.php' => 'php',
293 '.phtml' => 'php', 294 '.phtml' => 'php',
294 '.php3' => 'php', 295 '.php3' => 'php',
295 '.inc' => 'php' 296 '.inc' => 'php'
296 ); 297 );
297   298  
298 // }}} 299 // }}}
299   300  
300 // Default 'zipped' array 301 // Default 'zipped' array
301   302  
302 $zipped = array (); 303 $zipped = array ();
303   304  
304 // Set up the version info 305 // Set up the version info
305   306  
306 initSvnVersion($major,$minor); 307 initSvnVersion($major,$minor);
307   308  
308 // Get the language choice as defained as the default by config.inc 309 // Get the language choice as defained as the default by config.inc
309 $user_defaultLang = $lang['LANGUAGENAME']; 310 $user_defaultLang = $lang['LANGUAGENAME'];
310   311  
311 // Override this with the user choice if there is one, and memorise the setting 312 // Override this with the user choice if there is one, and memorise the setting
312 // as a cookie (since we don't have user accounts, we can't store the setting 313 // as a cookie (since we don't have user accounts, we can't store the setting
313 // anywhere else). We try to memorise a permanant cookie and a per session cookie 314 // anywhere else). We try to memorise a permanant cookie and a per session cookie
314 // in case the user's disabled permanant ones. 315 // in case the user's disabled permanant ones.
315   316  
316 if (!empty($_REQUEST['langchoice'])) 317 if (!empty($_REQUEST['langchoice']))
317 { 318 {
318 $user_defaultLang = $_REQUEST['langchoice']; 319 $user_defaultLang = $_REQUEST['langchoice'];
319 setcookie('storedlang', $_REQUEST['langchoice'], time()+(3600*24*356*10), '/'); 320 setcookie('storedlang', $_REQUEST['langchoice'], time()+(3600*24*356*10), '/');
320 setcookie('storedsesslang', $_REQUEST['langchoice']); 321 setcookie('storedsesslang', $_REQUEST['langchoice']);
321 } 322 }
322 else // Try to read an existing cookie if there is one 323 else // Try to read an existing cookie if there is one
323 { 324 {
324 if (!empty($_COOKIE['storedlang'])) $user_defaultLang = $_COOKIE['storedlang']; 325 if (!empty($_COOKIE['storedlang'])) $user_defaultLang = $_COOKIE['storedlang'];
325 else if (!empty($_COOKIE['storedsesslang'])) $user_defaultLang = $_COOKIE['storedsesslang']; 326 else if (!empty($_COOKIE['storedsesslang'])) $user_defaultLang = $_COOKIE['storedsesslang'];
326 } 327 }
327 328
328 $user_defaultFile = ''; 329 $user_defaultFile = '';
329 if ($handle = opendir('languages')) 330 if ($handle = opendir('languages'))
330 { 331 {
331 // Read the language name for each language. 332 // Read the language name for each language.
332 while (false !== ($file = readdir($handle))) 333 while (false !== ($file = readdir($handle)))
333 { 334 {
334 if ($file{0} != '.' && !is_dir('languages'.DIRECTORY_SEPARATOR.$file)) 335 if ($file{0} != '.' && !is_dir('languages'.DIRECTORY_SEPARATOR.$file))
335 { 336 {
336 $lang['LANGUAGENAME'] = ''; 337 $lang['LANGUAGENAME'] = '';
337 require 'languages/'.$file; 338 require 'languages/'.$file;
338 if ($lang['LANGUAGENAME'] != '') 339 if ($lang['LANGUAGENAME'] != '')
339 { 340 {
340 $langNames[] = $lang['LANGUAGENAME']; 341 $langNames[] = $lang['LANGUAGENAME'];
341 if ($lang['LANGUAGENAME'] == $user_defaultLang) 342 if ($lang['LANGUAGENAME'] == $user_defaultLang)
342 $user_defaultFile = $file; 343 $user_defaultFile = $file;
343 } 344 }
344 } 345 }
345 } 346 }
346   347  
347 closedir($handle); 348 closedir($handle);
348 349
349 // XXX: this shouldn't be necessary 350 // XXX: this shouldn't be necessary
350 // ^ i.e. just require english.inc, then the desired language 351 // ^ i.e. just require english.inc, then the desired language
351 // Reload english to get untranslated strings 352 // Reload english to get untranslated strings
352 require 'languages/english.inc'; 353 require 'languages/english.inc';
353 354
354 // Reload the default language 355 // Reload the default language
355 if (!empty($user_defaultFile)) 356 if (!empty($user_defaultFile))
356 require 'languages/'.$user_defaultFile; 357 require 'languages/'.$user_defaultFile;
357 358
358 $url = getParameterisedSelfUrl(true); 359 $url = getParameterisedSelfUrl(true);
359 $vars["lang_form"] = "<form action=\"$url\" method=\"post\" id=\"langform\">"; 360 $vars["lang_form"] = "<form action=\"$url\" method=\"post\" id=\"langform\">";
360 $vars["lang_select"] = "<select name=\"langchoice\" onchange=\"javascript:this.form.submit();\">"; 361 $vars["lang_select"] = "<select name=\"langchoice\" onchange=\"javascript:this.form.submit();\">";
361 362
362 reset($langNames); 363 reset($langNames);
363 foreach ($langNames as $name) 364 foreach ($langNames as $name)
364 { 365 {
365 $sel = ""; 366 $sel = "";
366 if ($name == $user_defaultLang) $sel = "selected"; 367 if ($name == $user_defaultLang) $sel = "selected";
367 $vars["lang_select"] .= "<option value=\"$name\" $sel>$name</option>"; 368 $vars["lang_select"] .= "<option value=\"$name\" $sel>$name</option>";
368 } 369 }
369 370
370 $vars["lang_select"] .= "</select>"; 371 $vars["lang_select"] .= "</select>";
371 $vars["lang_submit"] = "<input type=\"submit\" value=\"${lang["GO"]}\">"; 372 $vars["lang_submit"] = "<input type=\"submit\" value=\"${lang["GO"]}\">";
372 $vars["lang_endform"] = "</form>"; 373 $vars["lang_endform"] = "</form>";
373 } 374 }
374   375  
375 // Set up headers 376 // Set up headers
376   377  
377 header("Content-type: text/html; charset=".$config->outputEnc); 378 header('Content-Type: text/html; charset=UTF-8');
378   379  
379 // Make sure that the user has set up a repository 380 // Make sure that the user has set up a repository
380   381  
381 $reps = $config->getRepositories(); 382 $reps = $config->getRepositories();
382 if (empty($reps[0])) 383 if (empty($reps[0]))
383 { 384 {
384 echo $lang["SUPPLYREP"]; 385 echo $lang["SUPPLYREP"];
385 exit; 386 exit;
386 } 387 }
387   388  
388 // Override the rep parameter with the repository name if it's available 389 // Override the rep parameter with the repository name if it's available
389 $repname = @$_REQUEST["repname"]; 390 $repname = @$_REQUEST["repname"];
390 if (isset($repname)) 391 if (isset($repname))
391 { 392 {
392 $rep = $config->findRepository($repname); 393 $rep = $config->findRepository($repname);
393 } 394 }
394 else 395 else
395 $rep = $reps[0]; 396 $rep = $reps[0];
396 397
397 // Retrieve other standard parameters 398 // Retrieve other standard parameters
398   399  
399 # due to possible XSS exploit, we need to clean up path first 400 # due to possible XSS exploit, we need to clean up path first
400 $path = !empty($_REQUEST['path']) ? $_REQUEST['path'] : null; 401 $path = !empty($_REQUEST['path']) ? $_REQUEST['path'] : null;
401 $vars['safepath'] = htmlentities($path); 402 $vars['safepath'] = htmlentities($path);
402 $rev = (int)@$_REQUEST["rev"]; 403 $rev = (int)@$_REQUEST["rev"];
403 $showchanged = (@$_REQUEST["sc"] == 1)?1:0; 404 $showchanged = (@$_REQUEST["sc"] == 1)?1:0;
404   405  
405 // Function to create the project selection HTML form 406 // Function to create the project selection HTML form
406 function createProjectSelectionForm() 407 function createProjectSelectionForm()
407 { 408 {
408 global $config, $vars, $rep, $lang, $showchanged; 409 global $config, $vars, $rep, $lang, $showchanged;
409 410
410 $url = $config->getURL(-1, "", "form"); 411 $url = $config->getURL(-1, "", "form");
411 $vars["projects_form"] = "<form action=\"$url\" method=\"post\" id=\"projectform\">"; 412 $vars["projects_form"] = "<form action=\"$url\" method=\"post\" id=\"projectform\">";
412 413
413 $reps = $config->getRepositories(); 414 $reps = $config->getRepositories();
414 $vars["projects_select"] = "<select name=\"repname\" onchange=\"javascript:this.form.submit();\">"; 415 $vars["projects_select"] = "<select name=\"repname\" onchange=\"javascript:this.form.submit();\">";
415 416
416 foreach ($reps as $trep) 417 foreach ($reps as $trep)
417 { 418 {
418 if ($trep->hasReadAccess("/", true)) 419 if ($trep->hasReadAccess("/", true))
419 { 420 {
420 if ($rep->getDisplayName() == $trep->getDisplayName()) 421 if ($rep->getDisplayName() == $trep->getDisplayName())
421 $sel = "selected"; 422 $sel = "selected";
422 else 423 else
423 $sel = ""; 424 $sel = "";
424 425
425 $vars["projects_select"] .= "<option value=\"".$trep->getDisplayName()."\" $sel>".$trep->getDisplayName()."</option>"; 426 $vars["projects_select"] .= "<option value=\"".$trep->getDisplayName()."\" $sel>".$trep->getDisplayName()."</option>";
426 } 427 }
427 } 428 }
428 429
429 $vars["projects_select"] .= "</select>"; 430 $vars["projects_select"] .= "</select>";
430 431
431 $vars["projects_submit"] = "<input type=\"submit\" value=\"${lang["GO"]}\" />"; 432 $vars["projects_submit"] = "<input type=\"submit\" value=\"${lang["GO"]}\" />";
432 $vars["projects_endform"] = "<input type=\"hidden\" name=\"selectproj\" value=\"1\" /><input type=\"hidden\" name=\"op\" value=\"form\" /><input type=\"hidden\" name=\"sc\" value=\"$showchanged\" /></form>"; 433 $vars["projects_endform"] = "<input type=\"hidden\" name=\"selectproj\" value=\"1\" /><input type=\"hidden\" name=\"op\" value=\"form\" /><input type=\"hidden\" name=\"sc\" value=\"$showchanged\" /></form>";
433 } 434 }
434   435  
435 // Create the form if we're not in MultiViews. Otherwise wsvn must create the form once the current project has 436 // Create the form if we're not in MultiViews. Otherwise wsvn must create the form once the current project has
436 // been found 437 // been found
437   438  
438 if (!$config->multiViews) 439 if (!$config->multiViews)
439 { 440 {
440 createProjectSelectionForm(); 441 createProjectSelectionForm();
441 } 442 }
442   443  
443 if ($rep) 444 if ($rep)
444 { 445 {
445 $vars["allowdownload"] = $rep->getAllowDownload(); 446 $vars["allowdownload"] = $rep->getAllowDownload();
446 $vars["repname"] = $rep->getDisplayName(); 447 $vars["repname"] = $rep->getDisplayName();
447 } 448 }
448   449  
449 // As of version 1.70 the output encoding is forced to be UTF-8, since this is the output 450 // As of version 1.70 the output encoding is forced to be UTF-8, since this is the output
450 // encoding returned by svn log --xml. This is good, since we are no longer reliant on PHP's 451 // encoding returned by svn log --xml. This is good, since we are no longer reliant on PHP's
451 // rudimentary conversions. 452 // rudimentary conversions.
452   453  
453 $vars["charset"] = "UTF-8"; 454 $vars["charset"] = "UTF-8";
454 ?> 455 ?>