Jump to content
php.lv forumi

Nesaglaba izveleto valodu!


sniperzik

Recommended Posts

Sveiki,

 

man ir šāds scripts, bet es nesaprotu kapēc viņš nesaglabā izvēlēto valodu?

Ludzu palidziet!

<?
class object {};
$config = new object;
$config->dir	 = "lang/";
if (! isset($lang)) {
$lang = "en";
}

else if ($lang == "lv" ) { $SESSION["lang"] = "lv"; }
else if ($lang == "ru" ) { $SESSION["lang"] = "ru"; }
else if ($lang == "en" ) { $SESSION["lang"] = "en"; }
$config->global = $config->dir.$lang."/language.php";
include ($config->global);
?>

Edited by sniperzik
Link to comment
Share on other sites

session izmainiju !

 

<?

session_start();

class object {};
$config = new object;
$config->dir	 = "lang/";
if (! isset($lang)) {
$lang = "en";
}

else if ($lang == "lv" ) { $_SESSION["lang"] = "lv"; }
else if ($lang == "ru" ) { $_SESSION["lang"] = "ru"; }
else if ($lang == "en" ) { $_SESSION["lang"] = "en"; }
$config->global = $config->dir.$lang."/language.php";
include ($config->global);
?>

 

Nomainot citu valodu vins saglaba, bet atpakaļ kādu citu valodu vairs nevar nomainit! :(

 

Varbūt šādi nedrīt??

 

Varbūt ir kādi labāki un strādājoši valodas maiņas skripti?

 

Ja varat tad lūdzu pasakiet!

Link to comment
Share on other sites

izskatas ka tev ir ieslegti register_globals..

 

pamegjini shadi->

 

<?

session_start();

class object {};
$config = new object;
$config->dir	 = "lang/";
if (! empty($_SESSION['language'])) {
$lang = "en";
}

else if ($lang == "lv" ) { $_SESSION["language"] = "lv"; }
else if ($lang == "ru" ) { $_SESSION["language"] = "ru"; }
else if ($lang == "en" ) { $_SESSION["language"] = "en"; }
$config->global = $config->dir.$_SESSION['lang']."/language.php";
include ($config->global);
?>

Edited by MakaTaNaw
Link to comment
Share on other sites

<?php
session_start();

$languages = array(
			'lv',
			'en',
			'ru'
		);

if(!empty($_GET['lang']) && in_array($_GET['lang'], $languages))  $_SESSION['lang'] = $_GET['lang'];

$lang = (!empty($_SESSION['lang'])) ? $_SESSION['lang'] : 'lv';

var_dump($lang);
?>

Link to comment
Share on other sites

Es īsti neizprotu, ko tu tur mudries ar to klases definīciju, bet vai to vispār vajag ?

 

<?php
session_start();

$allowed_lang = array(
 'en', 'lv', 'ru'
);

if (isset($_GET['lang']) && in_array($_GET['lang'], $allowed_lang)) {
 $_SESSION['LANG'] = $_GET['lang'];
} elseif (!isset($_SESSION['LANG'])) {
 $_SESSION['LANG'] = 'en';
}

require('lang/'.$_SESSION['LANG'].'.php');
?>

Edited by andrisp
Link to comment
Share on other sites

×
×
  • Create New...