jwwceo Posted June 26, 2009 Share Posted June 26, 2009 Hey all. Last night, something on my server happened, and now my scripts aren't working like they should. It looks like my $_SERVER array is broken. When I echo $_SERVER['PHP_SELF'] I get the following: [php_SELF] => /cgi-bin/php5.cgi same thing for [sCRIPT_NAME] => /cgi-bin/php5.cgi I use the SELF variable in some script, so I need it to be working, any ideas?? is this possibly a virus?? James Quote Link to comment https://forums.phpfreaks.com/topic/163715-php-weirdness/ Share on other sites More sharing options...
BK87 Posted June 26, 2009 Share Posted June 26, 2009 whats in php5.cgi? Quote Link to comment https://forums.phpfreaks.com/topic/163715-php-weirdness/#findComment-863905 Share on other sites More sharing options...
pkedpker Posted June 26, 2009 Share Posted June 26, 2009 looks like common gateway interface php_self is just return filename of currently executing script but sometimes may return folder name too. SCRIPT_NAME is just script name. SCRIPT_FILENAME = the path where script is located. Quote Link to comment https://forums.phpfreaks.com/topic/163715-php-weirdness/#findComment-863908 Share on other sites More sharing options...
jwwceo Posted June 26, 2009 Author Share Posted June 26, 2009 #!/bin/bash PHPRC=$DOCUMENT_ROOT/../etc/php5 export PHPRC umask 022 SCRIPT_FILENAME=$PATH_TRANSLATED export SCRIPT_FILENAME exec /usr/bin/php5-cgi Quote Link to comment https://forums.phpfreaks.com/topic/163715-php-weirdness/#findComment-863910 Share on other sites More sharing options...
jwwceo Posted June 26, 2009 Author Share Posted June 26, 2009 Sorry if I'm not being clear. the problem is that the variable is not holding the right name. This file is called home.php, not php5.cgi. It is not returning the correct name, and that is breaking all my scripts where I use PHP_SELF. JAmes Quote Link to comment https://forums.phpfreaks.com/topic/163715-php-weirdness/#findComment-863912 Share on other sites More sharing options...
pkedpker Posted June 26, 2009 Share Posted June 26, 2009 you made cgi file? not need maybe? delete no? PHPRC=$DOCUMENT_ROOT/../etc/php5 path to php = DOCUMENT_ROOT + /../etc/php5 export PHPRC = Path to php.ini (environmental variable) export =? output umask 022 = CHMOD 644 which means (read/write files/read files) SCRIPT_FILENAME = $PATH_TRANSLATED ($PATH_TRANSLATED = ???) export SCRIPT_FILENAME (output that?) exec /user/bin/php5-cgi (run php5-cgi.exe) probably some kind of a script to run it in silent mode kinda like services on XP.. Quote Link to comment https://forums.phpfreaks.com/topic/163715-php-weirdness/#findComment-863915 Share on other sites More sharing options...
jwwceo Posted June 26, 2009 Author Share Posted June 26, 2009 I renamed php5.cgi as a test, but it doesnt change the $_SERVER variables. I still get php5.cgi instead of home.php for the filename. Quote Link to comment https://forums.phpfreaks.com/topic/163715-php-weirdness/#findComment-863921 Share on other sites More sharing options...
btherl Posted June 26, 2009 Share Posted June 26, 2009 Can you get the script name from one of the other server variables? If it's in the url then you should be able to extract it from there. Quote Link to comment https://forums.phpfreaks.com/topic/163715-php-weirdness/#findComment-863926 Share on other sites More sharing options...
jwwceo Posted June 26, 2009 Author Share Posted June 26, 2009 yes...I did that as a fix... Im just curious why this would happen? Can php break?? Do I need to re-compile maybe?? james Quote Link to comment https://forums.phpfreaks.com/topic/163715-php-weirdness/#findComment-863931 Share on other sites More sharing options...
btherl Posted June 26, 2009 Share Posted June 26, 2009 Is this server run by you or by someone else? If someone else runs it they may have reconfigured how php runs. Or even upgraded from php 4 to php 5. If the server is yours, it may have been affected by a change to the webserver, even if you didn't modify php itself. The short answer is that $_SERVER variables are not really guaranteed by php to hold any specific value. PHP relies on the web server to pass those values through, which is why they are called $_SERVER variables .. If the web server gives php different values, then that's what your script will get. The manual says this: $_SERVER is an array containing information such as headers, paths, and script locations. The entries in this array are created by the web server. There is no guarantee that every web server will provide any of these; servers may omit some, or provide others not listed here. That said, a large number of these variables are accounted for in the » CGI 1.1 specification, so you should be able to expect those. Quote Link to comment https://forums.phpfreaks.com/topic/163715-php-weirdness/#findComment-863983 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.