jablonka.czprosek.czf

websvn

Subversion Repositories:
[/] [include/] [setup.php] - Blame information for rev 5

 

Line No. Rev Author Line
11simandl<?php
2// WebSVN - Subversion repository viewing via the web using PHP
3// Copyright (C) 2004-2006 Tim Armes
4//
5// This program is free software; you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation; either version 2 of the License, or
8// (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You should have received a copy of the GNU General Public License
16// along with this program; if not, write to the Free Software
17// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18//
19// --
20//
21// setup.php
22//
23// Global setup
24 
25// --- DON'T CHANGE THIS FILE ---
26//
27// User changes should be done in config.ini
28 
29// Include the configuration class
30require_once 'include/configclass.php';
31 
32// Create the config
33$config = new WebSvnConfig();
34 
353simandlif (DIRECTORY_SEPARATOR == '\\') {
36 $config->setServerIsWindows();
37}
38 
391simandl// Set up the default character encodings
40if (function_exists('iconv_get_encoding')) {
41 $config->setInputEncoding(iconv_get_encoding('input_encoding'));
42}
43 
44// Set up locwebsvnhttp
45// Note: we will use nothing in MultiViews mode so that the URLs use the root
46// directory by default.
47if (empty($locwebsvnhttp)) {
48 $locwebsvnhttp = defined('WSVN_MULTIVIEWS') ? '' : '.';
49}
50if (empty($locwebsvnreal)) {
51 $locwebsvnreal = '.';
52}
53 
54$vars['locwebsvnhttp'] = $locwebsvnhttp;
55 
56// {{{ Content-Type's
57// Set up the default content-type extension handling
58 
59$contentType = array (
60'.dwg' => 'application/acad', // AutoCAD Drawing files
61'.arj' => 'application/arj', //  
62'.ccad' => 'application/clariscad', // ClarisCAD files
63'.drw' => 'application/drafting', // MATRA Prelude drafting
64'.dxf' => 'application/dxf', // DXF (AutoCAD)
65'.xl' => 'application/excel', // Microsoft Excel
66'.unv' => 'application/i-deas', //SDRC I-DEAS files
67'.igs' => 'application/iges', // IGES graphics format
68'.iges' => 'application/iges', // IGES graphics format
69'.hqx' => 'application/mac-binhex40', // Macintosh BinHex format
70'.word' => 'application/msword', // Microsoft Word
71'.w6w' => 'application/msword', // Microsoft Word
72'.doc' => 'application/msword', // Microsoft Word
73'.wri' => 'application/mswrite', // Microsoft Write
74'.bin' => 'application/octet-stream', // Uninterpreted binary
75'.exe' => 'application/x-msdownload', // Windows EXE
76'.oda' => 'application/oda', //  
77'.pdf' => 'application/pdf', // PDF (Adobe Acrobat)
78'.ai' => 'application/postscript', // PostScript
79'.ps' => 'application/postscript', // PostScript
80'.eps' => 'application/postscript', // PostScript
81'.prt' => 'application/pro_eng', // PTC Pro/ENGINEER
82'.part' => 'application/pro_eng', // PTC Pro/ENGINEER
83'.rtf' => 'application/rtf', // Rich Text Format
84'.set' => 'application/set', // SET (French CAD standard)
85'.stl' => 'application/sla', // Stereolithography
86'.sol' => 'application/solids', // MATRA Prelude Solids
87'.stp' => 'application/STEP', // ISO-10303 STEP data files
88'.step' => 'application/STEP', // ISO-10303 STEP data files
89'.vda' => 'application/vda', // VDA-FS Surface data
90'.dir' => 'application/x-director', // Macromedia Director
91'.dcr' => 'application/x-director', // Macromedia Director
92'.dxr' => 'application/x-director', // Macromedia Director
93'.mif' => 'application/x-mif', // FrameMaker MIF Format
94'.csh' => 'application/x-csh', // C-shell script
95'.dvi' => 'application/x-dvi', // TeX DVI
96'.gz' => 'application/x-gzip', // GNU Zip
97'.gzip' => 'application/x-gzip', // GNU Zip
98'.hdf' => 'application/x-hdf', // ncSA HDF Data File
99'.latex' => 'application/x-latex', // LaTeX source
100'.nc' => 'application/x-netcdf', // Unidata netCDF
101'.cdf' => 'application/x-netcdf', // Unidata netCDF
102'.sit' => 'application/x-stuffit', // Stiffut Archive
103'.tcl' => 'application/x-tcl', // TCL script
104'.texinfo' => 'application/x-texinfo', // Texinfo (Emacs)
105'.texi' => 'application/x-texinfo', // Texinfo (Emacs)
106'.t' => 'application/x-troff', // Troff
107'.tr' => 'application/x-troff', // Troff
108'.roff' => 'application/x-troff', // Troff
109'.man' => 'application/x-troff-man', // Troff with MAN macros
110'.me' => 'application/x-troff-me', // Troff with ME macros
111'.ms' => 'application/x-troff-ms', // Troff with MS macros
112'.src' => 'application/x-wais-source', // WAIS source
113'.bcpio' => 'application/x-bcpio', // Old binary CPIO
114'.cpio' => 'application/x-cpio', // POSIX CPIO
115'.gtar' => 'application/x-gtar', // GNU tar
116'.shar' => 'application/x-shar', // Shell archive
117'.sv4cpio' => 'application/x-sv4cpio', // SVR4 CPIO
118'.sv4crc' => 'application/x-sv4crc', // SVR4 CPIO with CRC
119'.tar' => 'application/x-tar', // 4.3BSD tar format
120'.ustar' => 'application/x-ustar', // POSIX tar format
121'.hlp' => 'application/x-winhelp', // Windows Help
122'.zip' => 'application/zip', // ZIP archive
123'.au' => 'audio/basic', // Basic audio (usually m-law)
124'.snd' => 'audio/basic', // Basic audio (usually m-law)
125'.aif' => 'audio/x-aiff', // AIFF audio
126'.aiff' => 'audio/x-aiff', // AIFF audio
127'.aifc' => 'audio/x-aiff', // AIFF audio
128'.ra' => 'audio/x-pn-realaudio', // RealAudio
129'.ram' => 'audio/x-pn-realaudio', // RealAudio
130'.rpm' => 'audio/x-pn-realaudio-plugin', // RealAudio (plug-in)
131'.wav' => 'audio/x-wav', // Windows WAVE audio
132'.mp3' => 'audio/x-mp3', // MP3 files
133'.gif' => 'image/gif', // gif image
134'.ief' => 'image/ief', // Image Exchange Format
135'.jpg' => 'image/jpeg', // JPEG image
136'.jpe' => 'image/jpeg', // JPEG image
137'.jpeg' => 'image/jpeg', // JPEG image
138'.pict' => 'image/pict', // Macintosh PICT
139'.tiff' => 'image/tiff', // TIFF image
140'.tif' => 'image/tiff', // TIFF image
141'.ras' => 'image/x-cmu-raster', // CMU raster
142'.pnm' => 'image/x-portable-anymap', // PBM Anymap format
143'.pbm' => 'image/x-portable-bitmap', // PBM Bitmap format
144'.pgm' => 'image/x-portable-graymap', // PBM Graymap format
145'.ppm' => 'image/x-portable-pixmap', // PBM Pixmap format
146'.rgb' => 'image/x-rgb', // RGB Image
147'.xbm' => 'image/x-xbitmap', // X Bitmap
148'.xpm' => 'image/x-xpixmap', // X Pixmap
149'.xwd' => 'image/x-xwindowdump', // X Windows dump (xwd) format
150'.zip' => 'multipart/x-zip', // PKZIP Archive
151'.gzip' => 'multipart/x-gzip', // GNU ZIP Archive
152'.mpeg' => 'video/mpeg', // MPEG video
153'.mpg' => 'video/mpeg', // MPEG video
154'.mpe' => 'video/mpeg', // MPEG video
155'.mpeg' => 'video/mpeg', // MPEG video
156'.qt' => 'video/quicktime', // QuickTime Video
157'.mov' => 'video/quicktime', // QuickTime Video
158'.avi' => 'video/msvideo', // Microsoft Windows Video
159'.movie' => 'video/x-sgi-movie', // SGI Movieplayer format
160'.wrl' => 'x-world/x-vrml', // VRML Worlds
161'.odt' => 'application/vnd.oasis.opendocument.text', // OpenDocument Text
162'.ott' => 'application/vnd.oasis.opendocument.text-template', // OpenDocument Text Template
163'.ods' => 'application/vnd.oasis.opendocument.spreadsheet', // OpenDocument Spreadsheet
164'.ots' => 'application/vnd.oasis.opendocument.spreadsheet-template', // OpenDocument Spreadsheet Template
165'.odp' => 'application/vnd.oasis.opendocument.presentation', // OpenDocument Presentation
166'.otp' => 'application/vnd.oasis.opendocument.presentation-template', // OpenDocument Presentation Template
167'.odg' => 'application/vnd.oasis.opendocument.graphics', // OpenDocument Drawing
168'.otg' => 'application/vnd.oasis.opendocument.graphics-template', // OpenDocument Drawing Template
169'.odc' => 'application/vnd.oasis.opendocument.chart', // OpenDocument Chart
170'.otc' => 'application/vnd.oasis.opendocument.chart-template', // OpenDocument Chart Template
171'.odf' => 'application/vnd.oasis.opendocument.formula', // OpenDocument Formula
172'.otf' => 'application/vnd.oasis.opendocument.formula-template', // OpenDocument Formula Template
173'.odi' => 'application/vnd.oasis.opendocument.image', // OpenDocument Image
174'.oti' => 'application/vnd.oasis.opendocument.image-template', // OpenDocument Image Template
175'.odm' => 'application/vnd.oasis.opendocument.text-master', // OpenDocument Master Document
176'.oth' => 'application/vnd.oasis.opendocument.text-web', // HTML Document Template
177'.odb' => 'application/vnd.oasis.opendocument.database', // OpenDocument Database
178);
179 
180// }}}
181 
182// {{{ Enscript file extensions
183 
184// List of extensions recognised by enscript.
185 
186$extEnscript = array
187(
1883simandl '.ada' => 'ada',
189 '.adb' => 'ada',
190 '.ads' => 'ada',
191 '.awk' => 'awk',
192 '.c' => 'c',
193 '.c++' => 'cpp',
194 '.cc' => 'cpp',
195 '.cpp' => 'cpp',
196 '.csh' => 'csh',
197 '.cxx' => 'cpp',
198 '.diff' => 'diffu',
199 '.dpr' => 'delphi',
200 '.e' => 'eiffel',
201 '.el' => 'elisp',
202 '.eps' => 'postscript',
203 '.f' => 'fortran',
204 '.for' => 'fortran',
205 '.gs' => 'haskell',
206 '.h' => 'c',
207 '.hpp' => 'cpp',
208 '.hs' => 'haskell',
209 '.htm' => 'html',
210 '.html' => 'html',
211 '.idl' => 'idl',
212 '.java' => 'java',
213 '.js' => 'javascript',
214 '.lgs' => 'haskell',
215 '.lhs' => 'haskell',
216 '.m' => 'objc',
217 '.m4' => 'm4',
218 '.man' => 'nroff',
219 '.nr' => 'nroff',
220 '.p' => 'pascal',
221 '.pas' => 'delphi',
222 '.patch' => 'diffu',
223 '.pkg' => 'sql',
224 '.pl' => 'perl',
225 '.pm' => 'perl',
226 '.pp' => 'pascal',
227 '.ps' => 'postscript',
228 '.s' => 'asm',
2291simandl '.scheme' => 'scheme',
2303simandl '.scm' => 'scheme',
231 '.scr' => 'synopsys',
232 '.sh' => 'sh',
233 '.shtml' => 'html',
234 '.sql' => 'sql',
235 '.st' => 'states',
236 '.syn' => 'synopsys',
237 '.synth' => 'synopsys',
238 '.tcl' => 'tcl',
239 '.tex' => 'tex',
240 '.texi' => 'tex',
2411simandl '.texinfo' => 'tex',
2423simandl '.v' => 'verilog',
243 '.vba' => 'vba',
244 '.vh' => 'verilog',
245 '.vhd' => 'vhdl',
246 '.vhdl' => 'vhdl',
247 '.py' => 'python',
248);
2491simandl 
2503simandl// }}}
2511simandl 
2523simandl// {{{ GeSHi file extensions
253 
254// List of extensions recognised by GeSHi.
255 
256$extGeshi = array
257(
258 'actionscript3' => array('as'),
259 'ada' => array('ada', 'adb', 'ads'),
260 'asm' => array('ash', 'asi', 'asm'),
261 'asp' => array('asp'),
262 'bash' => array('sh'),
263 'c' => array('c'),
264 'cfm' => array('cfm', 'cfml'),
265 'cobol' => array('cbl'),
266 'cpp' => array('cc', 'cpp', 'cxx', 'c++', 'h', 'hpp'),
267 'csharp' => array('cs'),
268 'css' => array('css'),
269 'd' => array('d'),
270 'delphi' => array('dpk', 'dpr', 'pas'),
271 'diff' => array('diff', 'patch'),
272 'dos' => array('bat', 'cmd'),
273 'eiffel' => array('e'),
274 'email' => array('eml'),
275 'fortran' => array('f', 'for'),
276 'gettext' => array('po', 'pot'),
277 'gml' => array('gml'),
278 'gnuplot' => array('plt'),
279 'groovy' => array('groovy'),
280 'haskell' => array('gs', 'hs', 'lgs', 'lhs'),
281 'html4strict' => array('html', 'htm'),
282 'idl' => array('idl'),
283 'ini' => array('desktop', 'ini'),
284 'java5' => array('java'),
285 'javascript' => array('js'),
286 'latex' => array('tex'),
287 'lisp' => array('lisp'),
288 'lua' => array('lua'),
289 'make' => array('make'),
290 'matlab' => array('m'),
291 'perl' => array('pl', 'pm'),
292 'php' => array('php', 'php3', 'php4', 'php5', 'phps', 'phtml'),
293 'povray' => array('pov'),
294 'providex' => array('pvc', 'pvx'),
295 'python' => array('py'),
296 'reg' => array('reg'),
297 'ruby' => array('rb'),
298 'scala' => array('scala'),
299 'scheme' => array('scm', 'scheme'),
300 'scilab' => array('sci'),
301 'smalltalk' => array('st'),
302 'sql' => array('sql'),
303 'tcl' => array('tcl'),
304 'vb' => array('bas'),
305 'vh' => array('v', 'verilog'),
306 'vhdl' => array('vhd', 'vhdl'),
307 'vim' => array('vim'),
308 'whitespace' => array('ws'),
309 'xml' => array('xml', 'xsl', 'xsd', 'xib', 'wsdl', 'svg', 'plist'),
310 'z80' => array('z80'),
3111simandl);
312 
313// }}}
314 
315// Include a default language file (must go before config.php)
316require 'languages/english.php';
317 
318// Get the user's personalised config (requires the locwebsvnhttp stuff above)
3193simandlif (file_exists(dirname(__FILE__).DIRECTORY_SEPARATOR.'config.php')) {
320 require_once 'config.php';
321} else {
322 die('File "includes'.DIRECTORY_SEPARATOR.'config.php" does not exists, please create one. The example is located under "includes'.DIRECTORY_SEPARATOR.'distconfig.php"');
323}
3241simandl 
325require_once 'include/svnlook.php';
326 
327// Make sure that the input locale is set up correctly
328setlocale(LC_ALL, '');
329 
330// Default 'zipped' array
331 
332$zipped = array();
333 
334// Set up the version info
335 
3363simandlinitSvnVersion();
337$vars['svnversion'] = $config->getSubversionVersion();
3381simandl 
3393simandl// Get the user choice if there is one, and memorise the setting as a cookie
340// (since we don't have user accounts, we can't store the setting anywhere
341// else). We try to memorise a permanent cookie and a per session cookie in
342// case the user has disabled permanent ones.
3431simandl 
344$userLang = false;
345if (!empty($_REQUEST['langchoice'])) {
346 $userLang = $_REQUEST['langchoice'];
347 setcookie('storedlang', $_REQUEST['langchoice'], time()+(3600*24*356*10), '/');
348 setcookie('storedsesslang', $_REQUEST['langchoice']);
349} else { // Try to read an existing cookie if there is one
350 if (!empty($_COOKIE['storedlang'])) $userLang = $_COOKIE['storedlang'];
351 else if (!empty($_COOKIE['storedsesslang'])) $userLang = $_COOKIE['storedsesslang'];
352}
353 
354// Load available languages
355require 'languages/languages.php';
356 
357// Get the default language as defined as the default by config.php
358$defaultLang = $config->getDefaultLanguage();
359if (!isset($languages[$defaultLang])) $defaultLang = 'en';
360 
361// Negotiate language
362$userLang = getUserLanguage($languages, $defaultLang, $userLang);
363$file = $languages[$userLang][0];
364 
365// Define the language array
366$lang = array();
367 
368// XXX: this shouldn't be necessary
369// ^ i.e. just require english.php, then the desired language
370// Reload english to get untranslated strings
371require 'languages/english.php';
372 
373// Reload the default language
374require 'languages/'.$file.'.php';
375 
376$vars['lang_code'] = $userLang;
377 
378$url = '?'.buildQuery($_GET + $_POST);
379$vars["lang_form"] = "<form action=\"$url\" method=\"post\" id=\"langform\">";
380$vars["lang_select"] = "<select name=\"langchoice\" onchange=\"javascript:this.form.submit();\">";
381 
382foreach ($languages as $code => $d) {
383 $sel = ($code == $userLang) ? ' selected="selected"' : '';
384 $vars["lang_select"] .= '<option value="'.$code.'"'.$sel.'>'.$d[2].' - '.$d[1].'</option>';
385}
386 
387$vars["lang_select"] .= "</select>";
388$vars["lang_submit"] = "<input type=\"submit\" value=\"${lang["GO"]}\" />";
389$vars["lang_endform"] = "</form>";
390 
391// Set up headers
392 
393header('Content-Type: text/html; charset=UTF-8');
394header('Content-Language: '.$userLang);
395 
3963simandl// multiviews has custom code to load the repository
397if (!$config->multiViews) {
398 // if the repoparameter has been set load the corresponding
399 // repository, else load the default
400 $repname = @$_REQUEST["repname"];
401 if (isset($repname)) {
402 $rep = $config->findRepository($repname);
403 } else {
404 $reps = $config->getRepositories();
405 $rep = (isset($reps[0]) ? $reps[0] : null);
406 }
4071simandl 
4083simandl // Make sure that the user has set up a repository
409 if ($rep == null) {
410 echo $lang["SUPPLYREP"];
411 exit;
412 }
4131simandl}
414 
415 
416// Retrieve other standard parameters
417 
418// due to possible XSS exploit, we need to clean up path first
419$path = !empty($_REQUEST['path']) ? $_REQUEST['path'] : null;
4203simandlif ($path === null || $path === '') $path = '/';
4211simandl$vars['safepath'] = htmlentities($path, ENT_QUOTES, 'UTF-8');
422$rev = (int)@$_REQUEST["rev"];
423 
424// Function to create the project selection HTML form
425function createProjectSelectionForm() {
426 global $config, $vars, $rep, $lang;
427 
428 if (!$config->showRepositorySelectionForm()) {
429 $vars["projects_form"] = '';
430 $vars["projects_select"] = '';
431 $vars["projects_submit"] = '';
432 $vars["projects_hidden"] = '';
433 $vars["projects_endform"] = '';
434 return;
435 }
436 
437 $url = $config->getURL(-1, "", "form");
438 $vars["projects_form"] = "<form action=\"$url\" method=\"post\" id=\"projectform\">";
439 
440 $reps = $config->getRepositories();
441 $vars["projects_select"] = "<select name=\"repname\" onchange=\"javascript:this.form.submit();\">";
442 
443 foreach ($reps as $trep) {
444 if ($trep->hasReadAccess("/", true)) {
445 if ($rep->getDisplayName() == $trep->getDisplayName()) {
446 $sel = ' selected="selected"';
447 } else {
448 $sel = "";
449 }
450 
451 $vars["projects_select"] .= "<option value=\"".$trep->getDisplayName()."\"$sel>".$trep->getDisplayName()."</option>";
452 }
453 }
454 
455 $vars["projects_select"] .= "</select>";
456 
457 $vars["projects_submit"] = "<input type=\"submit\" value=\"${lang["GO"]}\" />";
458 $vars["projects_hidden"] = "<input type=\"hidden\" name=\"selectproj\" value=\"1\" /><input type=\"hidden\" name=\"op\" value=\"form\" />";
459 $vars["projects_endform"] = "</form>";
460}
461 
462// Function to create the revision selection HTML form
463function createRevisionSelectionForm() {
464 global $config, $vars, $rep, $lang, $showchanged, $rev;
465 
466 if ($rev == 0) {
467 $thisrev = "HEAD";
468 } else {
469 $thisrev = $rev;
470 }
471 
472 list($url, $params) = $config->getUrlParts($rep, '', 'revision');
473 $vars["revision_form"] = "<form action=\"$url\" method=\"get\" id=\"revisionform\">";
474 
4753simandl $vars["revision_input"] = "<input type=\"text\" size=\"5\" name=\"rev\" value=\"$thisrev\" />";
4761simandl $hidden = '';
477 foreach ($params as $k => $v) {
478 $hidden .= "<input type=\"hidden\" name=\"$k\" value=\"".htmlspecialchars($v)."\" />";
479 }
480 $vars["revision_hidden"] = $hidden;
481 
482 $vars["revision_submit"] = "<input type=\"submit\" value=\"${lang["GO"]}\" />";
483 $vars["revision_endform"] = "</form>";
484}
485 
486// Create the form if we're not in MultiViews. Otherwise wsvn must create the form once the current project has
487// been found
488 
489if (!$config->multiViews) {
490 createProjectSelectionForm();
491 createRevisionSelectionForm();
492}
493 
4943simandlif (!$config->multiViews && $rep) {
4951simandl $vars["allowdownload"] = $rep->getAllowDownload();
496 $vars["repname"] = htmlentities($rep->getDisplayName(), ENT_QUOTES, 'UTF-8');
497}
498 
499// As of version 1.70 the output encoding is forced to be UTF-8, since this is the output
500// encoding returned by svn log --xml. This is good, since we are no longer reliant on PHP's
501// rudimentary conversions.
502 
503$vars["charset"] = "UTF-8";

Powered by WebSVN 2.2.1