Advertisement
Guest User

Untitled

a guest
Jul 4th, 2015
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.06 KB | None | 0 0
  1. <?php
  2.  
  3. // =======================================================================================
  4. // Script for checking file changes and if there's changes - replace with an old version
  5. // Really I don't know who need it, use freely everywhere!
  6. //
  7. // File list settings:
  8. // $files[number] = array('path/to/source.file', 'path/to/file_we_need_to.check');
  9. //
  10. // You can choose relative or absolut path
  11. // =======================================================================================
  12.  
  13. $files[0] = array('src/js.js', 'dest/js.js');
  14. $files[1] = array('src/js.js', 'dest/js.js');
  15.  
  16.  
  17. // =======================================================================================
  18. // Keep this safe :)
  19.  
  20. header('Content-Type: text/html; charset=utf-8');
  21.  
  22. foreach ($files AS $onefile) {
  23. $sfile = sha1_file($onefile[0]);
  24. $dfile = sha1_file($onefile[1]);
  25.  
  26. if ($sfile!=$dfile) {
  27. echo "There's changes in '".$dfile."'. Rewriting...<br />";
  28. if (!copy($onefile[0], $onefile[1])) {
  29. echo "We have a problem copying '".$onefile[0]."'...\n";
  30. }
  31. }
  32. }
  33.  
  34. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement