empty HTTP_ACCEPT_LANGUAGE

This is a discussion on empty HTTP_ACCEPT_LANGUAGE within the PHP Language forums, part of the PHP Programming Forums category; On Wed, 11 Aug 2004 08:16:52 +0200, BbT wrote: > I have a problem, because site processed like ...


Go Back   Usenet Forums > PHP Programming Forums > PHP Language

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 08-11-2004
jacek blech
 
Posts: n/a
Default Re: empty HTTP_ACCEPT_LANGUAGE

On Wed, 11 Aug 2004 08:16:52 +0200, BbT wrote:

> I have a problem, because site processed like that is loosing it's
> language variable. Pice of code, which is selecting langage, doesn't
> work, because variable $_SERVER['HTTP_ACCEPT_LANGUAGE'] is empty.
> Maybe someone know why ?


maybe because the page wasn't requested by a browser but by your printer
version script, therefor HTTP_ACCEPT_LANGUAGE can't have the language
preferences defined in the visitors browser.
why don't you use different css settings for browser/printer version of
your pages? i guess the content of the page is the same; font size or
background images or table widths are the values you want to change.

pozdrawiam.
Reply With Quote
  #2 (permalink)  
Old 08-11-2004
BbT
 
Posts: n/a
Default empty HTTP_ACCEPT_LANGUAGE

On my site I have a code based on $_SERVER['HTTP_ACCEPT_LANGUAGE'], to
selelect language variable:
if(!isset($_SESSION['lng'])) {
if(preg_match("/pl/i", $_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
$_SESSION['lng'] = "pl";
}
elseif(preg_match("/en/i", $_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
$_SESSION['lng'] = "en";
}
elseif(preg_match("/de/i", $_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
$_SESSION['lng'] = "de";
}
else {
$_SESSION['lng'] = "en";
}
}

There is also "printer version" script which read the site like this:
$refpage = (phpversion() > "4.1.0") ? $_SERVER['HTTP_REFERER'] :
$HTTP_SERVER_VARS['HTTP_REFERER'];
$read = fopen($refpage, "rb");
while(!feof($read))
{
$value .= fread($read, 16000);
}
fclose($read);
....
print $value;

I have a problem, because site processed like that is loosing it's
language variable. Pice of code, which is selecting langage, doesn't
work, because variable $_SERVER['HTTP_ACCEPT_LANGUAGE'] is empty.
Maybe someone know why ?

--
Pozdrawiam - BbT
Reply With Quote
  #3 (permalink)  
Old 08-11-2004
BbT
 
Posts: n/a
Default Re: empty HTTP_ACCEPT_LANGUAGE

jacek blech napisaƂ(a):

>>I have a problem, because site processed like that is loosing it's
>>language variable. Pice of code, which is selecting langage, doesn't
>>work, because variable $_SERVER['HTTP_ACCEPT_LANGUAGE'] is empty.
>>Maybe someone know why ?

>
>
> maybe because the page wasn't requested by a browser but by your printer
> version script, therefor HTTP_ACCEPT_LANGUAGE can't have the language
> preferences defined in the visitors browser.
> why don't you use different css settings for browser/printer version of
> your pages? i guess the content of the page is the same; font size or
> background images or table widths are the values you want to change.


My "printer version" script is cutting pieces of code between <!-- start
--> and <!-- stop --> markers from the input file, so I can decide which
pieces will be available for printing. Unfortunately it's loosing
language settings and that's my problem.

--
Pozdrawiam - BbT
Reply With Quote
  #4 (permalink)  
Old 08-11-2004
CJ Llewellyn
 
Posts: n/a
Default Re: empty HTTP_ACCEPT_LANGUAGE

"BbT" <marcin.usun.to@zdroje.one.pl> wrote in message
news:cfcdq1$rkb$1@atlantis.news.tpi.pl...
> On my site I have a code based on $_SERVER['HTTP_ACCEPT_LANGUAGE'], to
> selelect language variable:
> if(!isset($_SESSION['lng'])) {
> if(preg_match("/pl/i", $_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
> $_SESSION['lng'] = "pl";
> }
> elseif(preg_match("/en/i", $_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
> $_SESSION['lng'] = "en";
> }
> elseif(preg_match("/de/i", $_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
> $_SESSION['lng'] = "de";
> }
> else {
> $_SESSION['lng'] = "en";
> }
> }
>
> There is also "printer version" script which read the site like this:
> $refpage = (phpversion() > "4.1.0") ? $_SERVER['HTTP_REFERER'] :
> $HTTP_SERVER_VARS['HTTP_REFERER'];
> $read = fopen($refpage, "rb");
> while(!feof($read))
> {
> $value .= fread($read, 16000);
> }
> fclose($read);
> ...
> print $value;
>
> I have a problem, because site processed like that is loosing it's
> language variable. Pice of code, which is selecting langage, doesn't
> work, because variable $_SERVER['HTTP_ACCEPT_LANGUAGE'] is empty.
> Maybe someone know why ?


The web server is sending the request for the referer page, not the web
browser, and will only pass on a GET request, not all the other parts of a
HTTP request that a normal web browser would do.

Two ways to tackle this. If you have it available use curl to fetch fetch
the page. Otherwise, store all the browser information in a session
variable, then call the printer page.



Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 09:02 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0