Example #1
0
// of a mess because of the session handling stuff..
if (isset($_REQUEST['var_lang_lcm'])) {
    // ex: bg, fr, en, en_uk, etc. nothing else is accepted
    if (preg_match("/^[_A-Za-z]+[0-9]*\$/", $_REQUEST['var_lang_lcm'])) {
        include_lcm('inc_lang');
        include_lcm('inc_session');
        $new_lang = clean_input($_REQUEST['var_lang_lcm']);
        $valid_author = verifier_visiteur();
        if (lcm_set_language($new_lang)) {
            lcm_setcookie('lcm_lang', $new_lang, time() + 365 * 24 * 3600);
            // Save language preference only if we are installed and if author connected
            if ($valid_author && include_config_exists('inc_connect')) {
                include_lcm('inc_admin');
                lcm_query("UPDATE lcm_author \n\t\t\t\t\t\tSET lang = '" . $new_lang . "' \n\t\t\t\t\t\tWHERE id_author = " . $GLOBALS['author_session']['id_author']);
                $author_session['lang'] = $new_lang;
                lcm_add_session($author_session, $_COOKIE['lcm_session']);
            } else {
                lcm_log("Not valid_author ({$valid_author}) or not yet installed");
            }
            $cible->delvar('lang');
            $cible->addvar('lang', $new_lang);
        } else {
            lcm_log("lcm_set_language() is not happy, wrong lang code?");
        }
    }
}
// Redirection
// Under Apache, cookies with a redirection work
// Else, we do a HTTP refresh
if (ereg("^Apache", $_SERVER['SERVER_SOFTWARE'])) {
    @header("Location: " . $cible->getUrlForHeader());
Example #2
0
function creer_cookie_session($author)
{
    if ($id_author = $author['id_author']) {
        $id_session = $id_author . '_' . md5(create_uniq_id());
        $author['hash_env'] = hash_env();
        lcm_add_session($author, $id_session);
        return $id_session;
    }
}