Re: HALT Patch
| From: | Ilia Alshanetsky | Date: | Fri, 11 Mar 2005 22:05:48 +0000 |
| Subject: | Re: HALT Patch | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-15385@lists.php.net to get a copy of this message | ||
Wez Furlong wrote:
> If you name the token __HALT_PHP_PARSER__ instead (or something
> equally unlikely to be used by accident and unambiguous in meaning),
> you'll get a +1 from me :-)
I aim to please ;-) Here is the revised patch that makes the token a bit
clearer and also increases the strictness of the parser. For those of
you wondering how would you quickly locate the end of script and start
of data here are some solutions:
1) while (fgets($fp) != '<?php __HALT_PHP_PARSER__; ?>'));
2) Assuming the author knows the maximum length of the actual code, they
could read X bytes and then using strpos locate the position of the HALT
token and start reading data dump from there.
$fp = fopen(__FILE__, "r");
$halt_token = "<?php "."__HALT_PHP_PARSER__"."; ?>";
$pos = strpos(fread($fp, 10000), $halt_token);
fseek($fp, $pos + strlen($halt_token));
Ilia