Fix up ROOT_PATH, yet again

The previous implementation did not work correctly for symlinked folders.
The new approach uses debug_backtrace() and ROOT_DIR to determine the
difference between ROOT_DIR and the osTicket installation path.

This thing is like a turd that won't flush
Fixes cookie domain specification

if the domain given in HTTP_HOST variable happens to have a port
specification. Technically, the port specification should not be included in
the domain spec given in the cookie.

(And for the record, that makes no sense to me, seeing as a cookie would
otherwise be valid for all servers on any ports at a particular domain).
Avoid double-encoding thread titles

This is safe now, because the title is appropriately encoded in
class.thread.php/ThreadEntry::create()

Fixes #567, #718
Fixes ROOT_PATH detection on Windows

Also converts ROOT_DIR detection to always use forward slashes. And it fixes
the removal of the leading double-backslash on Windows UNC names (fixes #649)
Merge pull request #719 from greezybacon/issue/cookie-variant-port

Fixes cookie domain specification

Reviewed-By: Peter Rotich <peter@osticket.com>
Merge pull request #720 from greezybacon/issue/thread-title-encoding

Avoid double-encoding thread titles

Reviewed-By: Peter Rotich <peter@osticket.com>
Merge pull request #726 from greezybacon/issue/windows-root-path

Fix ROOT_PATH detection on Windows

Reviewed-By: Peter Rotich <peter@osticket.com>
Show correct description for template edits
Merge pull request #727 from greezybacon/issue/tpl-description

Show correct description for template edits

Reviewed-By:  Peter Rotich <peter@osticket.com>
Fix bug detecting emails from system email addresses
Merge pull request #730 from greezybacon/issue/thread-email-oops

Fix bug detecting emails from system email addresses

Reviewed-With: Peter Rotich <peter@osticket.com>
Fix email address comparison issue

When comparing the From address of incoming email. If the ticket owner sent
an email back into the system and the email address did not match exactly,
case-wise, the email would not be considered from the ticket owner.
Merge pull request #731 from greezybacon/issue/thread-owner-email

Fix email address comparison issue

Reviewed-By: Peter Rotich <peter@osticket.com>
Last mile for test failures

Add stubs.php to include stub classes for built-in PHP classes used
throughout the code. This will allow the testing suite to verify that a
method exists, albeit not in our codebase
Merge pull request #732 from greezybacon/feature/test-pass

Last mile for test failures

Reviewed-By: Peter Rotich <peter@osticket.com>
Fix 1.6-* upgrade to 1.7.1

8e72e521d48ca04fd8db7d05318e2c55b9b2d278 (v1.7.1.2+) introduced a bug where
osTicket version 1.6 would not send a cookie (by calling PHP
session_start()) for the login page. Therefore, after unpacking the 1.7.1
source code, an upgrade would not be possible, because a login would never
be processed correctly.
Merge pull request #736 from greezybacon/issue/1.6-upgrade

Fix 1.6-* upgrade to 1.7.1

Reviewed-By: Peter Rotich <peter@osticket.com>
Detect attachments with Content-Type: ...; name=

RFC2045, section 5.1 seems to indicate that arbitrary parameters can be
appended to a Content-Type header specification. Some email clients seem to
use the Content-Type header to specify an attachment without giving a
separate Content-Disposition header normally used to signify attachments.

This patch corrects attachment detection for piped emails to detect such
emails. The patch also correctly decodes filenames specified either in the
Content-Disposition or Content-Type headers using RFC5987, where the
filename can be encoded using an arbitrary character set (ie, not us-ascii).
Merge pull request #737 from greezybacon/issue/mailparse-attachments

Detect attachments with Content-Type: ...; name=

Reviewed-With: Jared Hancock <jared@osticket.com>
Implement RFC5987 for fetched attachments

Previously, filenames specified in email headers fetched using the PHP imap
extension were not decoded properly. Specifically, if RFC5987 was used to
encode the filenames, no decoding was performed at all.

This patch properly detects the filename attribute, using a decoding scheme
for RFC5987 if the attribute was encoded properly.

References:
http://osticket.com/forums/showthread.php?t=6129