MyBB Community Forums

Full Version: problem with ob_start and 1.4.11
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I hope I'm posting this in the right spot. I'm a newbie to the forums, but have been using mybb for about 2 years. I started using mybb with no experience writing any type of code and have been able to produce a community forum I'm very proud of...and that's because of this community, the support staff and the software you've created.

Enough back-patting! Now to my problem. I have been heavily modifying the templates to mybb, and some modification to the index.php file as well. I've always diverted from using some of the plugins because I wanted to learn on my own how to do it. I have been using...

ob_start();
include("http://www.greensburgneighbors.com/event.php");
$event = ob_get_contents();
ob_end_clean();

...on my index page as a way to include any information from my event.php file, which contained code like this...

Quote:<div class="topbarleft">Today and Tomorrow in Greensburg</div>
<table class="table" style="text-align:left">
<tr class="line">

<?php
$html = file_get_contents("http://www.greensburgneighbors.com/calendar.php");

$html1 = preg_replace('/<td class="trow1calendar" align="center" width="1">(.*?)<\/td>/', '', $html);

preg_match_all(
'/<td class="trow_sep" height="100" valign="top">.*?<\/td>.*?<\/td>/s',
$html1,
$eventcontainer, // will contain the blog posts
PREG_SET_ORDER // formats data into an array of posts
);

foreach ($eventcontainer as $eventinfo) {
$unformated = $eventinfo[0];

$str1 = preg_replace('/<td class=(.*?)>/', '<td class="trow1" valign="top">', $unformated);
$str2 = str_replace('<div class="float_right smalltext">', '<div>', $str1);
$event = str_replace('<div style="margin-bottom: 4px; text-align:left" class="reallysmalltext public_event">', '<div>', $str2);
echo $event . "\n";
}
?>
</tr>
</table>

I used this same method to include a weather widget and at times a "recent post" widget. This worked like a charm in 1.4.9, and then I upgraded to 1.4.11. After I upgraded, I added, once again, the ob_start code to the top of my index.php file. Once I did that the page simply "chugged" and never loaded any information into my browser. It never does send any error text. So I took the ob_start code out and index.php comes up just fine.

Any suggestions?

Does the new version of php or mybb not like ob_start?
Is there a problem with my event.php code that 1.4.11 recognizes that 1.4.9 didn't?
(2010-01-12, 08:16 PM)brack Wrote: [ -> ]Once I did that the page simply "chugged" and never loaded any information into my browser.
Does it ever finish loading (e.g. with a blank page)? Or does your browser just keep spinning?
It just spins, the longest I waited was about 3 minutes or so. If it takes longer than that I don't know.
Any chance your includes might have created an infinite loop of inclusions?
I'm not sure.

Would a loop involve the same variables being used in the event.php and index.php?

Its got me perplexed that it would work fine in 1.4.9, but then be goofy in 1.4.11.
Still at a loss, but think it might have something to with file_get_contents because...

I simplified my event.php code to this...
Quote:<?php
$html = file_get_contents("http://www.greensburgneighbors.com/calendar.php");
echo $html;
?>
...which should just output my calendar.php page as is, but all it does is chug. So why would file_get_contents be affected by any upgrade to 1.4.11 or was that simply a matter of chance?
I just tried replacing the index.php(1.4.11) with index.php(1.4.9) and it chugged.

Would there be anything in the config file or .htaccess that would cause this?
I've even tried using file_get_contents on a purely HTML page and nothing loads.

What server changes did 1.4.11 make? That might give me some insite.

Thanks in advance.
Nothing, really?

Well, anyway....I just tried uploading my backup files(back to 1.4.9, when everything worked great) and guess what, IT now chugs.

Does that mean my host changed a setting on the server? I'm using 1and1. Please, I'll take any guidance. It took me a while to figure out the whole file_get_contents and ob_start code, I would hate to lose all that effort.
Problem is fixed, but still not understood.

I took a week off from trying to figure this one out, then decided to try another approach today. After reading through some of the PHP manual, I discovered that file_get_contents does not like it when there is pure html in the php file. So I went back to my "event.php" file, took out any pure html and placed that into my template, and then tried to use ob_start in my index.php file. IT WORKED. Now I have today's and tomorrow's events showing on my index.php page.

But I don't know why? I don't know why, when I made the upgrade from 1.4.9 to 1.4.11 it now only allows php code in a php include file.

Also, I haven't yet tried echoing the html into the php script just yet. I'm just glad my little script is back to normal.