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']);
|
return array($result['total'], $result['size']);
|
||||||
}
|
}
|
||||||
|
|
||||||
function showdiff ( $dir, $gitfile, $h2, $c )
|
function showdiff ()
|
||||||
{
|
{
|
||||||
$cwd = getcwd();
|
if (isset($_GET['f'])) {
|
||||||
chdir( $dir );
|
$gitfile = $_GET['f'];
|
||||||
$file = `git diff {$h2} -- {$gitfile}`;
|
if (isset($_GET['hbp']))
|
||||||
chdir( $cwd );
|
$h = $_GET['hbp'];
|
||||||
$raw = htmlspecialchars( $file, ENT_XML1, 'UTF-8' );
|
if (isset($_GET['c']))
|
||||||
if ( $c == 'on' ) {
|
$c = $_GET['c'];
|
||||||
$trans = [ " " => " " ];
|
$cwd = getcwd();
|
||||||
$lines = explode ( "\n" , $raw );
|
chdir( GIT_DIR . 'en' );
|
||||||
foreach ( $lines as $line ) {
|
$file = `git diff {$h} -- {$gitfile}`;
|
||||||
$inline = strtr( $line , $trans );
|
chdir( $cwd );
|
||||||
$fc = substr( $inline , 0 , 1 );
|
$raw = htmlspecialchars( $file, ENT_XML1, 'UTF-8' );
|
||||||
if ( $fc == "+" ) {
|
if ( $c == 'on' ) {
|
||||||
echo "<div style='color:green;font-family:mono'>";
|
$trans = [ " " => " " ];
|
||||||
} elseif ( $fc == "-" ) {
|
$lines = explode ( "\n" , $raw );
|
||||||
echo "<div style='color:red;font-family:mono'>";
|
foreach ( $lines as $line ) {
|
||||||
} elseif ( $fc == "@" ) {
|
$inline = strtr( $line , $trans );
|
||||||
echo "<div style='color:blue;font-family:mono'>";
|
$fc = substr( $inline , 0 , 1 );
|
||||||
} else
|
if ( $fc == "+" ) {
|
||||||
echo "<div style='color:gray;font-family:mono'>";
|
echo "<div style='color:green;font-family:mono'>";
|
||||||
echo "$inline</div>\n";
|
} elseif ( $fc == "-" ) {
|
||||||
}
|
echo "<div style='color:red;font-family:mono'>";
|
||||||
echo "<p></p>";
|
} elseif ( $fc == "@" ) {
|
||||||
} else
|
echo "<div style='color:blue;font-family:mono'>";
|
||||||
echo "<pre style='font-family:mono'>" , $raw , "</pre>";
|
} 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)
|
function gen_date($file)
|
||||||
|
@ -382,14 +382,7 @@ END_OF_MULTILINE;
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'plain':
|
case 'plain':
|
||||||
if (isset($_GET['f'])) {
|
showdiff();
|
||||||
$gitfile = $_GET['f'];
|
|
||||||
if (isset($_GET['hbp']))
|
|
||||||
$h2 = $_GET['hbp'];
|
|
||||||
if (isset($_GET['c']))
|
|
||||||
$c = $_GET['c'];
|
|
||||||
showdiff( GIT_DIR . 'en', $gitfile, $h2, $c );
|
|
||||||
}
|
|
||||||
echo gen_date($DBLANG);
|
echo gen_date($DBLANG);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user