Honor ticket number in subject line without brackets

We introduced a glitch in 29b3714, which was the patch that introduced
matching on email headers other than the Subject.

I misinterpreted the original `preg_match()` regex, thinking that it was
requiring brackets. Looking at it again today, I see that it didn't. The
current one does, however, require surrounding brackets.

This patch also allows for extra letters or dashes between the `#` and the
ticket number. Eventually we should allow the ticket number itself to have
extra characters -- be formattable.

Fixes osTicket/osTicket-1.8#342
Merge pull request #873 from greezybacon/issue/subject-ticket-number

Honor ticket number in subject line without brackets

Reviewed-By: Peter Rotich <peter@osticket.com>
http: Legacy versions of IIS redirect incorrectly

(And newer versions don't seem to like the legacy code). This patch uses a
`Refresh` header for IIS versions prior to 7.0 (included with Windows Vista
/ Server 2008). Starting with IIS 7.0, the Location header should be
properly handled by IIS.
Merge pull request #874 from greezybacon/issue/iis-refresh

http: Legacy versions of IIS redirect incorrectly

Reviewed-By: Peter Rotich <peter@osticket.com>
Fix ticket queue counts for limited users
Use case-insensitive matching on email address

This patch addresses an issue where a client may have upper-case letters in
their email address. When visiting the client portal to check the ticket
status, previously, the exact same case would be required in the 'Email
Address' box.

This patch remove the case sensitivity for email logins.
Fix subject ticket number matcher (again)
Merge pull request #876 from greezybacon/issue/875

Use case-insensitive matching on email address

Reviewed-By: Peter Rotich <peter@osticket.com>
Merge pull request #877 from greezybacon/issue/subject-ticket-number

Fix subject ticket number matcher (again)

Reviewed-By: Peter Rotich <peter@osticket.com>
Adds missing argument for Ticket::lookup for ajax.

Couldn't find the rebase to this.. actually, I didn't look, I'm still struggling with git and eclipse, would probably have been easier with vim! Anyway, rewrote changes for 1.7.
Update ajax.tickets.php

Missed one.. :-(
mysql: Retire old mysql constants

Required for PHP 5.5 compatibility
Merge pull request #878 from greezybacon/issue/ticket-lock-lookup

Fix parameter count to TicketLock::lookup

Reviewed-By: Peter Rotich <peter@osticket.com>
mysqli: Retry on deadlock-found error

If MySQL error #1213 (deadlock found when trying to get lock) is returned
from query, it is safe to retry the query.

This patch will retry queries up to two times for a total of three. If the
query cannot be executed without error #1213 after the third time, the error
is logged as usual, and the system continues with the failed query.
Use case-insensitive matching on email address

This patch addresses an issue where a client may have upper-case letters in
their email address. When visiting the client portal to check the ticket
status, previously, the exact same case would be required in the 'Email
Address' box.

This patch removes the case sensitivity for email logins.
Timeout after max timeout while fetching emails

Processing fetching in ASC order of the last fetch time
Remove LIMIT of 10 emails per fetch
Flush the buffer and terminate the request cleanly on autocron
i18n: Remove unused, possibly incorrect formatting

These functions don't appear to be used an could corrupt UTF-8 encoded text
htmLawed: Fix corruption to UTF8 encoded text

On some combinations of operating systems, PHP and libpcre versions, `\s`
will match the iso-8859-x non-breaking-space, 0xa0. This regular expression
will munge the UTF8 encoded version, 0xc2a0 to 0xc220, which is not a valid
UTF8 character.

When inserted into a UTF8 field in mysql, the text will be truncated at and
after the first invalid character.
Send staff alerts as Notice as opposed to AutoRely

Some emails providers (e.g gmail/google) won't deliver emails marked
bulk/autoreply to group email address.
oops: Fix report time frame interpretation