Advanced search  

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Pages: [1]   Go Down

Author Topic: How coppermine stores language settings?  (Read 5736 times)

0 Members and 1 Guest are viewing this topic.

maolu

  • Coppermine newbie
  • Offline Offline
  • Posts: 19
How coppermine stores language settings?
« on: August 23, 2005, 09:30:28 am »

Hi everybody.

I'm trying to understand the way used in coppermine to store the language selected by a user.
How can it remember the last language you selected and show the gallery in that lang at the next visit?
Is it a cookie?!?

And in what part of the code can i find the commands that read this information?

Thankyou a lot.

« Last Edit: August 23, 2005, 11:18:38 am by GauGau »
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: How coppermine stores language settings?
« Reply #1 on: August 23, 2005, 09:48:21 am »

Logged

maolu

  • Coppermine newbie
  • Offline Offline
  • Posts: 19
Re: How coppermine stores language settings?
« Reply #2 on: August 23, 2005, 10:19:24 am »

ok thx.
So how can i get, via php, the language stored in this cookie?
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: How coppermine stores language settings?
« Reply #3 on: August 23, 2005, 10:45:14 am »

The user language is stored in
Code: [Select]
$USER['lang']To get a list of everything that coppermine "knows" about a user, try
Code: [Select]
print_r($USER);
Logged

maolu

  • Coppermine newbie
  • Offline Offline
  • Posts: 19
Re: How coppermine stores language settings?
« Reply #4 on: August 23, 2005, 11:05:05 am »

i tried with
Code: [Select]
echo $USER['lang'];but i get a costant result "r" :(

Right now i tested reading directly the cookie and it seems to work
Code: [Select]
$decoded = base64_decode($cpg133_data);
$lines = explode (":",$decoded);
$lastline = array_pop($lines);
$pieces = explode("\"",$lastline);
$currentLanguage = $pieces[1];
;D
Logged

maolu

  • Coppermine newbie
  • Offline Offline
  • Posts: 19
Re: How coppermine stores language settings?
« Reply #5 on: August 23, 2005, 06:01:43 pm »

OK, i have still problem with this issue... :\'( :\'( :\'(

The purpose is to be able to get and set the language values used in the gallery.
The reason is that i want to have also other pages in my site and of course if someone (I.E.) selects "english language" for the "LINKS" page, the same language has to be set also for the Coppermine Gallery and viceversa.

Right now the only functioning method i found in order to GET the language, as explined before,  is this:

Code: [Select]
function my_get_language($cookie)
{
    $decoded = base64_decode($cookie);
    $lines = explode (":",$decoded);
    $lastline = array_pop($lines);
    $pieces = explode("\"",$lastline);
    $currentLanguage = $pieces[1];
    return $currentLanguage;
}


In order to SET the language i use this method:

Code: [Select]
function my_set_language($cookieName, $cookie, $newLang)
{
    //GETS CURRENT LANGUAGE
    $decoded = base64_decode($cookie);
    $lines = explode (":",$decoded);
    $lastline = array_pop($lines);
    $pieces = explode("\"",$lastline);
    $currentLanguage = $pieces[1];
   
    //CREATES STRING WITH NEW LANGUAGE INFORMATION
    $decoded = base64_decode($cookie);
    $nonLanguageText = explode($currentLanguage, $decoded);
    $newLanguageString = base64_encode($nonLanguageText[0].$newLang.$nonLanguageText[1]);
   
    //SETS THE COOKIE WITH NEW LANGUAGE SETTINGS
    setcookie ($cookieName, $newLanguageString, time() + 86400, "/");
   
}


The problem is that right now it's not working... ::) :-[
So i tryed as a test to simply delete the Coppemine cookie using this:

Code: [Select]
setcookie("cpg133_data", "", time() - 3000, "");
But this is not worknig too, so i assume i'm not catching the point of the problem.
Can you help me?

Of course any kind of simpler solution is more then well accepted and if you say me "ehi you stupid, don't you know that you can use the function setGalleryCookieEasyer()!!" i'll be happy to hear that!
 ;D ;D ;D
Logged

Nibbler

  • Guest
Re: How coppermine stores language settings?
« Reply #6 on: August 23, 2005, 08:05:52 pm »

Look at the lang handling code in include/init.inc.php
Logged

maolu

  • Coppermine newbie
  • Offline Offline
  • Posts: 19
Re: How coppermine stores language settings?
« Reply #7 on: August 23, 2005, 10:32:26 pm »

you mean this?

Code: [Select]
if (isset($USER['lang']) && !strstr($USER['lang'], '/') && file_exists('lang/' . $USER['lang'] . '.php')) {
    $CONFIG['default_lang'] = $CONFIG['lang'];          // Save default language
    $CONFIG['lang'] = strtr($USER['lang'], '$/\\:*?"\'<>|`', '____________');
} elseif ($CONFIG['charset'] == 'utf-8') {
    include('include/select_lang.inc.php');
    if (file_exists('lang/' . $USER['lang'] . '.php')) {
        $CONFIG['default_lang'] = $CONFIG['lang'];      // Save default language
        $CONFIG['lang'] = $USER['lang'];
    }
} else {
    unset($USER['lang']);
}

By now it's not so clean to me how to use this if i want to set/get the language from outside the gallery's php files.
:-\\ ???

I mean, what could i do?
From a custom php file can i set language this way?
Code: [Select]
$CONFIG['lang'] = "english"
Am I missing something?
Logged

maolu

  • Coppermine newbie
  • Offline Offline
  • Posts: 19
Re: How coppermine stores language settings?
« Reply #8 on: August 25, 2005, 09:21:33 am »

Really no one knows it? ???

Somebody can tell me the reason why i cannot write into the Coppermine's cookies?

thx.
Logged

Joachim Müller

  • Dev Team member
  • Coppermine addict
  • ****
  • Offline Offline
  • Gender: Male
  • Posts: 47843
  • aka "GauGau"
    • gaugau.de
Re: How coppermine stores language settings?
« Reply #9 on: August 26, 2005, 09:21:51 am »

If you need custom information to be written, write your own cookie - don't abuse coppermine's cookie.
Logged

maolu

  • Coppermine newbie
  • Offline Offline
  • Posts: 19
Re: How coppermine stores language settings?
« Reply #10 on: August 26, 2005, 09:27:24 am »

If you need custom information to be written, write your own cookie - don't abuse coppermine's cookie.

Did you read what i wrote?!?! >:(

No custom information, i'm talking about the selected language. I only want to use the selected coppermine language also outside of the galley, this way unifying it in all my site.
Logged
Pages: [1]   Go Up
 

Page created in 0.022 seconds with 17 queries.