document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. <?php /*encoding:utf-8*/
  2.  
  3. error_reporting(E_ALL);
  4.  
  5. $dir = "adminpanel/";
  6. $recursive = true;
  7.  
  8. $count = 0;
  9. dir_walk("fileprint", $dir, array("php"), $recursive, $dir);
  10.  
  11. echo "processed: $count files";
  12.  
  13. function fileprint($file)
  14. {
  15.     global $count;
  16.     $content = file_get_contents($file);
  17.     if (strripos($content, "encoding:utf-8") === false)
  18.     {
  19.         $pi = strpos($content, "<?");
  20.         if ($pi !== false)
  21.         {
  22.             file_put_contents($file.".bak", $content);
  23.             $pi += strlen("<?");
  24.             $content = iconv("ISO-8859-2", "UTF-8", $content);
  25.             $content = substr($content, 0, $pi)." /*encoding:utf-8*/ ".substr($content, $pi);
  26.             //echo $file."\\n".$content."\\n\\n";
  27.             file_put_contents($file, $content);
  28.             $count ++;
  29.         }
  30.     }
  31. }
  32.  
  33. function dir_walk($callback, $dir, $types = null, $recursive = false, $baseDir = \'\') {
  34.     if ($dh = opendir($dir)) {
  35.         while (($file = readdir($dh)) !== false) {
  36.             if ($file === \'.\' || $file === \'..\') {
  37.                 continue;
  38.             }
  39.             if (is_file($dir . $file)) {
  40.                 if (is_array($types)) {
  41.                     if (!in_array(strtolower(pathinfo($dir . $file, PATHINFO_EXTENSION)), $types, true)) {
  42.                         continue;
  43.                     }
  44.                 }
  45.                 $callback($baseDir . $file);
  46.             }elseif($recursive && is_dir($dir . $file)) {
  47.                 dir_walk($callback, $dir . $file . DIRECTORY_SEPARATOR, $types, $recursive, $baseDir . $file . DIRECTORY_SEPARATOR);
  48.             }
  49.         }
  50.         closedir($dh);
  51.     }
  52. }
  53. ?>
');