| 1 | <? |
|---|
| 2 | /* |
|---|
| 3 | * licqweb. Copyright 2005, Philip Nelson |
|---|
| 4 | * |
|---|
| 5 | * This file is part of licqweb. |
|---|
| 6 | * |
|---|
| 7 | * licqweb is free software; you can redistribute it and/or modify |
|---|
| 8 | * it under the terms of the GNU General Public License as published by |
|---|
| 9 | * the Free Software Foundation; either version 2 of the License, or |
|---|
| 10 | * (at your option) any later version. |
|---|
| 11 | * |
|---|
| 12 | * licqweb is distributed in the hope that it will be useful, |
|---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 15 | * GNU General Public License for more details. |
|---|
| 16 | * |
|---|
| 17 | * You should have received a copy of the GNU General Public License |
|---|
| 18 | * along with licqweb; if not, write to the Free Software |
|---|
| 19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
|---|
| 20 | */ |
|---|
| 21 | $boundary = md5(uniqid(time())); |
|---|
| 22 | |
|---|
| 23 | function http_push_end() { |
|---|
| 24 | global $boundary; |
|---|
| 25 | echo "--$boundary--\r\n"; |
|---|
| 26 | } |
|---|
| 27 | |
|---|
| 28 | function http_push_start($time_limit = 0) { |
|---|
| 29 | global $boundary; |
|---|
| 30 | $contentType = "multipart/x-mixed-replace; boundary=$boundary"; |
|---|
| 31 | header("Content-type: $contentType"); |
|---|
| 32 | ob_implicit_flush(); |
|---|
| 33 | set_time_limit($time_limit); |
|---|
| 34 | register_shutdown_function('http_push_end'); |
|---|
| 35 | } |
|---|
| 36 | |
|---|
| 37 | function push(&$content, $contentType = 'text/xml') { |
|---|
| 38 | global $boundary; |
|---|
| 39 | static $is_first = true; |
|---|
| 40 | if ($is_first) { |
|---|
| 41 | echo "--$boundary\r\n"; |
|---|
| 42 | } |
|---|
| 43 | echo "Content-type: $contentType\r\n\r\n"; |
|---|
| 44 | echo "$content\r\n"; |
|---|
| 45 | echo "--$boundary\r\n"; |
|---|
| 46 | $is_first = false; |
|---|
| 47 | } |
|---|
| 48 | ?> |
|---|