[PHP] Missing Array Key with apache_request_headers()

2004-01-14 Thread Philip Pawley
Hello,

I don't get this at all.

I'm trying to use php to manipulate my HTTP headers. 

[ Background Info about HTTP headers.]
[ If an "ETag" header is sent by the server, then, next time a user-agent requests the 
same page, it sends back that header's value - in an "If-None-Match" header. ] 

The problem comes when I try to access the "If-None-Match" header using 
"apache_request_headers()". 

With Mozilla (I'm using 1.6b) the "If-Modified-Since" header is in the array. 
With Internet Explorer 6, it isn't, even though the header is sent out. (I'm checking 
the header output with the Proxomitron).

Why is this happening and what can I do about it?

Here are all the details:
---
The page I'm testing this with:

-
The Mozilla output on reload:

Array ( [0] => Accept [1] => Accept-Charset [2] => Accept-Encoding [3] => 
Accept-Language [4] => Cache-Control [5] => Connection [6] => Host [7] => 
If-None-Match [8] => Keep-Alive [9] => User-Agent )

and from the Prox:
GET /test.php HTTP/1.1
Host: pc
User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.6b) Gecko/20031208
Accept: 
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,image/jpeg,image/gif;q=0.2,*/*;q=0.1
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
If-None-Match: asdfghjkl
Cache-Control: max-age=0
Connection: keep-alive
---
The IE6 output on reload is:

Array ( [0] => Accept [1] => Accept-Encoding [2] => Accept-Language [3] => Connection 
[4] => Host [5] => Pragma [6] => User-Agent )

and from the Prox:
GET /test.php HTTP/1.1
Accept: */*
Accept-Language: en
Accept-Encoding: gzip, deflate
If-None-Match: asdfghjkl
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows 98)
Host: pc
Pragma: no-cache
Connection: keep-alive

As you can see, in both cases, all the request headers shown by the Proxomitron are 
also in the array - with the exception, for IE6, of the "If-None-Match" header.

Thanks in advance for your responses,

Philip Pawley

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Migrating from SSI and Perl

2003-12-30 Thread Philip Pawley
Have I got this right?

I am doing

 "$BRPHP" );
exec (' ../cgi-bin/browser.pl', $arr );
echo $arr[2];
echo $arr[3];
echo $arr[4];
echo $arr[5];
echo $arr[6];
?>

1. Am I passing $arr[1] to the perl script?
2. If no, what should I do instead?
3. If yes, how can I access it from the perl script? 

(Yes, I know the last question is a perl question, so I'll be happy to just get an 
answer to the first two).

Thanks,

Philip Pawley

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Migrating from SSI and Perl

2003-12-29 Thread Philip Pawley
Right, I used 

$output = shell_exec("perl browser.pl");
echo "output";

as Radek suggested. To call my browser-sniffing perl script and read back what the 
script prints.
My trouble now is that the perl script, being called by the php script rather than by 
SSI, no longer seems to have the cgi environment variables to call on.

I can get the variable using

$BRPHP = $_SERVER['HTTP_USER_AGENT'];

How do I pass this to the perl script? I've followed all the avenues suggested in the 
newbie guide.

The best I can seem to manage is to use exec() like so:

$BRPHP = $_SERVER['HTTP_USER_AGENT'];
$arr = array (1 => "$BRPHP" );
exec (' ../cgi-bin/browser.pl', $arr );
echo $arr[2];
echo $arr[3];
echo $arr[4];
echo $arr[5];
echo $arr[6];

The echo commands get me back the script's output, but am I passing $BRPHP to the perl 
script this way? (If the answer is "yes" then I can ask the folks at perl.org how to 
pick it up in the perl script).

Thanks,

Philip Pawley


At 26/12/03 12:29 -0500, you wrote:
>Check out shell_exec() and its siblings. I'd likely use it like so $output =
>shell_exec("perl myscript.pl"); and then do something with the $output
>variable
>
>R>
>
>> -Original Message-
>> From: Philip Pawley [mailto:[EMAIL PROTECTED]
>> Sent: December 26, 2003 12:07 PM
>> To: php-general
>> Subject: [PHP] Migrating from SSI and Perl
>>
>>
>> I am new to php.
>>
>> My site, at the moment, uses SSI to call a Perl browser-sniffing script.
>>
>> I would like to:
>> 1. use php to call the Perl script.
>> 2. then save the values the Perl script outputs as php variables.
>>
>> Can this be done? If so, how?
>>
>> Thanks,
>>
>> Philip Pawley

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Migrating from SSI and Perl

2003-12-26 Thread Philip Pawley
Hi Radek,

I tried to do something with this and failed dismally.

Is it possible for you to give me a really basic working example of what you suggest? 

Thanks,

Philip Pawley

At 26/12/03 12:29 -0500, you wrote:
>Check out shell_exec() and its siblings. I'd likely use it like so $output =
>shell_exec("perl myscript.pl"); and then do something with the $output
>variable
>
>R>
>
>> -Original Message-
>> From: Philip Pawley [mailto:[EMAIL PROTECTED]
>> Sent: December 26, 2003 12:07 PM
>> To: php-general
>> Subject: [PHP] Migrating from SSI and Perl
>>
>>
>> I am new to php.
>>
>> My site, at the moment, uses SSI to call a Perl browser-sniffing script.
>>
>> I would like to:
>> 1. use php to call the Perl script.
>> 2. then save the values the Perl script outputs as php variables.
>>
>> Can this be done? If so, how?
>>
>> Thanks,
>>
>> Philip Pawley

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Migrating from SSI and Perl

2003-12-26 Thread Philip Pawley
I am new to php.

My site, at the moment, uses SSI to call a Perl browser-sniffing script.

I would like to:
1. use php to call the Perl script.
2. then save the values the Perl script outputs as php variables.

Can this be done? If so, how?

Thanks,

Philip Pawley

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php