sniperzik Posted November 10, 2007 Report Posted November 10, 2007 (edited) 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 November 10, 2007 by sniperzik
Kavacky Posted November 10, 2007 Report Posted November 10, 2007 Jo superglobālais mainīgais saucas $_SESSION?
Vebers Posted November 11, 2007 Report Posted November 11, 2007 Un nespieciešams vēl skripta sākumā session_start()
sniperzik Posted November 11, 2007 Author Report Posted November 11, 2007 (edited) Bet kad es ielieku session start() man nomaina valodu un atpakaļ nemaina :( Edited November 11, 2007 by sniperzik
andrisp Posted November 11, 2007 Report Posted November 11, 2007 (edited) $SESSION uz $_SESSION vispār izmainīji ? Un vispār - tas session_start() ir obligāts. Edited November 11, 2007 by andrisp
sniperzik Posted November 12, 2007 Author Report Posted November 12, 2007 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!
Vebers Posted November 12, 2007 Report Posted November 12, 2007 (edited) 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 November 12, 2007 by MakaTaNaw
sniperzik Posted November 13, 2007 Author Report Posted November 13, 2007 Neiet :( man liekas ka shis nav istais paņēmiens varat ieteikt kādu labāku!? Paldies visiem!
Vebers Posted November 13, 2007 Report Posted November 13, 2007 <?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); ?>
andrisp Posted November 13, 2007 Report Posted November 13, 2007 (edited) 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 November 13, 2007 by andrisp
blackhalt Posted November 13, 2007 Report Posted November 13, 2007 Ar cepumiem arī var: http://lv.php.net/manual/en/features.cookies.php
sniperzik Posted November 14, 2007 Author Report Posted November 14, 2007 Liels, liels PALDIES visiem! Esmu ļoti pateicīgs. Viss beidzot strādā :)
Recommended Posts