As it goes with the usual web developers’ daily routines, I’m sure you’ve all been in a situation, where you had to work on a site without, or with very limited access options to the site’s server.
Usually, troubles go from no CPanel or Shell access, wrong permissions for the FTP user so you cannot change or add new files, down to a situation where you are restricted to only work from the site’s admin panel!
I know how frustrating that can be, so during the years I’ve developed little “Helpers” scripts, which were of great help to me, and hopefully, it can also save you some valuable time.
Today I will present you with a very simple, but very powerful PHP script, that will delete every file and folder in the current directory where the script is put. And all of that in a matter of seconds, even when dealing with large CMS sites like WordPress or Joomla! with thousands of files in them.
Trying to do the same thing through FTP, would sometimes take a tremendous amount of time. Even hours depending on your internet connection and the size of the dir you want to delete.
I “very intelligently” called it: Deleter.php
Ho to use it:
- Place it in your desired folder. Let’s say:
/user/public_html/my_site/Deleter.php
- And run it through the browser like
https://mysite.com/Deleter.php
- Wait to finish loading and you’re done. The script will also “self-delete” as part of the process. So no security leftovers will be present on your site.
Disclaimer:
Since this is a very powerful script it is important to be 100% sure where are you putting it and which files and folders you really like to delete before you even run it. When the script finishes, the deleted files are lost forever! So be careful what you are doing and use it at your own risk. I shall not be held liable for any misuse or damages it may do to your data or server.