Re: [PHP] Browser Sniffing

2003-03-04 Thread Tau Ceti

On a site I worked with we rely on browser detection in order to send the
correct stylesheet and other bits that make it more compatable on older
browsers. Browser detection is not just used to block unwanted browsers.

On Tue, 4 Mar 2003, Leif K-Brooks wrote:

 Checking browsers is pure evil, but if you must, use
 $_SERVER['HTTP_USER_AGENT'] on the server side.

 Ashley M. Kirchner wrote:

 
 I know, it can't be done in PHP.  That's not exactly what I'm here
  for.  I have a client who would like to redirect people to a polite
  'upgrade your browser' page whenever people visit his site (which has
  been developed in PHP no less).  My question here is, how can I make
  this so that regardless of what URL someone comes in to, it will
  always run the sniffer prior to loading the actual URL they visited?
  In other words, whether the visitor comes to the main url
  (http://www.site.org), or whether they are going to a specific link
  (http://ww.site.org/seethis/), the client would like the sniffer to
  check them all.
 
 I know I can stick the whole javascript sniffer into each and every
  file, but that's just not efficient.  Being that this site was created
  in PHP, I can very easily stick an 'include' in each file to include
  the javascript piece, however how can I use the results of that
  javascript piece inside PHP to then do a Header(Location...) type
  thing?  Can I even do that considering that javascript normally goes
  within the head.../head section, at which point the page headers
  were already sent, and doing a Location redirection within PHP will
  only result in an error.
 
 Suggestions welcome.
 

 --
 The above message is encrypted with double rot13 encoding.  Any unauthorized attempt 
 to decrypt it will be prosecuted to the full extent of the law.




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







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



[PHP] Post processing Perl output through PHP

2001-07-13 Thread tau

Hi all,

I am having a knightmare trying to get some PHP into the output of
a Perl script. PHP. I've heard rumours of Apache 2.0 allowing multiple
filters, which would be perfect when it's out, but not yet obviously.

I've tried calling the CGI PHP from inside Perl in a few ways:

==
#!/usr/bin/perl
$result = `/usr/bin/php -q  EOF
?php echo Hello World; ?
EOF
`;
print Content-Type: text/html\n\n;
print PHP output was $result\n;
exit;
==

I've also tried running this command as a system() call in Perl, and
sending the output of /usr/bin/php to a temporary file, then using
Perl to open and read the contents of that file.

Both methods work if I call the script myself at a shell prompt. In
the case of the file creation, an 11 byte file is duly created.

However, when I call the perl script from a web browser, I lose the
PHP output. The code given above doesn't help narrow it down, but
in the case of the file creating version, I notice back at a shell
prompt that the call to /usr/bin/php has made a 0 byte file... which
obviously explains why I see nothing once Perl copies it to the output.

So, that means there is something about /usr/bin/php that is making it
generate absolutely no output when called via apache and the perl script.

I am guessing that this has to do with the environment variables, as I
can see no other way in which /usr/bin/php would be aware of a difference
in its environment.

So, my question is, does anybody know how to persuade PHP to give me the
output when called in this way... perhaps by forging an environment 
variable from Perl first, or some clever command line switch...

Alternatively, and much preferred, some way of parsing the whole of the
perl output through PHP before returning to the browser. Then I could
just print PHP tags in my Perl output and Apache/mod_php would handle
the rest on the way back...

For reasons that really aren't worth going into, I need to access some
messy PHP functions from Perl, and I can't rewrite the PHP functions in
Perl because I have .php pages that need them, and I can't rewrite the
Perl scripts in PHP either. If I can't find a way of doing this, I will
probably tear all my hair out and then sit down to rewrite a separate
copy of every routine in Perl, and have two copies of all the code in
two different languages... knightmare come true !

Please please help me !!!

James
[EMAIL PROTECTED]

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]