效果图
上代码:
<style>
h1{font-size:24px;line-height:180%;font-weight:600;margin:1px 2px;color:#0180cf;}
h2{font-size:20px;line-height:140%;font-weight:600;margin:2px 4px;color:green;}
h3{font-size:16px;line-height:140%;font-weight:600;margin:2px 4px;color:green;}
h4{font-size:12px;line-height:120%;font-weight:300;margin:1px 2px;color:blue;}
b{font-size:14px;color:red;}
form{margin:11px auto;padding:10px;text-align:left;width:99%;border:1px #0180CF solid;}
select,input{padding:5px;}
button,input[type='submit']{background:green;color:white;padding:5px;}
input[type=text]{width:254px;}
</style>
<?php
$ddtt = date("YmdHis");
$domas = (isset($_GET['do']))?addslashes($_GET['do']):'';
$folds = (isset($_POST['time']))?addslashes($_POST['time']):'';
if( strlen($folds)>1){
if($folds=="AllFolder") $folds = '';
}else{
?>
<form name="qu" method="post" action="" >
<select name="time" id="time" >
<?php
$dir_name = "../";
$dir = opendir($dir_name);
$fileArr = array();
while ($file_name = readdir($dir)) {
if (($file_name ==".") || ($file_name == "..")) {
} else if(is_dir($dir_name.$file_name)) {
$fName = "$dir_name$file_name";
$fTime = filemtime($fName);
$fileArr[$file_name] = $fTime;
//可以文件夹分类,选择对应的目录查询:如果不分一个文件夹即可
echo "<option value=\"{$file_name}\">$file_name</option>";
}
}
echo "<option value=\"AllFolder\">AllFolder</option>";
?>
</select>
<button id="button" >立即显示</button>
</form>
<?php
exit();
}
function charaget($data){
if(!empty($data) ){
$fileType = mb_detect_encoding($data , array('UTF-8','GBK','LATIN1','BIG5')) ;
if( $fileType != 'UTF-8'){
$data = mb_convert_encoding($data ,'utf-8' , $fileType);
}
}
return $data;
}
function txtarea($nb,$folds,$ht="88vh") {
global $ddtt;
$json = json_encode($nb, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT);
return "<textarea style='display:inline; height:$ht;width:38vw;'>$json</textarea>";
}
function characet($data){
if(!empty($data) ){
$fileType = mb_detect_encoding($data , array('UTF-8','GBK','LATIN1','BIG5')) ;
if( $fileType != 'GBK'){
$data = mb_convert_encoding($data ,'GBK' , $fileType);
}
}
return $data;
}
function my_scandir($dir){
$files = array(); $filetxt=[];
if ( $handle = opendir($dir) ) {
while ( ($file = readdir($handle)) !== false ) {
if ( $file != ".." && $file != "." ) {
if ( is_dir($dir . $file. "" ) ) {
if(stristr($dir . $file,"/datar") || stristr($dir.$file,"/Tool@")){
//忽略的文件夹
}else{
$filetxt[$file] = my_scandir($dir . $file. "/" );
}
} else{
$filep = $dir . $file;
$filet = substr($file,-3);
$filep = charaget($filep); //$dir . $file;
$filea = charaget($file);
$b = preg_replace("/[^0-9^A-Z^a-z]+/u", '', $dir);
$blacki = "-laydate.css-laydate.js-"; //不搜索的文件名称
$whitei = "-php-css-.js-htm-tml-asp-txt-inc-sql-"; //搜索的文件后缀列表(一律后三位)
if(stristr($whitei,"-{$filet}-") && !stristr($blacki,"-{$file}-")){
if (is_file($filep)){}else{$filep = characet($filep);}
$filey = charaget($filep);
$filetxt[$filey]["filename"] = $filey;
$filetxt[$filey]["filesize"] = filesize($filey);
$filetxt[$filey]["fileedit"] = filemtime($filey);
$filetxt[$filey]["filejian"] = filectime($filey);
$filetxt[$filey]["filesmd5"] = md5_file($filey);
}
}
}
}
closedir($handle);
return $filetxt;
}
}
if($folds==""){$soudir = "../";}else{$soudir = "../{$folds}/";}
if(is_dir($soudir)) {
$result = my_scandir($soudir);
echo txtarea($result,$folds);
}else{
echo "<h1>文件夹<b>{$soudir}</b>不存在!</h1>\r\n";
}
然后用网络免费的对比工具(比如Mergely等)对比各次文件特征比如文件大小对比
以及HASH值对比,文件时间对比,文件增减对比等
Mergely对比工具: