mtense productions

some stuff you might find useful

Subscribe to this list via RSS Blog posts tagged in Web

Posted by on in Techie Stuff

When web hosts lock down their firewalls, they often close commonly used outgoing SMTP ports.  Most everyone is used to port 25 being blocked, but my web host was also blocking 465 and 587 which are the common ports for sending SMTP traffic over SSL and TLS connections.

Of course, when you get the first level support guys trying to mess with the firewall, they are rarely successful.  It is handy to have a command you and they can run to check their work.

Here are the openssl commands for checking the connections.  These connect to google's gmail servers.

openssl s_client -connect smtp.gmail.com:465 -crlf -ign_eof
openssl s_client -connect smtp.gmail.com:587 -starttls smtp -crlf

The first command connects on port 465 is typically used for SMTP traffic over SSL.  You can test different versions of SSL with the -ssl2 and -ssl3 options.  There is nothing email specific about the command. A small variation can be used to check https connections (HTTP over SSL)

openssl s_client -connect www.google.com:443 -crlf -ign_eof

Tagged in: Email SSL Web
Hits: 3833
0

Posted by on in Techie Stuff

It is really annoying when you are trying to make a file available for download and the user's browser keeps opening the file rather than allowing the user to save it.  This php script forces the Save As dialog to show up reliably when downloading a file.

To use the script, download it, set the $path variable to the relative path to your downloads folder, and upload the script to your website.  The default name for the downloads folder is "downloads".  Place your files in the downloads folder (specified in $path above) and link to the files like this:

  • http://www.example.com/download.php?file=filename.txt

For example, if your downloads folder is called "downloads" and it is at the root of your website, then there no changes necessary.  Simply upload the script to your website.

Download the script: download.php

Cleaning up the URL

On apache servers mod_rewrite can hide what's happening under the covers and clean up the download URLs.  So, for example instead of this

  • http://www.example.com/download.php?file=filename.txt

The user sees this

  • http://www.example.com/downloads/filename.txt

Although it appears that the file is being downloaded directly from the downloads directory, mod_rewrite can recognize and rewrite the URL to use the php script for downloading the file.

Options +FollowSymLinks
RewriteEngine On
RewriteRule   ^downloads/(.+)$   download.php?file=$1

Assuming mod_rewrite is available on your server, simply place the code above into the .htaccess file to support downlod URLs with no reference to the php script.  If the downloads directory is not in the root of your website, specify the path in the RewriteRule.  For example, if the downloads directory is located at /foo/bar/downloads, the RewriteRule should look like:

Options +FollowSymLinks
RewriteEngine On
RewriteRule   ^foo/bar/downloads/(.+)$   foo/bar/download.php?file=$1

Download the script with pretty URL: download.php

Tagged in: PHP Web
Hits: 3759
0
You are here: Home Tags Web