<?php
class SourceTransformingLoader extends php_user_filter
{
/**
* Php filter definition
*/
const PHP_FILTER_READ = 'php://filter/read=';
/**
* Default PHP filter name for registration
*/
const FILTER_IDENTIFIER = 'go.source.transforming.loader';
/**
* String buffer
*
* @var string
*/
protected $data = '';
/**
* Identifier of filter
*
* @var string
*/
protected static $filterId;
/**
* Register current loader as stream filter in PHP
*
* @param string $filterId Identifier for the filter
* @throws \RuntimeException If registration was failed
*/
public static function register($filterId = self::FILTER_IDENTIFIER)
{
if (!empty(self::$filterId)) {
throw new \RuntimeException('Stream filter already registered');
}
$result = stream_filter_register($filterId, __CLASS__);
if (!$result) {
throw new RuntimeException('Stream filter was not registered');
}
self::$filterId = $filterId;
}
/**
* {@inheritdoc}
*/
public function filter($in, $out, &$consumed, $closing)
{
while ($bucket = stream_bucket_make_writeable($in)) {
$this->data .= $bucket->data;
}
if ($closing || feof($this->stream)) {
$consumed = strlen($this->data);
$bucket = stream_bucket_new($this->stream, $this->data);
stream_bucket_append($out, $bucket);
return PSFS_PASS_ON;
}
return PSFS_FEED_ME;
}
}
SourceTransformingLoader::register();
echo file_get_contents('php://filter/read=go.source.transforming.loader/resource=' . __FILE__);
Output for 5.1.3 - 5.1.6, 5.2.0 - 5.2.17
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/bF4WL on line 39
<?php
class SourceTransformingLoader extends php_user_filter
{
/**
* Php filter definition
*/
const PHP_FILTER_READ = 'php://filter/read=';
/**
* Default PHP filter name for registration
*/
const FILTER_IDENTIFIER = 'go.source.transforming.loader';
/**
* String buffer
*
* @var string
*/
protected $data = '';
/**
* Identifier of filter
*
* @var string
*/
protected static $filterId;
/**
* Register current loader as stream filter in PHP
*
* @param string $filterId Identifier for the filter
* @throws \RuntimeException If registration was failed
*/
public static function register($filterId = self::FILTER_IDENTIFIER)
{
if (!empty(self::$filterId)) {
throw new \RuntimeException('Stream filter already registered');
}
$result = stream_filter_register($filterId, __CLASS__);
if (!$result) {
throw new RuntimeException('Stream filter was not registered');
}
self::$filterId = $filterId;
}
/**
* {@inheritdoc}
*/
public function filter($in, $out, &$consumed, $closing)
{
while ($bucket = stream_bucket_make_writeable($in)) {
$this->data .= $bucket->data;
}
if ($closing || feof($this->stream)) {
$consumed = strlen($this->data);
$bucket = stream_bucket_new($this->stream, $this->data);
stream_bucket_append($out, $bucket);
return PSFS_PASS_ON;
}
return PSFS_FEED_ME;
}
}
SourceTransformingLoader::register();
echo file_get_contents('php://filter/read=go.source.transforming.loader/resource=' . __FILE__);
Output for 5.1.2
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/bF4WL on line 39
FATAL: erealloc(): Unable to allocate 128217548 bytes
Process exited with code 1.
Output for 5.1.0 - 5.1.1
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/bF4WL on line 39
FATAL: erealloc(): Unable to allocate 132957908 bytes
Process exited with code 1.
Output for 5.0.5
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/bF4WL on line 39
FATAL: erealloc(): Unable to allocate 133243048 bytes
Process exited with code 1.
Output for 5.0.4
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/bF4WL on line 39
FATAL: erealloc(): Unable to allocate 124768744 bytes
Process exited with code 1.
Output for 5.0.3
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/bF4WL on line 39
FATAL: erealloc(): Unable to allocate 124880596 bytes
Process exited with code 1.
Output for 5.0.2
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/bF4WL on line 39
FATAL: erealloc(): Unable to allocate 124831444 bytes
Process exited with code 1.
Output for 5.0.1
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/bF4WL on line 39
FATAL: erealloc(): Unable to allocate 124826428 bytes
Process exited with code 1.
Output for 5.0.0
Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /in/bF4WL on line 39
FATAL: erealloc(): Unable to allocate 124866632 bytes
Process exited with code 1.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_CONST, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/bF4WL on line 8
Process exited with code 255.
Parse error: parse error, unexpected T_CONST, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/bF4WL on line 8
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/bF4WL on line 8
Process exited with code 255.