Make phone ext optional for XML API

Previously, the @ext attribute for the phone number field was assumed to be
included. An XML payload without the @ext attribute would have been
corrupted to include only the first digit of the phone number, which would
fail validation.

This patch correctly handles the XML payload without the @ext attribute for
the phone number. Subsequently, the <phone_ext> element is now also valid
(and optional as well).

Fixes #670
Remove requirement of ticket id in subject line

This patch affords an administrator the ability to remove the
[#%{ticket.number}] from the email template subject line for the new ticket
autoresponse and the new message autoresponse. Previously, the ticket number
with a prefixed hash in brackets was used to identify which ticket thread an
email was in reference to.

With this patch, the email message-id (which was already kept on file) is
sent in the MIME "References" header. When a user responds to and
autoresponse email, the "References" will include this message-id in the
return email. The ticket thread is then matched up with the email based on
the message-id rather than the subject line.

Ticket numbers are still supported in the subject line, in the event that
non-compliant email clients do not properly include the References header.
Merge pull request #688 from greezybacon/feature/message-id-tracking

Remove requirement of external-ticket-id in subject line

Reviewed-With: Peter Rotich <peter@osticket.com>
Fixup message-id tracking for piped emails
Properly detect and handle empty address lists

The mainly comes in when a MIME header which might contain a list of email
addresses (like Reply-To) is to be parsed, but is empty. The Mail_RFC822
class would return an empty mailbox @ localhost (where 'localhost' is the
default default_domain for mail address list parsing).
Don't send emails for non-existent table

When an admin logs in to upgrade to 1.7.1 and further from a version
pervious to 1.7.1, the system will attempt to clear password reset tokens
from the config table, which hasn't been upgraded yet to the namespaced
version from 1.7.1
ROOT_DIR should be used to identify filesystem paths

Historically, ROOT_PATH and ROOT_DIR contained the same value; however,
ROOT_PATH now points to the URL path where osTicket is installed, whereas
ROOT_DIR points to the file system location where osTicket is installed.
Use the correct Content-Type header for CAPTCHA

Some security inspection appliances and load balancers don't appreciate
something in the HTTP headers that is not a valid HTTP header. Furthermore,
the browser needs the Content-Type header to identify that the image is not
the PHP default of text/html
Merge pull request #696 from greezybacon/issue/squelch-pre-upgrade

Don't send emails for non-existent table

Reviewed-By: Peter Rotich <peter@osticket.com>
Include setup/tips.html in download package
Merge pull request #698 from greezybacon/issue/root-dir

ROOT_DIR should be used to identify filesystem paths

Reviewed-By: Peter Rotich <peter@osticket.com>
Merge pull request #699 from greezybacon/issue/captcha-header

Use the correct Content-Type header for CAPTCHA

Reviewed-By: Peter Rotich <peter@osticket.com>
Merge pull request #693 from greezybacon/issue/670

Make phone ext optional for XML API

Reviewed-By: Peter Rotich <peter@osticket.com>
Handle attachment filenames better

Previously, filenames saved in the database had the spaces changed for
underbars; however, other characters (such as commas and non-ascii
characters) presented issues with user agents downloading the attachments.

This patch handles the filename encoding for two special cases -- internet
explorer and safari, and provides the semi-standard RFC5987 method of
encoding the filename for the remaining browsers.

Attachments are no longer forced to be downloaded. It is up to the browser
to decide if the attachment should be shown in the browser or downloaded.

This patch also fixes a slight bug in the caching mechanism for downloads
concerning the last-modified time. The date sent to the browser was not
properly converted to GMT time, although the server claimed that it was.
Merge pull request #702 from greezybacon/issue/filename-commas

Handle attachment filenames better

Reviewed-By: Peter Rotich <peter@osticket.com>
Merge pull request #701 from greezybacon/issue/package-tips-html

Include setup/tips.html in download package

Reviewed-By: Peter Rotich <peter@osticket.com>
Define ROOT_PATH in chrooted environments too
Merge pull request #703 from greezybacon/issue/root-path

Define ROOT_PATH in chrooted environments too

Reviewed-By: Peter Rotich <peter@osticket.com>
Merge pull request #694 from greezybacon/issue/message-id-bugs

Fixup for the message-id tracking feature

Reviewed-By: Peter Rotich <peter@osticket.com>
Merge branch 'master' into develop