One more question: May I somehow save the lang-setting for the visitor - so he gets the same language when visiting the page next time (well, unless he doesn't delete his cookies) I guess I saw such a topic here on the forum, but can't re-find that
its possible, try this:
in global.php find:
4images v1.7:
if (isset($HTTP_GET_VARS['l']) || isset($HTTP_POST_VARS['l'])) {
$l = (isset($HTTP_GET_VARS['l'])) ? trim($HTTP_GET_VARS['l']) : trim($HTTP_POST_VARS['l']);
if (file_exists(ROOT_PATH.'lang/'.$l.'/main.php')) {
$config['language_dir'] = $l;
}
}
4images v1.7.x:
if (isset($HTTP_GET_VARS['l']) || isset($HTTP_POST_VARS['l'])) {
$requested_l = (isset($HTTP_GET_VARS['l'])) ? trim($HTTP_GET_VARS['l']) : trim($HTTP_POST_VARS['l']);
if ($requested_l != $config['language_dir'] && file_exists(ROOT_PATH.'lang/'.$requested_l.'/main.php')) {
$l = $requested_l;
$config['language_dir'] = $l;
}
}
Replace it with:
if (isset($HTTP_GET_VARS['l']) || isset($HTTP_POST_VARS['l'])) {
$requested_l = (isset($HTTP_GET_VARS['l'])) ? trim($HTTP_GET_VARS['l']) : trim($HTTP_POST_VARS['l']);
if (!preg_match('#\.\.[\\\/]#', $requested_l) && file_exists(ROOT_PATH.'lang/'.$requested_l.'/main.php'))
{
if ($requested_l != $config['language_dir'])
{
$l = $requested_l;
}
$config['language_dir'] = $requested_l;
setcookie('4images_lang', $requested_l, (time()+ 60 * 60 * 24 * 365), "/", "", 0);
}
}
else
{
if (isset($HTTP_COOKIE_VARS['4images_lang']) && !preg_match('#\.\.[\\\/]#', $HTTP_COOKIE_VARS['4images_lang']) && file_exists(ROOT_PATH.'lang/'.trim($HTTP_COOKIE_VARS['4images_lang']).'/main.php'))
{
$l = $config['language_dir'] = trim($HTTP_COOKIE_VARS['4images_lang']);
}
}
define("LANG_URL", !(isset($HTTP_COOKIE_VARS['4images_lang']) && trim($HTTP_COOKIE_VARS['4images_lang']) == $config['language_dir']));
And if u are using version
B of this mod, then replace in includes/page_header.php
$lang_select .= "<a class=\"lang\" href=\"".$lang_url.(preg_match("/english/i",$folder) ? "" : ((preg_match("/\?/", $lang_url) ? "&" : "?")."l=".$folder))."\" onMouseOver=\"(window.status='$folder'); return true\" onMouseOut=\"window.status=''; return true\"><img src=\"".TEMPLATE_PATH."/images/".$folder.".gif\" border=\"0\" alt=\"".$folder."\"></a> ";
with this:
$lang_select .= "<a class=\"lang\" href=\"".$lang_url.(preg_match("/\?/", $lang_url) ? "&" : "?")."l=".$folder."\" onMouseOver=\"(window.status='$folder'); return true\" onMouseOut=\"window.status=''; return true\"><img src=\"".TEMPLATE_PATH."/images/".$folder.".gif\" border=\"0\" alt=\"".$folder."\"></a> ";
If you don't want always see l=blah in the url, then in includes/sessions.php find:
if (!empty($l)) {Replace it with:
if (!empty($l) && LANG_URL) {
P.S.
I've updated the code to include the
security fixFor these who installed this mod before, you'll need find and replace this block in global.php:
if (isset($HTTP_GET_VARS['l']) || isset($HTTP_POST_VARS['l'])) {
$l = (isset($HTTP_GET_VARS['l'])) ? trim($HTTP_GET_VARS['l']) : trim($HTTP_POST_VARS['l']);
if (file_exists(ROOT_PATH.'lang/'.$l.'/main.php')) {
$config['language_dir'] = $l;
setcookie('4images_lang', $l, (time()+ 60 * 60 * 24 * 365), "/", "", 0);
}
}
else
{
if (isset($HTTP_COOKIE_VARS['4images_lang']) && file_exists(ROOT_PATH.'lang/'.$HTTP_COOKIE_VARS['4images_lang'].'/main.php'))
{
$l = $config['language_dir'] = $HTTP_COOKIE_VARS['4images_lang'];
}
}