30 lines
831 B
PHP
30 lines
831 B
PHP
|
<?php
|
||
|
defined('BASEPATH') OR exit('No direct script access allowed');
|
||
|
|
||
|
class Lang extends MY_Controller
|
||
|
{
|
||
|
public function __construct()
|
||
|
{
|
||
|
parent::__construct();
|
||
|
$this->load->helper('url');
|
||
|
$this->load->helper('cookie');
|
||
|
}
|
||
|
|
||
|
function change($lang = "en")
|
||
|
{
|
||
|
if (isset($_GET['r']) && !empty($_GET['r'])) {
|
||
|
$url = urldecode(base64_decode($_GET['r']));
|
||
|
} else {
|
||
|
$url = base_url();
|
||
|
}
|
||
|
if (in_array($lang, ['de', 'en', 'fr'])) {
|
||
|
$this->session->set_userdata('site_lang', $lang);
|
||
|
setcookie('language', $lang, time() + 7776000, '/');
|
||
|
} else {
|
||
|
$this->session->set_userdata('site_lang', 'en');
|
||
|
setcookie('language', 'en', time() + 7776000, '/');
|
||
|
}
|
||
|
redirect($url);
|
||
|
}
|
||
|
}
|