$PHP_SELF

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
technetx
-


Joined: 27 Oct 2008
Posts: 15

PostPosted: Sun Nov 09, 2008 8:38 pm    Post subject: $PHP_SELF Reply with quote

If you're having trouble with Abyss and PHP_SELF, change the "type" in your host to "Standard" instead of "PHP Style".

I was wondering why a bunch of scripts were duplicating URLs.... "/page.php?var=xxx" would end up being "/page.php/page.php?var=xxx". If you see this happening in your scripts, the only way it seems to solve it is:

1) change your php host setting to "Standard"
or 2), change every single line of code in all your scripts where you use $PHP_SELF.

I think I'll go with the first one for now ;)
Back to top View user's profile Send private message
TRUSTAbyss
-


Joined: 29 Oct 2003
Posts: 3714
Location: USA, GA

PostPosted: Sun Nov 09, 2008 10:05 pm    Post subject: Reply with quote

It's actually supposed to be $_SERVER['PHP_SELF']
_________________
Computer Programmer & Networking Specialist

Back to top View user's profile Send private message Visit poster's website MSN Messenger
technetx
-


Joined: 27 Oct 2008
Posts: 15

PostPosted: Sun Nov 09, 2008 10:26 pm    Post subject: RE: PHP_SELF Reply with quote

Hi Trust,

I was using the constant in the example, but it does it both with $PHP_SELF and $_SERVER['PHP_SELF'].
Back to top View user's profile Send private message
TRUSTAbyss
-


Joined: 29 Oct 2003
Posts: 3714
Location: USA, GA

PostPosted: Sun Nov 09, 2008 11:00 pm    Post subject: Reply with quote

What's the full PHP version you're using?
_________________
Computer Programmer & Networking Specialist

Back to top View user's profile Send private message Visit poster's website MSN Messenger
technetx
-


Joined: 27 Oct 2008
Posts: 15

PostPosted: Sun Nov 09, 2008 11:28 pm    Post subject: Reply with quote

PHP 5.2.6
Windows Vista
Abyss X2
Back to top View user's profile Send private message
TRUSTAbyss
-


Joined: 29 Oct 2003
Posts: 3714
Location: USA, GA

PostPosted: Sun Nov 09, 2008 11:29 pm    Post subject: Reply with quote

Can you post the code so that we may check it for any errors? Thank you!
The PHP version you're using should be set to Standard under "Scripting Parameters" for Type.
_________________
Computer Programmer & Networking Specialist

Back to top View user's profile Send private message Visit poster's website MSN Messenger
technetx
-


Joined: 27 Oct 2008
Posts: 15

PostPosted: Sun Nov 09, 2008 11:41 pm    Post subject: Reply with quote

Here's a simple one named test.php

If you have type set to "PHP Style"

<?php
echo $PHP_SELF."<br>";
echo $_SERVER['PHP_SELF']."<br>";
echo $SCRIPT_NAME."<br>";
?>
<p>&nbsp;</p>
<p>This is a <a href="<?=$PHP_SELF?>">link</a></p>

The output will be /test.php/test.php for all echo except $SCRIPT_NAME.

Setting type to "Standard" and it'll echo correctly.
Back to top View user's profile Send private message
technetx
-


Joined: 27 Oct 2008
Posts: 15

PostPosted: Sun Nov 09, 2008 11:48 pm    Post subject: Reply with quote

Note: Abyss and PHP 5.2.6 runs perfect using PHP Style... with only $PHP_SELF broken on hundreds of different scripts.

I haven't found any other errors. This is at least on Windows. Haven't tested Abyss on anything else but Vista and PHP 5.2.6 running external dedicated MySQL/FreeBSD on Dell Edge Servers.

Seems to be a good solid alternative to Apache on Linux and also Apache on Windows so far. Still have more testing to go, but getting pretty comfortable with Abyss ;)
Back to top View user's profile Send private message
DonQuichote
-


Joined: 24 Dec 2006
Posts: 68
Location: The Netherlands

PostPosted: Mon Nov 10, 2008 11:41 pm    Post subject: Known bug Reply with quote

It is a known (and irritant) bug of PHP.
Back to top View user's profile Send private message
technetx
-


Joined: 27 Oct 2008
Posts: 15

PostPosted: Tue Nov 11, 2008 1:33 am    Post subject: Reply with quote

Hi,

Is it a known bug of PHP or a know bug of "standard" vs. "php style" in Abyss on Windows?

I can't duplicate the bug running Apache on Win (same version of PHP) or Apache on *nix (same version of PHP).

Not placing blame here, I'm just trying to find all these bugs before using Abyss on a production box.

Would you happen to know what the difference is between "standard" and "php style"? I can't find any documentation... I'm trying to see if this setting would have any other negative effects for coding purposes.

Thanks!
Back to top View user's profile Send private message
DonQuichote
-


Joined: 24 Dec 2006
Posts: 68
Location: The Netherlands

PostPosted: Wed Nov 12, 2008 12:03 am    Post subject: Reply with quote

I have the same bug on Xubuntu 8.04. I read somewhere that there is a patch for it, but I write my code to run on all versions of PHP5 (you never know what server the code has to run on) and therefore take this bug into account, even if it is solved on my PC.
Back to top View user's profile Send private message
cornelis
-


Joined: 08 Feb 2009
Posts: 1
Location: holland

PostPosted: Sun Feb 08, 2009 12:33 pm    Post subject: PHP_SELF dows not work properly Reply with quote

Hi,

I have upgraded to Abyss 2.6 and PHP 5.2.8 on Windows XP and discovered problem with the PHP_SELF variable. The following programm deliveres the following output:

example error.php ::
<?php
echo($_SERVER['PHP_SELF']);
?>

output :
/error.php/error.php

It should be :
/error.php

I have tried to find the host setting, but cannot find it. Need some hint to resolve this problem.

Greetings
Cornelis
Back to top View user's profile Send private message
admin
Site Admin


Joined: 03 Mar 2002
Posts: 772

PostPosted: Sun Feb 08, 2009 4:17 pm    Post subject: Re: PHP_SELF dows not work properly Reply with quote

cornelis,

Please ensure that the PHP interpreter is declared in Abyss Web Server with its Type set to "Standard" and not to "PHP Style".

Actually, starting from PHP 5.2.4, PHP interpreters no more need the "PHP Style" workaround and will act as any "Standard" CGI interpreter.
_________________
Forum Administrator
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message
Lawrence
-


Joined: 16 Jan 2003
Posts: 202
Location: Brisbane, AU

PostPosted: Tue Jun 23, 2009 6:26 am    Post subject: Reply with quote

Ahoy admin/aprelium.

The PHP installation instructions still say that PHP-Style should be chosen, not Standard.

This has recently caused me some grief. If I might be so bold, I'd like to suggest the docs be changed to reflect this change and prevent others from suffering so terribly as I have. =)
_________________
[ Please stop confusing your opinion with fact. ]
Back to top View user's profile Send private message Visit poster's website ICQ Number
TRUSTAbyss
-


Joined: 29 Oct 2003
Posts: 3714
Location: USA, GA

PostPosted: Tue Jun 23, 2009 7:10 am    Post subject: Reply with quote

Lawrence wrote:
Ahoy admin/aprelium.

The PHP installation instructions still say that PHP-Style should be chosen, not Standard.

This has recently caused me some grief. If I might be so bold, I'd like to suggest the docs be changed to reflect this change and prevent others from suffering so terribly as I have. =)


Only PHP5 requires you to select Standard for Type. That guide is for PHP4.
http://www.aprelium.com/abyssws/php5win.html
_________________
Computer Programmer & Networking Specialist

Back to top View user's profile Send private message Visit poster's website MSN Messenger
Lawrence
-


Joined: 16 Jan 2003
Posts: 202
Location: Brisbane, AU

PostPosted: Tue Jun 23, 2009 10:35 am    Post subject: Reply with quote

That just means other errors need to be corrected. The page I linked includes PHP5 in its instructions.

that page wrote:
In the Interpreter field, press Browse..., go to the directory where you have installed PHP and click on php.exe if you have installed PHP 4 or php-cgi.exe if you have installed PHP 5.


that page wrote:
If you plan to install PHP 5 on Windows, we highly recommend using our preconfigured PHP 5 package.


that page wrote:
Set Type to PHP Style.


You're right that there are other special instructions for PHP5, but they are not found at the bottom of the page I linked, nor are they mentioned during the PHP-install page that is.
_________________
[ Please stop confusing your opinion with fact. ]
Back to top View user's profile Send private message Visit poster's website ICQ Number
TRUSTAbyss
-


Joined: 29 Oct 2003
Posts: 3714
Location: USA, GA

PostPosted: Tue Jun 23, 2009 6:19 pm    Post subject: Reply with quote

I agree, Aprelium should fix that.
_________________
Computer Programmer & Networking Specialist

Back to top View user's profile Send private message Visit poster's website MSN Messenger
SCM
-


Joined: 14 Aug 2009
Posts: 1

PostPosted: Fri Aug 14, 2009 6:19 pm    Post subject: abyss and php on linux does has same issue Reply with quote

I have followed the php installation instructions and also followed the instructions set out here but it makes no deference, im running the latest update to php on a fedora 9 box with the latest abyss version. no matter what i do i always get "domain/index.php/index.php" this is driving me nutty, if i dident already have a site in the apache web, i would just use apache and forget all about abyss all togeather. as it stands im now thinking ill have to set up another box as abyss seems to me to be completely unreliable to run php
Back to top View user's profile Send private message
DonQuichote
-


Joined: 24 Dec 2006
Posts: 68
Location: The Netherlands

PostPosted: Sat Aug 15, 2009 3:45 pm    Post subject: Reply with quote

Gee, did we not mention that this is a bug in PHP? Go on, install apache, spend 5 years to learn to administer it, and you will still see the same bug. It is in PHP, not in the Abyss.

This function works around that bug:
Code:
function PhpSelf()
        {$strResult = $_SERVER['PHP_SELF'];
         if((strlen($strResult) % 2)==0):
            $strHalf = substr($strResult, 0 , strlen($strResult)/2);
            if($strResult == $strHalf . $strHalf):
               $strResult = $strHalf; // No idea what happens here? There is a bug in PHP that can cause the PHP_SELF to be duplicate.
            endif;
         endif;
         return $strResult; }
Back to top View user's profile Send private message
dannydesiliva
-


Joined: 23 Sep 2009
Posts: 1

PostPosted: Wed Sep 23, 2009 7:46 am    Post subject: Slideshow problems due to PHP_SELF = REDIRECT_URL assignment Reply with quote

I wasn't able to start a slideshow or browse to the next image whenever I accessed a random image from my gallery startpage.

I've looked into the code and found the following cause:

In init.inc.php the variable PHP_SELF is assigned as

Code:

$PHP_SELF = isset($HTTP_SERVER_VARS['REDIRECT_URL']) ? $HTTP_SERVER_VARS['REDIRECT_URL'] : $HTTP_SERVER_VARS['SCRIPT_NAME'];


Problem is that on my provider's server (Apache 1.3.19, PHP 4.1.2), REDIRECT_URL always points to the php script URL INCLUDING the HTTP-GET variables. SCRIPT_NAME has the correct value but never gets used because REDIRECT_URL is already defined.

Example:

$PHP_SELF = /pixies/displayimage.php?album=random&cat=&pos=-26
instead of the desired
$PHP_SELF = /pixies/displayimage.php

(I've checked other servers on the web and they don't include the HTTP-GET variables in the REDIRECT_URL string. Lucky them.)

Could someone explain the reason why REDIRECT_URL is being used for PHP_SELF and not just SCRIPT_NAME?
I thought that REDIRECT_URL is just for error handling purposes.

Any insight is greatly appreciated!

Cheers,
onkeljossip (a very happy coppermine user)
Back to top View user's profile Send private message
satishbhawra51
-


Joined: 11 Oct 2009
Posts: 2

PostPosted: Mon Oct 12, 2009 12:21 am    Post subject: Reply with quote

If you're having trouble with Abyss and PHP_SELF, change the "type" in your host to "Standard" instead of "PHP Style".
_________________
web information | best hosting
Back to top View user's profile Send private message Visit poster's website
pankajnagarkoti87
-


Joined: 13 Oct 2009
Posts: 1

PostPosted: Tue Oct 13, 2009 11:25 pm    Post subject: Reply with quote

Can you post the code so that we may check it for any errors? Thank you!
_________________
Best hosting | Website worth calculater
Back to top View user's profile Send private message Visit poster's website
anybody
-


Joined: 17 Mar 2008
Posts: 90

PostPosted: Mon Jul 12, 2010 4:02 pm    Post subject: Re: RE: PHP_SELF Reply with quote

technetx wrote:
Hi Trust,

I was using the constant in the example, but it does it both with $PHP_SELF and $_SERVER['PHP_SELF'].
A statement needs to be said here that everyone needs to see.

To use the variable $PHP_SELF register_globals must be on and the PHP manual states loud and clear DO NOT DO THIS.

By the way PHP_SELF is not defined as a constant by PHP.

Click on this link and read what the PHP Manual from php.net says about register_globals.

Warning: This feature has been DEPRECATED as of PHP 5.3.0. Relying on this feature is highly discouraged.

Using register_globals is poor programming.
Back to top View user's profile Send private message
Toasty
-


Joined: 21 Feb 2008
Posts: 295
Location: Chicago, IL

PostPosted: Sat Jul 17, 2010 10:42 pm    Post subject: Reply with quote

register_globals does not need to be enabled for $PHP_SELF to work. I've always had register_globals off (on PHP 5.16 through 5.3.2), and I use that variable without issue.
_________________
Portfolio: Robert Lerner
Back to top View user's profile Send private message Visit poster's website
simon1
-


Joined: 07 Jan 2013
Posts: 1

PostPosted: Mon Jan 07, 2013 1:13 pm    Post subject: Reply with quote

TRUSTAbyss wrote:
Lawrence wrote:
Ahoy admin/aprelium.

The PHP installation instructions still say that PHP-Style should be chosen, not Standard.

This has recently caused me some grief. If I might be so bold, I'd like to suggest the docs be changed to reflect this change and prevent others from suffering so terribly as I have. =)


Only PHP5 requires you to select Standard for Type. That guide is for PHP4.
http://www.aprelium.com/abyssws/php5win.html




Hey Trust ,as technetx said change all the script line by line ......is it possible ???
because if i have large website and having huge amount of code then i cannot change whole script line by line ...so let me know is there any procedure from with i can change all the code automatically by once ..


thanks in advance to all .....
Back to top View user's profile Send private message
aprelium-support
-


Joined: 20 Feb 2009
Posts: 356

PostPosted: Tue Jan 08, 2013 11:16 am    Post subject: Reply with quote

simon1,

Are you sure you are affected by that issue? What scripts are you running? Are they written by you or some kind of opensource scripts?
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group