Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $oldDirectory = "./test1/"; //this is the ORIGINAL stuff
- $newDirectory = "./test2/"; //this is the NEW stuff
- foreach (glob($newDirectory . "*.*") as $filename) {
- $localFile = str_replace($filename, $newDirectory, "");
- $newHash = sha256(file_get_contents($filename));
- echo $localFile . ": " . $newHash;
- if (file_exists($oldDirectory . $localFile)) {
- echo " found locally ";
- $oldHash = sha256(file_get_contents($oldDirectory . $localFile));
- if ($newHash !== $oldHash) {
- echo " mismatch!";
- //uncomment the next line to auto replace (maybe?)
- //file_put_contents($oldDirectory . $localFile, file_get_contents($filename));
- }
- echo PHP_EOL;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement