AKB Forums

Go Back   AKB Forums > Technical sections > Languages, Compilers and Interpreters > Web Development
Home Register Blogs FAQ Members List Calendar Downloads Arcade Mark Forums Read

Web Development Java/PHP/Perl/ASP and more

Troubles when posting message? Click here! :: Проблемы с отправлением сообщения? Нажмите сюда!

Reply
 
LinkBack Thread Tools Display Modes
Old May 10, 2007, 19:10   #1
I Love BMW!
 
ExtremeSM's Avatar
 
Join Date: Nov 2006
Location: reload();
Posts: 63
Rep Power: 0
Reputation: 10
Question session_start(); problem

<?php
session_start();
$lang = $_SESSION["lang"];
if (!$lang) {$lang = $_GET['lang'];}
if ($lang == "ru") {
require("./data/languages/ru.php");
$_SESSION["lang"] = "ru";
}
else{
require("./data/languages/en.php");
$_SESSION["lang"] = "en";
}
?>

joxovurt jan ogneq eli, esor inch vor uxexs anjatvaca chem jogum vonc karelia dzel?
uzum em vor skzbic nayi lang ete ka session-i mech stana "ru"-a te "en", ete chka session-i mech get methodov vekali arjeq@ lang-i u gri session-i mej vor myus ejerum mna et en-@ kam ru-n... hima problems nranuma, vor mi angam inq@ mtav get metodov vekalec asenq ru arjeq@, grec sessioni mej, baic heto vor grum em ?lang=en arden chi poxum, mnuma hin session@ =\ vonc karelia dzel?
__________________
http://megauploader.net/ ------ new designed, new engine powered now still free, fast and without registration...
ExtremeSM is offline   Reply With Quote Quote selected
Old May 10, 2007, 19:57   #2
Дошкольник
 
Join Date: Oct 2004
Location: Yerevan
Posts: 116
Rep Power: 4
Reputation: 12
Send a message via ICQ to Intel
PHP Code:
<?php 
session_start
(); 
$lang $_SESSION['lang']; 

if(empty(
$lang)) 
{
    switch(
$_GET['lang'])
    {
        case 
"ru":
            
$_SESSION['lang'] = "ru";
            break;

        default:
            
$_SESSION['lang'] = "en";
            break;
    }

?>
Please test it.
Intel is offline   Reply With Quote Quote selected
Old May 10, 2007, 20:03   #3
I Love BMW!
 
ExtremeSM's Avatar
 
Join Date: Nov 2006
Location: reload();
Posts: 63
Rep Power: 0
Reputation: 10
may I ask? Inchna break anum ete cikl chka? O.o
__________________
http://megauploader.net/ ------ new designed, new engine powered now still free, fast and without registration...
ExtremeSM is offline   Reply With Quote Quote selected
Old May 10, 2007, 20:12   #4
I Love BMW!
 
ExtremeSM's Avatar
 
Join Date: Nov 2006
Location: reload();
Posts: 63
Rep Power: 0
Reputation: 10
так я и думал... чашхатец ((( тарс ора есор
__________________
http://megauploader.net/ ------ new designed, new engine powered now still free, fast and without registration...
ExtremeSM is offline   Reply With Quote Quote selected
Old May 10, 2007, 20:30   #5
Easy rider
 
Silver's Avatar
 
Join Date: Nov 2005
Location: tristeza
Posts: 1,087
Rep Power: 3
Reputation: 10
Send a message via ICQ to Silver
ExtremeSM, qo logikan a sxal.

Hly karda ushadir inch es grel`

Quote:
uzum em vor skzbic nayi lang ete ka session-i mech stana "ru"-a te "en", ete chka session-i mech get methodov vekali arjeq@ lang-i u gri session-i mej vor myus ejerum mna et en-@ kam ru-n...
1. Skzbic nayec lang ka sessioni mej te che
2. Ka (qani vor naxord requestic arden set er exel)
3. Hetevabar $_GET['lang']-y arden chi ditarkvum, qani vor du inqd es uzum vor`

Quote:
ete ka session-i mech stana "ru"-a te "en", ete chka session-i mech get methodov vekali arjeq@ lang-i u gri session-i mej
__________________




You must spread before giving to Silver again.
Silver is offline   Reply With Quote Quote selected
Old May 10, 2007, 20:39   #6
Easy rider
 
Silver's Avatar
 
Join Date: Nov 2005
Location: tristeza
Posts: 1,087
Rep Power: 3
Reputation: 10
Send a message via ICQ to Silver
Quote:
Originally Posted by ExtremeSM View Post
may I ask? Inchna break anum ete cikl chka? O.o

http://am.php.net/manual/en/control-...ures.break.php

Quote:
break ends execution of the current for, foreach, while, do-while or switch structure.

break accepts an optional numeric argument which tells it how many nested enclosing structures are to be broken out of.
__________________




You must spread before giving to Silver again.
Silver is offline   Reply With Quote Quote selected
Old May 10, 2007, 20:51   #7
I Love BMW!
 
ExtremeSM's Avatar
 
Join Date: Nov 2006
Location: reload();
Posts: 63
Rep Power: 0
Reputation: 10
Silver jan, vabsheto es el tenc heto mtaceci, uxxaki asum em uxexs anjatvaca hima...
baic stacvec voncvor, tu-tu-tu achkov chtanq

<?php
session_start();
if (!$_GET["lang"]) {$lang = $_SESSION["lang"];}
else {$lang = $_GET["lang"];} //STEX VOR ELSE AVELACRI EXAV =)))))))

if ($lang == "ru") {
require("./data/languages/ru.php");
$_SESSION["lang"] = "ru";
}
else{
require("./data/languages/en.php");
$_SESSION["lang"] = "en";
}
?>
__________________
http://megauploader.net/ ------ new designed, new engine powered now still free, fast and without registration...
ExtremeSM is offline   Reply With Quote Quote selected
Old May 10, 2007, 21:05   #8
наивная дурочка
 
TasteMyLipstick's Avatar
 
Join Date: Oct 2005
Location: бродяжка я
Posts: 197
Rep Power: 3
Reputation: 35
Send a message via ICQ to TasteMyLipstick
PHP Code:
<?php
session_start
();
$a_languages = array('en''ru');
$lang '';

if (isset(
$_GET['lang']) && in_array($_GET['lang'], $a_languages)) {
    
$_SESSION["lang"] = $_GET['lang'];
}
else if (isset(
$_SESSION["lang"]) && in_array($_SESSION["lang"], $a_languages)) {
}
else {
    
$s_lang "";
    foreach(
$a_languages as $language) {
        
$s_lang .= " <a href=\"?lang=$language\">$language</a>\r\n";
    }
    exit(
"Choose your language$s_lang");
};

$lang $_SESSION["lang"];
require(
"./data/languages/$lang.php");
?>
__________________
Я поняла, любовь - страна, Где каждый человек - притворщик.

Last edited by TasteMyLipstick : May 14, 2007 at 00:02.
TasteMyLipstick is offline   Reply With Quote Quote selected
Old May 10, 2007, 21:07   #9
Easy rider
 
Silver's Avatar
 
Join Date: Nov 2005
Location: tristeza
Posts: 1,087
Rep Power: 3
Reputation: 10
Send a message via ICQ to Silver
Here's an (IMHO) better way of writing the same thing:

PHP Code:
<?php
    session_start
();

    
$lang = (isset($_GET['lang']) ? $_SESSION['lang'] : $_GET['lang'];


    if (
language_exists($lang))
    {
        require(
'./data/languages/' $lang '.php');
        
$_SESSION['lang'] = $lang;
    }
?>
And there still are security issues I guess.
__________________




You must spread before giving to Silver again.
Silver is offline   Reply With Quote Quote selected
Old May 12, 2007, 04:25   #10
I Love BMW!
 
ExtremeSM's Avatar
 
Join Date: Nov 2006
Location: reload();
Posts: 63
Rep Power: 0
Reputation: 10
TasteMyLipstick -i dzev@ shat bard er, наверное это не для меня О.о

Silver jan, prosto vor ashxatuma, el haves chka dzer talu, baic qo asac dzev@ aveli sirun dzev er.

P.S.
$lang = (isset($_GET['lang']) ? $_SESSION['lang'] : $_GET['lang'];

es tox@ chisht em haskacel?
?-@ nshanakuma, vor stugi ete lang-@ get metodov arden tvaca, uremn pahi session-um, ete che, vekali henc get-ic ha? =)
__________________
http://megauploader.net/ ------ new designed, new engine powered now still free, fast and without registration...
ExtremeSM is offline   Reply With Quote Quote selected
Old May 12, 2007, 06:22   #11
I Love BMW!
 
ExtremeSM's Avatar
 
Join Date: Nov 2006
Location: reload();
Posts: 63
Rep Power: 0
Reputation: 10
En im dzevov arden exav qceci serveri vra arden, baic mi harc unem, vonc en poxum "input type=file"-i "browse" grac@??? vabshe hnaravora?
__________________
http://megauploader.net/ ------ new designed, new engine powered now still free, fast and without registration...
ExtremeSM is offline   Reply With Quote Quote selected
Old May 12, 2007, 06:43   #12
йес эм эли...
 
Mesrop's Avatar
 
Join Date: Feb 2005
Location: near the computer
Posts: 3,151
Rep Power: 4
Reputation: 60
Send a message via ICQ to Mesrop Send a message via AIM to Mesrop Send a message via MSN to Mesrop Send a message via Yahoo to Mesrop Send a message via Skype™ to Mesrop
Quote:
Originally Posted by ExtremeSM View Post
En im dzevov arden exav qceci serveri vra arden, baic mi harc unem, vonc en poxum "input type=file"-i "browse" grac@??? vabshe hnaravora?
inchqan jogelem dzev chi... baysde hnaravora vor javascriptov, css-ov miban stasvi
Mesrop is offline   Reply With Quote Quote selected
Old May 12, 2007, 07:31   #13
Дошкольник
 
Join Date: Oct 2004
Location: Yerevan
Posts: 116
Rep Power: 4
Reputation: 12
Send a message via ICQ to Intel
If it's not required to use $lang:

PHP Code:
if(isset($_GET['lang']))
{
    if(
language_exists($_GET['lang']))
    {
        
$_SESSION['lang'] = $_GET['lang'];
    }
}

require(
'./data/languages/' $_SESSION['lang'] . '.php'); 
Anyway, you must keep session scope clean to have it reliable, so it should be safe to include $_SESSION['lang'].php;
Also you may provide more detailed error reporting, this way.
Intel is offline   Reply With Quote Quote selected
Old May 12, 2007, 11:41   #14
I Love BMW!
 
ExtremeSM's Avatar
 
Join Date: Nov 2006
Location: reload();
Posts: 63
Rep Power: 0
Reputation: 10
tnx lol
tencel kporcem teche eli inch vor sksec tvarutyunner anel kods =\
__________________
http://megauploader.net/ ------ new designed, new engine powered now still free, fast and without registration...
ExtremeSM is offline   Reply With Quote Quote selected
Old May 12, 2007, 16:02   #15
I Love BMW!
 
ExtremeSM's Avatar
 
Join Date: Nov 2006
Location: reload();
Posts: 63
Rep Power: 0
Reputation: 10
joxovurt lav mi kerp "на соплях" ashxatuma, baic mi ban mnac, vonc et browse-@ anem? luboj dzevov, css-ov JS-ov, vor gri Обзор kam mi ban urish?
__________________
http://megauploader.net/ ------ new designed, new engine powered now still free, fast and without registration...
ExtremeSM is offline   Reply With Quote Quote selected
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
NHibernate: Problem with Configuration Intel Languages, Compilers and Interpreters 0 Mar 4, 2007 07:49
Georgiy Marganatis - No Problem!!! Rub MusiCity 0 Nov 9, 2006 23:27
PROBLEM: Unicode URLs Silver Web Development 1 Feb 27, 2006 05:42
Internet Problem !!! KarenN Software 2 Dec 22, 2005 10:46
Dial-up yahoo-mail access problem Tropical General 1 Nov 12, 2005 21:22


All times are GMT. The time now is 21:21.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
This board was founded on September 29, 2001
Powered by Viper Internet

Affordable Web Hosting | ParevNet

Buy text link