Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2018
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. <?php
  2. $oldDirectory = "./test1/"; //this is the ORIGINAL stuff
  3. $newDirectory = "./test2/"; //this is the NEW stuff
  4.  
  5. foreach (glob($newDirectory . "*.*") as $filename) {
  6. $localFile = str_replace($filename, $newDirectory, "");
  7. $newHash = sha256(file_get_contents($filename));
  8. echo $localFile . ": " . $newHash;
  9. if (file_exists($oldDirectory . $localFile)) {
  10. echo " found locally ";
  11. $oldHash = sha256(file_get_contents($oldDirectory . $localFile));
  12. if ($newHash !== $oldHash) {
  13. echo " mismatch!";
  14. //uncomment the next line to auto replace (maybe?)
  15. //file_put_contents($oldDirectory . $localFile, file_get_contents($filename));
  16. }
  17. echo PHP_EOL;
  18. }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement