Topic: "Show new post since last visit" does not show up

On my forum (http://groningen-info.de/forum/) the two upper right links "Show new posts" and "Mark all as read" do not show up and in the source I only get <div class="clearer"></div> instead.

I have found out that this is decided in header.php (line 171 and following) with the following IF-statement:

if (in_array(basename($_SERVER['PHP_SELF']), array('index.php', 'search.php'))) ...

What is the purpose of this?
What are the consequences of commenting out the IF?
What else could I do see the two links?

Re: "Show new post since last visit" does not show up

It would appear your PHP environment does not include the PHP_SELF variable. That's quite odd.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

3 (edited by pmmueller 2005-09-25 13:36)

Re: "Show new post since last visit" does not show up

Rickard, thanx for your quick reply.

Rickard wrote:

It would appear your PHP environment does not include the PHP_SELF variable. That's quite odd.

Step 1
I have checked my PHP environment (PHP version is 4.1.2.) with a file called phpinfo.php (including phpinfo()) and here are the results of the jury:

_SERVER["PHP_SELF"]    /forum/phpinfo.php

Forum is installed in subdirectory /forum/ and the filename seems to be available in the PHP_SELF environment variable.

Step 2
For debugging purposes I have added

echo "PHP_SELF variable is" . $_SERVER['PHP_SELF']

to the header.php and receive the following output:

PHP_SELF variable is /forum/indexphp

The DOT between file name and extension appears to be missing. Is that perhaps of significance?

Questions

- What is the purpose of this IF-statement? Security?

- What happens if I comment the IF (and the else) out?

4 (edited by Smartys 2005-09-25 14:57)

Re: "Show new post since last visit" does not show up

Mmm, it sounds like it's your webhost manipulating something
ie: I can go to http://groningen-info.de/forum/viewforum and get the viewforum page, whereas if I go there for this site I get a 404

Re: "Show new post since last visit" does not show up

Does it really output indexphp? Not index.php?

"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: "Show new post since last visit" does not show up

Well, what you could do is add the following above the current IF statement:

    if (strpos($_SERVER['PHP_SELF'], '.php') === FALSE)
        $_SERVER['PHP_SELF'] = str_replace('php', '.php', $_SERVER['PHP_SELF']);

This isn't a solution though, but rather just a 'dirty' workaround. Your server *should* output script.php.. Sounds like some form of mod_rewrite or something...

7 (edited by pmmueller 2005-09-25 16:27)

Re: "Show new post since last visit" does not show up

Rickard wrote:

Does it really output indexphp? Not index.php?

Yes. In the browser window and in the source code.

But it gets even weirder: If I select the string, copied it and on pasting it, it stops after index, even if other text after the ending php was also copied. Like this:

PHP_SELF is /forum/index

Whereas in the source and on the page it definitely reads (I am wearing reading glasses):

PHP_SELF is /forum/indexphp

So there seems to be something invisible between index and php that stops it from being copied. Weird.
Any ideas?

UPDATE:
The above copying was done in Firefox and its source window. In the windows editor (view source in IE) there is a space between index and php and it can be copied:

PHP_SELF is /forum/index php

So there seems to be something in that PHP_SELF variable that probably should not be there.

8 (edited by pmmueller 2005-09-25 16:20)

Re: "Show new post since last visit" does not show up

Smartys wrote:

Mmm, it sounds like it's your webhost manipulating something
ie: I can go to http://groningen-info.de/forum/viewforum and get the viewforum page, whereas if I go there for this site I get a 404

Do you mean "from this site"?

I get "Ungültige Anfrage. Der Link dem Sie gefolgt sind ist ungültig oder veraltet." meaning "Invalid request. The link is not valid or outdated." no matter whether I enter it in the browser window or follow the link in your message.

So I do not really think there is some webhost manipulating going on.

Re: "Show new post since last visit" does not show up

By "this site" I mean forums.punbb.org
I mean that I get a 404, versus on your site it loads the page tongue

10 (edited by pmmueller 2005-09-26 10:08)

Re: "Show new post since last visit" does not show up

Smartys wrote:

By "this site" I mean forums.punbb.org
I mean that I get a 404, versus on your site it loads the page tongue

I see. And you are right wink
I'll check if I have some forgotten .htaccess lying around there somewhere. Maybe from trying to get friendly URLs on Nucleus or something ...

UPDATE
The forwarding was done by Apache ContentNegotiation Modul:
http://httpd.apache.org/docs/1.3/conten … ation.html

Is currently switched off, and now I get a proper 404, just as it should be.
Thanx for your observation.

11 (edited by pmmueller 2005-09-26 15:53)

Re: "Show new post since last visit" does not show up

pmmueller wrote:
Rickard wrote:

Does it really output indexphp? Not index.php?

Yes ... So there seems to be something in that PHP_SELF variable that probably should not be there.

We captured packets with Ethereal and the packets contain the value 0x00 and not 0x2e, which would apparently be a proper DOT. Funnily enough Ethereal shows the wrong value as the right dot.

We currently have no explanation as to why PHP does this. But it at least explains why PHP_SELF fails the IF-statement in header.php and why "Show new post since last visit" in pubBB does not show up.

===
Temporary Solution
I am no programmer, but I figured that the following (unelegant and crude) patch will do. It checks if the strings "index" oder "search" appear in the variable and respectively replace it with the value it ought to have to begin with ("/forum" is just my path). I inserted it in header.php before line 171: 

if (strpos($_SERVER['PHP_SELF'], 'index')) {
  $_SERVER['PHP_SELF'] = "/forum/index.php";  
}    
if (strpos($_SERVER['PHP_SELF'], 'search')) {
  $_SERVER['PHP_SELF'] = "/forum/search.php";  
}

Any suggestions from PHP programmers as to make this statement more elegant are more than welcome.

===
Thank you everybody for your time and concern.

Re: "Show new post since last visit" does not show up

Well, is it possible, that this is at every server in another way? (Just a warning: My PHP is poor!)
Because, I've installed PunBB at a Linux (Suse)-server, a Windows-Server (my home-computer) and my Forum, which has the same problem, is on a SunOS - Server.
And I tried now blind what could work and these ways up (and guessing) didn't.

And in the PHP-Info my Server shows the admin_index.php as the PHP_SELF.

Do you know where the problem is, and will this problem be fixed (or sth. like that) in PunBB 1.3?
Thanks and greets from Lake Constance,
Florian