Author Topic: php weirdness  (Read 612 times)

0 Members and 1 Guest are viewing this topic.

Offline jwwceoTopic starter

  • Enthusiast
  • Posts: 206
    • View Profile
php weirdness
« on: June 25, 2009, 08:32:36 PM »
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

Offline BK87

  • Enthusiast
  • Posts: 496
    • View Profile
Re: php weirdness
« Reply #1 on: June 25, 2009, 11:58:52 PM »
whats in php5.cgi?
- Free image hosting =)

Offline pkedpker

  • Enthusiast
  • Posts: 172
    • View Profile
Re: php weirdness
« Reply #2 on: June 26, 2009, 12:09:29 AM »
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.
My main langauges I've learned since I've gotten into the computer world.. were Assembly and Basic together they made me into a god of hacking/cracking. A few years ago I learned C. Realized how much C helped me with picking up other langauges in a breeze like most importantly PHP =)

Offline jwwceoTopic starter

  • Enthusiast
  • Posts: 206
    • View Profile
Re: php weirdness
« Reply #3 on: June 26, 2009, 12:10:55 AM »
Code: [Select]
#!/bin/bash
PHPRC=$DOCUMENT_ROOT/../etc/php5
export PHPRC
umask 022
SCRIPT_FILENAME=$PATH_TRANSLATED
export SCRIPT_FILENAME
exec /usr/bin/php5-cgi

Offline jwwceoTopic starter

  • Enthusiast
  • Posts: 206
    • View Profile
Re: php weirdness
« Reply #4 on: June 26, 2009, 12:13:37 AM »
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


Offline pkedpker

  • Enthusiast
  • Posts: 172
    • View Profile
Re: php weirdness
« Reply #5 on: June 26, 2009, 12:24:06 AM »
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..
My main langauges I've learned since I've gotten into the computer world.. were Assembly and Basic together they made me into a god of hacking/cracking. A few years ago I learned C. Realized how much C helped me with picking up other langauges in a breeze like most importantly PHP =)

Offline jwwceoTopic starter

  • Enthusiast
  • Posts: 206
    • View Profile
Re: php weirdness
« Reply #6 on: June 26, 2009, 12:38:57 AM »
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.


Offline btherl

  • Guru
  • Fanatic
  • *
  • Posts: 3,791
  • Gender: Male
  • Matt is the best!
    • View Profile
Re: php weirdness
« Reply #7 on: June 26, 2009, 12:57:41 AM »
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.
Your php questions answered at Flingbits

Offline jwwceoTopic starter

  • Enthusiast
  • Posts: 206
    • View Profile
Re: php weirdness
« Reply #8 on: June 26, 2009, 01:01:30 AM »
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

Offline btherl

  • Guru
  • Fanatic
  • *
  • Posts: 3,791
  • Gender: Male
  • Matt is the best!
    • View Profile
Re: php weirdness
« Reply #9 on: June 26, 2009, 04:33:31 AM »
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:

Quote
$_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.
Your php questions answered at Flingbits