Forum Moderators: coopster

Message Too Old, No Replies

PHP via SSI no longer works after upgrade to 4.4.1

         

JohnKelly

2:58 am on Nov 30, 2005 (gmt 0)

10+ Year Member



I recently upgraded from PHP v4.3.2 to v4.4.1. During testing I noticed that some bits of PHP code no longer function.

For example:

in a page index.shtml I have an SSI:
<!--#include virtual="/includes/rightmenu.html"-->

The file rightmenu.html in turn has some HTML code but also:
<!--#include virtual="/includes/randomquote.phtml"-->

The file randomquote.phtml is where the trouble lies. It is supposed to open a data file of quotes, and then display one at random. The file looks like:

<?php

$fp = fopen ("../random/quotes.db", "r");
if (!$fp) {
echo "file cant be opened";
exit();
}
$n = 0;
while (!feof ($fp)) {
$buffer = fgets ($fp, 4096);
++$n;
}
--$n;
srand ((double) microtime() * 1000000);
$randno = rand(1, $n);
rewind ($fp);
$n = 0;
while ($n < $randno) {
$buffer = fgets ($fp, 4096);
++$n;
}
$buffer = trim($buffer);
fclose ($fp);

$quote_array = preg_split ("[\¦]", $buffer);

$ID = $quote_array[0];
$Name = $quote_array[1];
$Company = $quote_array[2];
$URL = $quote_array[3];
$Quote = $quote_array[4];

$Quote_Word_Array = explode(' ',$Quote);
$maxwords = 25;

$Quote_Size = count ($Quote_Word_Array);

if ($Quote_Size > $maxwords) {
foreach ($Quote_Word_Array as $word) {
$wordcount++;
if ($wordcount <= $maxwords) {
$Quote_limit = $Quote_limit . " " . $word;
}
}
$Quote_limit = $Quote_limit . "...." . " <A HREF=\"/aboutias/client_quotes.html#$ID\" CLASS=\"Quotes\">(cont.)</A>";
}
else { $Quote_limit = $Quote; }

When I load the page index.shtml, it hangs at the spot where quotes should appear.

What happened between v4.3.2 and 4.4.1 that could cause this?

kiwibrit

10:22 am on Nov 30, 2005 (gmt 0)

10+ Year Member



Given that you are using php, why not use php includes? genuine (and quite possibly ignorant question) I am still getting the hang of all this.

JohnKelly

12:58 pm on Nov 30, 2005 (gmt 0)

10+ Year Member



Fair question.... I'm using a lot of legacy code (thousands of pages) so don't want to have to change it all over.

Plus - it worked before the PHP upgrade.

coopster

2:49 pm on Nov 30, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



I don't know off-hand what the issue might be but I would begin by narrowing it down. Throw an
exit('You got this far');
message into the process step. Keep moving that statement further into the steps until you get no further. Then at least you can narrow down the problem area to an exact function or line number.

Also, crank up your error_reporting() [php.net] during troubleshooting here so you can see any and all messages.

JohnKelly

6:16 am on Dec 4, 2005 (gmt 0)

10+ Year Member



It seems that paths have changed somehow. I did find a workaround (hack) for the worst offender.

Thanks everyone for your help and advice!