Two little PHP scripts I use, and maybe you should too.

I wanted to introduce you to two small PHP scripts that I often use. Both are mainly used when working with Joomla! But I’m sure anyone can adjust it to other needs even with a little PHP knowledge.

Both scripts are tiny and meant to do one specific thing. Easy and effective.

The first file is universal; the second is prepared for Joomla! installations, but you can easily modify it if you know PHP to work with any similar folder structure.

copy.php — use it to transfer files between two servers.

This script lets you provide the source file and download it from a remote server to the server where the file is located. Mostly used for transferring large files between servers.

This is how the server to server PHP copy script file looks like

How copy.php works?

  1. Download the file from → here.

2. Upload it via FTP to the server where you want the file to be downloaded.

3. Edit the file and fill:

3a. In $source, provide the remote file full URL

3b. In $target, provide the target filename (file will be downloaded to the same folder where copy.php is)

4. Open your browser and fire up the file copy.php from your server

5. Wait a moment, and if all went fine, you’d see a “File copied” notification

That’s it; your file was copied.

tmpcleaner.php — use it to empty /tmp and /cache folders

In tmpcleaner.php file, you can choose if you want to clean only /tmp or /cache folders' contents. You can also empty both those folders at once.

tmpcleaner.php script.
tmpcleaner.php script.
This is how tmpcleaner.php PHP script code looks like

How tmpcleaner.php script works?

  1. Download the file from → here.
  2. Upload it via FTP to the location where your Joomla! installations are located
  3. Edit the file and comment or uncomment lines 3 and/or 4

3a. scanAndClear(‘tmp’) — this line tells the script to empty the /tmp folders

3b. scanAndClear(‘cache’) — this line tells the script to empty the /cache folders

4. Open your browser, navigate to the URL where the file is located, and fire it up.

5. See files and folders deleted. Once the process is over, you’ll see a “Done!” message.

Screenshot of finished work of the tmpcleaner.php script

Thank you for reading! I hope you find these scripts useful. If you have any questions or something to add, let me know.