<?php
class Settings extends Controller
{
	function Settings()
	{
		parent::Controller();
	}
	
	function lang()
	{
		$lang = $this->uri->segment(3);
		
		if($lang == 'hun')
		{
			$this->muser->user['lang']='hun';
		}
		elseif($lang == 'jap')
		{
			$this->muser->user['lang']='jap';
		}
		elseif($lang == 'gr')
		{
			$this->muser->user['lang']='gr';
		}
		elseif($lang == 'cr')
		{
			$this->muser->user['lang']='cr';
		}
		elseif($lang == 'be')
		{
			$this->muser->user['lang']='be';
		}
		elseif($lang == 'pol')
		{
			$this->muser->user['lang']='pol';
		}
		elseif($lang == 'esp')
		{
			$this->muser->user['lang']='esp';
		}
		else
		{
			$this->muser->user['lang']='eng';
		}
		
		unset($this->muser->user['admin']);
		unset($this->muser->user['admin_lang']);
		
		$this->phpsession->save('user',$this->muser->user);
		redirect('');
		
		/*
		$data['betolt']='';
		$this->load->view('redirect/index',$data);
		*/
		
	}
	
	function lang2(){
		$lang = $this->uri->segment(3);
		
		if($lang == 'hun')
		{
			$this->muser->user['lang']='hun';
		}
		elseif($lang == 'jap')
		{
			$this->muser->user['lang']='jap';
		}
		elseif($lang == 'gr')
		{
			$this->muser->user['lang']='gr';
		}
		elseif($lang == 'cr')
		{
			$this->muser->user['lang']='cr';
		}
		elseif($lang == 'be')
		{
			$this->muser->user['lang']='be';
		}
		elseif($lang == 'pol')
		{
			$this->muser->user['lang']='pol';
		}
		elseif($lang == 'esp')
		{
			$this->muser->user['lang']='esp';
		}
		else
		{
			$this->muser->user['lang']='eng';
		}
		
		unset($this->muser->user['admin']);
		unset($this->muser->user['admin_lang']);
		
		$this->phpsession->save('user',$this->muser->user);
		redirect('interior/download');
		
	}
	
	function langChange()
	{
		$data['csik']=array('home');
		$data['tartalom']='langchange';
		$this->load->view('site',$data);
	}
	
	function bugtracker_trigger()
	{
		$dir = "/home/cadline/bugtracker/";

		file_exists($dir."dump.sql") ? @unlink($dir."dump.sql") : "" ;
				
		exec("bunzip2 ".$dir."dump.sql.bz2");
		exec("mysql --user=cadline bugtracker < ".$dir."dump.sql");

		file_exists($dir."dump.sql") ? @unlink($dir."dump.sql") : "";
		file_exists($dir."dump.sql.bz2") ? @unlink($dir."dump.sql.bz2") : "";

		file_exists($dir."keydump.sql") ? @unlink($dir."keydump.sql") : "";
				
		exec("bunzip2 ".$dir."keydump.sql.bz2");
		exec("mysql --user=cadline hardlock < ".$dir."keydump.sql");

		file_exists($dir."keydump.sql") ? @unlink($dir."keydump.sql") : "";
		file_exists($dir."keydump.sql.bz2") ? @unlink($dir."keydump.sql.bz2") : "";

		echo date("Y.m.d. h:i").' updated';
	}
	
	function buy_lt()
	{
		$this->load->helper('file');
		
		$count = read_file("lt_counter.txt");
		
		if(!$count)
		{
			$count = 0;
		}
		
		write_file("lt_counter.txt",++$count);
		
		redirect('buy');
		
	}
	
}

?>