jablonka.czprosek.czf

websvn

Subversion Repositories:
[/] [filedetails.php] - Blame information for rev 3

 

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// filedetails.php
22//
23// Simply lists the contents of a file
24 
25require_once("include/setup.php");
26require_once("include/svnlook.php");
27require_once("include/utils.php");
28require_once("include/template.php");
29 
30// Make sure that we have a repository
31if (!isset($rep)) {
32 echo $lang["NOREP"];
33 exit;
34}
35 
36$svnrep = new SVNRepository($rep);
37 
38if ($path{0} != "/") {
39 $ppath = "/".$path;
40} else {
41 $ppath = $path;
42}
43 
44$passrev = $rev;
45 
46// If there's no revision info, go to the lastest revision for this path
47$history = $svnrep->getLog($path, "", "", true);
483simandlif (is_string($history)) {
49 echo $history;
50 exit;
51}
521simandl$youngest = isset($history->entries[0]) ? $history->entries[0]->rev: false;
53 
54if (empty($rev)) {
55 $rev = $youngest;
56}
57 
58$extn = strtolower(strrchr($path, "."));
59 
60// Check to see if the user has requested that this type be zipped and sent
61// to the browser as an attachment
62 
63if (in_array($extn, $zipped) && $rep->hasReadAccess($path, false)) {
64 $base = basename($path);
65 header("Content-Type: application/x-gzip");
66 header("Content-Disposition: attachment; filename=".urlencode($base).".gz");
67 
68 // Get the file contents and pipe into gzip. All this without creating
69 // a temporary file. Damn clever.
70 $svnrep->getFileContents($path, "", $rev, "| ".$config->gzip." -n -f");
71 
72 exit;
73}
74 
75// Check to see if we should serve it with a particular content-type.
76// The content-type could come from an svn:mime-type property on the
77// file, or from the $contentType array in setup.php.
78 
79if (!$rep->getIgnoreSvnMimeTypes()) {
80 $svnMimeType = $svnrep->getProperty($path, 'svn:mime-type', $rev);
81}
82 
83if (!$rep->getIgnoreWebSVNContentTypes()) {
84 $setupContentType = @$contentType[$extn];
85}
86 
873simandl// Use the documented priorities when establishing what content-type to use.
881simandlif (!empty($svnMimeType) && $svnMimeType != 'application/octet-stream') {
893simandl $mimeType = $svnMimeType;
901simandl} else if (!empty($setupContentType)) {
913simandl $mimeType = $setupContentType;
921simandl} else if (!empty($svnMimeType)) {
933simandl $mimeType = $svnMimeType; // Use SVN's default of "application/octet-stream"
941simandl}
95 
963simandl// If the MIME type exists but is set to be ignored, set it to an empty string.
97if (!empty($mimeType)) {
98 foreach ($config->inlineMimeTypes as $inlineType) {
99 if (preg_match('|'.$inlineType.'|', $mimeType)) {
100 $mimeType = '';
101 break;
102 }
103 }
104}
1051simandl 
1063simandl// If a MIME type is associated with the file, deliver with Content-Type header.
107if (!empty($mimeType) && $rep->hasReadAccess($path, false)) {
1081simandl $base = basename($path);
1093simandl header('Content-Type: '.$mimeType);
110 //header('Content-Length: '.$size);
111 header('Content-Disposition: inline; filename='.urlencode($base));
1121simandl $svnrep->getFileContents($path, "", $rev);
113 exit;
114}
115 
1163simandl// Display the file inline using WebSVN.
1171simandl 
118$url = $config->getURL($rep, $path, "file");
119 
120if ($rev != $youngest) {
121 $vars["goyoungestlink"] = "<a href=\"${url}\">${lang["GOYOUNGEST"]}</a>";
122} else {
123 $vars["goyoungestlink"] = "";
124}
125 
126$vars["action"] = "";
127$vars["repname"] = htmlentities($rep->getDisplayName(), ENT_QUOTES, 'UTF-8');
128$vars["rev"] = htmlentities($rev, ENT_QUOTES, 'UTF-8');
129$vars["path"] = htmlentities($ppath, ENT_QUOTES, 'UTF-8');
130 
131createDirLinks($rep, $ppath, $passrev);
132 
133$vars['indexurl'] = $config->getURL($rep, '', 'index');
134$vars['repurl'] = $config->getURL($rep, '', 'dir');
135 
136$url = $config->getURL($rep, $path, "log");
137$vars["fileviewloglink"] = "<a href=\"${url}rev=$passrev&amp;isdir=0\">${lang["VIEWLOG"]}</a>";
138 
139$url = $config->getURL($rep, $path, "diff");
140$vars["prevdifflink"] = "<a href=\"${url}rev=$passrev\">${lang["DIFFPREV"]}</a>";
141 
142$url = $config->getURL($rep, $path, "blame");
143$vars["blamelink"] = "<a href=\"${url}rev=$passrev\">${lang["BLAME"]}</a>";
144 
1453simandlif ($rep->isDownloadAllowed($path)) {
146 $url = $config->getURL($rep, $path, "dl");
147 $vars["dllink"] = "<a href=\"${url}rev=$passrev\">${lang["DOWNLOAD"]}</a>";
148}
149 
1501simandl$listing = array();
151 
152$vars["version"] = $version;
153 
154if (!$rep->hasReadAccess($path, false)) {
155 $vars["noaccess"] = true;
156}
157 
158parseTemplate($rep->getTemplatePath()."header.tmpl", $vars, $listing);
159parseTemplate($rep->getTemplatePath()."file.tmpl", $vars, $listing);
160parseTemplate($rep->getTemplatePath()."footer.tmpl", $vars, $listing);

Powered by WebSVN 2.2.1