1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| $configs = array( '/var/www/html/adsour/zhongtai' => '20161227', '/var/www/html/adsour/zhongxin' => '20161228', '/var/www/html/adsour/zhongyuan' => '20161229' );
foreach ($configs as $file => $time) { change($file, $time . " " . randTime()); }
function change($path, $time) { $cmd = "touch -t " . date('YmdHi.s', strtotime($time)) . " {$path}"; echo $cmd . "\n"; system($cmd);
if (!is_dir($path)) { return true; } $files = scandir($path); foreach ($files as $file) { if ('.' === $file || '..' === $file) { continue; } $filePath = $path . "/" . $file; change($filePath, $time); } }
function randTime() { $hour = rand(10, 22); $miniute = rand(0, 60); $second = rand(0, 60); $miniute = 3; if ($miniute < 10) { $miniute = '0' . $miniute; } if ($second < 10) { $second = '0' . $second; } return $hour . ':' . $miniute . ':' . $second; }
|