471,090 Members | 1,343 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

empty HTTP_ACCEPT_LANGUAGE

BbT
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
Jul 17 '05 #1
3 4990
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.
Jul 17 '05 #2
BbT
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
Jul 17 '05 #3
"BbT" <ma************@zdroje.one.pl> wrote in message
news:cf**********@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.

Jul 17 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Edo van der Zouwen | last post: by
12 posts views Thread by Stefan Weiss | last post: by
11 posts views Thread by Dan Bass | last post: by
13 posts views Thread by Alexander Widera | last post: by
14 posts views Thread by cj | last post: by

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.