version 3.9, 2000/07/29 12:41:25 |
version 3.27, 2000/09/28 18:06:58 |
|
|
#!/usr/bin/perl -ws |
#!/usr/bin/perl5 -ws |
# |
# |
# cvsweb - a CGI interface to CVS trees. |
# cvsweb - a CGI interface to CVS trees. |
# |
# |
# Written in their spare time by |
# Written in their spare time by |
# Bill Fenner <fenner@FreeBSD.org> (original work) |
# Bill Fenner <fenner@FreeBSD.org> (original work) |
# extended by Henner Zeller <zeller@think.de>, |
# extended by Henner Zeller <zeller@think.de>, |
# Henrik Nordstrom <hno@hem.passagen.se> |
# Henrik Nordstrom <hno@hem.passagen.se> |
# Ken Coar <coar@Apache.Org> |
# Ken Coar <coar@Apache.Org> |
# Dick Balaska <dick@buckosoft.com> |
# Dick Balaska <dick@buckosoft.com> |
# Akinori MUSHA <knu@FreeBSD.org> |
# Akinori MUSHA <knu@FreeBSD.org> |
|
# Jens-Uwe Mager <jum@helios.de> |
# |
# |
# Based on: |
# Based on: |
# * Bill Fenners cvsweb.cgi revision 1.28 available from: |
# * Bill Fenners cvsweb.cgi revision 1.28 available from: |
|
|
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
# SUCH DAMAGE. |
# SUCH DAMAGE. |
# |
# |
# $zId: cvsweb.cgi,v 1.93 2000/07/27 17:42:28 hzeller Exp $ |
# $zId: cvsweb.cgi,v 1.103 2000/09/20 17:02:29 jumager Exp $ |
# $Id$ |
# $Id$ |
# |
# |
### |
### |
|
|
%CVSROOT %CVSROOTdescr %MIRRORS %DEFAULTVALUE %ICONS %MTYPES |
%CVSROOT %CVSROOTdescr %MIRRORS %DEFAULTVALUE %ICONS %MTYPES |
%alltags @tabcolors %fileinfo %tags @branchnames %nameprinted |
%alltags @tabcolors %fileinfo %tags @branchnames %nameprinted |
%symrev %revsym @allrevisions %date %author @revdisplayorder |
%symrev %revsym @allrevisions %date %author @revdisplayorder |
@revisions %state %difflines %log %branchpoint @revorder $prcgi |
@revisions %state %difflines %log %branchpoint @revorder |
@prcategories $prcategories |
$prcgi @prcategories $prcategories $mancgi |
$checkoutMagic $doCheckout $scriptname $scriptwhere |
$checkoutMagic $doCheckout $scriptname $scriptwhere |
$where $pathinfo $Browser $nofilelinks $maycompress @stickyvars |
$where $pathinfo $Browser $nofilelinks $maycompress @stickyvars |
%funcline_regexp $is_mod_perl |
%funcline_regexp $is_mod_perl |
|
|
$bylog $byfile $hr_default $logsort $cvstree $cvsroot |
$bylog $byfile $hr_default $logsort $cvstree $cvsroot |
$mimetype $defaultTextPlain $defaultViewable $allow_compress |
$mimetype $defaultTextPlain $defaultViewable $allow_compress |
$GZIPBIN $backicon $diricon $fileicon $fullname $newname |
$GZIPBIN $backicon $diricon $fileicon $fullname $newname |
$cvstreedefault $body_tag $logo $defaulttitle $address |
$cvstreedefault $body_tag $body_tag_for_src |
$backcolor $long_intro $short_instruction $shortLogLen |
$logo $defaulttitle $address |
|
$long_intro $short_instruction $shortLogLen |
$show_author $dirtable $tablepadding $columnHeaderColorDefault |
$show_author $dirtable $tablepadding $columnHeaderColorDefault |
$columnHeaderColorSorted $hr_breakable $showfunc $hr_ignwhite |
$columnHeaderColorSorted $hr_breakable $showfunc $hr_ignwhite |
$hr_ignkeysubst $diffcolorHeading $diffcolorEmpty $diffcolorRemove |
$hr_ignkeysubst $diffcolorHeading $diffcolorEmpty $diffcolorRemove |
|
|
$navigationHeaderColor $tableBorderColor $markupLogColor |
$navigationHeaderColor $tableBorderColor $markupLogColor |
$tabstop $state $annTable $sel $curbranch @HideModules |
$tabstop $state $annTable $sel $curbranch @HideModules |
$module $use_descriptions %descriptions @mytz $dwhere $moddate |
$module $use_descriptions %descriptions @mytz $dwhere $moddate |
$use_moddate |
$use_moddate $has_zlib $gzip_open |
); |
); |
|
|
|
sub printDiffSelect($); |
|
sub findLastModifiedSubdirs(@); |
|
sub htmlify($;$); |
|
sub spacedHtmlText($;$); |
|
sub link($$); |
|
sub revcmp($$); |
|
sub fatal($$); |
|
sub redirect($); |
|
sub safeglob($); |
|
sub getMimeTypeFromSuffix($); |
|
sub head($;$); |
|
sub scan_directives(@); |
|
sub doAnnotate($$); |
|
sub doCheckout($$); |
|
sub cvswebMarkup($$$); |
|
sub viewable($); |
|
sub doDiff($$$$$$); |
|
sub getDirLogs($$@); |
|
sub readLog($;$); |
|
sub printLog($;$); |
|
sub doLog($); |
|
sub flush_diff_rows($$$$); |
|
sub human_readable_diff($); |
|
sub navigateHeader($$$$$); |
|
sub plural_write($$); |
|
sub readableTime($$); |
|
sub clickablePath($$); |
|
sub chooseCVSRoot(); |
|
sub chooseMirror(); |
|
sub fileSortCmp(); |
|
sub download_url($$;$); |
|
sub download_link($$$;$); |
|
sub toggleQuery($$); |
|
sub urlencode($); |
|
sub http_header(;$); |
|
sub html_header($); |
|
sub html_footer(); |
|
sub link_tags($); |
|
sub forbidden_module($); |
|
|
##### Start of Configuration Area ######## |
##### Start of Configuration Area ######## |
# == EDIT this == |
use Cwd; |
|
|
|
# == EDIT this == |
# User configuration is stored in |
# User configuration is stored in |
$config = defined($ENV{CVSWEB_CONFIG}) ? $ENV{CVSWEB_CONFIG} : '/usr/local/etc/cvsweb.conf'; |
$config = undef; |
|
|
|
for ($ENV{CVSWEB_CONFIG}, |
|
# '/home/knu/etc/cvsweb.conf', |
|
'/usr/local/etc/cvsweb.conf', |
|
getcwd . '/cvsweb.conf') { |
|
$config = $_ if defined($_) && -r $_; |
|
} |
|
|
# == Configuration defaults == |
# == Configuration defaults == |
# Defaults for configuration variables that shouldn't need |
# Defaults for configuration variables that shouldn't need |
# to be configured.. |
# to be configured.. |
Line 95 $allow_version_select = 1; |
|
Line 146 $allow_version_select = 1; |
|
# These are defined to allow checking with perl -cw |
# These are defined to allow checking with perl -cw |
%CVSROOT = %MIRRORS = %DEFAULTVALUE = %ICONS = %MTYPES = |
%CVSROOT = %MIRRORS = %DEFAULTVALUE = %ICONS = %MTYPES = |
%tags = %alltags = @tabcolors = (); |
%tags = %alltags = @tabcolors = (); |
$cvstreedefault = $body_tag = $logo = $defaulttitle = $address = |
$cvstreedefault = $body_tag = $body_tag_for_src = |
$backcolor = $long_intro = $short_instruction = $shortLogLen = |
$logo = $defaulttitle = $address = |
|
$long_intro = $short_instruction = $shortLogLen = |
$show_author = $dirtable = $tablepadding = $columnHeaderColorDefault = |
$show_author = $dirtable = $tablepadding = $columnHeaderColorDefault = |
$columnHeaderColorSorted = $hr_breakable = $showfunc = $hr_ignwhite = |
$columnHeaderColorSorted = $hr_breakable = $showfunc = $hr_ignwhite = |
$hr_ignkeysubst = $diffcolorHeading = $diffcolorEmpty = $diffcolorRemove = |
$hr_ignkeysubst = $diffcolorHeading = $diffcolorEmpty = $diffcolorRemove = |
Line 105 $difffontsize = $inputTextSize = $mime_types = $allow_ |
|
Line 157 $difffontsize = $inputTextSize = $mime_types = $allow_ |
|
$allow_markup = $use_java_script = $open_extern_window = |
$allow_markup = $use_java_script = $open_extern_window = |
$extern_window_width = $extern_window_height = $edit_option_form = |
$extern_window_width = $extern_window_height = $edit_option_form = |
$checkout_magic = $show_subdir_lastmod = $show_log_in_markup = $v = |
$checkout_magic = $show_subdir_lastmod = $show_log_in_markup = $v = |
$navigationHeaderColor = $tableBorderColor = $markupLogColor = |
$navigationHeaderColor = $tableBorderColor = $markupLogColor = |
$tabstop = $use_moddate = $moddate = undef; |
$tabstop = $use_moddate = $moddate = $gzip_open = undef; |
|
|
##### End of configuration variables ##### |
##### End of configuration variables ##### |
|
|
use Time::Local; |
use Time::Local; |
use IPC::Open2; |
use IPC::Open2; |
|
|
|
# Check if the zlib C library interface is installed, and if yes |
|
# we can avoid using the extra gzip process. |
|
eval { |
|
require Compress::Zlib; |
|
}; |
|
$has_zlib = !$@; |
|
|
$verbose = $v; |
$verbose = $v; |
$checkoutMagic = "~checkout~"; |
$checkoutMagic = "~checkout~"; |
$pathinfo = defined($ENV{PATH_INFO}) ? $ENV{PATH_INFO} : ''; |
$pathinfo = defined($ENV{PATH_INFO}) ? $ENV{PATH_INFO} : ''; |
Line 133 $is_mod_perl = defined($ENV{MOD_PERL}); |
|
Line 192 $is_mod_perl = defined($ENV{MOD_PERL}); |
|
# in lynx, it it very annoying to have two links |
# in lynx, it it very annoying to have two links |
# per file, so disable the link at the icon |
# per file, so disable the link at the icon |
# in this case: |
# in this case: |
$Browser = $ENV{HTTP_USER_AGENT} || ''; |
$Browser = $ENV{HTTP_USER_AGENT}; |
$is_lynx = ($Browser =~ m`^Lynx/`i); |
$is_lynx = ($Browser =~ m`^Lynx/`i); |
$is_w3m = ($Browser =~ m`^w3m/`i); |
$is_w3m = ($Browser =~ m`^w3m/`i); |
$is_msie = ($Browser =~ m`MSIE`); |
$is_msie = ($Browser =~ m`MSIE`); |
Line 150 $nofilelinks = $is_textbased; |
|
Line 209 $nofilelinks = $is_textbased; |
|
# braindamaged MS-Internet Exploders claim that they |
# braindamaged MS-Internet Exploders claim that they |
# accept gzip .. but don't in fact and |
# accept gzip .. but don't in fact and |
# display garbage then :-/ |
# display garbage then :-/ |
# Turn off gzip if running under mod_perl. piping does |
# Turn off gzip if running under mod_perl and no zlib is available, |
# not work as expected inside the server. One can probably |
# piping does not work as expected inside the server. |
# achieve the same result using Apache::GZIPFilter. |
$maycompress = (((defined($ENV{HTTP_ACCEPT_ENCODING}) |
$maycompress =(($ENV{HTTP_ACCEPT_ENCODING} =~ m`gzip` |
&& $ENV{HTTP_ACCEPT_ENCODING} =~ m`gzip`) |
|| $is_mozilla3) |
|| $is_mozilla3) |
&& !$is_msie |
&& !$is_msie |
&& !$is_mod_perl); |
&& !($is_mod_perl && !$has_zlib)); |
|
|
# put here the variables we need in order |
# put here the variables we need in order |
# to hold our state - they will be added (with |
# to hold our state - they will be added (with |
# their current value) to any link/query string |
# their current value) to any link/query string |
# you construct |
# you construct |
@stickyvars = qw(cvsroot hideattic sortby logsort f only_with_tag); |
@stickyvars = qw(cvsroot hideattic sortby logsort f only_with_tag); |
|
|
if (-f $config) { |
if (-f $config) { |
do $config; |
do $config |
} |
|| &fatal("500 Internal Error", |
else { |
sprintf('Error in loading configuration file: %s<BR><BR>%s<BR>', |
|
$config, &htmlify($@))); |
|
} else { |
&fatal("500 Internal Error", |
&fatal("500 Internal Error", |
'Configuration not found. Set the variable <code>$config</code> ' |
'Configuration not found. Set the variable <code>$config</code> ' |
. 'in cvsweb.cgi, or the environment variable ' |
. 'in cvsweb.cgi, or the environment variable ' |
|
|
undef %input; |
undef %input; |
$query = $ENV{QUERY_STRING}; |
$query = $ENV{QUERY_STRING}; |
|
|
if ($query ne '') { |
if (defined($query) && $query ne '') { |
foreach (split(/&/, $query)) { |
foreach (split(/&/, $query)) { |
s/%(..)/sprintf("%c", hex($1))/ge; # unquote %-quoted |
s/%(..)/sprintf("%c", hex($1))/ge; # unquote %-quoted |
if (/(\S+)=(.*)/) { |
if (/(\S+)=(.*)/) { |
Line 190 if ($query ne '') { |
|
Line 251 if ($query ne '') { |
|
} |
} |
} |
} |
|
|
# For backwards compability, set only_with_tag to only_on_branch if set. |
# For backwards compability, set only_with_tag to only_on_branch if set. |
$input{only_with_tag} = $input{only_on_branch} |
$input{only_with_tag} = $input{only_on_branch} |
if (defined($input{only_on_branch})); |
if (defined($input{only_on_branch})); |
|
|
Line 217 foreach (keys %DEFAULTVALUE) |
|
Line 278 foreach (keys %DEFAULTVALUE) |
|
} |
} |
} |
} |
} |
} |
|
|
$barequery = ""; |
$barequery = ""; |
foreach (@stickyvars) { |
foreach (@stickyvars) { |
# construct a query string with the sticky non default parameters set |
# construct a query string with the sticky non default parameters set |
if (defined($input{$_}) && $input{$_} ne '' && |
if (defined($input{$_}) && $input{$_} ne '' && |
!(defined($DEFAULTVALUE{$_}) && $input{$_} eq $DEFAULTVALUE{$_})) { |
!(defined($DEFAULTVALUE{$_}) && $input{$_} eq $DEFAULTVALUE{$_})) { |
if ($barequery) { |
if ($barequery) { |
$barequery = $barequery . "&"; |
$barequery = $barequery . "&"; |
Line 296 foreach my $k (keys %ICONS) { |
|
Line 357 foreach my $k (keys %ICONS) { |
|
} |
} |
} |
} |
|
|
|
my $config_cvstree = "$config-$cvstree"; |
|
|
# Do some special configuration for cvstrees |
# Do some special configuration for cvstrees |
do "$config-$cvstree" if (-f "$config-$cvstree"); |
if (-f $config_cvstree) { |
|
do $config_cvstree |
|
|| &fatal("500 Internal Error", |
|
sprintf('Error in loading configuration file: %s<BR><BR>%s<BR>', |
|
$config_cvstree, &htmlify($@))); |
|
} |
|
|
$prcategories = '(?:' . join('|', @prcategories) . ')'; |
$prcategories = '(?:' . join('|', @prcategories) . ')'; |
|
$prcgi .= '%s' if defined($prcgi) && $prcgi !~ /%s/; |
|
|
$fullname = $cvsroot . '/' . $where; |
$fullname = $cvsroot . '/' . $where; |
$mimetype = &getMimeTypeFromSuffix ($fullname); |
$mimetype = &getMimeTypeFromSuffix ($fullname); |
Line 309 $defaultViewable = $allow_markup && viewable($mimetype |
|
Line 378 $defaultViewable = $allow_markup && viewable($mimetype |
|
# search for GZIP if compression allowed |
# search for GZIP if compression allowed |
# We've to find out if the GZIP-binary exists .. otherwise |
# We've to find out if the GZIP-binary exists .. otherwise |
# ge get an Internal Server Error if we try to pipe the |
# ge get an Internal Server Error if we try to pipe the |
# output through the nonexistent gzip .. |
# output through the nonexistent gzip .. |
# any more elegant ways to prevent this are welcome! |
# any more elegant ways to prevent this are welcome! |
if ($allow_compress && $maycompress) { |
if ($allow_compress && $maycompress && !$has_zlib) { |
foreach (split(/:/, $ENV{PATH})) { |
foreach (split(/:/, $ENV{PATH})) { |
if (-x "$_/gzip") { |
if (-x "$_/gzip") { |
$GZIPBIN = "$_/gzip"; |
$GZIPBIN = "$_/gzip"; |
Line 390 elsif (-d $fullname) { |
|
Line 459 elsif (-d $fullname) { |
|
$input{only_with_tag}; |
$input{only_with_tag}; |
|
|
} |
} |
|
|
|
|
|
|
print "<HR NOSHADE>\n"; |
print "<HR NOSHADE>\n"; |
# Using <MENU> in this manner violates the HTML2.0 spec but |
# Using <MENU> in this manner violates the HTML2.0 spec but |
# provides the results that I want in most browsers. Another |
# provides the results that I want in most browsers. Another |
# case of layout spooging up HTML. |
# case of layout spooging up HTML. |
|
|
my $infocols = 0; |
my $infocols = 0; |
if ($dirtable) { |
if ($dirtable) { |
if (defined($tableBorderColor)) { |
if (defined($tableBorderColor)) { |
Line 405 elsif (-d $fullname) { |
|
Line 474 elsif (-d $fullname) { |
|
} |
} |
print "<table width=\"100%\" border=0 cellspacing=1 cellpadding=$tablepadding>\n"; |
print "<table width=\"100%\" border=0 cellspacing=1 cellpadding=$tablepadding>\n"; |
$infocols++; |
$infocols++; |
print "<tr><th align=left bgcolor=\"" . (($byfile) ? |
print "<tr><th align=left bgcolor=\"" . (($byfile) ? |
$columnHeaderColorSorted : |
$columnHeaderColorSorted : |
$columnHeaderColorDefault) . "\">"; |
$columnHeaderColorDefault) . "\">"; |
print "<a href=\"./" . &toggleQuery("sortby","file") . |
print "<a href=\"./" . &toggleQuery("sortby","file") . |
"#dirlist\">" if (!$byfile); |
"#dirlist\">" if (!$byfile); |
Line 417 elsif (-d $fullname) { |
|
Line 486 elsif (-d $fullname) { |
|
# with revision information: |
# with revision information: |
if (scalar(%fileinfo)) { |
if (scalar(%fileinfo)) { |
$infocols++; |
$infocols++; |
print "<th align=left bgcolor=\"" . (($byrev) ? |
print "<th align=left bgcolor=\"" . (($byrev) ? |
$columnHeaderColorSorted : |
$columnHeaderColorSorted : |
$columnHeaderColorDefault) . "\">"; |
$columnHeaderColorDefault) . "\">"; |
print "<a href=\"./" . &toggleQuery ("sortby","rev") . |
print "<a href=\"./" . &toggleQuery ("sortby","rev") . |
"#dirlist\">" if (!$byrev); |
"#dirlist\">" if (!$byrev); |
Line 426 elsif (-d $fullname) { |
|
Line 495 elsif (-d $fullname) { |
|
print "</a>" if (!$byrev); |
print "</a>" if (!$byrev); |
print "</th>"; |
print "</th>"; |
$infocols++; |
$infocols++; |
print "<th align=left bgcolor=\"" . (($bydate) ? |
print "<th align=left bgcolor=\"" . (($bydate) ? |
$columnHeaderColorSorted : |
$columnHeaderColorSorted : |
$columnHeaderColorDefault) . "\">"; |
$columnHeaderColorDefault) . "\">"; |
print "<a href=\"./" . &toggleQuery ("sortby","date") . |
print "<a href=\"./" . &toggleQuery ("sortby","date") . |
"#dirlist\">" if (!$bydate); |
"#dirlist\">" if (!$bydate); |
Line 436 elsif (-d $fullname) { |
|
Line 505 elsif (-d $fullname) { |
|
print "</th>"; |
print "</th>"; |
if ($show_author) { |
if ($show_author) { |
$infocols++; |
$infocols++; |
print "<th align=left bgcolor=\"" . (($byauthor) ? |
print "<th align=left bgcolor=\"" . (($byauthor) ? |
$columnHeaderColorSorted : |
$columnHeaderColorSorted : |
$columnHeaderColorDefault) . "\">"; |
$columnHeaderColorDefault) . "\">"; |
print "<a href=\"./" . &toggleQuery ("sortby","author") . |
print "<a href=\"./" . &toggleQuery ("sortby","author") . |
"#dirlist\">" if (!$byauthor); |
"#dirlist\">" if (!$byauthor); |
Line 446 elsif (-d $fullname) { |
|
Line 515 elsif (-d $fullname) { |
|
print "</th>"; |
print "</th>"; |
} |
} |
$infocols++; |
$infocols++; |
print "<th align=left bgcolor=\"" . (($bylog) ? |
print "<th align=left bgcolor=\"" . (($bylog) ? |
$columnHeaderColorSorted : |
$columnHeaderColorSorted : |
$columnHeaderColorDefault) . "\">"; |
$columnHeaderColorDefault) . "\">"; |
print "<a href=\"./", toggleQuery("sortby","log"), "#dirlist\">" if (!$bylog); |
print "<a href=\"./", toggleQuery("sortby","log"), "#dirlist\">" if (!$bylog); |
print "Last log entry"; |
print "Last log entry"; |
Line 465 elsif (-d $fullname) { |
|
Line 534 elsif (-d $fullname) { |
|
print "<menu>\n"; |
print "<menu>\n"; |
} |
} |
my $dirrow = 0; |
my $dirrow = 0; |
|
|
my $i; |
my $i; |
lookingforattic: |
lookingforattic: |
for ($i = 0; $i <= $#dir; $i++) { |
for ($i = 0; $i <= $#dir; $i++) { |
Line 480 elsif (-d $fullname) { |
|
Line 549 elsif (-d $fullname) { |
|
closedir($dh); |
closedir($dh); |
} |
} |
|
|
my $hideAtticToggleLink = "<a href=\"./" . |
my $hideAtticToggleLink = "<a href=\"./" . |
&toggleQuery ("hideattic") . |
&toggleQuery ("hideattic") . |
"#dirlist\">[Hide]</a>" if (!$input{'hideattic'}); |
"#dirlist\">[Hide]</a>" if (!$input{'hideattic'}); |
|
|
Line 542 elsif (-d $fullname) { |
|
Line 611 elsif (-d $fullname) { |
|
} |
} |
print " ", &link($_ . "/", $url), $attic; |
print " ", &link($_ . "/", $url), $attic; |
if ($_ eq "Attic") { |
if ($_ eq "Attic") { |
print " <a href=\"./" . |
print " <a href=\"./" . |
&toggleQuery ("hideattic") . |
&toggleQuery ("hideattic") . |
"#dirlist\">[Don't hide]</a>"; |
"#dirlist\">[Don't hide]</a>"; |
} |
} |
} |
} |
# Show last change in dir |
# Show last change in dir |
if ($filename) { |
if ($filename) { |
print "</td><td> </td><td> " if ($dirtable); |
print "</td><td> </td><td> " if ($dirtable); |
Line 615 elsif (-d $fullname) { |
|
Line 684 elsif (-d $fullname) { |
|
print " ", &link($_, $url), $attic; |
print " ", &link($_, $url), $attic; |
print "</td><td> " if ($dirtable); |
print "</td><td> " if ($dirtable); |
download_link($fileurl, |
download_link($fileurl, |
$rev, $rev, |
$rev, $rev, |
$defaultViewable ? "text/x-cvsweb-markup" : undef); |
$defaultViewable ? "text/x-cvsweb-markup" : undef); |
print "</td><td> " if ($dirtable); |
print "</td><td> " if ($dirtable); |
if ($date) { |
if ($date) { |
Line 643 elsif (-d $fullname) { |
|
Line 712 elsif (-d $fullname) { |
|
print "</td></tr></table>"; |
print "</td></tr></table>"; |
} |
} |
print "". ($dirtable == 1) ? "</table>" : "</menu>" . "\n"; |
print "". ($dirtable == 1) ? "</table>" : "</menu>" . "\n"; |
|
|
if ($filesexists && !$filesfound) { |
if ($filesexists && !$filesfound) { |
print "<P><B>NOTE:</B> There are $filesexists files, but none matches the current tag ($input{only_with_tag})\n"; |
print "<P><B>NOTE:</B> There are $filesexists files, but none matches the current tag ($input{only_with_tag})\n"; |
} |
} |
if ($input{only_with_tag} && (!%tags || !$tags{$input{only_with_tag}})) { |
if ($input{only_with_tag} && (!%tags || !$tags{$input{only_with_tag}})) { |
%tags = %alltags |
%tags = %alltags |
} |
} |
if (scalar %tags |
if (scalar %tags |
|| $input{only_with_tag} |
|| $input{only_with_tag} |
|| $edit_option_form |
|| $edit_option_form |
|| defined($input{"options"})) { |
|| defined($input{"options"})) { |
print "<hr size=1 NOSHADE>"; |
print "<hr size=1 NOSHADE>"; |
Line 662 elsif (-d $fullname) { |
|
Line 731 elsif (-d $fullname) { |
|
foreach my $var (@stickyvars) { |
foreach my $var (@stickyvars) { |
print "<INPUT TYPE=HIDDEN NAME=\"$var\" VALUE=\"$input{$var}\">\n" |
print "<INPUT TYPE=HIDDEN NAME=\"$var\" VALUE=\"$input{$var}\">\n" |
if (defined($input{$var}) |
if (defined($input{$var}) |
&& $input{$var} ne $DEFAULTVALUE{$var} |
&& (!defined($DEFAULTVALUE{$var}) |
|
|| $input{$var} ne $DEFAULTVALUE{$var}) |
&& $input{$var} ne "" |
&& $input{$var} ne "" |
&& $var ne "only_with_tag"); |
&& $var ne "only_with_tag"); |
} |
} |
Line 672 elsif (-d $fullname) { |
|
Line 742 elsif (-d $fullname) { |
|
print ">"; |
print ">"; |
print "<OPTION VALUE=\"\">All tags / default branch\n"; |
print "<OPTION VALUE=\"\">All tags / default branch\n"; |
foreach my $tag (reverse sort { lc $a cmp lc $b } keys %tags) { |
foreach my $tag (reverse sort { lc $a cmp lc $b } keys %tags) { |
print "<OPTION",defined($input{only_with_tag}) && |
print "<OPTION",defined($input{only_with_tag}) && |
$input{only_with_tag} eq $tag ? " SELECTED":"", |
$input{only_with_tag} eq $tag ? " SELECTED" : "", |
">$tag\n"; |
">$tag\n"; |
} |
} |
print "</SELECT>\n"; |
print "</SELECT>\n"; |
Line 706 elsif (-d $fullname) { |
|
Line 776 elsif (-d $fullname) { |
|
print "<OPTION VALUE=rev",$logsort eq "rev" ? " SELECTED" : "", ">Revision"; |
print "<OPTION VALUE=rev",$logsort eq "rev" ? " SELECTED" : "", ">Revision"; |
print "</SELECT></td></tr>"; |
print "</SELECT></td></tr>"; |
print "<tr><td>Diff format: "; |
print "<tr><td>Diff format: "; |
printDiffSelect(); |
printDiffSelect(0); |
print "</td>"; |
print "</td>"; |
print "<td>Show Attic files: "; |
print "<td>Show Attic files: "; |
print "<INPUT NAME=hideattic TYPE=CHECKBOX", $input{'hideattic'}?" CHECKED":"", |
print "<INPUT NAME=hideattic TYPE=CHECKBOX", $input{'hideattic'} ? " CHECKED" : "", |
"></td></tr>\n"; |
"></td></tr>\n"; |
print "<tr><td align=center colspan=2><input type=submit value=\"Change Options\">"; |
print "<tr><td align=center colspan=2><input type=submit value=\"Change Options\">"; |
print "</td></tr></table></center></FORM>\n"; |
print "</td></tr></table></center></FORM>\n"; |
} |
} |
print &html_footer; |
print &html_footer; |
print "</BODY></HTML>\n"; |
print "</BODY></HTML>\n"; |
} |
} |
|
|
############################### |
############################### |
# View Files |
# View Files |
Line 724 elsif (-d $fullname) { |
|
Line 794 elsif (-d $fullname) { |
|
elsif (-f $fullname . ',v') { |
elsif (-f $fullname . ',v') { |
if (defined($input{'rev'}) || $doCheckout) { |
if (defined($input{'rev'}) || $doCheckout) { |
&doCheckout($fullname, $input{'rev'}); |
&doCheckout($fullname, $input{'rev'}); |
|
gzipclose(); |
exit; |
exit; |
} |
} |
if (defined($input{'annotate'}) && $allow_annotate) { |
if (defined($input{'annotate'}) && $allow_annotate) { |
&doAnnotate($input{'annotate'}); |
&doAnnotate($input{'annotate'}); |
|
gzipclose(); |
exit; |
exit; |
} |
} |
if (defined($input{'r1'}) && defined($input{'r2'})) { |
if (defined($input{'r1'}) && defined($input{'r2'})) { |
&doDiff($fullname, $input{'r1'}, $input{'tr1'}, |
&doDiff($fullname, $input{'r1'}, $input{'tr1'}, |
$input{'r2'}, $input{'tr2'}, $input{'f'}); |
$input{'r2'}, $input{'tr2'}, $input{'f'}); |
|
gzipclose(); |
exit; |
exit; |
} |
} |
print("going to dolog($fullname)\n") if ($verbose); |
print("going to dolog($fullname)\n") if ($verbose); |
Line 755 elsif (-d $fullname) { |
|
Line 828 elsif (-d $fullname) { |
|
# e.g. foo.c |
# e.g. foo.c |
&doDiff($fullname, $input{'r1'}, $input{'tr1'}, |
&doDiff($fullname, $input{'r1'}, $input{'tr1'}, |
$input{'r2'}, $input{'tr2'}, $input{'f'}); |
$input{'r2'}, $input{'tr2'}, $input{'f'}); |
|
gzipclose(); |
exit; |
exit; |
} |
} |
elsif (($newname = $fullname) =~ s|/([^/]+)$|/Attic/$1| && |
elsif (($newname = $fullname) =~ s|/([^/]+)$|/Attic/$1| && |
Line 788 elsif (-d $fullname) { |
|
Line 862 elsif (-d $fullname) { |
|
} |
} |
&fatal("404 Not Found","$where: no such file or directory"); |
&fatal("404 Not Found","$where: no such file or directory"); |
} |
} |
|
|
|
gzipclose(); |
## End MAIN |
## End MAIN |
|
|
sub printDiffSelect { |
sub printDiffSelect($) { |
my ($use_java_script) = @_; |
my ($use_java_script) = @_; |
$use_java_script = 0 if (!defined($use_java_script)); |
|
my ($f) = $input{'f'}; |
my ($f) = $input{'f'}; |
print "<SELECT NAME=\"f\""; |
print "<SELECT NAME=\"f\""; |
print " onchange=\"submit()\"" if ($use_java_script); |
print " onchange=\"submit()\"" if ($use_java_script); |
Line 805 sub printDiffSelect { |
|
Line 880 sub printDiffSelect { |
|
print "</SELECT>"; |
print "</SELECT>"; |
} |
} |
|
|
sub findLastModifiedSubdirs { |
sub findLastModifiedSubdirs(@) { |
my (@dirs) = @_; |
my (@dirs) = @_; |
my ($dirname, @files); |
my ($dirname, @files); |
|
|
Line 839 sub findLastModifiedSubdirs { |
|
Line 914 sub findLastModifiedSubdirs { |
|
return @files; |
return @files; |
} |
} |
|
|
sub htmlify { |
sub htmlify($;$) { |
my($string, $pr) = @_; |
my($string, $extra) = @_; |
|
|
# Special Characters; RFC 1866 |
# Special Characters; RFC 1866 |
$string =~ s/&/&/g; |
$string =~ s/&/&/g; |
$string =~ s/\"/"/g; |
$string =~ s/\"/"/g; |
$string =~ s/</</g; |
$string =~ s/</</g; |
$string =~ s/>/>/g; |
$string =~ s/>/>/g; |
|
|
# get URL's as link .. |
# get URL's as link .. |
$string =~ s`(http|ftp|https)(://[-a-zA-Z0-9%.~:_/]+)([?&]([-a-zA-Z0-9%.~:_]+)=([-a-zA-Z0-9%.~:_])+)*`<A HREF="$1$2$3">$1$2$3</A>`; |
$string =~ s`(http|ftp|https)(://[-a-zA-Z0-9%.~:_/]+)([?&]([-a-zA-Z0-9%.~:_]+)=([-a-zA-Z0-9%.~:_])+)*`<A HREF="$1$2$3">$1$2$3</A>`g; # ` |
# get e-mails as link |
# get e-mails as link |
$string =~ s`([-a-zA-Z0-9_.]+@([-a-zA-Z0-9]+\.)+[A-Za-z]{2,4})`<A HREF="mailto:$1">$1</A>`; |
$string =~ s`([-a-zA-Z0-9_.]+@([-a-zA-Z0-9]+\.)+[A-Za-z]{2,4})`<A HREF="mailto:$1">$1</A>`g; # ` |
|
|
# get #PR as link .. |
if ($extra) { |
if ($pr && defined($prcgi)) { |
# get PR #'s as link .. |
1 while $string =~ s`\b(pr[:#]?\s*(?:#?\d+[,\s]\s*)*#?)(\d+)\b`$1<A HREF="$prcgi$2">$2</A>`i; |
if (defined($prcgi)) { |
$string =~ s`\b${prcategories}/(\d+)\b`<A HREF="$prcgi$1">$&</A>`igo; |
1 while $string =~ s`\b(pr[:#]?\s*(?:#?\d+[,\s]\s*)*#?)(\d+)\b`$1 . &link($2, sprintf($prcgi, $2))`ie; # ` |
|
$string =~ s`\b${prcategories}/(\d+)\b`&link($&, sprintf($prcgi, $1))`igeo; # ` |
|
} |
|
|
|
# get manpage specs as link .. |
|
if (defined($mancgi)) { |
|
$string =~ s`\b([a-zA-Z]\w+)\(([0-9n])\)\B`&link($&, sprintf($mancgi, $2, $1))`ge; # ` |
|
} |
} |
} |
|
|
return $string; |
return $string; |
} |
} |
|
|
sub spacedHtmlText { |
sub spacedHtmlText($;$) { |
my($string, $pr) = @_; |
local $_ = $_[0]; |
|
my $ts = $_[1] || $tabstop; |
|
|
# Cut trailing spaces |
# Cut trailing spaces and tabs |
s/\s+$//; |
s/[ \t]+$//; |
|
|
# Expand tabs |
if (defined($ts)) { |
$string =~ s/\t+/' ' x (length($&) * $tabstop - length($`) % $tabstop)/e |
# Expand tabs |
if (defined($tabstop)); |
1 while s/\t+/' ' x (length($&) * $ts - length($`) % $ts)/e |
|
} |
|
|
# replace <tab> and <space> (\001 is to protect us from htmlify) |
# replace <tab> and <space> (\001 is to protect us from htmlify) |
# gzip can make excellent use of this repeating pattern :-) |
# gzip can make excellent use of this repeating pattern :-) |
$string =~ s/\001/\001%/g; #protect our & substitute |
|
if ($hr_breakable) { |
if ($hr_breakable) { |
# make every other space 'breakable' |
# make every other space 'breakable' |
$string =~ s/ / \001nbsp; \001nbsp; \001nbsp; \001nbsp;/g; # <tab> |
s/ / \001nbsp;/g; # 2 * <space> |
$string =~ s/ / \001nbsp;/g; # 2 * <space> |
|
# leave single space as it is |
# leave single space as it is |
|
} else { |
|
s/ /\001nbsp;/g; |
} |
} |
else { |
|
$string =~ s/ /\001nbsp;\001nbsp;\001nbsp;\001nbsp;\001nbsp;\001nbsp;\001nbsp;\001nbsp;/g; |
|
$string =~ s/ /\001nbsp;/g; |
|
} |
|
|
|
$string = htmlify($string); |
$_ = htmlify($_); |
|
|
# unescape |
# unescape |
$string =~ s/\001([^%])/&$1/g; |
y/\001/&/; |
$string =~ s/\001%/\001/g; |
|
|
|
return $string; |
return $_; |
} |
} |
|
|
sub link { |
sub link($$) { |
my($name, $where) = @_; |
my($name, $where) = @_; |
|
|
return "<A HREF=\"$where\">$name</A>\n"; |
return "<A HREF=\"$where\">$name</A>\n"; |
} |
} |
|
|
sub revcmp { |
sub revcmp($$) { |
my($rev1, $rev2) = @_; |
my($rev1, $rev2) = @_; |
|
|
|
# make no comparison for a tag or a branch |
|
return 0 if $rev1 =~ /[^\d.]/ || $rev2 =~ /[^\d.]/; |
|
|
my(@r1) = split(/\./, $rev1); |
my(@r1) = split(/\./, $rev1); |
my(@r2) = split(/\./, $rev2); |
my(@r2) = split(/\./, $rev2); |
my($a,$b); |
my($a,$b); |
|
|
return 0; |
return 0; |
} |
} |
|
|
sub fatal { |
sub fatal($$) { |
my($errcode, $errmsg) = @_; |
my($errcode, $errmsg) = @_; |
if ($is_mod_perl) { |
if ($is_mod_perl) { |
Apache->request->status((split(/ /, $errcode))[0]); |
Apache->request->status((split(/ /, $errcode))[0]); |
|
|
exit(1); |
exit(1); |
} |
} |
|
|
sub redirect { |
sub redirect($) { |
my($url) = @_; |
my($url) = @_; |
if ($is_mod_perl) { |
if ($is_mod_perl) { |
Apache->request->status(301); |
Apache->request->status(301); |
|
|
exit(1); |
exit(1); |
} |
} |
|
|
sub safeglob { |
sub safeglob($) { |
my ($filename) = @_; |
my ($filename) = @_; |
my ($dirname); |
my ($dirname); |
my (@results); |
my (@results); |
|
|
@results; |
@results; |
} |
} |
|
|
sub getMimeTypeFromSuffix { |
sub getMimeTypeFromSuffix($) { |
my ($fullname) = @_; |
my ($fullname) = @_; |
my ($mimetype, $suffix); |
my ($mimetype, $suffix); |
my $fh = do {local(*FH);}; |
my $fh = do {local(*FH);}; |
Line 984 sub getMimeTypeFromSuffix { |
|
Line 1067 sub getMimeTypeFromSuffix { |
|
($suffix = $fullname) =~ s/^.*\.([^.]*)$/$1/; |
($suffix = $fullname) =~ s/^.*\.([^.]*)$/$1/; |
$mimetype = $MTYPES{$suffix}; |
$mimetype = $MTYPES{$suffix}; |
$mimetype = $MTYPES{'*'} if (!$mimetype); |
$mimetype = $MTYPES{'*'} if (!$mimetype); |
|
|
if (!$mimetype && -f $mime_types) { |
if (!$mimetype && -f $mime_types) { |
# okey, this is something special - search the |
# okey, this is something special - search the |
# mime.types database |
# mime.types database |
Line 997 sub getMimeTypeFromSuffix { |
|
Line 1080 sub getMimeTypeFromSuffix { |
|
} |
} |
close ($fh); |
close ($fh); |
} |
} |
|
|
# okey, didn't find anything useful .. |
# okey, didn't find anything useful .. |
if (!($mimetype =~ /\S\/\S/)) { |
if (!($mimetype =~ /\S\/\S/)) { |
$mimetype = "text/plain"; |
$mimetype = "text/plain"; |
Line 1006 sub getMimeTypeFromSuffix { |
|
Line 1089 sub getMimeTypeFromSuffix { |
|
} |
} |
|
|
############################### |
############################### |
|
# read first lines like head(1) |
|
############################### |
|
sub head($;$) { |
|
my $fh = $_[0]; |
|
my $linecount = $_[1] || 10; |
|
|
|
my @buf; |
|
|
|
if ($linecount > 0) { |
|
my $i; |
|
for ($i = 0; !eof($fh) && $i < $linecount; $i++) { |
|
push @buf, scalar <$fh>; |
|
} |
|
} else { |
|
@buf = <$fh>; |
|
} |
|
|
|
@buf; |
|
} |
|
|
|
############################### |
|
# scan vim and Emacs directives |
|
############################### |
|
sub scan_directives(@) { |
|
my $ts = undef; |
|
|
|
for (@_) { |
|
$ts = $1 if /\b(?:ts|tabstop|tab-width)[:=]\s*([1-9]\d*)\b/; |
|
} |
|
|
|
('tabstop' => $ts); |
|
} |
|
|
|
############################### |
# show Annotation |
# show Annotation |
############################### |
############################### |
sub doAnnotate ($$) { |
sub doAnnotate($$) { |
my ($rev) = @_; |
my ($rev) = @_; |
my ($pid); |
my ($pid); |
my ($pathname, $filename); |
my ($pathname, $filename); |
Line 1017 sub doAnnotate ($$) { |
|
Line 1134 sub doAnnotate ($$) { |
|
|
|
# make sure the revisions a wellformed, for security |
# make sure the revisions a wellformed, for security |
# reasons .. |
# reasons .. |
if (!($rev =~ /^[\d\.]+$/)) { |
if ($rev =~ /[^\w.]/) { |
&fatal("404 Not Found", |
&fatal("404 Not Found", |
"Malformed query \"$ENV{QUERY_STRING}\""); |
"Malformed query \"$ENV{QUERY_STRING}\""); |
} |
} |
Line 1027 sub doAnnotate ($$) { |
|
Line 1144 sub doAnnotate ($$) { |
|
|
|
http_header(); |
http_header(); |
|
|
navigateHeader ($scriptwhere,$pathname,$filename,$rev, "annotate"); |
navigateHeader($scriptwhere,$pathname,$filename,$rev, "annotate"); |
print "<h3 align=center>Annotation of $pathname$filename, Revision $rev</h3>\n"; |
print "<h3 align=center>Annotation of $pathname$filename, Revision $rev</h3>\n"; |
|
|
# this seems to be necessary |
# this seems to be necessary |
Line 1039 sub doAnnotate ($$) { |
|
Line 1156 sub doAnnotate ($$) { |
|
# the public domain. |
# the public domain. |
# we could abandon the use of rlog, rcsdiff and co using |
# we could abandon the use of rlog, rcsdiff and co using |
# the cvsserver in a similiar way one day (..after rewrite) |
# the cvsserver in a similiar way one day (..after rewrite) |
$pid = open2($reader, $writer, "cvs server") || fatal ("500 Internal Error", |
$pid = open2($reader, $writer, "cvs server") || fatal ("500 Internal Error", |
"Fatal Error - unable to open cvs for annotation"); |
"Fatal Error - unable to open cvs for annotation"); |
|
|
# OK, first send the request to the server. A simplified example is: |
# OK, first send the request to the server. A simplified example is: |
# Root /home/kingdon/zwork/cvsroot |
# Root /home/kingdon/zwork/cvsroot |
# Argument foo/xx |
# Argument foo/xx |
Line 1051 sub doAnnotate ($$) { |
|
Line 1168 sub doAnnotate ($$) { |
|
# /home/kingdon/zwork/cvsroot |
# /home/kingdon/zwork/cvsroot |
# annotate |
# annotate |
# although as you can see there are a few more details. |
# although as you can see there are a few more details. |
|
|
print $writer "Root $cvsroot\n"; |
print $writer "Root $cvsroot\n"; |
print $writer "Valid-responses ok error Valid-requests Checked-in Updated Merged Removed M E\n"; |
print $writer "Valid-responses ok error Valid-requests Checked-in Updated Merged Removed M E\n"; |
# Don't worry about sending valid-requests, the server just needs to |
# Don't worry about sending valid-requests, the server just needs to |
Line 1071 sub doAnnotate ($$) { |
|
Line 1188 sub doAnnotate ($$) { |
|
if ($path eq "") { |
if ($path eq "") { |
# In our example, $_ is "dir". |
# In our example, $_ is "dir". |
$path = $_; |
$path = $_; |
} |
} |
else { |
else { |
print $writer "Directory $path\n"; |
print $writer "Directory $path\n"; |
print $writer "$cvsroot/$path\n"; |
print $writer "$cvsroot/$path\n"; |
Line 1084 sub doAnnotate ($$) { |
|
Line 1201 sub doAnnotate ($$) { |
|
# And the last "Directory" before "annotate" is the top level. |
# And the last "Directory" before "annotate" is the top level. |
print $writer "Directory .\n"; |
print $writer "Directory .\n"; |
print $writer "$cvsroot\n"; |
print $writer "$cvsroot\n"; |
|
|
print $writer "annotate\n"; |
print $writer "annotate\n"; |
# OK, we've sent our command to the server. Thing to do is to |
# OK, we've sent our command to the server. Thing to do is to |
# close the writer side and get all the responses. If "cvs server" |
# close the writer side and get all the responses. If "cvs server" |
# were nicer about buffering, then we could just leave it open, I think. |
# were nicer about buffering, then we could just leave it open, I think. |
close ($writer) || die "cannot close: $!"; |
close ($writer) || die "cannot close: $!"; |
|
|
# Ready to get the responses from the server. |
# Ready to get the responses from the server. |
# For example: |
# For example: |
# E Annotations for foo/xx |
# E Annotations for foo/xx |
# E *************** |
# E *************** |
# M 1.3 (kingdon 06-Sep-97): hello |
# M 1.3 (kingdon 06-Sep-97): hello |
# ok |
# ok |
my ($lineNr) = 0; |
my ($lineNr) = 0; |
my ($oldLrev, $oldLusr) = ("", ""); |
my ($oldLrev, $oldLusr) = ("", ""); |
Line 1106 sub doAnnotate ($$) { |
|
Line 1223 sub doAnnotate ($$) { |
|
else { |
else { |
print "<pre>"; |
print "<pre>"; |
} |
} |
while (<$reader>) { |
|
|
# prefetch several lines |
|
my @buf = head($reader); |
|
|
|
my %d = scan_directives(@buf); |
|
|
|
while (@buf || !eof($reader)) { |
|
$_ = @buf ? shift @buf : <$reader>; |
|
|
my @words = split; |
my @words = split; |
# Adding one is for the (single) space which follows $words[0]. |
# Adding one is for the (single) space which follows $words[0]. |
my $rest = substr ($_, length ($words[0]) + 1); |
my $rest = substr ($_, length ($words[0]) + 1); |
Line 1124 sub doAnnotate ($$) { |
|
Line 1249 sub doAnnotate ($$) { |
|
} |
} |
else { |
else { |
$revprint = $lrev; $oldLusr = ""; |
$revprint = $lrev; $oldLusr = ""; |
|
$revprint =~ s`^(\S+)`<a href="${scriptwhere}${barequery}#rev$1">$1</A>`; # ` |
} |
} |
if ($lusr eq $oldLusr) { |
if ($lusr eq $oldLusr) { |
$usrprint = " "; |
$usrprint = " "; |
Line 1136 sub doAnnotate ($$) { |
|
Line 1262 sub doAnnotate ($$) { |
|
# is there a less timeconsuming way to strip spaces ? |
# is there a less timeconsuming way to strip spaces ? |
($lrev = $lrev) =~ s/\s+//g; |
($lrev = $lrev) =~ s/\s+//g; |
my $isCurrentRev = ($rev eq $lrev); |
my $isCurrentRev = ($rev eq $lrev); |
|
|
print "<b>" if ($isCurrentRev); |
print "<b>" if ($isCurrentRev); |
printf ("%8s%s%8s %4d:", $revprint, ($isCurrentRev ? "|" : " "), $usrprint, $lineNr); |
printf ("%8s%s%8s %4d:", $revprint, ($isCurrentRev ? "|" : " "), $usrprint, $lineNr); |
print spacedHtmlText($line); |
print spacedHtmlText($line, $d{'tabstop'}); |
print "</b>" if ($isCurrentRev); |
print "</b>" if ($isCurrentRev); |
} |
} |
elsif ($words[0] eq "ok") { |
elsif ($words[0] eq "ok") { |
Line 1163 sub doAnnotate ($$) { |
|
Line 1289 sub doAnnotate ($$) { |
|
############################### |
############################### |
# make Checkout |
# make Checkout |
############################### |
############################### |
sub doCheckout { |
sub doCheckout($$) { |
my ($fullname, $rev) = @_; |
my ($fullname, $rev) = @_; |
my ($mimetype,$revopt); |
my ($mimetype,$revopt); |
my $fh = do {local(*FH);}; |
my $fh = do {local(*FH);}; |
|
|
|
if ($rev eq 'HEAD' || $rev eq '.') { |
|
$rev = undef; |
|
} |
|
|
# make sure the revisions a wellformed, for security |
# make sure the revisions a wellformed, for security |
# reasons .. |
# reasons .. |
if (defined($rev) && !($rev =~ /^[\d\.]+$/)) { |
if (defined($rev) && $rev =~ /[^\w.]/) { |
&fatal("404 Not Found", |
&fatal("404 Not Found", |
"Malformed query \"$ENV{QUERY_STRING}\""); |
"Malformed query \"$ENV{QUERY_STRING}\""); |
} |
} |
Line 1197 sub doCheckout { |
|
Line 1327 sub doCheckout { |
|
$moddate=$date{$symrev{HEAD}}; |
$moddate=$date{$symrev{HEAD}}; |
} |
} |
} |
} |
|
|
### just for the record: |
### just for the record: |
### 'cvs co' seems to have a bug regarding single checkout of |
### 'cvs co' seems to have a bug regarding single checkout of |
### directories/files having spaces in it; |
### directories/files having spaces in it; |
Line 1206 sub doCheckout { |
|
Line 1336 sub doCheckout { |
|
# Safely for a child process to read from. |
# Safely for a child process to read from. |
if (! open($fh, "-|")) { # child |
if (! open($fh, "-|")) { # child |
open(STDERR, ">&STDOUT"); # Redirect stderr to stdout |
open(STDERR, ">&STDOUT"); # Redirect stderr to stdout |
exec("cvs", "-d", $cvsroot, "co", "-p", $revopt, $where); |
exec("cvs", "-Rld", $cvsroot, "co", "-p", $revopt, $where); |
} |
} |
#=================================================================== |
#=================================================================== |
#Checking out squid/src/ftp.c |
#Checking out squid/src/ftp.c |
#RCS: /usr/src/CVS/squid/src/ftp.c,v |
#RCS: /usr/src/CVS/squid/src/ftp.c,v |
Line 1246 sub doCheckout { |
|
Line 1376 sub doCheckout { |
|
close($fh); |
close($fh); |
} |
} |
|
|
sub cvswebMarkup { |
sub cvswebMarkup($$$) { |
my ($filehandle,$fullname,$revision) = @_; |
my ($filehandle,$fullname,$revision) = @_; |
my ($pathname, $filename); |
my ($pathname, $filename); |
|
|
Line 1256 sub cvswebMarkup { |
|
Line 1386 sub cvswebMarkup { |
|
|
|
http_header(); |
http_header(); |
|
|
navigateHeader ($scriptwhere, $pathname, $filename, $revision, "view"); |
navigateHeader($scriptwhere, $pathname, $filename, $revision, "view"); |
print "<HR noshade>"; |
print "<HR noshade>"; |
print "<table width=\"100%\"><tr><td bgcolor=\"$markupLogColor\">"; |
print "<table width=\"100%\"><tr><td bgcolor=\"$markupLogColor\">"; |
print "File: ", &clickablePath($where, 1); |
print "File: ", &clickablePath($where, 1); |
Line 1264 sub cvswebMarkup { |
|
Line 1394 sub cvswebMarkup { |
|
&download_link(urlencode($fileurl), $revision, "(download)"); |
&download_link(urlencode($fileurl), $revision, "(download)"); |
if (!$defaultTextPlain) { |
if (!$defaultTextPlain) { |
print " "; |
print " "; |
&download_link(urlencode($fileurl), $revision, "(as text)", |
&download_link(urlencode($fileurl), $revision, "(as text)", |
"text/plain"); |
"text/plain"); |
} |
} |
print "<BR>\n"; |
print "<BR>\n"; |
Line 1278 sub cvswebMarkup { |
|
Line 1408 sub cvswebMarkup { |
|
$input{only_with_tag}; |
$input{only_with_tag}; |
} |
} |
print "</td></tr></table>"; |
print "</td></tr></table>"; |
my @content = <$filehandle>; |
|
my $url = download_url($fileurl, $revision, $mimetype); |
my $url = download_url($fileurl, $revision, $mimetype); |
print "<HR noshade>"; |
print "<HR noshade>"; |
if ($mimetype =~ /^image/) { |
if ($mimetype =~ /^image/) { |
print "<IMG SRC=\"$url$barequery\"><BR>"; |
print "<IMG SRC=\"$url$barequery\"><BR>"; |
} |
} |
|
elsif ($mimetype =~ m%^application/pdf%) { |
|
print "<EMBED SRC=\"$url$barequery\" WIDTH=\"100%\"><BR>"; |
|
} |
else { |
else { |
print "<PRE>"; |
print "<PRE>"; |
foreach (@content) { |
|
print spacedHtmlText($_); |
# prefetch several lines |
|
my @buf = head($filehandle); |
|
|
|
my %d = scan_directives(@buf); |
|
|
|
while (@buf || !eof($filehandle)) { |
|
$_ = @buf ? shift @buf : <$filehandle>; |
|
|
|
print spacedHtmlText($_, $d{'tabstop'}); |
} |
} |
print "</PRE>"; |
print "</PRE>"; |
} |
} |
Line 1296 sub cvswebMarkup { |
|
Line 1436 sub cvswebMarkup { |
|
sub viewable($) { |
sub viewable($) { |
my ($mimetype) = @_; |
my ($mimetype) = @_; |
|
|
$mimetype =~ m%^text/% || |
$mimetype =~ m%^((text|image)/|application/pdf)% ; |
$mimetype =~ m%^image/% || |
|
0; |
|
} |
} |
|
|
############################### |
############################### |
# Show Colored Diff |
# Show Colored Diff |
############################### |
############################### |
sub doDiff { |
sub doDiff($$$$$$) { |
my($fullname, $r1, $tr1, $r2, $tr2, $f) = @_; |
my($fullname, $r1, $tr1, $r2, $tr2, $f) = @_; |
my $fh = do {local(*FH);}; |
my $fh = do {local(*FH);}; |
my ($rev1, $rev2, $sym1, $sym2, @difftype, $diffname, $f1, $f2); |
my ($rev1, $rev2, $sym1, $sym2, @difftype, $diffname, $f1, $f2); |
|
|
$rev2 = $tr2; |
$rev2 = $tr2; |
$sym2 = ""; |
$sym2 = ""; |
} |
} |
|
|
# make sure the revisions a wellformed, for security |
# make sure the revisions a wellformed, for security |
# reasons .. |
# reasons .. |
if (!($rev1 =~ /^[\d\.]+$/) || !($rev2 =~ /^[\d\.]+$/)) { |
if ($rev1 =~ /[^\w.]/ || $rev2 =~ /[^\w.]/) { |
&fatal("404 Not Found", |
&fatal("404 Not Found", |
"Malformed query \"$ENV{QUERY_STRING}\""); |
"Malformed query \"$ENV{QUERY_STRING}\""); |
} |
} |
|
|
|
|
# apply special options |
# apply special options |
if ($showfunc) { |
if ($showfunc) { |
push @difftype, '-p'; |
push @difftype, '-p' if $f =~ /^[cHhu]$/; |
|
|
my($re1, $re2); |
my($re1, $re2); |
|
|
|
|
if ($human_readable) { |
if ($human_readable) { |
http_header(); |
http_header(); |
&human_readable_diff($fh, $rev2); |
&human_readable_diff($fh, $rev2); |
|
gzipclose(); |
exit; |
exit; |
} |
} |
else { |
else { |
|
|
############################### |
############################### |
# Show Logs .. |
# Show Logs .. |
############################### |
############################### |
sub getDirLogs { |
sub getDirLogs($$@) { |
my ($cvsroot,$dirname,@otherFiles) = @_; |
my ($cvsroot,$dirname,@otherFiles) = @_; |
my ($state,$otherFiles,$tag, $file, $date, $branchpoint, $branch, $log); |
my ($state,$otherFiles,$tag, $file, $date, $branchpoint, $branch, $log); |
my ($rev, $revision, $revwanted, $filename, $head, $author); |
my ($rev, $revision, $revwanted, $filename, $head, $author); |
Line 1466 sub getDirLogs { |
|
Line 1606 sub getDirLogs { |
|
} |
} |
|
|
# just execute rlog if there are any files |
# just execute rlog if there are any files |
if ($#files < 0) { |
if ($#files < 0) { |
return; |
return; |
} |
} |
|
|
|
|
} |
} |
if ($state eq "head" && /^symbolic names/) { |
if ($state eq "head" && /^symbolic names/) { |
$state = "tags"; |
$state = "tags"; |
($branch = $head) =~ s/\.\d+$// if (!defined($branch)); |
($branch = $head) =~ s/\.\d+$// if (!defined($branch)); |
$branch =~ s/(\.?)(\d+)$/${1}0.$2/; |
$branch =~ s/(\.?)(\d+)$/${1}0.$2/; |
$symrev{MAIN} = $branch; |
$symrev{MAIN} = $branch; |
$symrev{HEAD} = $branch; |
$symrev{HEAD} = $branch; |
|
|
} |
} |
} |
} |
if ($. == 0) { |
if ($. == 0) { |
fatal("500 Internal Error", |
fatal("500 Internal Error", |
"Failed to spawn GNU rlog on <em>'".join(", ", @files)."'</em><p>did you set the <b>\$ENV{PATH}</b> in your configuration file correctly ?"); |
"Failed to spawn GNU rlog on <em>'".join(", ", @files)."'</em><p>did you set the <b>\$ENV{PATH}</b> in your configuration file correctly ?"); |
} |
} |
close($fh); |
close($fh); |
} |
} |
|
|
sub readLog { |
sub readLog($;$) { |
my($fullname,$revision) = @_; |
my($fullname,$revision) = @_; |
my ($symnames, $head, $rev, $br, $brp, $branch, $branchrev); |
my ($symnames, $head, $rev, $br, $brp, $branch, $branchrev); |
my $fh = do {local(*FH);}; |
my $fh = do {local(*FH);}; |
Line 1878 sub printLog($;$) { |
|
Line 2018 sub printLog($;$) { |
|
} |
} |
if (not $defaultTextPlain) { |
if (not $defaultTextPlain) { |
print " / "; |
print " / "; |
&download_link($fileurl, $_, "(as text)", |
&download_link($fileurl, $_, "(as text)", |
"text/plain"); |
"text/plain"); |
} |
} |
if (!$defaultViewable) { |
if (!$defaultViewable) { |
Line 2019 sub printLog($;$) { |
|
Line 2159 sub printLog($;$) { |
|
print "</PRE>\n"; |
print "</PRE>\n"; |
} |
} |
|
|
sub doLog { |
sub doLog($) { |
my($fullname) = @_; |
my($fullname) = @_; |
my ($diffrev, $upwhere, $filename, $backurl); |
my ($diffrev, $upwhere, $filename, $backurl); |
|
|
readLog($fullname); |
readLog($fullname); |
|
|
html_header("CVS log for $where"); |
html_header("CVS log for $where"); |
|
|
foreach (@stickyvars) { |
foreach (@stickyvars) { |
print "<INPUT TYPE=HIDDEN NAME=\"$_\" VALUE=\"$input{$_}\">\n" |
print "<INPUT TYPE=HIDDEN NAME=\"$_\" VALUE=\"$input{$_}\">\n" |
if (defined($input{$_}) |
if (defined($input{$_}) |
&& ($input{$_} ne $DEFAULTVALUE{$_} && $input{$_} ne "")); |
&& ((!defined($DEFAULTVALUE{$_}) |
|
|| $input{$_} ne $DEFAULTVALUE{$_}) |
|
&& $input{$_} ne "")); |
} |
} |
print "Diffs between \n"; |
print "<TABLE><TR>\n"; |
|
print "<TD align=right>Diffs between \n"; |
print "<SELECT NAME=\"r1\">\n"; |
print "<SELECT NAME=\"r1\">\n"; |
print "<OPTION VALUE=\"text\" SELECTED>Use Text Field\n"; |
print "<OPTION VALUE=\"text\" SELECTED>Use Text Field\n"; |
print $sel; |
print $sel; |
print "</SELECT>\n"; |
print "</SELECT>\n"; |
$diffrev = $revdisplayorder[$#revdisplayorder]; |
$diffrev = $revdisplayorder[$#revdisplayorder]; |
$diffrev = $input{"r1"} if (defined($input{"r1"})); |
$diffrev = $input{"r1"} if (defined($input{"r1"})); |
print "<INPUT TYPE=\"TEXT\" SIZE=\"$inputTextSize\" NAME=\"tr1\" VALUE=\"$diffrev\" onChange='document.diff_select.r1.selectedIndex=0'>\n"; |
print "<INPUT TYPE=\"TEXT\" SIZE=\"$inputTextSize\" NAME=\"tr1\" VALUE=\"$diffrev\" onChange='document.diff_select.r1.selectedIndex=0'></TD>"; |
print " and \n"; |
print "<TD><BR></TD></TR>\n"; |
|
print "<TR><TD align=right>and \n"; |
print "<SELECT NAME=\"r2\">\n"; |
print "<SELECT NAME=\"r2\">\n"; |
print "<OPTION VALUE=\"text\" SELECTED>Use Text Field\n"; |
print "<OPTION VALUE=\"text\" SELECTED>Use Text Field\n"; |
print $sel; |
print $sel; |
print "</SELECT>\n"; |
print "</SELECT>\n"; |
$diffrev = $revdisplayorder[0]; |
$diffrev = $revdisplayorder[0]; |
$diffrev = $input{"r2"} if (defined($input{"r2"})); |
$diffrev = $input{"r2"} if (defined($input{"r2"})); |
print "<INPUT TYPE=\"TEXT\" SIZE=\"$inputTextSize\" NAME=\"tr2\" VALUE=\"$diffrev\" onChange='docuement.diff_select.r2.selectedIndex=0'>\n"; |
print "<INPUT TYPE=\"TEXT\" SIZE=\"$inputTextSize\" NAME=\"tr2\" VALUE=\"$diffrev\" onChange='document.diff_select.r2.selectedIndex=0'></TD>"; |
print "<BR>Type of Diff should be a "; |
print "<TD><INPUT TYPE=SUBMIT VALUE=\" Get Diffs \"></TD>\n"; |
printDiffSelect(); |
|
print "<INPUT TYPE=SUBMIT VALUE=\" Get Diffs \">\n"; |
|
print "</FORM>\n"; |
print "</FORM>\n"; |
|
print "</TR></TABLE>\n"; |
print "<HR noshade>\n"; |
print "<HR noshade>\n"; |
|
print "<TABLE>"; |
|
print "<FORM METHOD=\"GET\" ACTION=\"$scriptwhere\">\n"; |
|
print "<TR><TD align=right>Preferred Diff type:</TD>"; |
|
print "<TD>"; |
|
printDiffSelect($use_java_script); |
|
print "</TD><TD></TD></TR>\n"; |
if (@branchnames) { |
if (@branchnames) { |
|
print "<TR><TD align=right>View only Branch:</TD>"; |
|
print "<TD>"; |
print "<A name=branch></A>\n"; |
print "<A name=branch></A>\n"; |
print "<FORM METHOD=\"GET\" ACTION=\"$scriptwhere\">\n"; |
|
foreach (@stickyvars) { |
|
next if ($_ eq "only_with_tag"); |
|
next if ($_ eq "logsort"); |
|
print "<INPUT TYPE=HIDDEN NAME=\"$_\" VALUE=\"$input{$_}\">\n" |
|
if (defined($input{$_}) && $input{$_} ne $DEFAULTVALUE{$_} |
|
&& $input{$_} ne ""); |
|
} |
|
print "View only Branch: \n"; |
|
print "<SELECT NAME=\"only_with_tag\""; |
print "<SELECT NAME=\"only_with_tag\""; |
print " onchange=\"submit()\"" if ($use_java_script); |
print " onchange=\"submit()\"" if ($use_java_script); |
print ">\n"; |
print ">\n"; |
|
|
&& $input{"only_with_tag"} eq $_); |
&& $input{"only_with_tag"} eq $_); |
print ">${_}\n"; |
print ">${_}\n"; |
} |
} |
print "</SELECT>\n"; |
print "</SELECT></TD><TD></TD></TR>\n"; |
print "<INPUT TYPE=SUBMIT VALUE=\" View Branch \">\n"; |
|
print "</FORM>\n"; |
|
} |
} |
print "<A name=logsort></A>\n"; |
|
print "<FORM METHOD=\"GET\" ACTION=\"$scriptwhere\">\n"; |
|
foreach (@stickyvars) { |
foreach (@stickyvars) { |
|
next if ($_ eq "f"); |
next if ($_ eq "only_with_tag"); |
next if ($_ eq "only_with_tag"); |
next if ($_ eq "logsort"); |
next if ($_ eq "logsort"); |
print "<INPUT TYPE=HIDDEN NAME=\"$_\" VALUE=\"$input{$_}\">\n" |
print "<INPUT TYPE=HIDDEN NAME=\"$_\" VALUE=\"$input{$_}\">\n" |
if (defined($input{$_}) && $input{$_} ne $DEFAULTVALUE{$_} |
if (defined($input{$_}) |
|
&& (!defined($DEFAULTVALUE{$_}) |
|
|| $input{$_} ne $DEFAULTVALUE{$_}) |
&& $input{$_} ne ""); |
&& $input{$_} ne ""); |
} |
} |
print "Sort log by: \n"; |
print "<TR><TD align=right>"; |
print "<SELECT NAME=\"logsort\""; |
print "<A name=logsort></A>\n"; |
|
print "Sort log by:</TD>"; |
|
print "<TD><SELECT NAME=\"logsort\""; |
print " onchange=\"submit()\"" if ($use_java_script); |
print " onchange=\"submit()\"" if ($use_java_script); |
print ">\n"; |
print ">\n"; |
print "<OPTION VALUE=cvs",$logsort eq "cvs" ? " SELECTED" : "", ">Not sorted"; |
print "<OPTION VALUE=cvs",$logsort eq "cvs" ? " SELECTED" : "", ">Not sorted"; |
print "<OPTION VALUE=date",$logsort eq "date" ? " SELECTED" : "", ">Commit date"; |
print "<OPTION VALUE=date",$logsort eq "date" ? " SELECTED" : "", ">Commit date"; |
print "<OPTION VALUE=rev",$logsort eq "rev" ? " SELECTED" : "", ">Revision"; |
print "<OPTION VALUE=rev",$logsort eq "rev" ? " SELECTED" : "", ">Revision"; |
print "</SELECT>\n"; |
print "</SELECT></TD>"; |
print "<INPUT TYPE=SUBMIT VALUE=\" Sort \">\n"; |
print "<TD><INPUT TYPE=SUBMIT VALUE=\" Set \"></TD>"; |
print "</FORM>\n"; |
print "</FORM>\n"; |
|
print "</TR></TABLE>"; |
print &html_footer; |
print &html_footer; |
print "</BODY></HTML>\n"; |
print "</BODY></HTML>\n"; |
} |
} |
|
|
sub flush_diff_rows ($$$$) |
sub flush_diff_rows($$$$) { |
{ |
|
my $j; |
my $j; |
my ($leftColRef,$rightColRef,$leftRow,$rightRow) = @_; |
my ($leftColRef,$rightColRef,$leftRow,$rightRow) = @_; |
if ($state eq "PreChangeRemove") { # we just got remove-lines before |
if ($state eq "PreChangeRemove") { # we just got remove-lines before |
Line 2174 sub flush_diff_rows ($$$$) |
|
Line 2317 sub flush_diff_rows ($$$$) |
|
# human_readable_diff(String revision_to_return_to); |
# human_readable_diff(String revision_to_return_to); |
## |
## |
sub human_readable_diff($){ |
sub human_readable_diff($){ |
my ($i,$difftxt, $where_nd, $filename, $pathname, $scriptwhere_nd); |
my ($difftxt, $where_nd, $filename, $pathname, $scriptwhere_nd); |
my ($fh, $rev) = @_; |
my ($fh, $rev) = @_; |
my ($date1, $date2, $r1d, $r2d, $r1r, $r2r, $rev1, $rev2, $sym1, $sym2); |
my ($date1, $date2, $r1d, $r2d, $r1r, $r2r, $rev1, $rev2, $sym1, $sym2); |
my (@rightCol, @leftCol); |
my (@rightCol, @leftCol); |
Line 2184 sub human_readable_diff($){ |
|
Line 2327 sub human_readable_diff($){ |
|
($pathname = $where_nd) =~ s/(Attic\/)?[^\/]*$//; |
($pathname = $where_nd) =~ s/(Attic\/)?[^\/]*$//; |
($scriptwhere_nd = $scriptwhere) =~ s/.diff$//; |
($scriptwhere_nd = $scriptwhere) =~ s/.diff$//; |
|
|
navigateHeader ($scriptwhere_nd, $pathname, $filename, $rev, "diff"); |
navigateHeader($scriptwhere_nd, $pathname, $filename, $rev, "diff"); |
|
|
# Read header to pick up read revision and date, if possible |
# Read header to pick up read revision and date, if possible |
while (<$fh>) { |
while (<$fh>) { |
Line 2200 sub human_readable_diff($){ |
|
Line 2343 sub human_readable_diff($){ |
|
$rev2 = $r2r; |
$rev2 = $r2r; |
$date2 = $r2d; |
$date2 = $r2d; |
} |
} |
|
|
print "<h3 align=center>Diff for /$where_nd between version $rev1 and $rev2</h3>\n"; |
print "<h3 align=center>Diff for /$where_nd between version $rev1 and $rev2</h3>\n"; |
|
|
print "<table border=0 cellspacing=0 cellpadding=0 width=\"100%\">\n"; |
print "<table border=0 cellspacing=0 cellpadding=0 width=\"100%\">\n"; |
Line 2228 sub human_readable_diff($){ |
|
Line 2371 sub human_readable_diff($){ |
|
# cascading style sheets because we've to set the |
# cascading style sheets because we've to set the |
# font and color for each row. anyone ...? |
# font and color for each row. anyone ...? |
#### |
#### |
while (<$fh>) { |
|
$difftxt = $_; |
# prefetch several lines |
|
my @buf = head($fh); |
|
|
|
my %d = scan_directives(@buf); |
|
|
|
while (@buf || !eof($fh)) { |
|
$difftxt = @buf ? shift @buf : <$fh>; |
|
|
if ($difftxt =~ /^@@/) { |
if ($difftxt =~ /^@@/) { |
($oldline,$newline,$funname) = $difftxt =~ /@@ \-([0-9]+).*\+([0-9]+).*@@(.*)/; |
($oldline,$newline,$funname) = $difftxt =~ /@@ \-([0-9]+).*\+([0-9]+).*@@(.*)/; |
print "<tr bgcolor=\"$diffcolorHeading\"><td width=\"50%\">"; |
print "<tr bgcolor=\"$diffcolorHeading\"><td width=\"50%\">"; |
Line 2246 sub human_readable_diff($){ |
|
Line 2395 sub human_readable_diff($){ |
|
} |
} |
else { |
else { |
($diffcode,$rest) = $difftxt =~ /^([-+ ])(.*)/; |
($diffcode,$rest) = $difftxt =~ /^([-+ ])(.*)/; |
$_ = spacedHtmlText ($rest); |
$_ = spacedHtmlText($rest, $d{'tabstop'}); |
|
|
# Add fontface, size |
# Add fontface, size |
$_ = "$fs $_$fe"; |
$_ = "$fs $_$fe"; |
|
|
######### |
######### |
# little state machine to parse unified-diff output (Hen, zeller@think.de) |
# little state machine to parse unified-diff output (Hen, zeller@think.de) |
# in order to get some nice 'ediff'-mode output |
# in order to get some nice 'ediff'-mode output |
Line 2268 sub human_readable_diff($){ |
|
Line 2417 sub human_readable_diff($){ |
|
$state = "PreChange"; |
$state = "PreChange"; |
$rightCol[$rightRow++] = $_; |
$rightCol[$rightRow++] = $_; |
} |
} |
} |
} |
elsif ($diffcode eq '-') { |
elsif ($diffcode eq '-') { |
$state = "PreChangeRemove"; |
$state = "PreChangeRemove"; |
$leftCol[$leftRow++] = $_; |
$leftCol[$leftRow++] = $_; |
Line 2324 sub human_readable_diff($){ |
|
Line 2473 sub human_readable_diff($){ |
|
print "</tr></table>"; |
print "</tr></table>"; |
} |
} |
|
|
sub navigateHeader ($$$$$) { |
sub navigateHeader($$$$$) { |
my ($swhere,$path,$filename,$rev,$title) = @_; |
my ($swhere,$path,$filename,$rev,$title) = @_; |
$swhere = "" if ($swhere eq $scriptwhere); |
$swhere = "" if ($swhere eq $scriptwhere); |
$swhere = urlencode($filename) if ($swhere eq ""); |
$swhere = urlencode($filename) if ($swhere eq ""); |
print "<\!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">"; |
print "<\!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 Transitional//EN\">"; |
print "<HTML>\n<HEAD>\n"; |
print "<HTML>\n<HEAD>\n"; |
print '<!-- CVSweb $zRevision: 1.93 $ $Revision$ -->'; |
print '<!-- CVSweb $zRevision: 1.103 $ $Revision$ -->'; |
print "\n<TITLE>$path$filename - $title - $rev</TITLE></HEAD>\n"; |
print "\n<TITLE>$path$filename - $title - $rev</TITLE></HEAD>\n"; |
print "<BODY BGCOLOR=\"$backcolor\">\n"; |
print "$body_tag_for_src\n"; |
print "<table width=\"100%\" border=0 cellspacing=0 cellpadding=1 bgcolor=\"$navigationHeaderColor\">"; |
print "<table width=\"100%\" border=0 cellspacing=0 cellpadding=1 bgcolor=\"$navigationHeaderColor\">"; |
print "<tr valign=bottom><td>"; |
print "<tr valign=bottom><td>"; |
print "<a href=\"$swhere$query#rev$rev\">$backicon"; |
print "<a href=\"$swhere$query#rev$rev\">$backicon"; |
print "</a> <b>Return to ", &link("$filename","$swhere$query#rev$rev")," CVS log"; |
print "</a> <b>Return to ", &link("$filename","$swhere$query#rev$rev")," CVS log"; |
print "</b> $fileicon</td>"; |
print "</b> $fileicon</td>"; |
|
|
print "<td align=right>$diricon <b>Up to ", &clickablePath($path, 1), "</b></td>"; |
print "<td align=right>$diricon <b>Up to ", &clickablePath($path, 1), "</b></td>"; |
print "</tr></table>"; |
print "</tr></table>"; |
} |
} |
|
|
sub plural_write ($$) |
sub plural_write($$) { |
{ |
|
my ($num,$text) = @_; |
my ($num,$text) = @_; |
if ($num != 1) { |
if ($num != 1) { |
$text = $text . "s"; |
$text = $text . "s"; |
Line 2362 sub plural_write ($$) |
|
Line 2510 sub plural_write ($$) |
|
# '..time ago' |
# '..time ago' |
# H. Zeller <zeller@think.de> |
# H. Zeller <zeller@think.de> |
## |
## |
sub readableTime ($$) |
sub readableTime($$) { |
{ |
|
my ($i, $break, $retval); |
my ($i, $break, $retval); |
my ($secs,$long) = @_; |
my ($secs,$long) = @_; |
|
|
Line 2381 sub readableTime ($$) |
|
Line 2528 sub readableTime ($$) |
|
31536000, 'year'); |
31536000, 'year'); |
my @breaks = sort {$a <=> $b} keys %desc; |
my @breaks = sort {$a <=> $b} keys %desc; |
$i = 0; |
$i = 0; |
while ($i <= $#breaks && $secs >= 2 * $breaks[$i]) { |
while ($i <= $#breaks && $secs >= 2 * $breaks[$i]) { |
$i++; |
$i++; |
} |
} |
$i--; |
$i--; |
Line 2392 sub readableTime ($$) |
|
Line 2539 sub readableTime ($$) |
|
my $rest = $secs % $break; |
my $rest = $secs % $break; |
$i--; |
$i--; |
$break = $breaks[$i]; |
$break = $breaks[$i]; |
my $resttime = plural_write(int ($rest / $break), |
my $resttime = plural_write(int ($rest / $break), |
$desc{$break}); |
$desc{$break}); |
if ($resttime) { |
if ($resttime) { |
$retval = $retval . ", " . $resttime; |
$retval = $retval . ", " . $resttime; |
Line 2410 sub readableTime ($$) |
|
Line 2557 sub readableTime ($$) |
|
# basename (last directory/file) is a link as well |
# basename (last directory/file) is a link as well |
## |
## |
sub clickablePath($$) { |
sub clickablePath($$) { |
my ($pathname,$clickLast) = @_; |
my ($pathname,$clickLast) = @_; |
my $retval = ''; |
my $retval = ''; |
|
|
if ($pathname eq '/') { |
if ($pathname eq '/') { |
# this should never happen - chooseCVSRoot() is |
# this should never happen - chooseCVSRoot() is |
# intended to do this |
# intended to do this |
Line 2454 sub chooseCVSRoot() { |
|
Line 2601 sub chooseCVSRoot() { |
|
my ($k); |
my ($k); |
print "<form method=\"GET\" action=\"${scriptwhere}\">\n"; |
print "<form method=\"GET\" action=\"${scriptwhere}\">\n"; |
foreach $k (keys %input) { |
foreach $k (keys %input) { |
print "<input type=hidden NAME=$k VALUE=$input{$k}>\n" |
print "<input type=hidden NAME=$k VALUE=$input{$k}>\n" |
if ($input{$k}) && ($k ne "cvsroot"); |
if ($input{$k}) && ($k ne "cvsroot"); |
} |
} |
# Form-Elements look wierd in Netscape if the background |
# Form-Elements look wierd in Netscape if the background |
Line 2488 sub chooseMirror() { |
|
Line 2635 sub chooseMirror() { |
|
# and may not be useful for your site; If you don't |
# and may not be useful for your site; If you don't |
# set %MIRRORS this won't show up, anyway |
# set %MIRRORS this won't show up, anyway |
# |
# |
# Should perhaps exlude the current site somehow.. |
# Should perhaps exlude the current site somehow.. |
if (keys %MIRRORS) { |
if (keys %MIRRORS) { |
print "\nThis cvsweb is mirrored in:\n"; |
print "\nThis cvsweb is mirrored in:\n"; |
foreach $mirror (keys %MIRRORS) { |
foreach $mirror (keys %MIRRORS) { |
Line 2500 sub chooseMirror() { |
|
Line 2647 sub chooseMirror() { |
|
} |
} |
} |
} |
|
|
sub fileSortCmp { |
sub fileSortCmp() { |
my ($comp) = 0; |
my ($comp) = 0; |
my ($c,$d,$af,$bf); |
my ($c,$d,$af,$bf); |
|
|
Line 2531 sub fileSortCmp { |
|
Line 2678 sub fileSortCmp { |
|
} |
} |
|
|
# make A url for downloading |
# make A url for downloading |
sub download_url { |
sub download_url($$;$) { |
my ($url,$revision,$mimetype) = @_; |
my ($url,$revision,$mimetype) = @_; |
|
|
$revision =~ s/\b0\.//; |
$revision =~ s/\b0\.//; |
Line 2548 sub download_url { |
|
Line 2695 sub download_url { |
|
return $url; |
return $url; |
} |
} |
|
|
# Presents a link to download the |
# Presents a link to download the |
# selected revision |
# selected revision |
sub download_link { |
sub download_link($$$;$) { |
my ($url,$revision,$textlink,$mimetype) = @_; |
my ($url,$revision,$textlink,$mimetype) = @_; |
my ($fullurl) = download_url($url,$revision,$mimetype); |
my ($fullurl) = download_url($url,$revision,$mimetype); |
my ($paren) = $textlink =~ /^\(/; |
my ($paren) = $textlink =~ /^\(/; |
Line 2622 sub toggleQuery($$) { |
|
Line 2769 sub toggleQuery($$) { |
|
return ""; |
return ""; |
} |
} |
|
|
sub urlencode { |
sub urlencode($) { |
my ($in) = @_; |
my ($in) = @_; |
my ($out); |
my ($out); |
($out = $in) =~ s/([\000-+{-\377])/sprintf("%%%02x", ord($1))/ge; |
($out = $in) =~ s/([\000-+{-\377])/sprintf("%%%02x", ord($1))/ge; |
return $out; |
return $out; |
} |
} |
|
|
sub http_header { |
sub http_header(;$) { |
my $content_type = shift || "text/html"; |
my $content_type = shift || "text/html"; |
if (defined($moddate)) { |
if (defined($moddate)) { |
if ($is_mod_perl) { |
if ($is_mod_perl) { |
Apache->request->header_out(Last_modified => scalar gmtime($moddate) . " GMT"); |
Apache->request->header_out("Last-Modified" => scalar gmtime($moddate) . " GMT"); |
} |
} |
else { |
else { |
print "Last-Modified: " . scalar gmtime($moddate) . " GMT\r\n"; |
print "Last-Modified: " . scalar gmtime($moddate) . " GMT\r\n"; |
Line 2646 sub http_header { |
|
Line 2793 sub http_header { |
|
print "Content-type: $content_type\r\n"; |
print "Content-type: $content_type\r\n"; |
} |
} |
if ($allow_compress && $maycompress) { |
if ($allow_compress && $maycompress) { |
my $fh = do {local(*FH);}; |
if ($has_zlib || (defined($GZIPBIN) && open(GZIP, "|$GZIPBIN -1 -c"))) { |
if (defined($GZIPBIN) && open($fh, "|$GZIPBIN -1 -c")) { |
|
if ($is_mod_perl) { |
if ($is_mod_perl) { |
Apache->request->content_encoding("x-gzip"); |
Apache->request->content_encoding("x-gzip"); |
Apache->request->header_out(Vary => "Accept-Encoding"); |
Apache->request->header_out(Vary => "Accept-Encoding"); |
Line 2659 sub http_header { |
|
Line 2805 sub http_header { |
|
print "\r\n"; # Close headers |
print "\r\n"; # Close headers |
} |
} |
$| = 1; $| = 0; # Flush header output |
$| = 1; $| = 0; # Flush header output |
select ($fh); |
if ($has_zlib) { |
|
tie *GZIP, __PACKAGE__, \*STDOUT; |
|
} |
|
select(GZIP); |
|
$gzip_open = 1; |
# print "<!-- gzipped -->" if ($content_type eq "text/html"); |
# print "<!-- gzipped -->" if ($content_type eq "text/html"); |
} |
} |
else { |
else { |
Line 2684 sub http_header { |
|
Line 2834 sub http_header { |
|
|
|
sub html_header($) { |
sub html_header($) { |
my ($title) = @_; |
my ($title) = @_; |
my $version = '$zRevision: 1.93 $ $Revision$'; |
my $version = '$zRevision: 1.103 $ $Revision$'; #' |
http_header(); |
http_header(); |
print <<EOH; |
print <<EOH; |
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN" |
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN" |
Line 2698 $logo <h1 align="center">$title</h1> |
|
Line 2848 $logo <h1 align="center">$title</h1> |
|
EOH |
EOH |
} |
} |
|
|
sub html_footer { |
sub html_footer() { |
return "<hr noshade><address>$address</address>\n"; |
return "<hr noshade><address>$address</address>\n"; |
} |
} |
|
|
sub link_tags |
sub link_tags($) { |
{ |
|
my ($tags) = @_; |
my ($tags) = @_; |
my ($ret) = ""; |
my ($ret) = ""; |
my ($fileurl,$filename); |
my ($fileurl,$filename); |
|
|
# |
# |
# See if a module is listed in the config file's @HideModule list. |
# See if a module is listed in the config file's @HideModule list. |
# |
# |
sub forbidden_module { |
sub forbidden_module($) { |
my($module) = @_; |
my($module) = @_; |
|
|
for (my $i=0; $i < @HideModules; $i++) { |
for (my $i=0; $i < @HideModules; $i++) { |
return 1 if $module eq $HideModules[$i]; |
return 1 if $module eq $HideModules[$i]; |
} |
} |
|
|
return 0; |
return 0; |
|
} |
|
|
|
# Close the GZIP handle remove the tie. |
|
|
|
sub gzipclose { |
|
if ($gzip_open) { |
|
select(STDOUT); |
|
close(GZIP); |
|
untie *GZIP; |
|
$gzip_open = 0; |
|
} |
|
} |
|
|
|
# implement a gzipped file handle via the Compress:Zlib compression |
|
# library. |
|
|
|
sub MAGIC1() { 0x1f } |
|
sub MAGIC2() { 0x8b } |
|
sub OSCODE() { 3 } |
|
|
|
sub TIEHANDLE { |
|
my ($class, $out) = @_; |
|
my ($d) = Compress::Zlib::deflateInit(-Level => Compress::Zlib::Z_BEST_COMPRESSION(), |
|
-WindowBits => -Compress::Zlib::MAX_WBITS()) or return undef; |
|
my ($o) = { |
|
handle => $out, |
|
dh => $d, |
|
crc => 0, |
|
len => 0, |
|
}; |
|
my ($header) = pack("c10", MAGIC1, MAGIC2, Compress::Zlib::Z_DEFLATED(), 0,0,0,0,0,0, OSCODE); |
|
print {$o->{handle}} $header; |
|
return bless($o, $class); |
|
} |
|
|
|
sub PRINT { |
|
my ($o) = shift; |
|
my ($buf) = join(defined $, ? $, : "",@_); |
|
my ($len) = length($buf); |
|
my ($compressed, $status) = $o->{dh}->deflate($buf); |
|
print {$o->{handle}} $compressed if defined($compressed); |
|
$o->{crc} = Compress::Zlib::crc32($buf, $o->{crc}); |
|
$o->{len} += $len; |
|
return $len; |
|
} |
|
|
|
sub PRINTF { |
|
my ($o) = shift; |
|
my ($fmt) = shift; |
|
my ($buf) = sprintf($fmt, @_); |
|
my ($len) = length($buf); |
|
my ($compressed, $status) = $o->{dh}->deflate($buf); |
|
print {$o->{handle}} $compressed if defined($compressed); |
|
$o->{crc} = Compress::Zlib::crc32($buf, $o->{crc}); |
|
$o->{len} += $len; |
|
return $len; |
|
} |
|
|
|
sub WRITE { |
|
my ($o, $buf, $len, $off) = @_; |
|
my ($compressed, $status) = $o->{dh}->deflate(substr($buf, 0, $len)); |
|
print {$o->{handle}} $compressed if defined($compressed); |
|
$o->{crc} = Compress::Zlib::crc32(substr($buf, 0, $len), $o->{crc}); |
|
$o->{len} += $len; |
|
return $len; |
|
} |
|
|
|
sub CLOSE { |
|
my ($o) = @_; |
|
return if !defined( $o->{dh}); |
|
my ($buf) = $o->{dh}->flush(); |
|
$buf .= pack("V V", $o->{crc}, $o->{len}); |
|
print {$o->{handle}} $buf; |
|
undef $o->{dh}; |
|
} |
|
|
|
sub DESTROY { |
|
my ($o) = @_; |
|
CLOSE($o); |
} |
} |