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