empty HTTP_ACCEPT_LANGUAGE

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • BbT

    empty HTTP_ACCEPT_LANGUAGE

    On my site I have a code based on $_SERVER['HTTP_ACCEPT_LA NGUAGE'], to
    selelect language variable:
    if(!isset($_SES SION['lng'])) {
    if(preg_match("/pl/i", $_SERVER['HTTP_ACCEPT_LA NGUAGE'])) {
    $_SESSION['lng'] = "pl";
    }
    elseif(preg_mat ch("/en/i", $_SERVER['HTTP_ACCEPT_LA NGUAGE'])) {
    $_SESSION['lng'] = "en";
    }
    elseif(preg_mat ch("/de/i", $_SERVER['HTTP_ACCEPT_LA NGUAGE'])) {
    $_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_VA RS['HTTP_REFERER'];
    $read = fopen($refpage, "rb");
    while(!feof($re ad))
    {
    $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_LA NGUAGE'] is empty.
    Maybe someone know why ?

    --
    Pozdrawiam - BbT
  • jacek blech

    #2
    Re: empty HTTP_ACCEPT_LAN GUAGE

    On Wed, 11 Aug 2004 08:16:52 +0200, BbT wrote:
    [color=blue]
    > 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_LA NGUAGE'] is empty.
    > Maybe someone know why ?[/color]

    maybe because the page wasn't requested by a browser but by your printer
    version script, therefor HTTP_ACCEPT_LAN GUAGE 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.

    Comment

    • BbT

      #3
      Re: empty HTTP_ACCEPT_LAN GUAGE

      jacek blech napisał(a):
      [color=blue][color=green]
      >>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_LA NGUAGE'] is empty.
      >>Maybe someone know why ?[/color]
      >
      >
      > maybe because the page wasn't requested by a browser but by your printer
      > version script, therefor HTTP_ACCEPT_LAN GUAGE 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.[/color]

      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

      Comment

      • CJ Llewellyn

        #4
        Re: empty HTTP_ACCEPT_LAN GUAGE

        "BbT" <marcin.usun.to @zdroje.one.pl> wrote in message
        news:cfcdq1$rkb $1@atlantis.new s.tpi.pl...[color=blue]
        > On my site I have a code based on $_SERVER['HTTP_ACCEPT_LA NGUAGE'], to
        > selelect language variable:
        > if(!isset($_SES SION['lng'])) {
        > if(preg_match("/pl/i", $_SERVER['HTTP_ACCEPT_LA NGUAGE'])) {
        > $_SESSION['lng'] = "pl";
        > }
        > elseif(preg_mat ch("/en/i", $_SERVER['HTTP_ACCEPT_LA NGUAGE'])) {
        > $_SESSION['lng'] = "en";
        > }
        > elseif(preg_mat ch("/de/i", $_SERVER['HTTP_ACCEPT_LA NGUAGE'])) {
        > $_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_VA RS['HTTP_REFERER'];
        > $read = fopen($refpage, "rb");
        > while(!feof($re ad))
        > {
        > $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_LA NGUAGE'] is empty.
        > Maybe someone know why ?[/color]

        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.



        Comment

        Working...