<?
mysql_connect('localhost', 'root', '') or die();
mysql_select_db('data');
$dir = "data/save_img/data/";
$files = array_diff( scandir( $dir), array('..', '.'));
foreach($files AS $i => $filename) {
if (strlen($filename) < 32 && $filename !== '.htaccess') {
$key = md5($filename).".jpg";
$block_n = $dir.$filename;
$block_res = $dir.$key;
rename($block_n, $block_res);
mysql_query("INSERT INTO `img` (`id`, `way`) VALUES (NULL, '$block_res')");
} else {
}
}
?>