mirror of
https://github.com/php/web-doc.git
synced 2025-08-06 11:06:29 +00:00
this is even safer
This commit is contained in:
@ -238,32 +238,39 @@ function get_stats($idx, $lang, $status) {
|
||||
return array($result['total'], $result['size']);
|
||||
}
|
||||
|
||||
function showdiff ( $dir, $gitfile, $h2, $c )
|
||||
function showdiff ()
|
||||
{
|
||||
$cwd = getcwd();
|
||||
chdir( $dir );
|
||||
$file = `git diff {$h2} -- {$gitfile}`;
|
||||
chdir( $cwd );
|
||||
$raw = htmlspecialchars( $file, ENT_XML1, 'UTF-8' );
|
||||
if ( $c == 'on' ) {
|
||||
$trans = [ " " => " " ];
|
||||
$lines = explode ( "\n" , $raw );
|
||||
foreach ( $lines as $line ) {
|
||||
$inline = strtr( $line , $trans );
|
||||
$fc = substr( $inline , 0 , 1 );
|
||||
if ( $fc == "+" ) {
|
||||
echo "<div style='color:green;font-family:mono'>";
|
||||
} elseif ( $fc == "-" ) {
|
||||
echo "<div style='color:red;font-family:mono'>";
|
||||
} elseif ( $fc == "@" ) {
|
||||
echo "<div style='color:blue;font-family:mono'>";
|
||||
} else
|
||||
echo "<div style='color:gray;font-family:mono'>";
|
||||
echo "$inline</div>\n";
|
||||
}
|
||||
echo "<p></p>";
|
||||
} else
|
||||
echo "<pre style='font-family:mono'>" , $raw , "</pre>";
|
||||
if (isset($_GET['f'])) {
|
||||
$gitfile = $_GET['f'];
|
||||
if (isset($_GET['hbp']))
|
||||
$h = $_GET['hbp'];
|
||||
if (isset($_GET['c']))
|
||||
$c = $_GET['c'];
|
||||
$cwd = getcwd();
|
||||
chdir( GIT_DIR . 'en' );
|
||||
$file = `git diff {$h} -- {$gitfile}`;
|
||||
chdir( $cwd );
|
||||
$raw = htmlspecialchars( $file, ENT_XML1, 'UTF-8' );
|
||||
if ( $c == 'on' ) {
|
||||
$trans = [ " " => " " ];
|
||||
$lines = explode ( "\n" , $raw );
|
||||
foreach ( $lines as $line ) {
|
||||
$inline = strtr( $line , $trans );
|
||||
$fc = substr( $inline , 0 , 1 );
|
||||
if ( $fc == "+" ) {
|
||||
echo "<div style='color:green;font-family:mono'>";
|
||||
} elseif ( $fc == "-" ) {
|
||||
echo "<div style='color:red;font-family:mono'>";
|
||||
} elseif ( $fc == "@" ) {
|
||||
echo "<div style='color:blue;font-family:mono'>";
|
||||
} else
|
||||
echo "<div style='color:gray;font-family:mono'>";
|
||||
echo "$inline</div>\n";
|
||||
}
|
||||
echo "<p></p>";
|
||||
} else
|
||||
echo "<pre style='font-family:mono'>" , $raw , "</pre>";
|
||||
}
|
||||
}
|
||||
|
||||
function gen_date($file)
|
||||
|
@ -382,14 +382,7 @@ END_OF_MULTILINE;
|
||||
break;
|
||||
|
||||
case 'plain':
|
||||
if (isset($_GET['f'])) {
|
||||
$gitfile = $_GET['f'];
|
||||
if (isset($_GET['hbp']))
|
||||
$h2 = $_GET['hbp'];
|
||||
if (isset($_GET['c']))
|
||||
$c = $_GET['c'];
|
||||
showdiff( GIT_DIR . 'en', $gitfile, $h2, $c );
|
||||
}
|
||||
showdiff();
|
||||
echo gen_date($DBLANG);
|
||||
break;
|
||||
|
||||
|
Reference in New Issue
Block a user