public function test_register_filter()
 {
     ConvertMbstringEncoding::register();
     $filterName = ConvertMbstringEncoding::getFilterName();
     $registeredFilters = stream_get_filters();
     $this->assertTrue(in_array($filterName, $registeredFilters));
 }
 /**
  * Setup method. Ensure filter we depend on is available
  *
  * @return void
  */
 public function setUp()
 {
     $depend = $this->filter();
     if (!in_array($depend, stream_get_filters())) {
         throw new PrerequisitesNotMetError(ucfirst($depend) . ' stream filter not available', null, [$depend]);
     }
 }
 public function setUp()
 {
     // register filter
     $filters = stream_get_filters();
     if (!in_array('crypto.filter', $filters)) {
         stream_filter_register('crypto.filter', 'Fruit\\CryptoKit\\CryptoFilter');
     }
 }
 /**
  * Register the stream filter
  *
  * @return bool
  */
 public static function register()
 {
     $result = false;
     $name = self::getName();
     if (!empty($name) && !in_array($name, stream_get_filters())) {
         $result = stream_filter_register(self::getName(), get_called_class());
     }
     return $result;
 }
 protected function renderWithContext()
 {
     if (!in_array("displayObjectRenderer", stream_get_filters())) {
         stream_filter_register("displayObjectRenderer", "DisplayObjectRenderer");
     }
     $pointer = fopen($this->url, "r");
     if ($this->context) {
         stream_filter_append($pointer, "displayObjectRenderer", STREAM_FILTER_READ, $this->context);
     } else {
         stream_filter_append($pointer, "displayObjectRenderer", STREAM_FILTER_READ);
     }
     return stream_get_contents($pointer);
 }
Beispiel #6
0
 public static function renderDisplayObjectWithUri($uri, &$dictionary = null)
 {
     if (!in_array("displayObjectRenderer_mustache", stream_get_filters())) {
         stream_filter_register("displayObjectRenderer_mustache", "AMMustacheRenderer");
     }
     if (file_exists($uri)) {
         $pointer = fopen($uri, "r");
         stream_filter_append($pointer, "displayObjectRenderer_mustache", STREAM_FILTER_READ);
         return stream_get_contents($pointer);
     } else {
         trigger_error('AMMustache unable to open file ' . $uri, E_USER_ERROR);
     }
 }
Beispiel #7
0
 public static function renderDisplayObjectWithURLAndDictionary($url, &$dictionary = null)
 {
     static $suffix;
     // = 1;
     if (!in_array("displayObjectRenderer_{$suffix}", stream_get_filters())) {
         stream_filter_register("displayObjectRenderer_{$suffix}", "DisplayObjectRenderer");
     }
     $pointer = fopen($url, "r");
     if ($dictionary) {
         stream_filter_append($pointer, "displayObjectRenderer_{$suffix}", STREAM_FILTER_READ, $dictionary);
     } else {
         stream_filter_append($pointer, "displayObjectRenderer_{$suffix}", STREAM_FILTER_READ);
     }
     //$suffix++;
     return stream_get_contents($pointer);
 }
Beispiel #8
0
 public function testHandlesCompression()
 {
     $body = EntityBody::factory('testing 123...testing 123');
     $this->assertFalse($body->getContentEncoding(), '-> getContentEncoding() must initially return FALSE');
     $size = $body->getContentLength();
     $body->compress();
     $this->assertEquals('gzip', $body->getContentEncoding(), '-> getContentEncoding() must return the correct encoding after compressing');
     $this->assertEquals(gzdeflate('testing 123...testing 123'), (string) $body);
     $this->assertTrue($body->getContentLength() < $size);
     $this->assertTrue($body->uncompress());
     $this->assertEquals('testing 123...testing 123', (string) $body);
     $this->assertFalse($body->getContentEncoding(), '-> getContentEncoding() must reset to FALSE');
     if (in_array('bzip2.*', stream_get_filters())) {
         $this->assertTrue($body->compress('bzip2.compress'));
         $this->assertEquals('compress', $body->getContentEncoding(), '-> compress() must set \'compress\' as the Content-Encoding');
     }
     $this->assertFalse($body->compress('non-existent'), '-> compress() must return false when a non-existent stream filter is used');
     // Release the body
     unset($body);
     // Use gzip compression on the initial content.  This will include a
     // gzip header which will need to be stripped when deflating the stream
     $body = EntityBody::factory(gzencode('test'));
     $this->assertSame($body, $body->setStreamFilterContentEncoding('zlib.deflate'));
     $this->assertTrue($body->uncompress('zlib.inflate'));
     $this->assertEquals('test', (string) $body);
     unset($body);
     // Test using a very long string
     $largeString = '';
     for ($i = 0; $i < 25000; $i++) {
         $largeString .= chr(rand(33, 126));
     }
     $body = EntityBody::factory($largeString);
     $this->assertEquals($largeString, (string) $body);
     $this->assertTrue($body->compress());
     $this->assertNotEquals($largeString, (string) $body);
     $compressed = (string) $body;
     $this->assertTrue($body->uncompress());
     $this->assertEquals($largeString, (string) $body);
     $this->assertEquals($compressed, gzdeflate($largeString));
     $body = EntityBody::factory(fopen(__DIR__ . '/../TestData/compress_test', 'w'));
     $this->assertFalse($body->compress());
     unset($body);
     unlink(__DIR__ . '/../TestData/compress_test');
 }
Beispiel #9
0
 function streams()
 {
     $sw = stream_get_wrappers();
     $sf = stream_get_filters();
     /*
     Console::writeLn("Stream Management");
     Console::writeLn(" |- Registered wrappers");
     for($n=0; $n<count($sw); $n++) {
         $this->treenode( $sw[$n] , !(($n+1)<count($sw)), false );
     }
     
     Console::writeLn(" '- Registered filters");
     for($n=0; $n<count($sf); $n++) {
         $this->treenode( $sf[$n] , !(($n+1)<count($sf)), true );
     }
     */
     $cb = 0;
     Console::writeLn(__astr("\\b{Registered Wrappers:}"));
     sort($sw);
     foreach ($sw as $val) {
         Console::write('  %-18s', $val);
         $cb++;
         if ($cb > 3 && $val != end($sw)) {
             Console::writeLn();
             $cb = 0;
         }
     }
     Console::writeLn();
     Console::writeLn();
     $cb = 0;
     Console::writeLn(__astr("\\b{Registered Filters:}"));
     sort($sf);
     foreach ($sf as $val) {
         Console::write('  %-18s', $val);
         $cb++;
         if ($cb > 3 && $val != end($sf)) {
             Console::writeLn();
             $cb = 0;
         }
     }
     Console::writeLn();
     Console::writeLn();
 }
Beispiel #10
0
function putfile($host, $port, $url, $referer, $cookie, $file, $filename, $proxy = 0, $pauth = 0, $upagent = 0, $scheme = 'http')
{
    global $nn, $lastError, $fp, $fs;
    if (empty($upagent)) {
        $upagent = rl_UserAgent;
    }
    $scheme = strtolower("{$scheme}://");
    if (!is_readable($file)) {
        $lastError = sprintf(lang(65), $file);
        return FALSE;
    }
    $fileSize = getSize($file);
    if (!empty($cookie)) {
        if (is_array($cookie)) {
            $cookies = count($cookie) > 0 ? CookiesToStr($cookie) : 0;
        } else {
            $cookies = trim($cookie);
        }
    }
    if ($scheme == 'https://') {
        if (!extension_loaded('openssl')) {
            html_error('You need to install/enable PHP\'s OpenSSL extension to support uploading via HTTPS.');
        }
        $scheme = 'tls://';
        if ($port == 0 || $port == 80) {
            $port = 443;
        }
    }
    if (!empty($referer) && ($pos = strpos("\r\n", $referer)) !== 0) {
        $origin = parse_url($pos ? substr($referer, 0, $pos) : $referer);
        $origin = strtolower($origin['scheme']) . '://' . strtolower($origin['host']) . (!empty($origin['port']) && $origin['port'] != defport(array('scheme' => $origin['scheme'])) ? ':' . $origin['port'] : '');
    } else {
        $origin = ($scheme == 'tls://' ? 'https://' : $scheme) . $host . ($port != 80 && ($scheme != 'tls://' || $port != 443) ? ':' . $port : '');
    }
    if ($proxy) {
        list($proxyHost, $proxyPort) = explode(':', $proxy, 2);
        $host = $host . ($port != 80 && ($scheme != 'tls://' || $port != 443) ? ':' . $port : '');
        $url = "{$scheme}{$host}{$url}";
    }
    if ($scheme != 'tls://') {
        $scheme = '';
    }
    $request = array();
    $request[] = 'PUT ' . str_replace(' ', '%20', $url) . ' HTTP/1.1';
    $request[] = "Host: {$host}";
    $request[] = "User-Agent: {$upagent}";
    $request[] = 'Accept: text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/webp, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1';
    $request[] = 'Accept-Language: en-US,en;q=0.9';
    $request[] = 'Accept-Charset: utf-8,windows-1251;q=0.7,*;q=0.7';
    if (!empty($referer)) {
        $request[] = "Referer: {$referer}";
    }
    if (!empty($cookies)) {
        $request[] = "Cookie: {$cookies}";
    }
    if (!empty($pauth)) {
        $request[] = "Proxy-Authorization: Basic {$pauth}";
    }
    $request[] = "X-File-Name: {$filename}";
    $request[] = "X-File-Size: {$fileSize}";
    $request[] = "Origin: {$origin}";
    $request[] = 'Content-Disposition: attachment';
    $request[] = 'Content-Type: multipart/form-data';
    $request[] = "Content-Length: {$fileSize}";
    $request[] = 'Connection: Close';
    $request = implode($nn, $request) . $nn . $nn;
    $errno = 0;
    $errstr = '';
    $hosts = (!empty($proxyHost) ? $scheme . $proxyHost : $scheme . $host) . ':' . (!empty($proxyPort) ? $proxyPort : $port);
    $fp = @stream_socket_client($hosts, $errno, $errstr, 120, STREAM_CLIENT_CONNECT);
    if (!$fp) {
        if (!function_exists('stream_socket_client')) {
            html_error('[ERROR] stream_socket_client() is disabled.');
        }
        $dis_host = !empty($proxyHost) ? $proxyHost : $host;
        $dis_port = !empty($proxyPort) ? $proxyPort : $port;
        html_error(sprintf(lang(88), $dis_host, $dis_port));
    }
    if ($errno || $errstr) {
        $lastError = $errstr;
        return false;
    }
    if ($proxy) {
        echo '<p>' . sprintf(lang(89), $proxyHost, $proxyPort) . '<br />PUT: <b>' . htmlspecialchars($url) . "</b>...<br />\n";
    } else {
        echo '<p>' . sprintf(lang(90), $host, $port) . '</p>';
    }
    echo lang(104) . ' <b>' . htmlspecialchars($filename) . '</b>, ' . lang(56) . ' <b>' . bytesToKbOrMbOrGb($fileSize) . '</b>...<br />';
    $GLOBALS['id'] = md5(time() * rand(0, 10));
    require TEMPLATE_DIR . '/uploadui.php';
    flush();
    $timeStart = microtime(true);
    $chunkSize = GetChunkSize($fileSize);
    fwrite($fp, $request);
    fflush($fp);
    $fs = fopen($file, 'r');
    $totalsend = $time = $lastChunkTime = 0;
    while (!feof($fs) && !$errno && !$errstr) {
        $data = fread($fs, $chunkSize);
        if ($data === false) {
            fclose($fs);
            fclose($fp);
            html_error(lang(112));
        }
        $sendbyte = @fwrite($fp, $data);
        fflush($fp);
        if ($sendbyte === false || strlen($data) > $sendbyte) {
            fclose($fs);
            fclose($fp);
            html_error(lang(113));
        }
        $totalsend += $sendbyte;
        $time = microtime(true) - $timeStart;
        $chunkTime = $time - $lastChunkTime;
        $chunkTime = $chunkTime > 0 ? $chunkTime : 1;
        $lastChunkTime = $time;
        $speed = round($sendbyte / 1024 / $chunkTime, 2);
        $percent = round($totalsend / $fileSize * 100, 2);
        echo "<script type='text/javascript'>pr('{$percent}', '" . bytesToKbOrMbOrGb($totalsend) . "', '{$speed}');</script>\n";
        flush();
    }
    if ($errno || $errstr) {
        $lastError = $errstr;
        return false;
    }
    fclose($fs);
    fflush($fp);
    $llen = 0;
    $header = '';
    do {
        $header .= fgets($fp, 16384);
        $len = strlen($header);
        if (!$header || $len == $llen) {
            $lastError = lang(91);
            stream_socket_shutdown($fp, STREAM_SHUT_RDWR);
            fclose($fp);
            return false;
        }
        $llen = $len;
    } while (strpos($header, $nn . $nn) === false);
    // Array for active stream filters
    $sFilters = array();
    if (stripos($header, "\nTransfer-Encoding: chunked") !== false && in_array('dechunk', stream_get_filters())) {
        $sFilters['dechunk'] = stream_filter_append($fp, 'dechunk', STREAM_FILTER_READ);
    }
    // Add built-in dechunk filter
    $page = '';
    do {
        $data = @fread($fp, 16384);
        if ($data == '') {
            break;
        }
        $page .= $data;
    } while (!feof($fp) && strlen($data) > 0);
    stream_socket_shutdown($fp, STREAM_SHUT_RDWR);
    fclose($fp);
    if (stripos($header, "\nTransfer-Encoding: chunked") !== false && empty($sFilters['dechunk']) && function_exists('http_chunked_decode')) {
        $dechunked = http_chunked_decode($page);
        if ($dechunked !== false) {
            $page = $dechunked;
        }
        unset($dechunked);
    }
    $page = $header . $page;
    return $page;
}
Beispiel #11
0
 public function CheckBack($header)
 {
     if (stripos($header, "\nContent-Type: text/html") !== false) {
         global $fp, $sFilters;
         if (empty($fp) || !is_resource($fp)) {
             html_error('[filesflash_com] Cannot check download error.');
         }
         $is_chunked = stripos($header, "\nTransfer-Encoding: chunked") !== false;
         if (!isset($sFilters) || !is_array($sFilters)) {
             $sFilters = array();
         }
         if ($is_chunked && empty($sFilters['dechunk']) && in_array('dechunk', stream_get_filters())) {
             $sFilters['dechunk'] = stream_filter_append($fp, 'dechunk', STREAM_FILTER_READ);
         }
         $body = stream_get_contents($fp);
         if ($is_chunked && empty($sFilters['dechunk']) && function_exists('http_chunked_decode')) {
             $dechunked = http_chunked_decode($body);
             if ($dechunked !== false) {
                 $body = $dechunked;
             }
             unset($dechunked);
         }
         is_present($body, 'Your IP address is not valid for this link.', '[filesflash_com] Your IP address is not valid for this link.');
         is_present($body, 'Your IP address is already downloading another link.', '[filesflash_com] Your IP address is already downloading another link.');
         is_present($body, 'Your link has expired.', '[filesflash_com] Your link has expired.');
         is_present($body, 'Interrupted free downloads cannot be resumed.', '[filesflash_com] Interrupted free downloads cannot be resumed.');
         html_error('[filesflash_com] Unknown download error.');
     }
 }
Beispiel #12
0
 /**
  * Attach a filter in FIFO order
  *
  * @param mixed $filter An object that implements ObjectInterface, ObjectIdentifier object
  *                      or valid identifier string
  * @param array $config  An optional array of filter config options
  * @return  bool   Returns TRUE if the filter was attached, FALSE otherwise
  */
 public function attachFilter($filter, $config = array())
 {
     $result = false;
     //Handle custom filters
     if (!in_array($filter, stream_get_filters())) {
         //Create the complete identifier if a partial identifier was passed
         if (is_string($filter) && strpos($filter, '.') === false) {
             $identifier = clone $this->getIdentifier();
             $identifier->path = array('stream', 'filter');
             $identifier->name = $filter;
         } else {
             $identifier = $this->getIdentifier($filter);
         }
         if ($identifier->inherits('Nooku\\Library\\FilesystemStreamFilterInterface')) {
             $filter = $identifier->classname;
             $filter::register();
             $filter = $filter::getName();
         }
     }
     //If we have a valid filter name create the filter and append it
     if (is_string($filter) && !empty($filter)) {
         $mode = 0;
         if ($this->isReadable()) {
             $mode = $mode & STREAM_FILTER_READ;
         }
         if ($this->isWritable()) {
             $mode = $mode & STREAM_FILTER_WRITE;
         }
         if ($resource = stream_filter_append($this->_resource, $filter, $mode, $config)) {
             $this->_filters[$filter] = $filter;
             $result = true;
         }
     }
     return $result;
 }
 /**
  * @runInSeparateProcess
  */
 public function testRespondWithPaddedStreamFilterOutput()
 {
     $availableFilter = stream_get_filters();
     if (in_array('mcrypt.*', $availableFilter) && in_array('mdecrypt.*', $availableFilter)) {
         $app = new App();
         $app->get('/foo', function ($req, $res) {
             $key = base64_decode('xxxxxxxxxxxxxxxx');
             $iv = base64_decode('Z6wNDk9LogWI4HYlRu0mng==');
             $data = 'Hello';
             $length = strlen($data);
             $stream = fopen('php://temp', 'r+');
             $filter = stream_filter_append($stream, 'mcrypt.rijndael-128', STREAM_FILTER_WRITE, ['key' => $key, 'iv' => $iv]);
             fwrite($stream, $data);
             rewind($stream);
             stream_filter_remove($filter);
             stream_filter_append($stream, 'mdecrypt.rijndael-128', STREAM_FILTER_READ, ['key' => $key, 'iv' => $iv]);
             return $res->withHeader('Content-Length', $length)->withBody(new Body($stream));
         });
         // Prepare request and response objects
         $env = Environment::mock(['SCRIPT_NAME' => '/index.php', 'REQUEST_URI' => '/foo', 'REQUEST_METHOD' => 'GET']);
         $uri = Uri::createFromEnvironment($env);
         $headers = Headers::createFromEnvironment($env);
         $cookies = [];
         $serverParams = $env->all();
         $body = new RequestBody();
         $req = new Request('GET', $uri, $headers, $cookies, $serverParams, $body);
         $res = new Response();
         // Invoke app
         $resOut = $app($req, $res);
         $app->respond($resOut);
         $this->assertInstanceOf('\\Psr\\Http\\Message\\ResponseInterface', $resOut);
         $this->expectOutputString('Hello');
     } else {
         $this->assertTrue(true);
     }
 }
 /**
  * Registers stream extensions for PartStream and CharsetStreamFilter
  * 
  * @see stream_filter_register
  * @see stream_wrapper_register
  */
 protected function registerStreamExtensions()
 {
     stream_filter_register(UUEncodeStreamFilter::STREAM_FILTER_NAME, __NAMESPACE__ . '\\Stream\\UUEncodeStreamFilter');
     stream_filter_register(CharsetStreamFilter::STREAM_FILTER_NAME, __NAMESPACE__ . '\\Stream\\CharsetStreamFilter');
     stream_wrapper_register(PartStream::STREAM_WRAPPER_PROTOCOL, __NAMESPACE__ . '\\Stream\\PartStream');
     // hhvm compatibility -- at time of writing, no convert.* filters
     // should return false if already registered
     $filters = stream_get_filters();
     // @codeCoverageIgnoreStart
     if (!in_array('convert.*', $filters)) {
         stream_filter_register(QuotedPrintableDecodeStreamFilter::STREAM_FILTER_NAME, __NAMESPACE__ . '\\Stream\\QuotedPrintableDecodeStreamFilter');
         stream_filter_register(Base64DecodeStreamFilter::STREAM_FILTER_NAME, __NAMESPACE__ . '\\Stream\\Base64DecodeStreamFilter');
     }
     // @codeCoverageIgnoreEnd
 }
Beispiel #15
0
 public function CheckBack(&$headers)
 {
     if (substr($headers, 9, 3) == '416') {
         html_error('[google_com.php] Plugin needs a fix, \'Range\' method is not working.');
     }
     if (stripos($headers, "\nTransfer-Encoding: chunked") !== false) {
         global $fp, $sFilters;
         if (empty($fp) || !is_resource($fp)) {
             html_error('Error: Your rapidleech copy is outdated and it doesn\'t support functions required by this plugin.');
         }
         if (!in_array('dechunk', stream_get_filters())) {
             html_error('Error: dechunk filter not available, cannot download chunked file.');
         }
         if (!isset($sFilters) || !is_array($sFilters)) {
             $sFilters = array();
         }
         if (empty($sFilters['dechunk'])) {
             $sFilters['dechunk'] = stream_filter_append($fp, 'dechunk', STREAM_FILTER_READ);
         }
         if (!$sFilters['dechunk']) {
             html_error('Error: Unknown error while initializing dechunk filter, cannot download chunked file.');
         }
         // Little hack to get the filesize.
         $headers = preg_replace('@\\nContent-Range\\: bytes 0-\\d+/@i', "\nContent-Length: ", $headers, 1);
     }
 }
Beispiel #16
0
 /**
  * Returns a list of filters
  *
  * @return  array
  *
  * @since   11.1
  */
 function getFilters()
 {
     // Note: This will look like the getSupported() function with J! filters.
     // TODO: add user space filter loading like user space stream loading
     return stream_get_filters();
 }
Beispiel #17
0
<?php

var_dump(stream_get_filters("a"));
var_dump(stream_filter_register());
var_dump(stream_filter_append());
var_dump(stream_filter_prepend());
var_dump(stream_filter_remove());
var_dump(stream_bucket_make_writeable());
var_dump(stream_bucket_append());
var_dump(stream_bucket_prepend());
Beispiel #18
0
 public function EncodeQP($string, $line_max = 76, $space_conv = false)
 {
     if (function_exists('quoted_printable_encode')) {
         return quoted_printable_encode($string);
     }
     $filters = stream_get_filters();
     if (!in_array('convert.*', $filters)) {
         return $this->EncodeQPphp($string, $line_max, $space_conv);
     }
     $fp = fopen('php://temp/', 'r+');
     $string = preg_replace('/\\r\\n?/', $this->LE, $string);
     $params = array('line-length' => $line_max, 'line-break-chars' => $this->LE);
     $s = stream_filter_append($fp, 'convert.quoted-printable-encode', STREAM_FILTER_READ, $params);
     fputs($fp, $string);
     rewind($fp);
     $out = stream_get_contents($fp);
     stream_filter_remove($s);
     $out = preg_replace('/^\\./m', '=2E', $out);
     fclose($fp);
     return $out;
 }
Beispiel #19
0
 public function CheckBack($header)
 {
     $statuscode = intval(substr($header, 9, 3));
     if ($statuscode != 200) {
         switch ($statuscode) {
             case 509:
                 html_error('[Mega_co_nz] Transfer quota exeeded.');
             case 503:
                 html_error('[Mega_co_nz] Too many connections for this download.');
             case 403:
                 html_error('[Mega_co_nz] Link used/expired.');
             case 404:
                 html_error('[Mega_co_nz] Link expired.');
             default:
                 html_error('[Mega_co_nz][HTTP] ' . trim(substr($header, 9, strpos($header, "\n") - 8)));
         }
     }
     global $fp, $sFilters;
     if (empty($fp) || !is_resource($fp)) {
         html_error("Error: Your rapidleech version is outdated and it doesn't support this plugin.");
     }
     if (!empty($_GET['T8']['fkey'])) {
         $key = $this->base64_to_a32(urldecode($_GET['T8']['fkey']));
     } elseif (preg_match('@^(T8|N)?!([^!]{8})!([\\w\\-\\,]{43})@i', parse_url($_GET['referer'], PHP_URL_FRAGMENT), $dat)) {
         $key = $this->base64_to_a32($dat[2]);
     } else {
         html_error("[CB] File's key not found.");
     }
     $iv = array_merge(array_slice($key, 4, 2), array(0, 0));
     $key = array($key[0] ^ $key[4], $key[1] ^ $key[5], $key[2] ^ $key[6], $key[3] ^ $key[7]);
     $opts = array('iv' => $this->a32_to_str($iv), 'key' => $this->a32_to_str($key), 'mode' => 'ctr');
     if (!stream_filter_register('MegaDlDecrypt', 'Th3822_MegaDlDecrypt') && !in_array('MegaDlDecrypt', stream_get_filters())) {
         html_error('Error: Cannot register "MegaDlDecrypt" filter.');
     }
     if (!isset($sFilters) || !is_array($sFilters)) {
         $sFilters = array();
     }
     if (empty($sFilters['MegaDlDecrypt'])) {
         $sFilters['MegaDlDecrypt'] = stream_filter_prepend($fp, 'MegaDlDecrypt', STREAM_FILTER_READ, $opts);
     }
     if (!$sFilters['MegaDlDecrypt']) {
         html_error('Error: Unknown error while initializing MegaDlDecrypt filter, cannot continue download.');
     }
 }
Beispiel #20
0
<?php

var_dump(in_array('string.rot13', stream_get_filters()));
Beispiel #21
0
<?php

// Register chunk filter if not found
if (!array_key_exists('chunk', stream_get_filters())) {
    stream_filter_register('chunk', 'Http\\Message\\Encoding\\Filter\\Chunk');
}
<?php

$streamlist = stream_get_filters();
print_r($streamlist);
Beispiel #23
0
}
function fg($path, &$g = NULL)
{
    global $doc;
    return count($g = glob("{$doc}/{$path}"));
}
$ext = "http";
$doc = "/home/mike/Development/src/php/phpdoc/en/trunk/reference/{$ext}";
$ref = new ReflectionExtension($ext);
printf("Undocumented INI options:\n");
foreach ($ref->getINIEntries() as $name => $tmp) {
    re("configuration.xml", "#<entry>{$name}</entry>#") or printf("\t%s (%s)\n", $name, $tmp);
}
printf("\n");
printf("Undocumented stream filters:\n");
foreach (preg_grep("/^{$ext}\\./", stream_get_filters()) as $filter) {
    fe(sprintf("streamfilters/%s.xml", substr($filter, 5))) or printf("\t%s\n", $filter);
}
printf("\n");
printf("Undocumented constants:\n");
foreach ($ref->getConstants() as $name => $tmp) {
    re("constants.xml", "#<constant>{$name}</constant>#") or printf("\t%s (%s)\n", $name, $tmp);
}
printf("\n");
printf("Undocumented functions:\n");
foreach ($ref->getFunctions() as $func) {
    /* @var $func ReflectionFunction */
    fg(sprintf("functions/*/%s.xml", strtr($func->getName(), '_', '-'))) or printf("\t%s()\n", $func->getName());
}
printf("\n");
printf("Undocumented classes/members:\n");
 /**
  * Add a filter in FIFO order
  *
  * @param mixed $filter An object that implements ObjectInterface, ObjectIdentifier object
  *                      or valid identifier string
  * @param array $config  An optional array of filter config options
  * @return  bool   Returns TRUE if the filter was added, FALSE otherwise
  */
 public function addFilter($filter, $config = array())
 {
     $result = false;
     if (is_resource($this->_resource)) {
         //Handle custom filters
         if (!in_array($filter, stream_get_filters())) {
             //Create the complete identifier if a partial identifier was passed
             if (is_string($filter) && strpos($filter, '.') === false) {
                 $identifier = $this->getIdentifier()->toArray();
                 $identifier['path'] = array('stream', 'filter');
                 $identifier['name'] = $filter;
                 $identifier = $this->getIdentifier($identifier);
             } else {
                 $identifier = $this->getIdentifier($filter);
             }
             //Make sure the class
             $class = $this->getObject('manager')->getClass($identifier);
             if (array_key_exists('KFilesystemStreamFilterInterface', class_implements($class))) {
                 $filter = $class::getName();
                 if (!empty($filter) && !in_array($filter, stream_get_filters())) {
                     stream_filter_register($filter, $class);
                 }
             }
         }
         //If we have a valid filter name create the filter and append it
         if (is_string($filter) && !empty($filter)) {
             $mode = 0;
             if ($this->isReadable()) {
                 $mode = $mode & STREAM_FILTER_READ;
             }
             if ($this->isWritable()) {
                 $mode = $mode & STREAM_FILTER_WRITE;
             }
             if ($resource = stream_filter_append($this->_resource, $filter, $mode, $config)) {
                 $this->_filters[$filter] = $filter;
                 $result = true;
             }
         }
     }
     return $result;
 }
Beispiel #25
0
 /**
  * @internal SysAdmin phpinfo.
  * @attribute[RequestParam('extension','string',false)]
  * @attribute[RequestParam('search','string',false)]
  * @attribute[RequestParam('dump_server','bool',false)]
  */
 function PhpInfo($extension, $search, $dump_server)
 {
     if ($dump_server) {
         $search = $extension = "";
     }
     if ($search) {
         $extension = null;
     }
     foreach (ini_get_all() as $k => $v) {
         $k = explode('.', $k, 2);
         if (count($k) < 2) {
             $k = array('Core', $k[0]);
         }
         $data[$k[0]][$k[1]] = $v;
     }
     ksort($data);
     $tab = $this->content(Table::Make());
     $tab->addClass('phpinfo')->SetCaption("Basic information")->AddNewRow("PHP version", phpversion())->AddNewRow("PHP ini file", php_ini_loaded_file())->AddNewRow("SAPI", php_sapi_name())->AddNewRow("OS", php_uname())->AddNewRow("Apache version", apache_get_version())->AddNewRow("Apache modules", implode(', ', apache_get_modules()))->AddNewRow("Loaded extensions", implode(', ', get_loaded_extensions()))->AddNewRow("Stream wrappers", implode(', ', stream_get_wrappers()))->AddNewRow("Stream transports", implode(', ', stream_get_transports()))->AddNewRow("Stream filters", implode(', ', stream_get_filters()));
     $ext_nav = $this->content(new Control('div'))->css('margin-bottom', '25px');
     $ext_nav->content("Select extension: ");
     $sel = $ext_nav->content(new Select());
     $ext_nav->content("&nbsp;&nbsp;&nbsp;Or search: ");
     $tb = $ext_nav->content(new TextInput());
     $tb->value = $search;
     $q = buildQuery('sysadmin', 'phpinfo');
     $sel->onchange = "wdf.redirect({extension:\$(this).val()})";
     $tb->onkeydown = "if( event.which==13 ) wdf.redirect({search:\$(this).val()})";
     $ext_nav->content('&nbsp;&nbsp;&nbsp;Or ');
     $q = buildQuery('sysadmin', 'phpinfo', 'dump_server=1');
     $ext_nav->content(new Anchor($q, 'dump the $_SERVER variable'));
     $get_version = function ($ext) {
         $res = $ext == 'zend' ? zend_version() : phpversion($ext);
         return $res ? " [{$res}]" : '';
     };
     $sel->SetCurrentValue($extension)->AddOption('', '(select one)');
     $sel->AddOption('all', 'All values');
     foreach (array_keys($data) as $ext) {
         $ver = $ext == 'zend' ? zend_version() : phpversion($ext);
         $sel->AddOption($ext, $ext . $get_version($ext) . " (" . count($data[$ext]) . ")");
     }
     if ($dump_server) {
         $tab = $this->content(new Table())->addClass('phpinfo')->SetCaption('Contents of the $_SERVER variable')->SetHeader('Name', 'Value');
         foreach ($_SERVER as $k => $v) {
             $tab->AddNewRow($k, $v);
         }
     }
     if ($extension || $extension == 'all' || $search) {
         foreach ($data as $k => $config) {
             if (!$search && $k != $extension && $extension != 'all') {
                 continue;
             }
             $tab = false;
             foreach ($config as $ck => $v) {
                 if ($search && stripos($ck, $search) === false && stripos($v['local_value'], $search) === false && stripos($v['global_value'], $search) === false) {
                     continue;
                 }
                 if (!$tab) {
                     $tab = $this->content(new Table())->addClass('phpinfo')->SetCaption($k . $get_version($k))->SetHeader('Name', 'Local', 'Master');
                 }
                 $tr = $tab->NewRow(array($ck, $v['local_value'], $v['global_value']));
                 if ($v['local_value'] !== '' && $v['local_value'] != $v['global_value']) {
                     $tr->GetCell(2)->css('color', 'red');
                 }
             }
         }
     }
 }
Beispiel #26
0
 /**
  * Get all registered filer names.
  *
  * @return  array
  */
 public static function getRegistered()
 {
     return stream_get_filters();
 }
Beispiel #27
0
            }
        }
    }
}
// Determine the tests to be run.
$test_files = array();
$redir_tests = array();
$test_results = array();
$PHP_FAILED_TESTS = array('BORKED' => array(), 'FAILED' => array(), 'WARNED' => array(), 'LEAKED' => array(), 'XFAILED' => array());
// If parameters given assume they represent selected tests to run.
$failed_tests_file = false;
$pass_option_n = false;
$pass_options = '';
$compression = 0;
$output_file = $CUR_DIR . '/php_test_results_' . date('Ymd_Hi') . '.txt';
if ($compression && in_array("compress.zlib", stream_get_filters())) {
    $output_file = 'compress.zlib://' . $output_file . '.gz';
}
$just_save_results = false;
$leak_check = false;
$html_output = false;
$html_file = null;
$temp_source = null;
$temp_target = null;
$temp_urlbase = null;
$conf_passed = null;
$no_clean = false;
$cfgtypes = array('show', 'keep');
$cfgfiles = array('skip', 'php', 'clean', 'out', 'diff', 'exp');
$cfg = array();
foreach ($cfgtypes as $type) {
Beispiel #28
0
 /**
  * Alias for stream_get_filters
  * @return array
  */
 public static function getFilters()
 {
     return stream_get_filters();
 }
 /**
  * Encode string to RFC2045 (6.7) quoted-printable format
  * Uses a PHP5 stream filter to do the encoding about 64x faster than the old version
  * Also results in same content as you started with after decoding
  * @see EncodeQPphp()
  * @access public
  * @param string $string the text to encode
  * @param integer $line_max Number of chars allowed on a line before wrapping
  * @param boolean $space_conv Dummy param for compatibility with existing EncodeQP function
  * @return string
  * @author Marcus Bointon
  */
 public function EncodeQP($string, $line_max = 76, $space_conv = false)
 {
     if (function_exists('quoted_printable_encode')) {
         //Use native function if it's available (>= PHP5.3)
         return quoted_printable_encode($string);
     }
     $filters = stream_get_filters();
     if (!in_array('convert.*', $filters)) {
         //Got convert stream filter?
         return $this->EncodeQPphp($string, $line_max, $space_conv);
         //Fall back to old implementation
     }
     $fp = fopen('php://temp/', 'r+');
     $string = preg_replace('/\\r\\n?/', $this->LE, $string);
     //Normalise line breaks
     $params = array('line-length' => $line_max, 'line-break-chars' => $this->LE);
     $s = stream_filter_append($fp, 'convert.quoted-printable-encode', STREAM_FILTER_READ, $params);
     fputs($fp, $string);
     rewind($fp);
     $out = stream_get_contents($fp);
     stream_filter_remove($s);
     $out = preg_replace('/^\\./m', '=2E', $out);
     //Encode . if it is first char on a line, workaround for bug in Exchange
     fclose($fp);
     return $out;
 }
Beispiel #30
0
 /**
  * Searches for filter in steam_get_filters()
  *
  * @param string $filter
  * @return boolean
  */
 private function _testFilter($filter)
 {
     // Search for filter in list
     foreach (stream_get_filters() as $actual) {
         $actual = str_replace('\\*', '.*', preg_quote($actual));
         if (preg_match("!{$actual}!", $filter)) {
             return true;
         }
     }
     // Not found
     return false;
 }