how to get rid of useless, duplicates, backups files from a webroot folder
I just recove开发者_运维问答r an old website full of useless file (index2.php, index_bkup.php, test.php...), and I wonder how to make a list of these...
Solution can be either server side or client side (but I can't do too much thing serverside)...
As I say the site is pretty old and use a lot of include() function.
Thx for ideas !
I don't know if this should be automated, as it could delete files that look like garbage.
You could do...
$files = glob('path/*.php');
$files = preg_grep('/\d+\.php$/', $files);
foreach($files as $file) {
unlink($file);
}
This will get all PHP files in a directory and delete ones which have a number before the extension, for example index2.php
.
It won't match test.php
, but you could modify it to.
Either way, it may be better using grep
to find these, and then determining on a file by file basis whether they should be deleted or not.
Please backup first.
精彩评论