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  
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 12, 2007, 16:45   #16
Дошкольник
 
Join Date: Oct 2004
Location: Yerevan
Posts: 116
Rep Power: 5
Reputation: 12
Send a message via ICQ to Intel
AFAIK, there's no ordinary way to do that, but there are few workarounds available.

Ask Google about: "Browse Button CSS".

Good luck and productive research.
Intel is offline   Reply With Quote Quote selected
Old May 12, 2007, 18:19   #17
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 12, 2007, 19:38   #18
йес эм эли...
 
Mesrop's Avatar
 
Join Date: Feb 2005
Location: near the computer
Posts: 3,203
Rep Power: 4
Reputation: 89
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
хмм... ок сенкс, даже и не подумал чето прогуглить...

П.С.
А что значит АФАИК? О.о
Quote:
AFAIK - As Far As I Know - насколько мне известно
...
Mesrop is offline   Reply With Quote Quote selected
Old May 12, 2007, 20:22   #19
наивная дурочка
 
TasteMyLipstick's Avatar
 
Join Date: Oct 2005
Location: бродяжка я
Posts: 197
Rep Power: 3
Reputation: 35
Send a message via ICQ to TasteMyLipstick
Quote:
Originally Posted by Silver View Post
Here's an (IMHO) better way of writing the same thing:

And there still are security issues I guess.
If you mean script injection, I prevented it in the following line "...&& in_array($_GET['lang'], $a_languages)" for both $_SESSION and $_GET arrays.
__________________
Я поняла, любовь - страна, Где каждый человек - притворщик.
TasteMyLipstick is offline   Reply With Quote Quote selected
Old May 13, 2007, 04:00   #20
Дошкольник
 
Join Date: Oct 2004
Location: Yerevan
Posts: 116
Rep Power: 5
Reputation: 12
Send a message via ICQ to Intel
As I've mentioned previously, there's no need to check session vars(because like the database records, session variables and their values must be formed by the script, unlike variables coming from request), except that your code is almost unreadable, and less flexible.
Intel is offline   Reply With Quote Quote selected
Old May 13, 2007, 08:01   #21
Easy rider
 
Silver's Avatar
 
Join Date: Nov 2005
Location: tristeza
Posts: 1,085
Rep Power: 3
Reputation: 10
Send a message via ICQ to Silver
Intel, my code is almost unreadable?!
Dude!!!
__________________




You must spread before giving to Silver again.
Silver is offline   Reply With Quote Quote selected
Old May 13, 2007, 15:27   #22
Дошкольник
 
Join Date: Oct 2004
Location: Yerevan
Posts: 116
Rep Power: 5
Reputation: 12
Send a message via ICQ to Intel
No, I meant her code, not yours ;-)
Intel is offline   Reply With Quote Quote selected
Old May 14, 2007, 00:13   #23
наивная дурочка
 
TasteMyLipstick's Avatar
 
Join Date: Oct 2005
Location: бродяжка я
Posts: 197
Rep Power: 3
Reputation: 35
Send a message via ICQ to TasteMyLipstick
Quote:
Originally Posted by Intel View Post
As I've mentioned previously, there's no need to check session vars(because like the database records, session variables and their values must be formed by the script, unlike variables coming from request), except that your code is almost unreadable, and less flexible.
What is less flexible about my code? I'd say it's much more flexible than yours, where you used switch case operators for checking the value of every single language. I think it's not so smart to do so.
__________________
Я поняла, любовь - страна, Где каждый человек - притворщик.
TasteMyLipstick is offline   Reply With Quote Quote selected
Old May 14, 2007, 07:25   #24
Easy rider
 
Silver's Avatar
 
Join Date: Nov 2005
Location: tristeza
Posts: 1,085
Rep Power: 3
Reputation: 10
Send a message via ICQ to Silver
TasteMyLipstick, switch IMHO is better than if -> elseif -> elseif -> elseif -> else.
__________________




You must spread before giving to Silver again.
Silver is offline   Reply With Quote Quote selected
Old May 14, 2007, 07:25   #25
Easy rider
 
Silver's Avatar
 
Join Date: Nov 2005
Location: tristeza
Posts: 1,085
Rep Power: 3
Reputation: 10
Send a message via ICQ to Silver
Any code is 100% flexible if you can edit it
__________________




You must spread before giving to Silver again.
Silver is offline   Reply With Quote Quote selected
Old May 14, 2007, 12:32   #26
Дошкольник
 
Join Date: Oct 2004
Location: Yerevan
Posts: 116
Rep Power: 5
Reputation: 12
Send a message via ICQ to Intel
Quote:
Originally Posted by TasteMyLipstick View Post
What is less flexible about my code?
Theoretically, for example you can't control, if the $_GET['lang'] is defined, or not. You may only surmise, starting from isset($_GET['lang']) conjunct with in_array($_GET['lang'], $a_languages).
Quote:
Originally Posted by TasteMyLipstick View Post
I'd say it's much more flexible than yours, where you used switch case operators for checking the value of every single language. I think it's not so smart to do so.
Well, it's not a big deal, I think. Assuming that:
First of all, the count of languages is finite, and in handsome majority of cases not greater than 2 or 3. So probably our switch structure will not grow up so much.
Secoundly, you may perform custom actions different for each language.

In addition:
Your code contains useless assignings, checks, script termination, also it outputs HTML code(which, I suppose, is very rough for back-end layer) ...
Intel 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 19:12.


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