By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,934 Members | 1,366 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,934 IT Pros & Developers. It's quick & easy.

apache ENV variables

P: n/a
Hello dear All!

I need to print out and pass apache evironment variables (like HTTP_HOST,
SERVER _NAME, REMOTE_ADDR) to another program which is to process them and
take definite actions depending on the current values of those variables.

But the thing is: apache variables are invisible for PHP. Could you please
give me advice or a couple of links where to learn how to wrap it around?

Thanks.
Jul 17 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Vitali Malicky wrote:
I need to print out and pass apache evironment variables (like HTTP_HOST,
SERVER _NAME, REMOTE_ADDR) to another program which is to process them and
take definite actions depending on the current values of those variables.

But the thing is: apache variables are invisible for PHP. Could you please
give me advice or a couple of links where to learn how to wrap it around?


All your examples are available in the super global array $_SERVER.

Try

<?php
echo '<pre>';
print_r($_SERVER);
echo '</pre>';
?>

to check what you have available in that very wonderful array :)
--
USENET would be a better place if everybody read: : mail address :
http://www.catb.org/~esr/faqs/smart-questions.html : is valid for :
http://www.netmeister.org/news/learn2quote2.html : "text/plain" :
http://www.expita.com/nomime.html : to 10K bytes :
Jul 17 '05 #2

P: n/a

"Pedro Graca" <he****@hotpop.com> wrote in message
news:c3*************@ID-203069.news.uni-berlin.de...
Vitali Malicky wrote:
I need to print out and pass apache evironment variables (like HTTP_HOST, SERVER _NAME, REMOTE_ADDR) to another program which is to process them and take definite actions depending on the current values of those variables.
But the thing is: apache variables are invisible for PHP. Could you please give me advice or a couple of links where to learn how to wrap it
around?
All your examples are available in the super global array $_SERVER.

Try

<?php
echo '<pre>';
print_r($_SERVER);
echo '</pre>';
?>

to check what you have available in that very wonderful array :)

Thanks, I know that wonderful aray, but the task is different.
My so called "THIRD" programs envoked from PHP script cannot see these
variables.
All the variables can be seen in the browser, it's ok, but, say, PHP
function mail() envoked from the PHP script does not get any of the apache
veriables, which, I'm coming again, seen in the browser very well, and clear
black on white... ;)

WBR.
Jul 17 '05 #3

P: n/a
On 2004-03-18, Vitali Malicky <li********@REMOVEzone3000.net> wrote:

"Pedro Graca" <he****@hotpop.com> wrote in message
news:c3*************@ID-203069.news.uni-berlin.de...
Vitali Malicky wrote:
> I need to print out and pass apache evironment variables (like HTTP_HOST, > SERVER _NAME, REMOTE_ADDR) to another program which is to process them and > take definite actions depending on the current values of those variables. >
> But the thing is: apache variables are invisible for PHP. Could you please > give me advice or a couple of links where to learn how to wrap it

around?

All your examples are available in the super global array $_SERVER.

Try

<?php
echo '<pre>';
print_r($_SERVER);
echo '</pre>';
?>

to check what you have available in that very wonderful array :)

Thanks, I know that wonderful aray, but the task is different.
My so called "THIRD" programs envoked from PHP script cannot see these
variables.


Pass them as arguments to your "third programs".

--
http://home.mysth.be/~timvw
Jul 17 '05 #4

P: n/a
Vitali Malicky wrote:
Vitali Malicky wrote:
> I need to print out and pass apache evironment variables (like
> HTTP_HOST, SERVER _NAME, REMOTE_ADDR) to another program which
> is to process them and take definite actions depending on the
> current values of those variables.
>
> But the thing is: apache variables are invisible for PHP. Could
> you please give me advice or a couple of links where to learn
> how to wrap it around?

Thanks, I know that wonderful aray [$_SESSION], but the task is different.
My so called "THIRD" programs envoked from PHP script cannot see these
variables.
All the variables can be seen in the browser, it's ok, but, say, PHP
function mail() envoked from the PHP script does not get any of the apache
veriables, which, I'm coming again, seen in the browser very well, and clear
black on white... ;)


Ah! sorry, I didn't quite get what you wanted.

Try putenv()

My /third/ program
pedro@localhost:~$ cat testenv
#!/bin/sh
echo PHP var is $PHP_VAR

My /second/ (hehehe) program
pedro@localhost:~$ cat xx.php
<?php
system('./testenv');
putenv('PHP_VAR=pedro');
system('./testenv')
?>

/first/ program is the command-line
pedro@localhost:~$ php xx.php
PHP var is
PHP var is pedro
--
USENET would be a better place if everybody read: : mail address :
http://www.catb.org/~esr/faqs/smart-questions.html : is valid for :
http://www.netmeister.org/news/learn2quote2.html : "text/plain" :
http://www.expita.com/nomime.html : to 10K bytes :
Jul 17 '05 #5

P: n/a
OK, guys, thanks for your effort to help. But I thinks I have to clear out
some things so that the task would be completely clear.

1 there is webhosting services with a free month trial
2 it provides ftp, ssh, mail, etc...
3 mail is qmail
4 qmail has a Message-ID field looking like this:
"Message-ID: <20**************************@mx.mail.server.dom >"
5 many persistent spammers take a delight with our services and use the
month trial to SPAM (bastards)
6 It's very hard to control 1500 user sending spam from a php web aplication
or command line scripts...
7 so, I've managed to add some code into qmail to put ehm... say, "a marker"
so that the above field looks like:
"Message-ID: <20**************************@mx.mail.server.dom(u ser)>" where
user runs a script from the command line (user is USER env var value, it's
clear, isn't it?), and
"Message-ID:
<20**************************@mx.mail.server.dom(w ww.user.virt.dom)>" Now it
is SERVER_NAME var for the "marker"

Everything works fine. I localy depricated some options in qmail-inject so
that "advanced" spammers could not influence on the Message-ID field.

The aim of all this job: as soon as the robot suspects spam flood it stops
qmail, I look into the header and see in the "marker" who was spamming
(USER, LOGNAME or SERVER_NAME or SCRIPT_FILENAME var value, getenv()'d by
qmail-inject, during the envelope process).

The trouble: when the php mail() function is called the apache vars
SERVER_NAME, SCRIPT_FILENAME, etc... are lost. Any other way of spaming
(well, running this same php script from the command line) does what is
intended - the USER or LOGNAME var value is just inserted into the string as
the "marker".

.... but. where apache variable are lost, and how to get them out?.. :(

Did you get the idea, dear All?

If this is success, I'm going to go further and to code some three more
control files for qmail where I could explicitedly allow/disallow(by
default) to send mail via web aplications and command line scripts (forum
registration, etc, etc...) for hosters who are not spamers.

Hope I've made myself clear now, and hope for real help, too (not verbal
exercising) :)

Thanks,
Life

Jul 17 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.