source: trunk/zpush/lib/utils/compat.php @ 7589

Revision 7589, 3.5 KB checked in by douglas, 11 years ago (diff)

Ticket #3209 - Integrar módulo de sincronização Z-push ao Expresso

Line 
1<?php
2/***********************************************
3* File      :   compat.php
4* Project   :   Z-Push
5* Descr     :   Help function for files
6*
7* Created   :   01.10.2007
8*
9* Copyright 2007 - 2012 Zarafa Deutschland GmbH
10*
11* This program is free software: you can redistribute it and/or modify
12* it under the terms of the GNU Affero General Public License, version 3,
13* as published by the Free Software Foundation with the following additional
14* term according to sec. 7:
15*
16* According to sec. 7 of the GNU Affero General Public License, version 3,
17* the terms of the AGPL are supplemented with the following terms:
18*
19* "Zarafa" is a registered trademark of Zarafa B.V.
20* "Z-Push" is a registered trademark of Zarafa Deutschland GmbH
21* The licensing of the Program under the AGPL does not imply a trademark license.
22* Therefore any rights, title and interest in our trademarks remain entirely with us.
23*
24* However, if you propagate an unmodified version of the Program you are
25* allowed to use the term "Z-Push" to indicate that you distribute the Program.
26* Furthermore you may use our trademarks where it is necessary to indicate
27* the intended purpose of a product or service provided you use it in accordance
28* with honest practices in industrial or commercial matters.
29* If you want to propagate modified versions of the Program under the name "Z-Push",
30* you may only do so if you have a written permission by Zarafa Deutschland GmbH
31* (to acquire a permission please contact Zarafa at trademark@zarafa.com).
32*
33* This program is distributed in the hope that it will be useful,
34* but WITHOUT ANY WARRANTY; without even the implied warranty of
35* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
36* GNU Affero General Public License for more details.
37*
38* You should have received a copy of the GNU Affero General Public License
39* along with this program.  If not, see <http://www.gnu.org/licenses/>.
40*
41* Consult LICENSE file for details
42************************************************/
43
44if (!function_exists("quoted_printable_encode")) {
45    /**
46     * Process a string to fit the requirements of RFC2045 section 6.7. Note that
47     * this works, but replaces more characters than the minimum set. For readability
48     * the spaces and CRLF pairs aren't encoded though.
49     *
50     * @param string    $string     string to be encoded
51     *
52     * @see http://www.php.net/manual/en/function.quoted-printable-decode.php#89417
53     */
54    function quoted_printable_encode($string) {
55        return preg_replace('/[^\r\n]{73}[^=\r\n]{2}/', "$0=\n", str_replace(array('%20', '%0D%0A', '%'), array(' ', "\r\n", '='), rawurlencode($string)));
56    }
57}
58
59if (!function_exists("apache_request_headers")) {
60    /**
61      * When using other webservers or using php as cgi in apache
62      * the function apache_request_headers() is not available.
63      * This function parses the environment variables to extract
64      * the necessary headers for Z-Push
65      */
66    function apache_request_headers() {
67        $headers = array();
68        foreach ($_SERVER as $key => $value)
69            if (substr($key, 0, 5) == 'HTTP_')
70                $headers[strtr(substr($key, 5), '_', '-')] = $value;
71
72        return $headers;
73    }
74}
75
76if (!function_exists("hex2bin")) {
77    /**
78     * Complementary function to bin2hex() which converts a hex entryid to a binary entryid.
79     * Since PHP 5.4 an internal hex2bin() implementation is available.
80     *
81     * @param string    $data   the hexadecimal string
82     *
83     * @returns string
84     */
85    function hex2bin($data) {
86        return pack("H*", $data);
87    }
88}
89?>
Note: See TracBrowser for help on using the repository browser.