Initial commit as of 2018-10-16
This commit is contained in:
29
application/controllers/Lang.php
Normal file
29
application/controllers/Lang.php
Normal file
@@ -0,0 +1,29 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user