<?php
class Events extends Controller{
    function __construct(){
		parent::Controller();
        $this->load->model('mevents');
        //loading library for current date display
        $this->load->library('dateclass');
	}
    
    function index(){
		print "index";
    }
    
	// 2011 augusztustol
	function regisztracio(){
		$data['lang']      = $this->muser->user['lang'];
		$data['title']     = hun() ? 'Workshopok - ARCHLine.XP CAD Software' : 'Workshops - ARCHLine.XP CAD Software';
		$data['tartalom']  = 'page/show';
		$data['javascript'] = array('jquery_ui','regformcheck');
		$data['style']      = array('jquery.ui');
		$data['error']      = false;
		
		
		$countries = array();
		$orszagok = $this->db->query('SELECT * FROM `'.CRMADATBAZIS.'`.`countries`')->result_array();
		foreach( $orszagok as $orszag )
			$countries[$orszag['ctrID']] = hun() ? strtolower($orszag['ctrName']) : strtolower($orszag['ctrNameEng']);
		
		
		$post = array();
		
		$post['nev']     = $this->input->post('strName1').' '.$this->input->post('strName2');
		$post['cegnev']  = $this->input->post('strCompany');
		$post['varos']   = $this->input->post('strCity');
		$post['irsz']    = $this->input->post('strZip');
		$post['cim']     = $this->input->post('strStreet');
		$post['tel']     = $this->input->post('strTel');
		$post['email']   = $this->input->post('strEMail');
		
		$post['foglalkozas'] = $this->input->post('nUserProf');
		$post['nctrid']      = array_search(strtolower($this->input->post('ctrName')), $countries);
		
		$post['comment']  = $this->input->post('comment');
		$post['event_id'] = $this->input->post('event_id');
		$post['event_main_id'] = $this->input->post('event_main_id');
		$post['gep']      = $this->input->post('gep');
		$post['parkolo']  = $this->input->post('parkolo');
		
		
		// archline klubos várólistás-e
		if( $post['event_main_id']==56 && substr($post['event_id'],0,3)=="vl_" ){
			$post['event_id'] = substr($post['event_id'],3);
			$post['nolimit'] = true;
		}
		
		if($post['event_id']!="personal" && $post['event_id']!="online" && $post['event_id'] != "eloado")
			$foesemx = $this->db->query("SELECT parkolo FROM events_new_main WHERE event_main_id=".$post['event_main_id'])->row();
			
        if($post['event_id']!="personal" && $post['event_id']!="online" && $post['event_id'] != "eloado")
			$foglaltak = $this->db->query("SELECT sum(gep) as gep, sum(parkolo) as parkolo FROM events_new_registrations WHERE event_id=".$post['event_id']." AND deleted=0")->row();
		else{
			$foglaltak->parkolo = 100;
			$foglaltak->gep     = 100;
		}
		
        // robot szűrés
        if( !$post['email'] || $this->input->post('url') ){
			print "Nem megfelelo adatok! ";
			
			$record->osztaly = "events";
			$record->fv      = "regisztracio";
			$record->hiba    = "Robot? Workshop jelentkezés:";
			foreach($_POST as $k=>$v)
				$record->hiba .= "\n['".$k."'] = ".$v;
            $record->hiba .= "\nIP: ".$_SERVER['REMOTE_ADDR'];
			$record->datum = date('Y-m-d H:i:s',time());
			$this->db->insert('a_hibak',$record);
			
			return;
		}
		
		
		if($post['event_id'] != "online" && $post['event_id'] != "personal" && $post['event_id'] != "eloado" && $error = $this->mevents->eventFormCheck($post, $this->muser->user['lang'])){
			$this->phpsession->save('wshiba',implode('<br />', $error));
			header("Location: ".$_SERVER["HTTP_REFERER"]);
			return;
		}
		
		// kért-e parkolót
		if( hun() && $this->input->post('parkolo') == "on" ){
			$post['parkolo'] = 1;
			$osszhely = $foesemx->parkolo;
			$foglalthelyek = $foglaltak->parkolo;
			// ha nincs üres hely, megszakítás
			if( $foglalthelyek >= $osszhely ){
				$this->phpsession->save('wshiba',"Az Ön által megadott napra már minden parkolóhelyünk foglalt, kérjük, válasszon másik időpontot, vagy sziveskedjék a MOntevideo 5. sz. mélygarázsban parkolni.");
				$this->phpsession->save('wshibaadatok',$post);
				header("Location: ".$_SERVER["HTTP_REFERER"]);
				return;
			}
		}
		
		// kért-e gépet
		if( hun() && $this->input->post('gep') == "on" ){
			$post['gep'] = 1;
			$osszgep = 2;
			$foglaltgepek = $foglaltak->gep;
			// ha nincs üres hely, megszakítás
			if( $foglaltgepek >= $osszgep ){
				$this->phpsession->save('wshiba',"A kiválasztott workshop időpontra már nincs szabad gépünk!");
				header("Location: ".$_SERVER["HTTP_REFERER"]);
				return;
			}
		}
		
		
		//insert registration into the database
		if( $post['event_id'] != "online" && $post['event_id'] != "personal" )
			$result = $this->mevents->EventRegistration($post);
		else
			$result = 'success';
		
		//collecting main event details
		$main_event_details = $this->mevents->getMainEventDetails($post['event_main_id']);
		
		if($result == 'success'){
			$event_details = $this->mevents->getEventDetailsByID($post['event_id']);
			
			if( $post['event_id'] != "online" && $post['event_id'] != "personal" && $post['event_id'] != "eloado" ){
				$event_details = $this->mevents->getEventDetailsByID($post['event_id']);
				$start = date('Y-m-d H:i',$event_details->start_ts);
				$end = date('Y-m-d H:i',$event_details->end_ts);
			}else{
				$event_details->name = $main_event_details->name." - ".$post['event_id'];
				$start = "";
				$end = "";
			}
			
			//collect the event's and user's data for the emails
			$mail_data = array(
				'nev'    => $post['nev'],
				'cegnev' => $post['cegnev'],
				'varos'  => $post['varos'],
				'irsz'   => $post['irsz'],
				'cim'    => $post['cim'],
				'tel'    => $post['tel'],
				'email'  => $post['email'],
				'comment' => $post['comment'],
				'start'  => $start,
				'end'    => $end,
				'event_details' => $event_details,
				'main_event_details' => $this->mevents->getMainEventDetails($post['event_main_id'])
			);
			
			//send an email to cadline
			$this->load->library('email');
			$this->email->initialize();
			$this->email->from('info@cadline.hu', 'Cadline Weboldal');
			$this->email->subject($main_event_details->name.' Registration');
			$this->email->message($this->load->view('events/mail/reg_success_to_cadline', $mail_data, true));
			
			if(hun())
				$this->email->send('info@cadline.hu', 'smtp');
			else
				$this->email->send('info@archlinexp.com', 'smtp');
		//	$this->email->send('eszter@cadline.hu', 'smtp');
			$this->email->clear();
			
			//send an email to the registered user
			$this->load->model('mclusers');
			if( $post['event_id'] == "online" ){
				if(hun())
					$page = $this->mpages->get_row(611);
				else{
					$page = $this->mpages->get_row(610);
					
					
					$email = $post['email'];
					
					$egyezes = "klkájkl".rand(2222222);
					$info = "Online WS kérés".", téma: ".$main_event_details->name;
					if($post['comment'] != "")
						$info .= ", komment: ".$post['comment'];
					
					if(UJUGYFELKEZELO===true)
						$this->mclusers->levelesemeny($email, "events", "regisztracio", 190, $egyezes, $info, "eng", $info);
					else
						$this->mclusers->levelesemeny($email, "events", "regisztracio", 149, $egyezes, $info, "eng", $info);
				}
			}
			elseif( $post['event_id'] == "personal" )
			{
				$info = "WS kérés: ".$event_details->name." ".mysql_escape_string($post['comment']);
				$datum = date('Y-m-d', time());
				
				if(hun()){
					if($post['event_main_id']==56){
						$page = $this->mpages->get_row(746);
						$nTopicID = (UJUGYFELKEZELO===true) ? 5 : 161;
						$info .= " Javasolt tema: ".$this->input->post('ujtema');
					}
					else{
						$page = $this->mpages->get_row(613);
						$nTopicID = 121;
					}
					
					$nUserID = $this->mclusers->get_nUserIDByEmail($post['email'],'hun');
					
					if(!$nUserID){
						$tomb['strName']    = $post['nev'];
						$tomb['strCompany'] = $post['cegnev'];
						$tomb['strCity']    = $post['varos'];
						$tomb['strZip']     = $post['irsz'];
						$tomb['strStreet']  = $post['cim'];
						$tomb['strMobil']   = $post['tel'];
						$tomb['nUserProf']  = $post['foglalkozas'];
						$tomb['nCtrID']     = $post['nctrid'];
						$nUserID = $this->mclusers->addUserHun($tomb);
						
						$tomb2['nUserID'] = $nUserID;
						$tomb2['email']   = $post['email'];
						$this->mclusers->addUserEmailHun($tomb2);
					}
					
					$query .= "INSERT INTO `".CRMADATBAZIS."`.`u_history` VALUES (NULL,{$nUserID},{$nTopicID},'{$datum}','web','{$info}', 36, '', '', NULL, NULL, NULL)";
					
					$this->db->query($query);
					
				}else{
					$page = $this->mpages->get_row(612);
					
					$nUserID = $this->mclusers->get_nUserIDByEmail($post['email'],'eng');
					
					if(!$nUserID){
						$tomb['strName']    = $post['nev'];
						$tomb['strCompany'] = $post['cegnev'];
						$tomb['strCity']    = $post['varos'];
						$tomb['strZip']     = $post['irsz'];
						$tomb['strStreet']  = $post['cim'];
						$tomb['strTel']     = $post['tel'];
						$tomb['nUserProf']  = $post['foglalkozas'];
						$tomb['nCtrID']     = $post['nctrid'];
						$nUserID = $this->mclusers->addUserEng($tomb);
						
						$tomb2['nUserID'] = $nUserID;
						$tomb2['email']   = $post['email'];
						$this->mclusers->addUserEmailEng($tomb2);
					}
					
					if(UJUGYFELKEZELO===true)
						$query = "INSERT INTO `".CRMADATBAZIS."`.`u_history` VALUES (NULL,{$nUserID},223,'{$datum}','web','{$info}', 36, '', '', NULL, NULL, NULL)";
					else
						$query .= "INSERT INTO `clusers_eng`.`cl_history` VALUES (NULL, ".$nUserID.", 138, '{$datum}', 'web', '{$info}', 0)";
		
					$this->db->query($query);
				}
			}
			elseif( $post['event_id'] == "eloado" ){
				$page = hun() ? $this->mpages->get_row(773) : $this->mpages->get_row(838);
				
				$email = $post['email'];
				
				$egyezes = "klkájkl".rand(2222222);
				$info = "AL Klub előadó ";
				if($post['comment'] != "")
					$info .= "komment: ".$post['comment'];
				$info2 = $info.print_r($mail_data,true);
				
				$nTopicID = hun() ? 3 : 278;
				
				$this->mclusers->levelesemeny($email, "events", "regisztracio", $nTopicID, $egyezes, $info, "hun", $info2);
			}
			else
			{
				if( hun() && $main_event_details->reg_success_mail_page==578 ){
					// parkoló nem, pc nem
					if( $post['parkolo']!=1 && $post['gep']!=1 )
						$page = $this->mpages->get_row(735);
					
					// parkoló nem, pc igen
					if( $post['parkolo']!=1 && $post['gep']==1 )
						$page = $this->mpages->get_row(738);
					
					// parkoló igen, pc nem
					if( $post['parkolo']==1 && $post['gep']!=1 )
						$page = $this->mpages->get_row(736);
					
					// parkoló igen, pc igen
					if( $post['parkolo']==1 && $post['gep']==1 )
						$page = $this->mpages->get_row(737);
				}elseif($post['event_main_id']==56 && isset($post['nolimit']) && $post['nolimit']===true){
					$page = $this->mpages->get_row(747);
				}
				else{
					$page = $this->mpages->get_row($main_event_details->reg_success_mail_page);
				}
				$info = "(web) ".mysql_escape_string($post['comment']);
				if($this->input->post('sz_nev') || $this->input->post('sz_varos') || $this->input->post('sz_irsz') || $this->input->post('sz_cim'))
					$info .= ", Számlázási adatok: ".$this->input->post('sz_nev')." ".$this->input->post('sz_varos')." ".$this->input->post('sz_irsz')." ".$this->input->post('sz_cim');
				if( $this->input->post('al_javaslat'=="on") || $this->input->post('ujtema') != "" ){
					$info .= " Javasolt téma: ".$this->input->post('ujtema');
				}
				
				$datum = date('Y-m-d', $event_details->start_ts);
				
				if(hun()){
					$nUserID = $this->mclusers->get_nUserIDByEmail($post['email'],'hun');
					
					if(!$nUserID){
						$tomb['strName']    = $post['nev'];
						$tomb['strCompany'] = $post['cegnev'];
						$tomb['strCity']    = $post['varos'];
						$tomb['strZip']     = $post['irsz'];
						$tomb['strStreet']  = $post['cim'];
						$tomb['strTel']     = $post['tel'];
						$tomb['nUserProf']  = $post['foglalkozas'];
						$tomb['nCtrID']     = $post['nctrid'];
						$nUserID = $this->mclusers->addUserHun($tomb);
						
						$tomb2['nUserID'] = $nUserID;
						$tomb2['email']   = $post['email'];
						$this->mclusers->addUserEmailHun($tomb2);
					}
					
					if(isset($post['parkolo']) && $post['parkolo']>0)
						$info .= " , Kért parkolóhelyet";
					
					if(isset($post['gep']) && $post['gep']>0)
						$info .= " , Kért gépet";
					
					if($post['event_main_id']==56 && isset($post['nolimit']) && $post['nolimit']===true){
						$nTopicID = 4;
						$info .= " , jelentkezés ideje: ".date('Y-m-d H:i:s',time());
					}elseif($post['event_main_id']==56)
						$nTopicID = 5;
					else
						$nTopicID = 123;
					
					$info .= " cim: ".$post['irsz']." ".$post['varos'].", ".$post['cim'];
					
					$query = "INSERT INTO `".CRMADATBAZIS."`.`u_history` VALUES (NULL, {$nUserID}, {$nTopicID}, '{$datum}', '{$event_details->name}', '{$info}', 36, '', '', NULL, NULL, NULL)";
		
					$this->db->query($query);
					if( $post['event_main_id']==56 && $this->input->post('al_eloado')=="on" ){
						$query = "INSERT INTO `".CRMADATBAZIS."`.`u_history` VALUES (NULL, ".$nUserID.", 3, '".$datum."', '{$event_details->name}', '".$info."', 36, '', '', NULL, NULL, NULL)";
						$this->db->query($query);
					}
					
					if($post['event_main_id']==56)
						$this->cache->delete('archline-klub-idopontok');
				}else{
					$nUserID = $this->mclusers->get_nUserIDByEmail($post['email'],'eng');
					
					if(!$nUserID){
						$tomb['strName']    = $post['nev'];
						$tomb['strCompany'] = $post['cegnev'];
						$tomb['strCity']    = $post['varos'];
						$tomb['strZip']     = $post['irsz'];
						$tomb['strStreet']  = $post['cim'];
						$tomb['strMobil']   = $post['tel'];
						$tomb['strTel']     = $post['tel'];
						$tomb['nUserProf']  = $post['foglalkozas'];
						$tomb['nCtrID']     = $post['nctrid'];
						$nUserID = $this->mclusers->addUserEng($tomb);
						
						$tomb2['nUserID'] = $nUserID;
						$tomb2['email']   = $post['email'];
						$this->mclusers->addUserEmailEng($tomb2);
					}
					
					$nTopicID = ($post['event_main_id']==63) ? 277 : 226;
					$query = "INSERT INTO `".CRMADATBAZIS."`.`u_history` VALUES (NULL, ".$nUserID.", {$nTopicID}, '".$datum."', '{$event_details->name}', '".$info."', 36, '', '', NULL, NULL, NULL)";
					$this->db->query($query);
					if( $post['event_main_id']==63 && $this->input->post('al_eloado')=="on" ){
						$query = "INSERT INTO `".CRMADATBAZIS."`.`u_history` VALUES (NULL, ".$nUserID.", 278, '".$datum."', '{$event_details->name}', '".$info."', 36, '', '', NULL, NULL, NULL)";
						$this->db->query($query);
					}
					
				}
			}
			
			//change the users name constans in the page body
			$page->page_body = str_ireplace('#reg_name#', $mail_data['nev'], $page->page_body);
			
			// construmásnál időpont
			//$hetnapok = array("hétfő", "kedd", "szerda", "csütörtök", "péntek", "szombat", "vasárnap");
			$hetnapok = lang('napok');
			$ennyiedik = date('N',$event_details->start_ts);
			$hetnap = $hetnapok[($ennyiedik-1)];
			
			$idopontkimenolevelbe = date('Y. m. d. (', $event_details->start_ts);
			$idopontkimenolevelbe .= $hetnap;
			$idopontkimenolevelbe .= date(') - H', $event_details->start_ts);
			$idopontkimenolevelbe .= " óra";
			
			$idopontkimenolevelbe2 = date('Y. m. d. (', $event_details->start_ts);
			$idopontkimenolevelbe2 .= $hetnap;
			$idopontkimenolevelbe2 .= date(')  H:i - ', $event_details->start_ts);
			$idopontkimenolevelbe2 .= date('H:i', $event_details->end_ts);
			
			$esemnevkimenolevelbe = $event_details->name;
			
			$page->page_body = str_ireplace('#idopont#', $idopontkimenolevelbe, $page->page_body);
			$page->page_body = str_ireplace('#idopont2#', $idopontkimenolevelbe2, $page->page_body);
			$page->page_body = str_ireplace('#esemenyneve#',$esemnevkimenolevelbe,$page->page_body);
			
			$this->load->library('email');
			$this->email->initialize();
			if(hun())
				$this->email->from('info@cadline.hu', 'ARCHLine.hu');
			else
				$this->email->from('info@archlinexp.com', 'ARCHLineXP.com');
			$this->email->subject($page->page_title);
			$this->email->message($page->page_body);
			
			$this->email->send($post['email'], 'smtp');
		//	$this->email->send('sztikee@gmail.com', 'smtp');
			
			//get the content of the success page
			$lapid = $main_event_details->reg_success_page;
			$data['cimlap'] = $this->mpages->get_row($lapid);
			$data['cimlap']->page_body = str_ireplace('#reg_name#',$post['nev'],$data['cimlap']->page_body);
		} elseif($result == 'limit') {
			//get the content of the limit page
			$data['cimlap'] = hun() ? $this->mpages->get_row(489) : $this->mpages->get_row(481);
		} elseif($result == 'multiple') {
			//get the content of the multiple registration page
			$data['cimlap'] = hun() ? $this->mpages->get_row(488) : $this->mpages->get_row(482);
		}
		
		$data['tartalom'] = 'events/registration_success';
		
		$this->load->view('site', $data);
	}
	
	
	function csoportosregisztracio(){
		$data['lang']       = $this->muser->user['lang'];
		$data['title']      = hun() ? 'Workshopok - ARCHLine.XP CAD Software' : 'Workshops - ARCHLine.XP CAD Software';
		$data['tartalom']   = 'page/show';
		$data['javascript'] = array('jquery_ui','regformcheck');
		$data['style']      = array('jquery.ui');
		$data['error']      = false;
		
		$countries = array();
		$orszagok = $this->db->query('SELECT * FROM `'.CRMADATBAZIS.'`.`countries`')->result_array();
		foreach( $orszagok as $orszag )
			$countries[$orszag['ctrID']] = hun() ? strtolower($orszag['ctrName']) : strtolower($orszag['ctrNameEng']);
		
		
		$post = array();
		
		$post['nev']     = $this->input->post('strName1').' '.$this->input->post('strName2');
		$post['cegnev']  = $this->input->post('strCompany');
		$post['varos']   = $this->input->post('strCity');
		$post['irsz']    = $this->input->post('strZip');
		$post['cim']     = $this->input->post('strStreet');
		$post['tel']     = $this->input->post('strTel');
		$post['email']   = $this->input->post('strEMail');
		
		$post['foglalkozas'] = $this->input->post('nUserProf');
		$post['nctrid']      = array_search(strtolower($this->input->post('ctrName')), $countries);
		
		$post['comment'] = $this->input->post('comment');
		$post['event_ids'] = $this->input->post('event_ids');
		$post['event_main_id'] = $this->input->post('event_main_id');
		
		
		
        // robot szűrés
        if( !$post['email'] || $this->input->post('url') ){
			print "Nem megfelelo adatok! ";
			
			$record->osztaly = "events";
			$record->fv      = "regisztracio";
			$record->hiba    = "Robot? Workshop jelentkezés:";
			foreach($_POST as $k=>$v)
				$record->hiba .= "\n['".$k."'] = ".$v;
            $record->hiba .= "\nIP: ".$_SERVER['REMOTE_ADDR'];
			$record->datum = date('Y-m-d H:i:s',time());
			$this->db->insert('a_hibak',$record);
			
			return;
		}
		
		
		$darab = ($post['event_main_id']=="haladokurzus") ? 6 : 4;
		
		//if(count($post['event_ids'])!=$darab){
		if(count($post['event_ids'])<0){
			$this->phpsession->save('wshiba',"Az érvényes jelentkezéshez {$darab} workshopot kell kiválasztani!");
			header("Location: ".$_SERVER["HTTP_REFERER"]);
			return;
		}
		
		$post['event_main_id'] = 0;
		foreach($post['event_ids'] as $evid){
			$post['event_id'] = $evid;
			if( is_numeric($evid) && $error = $this->mevents->eventFormCheck($post, "hun")){
				$this->phpsession->save('wshiba',implode('<br />', $error));
				header("Location: ".$_SERVER["HTTP_REFERER"]);
				return;
			}
		}
		$post['event_main_id'] = $this->input->post('event_main_id');
		
		
		//insert registration into the database
		if( $post['event_ids'][0] != "personal" ){
			foreach($post['event_ids'] as $evid){
				$post['event_id'] = $evid;
				$post['parkolo'] = ($_POST['parkolo'][$evid]=="on") ? 1 : 0;
				$post['gep'] = ($_POST['gep'][$evid]=="on") ? 1 : 0;
				$result = $this->mevents->EventRegistration($post);
			}
		}else
			$result = 'success';
		
		//collecting main event details
		if($result == 'success'){
			
			//send an email to the registered user
			$this->load->model('mclusers');
			
			$page = $this->mpages->get_row(799);
			
			$info = "(web) ".mysql_escape_string($post['comment']);
			if($this->input->post('sz_nev') || $this->input->post('sz_varos') || $this->input->post('sz_irsz') || $this->input->post('sz_cim'))
				$info .= ", Számlázási adatok: ".$this->input->post('sz_nev')." ".$this->input->post('sz_varos')." ".$this->input->post('sz_irsz')." ".$this->input->post('sz_cim');
			
			
			$nUserID = $this->mclusers->get_nUserIDByEmail($post['email'],'hun');
			
			if(!$nUserID){
				$tomb['strName']    = $post['nev'];
				$tomb['strCompany'] = $post['cegnev'];
				$tomb['strCity']    = $post['varos'];
				$tomb['strZip']     = $post['irsz'];
				$tomb['strStreet']  = $post['cim'];
				$tomb['strTel']     = $post['tel'];
				$tomb['nUserProf']  = $post['foglalkozas'];
				$tomb['nCtrID']     = $post['nctrid'];
				$nUserID = $this->mclusers->addUserHun($tomb);
				
				$tomb2['nUserID'] = $nUserID;
				$tomb2['email']   = $post['email'];
				$this->mclusers->addUserEmailHun($tomb2);
			}
			
			$nTopicID = (UJUGYFELKEZELO===true) ? 123 : 132;
			
			$emailesemenyekinfo = "";
			foreach($post['event_ids'] as $evid){
				$event_details = $this->mevents->getEventDetailsByID($evid);
				$datum = date('Y-m-d', $event_details->start_ts);
				
				$kurzus = $emailinfo = $infoplusz = "";
				if( ($darab==4 && count($post['event_ids'])==4)  || ($darab==6 && count($post['event_ids'])==6) )
					$kurzus = "Kurzus - ";
				
				if($_POST['parkolo'][$evid]=="on"){
					$infoplusz .= ", <b>kért parkolót</b>";
					$emailinfo = " Parkolóhely foglalva.";
				}
				else{
					$emailinfo = " Nem igényelt parkolóhelyet.";
				}
				
				if($_POST['gep'][$evid]=="on"){
					$infoplusz .= ", <b>kért gépet</b>";
					$emailinfo .= " Számítógép igényét rögzítettük.";
				}
				else{
					$emailinfo .= " Nem igényelt számítógépet.";
				}
				
				//print "emailinfo: {$emailinfo}"; exit;
				$infoplusz .= " cim: ".$post['irsz']." ".$post['varos'].", ".$post['cim'];
				
				$query = "INSERT INTO `".CRMADATBAZIS."`.`u_history` VALUES (NULL, {$nUserID}, {$nTopicID}, '{$datum}', '{$kurzus}{$event_details->name}', '{$info}{$infoplusz}', 36, '', '', NULL, NULL, NULL)";
				$this->db->query($query);
				//$this->mclusers->addEvent($nUserID, $nTopicID, $info.$infoplusz, 'hun', $datum);
				$emailesemenyekinfo .= "<b>".$event_details->name."</b> ".date('Y. m. d. H:i', $event_details->start_ts)." - ".date('H:i', $event_details->end_ts);
				$emailesemenyekinfo .= " {$emailinfo}<br>";
			}
				
			
			//change the users name constans in the page body
			
			$event_details = $this->mevents->getEventDetailsByID($post['event_ids'][0]);
			
			if( $post['event_id'] != "personal" ){
				$event_details->name = $emailesemenyekinfo;
				$start = date('Y-m-d H:i',$event_details->start_ts);
				$end = date('Y-m-d H:i',$event_details->end_ts);
			}else{
				$event_details->name = "Csoportos regisztráció kérés - ".$post['event_id'];
				$start = "";
				$end = "";
			}
			
			//collect the event's and user's data for the emails
			$mail_data = array(
				'nev'    => $post['nev'],
				'cegnev' => $post['cegnev'],
				'varos'  => $post['varos'],
				'irsz'   => $post['irsz'],
				'cim'    => $post['cim'],
				'tel'    => $post['tel'],
				'email'  => $post['email'],
				'comment' => $post['comment'],
				'start'  => $start,
				'end'    => $end,
				'event_details' => $event_details
			);
			
			//send an email to cadline
			$this->load->library('email');
			$this->email->initialize();
			$this->email->from('info@cadline.hu', 'Cadline Weboldal');
			$this->email->subject('ARCHLine.XP Workshop Regisztráció');
			$this->email->message($this->load->view('events/mail/reg_success_to_cadline', $mail_data, true));
			
			$this->email->send('info@cadline.hu', 'smtp');
		//	$this->email->send('eszter@cadline.hu', 'smtp');
			$this->email->clear();
			
			if(count($post['event_ids'])>5 && $darab==6)
				$arak =  "6 alkalom: 42.000 Ft+áfa = bruttó 53.340 Ft - helyett 35.000 Ft +Áfa = bruttó <b>44.450.- Ft</b>";
			elseif(count($post['event_ids'])>3 && $darab==4)
				$arak =  "4 alkalom: 24.000 Ft+áfa = bruttó 30.480 Ft - helyett 18.000 Ft +Áfa = bruttó <b>22.860.- Ft</b>";
			else{
				if($darab==6)
					$arak =  count($post['event_ids'])." alkalom: 7.000,-Ft + Áfa = 8.890,-Ft / alkalom = összesen bruttó <b>".(count($post['event_ids'])*8890).".- Ft</b>";
				else
					$arak =  count($post['event_ids'])." alkalom: 6.000,-Ft + Áfa = 7.620,-Ft / alkalom = összesen bruttó <b>".(count($post['event_ids'])*7620).".- Ft</b>";
			}
			
			$page->page_body = str_ireplace('#idopontok#', $emailesemenyekinfo, $page->page_body);
			$page->page_body = str_ireplace('#nev#',$post['nev'],$page->page_body);
			$page->page_body = str_ireplace('#arak#',$arak,$page->page_body);
			
			$this->load->library('email');
			$this->email->initialize();
			$this->email->from('info@cadline.hu', 'ARCHLine.hu');
			$this->email->subject('ARCHLine.XP Workshop Regisztráció');
			$this->email->message($page->page_body);
			
			$this->email->send($post['email'], 'smtp');
			
			//get the content of the success page
			$data['cimlap'] = $this->mpages->get_row(490);
			$data['cimlap']->page_body = str_ireplace('#reg_name#',$post['nev'],$data['cimlap']->page_body);
		} elseif($result == 'limit') {
			//get the content of the limit page
			$data['cimlap'] = hun() ? $this->mpages->get_row(489) : $this->mpages->get_row(481);
		} elseif($result == 'multiple') {
			//get the content of the multiple registration page
			$data['cimlap'] = hun() ? $this->mpages->get_row(488) : $this->mpages->get_row(482);
		}
		
		$data['tartalom'] = 'events/registration_success';
		
		$this->load->view('site', $data);
	}
	
	
	
	// vizsgára jelentkezés
	function felhasznaloivizsga(){
		$csoport_id = 5;
		$data['error'] = false;
		$data['title'] = 'ARCHLine.XP Felhasználói vizsga, vizsgajelentkezés';
		$data['tartalom']='interior/oktatoivizsga';
		
		$idopontok  = array();
		$vizsga_idk = $this->db->query("SELECT * FROM `tcexam`.`tce_testgroups` WHERE tstgrp_group_id = {$csoport_id}")->result();
		
		foreach($vizsga_idk as $v_id){
			$v_id = $v_id->tstgrp_test_id;
			$vizsga = $this->db->query("SELECT * FROM `tcexam`.`tce_tests` WHERE test_id = {$v_id} AND test_begin_time>'".date('Y-m-d H:i:s',time())."'")->row();
			if($vizsga)
				$idopontok[] = $vizsga;
		}
		$data['idopontok'] = $idopontok;
		
		
		$do = $this->input->post('do');
		if($do){
			$this->load->model('mclusers');
			$post = array();
			
			$post['nev']    = $this->input->post('nev');
			$post['cegnev'] = $this->input->post('cegnev');
			$post['iskola'] = $this->input->post('cegnev');
			$post['varos']  = $this->input->post('varos');
			$post['irsz']   = $this->input->post('irsz');
			$post['cim']    = $this->input->post('cim');
			$post['tel']    = $this->input->post('tel');
			$post['email']  = $this->input->post('email');
			$post['comment'] = $this->input->post('comment');
			$post['test_id'] = $this->input->post('test_id');
			$useremail = $post['email'];
			
			// hibaellenőrzés
			if( !$post['nev'] || !$post['email'] || !$post['tel'] || !is_numeric($post['test_id']) ){
				$data['cimlap'] = $this->mpages->get_row(697);
				$data['cimlap']->page_body = "";
				$data['error'] = 'A név, e-mail cím, telefonszám és időpont megadása kötelező!';
				$this->load->view('site',$data);
				return;
			}
			
			if( $post['test_id'] != -1 )
				$vizsga = $this->db->query("SELECT * FROM `tcexam`.`tce_tests` WHERE test_id = ".$post['test_id'])->row();
			
			// Felhasználó azonosítása a kék könyvben, e-mail címből
			$nUserID = $this->mclusers->get_nUserIDByEmail($post['email']);
				// ha nincs benne vagy nem egyertelmu, akkor ujat felvenni
			if( !$nUserID ){
				$tomb['strName']    = $post['nev'];
				$tomb['strCompany'] = $post['cegnev'];
				$tomb['strCity']    = $post['varos'];
				$tomb['strZip']     = $post['irsz'];
				$tomb['strMobil']   = $post['tel'];
				$tomb['strTel']     = $post['tel'];
				$nUserID = $this->mclusers->addUserHun($tomb);
				
				$tomb2['nUserID'] = $nUserID;
				$tomb2['email']   = $post['email'];
				$this->mclusers->addUserEmailHun($tomb2);
			}
			
			// felvenni a TCExam-ba, vagy új jelszót generálni neki
			$chars = "abcdefghijkmnopqrstuvwxyzABCDEFGHIJKMNOPQRSTUVWXYZ0123456789";
			$jelszo = '' ;
			for($i=0; $i<8; $i++){
				$num = rand() % strlen($chars);
				$jelszo = $jelszo . $chars[$num];
			}
			$bennevane = $this->db->query("SELECT user_id FROM `tcexam`.`tce_users` WHERE user_email='{$useremail}'")->row();
				// felvenni
			if( !$bennevane ){
				// users táblába
				$beszurni['user_name'] = $useremail;
				$beszurni['user_password'] = md5($jelszo);
				$beszurni['user_email'] = $useremail;
				$beszurni['user_regdate'] = date('Y-m-d H:i:s', time());
				$beszurni['user_ip'] = $_SERVER['REMOTE_ADDR'];
				$beszurni['user_firstname'] = current(explode(' ',$post['nev']));
				$beszurni['user_lastname'] = end(explode(' ',$post['nev']));
				$beszurni['user_regnumber'] = $nUserID;
				$beszurni['user_level'] = 3;
				
				$this->db->insert('tcexam.tce_users',$beszurni);
				
				$tcexam_user_id =  mysql_insert_id();
				
				// csoporthoz rendelés
				$query2 = "INSERT INTO `tcexam`.`tce_usrgroups` (usrgrp_user_id, usrgrp_group_id) ";
				$query2 .= " VALUES ({$tcexam_user_id}, {$csoport_id}) ";
				$this->db->query($query2);
				
			}	// új jelszó
			else{
				$query = "UPDATE `tcexam`.`tce_users` SET user_password=MD5('{$jelszo}') WHERE user_id=".$bennevane->user_id;
				$this->db->query($query);
			}
			
			
			// CadLine AB esemény
			$eseminfo = 'Vizsgára jelentkezés '.date('Y-m-d H:i',time()).' idopontban, e-mail: '.$post['email'].', jelszó: '.$jelszo;
			if($post['comment'])
				$eseminfo .= ", megjegyzés: ".$post['comment'];
			
			if(UJUGYFELKEZELO===true)
				$this->mclusers->addEvent($nUserID, 85, $eseminfo, 'hun', substr($vizsga->test_begin_time,0,10));
			else
				$this->mclusers->addEvent($nUserID, 150, $eseminfo, 'hun', substr($vizsga->test_begin_time,0,10));
			
			
			// levelek küldése
			$mail_data = array(
				'nev'    => $post['nev'],
				'iskola' => $post['cegnev'],
				'varos'  => $post['varos'],
				'irsz'   => $post['irsz'],
				'cim'    => $post['cim'],
				'tel'    => $post['tel'],
				'email'  => $post['email'],
				'comment' => $post['comment'],
				'event_details' => "ARCHLine.XP felhasználói vizsga",
				'jelszo'  => $jelszo,
			);
			if($vizsga){
				$mail_data['start'] = substr($vizsga->test_begin_time,0,-3);
				$mail_data['end']   = substr($vizsga->test_end_time,0,-3);
				$mail_data['idopont'] = substr($vizsga->test_begin_time,0,-3)." - ".substr($vizsga->test_end_time,-8,5);
			}else{
				$mail_data['start'] = "Egyéni időpont kérés";
				$mail_data['end']   = "";
				$mail_data['idopont'] = $mail_data['start'];
			}
			
			$page = $this->mpages->get_row(724);
			foreach($mail_data as $k=>$adat){
				$csere = '#'.$k.'#';
				$page->page_body = str_ireplace($csere,$adat,$page->page_body);
			}
			
			
					// cadline-nak
			$this->load->library('email');
			$this->email->initialize();
			$this->email->from('info@cadline.hu', 'Archline Weboldal');
			$this->email->subject('ARCHLine.XP vizsgajelentkezés');
			$this->email->message($page->page_body);
			
			$this->email->send('info@cadline.hu', 'smtp');
		//	$this->email->send('eszter@cadline.hu', 'smtp');
			$this->email->clear();
			
					// felhasználónak
			$this->email->from('info@cadline.hu', 'Archline Weboldal');
			$this->email->subject('ARCHLine.XP vizsgajelentkezés');
			$this->email->message($page->page_body);
			$this->email->send($post['email'], 'smtp');
			
			
			// visszajelzés a honlapon
			$data['cimlap']   = $this->mpages->get_row(490);
			$data['tartalom'] = 'events/registration_success';
		}
		
		$this->load->view('site',$data);
	}
	
	function oktatoivizsga(){
		$csoport_id = 3;
		$data['error'] = false;
		$data['title'] = 'ARCHLine.XP Oktatói vizsga, vizsgajelentkezés';
		$data['tartalom']='interior/oktatoivizsga';
		
		$idopontok  = array();
		$vizsga_idk = $this->db->query("SELECT * FROM `tcexam`.`tce_testgroups` WHERE tstgrp_group_id = {$csoport_id}")->result();
		
		foreach($vizsga_idk as $v_id){
			$v_id = $v_id->tstgrp_test_id;
			$vizsga = $this->db->query("SELECT * FROM `tcexam`.`tce_tests` WHERE test_id = {$v_id} AND test_begin_time>'".date('Y-m-d H:i:s',time())."'")->row();
			if($vizsga)
				$idopontok[] = $vizsga;
		}
		$data['idopontok'] = $idopontok;
		
		
		$do = $this->input->post('do');
		if($do){
			$this->load->model('mclusers');
			$post = array();
			
			$post['nev']    = $this->input->post('nev');
			$post['cegnev'] = $this->input->post('cegnev');
			$post['iskola'] = $this->input->post('cegnev');
			$post['varos']  = $this->input->post('varos');
			$post['irsz']   = $this->input->post('irsz');
			$post['cim']    = $this->input->post('cim');
			$post['tel']    = $this->input->post('tel');
			$post['email']  = $this->input->post('email');
			$post['comment'] = $this->input->post('comment');
			$post['test_id'] = $this->input->post('test_id');
			$useremail = $post['email'];
			
			// hibaellenőrzés
			if( !$post['nev'] || !$post['email'] || !$post['tel'] || !is_numeric($post['test_id']) ){
				$data['cimlap'] = $this->mpages->get_row(697);
				$data['cimlap']->page_body = "";
				$data['error'] = 'A név, e-mail cím, telefonszám és időpont megadása kötelező!';
				$this->load->view('site',$data);
				return;
			}
			
			if( $post['test_id'] != -1 )
				$vizsga = $this->db->query("SELECT * FROM `tcexam`.`tce_tests` WHERE test_id = ".$post['test_id'])->row();
			
			// Felhasználó azonosítása a kék könyvben, e-mail címből
			$nUserID = $this->mclusers->get_nUserIDByEmail($post['email']);
				// ha nincs benne vagy nem egyertelmu, akkor ujat felvenni
			if( !$nUserID ){
				$tomb['strName']    = $post['nev'];
				$tomb['strCompany'] = $post['cegnev'];
				$tomb['strCity']    = $post['varos'];
				$tomb['strZip']     = $post['irsz'];
				$tomb['strMobil']   = $post['tel'];
				$tomb['strTel']     = $post['tel'];
				$nUserID = $this->mclusers->addUserHun($tomb);
				
				$tomb2['nUserID'] = $nUserID;
				$tomb2['email']   = $post['email'];
				$this->mclusers->addUserEmailHun($tomb2);
			}
			
			// felvenni a TCExam-ba, vagy új jelszót generálni neki
			$chars = "abcdefghijkmnopqrstuvwxyzABCDEFGHIJKMNOPQRSTUVWXYZ0123456789";
			$jelszo = '' ;
			for($i=0; $i<8; $i++){
				$num = rand() % strlen($chars);
				$jelszo = $jelszo . $chars[$num];
			}
			$bennevane = $this->db->query("SELECT user_id FROM `tcexam`.`tce_users` WHERE user_email='{$useremail}'")->row();
				// felvenni
			if( !$bennevane ){
				// users táblába
				$beszurni['user_name'] = $useremail;
				$beszurni['user_password'] = md5($jelszo);
				$beszurni['user_email'] = $useremail;
				$beszurni['user_regdate'] = date('Y-m-d H:i:s', time());
				$beszurni['user_ip'] = $_SERVER['REMOTE_ADDR'];
				$beszurni['user_firstname'] = current(explode(' ',$post['nev']));
				$beszurni['user_lastname'] = end(explode(' ',$post['nev']));
				$beszurni['user_regnumber'] = $nUserID;
				$beszurni['user_level'] = 3;
				
				$this->db->insert('tcexam.tce_users',$beszurni);
				
				$tcexam_user_id =  mysql_insert_id();
				
				// csoporthoz rendelés
				$query2 = "INSERT INTO `tcexam`.`tce_usrgroups` (usrgrp_user_id, usrgrp_group_id) ";
				$query2 .= " VALUES ({$tcexam_user_id}, 3) ";
				$this->db->query($query2);
				$query3 = "INSERT INTO `tcexam`.`tce_usrgroups` (usrgrp_user_id, usrgrp_group_id) ";
				$query3 .= " VALUES ({$tcexam_user_id}, 4) ";
				$this->db->query($query3);
				
			}	// új jelszó
			else{
				$query = "UPDATE `tcexam`.`tce_users` SET user_password=MD5('{$jelszo}') WHERE user_id=".$bennevane->user_id;
				$this->db->query($query);
			}
			
			
			// CadLine AB esemény
			$eseminfo = 'Vizsgára jelentkezés '.date('Y-m-d H:i',time()).' idopontban, e-mail: '.$post['email'].', jelszó: '.$jelszo;
			if($post['comment'])
				$eseminfo .= ", megjegyzés: ".$post['comment'];
			
			if(UJUGYFELKEZELO===true)
				$this->mclusers->addEvent($nUserID, 85, $eseminfo, 'hun', substr($vizsga->test_begin_time,0,10));
			else
				$this->mclusers->addEvent($nUserID, 150, $eseminfo, 'hun', substr($vizsga->test_begin_time,0,10));
			
			
			// levelek küldése
			$mail_data = array(
				'nev'    => $post['nev'],
				'iskola' => $post['cegnev'],
				'varos'  => $post['varos'],
				'irsz'   => $post['irsz'],
				'cim'    => $post['cim'],
				'tel'    => $post['tel'],
				'email'  => $post['email'],
				'comment' => $post['comment'],
				'event_details' => "ARCHLine.XP oktatói vizsga",
				'jelszo'  => $jelszo,
			);
			if($vizsga){
				$mail_data['start'] = substr($vizsga->test_begin_time,0,-3);
				$mail_data['end']   = substr($vizsga->test_end_time,0,-3);
				$mail_data['idopont'] = substr($vizsga->test_begin_time,0,-3)." - ".substr($vizsga->test_end_time,-8,5);
			}else{
				$mail_data['start'] = "Egyéni időpont kérés";
				$mail_data['end']   = "";
				$mail_data['idopont'] = $mail_data['start'];
			}
			
			$page = $this->mpages->get_row(700);
			foreach($mail_data as $k=>$adat){
				$csere = '#'.$k.'#';
				$page->page_body = str_ireplace($csere,$adat,$page->page_body);
			}
			
			
					// cadline-nak
			$this->load->library('email');
			$this->email->initialize();
			$this->email->from('info@cadline.hu', 'Archline Weboldal');
			$this->email->subject('ARCHLine.XP vizsgajelentkezés');
			$this->email->message($page->page_body);
			
			$this->email->send('info@cadline.hu', 'smtp');
		//	$this->email->send('eszter@cadline.hu', 'smtp');
			$this->email->clear();
			
					// oktatónak
			$this->email->from('info@cadline.hu', 'Archline Weboldal');
			$this->email->subject('ARCHLine.XP vizsgajelentkezés');
			$this->email->message($page->page_body);
			$this->email->send($post['email'], 'smtp');
			
			
			// visszajelzés a honlapon
			$data['cimlap']   = $this->mpages->get_row(490);
			$data['tartalom'] = 'events/registration_success';
		}
		
		$this->load->view('site',$data);
	}
	
	function ujoktatoivizsgajelszo(){
		$do = $this->input->post('do');
		$useremail = $this->input->post('email');
		if( !$useremail )
			$useremail = $this->input->post('user_email');
		
		if( $do && $useremail ){
			$chars = "abcdefghijkmnopqrstuvwxyzABCDEFGHIJKMNOPQRSTUVWXYZ0123456789";
			$jelszo = '' ;
			for($i=0; $i<8; $i++){
				$num = rand() % strlen($chars);
				$jelszo = $jelszo . $chars[$num];
			}
			
			$bennevane = $this->db->query("SELECT user_id, user_regnumber, user_name FROM `tcexam`.`tce_users` WHERE user_email='{$useremail}'")->row();
			// megváltoztatás + email küldés
			if($bennevane){
				$query = "UPDATE `tcexam`.`tce_users` SET user_password=MD5('{$jelszo}') WHERE user_id=".$bennevane->user_id;
				$this->db->query($query);
				
				$mail_data = array(
					'email'  => $bennevane->user_name,
					'jelszo' => $jelszo
				);
				$page = $this->mpages->get_row(705);
				foreach($mail_data as $k=>$adat){
					$csere = '#'.$k.'#';
					$page->page_body = str_ireplace($csere,$adat,$page->page_body);
				}
				
				// új jelszót a kék könyvbe
				$this->load->model('mclusers');
				$eseminfo = "Új jelszót igényelt: ".$jelszo;
				$this->mclusers->addEvent($bennevane->user_regnumber, 150, $eseminfo, 'hun');
				
				
				$this->load->library('email');
				$this->email->initialize();
				$this->email->from('info@cadline.hu', 'Archline Weboldal');
				$this->email->subject('ARCHLine.XP vizsga jelszó');
				$this->email->message($page->page_body);
				$this->email->send($useremail, 'smtp');
				
				$data['cimlap']   = $this->mpages->get_row(706);
				
			}	// hiba
			else{
				$data['cimlap']   = $this->mpages->get_row(707);
			}
			
		}
		else{
			$data['cimlap']   = $this->mpages->get_row(707);
		}
		
		$data['tartalom'] = 'events/registration_success';
		$this->load->view('site',$data);
	}
	
	function idealhomeshow(){
		$data['lang'] = $this->muser->user['lang'];
		$data['javascript'] = array('jquery_ui');
		$data['style'] = array('jquery.ui');
		$data['error'] = false;
		$data['title'] = 'ARCHLine.XP Interior Design Software - Ideal Home Show 2012';
		$data['tartalom']='workshop/idealhomeshow';
		
		$results = $this->mevents->getEventDatesByDay(52, true);
		
		$events2 = array();
		$eventsxxx = $this->mevents->getEventsByMainEventID(52, true);
		foreach($eventsxxx as $event){
			$event->able_to_reg = $this->mevents->checkEventLimit($event->event_id);
			$return_events[strtotime(date('Y-m-d', $event->start_ts))][date('H:i', $event->start_ts).' - '.date('H:i', $event->end_ts)] = $event;
		}
	//	print_r($return_events);
		
		ksort($results['times']);
		
		$data['times'] = $results['times'];
		$data['esemenyek'] = $return_events;
		
		
		$do = $this->input->post('do');
		
		if($do){
			$post = array();
			
			$post['nev'] = $this->input->post('nev');
			$post['cegnev'] = $this->input->post('cegnev');
			$post['varos'] = $this->input->post('varos');
			$post['irsz'] = $this->input->post('irsz');
			$post['cim'] = $this->input->post('cim');
			$post['tel'] = $this->input->post('tel');
			$post['email'] = $this->input->post('email');
			$post['comment'] = $this->input->post('comment');
			$post['event_id'] = $this->input->post('event_id');
			$post['event_main_id'] = 52;
			
			if($error = $this->mevents->eventFormCheck($post, $this->muser->user['lang'])){
				$data['error'] = implode('<br />', $error);
			} else {
				//insert registration into the database
				$result = $this->mevents->EventRegistration($post);
				
				//collecting main event details
				$main_event_details = $this->mevents->getMainEventDetails(52);
				
				if($result == 'success'){
					$event_details = $this->mevents->getEventDetailsByID($post['event_id']);
					
					//collect the event's and user's data for the emails
					$mail_data = array(
						'nev' => $post['nev'],
						'cegnev' => $post['cegnev'],
						'varos' => $post['varos'],
						'irsz' => $post['irsz'],
						'cim' => $post['cim'],
						'tel' => $post['tel'],
						'email' => $post['email'],
						'comment' => $post['comment'],
						'start' => date('Y-m-d H:i',$event_details->start_ts),
						'end' => date('Y-m-d H:i',$event_details->end_ts),
						'event_details' => $this->mevents->getEventDetailsByID($post['event_id']),
						'main_event_details' => $this->mevents->getMainEventDetails(52)
					);
					
					//send an email to cadline
					$this->load->library('email');
					$this->email->initialize();
					$this->email->from('info@archlinexp.com', 'Cadline Website');
					$this->email->subject($main_event_details->name.' Registration');
					$this->email->message($this->load->view('courses/mail/reg_success_to_cadline', $mail_data, true));
					
					$this->email->send('info@archlinexp.com', 'smtp');
				//	$this->email->send('sztikee@gmail.com', 'smtp');
					$this->email->clear();
					
					
					//send an email to the registered user
					$page = $this->mpages->get_row($main_event_details->reg_success_mail_page);
					
					//change the users name constans in the page body
					$page->page_body = str_ireplace('#reg_name#', $mail_data['nev'], $page->page_body);
					
					$this->load->library('email');
					$this->email->initialize();
					$this->email->from('info@archlinexp.com', 'ARCHLineXP.com');
					$this->email->subject($page->page_title);
					$this->email->message($page->page_body);
					
					$this->email->send($post['email'], 'smtp');
					
					
					// esemény felvétele a sárga könyvbe
					$this->load->model('mclusers');
					$nUserID = $this->mclusers->get_nUserIDByEmail($post['email'],'eng');
					if( !$nUserID ){
						// user beszúrás
						$tomb->strName = $post['nev'];
						$tomb->strTel = $post['tel'];
						$tomb->strMobil = $post['tel'];
						$tomb->strEMail = $post['email'];
						$tomb->strCity = $post['varos'];
						$tomb->nUserType = 0;
						$tomb->nCtrID = 0;
						$tomb->strCompany = '';
						$tomb->strInfo = "";
						
						$nUserID = $this->mclusers->addUserEng($tomb);
						
						
						// email beszúrás
						$tomb2->email = $post['email'];
						$tomb2->nUserID = $nUserID;
						$tomb2->default = "1";
						$tomb2->active = "1";
						$tomb2->deleted = "0";
						
						$this->mclusers->addUserEmailEng($tomb2);
					}
					$info = "Ideal home show: ".$mail_data['start']." - ".$mail_data['end'];
					$this->mclusers->addEvent($nUserID, "113", $info, 'eng');
					
					
					//get the content of the success page
					$data['cimlap'] = $this->mpages->get_row($main_event_details->reg_success_page);
					$data['cimlap']->page_body = str_ireplace('#reg_name#',$post['nev'],$data['cimlap']->page_body);
				} elseif($result == 'limit') {
					//get the content of the limit page
					$data['cimlap'] = hun() ? $this->mpages->get_row(489) : $this->mpages->get_row(481);
				} elseif($result == 'multiple') {
					//get the content of the multiple registration page
					$data['cimlap'] = hun() ? $this->mpages->get_row(488) : $this->mpages->get_row(482);
				}
				
				$data['tartalom'] = 'events/registration_success';
			}
		}
		
		$this->load->view('site',$data);
		
	}
	
	function pecsexpo(){
		$data['lang'] = $this->muser->user['lang'];
		$data['javascript'] = array('jquery_ui');
		$data['style'] = array('jquery.ui');
		$data['error'] = false;
		$data['title'] = 'ARCHLine.XP CAD program, Pécs Expo';
		$data['tartalom']='workshop/pecsexpo';
		
		$results = $this->mevents->getEventsByMainEventID(53, true);
		$results = $this->db->query("SELECT * FROM `events_new` WHERE `event_main_id` =53 ORDER BY `events_new`.`name` ASC")->result();
		
	//	print_r($results);
		foreach($results as $date){
			$date->times->able_to_reg = $this->mevents->checkEventLimit($date->event_id);
		}
		$data['dates'] = $results;
		
		
		$do = $this->input->post('do');
		
		if($do){
			$post = array();
			
			$post['nev'] = $this->input->post('nev');
			$post['cegnev'] = $this->input->post('cegnev');
			$post['varos'] = $this->input->post('varos');
			$post['irsz'] = $this->input->post('irsz');
			$post['cim'] = $this->input->post('cim');
			$post['tel'] = $this->input->post('tel');
			$post['email'] = $this->input->post('email');
			$post['comment'] = $this->input->post('comment');
			$post['event_id'] = $this->input->post('event_id');
			$post['event_main_id'] = 53;
			
			if($error = $this->mevents->eventFormCheck($post, $this->muser->user['lang'])){
				$data['error'] = implode('<br />', $error);
			} else {
				//insert registration into the database
				$result = $this->mevents->EventRegistration($post);
				
				//collecting main event details
				$main_event_details = $this->mevents->getMainEventDetails(53);
				
				if($result == 'success'){
					$event_details = $this->mevents->getEventDetailsByID($post['event_id']);
					
					//collect the event's and user's data for the emails
					$mail_data = array(
						'nev' => $post['nev'],
						'cegnev' => $post['cegnev'],
						'varos' => $post['varos'],
						'irsz' => $post['irsz'],
						'cim' => $post['cim'],
						'tel' => $post['tel'],
						'email' => $post['email'],
						'comment' => $post['comment'],
						'start' => date('Y-m-d H:i',$event_details->start_ts),
						'end' => date('Y-m-d H:i',$event_details->end_ts),
						'event_details' => $this->mevents->getEventDetailsByID($post['event_id']),
						'main_event_details' => $this->mevents->getMainEventDetails(52)
					);
					
					//send an email to cadline
					$this->load->library('email');
					$this->email->initialize();
					$this->email->from('info@cadline.hu', 'Cadline Website');
					$this->email->subject($main_event_details->name.' Registration');
					$this->email->message($this->load->view('courses/mail/reg_success_to_cadline', $mail_data, true));
					
					$this->email->send('info@cadline.hu', 'smtp');
				//	$this->email->send('sztikee@gmail.com', 'smtp');
					$this->email->clear();
					
					
					//send an email to the registered user
					$page = $this->mpages->get_row($main_event_details->reg_success_mail_page);
					
					//change the users name constans in the page body
					$page->page_body = str_ireplace('#name#', $mail_data['nev'], $page->page_body);
					$page->page_body = str_ireplace('#idopont#', date('Y-m-d H:i',$event_details->start_ts), $page->page_body);
					
					$this->load->library('email');
					$this->email->initialize();
					$this->email->from('info@cadline.hu', 'CadLine Kft.');
					$this->email->subject($page->page_title);
					$this->email->message($page->page_body);
					
					$this->email->send($post['email'], 'smtp');
					
					
					// esemény felvétele a kék könyvbe
					$this->load->model('mclusers');
					$nUserID = $this->mclusers->get_nUserIDByEmail($post['email'],'hun');
					if( !$nUserID ){
						// user beszúrás
						$tomb->strName = $post['nev'];
						$tomb->strTel = $post['tel'];
						$tomb->strMobil = $post['tel'];
						$tomb->strEMail = $post['email'];
						$tomb->strCity = $post['varos'];
						$tomb->nUserType = 0;
						$tomb->nCtrID = 0;
						$tomb->strCompany = '';
						$tomb->strInfo = "";
						
						$nUserID = $this->mclusers->addUserEng($tomb);
						
						
						// email beszúrás
						$tomb2->email = $post['email'];
						$tomb2->nUserID = $nUserID;
						$tomb2->default = "1";
						$tomb2->active = "1";
						$tomb2->deleted = "0";
						
						$this->mclusers->addUserEmailEng($tomb2);
					}
					$info = "Pécs expo: ".$mail_data['start']." - ".$mail_data['end'];
					$this->mclusers->addEvent($nUserID, "12", $info, 'hun', date('Y-m-d',$event_details->start_ts));
					
					
					//get the content of the success page
					$data['cimlap'] = $this->mpages->get_row($main_event_details->reg_success_page);
					$data['cimlap']->page_body = str_ireplace('#reg_name#',$post['nev'],$data['cimlap']->page_body);
				} elseif($result == 'limit') {
					//get the content of the limit page
					$data['cimlap'] = hun() ? $this->mpages->get_row(489) : $this->mpages->get_row(481);
				} elseif($result == 'multiple') {
					//get the content of the multiple registration page
					$data['cimlap'] = hun() ? $this->mpages->get_row(488) : $this->mpages->get_row(482);
				}
				
				$data['tartalom'] = 'events/registration_success';
			}
		}
		
		$this->load->view('site',$data);
	}
	
    function no_main_event(){
        $data['lang'] = $this->muser->user['lang'];
		$data['title'] = hun() ? 'Bemutatók - ARCHLine.XP CAD Software' : 'Events - ARCHLine.XP CAD Software';
		$data['tartalom'] = 'events/no_main_event';
        $data['page'] = hun() ? $this->mpages->get_row(493) : $this->mpages->get_row(494);
		if(hun())
		    $data['csik'] = array('Főoldal', 'Bemutatók');
        else
		   $data['csik'] = array('home', 'events');
        $this->load->view('site', $data);
    }
    
    function registrate(){
        redirect('events');
        /*
        $event_main_id = $this->uri->segment(3);
        
        if(!$event_main_id || !$main_event_details = $this->mevents->getMainEventDetails($event_main_id)){
            redirect('events');
        }
        
        $data['lang'] = $this->muser->user['lang'];
		$data['title'] = hun() ? $main_event_details->name.' - Events - ARCHLine.XP CAD Software' : $main_event_details->name.' - Events - ARCHLine.XP CAD Software';
		$data['tartalom'] = 'events/registrate';
		$data['csik'] = array('home', 'events', $main_event_details->name);
        $data['error'] = false;
        
        $data['main_event'] = $main_event_details;
        
        $results = $this->mevents->getEventDatesByDay($event_main_id);
        
        $data['events'] = $results['events'];
        $data['times'] = $results['times'];
                
        $do = $this->input->post('do');
        
        if(!$do){
            $this->load->view('site', $data);
        } else {
            $post = array();
            
            $post['nev'] = $this->input->post('nev');
            $post['cegnev'] = $this->input->post('cegnev');
            $post['varos'] = $this->input->post('varos');
            $post['irsz'] = $this->input->post('irsz');
            $post['cim'] = $this->input->post('cim');
            $post['tel'] = $this->input->post('tel');
            $post['email'] = $this->input->post('email');
            $post['comment'] = $this->input->post('comment');
            $post['event_id'] = $this->input->post('event_id');
            $post['event_main_id'] = $event_main_id;
            
            if($error = $this->mevents->eventFormCheck($post, $this->muser->user['lang'])){
                $data['error'] = implode('<br />', $error);
            } else {
                //insert registration into the database
                $result = $this->mevents->EventRegistration($post);
                
                if($result == 'success'){
                    //get the content of the success page
                    $data['cimlap'] = $this->mpages->get_row(480);
                    
                    $event_details = $this->mevents->getEventDetailsByID($post['event_id']);
                    
                    //collect the event's and user's data for the emails
                    $mail_data = array(
                        'nev' => $post['nev'],
                        'cegnev' => $post['cegnev'],
                        'varos' => $post['varos'],
                        'irsz' => $post['irsz'],
                        'cim' => $post['cim'],
                        'tel' => $post['tel'],
                        'email' => $post['email'],
                        'comment' => $post['comment'],
                        'start' => date('Y-m-d H:i',$event_details->start_ts),
                        'end' => date('Y-m-d H:i',$event_details->end_ts),
                        'event_details' => $this->mevents->getEventDetailsByID($post['event_id'])
                    );
                    
                    //send an email to cadline
                    $this->load->library('email');
					$this->email->initialize();
					$this->email->from('info@cadline.hu', 'Cadline Weboldal');
					$this->email->subject($main_event_details->name.' Registration');
					$this->email->message($this->load->view('events/mail/reg_success_to_cadline', $mail_data, true));
					
					$this->email->send('info@archlinexp.com', 'smtp');
					//$this->email->send('sztikee@gmail.com', 'smtp');
                    //$this->email->send('atikenny@gmail.com', 'smtp');
					$this->email->clear();
                    
                    //send an email to the registered user
                    $page = $this->mpages->get_row($main_event_details->reg_success_mail_page);
                    
                    //change the users name constans in the page body
                    $page->page_body = str_ireplace('#reg_name#', $mail_data['nev'], $page->page_body);
                    
                    $this->load->library('email');
					$this->email->initialize();
					$this->email->from('info@archlinexp.com', 'ARCHLineXP.com');
					$this->email->subject($page->page_title);
					$this->email->message($page->page_body);
					
					$this->email->send($post['email'], 'smtp');
                } elseif($result == 'limit') {
                    //get the content of the limit page
                    $data['cimlap'] = $this->mpages->get_row(481);
                } elseif($result == 'multiple') {
                    //get the content of the multiple registration page
                    $data['cimlap'] = $this->mpages->get_row(482);
                }
                
                $data['tartalom'] = 'events/registration_success';
            }
            
            $this->load->view('site', $data);
        }
        */
    }
    
	function click(){
		$this->load->model('mclusers');
		
		$temptomb = explode("/", $_SERVER[ 'REQUEST_URI'] );
		$email = str_replace("%40","@",end($temptomb));
		$tema = $this->uri->segment(3);
		
		$user = $this->phpsession->get('user');
		$user['voltmobiloldal'] = true;
		$this->phpsession->save('user',$user);
		
		if($tema == "marzipan"){			// már nincs
			$egyezes = "/marzipan";
			$info = "Marcipán oldal megtekintve: archlinexp.com/marzipan";
			$hibainfo = "Marzipán";
			
			if(UJUGYFELKEZELO===true)
				$this->mclusers->levelesemeny($email, "events", "click", 181, $egyezes, $info, "eng", $hibainfo);
			else
				$this->mclusers->levelesemeny($email, "events", "click", 157, $egyezes, $info, "eng", $hibainfo);
			
			redirect("marzipan");
			
		}elseif($tema == "akcio"){			// már nincs
		//	$egyezes = "/page/show/635";
			$egyezes = "news/show/ev-vegi-akcio";
			$info = "Akció oldal megtekintve: archline.hu/page/show/635";
			$hibainfo = "Akció";
			
			if(UJUGYFELKEZELO===true)
				$this->mclusers->levelesemeny($email, "events", "click", 57, $egyezes, $info, "hun", $hibainfo);
			else
				$this->mclusers->levelesemeny($email, "events", "click", 138, $egyezes, $info, "hun", $hibainfo);
			
		//	redirect("page/show/635");
			redirect("news/show/ev-vegi-akcio");
			
		}elseif($tema == "bratislava"){		// már nincs
			$egyezes = "/page/show/637";
			$info = "Presentation in Bratislava megtekintve: http://www.archlinexp.com/page/show/637";
			$hibainfo = "Bratislava";
			
			if(UJUGYFELKEZELO===true)
				$this->mclusers->levelesemeny($email, "events", "click", 250, $egyezes, $info, "esp", $hibainfo);
			else
				$this->mclusers->levelesemenyEsp($email, "events", "click", 136, $egyezes, $info, "esp", $hibainfo);
			
			redirect("page/show/637");
			
		}elseif($tema == "interiorpro"){
			$egyezes = "/interior/pro";
			$info = "Has been seen: http://www.archlinexp.com/interior/pro";
			$hibainfo = "Interior PRO";
			
			if(UJUGYFELKEZELO===true)
				$this->mclusers->levelesemeny($email, "events", "click", 180, $egyezes, $info, "eng", $hibainfo);
			else
				$this->mclusers->levelesemeny($email, "events", "click", 164, $egyezes, $info, "eng", $hibainfo);
			
			redirect("/interior/pro");
			
		}elseif($tema == "interiorproesp"){
			$egyezes = "/interior/pro";
			$info = "Has been seen: http://www.archlinexp.com/interior/pro";
			$hibainfo = "Interior PRO, esp";
			
			if(UJUGYFELKEZELO===true)
				$this->mclusers->levelesemeny($email, "events", "click", 255, $egyezes, $info, "esp", $hibainfo);
			else
				$this->mclusers->levelesemenyEsp($email, "events", "click", 137, $egyezes, $info, "esp", $hibainfo);
			
			redirect("/interior/pro");
			
		}elseif($tema == "ujdonsagok2012"){
			$egyezes = "/ujdonsagok-2012";
			$info = "Újdonságok megtekintve: http://www.archline.hu/ujdonsagok-2012";
			$hibainfo = "Ujdonságok 2012, hun";
			
			if(UJUGYFELKEZELO===true)
				$this->mclusers->levelesemeny($email, "events", "click", 74, $egyezes, $info, "hun", $hibainfo);
			else
				$this->mclusers->levelesemeny($email, "events", "click", 131, $egyezes, $info, "hun", $hibainfo);
			
			redirect("ujdonsagok-2012");
			
		}elseif($tema == "birmingham"){
			$egyezes = "/workshop/birmingham";
			$info = "Has been seen: http://www.archlinexp.com/workshop/birmingham";
			$hibainfo = "birmingham";
			
			if(UJUGYFELKEZELO===true)
				$this->mclusers->levelesemeny($email, "events", "click", 170, $egyezes, $info, "eng", $hibainfo);
			else
				$this->mclusers->levelesemeny($email, "events", "click", 165, $egyezes, $info, "eng", $hibainfo);
			
			redirect("/workshop/birmingham");
			
		}elseif($tema == "akcio-vn"){
			//$egyezes = "Valentin napi akci";
			//$info = "Megtekintve: http://www.archline.hu/ Valentin napi akció";
			$egyezes = "/buy Valentin napi akc";
			$info = "Megtekintve: http://www.archline.hu/buy Valentin napi akció";
			$hibainfo = "Valentin napi akció, hun";
			
			if(UJUGYFELKEZELO===true)
				$this->mclusers->levelesemeny($email, "events", "click", 57, $egyezes, $info, "hun", $hibainfo);
			else
				$this->mclusers->levelesemeny($email, "events", "click", 138, $egyezes, $info, "hun", $hibainfo);
			
			redirect("buy");
			
		}elseif($tema == "akcio-construma"){
			$egyezes = "/buy Construma akc";
			$info = "Megtekintve: http://www.archline.hu/buy Construma akció";
			$hibainfo = "Construma akció, hun";
			
			if(UJUGYFELKEZELO===true)
				$this->mclusers->levelesemeny($email, "events", "click", 57, $egyezes, $info, "hun", $hibainfo);
			else
				$this->mclusers->levelesemeny($email, "events", "click", 138, $egyezes, $info, "hun", $hibainfo);
			
			redirect("buy");
			
		}elseif($tema == "akcio-megrendelo"){
			$egyezes = "megrendelo lap";
			$info = "Megtekintve: http://www.archline.hu/public/upload/hun/Megrendelo_2012_Interior.pdf akció, megrendelo lap";
			$hibainfo = "Valentin nap, megrendelő lap, hun";
			
			if(UJUGYFELKEZELO===true)
				$this->mclusers->levelesemeny($email, "events", "click", 57, $egyezes, $info, "hun", $hibainfo);
			else
				$this->mclusers->levelesemeny($email, "events", "click", 138, $egyezes, $info, "hun", $hibainfo);
			
			redirect("public/upload/hun/Megrendelo_2012_Interior.pdf");
			
		}elseif($tema == "service-handsketch"){
			/*$egyezes = "archlinexp.com/services/sketch .";
			$info = "Has been seen: http://www.archlinexp.com/services/sketch .";
			$hibainfo = "Hand sketch, eng";
			
			$this->mclusers->levelesemeny($email, "events", "click", 176, $egyezes, $info, "eng", $hibainfo);
			
			redirect("services/sketch");*/
			$egyezes = "archlinexp.eu/packages/3d-interior-modeling .";
			$info = "3D model, Has been seen: www.archlinexp.eu/packages/3d-interior-modeling .";
			$hibainfo = "Model price, eng";
			
			if(UJUGYFELKEZELO===true)
				$this->mclusers->levelesemeny($email, "events", "click", 187, $egyezes, $info, "eng", $hibainfo);
			else
				$this->mclusers->levelesemeny($email, "events", "click", 176, $egyezes, $info, "eng", $hibainfo);
			header('Location: http://www.archlinexp.eu/packages/3d-interior-modeling');
			exit;
			
		}elseif($tema == "service-rendering"){
			/*$egyezes = "archlinexp.com/services/rendering";
			$info = "Has been seen: http://www.archlinexp.com/services/rendering";
			$hibainfo = "Rendering, eng";
			
			$this->mclusers->levelesemeny($email, "events", "click", 176, $egyezes, $info, "eng", $hibainfo);
			
			redirect("services/rendering");*/
			$egyezes = "archlinexp.eu/packages/photorealistic-rendering .";
			$info = "Rendering, Has been seen: www.archlinexp.eu/packages/photorealistic-rendering .";
			$hibainfo = "RE price, eng";
			
			if(UJUGYFELKEZELO===true)
				$this->mclusers->levelesemeny($email, "events", "click", 187, $egyezes, $info, "eng", $hibainfo);
			else
				$this->mclusers->levelesemeny($email, "events", "click", 176, $egyezes, $info, "eng", $hibainfo);
			header('Location: http://www.archlinexp.eu/packages/photorealistic-rendering');
			exit;
			
		}elseif($tema == "service-virtuallyfurnish"){
			/*$egyezes = "archlinexp.com/services/virtuallyfurnish";
			$info = "Has been seen: http://www.archlinexp.com/services/virtuallyfurnish";
			$hibainfo = "Virtually staged, eng";
			
			$this->mclusers->levelesemeny($email, "events", "click", 176, $egyezes, $info, "eng", $hibainfo);
			
			redirect("services/virtuallyfurnish");*/
			$egyezes = "archlinexp.eu/packages/virtual-photo-staging .";
			$info = "Virtually staged, Has been seen: www.archlinexp.eu/packages/virtual-photo-staging .";
			$hibainfo = "VS price, eng";
			
			if(UJUGYFELKEZELO===true)
				$this->mclusers->levelesemeny($email, "events", "click", 187, $egyezes, $info, "eng", $hibainfo);
			else
				$this->mclusers->levelesemeny($email, "events", "click", 176, $egyezes, $info, "eng", $hibainfo);
			header('Location: http://www.archlinexp.eu/packages/virtual-photo-staging');
			exit;
			
		}elseif($tema == "service-vs-price"){
			/*$egyezes = "archlinexp.com/services/virtuallyfurnish/pricing";
			$info = "Virtually staged, Has been seen: http://www.archlinexp.com/services/virtuallyfurnish/pricing";
			$hibainfo = "VS price, eng";
			
			$this->mclusers->levelesemeny($email, "events", "click", 176, $egyezes, $info, "eng", $hibainfo);
			
			redirect("services/virtuallyfurnish/pricing");*/
			$egyezes = "archlinexp.eu/packages/virtual-photo-staging/details";
			$info = "Virtually staged, Has been seen: www.archlinexp.eu/packages/virtual-photo-staging/details";
			$hibainfo = "VS price, eng";
			
			if(UJUGYFELKEZELO===true)
				$this->mclusers->levelesemeny($email, "events", "click", 187, $egyezes, $info, "eng", $hibainfo);
			else
				$this->mclusers->levelesemeny($email, "events", "click", 176, $egyezes, $info, "eng", $hibainfo);
			header('Location: http://www.archlinexp.eu/packages/virtual-photo-staging/details');
			exit;
			
		}elseif($tema == "service-re-price"){
			/*$egyezes = "archlinexp.com/services/rendering/pricing";
			$info = "Rendering, Has been seen: http://www.archlinexp.com/services/rendering/pricing";
			$hibainfo = "RE price, eng";
			
			$this->mclusers->levelesemeny($email, "events", "click", 176, $egyezes, $info, "eng", $hibainfo);
			
			redirect("services/rendering/pricing");*/
			$egyezes = "archlinexp.eu/packages/photorealistic-rendering/details";
			$info = "Rendering, Has been seen: www.archlinexp.eu/packages/photorealistic-rendering/details";
			$hibainfo = "RE price, eng";
			
			if(UJUGYFELKEZELO===true)
				$this->mclusers->levelesemeny($email, "events", "click", 187, $egyezes, $info, "eng", $hibainfo);
			else
				$this->mclusers->levelesemeny($email, "events", "click", 176, $egyezes, $info, "eng", $hibainfo);
			header('Location: http://www.archlinexp.eu/packages/photorealistic-rendering/details');
			exit;
			
		}elseif($tema == "service-sk-price"){
			/*$egyezes = "archlinexp.com/services/sketch/pricing";
			$info = "Hand sketch, Has been seen: http://www.archlinexp.com/services/sketch/pricing";
			$hibainfo = "SK price, eng";
			
			$this->mclusers->levelesemeny($email, "events", "click", 176, $egyezes, $info, "eng", $hibainfo);
			
			redirect("services/sketch/pricing");*/
			$egyezes = "archlinexp.eu/packages/3d-interior-modeling/details";
			$info = "3D model, Has been seen: www.archlinexp.eu/packages/3d-interior-modeling/details";
			$hibainfo = "Model price, eng";
			
			if(UJUGYFELKEZELO===true)
				$this->mclusers->levelesemeny($email, "events", "click", 187, $egyezes, $info, "eng", $hibainfo);
			else
				$this->mclusers->levelesemeny($email, "events", "click", 176, $egyezes, $info, "eng", $hibainfo);
			header('Location: http://www.archlinexp.eu/packages/3d-interior-modeling/details');
			exit;
			
		}elseif($tema == "szolgaltatasok-kezirajz"){
			$egyezes = "archline.hu/services/sketch .";
			$info = "Megtekintve: http://www.archline.hu/services/sketch .";
			$hibainfo = "Szolgáltatások, hun";
			
			if(UJUGYFELKEZELO===true)
				$this->mclusers->levelesemeny($email, "events", "click", 72, $egyezes, $info, "hun", $hibainfo);
			else
				$this->mclusers->levelesemeny($email, "events", "click", 140, $egyezes, $info, "hun", $hibainfo);
			
			redirect("services/sketch");
			
		}elseif($tema == "szolgaltatasok-vs-arak"){
			$egyezes = "archline.hu/services/virtuallyfurnish/pricing";
			$info = "Virtual staging, megtekintve: http://www.archline.hu/services/virtuallyfurnish/pricing";
			$hibainfo = "VS árak, hun";
			
			if(UJUGYFELKEZELO===true)
				$this->mclusers->levelesemeny($email, "events", "click", 72, $egyezes, $info, "hun", $hibainfo);
			else
				$this->mclusers->levelesemeny($email, "events", "click", 140, $egyezes, $info, "hun", $hibainfo);
			
			redirect("services/virtuallyfurnish/pricing");
			
		}elseif($tema == "szolgaltatasok-re-arak"){
			$egyezes = "archline.hu/services/rendering/pricing";
			$info = "Renderelt képek készítése, megtekintve: http://www.archline.hu/services/rendering/pricing";
			$hibainfo = "Renderelés árak, hun";
			
			if(UJUGYFELKEZELO===true)
				$this->mclusers->levelesemeny($email, "events", "click", 72, $egyezes, $info, "hun", $hibainfo);
			else
				$this->mclusers->levelesemeny($email, "events", "click", 140, $egyezes, $info, "hun", $hibainfo);
			
			redirect("services/rendering/pricing");
			
		}elseif($tema == "szolgaltatasok-sk-arak"){
			$egyezes = "archline.hu/services/sketch/pricing";
			$info = "3D modell készítése, megtekintve: http://www.archline.hu/services/sketch/pricing";
			$hibainfo = "3D modell árak, hun";
			
			if(UJUGYFELKEZELO===true)
				$this->mclusers->levelesemeny($email, "events", "click", 72, $egyezes, $info, "hun", $hibainfo);
			else
				$this->mclusers->levelesemeny($email, "events", "click", 140, $egyezes, $info, "hun", $hibainfo);
			
			redirect("services/sketch/pricing");
			
		}elseif($tema == "service-handsketch-esp"){
			$egyezes = "archlinexp.com/services/sketch .";
			$info = "Has been seen: http://www.archlinexp.com/services/sketch .";
			$hibainfo = "Hand sketch, esp";
			
			if(UJUGYFELKEZELO===true)
				$this->mclusers->levelesemeny($email, "events", "click", 257, $egyezes, $info, "esp", $hibainfo);
			else
				$this->mclusers->levelesemenyEsp($email, "events", "click", 140, $egyezes, $info, "esp", $hibainfo);
			
			redirect("services/sketch");
			
		}elseif($tema == "service-vs-price-esp"){
			$egyezes = "archlinexp.com/services/virtuallyfurnish/pricing";
			$info = "Virtually staged, Has been seen: http://www.archlinexp.com/services/virtuallyfurnish/pricing";
			$hibainfo = "VS price, esp";
			
			if(UJUGYFELKEZELO===true)
				$this->mclusers->levelesemeny($email, "events", "click", 257, $egyezes, $info, "esp", $hibainfo);
			else
				$this->mclusers->levelesemenyEsp($email, "events", "click", 140, $egyezes, $info, "esp", $hibainfo);
			
			redirect("services/virtuallyfurnish/pricing");
			
		}elseif($tema == "service-re-price-esp"){
			$egyezes = "archlinexp.com/services/rendering/pricing";
			$info = "Rendering, Has been seen: http://www.archlinexp.com/services/rendering/pricing";
			$hibainfo = "RE price, esp";
			
			if(UJUGYFELKEZELO===true)
				$this->mclusers->levelesemeny($email, "events", "click", 257, $egyezes, $info, "esp", $hibainfo);
			else
				$this->mclusers->levelesemenyEsp($email, "events", "click", 140, $egyezes, $info, "esp", $hibainfo);
			
			redirect("services/rendering/pricing");
			
		}elseif($tema == "service-sk-price-esp"){
			$egyezes = "archlinexp.com/services/sketch/pricing";
			$info = "Hand sketch, Has been seen: http://www.archlinexp.com/services/sketch/pricing";
			$hibainfo = "SK price, esp";
			
			if(UJUGYFELKEZELO===true)
				$this->mclusers->levelesemeny($email, "events", "click", 257, $egyezes, $info, "esp", $hibainfo);
			else
				$this->mclusers->levelesemenyEsp($email, "events", "click", 140, $egyezes, $info, "esp", $hibainfo);
			
			redirect("services/sketch/pricing");
			
		}elseif($tema == "news-services"){
			$egyezes = "archlinexp.com/new-features-2012";
			$info = "New Features, Has been seen: http://www.archlinexp.com/new-features-2012";
			$hibainfo = "News services, eng";
			
			if(UJUGYFELKEZELO===true)
				$this->mclusers->levelesemeny($email, "events", "click", 182, $egyezes, $info, "eng", $hibainfo);
			else
				$this->mclusers->levelesemeny($email, "events", "click", 178, $egyezes, $info, "eng", $hibainfo);
			
			redirect("new-features-2012");
			
		}elseif($tema == "download-interior"){
			$egyezes = "archlinexp.com/interior/download";
			$info = "Interior Download, Has been seen: http://www.archlinexp.com/interior/download";
			$hibainfo = "Int download, eng";
			
			if(UJUGYFELKEZELO===true)
				$this->mclusers->levelesemeny($email, "events", "click", 182, $egyezes, $info, "eng", $hibainfo);
			else
				$this->mclusers->levelesemeny($email, "events", "click", 178, $egyezes, $info, "eng", $hibainfo);
			
			redirect("interior/download");
			
		}elseif($tema == "download-int-hun"){
			$egyezes = "archline.hu/interior/download";
			$info = "Letöltési oldal: http://www.archline.hu/interior/download";
			$hibainfo = "Interior letöltés, hun";
			
			if(UJUGYFELKEZELO===true)
				$this->mclusers->levelesemeny($email, "events", "click", 70, $egyezes, $info, "hun", $hibainfo);
			else
				$this->mclusers->levelesemeny($email, "events", "click", 141, $egyezes, $info, "hun", $hibainfo);
			
			redirect("interior/download");
			
		}elseif($tema == "new-features-esp"){
			$egyezes = "archlinexp.com/new-features-2012";
			$info = "Újdonságok oldal megtekintve: http://www.archlinexp.com/new-features-2012";
			$hibainfo = "újdonságok, esp";
			
			if(UJUGYFELKEZELO===true)
				$this->mclusers->levelesemeny($email, "events", "click", 258, $egyezes, $info, "esp", $hibainfo);
			else
				$this->mclusers->levelesemenyEsp($email, "events", "click", 142, $egyezes, $info, "esp", $hibainfo);
			
			redirect("new-features-2012");
			
		}elseif($tema == "akcio-hv"){
			$egyezes = "archline.hu .. húsvét";
			$info = "Húsvéti akció megtekintve: http://www.archline.hu .. húsvét";
			$hibainfo = "húsvét, hun";
			
			if(UJUGYFELKEZELO===true)
				$this->mclusers->levelesemeny($email, "events", "click", 67, $egyezes, $info, "hun", $hibainfo);
			else
				$this->mclusers->levelesemeny($email, "events", "click", 147, $egyezes, $info, "hun", $hibainfo);
			
			redirect("");
			
		}elseif($tema == "construma2012" || $tema == "construma2013"){
			$egyezes = "workshop/construma";
			$info = "Construma oldal megtekintve: http://www.archline.hu/workshop/construma";
			$hibainfo = "construma, hun";
			
			if(UJUGYFELKEZELO===true)
				$this->mclusers->levelesemeny($email, "events", "click", 74, $egyezes, $info, "hun", $hibainfo);
			else
				$this->mclusers->levelesemeny($email, "events", "click", 131, $egyezes, $info, "hun", $hibainfo);
			
			redirect("workshop/construma");
			
		}elseif($tema == "honapkepereszletek"){
			$egyezes = "news/show/83";
			$info = "A hónap képe pályázat részletei megtekintve: http://www.archline.hu/news/show/83";
			$hibainfo = "honapkepereszletek, hun";
			
			if(UJUGYFELKEZELO===true)
				$this->mclusers->levelesemeny($email, "events", "click", 66, $egyezes, $info, "hun", $hibainfo);
			else
				$this->mclusers->levelesemeny($email, "events", "click", 148, $egyezes, $info, "hun", $hibainfo);
			
			redirect("news/show/83");
			
		}elseif($tema == "showroom"){
			$egyezes = "archlinexp.com/showroom";
			$info = "Showroom, Has been seen: http://www.archlinexp.com/showroom";
			$hibainfo = "showroom, eng";
			
			if(UJUGYFELKEZELO===true)
				$this->mclusers->levelesemeny($email, "events", "click", 186, $egyezes, $info, "eng", $hibainfo);
			else
				$this->mclusers->levelesemeny($email, "events", "click", 184, $egyezes, $info, "eng", $hibainfo);
			
			redirect("showroom");
			
		}elseif($tema == "bemutatoterem"){
			$egyezes = "archline.hu/showroom";
			$info = "Bemutatóterem oldal: http://www.archline.hu/showroom";
			$hibainfo = "showroom, hun";
			
			if(UJUGYFELKEZELO===true)
				$this->mclusers->levelesemeny($email, "events", "click", 59, $egyezes, $info, "hun", $hibainfo);
			else
				$this->mclusers->levelesemeny($email, "events", "click", 149, $egyezes, $info, "hun", $hibainfo);
			
			redirect("showroom");
			
		}elseif($tema == "ujdonsag-bemutatoterem"){
			$egyezes = "archline.hu/page/show/bemutatoterem";
			$info = "Bemutatóterem oldal: http://www.archline.hu/page/show/bemutatoterem";
			$hibainfo = "Újdonság, bemutatóterem, hun";
			
			if(UJUGYFELKEZELO===true)
				$this->mclusers->levelesemeny($email, "events", "click", 59, $egyezes, $info, "hun", $hibainfo);
			else
				$this->mclusers->levelesemeny($email, "events", "click", 149, $egyezes, $info, "hun", $hibainfo);
			
			redirect("page/show/bemutatoterem");
			
		}elseif($tema == "chelsea"){
			$egyezes = "archlinexp.com/chelseaflower";
			$info = "Has been seen: http://www.archlinexp.com/chelseaflower";
			$hibainfo = "Chelsea, eng";
			
			if(UJUGYFELKEZELO===true)
				$this->mclusers->levelesemeny($email, "events", "click", 171, $egyezes, $info, "eng", $hibainfo);
			else
				$this->mclusers->levelesemeny($email, "events", "click", 186, $egyezes, $info, "eng", $hibainfo);
			
			redirect("chelseaflower");
			
		}elseif($tema == "idealhomeshow"){
			$egyezes = "archlinexp.com/events/idealhomeshow";
			$info = "Has been seen: http://www.archlinexp.com/events/idealhomeshow";
			$hibainfo = "Ideal home show, eng";
			
			if(UJUGYFELKEZELO===true)
				$this->mclusers->levelesemeny($email, "events", "click", 179, $egyezes, $info, "eng", $hibainfo);
			else
				$this->mclusers->levelesemeny($email, "events", "click", 187, $egyezes, $info, "eng", $hibainfo);
			
			redirect("events/idealhomeshow");
			
		}elseif($tema == "pecsexpo"){
			$egyezes = "archline.hu/events/pecsexpo";
			$info = "Pécs Expo megtekintve: http://www.archline.hu/events/pecsexpo";
			$hibainfo = "Pécs expo";
			
			if(UJUGYFELKEZELO===true)
				$this->mclusers->levelesemeny($email, "events", "click", 71, $egyezes, $info, "hun", $hibainfo);
			else
				$this->mclusers->levelesemeny($email, "events", "click", 151, $egyezes, $info, "hun", $hibainfo);
			
			redirect("events/pecsexpo");
			
		}elseif($tema == "mainsite"){
			$egyezes = "archlinexp.com. ..";
			$info = "Has been seen: http://www.archlinexp.com. ..";
			$hibainfo = "Main site, eng";
			
			if(UJUGYFELKEZELO===true)
				$this->mclusers->levelesemeny($email, "events", "click", 176, $egyezes, $info, "eng", $hibainfo);
			else
				$this->mclusers->levelesemeny($email, "events", "click", 190, $egyezes, $info, "eng", $hibainfo);
			
			header('Location: http://www.archlinexp.com');
			
		}elseif($tema == "free-app"){
			$egyezes = "archlinexp.com/free-app";
			$info = "Has been seen: http://www.archlinexp.com/free-app";
			$hibainfo = "Free app, eng";
			
			if(UJUGYFELKEZELO===true)
				$this->mclusers->levelesemeny($email, "events", "click", 177, $egyezes, $info, "eng", $hibainfo);
			else
				$this->mclusers->levelesemeny($email, "events", "click", 191, $egyezes, $info, "eng", $hibainfo);
			
			redirect("free-app");
			
		}elseif($tema == "bnv2012"){
			$egyezes = "archline.hu/workshop/bnv";
			$info = "BNV megtekintve: http://www.archline.hu/workshop/bnv";
			$hibainfo = "BNV levél";
			
			if(UJUGYFELKEZELO===true)
				$this->mclusers->levelesemeny($email, "events", "click", 60, $egyezes, $info, "hun", $hibainfo);
			else
				$this->mclusers->levelesemeny($email, "events", "click", 157, $egyezes, $info, "hun", $hibainfo);
			
			//redirect("workshop/bnv");
			header("Location: http://www.archline.hu/workshop/bnv"); exit;
			
		}elseif($tema == "interiorpricelist"){
			$egyezes = "archlinexp.com/interior/buy";
			$info = "Has been seen: http://www.archlinexp.com/interior/buy";
			$hibainfo = "Pricelist, eng";
			
			if(UJUGYFELKEZELO===true)
				$this->mclusers->levelesemeny($email, "events", "click", 169, $egyezes, $info, "eng", $hibainfo);
			else
				$this->mclusers->levelesemeny($email, "events", "click", 192, $egyezes, $info, "eng", $hibainfo);
			
			redirect("interior/buy");
			
		}elseif($tema == "onlinepresentation"){
			$egyezes = "archlinexp.com/presentation/online";
			$info = "Has been seen: http://www.archlinexp.com/presentation/online";
			$hibainfo = "Online presentation, eng";
			
			if(UJUGYFELKEZELO===true)
				$this->mclusers->levelesemeny($email, "events", "click", 184, $egyezes, $info, "eng", $hibainfo);
			else
				$this->mclusers->levelesemeny($email, "events", "click", 193, $egyezes, $info, "eng", $hibainfo);
			
			redirect("presentation/online");
			
		}elseif($tema == "freeapphu"){
			$egyezes = "archline.hu/free-app";
			$info = "ARCHLine View megtekintve: http://www.archline.hu/free-app";
			$hibainfo = "Free app hun";
			
			if(UJUGYFELKEZELO===true)
				$this->mclusers->levelesemeny($email, "events", "click", 62, $egyezes, $info, "hun", $hibainfo);
			else
				$this->mclusers->levelesemeny($email, "events", "click", 158, $egyezes, $info, "hun", $hibainfo);
			
			//redirect("workshop/bnv");
			header("Location: http://www.archline.hu/free-app"); exit;
			
		}elseif($tema == "archlineklub"){
			$klubtema = "/".$this->uri->segment(4);
			if( strpos($klubtema,'@') )
				$klubtema = "";
			$egyezes = "archline.hu/archline-klub".$klubtema;
			$info = "ARCHLine Klub megtekintve: http://www.archline.hu/archline-klub".$klubtema;
			$hibainfo = "Archline Klub";
			
			if(UJUGYFELKEZELO===true)
				$this->mclusers->levelesemeny($email, "events", "click", 58, $egyezes, $info, "hun", $hibainfo);
			else
				$this->mclusers->levelesemeny($email, "events", "click", 159, $egyezes, $info, "hun", $hibainfo);
			
			redirect("archline-klub".$klubtema);
			
		}elseif($tema == "archlineevening"){
			$klubtema = "/".$this->uri->segment(4);
			if( strpos($klubtema,'@') )
				$klubtema = "";
			$egyezes = "archlinexp.com/archline-evening".$klubtema;
			$info = "ARCHLine Evening megtekintve: http://www.archlinexp.com/archline-evening".$klubtema;
			$hibainfo = "Archline Evening";
			
			$this->mclusers->levelesemeny($email, "events", "click", 276, $egyezes, $info, "eng", $hibainfo);
			
			redirect("archline-evening".$klubtema);
			
		}elseif($tema == "christmasoffer"){
			$egyezes = "archlinexp.com/news/show/christmas-offer";
			$info = "Christmas offer: http://www.archlinexp.com/news/show/christmas-offer";
			$hibainfo = "christmas offer new, eng";
			
			if(UJUGYFELKEZELO===true)
				$this->mclusers->levelesemeny($email, "events", "click", 183, $egyezes, $info, "eng", $hibainfo);
			else
				$this->mclusers->levelesemeny($email, "events", "click", 147, $egyezes, $info, "eng", $hibainfo);
			
			redirect("news/show/christmas-offer");
			
		}elseif($tema == "betaletoltes32"){
			$egyezes = "Béta letöltve: http://www.archline.hu/public/downloads/eng/ARCHLINE_XP2014_Beta_32bit_setup.exe";
			$info = "Béta letöltve: http://www.archline.hu/public/downloads/eng/ARCHLINE_XP2014_Beta_32bit_setup.exe";
			$hibainfo = "Béta, hun";
			
			$this->mclusers->levelesemeny($email, "events", "click", 9, $egyezes, $info, "hun", $hibainfo);
			
			redirect("public/downloads/eng/ARCHLINE_XP2014_Beta_32bit_setup.exe");
			
		}elseif($tema == "betaletoltes64"){
			$egyezes = "Béta letöltve: http://www.archline.hu/public/downloads/eng/ARCHLINE_XP2014_Beta_64bit_setup.exe";
			$info = "Béta letöltve: http://www.archline.hu/public/downloads/eng/ARCHLINE_XP2014_Beta_64bit_setup.exe";
			$hibainfo = "Béta, hun";
			
			$this->mclusers->levelesemeny($email, "events", "click", 9, $egyezes, $info, "hun", $hibainfo);
			
			redirect("public/downloads/eng/ARCHLINE_XP2014_Beta_64bit_setup.exe");
			
		}elseif($tema == "evkepe2012"){
			//$egyezes = "www.archline.hu/yearpicture2012";
			//$info = "Has been seen: http://www.archline.hu/yearpicture2012";
			$egyezes = "www.archline.hu/palyazat/nyertes2012";
			$info = "Megtekintve: http://www.archline.hu/palyazat/nyertes2012";
			$hibainfo = "év képe, hun";
			
			if(UJUGYFELKEZELO===true)
				$this->mclusers->levelesemeny($email, "events", "click", 61, $egyezes, $info, "hun", $hibainfo);
			else
				$this->mclusers->levelesemeny($email, "events", "click", 163, $egyezes, $info, "hun", $hibainfo);
			
			//redirect("palyazat/evkepe2012");
			redirect("palyazat/nyertes2012");
			
		}elseif($tema == "yearpicture2012"){
			$egyezes = "www.archlinexp.com/yearpicture2012";
			$info = "Has been seen: http://www.archlinexp.com/yearpicture2012";
			$hibainfo = "év képe, eng";
			
			if(UJUGYFELKEZELO===true)
				$this->mclusers->levelesemeny($email, "events", "click", 175, $egyezes, $info, "eng", $hibainfo);
			else
				$this->mclusers->levelesemeny($email, "events", "click", 196, $egyezes, $info, "eng", $hibainfo);
			
			redirect("yearpicture2012");
			
		}elseif($tema == "ujdonsagok2013"){
			$egyezes = "archline.hu/ujdonsagok-2013";
			$info = "Megtekintve: http://www.archline.hu/ujdonsagok-2013";
			$hibainfo = "2013 újdonságok, hun";
			
			if(UJUGYFELKEZELO===true)
				$this->mclusers->levelesemeny($email, "events", "click", 73, $egyezes, $info, "hun", $hibainfo);
			else
				$this->mclusers->levelesemeny($email, "events", "click", 169, $egyezes, $info, "hun", $hibainfo);
			
			redirect("/ujdonsagok-2013");
			
		}elseif($tema == "ujdonsagok2013v2"){
			$egyezes = "archline.hu/ujdonsagok-2013";
			$info = "Megtekintve: http://www.archline.hu .. újdonságok 2013";
			$hibainfo = "2013 újdonságok, hun";
			
			if(UJUGYFELKEZELO===true)
				$this->mclusers->levelesemeny($email, "events", "click", 73, $egyezes, $info, "hun", $hibainfo);
			else
				$this->mclusers->levelesemeny($email, "events", "click", 169, $egyezes, $info, "hun", $hibainfo);
			
			redirect("");
			
		}elseif($tema == "newfeatures2013"){
			$egyezes = "www.archlinexp.com/new-features-2013";
			$info = "New features 2013: http://www.archlinexp.com/new-features-2013";
			$hibainfo = "new features, eng";
			
			if(UJUGYFELKEZELO===true)
				$this->mclusers->levelesemeny($email, "events", "click", 172, $egyezes, $info, "eng", $hibainfo);
			else
				$this->mclusers->levelesemeny($email, "events", "click", 178, $egyezes, $info, "eng", $hibainfo);
			
			redirect("new-features-2013");
			
		}elseif($tema == "paratlanlehetosegparosaval"){
			$egyezes = "archline.hu/construmaakcio";
			$info = "Megtekintve: http://www.archline.hu/construmaakcio";
			$hibainfo = "Construma akció, hun";
			
			if(UJUGYFELKEZELO===true)
				$this->mclusers->levelesemeny($email, "events", "click", 57, $egyezes, $info, "hun", $hibainfo);
			else
				$this->mclusers->levelesemeny($email, "events", "click", 138, $egyezes, $info, "hun", $hibainfo);
			
			redirect("/construmaakcio");
			
		}elseif($tema == "kbbpresentation"){
			$egyezes = "www.archlinexp.com/presentation/kbb";
			$info = "KBB London 2013: http://www.archlinexp.com/presentation/kbb";
			$hibainfo = "kbb presentation, eng";
			
			if(UJUGYFELKEZELO===true)
				$this->mclusers->levelesemeny($email, "events", "click", 182, $egyezes, $info, "eng", $hibainfo);
			else
				$this->mclusers->levelesemeny($email, "events", "click", 178, $egyezes, $info, "eng", $hibainfo);
			
			redirect("presentation/kbb");
			
		}elseif($tema == "kbbworkshop"){
			$egyezes = "www.archlinexp.com/workshop/kbb";
			$info = "KBB London 2013: http://www.archlinexp.com/workshop/kbb";
			$hibainfo = "kbb workshop, eng";
			
			if(UJUGYFELKEZELO===true)
				$this->mclusers->levelesemeny($email, "events", "click", 182, $egyezes, $info, "eng", $hibainfo);
			else
				$this->mclusers->levelesemeny($email, "events", "click", 178, $egyezes, $info, "eng", $hibainfo);
			
			redirect("workshop/kbb");
			
		}elseif($tema == "tervezz-szabadon"){
			$egyezes = "www.archline.hu/tervezz-szabadon/palyazat";
			$info = "Tervezz szabadon pályázat: http://www.archline.hu/tervezz-szabadon/palyazat";
			$hibainfo = "tervezz szabadon, hun";
			
			$this->mclusers->levelesemeny($email, "events", "click", 273, $egyezes, $info, "hun", $hibainfo);
			
			redirect("tervezz-szabadon/palyazat");
			
		}elseif($tema == "tervezz-szabadon-amator"){
			$egyezes = "www.archline.hu/tervezz-szabadon/palyazat/amator";
			$info = "Tervezz szabadon pályázat: http://www.archline.hu/tervezz-szabadon/palyazat/amator";
			$hibainfo = "tervezz szabadon, hun amator";
			
			$this->mclusers->levelesemeny($email, "events", "click", 283, $egyezes, $info, "hun", $hibainfo);
			
			redirect("tervezz-szabadon/palyazat/amator");
			
		}elseif($tema == "tervezz-szabadon-felhasznalo"){
			$egyezes = "www.archline.hu/tervezz-szabadon/palyazat/felhasznalo";
			$info = "Tervezz szabadon pályázat: http://www.archline.hu/tervezz-szabadon/palyazat/felhasznalo";
			$hibainfo = "tervezz szabadon, hun felhasznalo";
			
			$this->mclusers->levelesemeny($email, "events", "click", 285, $egyezes, $info, "hun", $hibainfo);
			
			redirect("tervezz-szabadon/palyazat/felhasznalo");
			
		}elseif($tema == "feel-free-to-design-amature"){
			$egyezes = "www.archlinexp.com/voting/voting/amature";
			$info = "Tervezz szabadon pályázat: http://www.archline.com/voting/voting/amature";
			$hibainfo = "tervezz szabadon, eng amature";
			
			$this->mclusers->levelesemeny($email, "events", "click", 284, $egyezes, $info, "eng", $hibainfo);
			
			redirect("feel-free-to-design/voting/amature");
			
		}elseif($tema == "feel-free-to-design-user"){
			$egyezes = "www.archlinexp.com/feel-free-to-design/voting/user";
			$info = "Tervezz szabadon pályázat: http://www.archlinexp.com/feel-free-to-design/voting/felhasznalo";
			$hibainfo = "tervezz szabadon, eng user";
			
			$this->mclusers->levelesemeny($email, "events", "click", 286, $egyezes, $info, "eng", $hibainfo);
			
			redirect("feel-free-to-design/voting/felhasznalo");
			
		}else{
			$record->osztaly = "events";
			$record->fv = "click";
			$record->hiba = "Hibás téma: ".$tema."\nemail: ".$email;
			$record->datum = date('Y-m-d H:i:s',time());
			$this->db->insert('a_hibak',$record);
			
			redirect('');
		}
		
		redirect('');
    }
	
	function newclick(){
		$this->load->model('mclusers');
		
		$temptomb = explode("/", $_SERVER[ 'REQUEST_URI'] );
		$email = str_replace("%40","@",end($temptomb));
		$tema = $this->uri->segment(3);
		
		$user = $this->phpsession->get('user');
		$user['voltmobiloldal'] = true;
		$this->phpsession->save('user',$user);
		
		if($adatok = $this->db->where('alias',$tema)->get('followed_links')->row()){
			$egyezes   = $adatok->esem_cont;
			$info      = $adatok->esem_cont;
			$hibainfo  = $adatok->name;
			$lang      = $adatok->lang;
			$esem_id   = $adatok->esem_id;
			
			$this->mclusers->levelesemeny($email, "events", "newclick", $esem_id, $egyezes, $info, $lang, $hibainfo);
			
			header("Location: ".$adatok->redirect); exit;
		}
		
		redirect('');
	}
	
	function regcz(){
		$this->load->model('mclusers');
		
		$user["strName"] = $this->input->post("name");
		$user["strTel"] = $this->input->post("phone");
		$user["strEmail"] = $this->input->post("email");
		$user["nCtrID"] = 420;
		
		$info = "Regisztráció a honlapon: Presentation in Bratislava, name: ".$user["strName"].", phone: ".$user["strTel"];
		
		$nUserID = $this->mclusers->get_nUserIDByEmail($user["strEmail"],'esp');
		
		
		if($nUserID){
			$this->mclusers->addEvent($nUserID, "113", $info, 'esp');
			
		}else{
		
			$nUserID = $this->mclusers->addUserSpa($user);
			
			$this->mclusers->addEvent($nUserID, "113", $info,'esp');
			
		}
		
		$page = $this->mpages->get_row(638);
		
		$this->load->library('email');
		$this->email->initialize();
		
		$this->email->from('info@archlinexp.com', 'Cadline Weboldal');
		$this->email->subject('Registration, Presentation in Bratislava');
		$this->email->message($page->page_body);
		$this->email->send($this->input->post("email"), 'smtp');
		
		redirect('/page/show/638');
		
		/*$this->email->clear();
		
		$this->email->from('info@archlinexp.com', 'Cadline Weboldal');
		$this->email->subject('Registration, Presentation in Bratislava');
		$this->email->message($page->page_body);
		$this->email->send('info@archlinexp.com', 'smtp');*/
		
	}
	
	function chelseaflower(){
		
		$data['javascript'] = array(
					'jquery.mousewheel.min',
					
					'fancybox-1.3.4/fancybox/jquery.fancybox-1.3.4.pack',
					
				);
				
		$data['style'] = array(
					
					'../js/fancybox-1.3.4/fancybox/jquery.fancybox-1.3.4v2'
				);
		
		$data['title'] = "ARCHLine.XP, Chelsea Flower Show";
		
		$data['page']  = $this->mpages->get_row(687);
		
		$data['tartalom'] = 'other/chelseaflower';
		
		$this->load->view('site', $data);
	}
	
}