khr2003
khr2003

Reputation: 1065

using stream wrappers in php gives blank page

I am implementing a template system using the wrapper class in this example: http://www.php.net/manual/en/stream.streamwrapper.example-1.php

I use this code to get the wrapper output:

    ob_start();
    include("template://" . $template_name);
    $template .= ob_get_contents();
    ob_end_clean();

However, in some servers this code is not working, all I get is a blank page. I am not sure if it is a php directive issue, I changed allow_url_include to both 0 and 1, but it did not have any effects on the code.

So what is the problem with the code.

EDIT: error logging is on, and it is not showing any errors related to this issue

Upvotes: 1

Views: 343

Answers (3)

mr_than
mr_than

Reputation: 410

My host updated to Litespeed and a more stringent Suhosin setup. At first I thought it was Litespeed, but it was indeed Suhosin (I twigged from this thread, thanks!).

It's just a php.ini setting you need to change, you have to add your stream name to the include whitelist:

suhosin.executor.include.whitelist = template://

And then it'll work fine again. Here's a couple more links saying the same:

Upvotes: 1

badsyntax
badsyntax

Reputation: 9650

I had the same issue and found that PHP Suhosin was causing this 'white screen of death'.

That could explain why this works on some servers and not on others.

There could be a Suhosin config option for dealing with that, check out the website: http://www.hardened-php.net/suhosin/

tl;dr I ended up removing Suhosin which resolved the issue.

Upvotes: 0

Denis de Bernardy
Denis de Bernardy

Reputation: 78561

in some servers this code is not working

In all likelihood, this is because php streams are not available or configured properly on these servers. It die with an error, and you don't see the error because of the output buffer

Upvotes: 1

Related Questions