<?php
function doit($dir= '.' ){
$d=opendir($dir);
while ($f=readdir($d)){
if ($f!== '.' AND $f!== '..' ){
echo $f;
if (is_file($dir. '/' .$f)){
echo ' Converting...' ; $a=file_get_contents($dir. '/' .$f);
$a=iconv( 'UTF-8' ,'WINDOWS-1251' ,$a);
$fp=fopen($dir. '/' .$f, 'w' );
fwrite($fp,$a);
fclose($fp);
echo ' - OK<br />' ;
} elseif (is_dir($dir. '/' .$f)){
echo ' changing dir<br />' ;
doit($dir. '/' .$f);
} else{
echo ' Skipping<br />' ;
}
}
}
}
doit( '.' );
?>