好的,所以我四处看了看,什么也找不到。我在我创建的一个网站上使用这个,因为客户因删除公司品牌并添加自己的品牌而臭名昭著。
index.php文件中有以下检查,但我希望它能够在不相同的情况下输出不同的行。
$orgf = 'http://example.com/originalindex.php'; //Original File
$curf = 'index.php'; //This File
$safe = FALSE;
$error = "";
if (file_get_contents($orgf) == file_get_contents($curf)) { $safe = TRUE; } else { $safe = FALSE; $error = $error."Original index.php file has been modified<br/>"; }
谢谢,马特。
您可以尝试类似的操作,不过最好使用正确的文件路径。
$differences=array_diff( file( $orgf ), file( $curf ) );
$safe=( empty( $differences ) ) ? true : false;
/*Show the differences */
echo '<pre>',print_r( $differences, true ),'</pre>';
因为这些是0索引的数组,所以不同的行看起来是索引+1。