| 1 |
<?php |
| 2 |
|
| 3 |
namespace Safe; |
| 4 |
|
| 5 |
use Safe\Exceptions\OutcontrolException; |
| 6 |
|
| 7 |
/** |
| 8 |
* This function discards the contents of the topmost output buffer and turns |
| 9 |
* off this output buffering. If you want to further process the buffer's |
| 10 |
* contents you have to call ob_get_contents before |
| 11 |
* ob_end_clean as the buffer contents are discarded |
| 12 |
* when ob_end_clean is called. |
| 13 |
* |
| 14 |
* The output buffer must be started by |
| 15 |
* ob_start with PHP_OUTPUT_HANDLER_CLEANABLE |
| 16 |
* and PHP_OUTPUT_HANDLER_REMOVABLE |
| 17 |
* flags. Otherwise ob_end_clean will not work. |
| 18 |
* |
| 19 |
* @throws OutcontrolException |
| 20 |
* |
| 21 |
*/ |
| 22 |
function ob_end_clean(): void |
| 23 |
{ |
| 24 |
error_clear_last(); |
| 25 |
$result = \ob_end_clean(); |
| 26 |
if ($result === false) { |
| 27 |
throw OutcontrolException::createFromPhpError(); |
| 28 |
} |
| 29 |
} |
| 30 |
|
| 31 |
|
| 32 |
/** |
| 33 |
* This function will send the contents of the topmost output buffer (if |
| 34 |
* any) and turn this output buffer off. If you want to further |
| 35 |
* process the buffer's contents you have to call |
| 36 |
* ob_get_contents before |
| 37 |
* ob_end_flush as the buffer contents are |
| 38 |
* discarded after ob_end_flush is called. |
| 39 |
* |
| 40 |
* The output buffer must be started by |
| 41 |
* ob_start with PHP_OUTPUT_HANDLER_FLUSHABLE |
| 42 |
* and PHP_OUTPUT_HANDLER_REMOVABLE |
| 43 |
* flags. Otherwise ob_end_flush will not work. |
| 44 |
* |
| 45 |
* @throws OutcontrolException |
| 46 |
* |
| 47 |
*/ |
| 48 |
function ob_end_flush(): void |
| 49 |
{ |
| 50 |
error_clear_last(); |
| 51 |
$result = \ob_end_flush(); |
| 52 |
if ($result === false) { |
| 53 |
throw OutcontrolException::createFromPhpError(); |
| 54 |
} |
| 55 |
} |
| 56 |
|
| 57 |
|
| 58 |
/** |
| 59 |
* This function adds another name/value pair to the URL rewrite mechanism. |
| 60 |
* The name and value will be added to URLs (as GET parameter) and forms |
| 61 |
* (as hidden input fields) the same way as the session ID when transparent |
| 62 |
* URL rewriting is enabled with session.use_trans_sid. |
| 63 |
* |
| 64 |
* This function's behaviour is controlled by the url_rewriter.tags and |
| 65 |
* url_rewriter.hosts php.ini |
| 66 |
* parameters. |
| 67 |
* |
| 68 |
* Note that this function can be successfully called at most once per request. |
| 69 |
* |
| 70 |
* @param string $name The variable name. |
| 71 |
* @param string $value The variable value. |
| 72 |
* @throws OutcontrolException |
| 73 |
* |
| 74 |
*/ |
| 75 |
function output_add_rewrite_var(string $name, string $value): void |
| 76 |
{ |
| 77 |
error_clear_last(); |
| 78 |
$result = \output_add_rewrite_var($name, $value); |
| 79 |
if ($result === false) { |
| 80 |
throw OutcontrolException::createFromPhpError(); |
| 81 |
} |
| 82 |
} |
| 83 |
|
| 84 |
|
| 85 |
/** |
| 86 |
* This function resets the URL rewriter and removes all rewrite |
| 87 |
* variables previously set by the output_add_rewrite_var |
| 88 |
* function. |
| 89 |
* |
| 90 |
* @throws OutcontrolException |
| 91 |
* |
| 92 |
*/ |
| 93 |
function output_reset_rewrite_vars(): void |
| 94 |
{ |
| 95 |
error_clear_last(); |
| 96 |
$result = \output_reset_rewrite_vars(); |
| 97 |
if ($result === false) { |
| 98 |
throw OutcontrolException::createFromPhpError(); |
| 99 |
} |
| 100 |
} |
| 101 |
|