~olivier-chatelain/php-addressbook/trunk

« back to all changes in this revision

Viewing changes to z-push/lib/utils/compat.php

  • Committer: chatelao
  • Date: 2016-09-11 07:59:37 UTC
  • Revision ID: git-v1:03926e44d99a04a3b05d4761e322a1f5e8a405d7
Chg: Upgrade z-push from 2.0.3 to 2.2.12 (stable)

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
*
7
7
* Created   :   01.10.2007
8
8
*
9
 
* Copyright 2007 - 2012 Zarafa Deutschland GmbH
 
9
* Copyright 2007 - 2013 Zarafa Deutschland GmbH
10
10
*
11
11
* This program is free software: you can redistribute it and/or modify
12
12
* it under the terms of the GNU Affero General Public License, version 3,
84
84
    function apache_request_headers() {
85
85
        $header = array();
86
86
        
 
87
        foreach ($_SERVER as $key => $value)
 
88
            if (substr($key, 0, 5) == 'HTTP_')
 
89
                $headers[strtr(substr($key, 5), '_', '-')] = $value;
 
90
 
87
91
        if(isset($_SERVER['HTTP_MS_ASPROTOCOLVERSION'])) {
88
92
          $header['Ms-Asprotocolversion'] = $_SERVER['HTTP_MS_ASPROTOCOLVERSION'];
89
93
        }
118
122
    //*/
119
123
}
120
124
 
121
 
 
122
125
if (!function_exists("hex2bin")) {
123
126
    /**
124
127
     * Complementary function to bin2hex() which converts a hex entryid to a binary entryid.
132
135
        return pack("H*", $data);
133
136
    }
134
137
}
 
138
 
 
139
if (!function_exists('http_response_code')) {
 
140
    /**
 
141
     * http_response_code does not exists in PHP < 5.4
 
142
     * http://php.net/manual/en/function.http-response-code.php
 
143
     */
 
144
    function http_response_code($code = NULL) {
 
145
        if ($code !== NULL) {
 
146
            switch ($code) {
 
147
                case 100: $text = 'Continue'; break;
 
148
                case 101: $text = 'Switching Protocols'; break;
 
149
                case 200: $text = 'OK'; break;
 
150
                case 201: $text = 'Created'; break;
 
151
                case 202: $text = 'Accepted'; break;
 
152
                case 203: $text = 'Non-Authoritative Information'; break;
 
153
                case 204: $text = 'No Content'; break;
 
154
                case 205: $text = 'Reset Content'; break;
 
155
                case 206: $text = 'Partial Content'; break;
 
156
                case 300: $text = 'Multiple Choices'; break;
 
157
                case 301: $text = 'Moved Permanently'; break;
 
158
                case 302: $text = 'Moved Temporarily'; break;
 
159
                case 303: $text = 'See Other'; break;
 
160
                case 304: $text = 'Not Modified'; break;
 
161
                case 305: $text = 'Use Proxy'; break;
 
162
                case 400: $text = 'Bad Request'; break;
 
163
                case 401: $text = 'Unauthorized'; break;
 
164
                case 402: $text = 'Payment Required'; break;
 
165
                case 403: $text = 'Forbidden'; break;
 
166
                case 404: $text = 'Not Found'; break;
 
167
                case 405: $text = 'Method Not Allowed'; break;
 
168
                case 406: $text = 'Not Acceptable'; break;
 
169
                case 407: $text = 'Proxy Authentication Required'; break;
 
170
                case 408: $text = 'Request Time-out'; break;
 
171
                case 409: $text = 'Conflict'; break;
 
172
                case 410: $text = 'Gone'; break;
 
173
                case 411: $text = 'Length Required'; break;
 
174
                case 412: $text = 'Precondition Failed'; break;
 
175
                case 413: $text = 'Request Entity Too Large'; break;
 
176
                case 414: $text = 'Request-URI Too Large'; break;
 
177
                case 415: $text = 'Unsupported Media Type'; break;
 
178
                case 500: $text = 'Internal Server Error'; break;
 
179
                case 501: $text = 'Not Implemented'; break;
 
180
                case 502: $text = 'Bad Gateway'; break;
 
181
                case 503: $text = 'Service Unavailable'; break;
 
182
                case 504: $text = 'Gateway Time-out'; break;
 
183
                case 505: $text = 'HTTP Version not supported'; break;
 
184
                default:
 
185
                    exit('Unknown http status code "' . htmlentities($code) . '"');
 
186
                    break;
 
187
            }
 
188
 
 
189
            $protocol = (isset($_SERVER['SERVER_PROTOCOL']) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0');
 
190
            header($protocol . ' ' . $code . ' ' . $text);
 
191
 
 
192
            $GLOBALS['http_response_code'] = $code;
 
193
        } else {
 
194
            $code = (isset($GLOBALS['http_response_code']) ? $GLOBALS['http_response_code'] : 200);
 
195
        }
 
196
 
 
197
        return $code;
 
198
    }
 
199
}
 
200
 
 
201
if (!function_exists('memory_get_peak_usage')) {
 
202
    /**
 
203
     * memory_get_peak_usage is not available prior to PHP 5.2.
 
204
     * This complementary function will return the value of memory_get_usage();
 
205
     * @see http://php.net/manual/en/function.memory-get-usage.php
 
206
     * @see http://php.net/manual/en/function.memory-get-peak-usage.php
 
207
     *
 
208
     * @param boolean $real_usage
 
209
     */
 
210
    function memory_get_peak_usage($real_usage = false) {
 
211
        ZLog::Write(LOGLEVEL_DEBUG, "memory_get_peak_usage() is not available on this system. The value of memory_get_usage() will be used.");
 
212
        return memory_get_usage();
 
213
    }
 
214
 
 
215
}
 
216
 
135
217
?>
 
 
b'\\ No newline at end of file'