473,385 Members | 1,873 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

apache ENV variables

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
5 3054
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

"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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Nick Rees | last post by:
Hi, I've got a strange query that I can't figure out. I've got a new installation of Apache 1.3.28 and PHP 4.3.3 on my laptop, but it doesn't appear to be processing URLs correctly. I've tried...
2
by: Kang Sun | last post by:
Greetings! I am testing Apache/PHP/MySQL. The connection seems to be right but when I try to http://my_machine/mypage.php3?id=1", I won't be able to get value the variable $id. Did I miss anything...
8
by: Tony | last post by:
I'm working with someone on a PHP project. The other person is doing testing of scripts on their personal machine using Apache as a web server. The production server and the one I'm using are both...
3
by: Jim Johnstone | last post by:
Some details of my HOME PC. I am running the following .... Win2000 SP4; IE V6; 512MB RAM; H/Disk Space OK. In the past couple of weeks I have installed/configured from binaries for .. MySQL...
1
by: Bruce Lehmann | last post by:
Hi, I've installed Apache (WAMP install) so I can edit and test my web site on my home computer. In general php code seems to work, but I can't access Apache variables such as PATH or...
15
by: weissborn | last post by:
I'm a php newbie. I have installed apache 2.0.54 and php 5.0.5 on my win2k box. However, it does not appear the php is working properly. I base this on the following code(which I got from a...
1
by: sysxperts | last post by:
Hello, Having an issue that is specific to PHP compiled with PGSQL support with versions noted in subject line. I understand that there are many variables to consider here but believe I have...
3
by: genenamg | last post by:
Hi, I am trying to run and configure Apache 2.0, php 5 and mysql on win xp professional - this is the first time I have tried to install and configure all three. I am having difficulty trying...
9
by: mariosp | last post by:
Hello all, Obvisouly I need to migrate the Apache linux to windows IIS. Do u know some tips on that? As an alternative method, I configured APache on Windows 2003 and the links dont work What...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.