Fix parsing of attachments

If the body is declared with inline disposition and no filename, the parser
engine would create an incorrect attachments list.
Use base64 encoding for text version of emails

Some mail clients and mail brokers do not properly handle quoted-printable
encoding, used in osTicket outgoing emails. Oddly, the end mail clients
render the email with trailing equal signs (=) at the end of every line,
where it was added due to QP encoding.

References:
http://www.osticket.com/forums/forum/osticket-1-7-latest-release/troubleshooting-and-problems-aa/10708-solved-microsoft-exchange-internet-mail-lines-end-with
RFC 2045 section 6.7, http://www.ietf.org/rfc/rfc2045.txt
Die with internal server error on misconfiguration

Or internal server (database) outage
Crazy performance penalty scanning blob tables

When scanning the file_chunk table for orphaned file chunks that can be
deleted, apparently, MySQL will read (at least part of) the blob data from
the disk. For databases with lots of large attachments, this can take
considerable time. Considering that it is triggered from the autocron and
will run everytime the cron is run, the database will spend considerable
time scanning for rows to be cleaned.

This patch changes the orphan cleanup into two phases. The first will search
just for the pk's of file chunks to be deleted. If any are found, then the
chunks are deleted by the file_id and chunk_id, which is the primary key of
the table.

The SELECT query seems to run at least 20 times faster than the delete
statement, and DELETEing against the primary key of the blob table should
be the fastest possible operation. Somehow, both queries required a full
table scan; however, because the SELECT statement is explictly only
interested in two fields, it is more clear to the query optimizer that the
blob data should not be scanned.

References:
http://stackoverflow.com/q/9511476
Better converting from ticket thread to PDF

Assume that text in the database is encoded in UTF-8 and assume that it is
HTML text and the entities should be decoded prior to display in the PDF.

Fixes #756
Merge pull request #760 from greezybacon/issue/mail-client-qp

Use base64 encoding for text version of emails

Reviewed-By: Peter Rotich <peter@osticket.com>
Merge pull request #761 from greezybacon/issue/inline-email-body

Fix parsing of attachments

Reviewed-By: Peter Rotich <peter@osticket.com>
Merge pull request #762 from greezybacon/issue/die-with-500

Die with internal server error on misconfiguration

Reviewed-By: Peter Rotich <peter@osticket.com>
Merge pull request #765 from greezybacon/issue/htmlchars-in-pdf

Better converting from ticket thread to PDF

Reviewed-By: Peter Rotich <peter@osticket.com>
Merge pull request #764 from greezybacon/issue/very-slow-deletes

Crazy performance penalty scanning blob tables

Reviewed-By: Peter Rotich <peter@osticket.com>
Change PDF print to show custom logo

If the GD extension is not available for the PHP installation, then use a
copy of the default client-site logo with the alpha channel removed.
Merge pull request #763 from greezybacon/issue/pdf-logo

Change PDF print to show custom logo

Reviewed-By: Peter Rotich <peter@osticket.com>
Bugfix: Wrong function name