• Skip to main content

Uly.me

cloud engineer

  • Home
  • About
  • Search

Archives for July 2016

How To Force Downloads

July 24, 2016

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>

<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 = "http://domain.com/download/";
$url = $filepath.$filename;
header("Content-disposition: attachment; filename=".$filename."");
header("Content-type: application/octet-stream");
readfile("".$url."");

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

Our HTML download link will look like this.

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

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

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

Filed Under: PHP Tagged With: browser, download, readfile

Install Exim4 On Ubuntu Server

July 22, 2016

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

$ sudo apt install exim4

Configure Exim4.

$ sudo dpkg-reconfigure exim4-config

$ 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 “127.0.0.1 ; ::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" recepient@email.com
$ Hello there. This is the body of the message.

$ mail -s "Your Subject" recepient@email.com $ 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.

Filed Under: Linux Tagged With: exim4, mail

Remove CleanMyMac

July 19, 2016

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.

Filed Under: Mac, Misc Tagged With: cleanmymac, find any file, terminal

  • Go to page 1
  • Go to page 2
  • Go to page 3
  • Go to Next Page »
  • Home
  • About
  • Search

Copyright © 2023