/usr/bin/diff2php is in hxtools 20170430-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | #!/usr/bin/perl
#
# diff2php - turn a .diff into a multi-purpose PHP script
# written by Jan Engelhardt, 2004-2007
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the WTF Public License version 2 or
# (at your option) any later version.
#
use strict;
my %C = qw(black 000000 red AA0000 green 00AA00 brown AA5500
blue 0000AA magenta AA00AA cyan 00AAAA gray AAAAAA
dgray 555555 hred FF0000 hgreen 00FF00 yellow FFFF00
hblue 0000FF hmagenta FF00FF hcyan 00FFFF white FFFFFF
dblue 000080);
my $F = "</font>";
my %D;
my @keep;
foreach my $key (keys %C) {
$D{$key} = "<font color=\"".$C{$key}."\">";
}
print <<"--EOF";
<?php
if (getenv("QUERY_STRING") == "1") {
header("Content-Type: text/plain\n");
?>
--EOF
while (defined(my $ln = <STDIN>)) {
push(@keep, $ln);
$ln =~ s{<\?}{<\?php echo "<?"; ?>}g;
print $ln;
}
print <<"--EOF";
<?php } else { ?>
<html>
<style type="text/css">
a { color: B0B0B0; }
</style>
<body style="background-color: #$C{dblue}; color: #$C{gray};">
<p><a href="?1"><i>Download this file as TXT</i></a></p>
<hr />
<pre>
--EOF
while (defined(my $line = shift @keep)) {
chomp($line);
$line =~ s/&/&/gso;
$line =~ s/</</gso;
$line =~ s/>/>/gso;
$line =~ s/^(#.*)/$D{yellow}$1$F/ ||
$line =~ s/^(\@\@.+\@\@)(.*)/$D{cyan}$1$F$D{hcyan}$2$F/ ||
$line =~ s/^(Index:\s.*)/$D{black}$1$F/ ||
$line =~ s/^(diff.*)/<span style="background-color: #$C{red};">$D{white}$1$F<\/span>/ ||
$line =~ s/^((---|\+\+\+|\*\*\*).*)/$D{hmagenta}$1$F/ ||
$line =~ s/^(===.*)/$D{brown}$1$F/ ||
$line =~ s/^([\+\>].*)/$D{hgreen}$1$F/ ||
$line =~ s/^([\-\<].*)/$D{hred}$1$F/ ||
$line =~ s/^(\!.*)/$D{yellow}$1$F/ ||
$line =~ s/^(\?.*)/$D{brown}$1$F/ ||
$line =~ s/^((RCS|retrieving)\s.*)/$D{brown}$1$F/ ||
$line =~ s/^((Only|Common|File|Files|Binary)\s.*)/$D{hblue}$1$F/;
print $line, "\n";
}
print <<"--EOF";
</pre>
</body>
</html>
<?php } ?>
--EOF
|