How To Force Downloads

Browsers behave differently when it comes to linking media files. Sometimes it will play them directly on the browser. Sometimes it will download them. Each browser seems to have their own rules. So, how do we force all browsers to download media files with just a click of a link.

A simple link like the one below simply won’t work.

<a href="video.mp4">Download</a>

One way of forcing downloads is to use a PHP function called readfile.

We have a file below called dl.php. We pass the filename to it, as well as set the path and URL.

$filename = $_GET['file'];
$filepath = "";
$url = $filepath.$filename;
header("Content-disposition: attachment; filename=".$filename."");
header("Content-type: application/octet-stream");

Our HTML download link will look like this.

<a href="dl.php?file=video.mp4">Download</a>

It’s one way of forcing a download via the PHP route.

Install Exim4 On Ubuntu Server

Exim4 is a MTA or message transfer agent that runs on Linux systems. It’s freely available under GNU Linux. If you need to run mail from a server or send an email through an app, you’ll need to install Exim4. It can be installed in place of Sendmail or Postfix.

To install Exim4, open up your Terminal.

$ sudo apt install exim4

Configure Exim4.

$ sudo dpkg-reconfigure exim4-config

You’ll be asked several questions.

  1. Select “internet site” for type of mail configuration.
  2. Enter your domain name when asked about system mail name.
  3. Answer “ ; ::1” when asked about incoming SMTP connections
  4. Answer the default answers for the next 3 questions.
  5. Answer “No” for Dial on demand.
  6. Answer “mbox” for delivery method for local mail.
  7. Answer “yes” to split configuration into small files.

If you need to reconfigure Exim4, just re-run the reconfigure command.

Don’t try to edit the /var/lib/exim4/config.autogenerated file.

Test if Exim4 is sending out emails.

$ mail -s "Your Subject"
$ Hello there. This is the body of the message.

Type Ctrl-D to send the message.

Another way to test if Exim4 is working is to use WordPress. There’s a lost password link below the login page. Click on that. Supply a valid user email address. You should received an email directly from WordPress.

Remove CleanMyMac

Several months ago, I’ve installed an app called CleanMyMac. Big mistake. I didn’t like it much. I deleted it shortly after. The uninstall didn’t quite exactly remove everything. This morning, I updated my computer with the latest Mac updates. It required a reboot. Sure enough, the CleanMyMac notifications came back. Apparently, there’s some pieces of the app that are still running on my machine.

The only way I was able to delete anything related to the CleanMyMac app was to use a couple of tools. One is called Find Any File, a handy utility for finding obscure files in your OS. The other is the handy tool called the Terminal. Start with the Find Any File app and search for files that contain the words “CleanMyMac” and “macaw.” The Find Any File app will show you a list of files and their locations. You should be able to delete the files directly from the app. However, there are some files that are write-protected. They can be deleted using a sudo account on the Terminal.

Open up your Terminal and start deleting the files using “sudo rm” command. You’ll be ask to provide the admin password. Don’t forget to empty the Trash.

That should do the trick.

The Return of the Linux Desktop

I’m thinking about using the Linux desktop again after 4 years of inactivity. The MacOS was the desktop of choice. I’ve been happy with the switch. I don’t anticipate abandoning it any time soon. Lately I thought about sharpening up my Linux skills after having been dormant for years. I need a Linux platform that I can work with. Ubuntu is my default, but there are other distros equally interesting. Mint, Debian and Fedora come to mind. Instead of having multiple boot partitions, I might install Ubuntu as the base distro and install Virtualbox. Other distros can be fired up as virtual machines. In that way, it’s simple to manage. I just need a heftier machine that can handle several VMs running at the same time. That’s the plan for the next several weeks.

Change WordPress Password

One of the worst things that could happen to your blog is losing your login credentials. It’s a rare event, but it does happen occasionally. This is particularly true if you run hundreds of blogs and websites. Keeping track of all usernames and passwords can be a bit of a challenge.

If you have forgotten your WordPress password, you can quickly recover it, by using the “Lost your password” link underneath the login form. In my case, WordPress mail was not working. So, not only I can’t remember my password, but I also can’t send out lost passwords via email.

Thankfully, I had access to PHPMyadmin, a MySQL database administration tool.

Log in to PHPMyadmin. Access the WordPress database and look for the wp_users table. Edit the admin user and change the “user_pass” field. The WordPress password field uses the MD5 encryption instead of being in the clear.


Save your changes. Log in to WordPress.