Имеется PHP-скрипт, который хеширует файлы из папки "update" в md5:
<?php
$folder = 'update/';
$file = 'update.upd';
$separator = '[cell]';
file_put_contents($file,'');
function rdir ($path2dir) {
$d = dir ($path2dir);
while (false !== ($entry = $d->read())) {
if ($entry!='.' && $entry!='..' && $entry!='' ) {
$all_path = $path2dir.$entry;
$new_path = go ($all_path, is_file($all_path));
if (!is_file($all_path)) {
if (!rdir ($new_path)) {
return false;
}
}
}
}
return true;
}
function go ($path2file, $is_file = true) {
if ($is_file) {
$as = 'http://'.$_SERVER['SERVER_NAME'].dirname($_SERVER['SCRIPT_NAME']).'/'.$path2file.$separator.md5_file($path2file).$separator.substr($path2file,strrpos($path2file,'\\')+6).'\n';
$fh = fopen($file, 'a+');
fwrite($fh, $as);
} else {
$path2file = $path2file.'/';
}
return $path2file;
}
if (rdir ($folder)){echo('OK');}
?>
При открытии этого файла в браузере, должно быть выведено сообщение "ОК", а в директории, где находится скрипт, появится файл "update.upd
", который будет содержать в себе хэш-суммы.
При открытии файла в браузере выводится подобное:
Warning: fopen() [function.fopen]: Filename cannot be empty in T:\home\ixcraft.local\launcher\md5.php on line 24 Warning: fwrite() expects parameter 1 to be resource, boolean given in T:\home\ixcraft.local\launcher\md5.php on line 25
Проблема в функциях fopen() и fwrite(), - это и так всем понятно.
Вопрос: как решить данную проблему, в чём ошибка?