473,414 Members | 1,697 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,414 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 5280
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
by: Mikko Ohtamaa | last post by:
From XML specification: The representation of an empty element is either a start-tag immediately followed by an end-tag, or an empty-element tag. (This means that <foo></foo> is equal to...
8
by: Edo van der Zouwen | last post by:
It's quite easy in Php: <?php $language = $_SERVER; $language_short = substr($taal,0,2); echo $language_short; ?>
12
by: Stefan Weiss | last post by:
Hi. (this is somewhat similar to yesterday's thread about empty links) I noticed that Tidy issues warnings whenever it encounters empty tags, and strips those tags if cleanup was requested....
2
by: Andreas Palm | last post by:
I have a dataset that has DBNull in certain columns, now when I write out this one to XML, I only get the columns as elements that do have data in it. However I do need also the empty colums as...
11
by: Dan Bass | last post by:
which one do you use and why? MyString == null || MyString == "" vs MyString == null || MyString.Length == 0
13
by: Alexander Widera | last post by:
hi, who has seen the follow problem or could help please? i visit a page .... i read a sesssion-var . ... everythink works...... i visit the page again..... error ... the sessionvar is null .... i...
14
by: cj | last post by:
What is string.empty used for? I can't say: if string.empty then I have to use: if string = "" then which is ok, I just want to know what .empty is for.
26
by: anonieko | last post by:
In the past I always used "" everywhere for empty string in my code without a problem. Now, do you think I should use String.Empty instead of "" (at all times) ? Let me know your thoughts.
2
by: RvT | last post by:
I have an interesting problem. I have FireFox2, IE7 and Opera9 as test browsers. All browsers are in Dutch. When I execute the following: <?=$_SERVER?> The result is as follows: FireFox:...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.