<?php
class Downloads extends Controller
{
	function Downloads()
	{
		parent::Controller();
		$this->load->model('mdownloads');
		$this->load->model('mctr');
	}
	
	function index()
	{
		$this->indexv2();
		return;
		
		$data['aktiv']=1;
		
		$data['lang']=$this->muser->user['lang'];
		hun() ? $data['ctr']=$this->mctr->get_all_ctr('ctrNameHun') : $data['ctr']=$this->mctr->get_all_ctr();
		
		if(jap()){
            $data['aktiv']=9;
			$data['tartalom']='downloads/japantrial';
			$data['javascript'] = array('prototype');
		}
		else
		{
			if(hun())
			    $data['cimlap'] = $this->mpages->get_row(304);
			elseif(be())
			    $data['cimlap'] = $this->mpages->get_row(364);
			else
			    $data['cimlap'] = $this->mpages->get_row(305);
			    
			$data['tartalom']='downloads/index';
			$data['javascript'] = array('downloads');
		}

		$data['title'] = hun() ? 'ARCHLine.XP Letöltés' : 'ARCHLine.XP Download';
		$data['csik']=array('home','downloads');
		$this->load->view('site',$data);
	}
	
	function indexv2(){
		$data['aktiv']=1;
		
		$data['lang']=$this->muser->user['lang'];
		hun() ? $data['ctr']=$this->mctr->get_all_ctr('ctrNameHun') : $data['ctr']=$this->mctr->get_all_ctr();
		
		if(hun())
		    $data['cimlap'] = $this->mpages->get_row(304);
		elseif(be())
		    $data['cimlap'] = $this->mpages->get_row(364);
		else
		    $data['cimlap'] = $this->mpages->get_row(305);
		
		//if( $_SERVER['REMOTE_ADDR']=='87.242.17.127' )
			$data['tartalom']='downloads/indexv3';
		/*else
			$data['tartalom']='downloads/indexv2';*/
		$data['javascript'] = array(
								/*'downloads',*/
								'regformcheck',
								'fancybox/jquery-1.3.2.min',
								'fancybox/jquery.easing.1.3',
								'fancybox/jquery.fancybox-1.2.1.pack'/*,
								'fancybox/fancy'*/
								);
		$data['style'] = array('fancybox_gal');

		$data['title'] = hun() ? 'ARCHLine.XP Építészeti próbaverzió Letöltés' : 'ARCHLine.XP Architect trial Download';
		$data['csik']=array('home','downloads');
		$this->load->view('site',$data);
	}
	
	function japantrial()
	{
		$data['aktiv']=9;
		
		$data['lang']=$this->muser->user['lang'];
		$data['tartalom']='downloads/japantrial';
		$data['javascript'] = array('prototype');
		$data['csik']=array('home','downloads');
		$this->load->view('site',$data);
	}
	
	
	function student()
	{
		$this->studentv2();
		return;
		
		$data['aktiv']=5;
		$data['ctr'] = hun() ? $this->mctr->get_all_ctr('ctrNameHun') : $this->mctr->get_all_ctr();
		$data['lang']=$this->muser->user['lang'];
		
		$data['title'] = hun() ? 'ARCHLine.XP Letöltés - Diákváltozat' : 'ARCHLine.XP Download - Student';
		$data['tartalom'] = 'downloads/student';
		$data['javascript'] = array('downloads_stud');
		$data['csik'] = array('home','downloads');
		$this->load->view('site',$data);
	}
	
	function studentv2(){
	
		redirect('downloads');
		
		$data['ctr'] = hun() ? $this->mctr->get_all_ctr('ctrNameHun') : $this->mctr->get_all_ctr();
		$data['lang']=$this->muser->user['lang'];
		
		
		$data['title'] = hun() ? 'ARCHLine.XP Építészet letöltés - Diákváltozat' : 'ARCHLine.XP Download - Student';
		$data['tartalom'] = 'downloads/studentv2';
		$data['javascript'] = array('downloads_stud');
		$data['csik'] = array('home','downloads');
		$this->load->view('site',$data);
	}
	
	function student2009()
	{
		$data['aktiv']=5;
		
		$data['lang']=$this->muser->user['lang'];
		$data['tartalom']='downloads/student2009';
		$data['javascript'] = array('prototype');
		$data['csik']=array('home','downloads');
		$this->load->view('site',$data);
	}
	
	function itc()
	{
		Header("HTTP/1.1 301 Moved Permanently");
		if(hun())
			header("Location: /page/show/462");
		else
			Header("Location: /page/show/469");
		exit;
		
		$data['aktiv']=6;
		$data['ctr'] = hun() ? $this->mctr->get_all_ctr('ctrNameHun') : $this->mctr->get_all_ctr();
		$data['lang']=$this->muser->user['lang'];

		$data['title'] = hun() ? 'ARCHLine.XP Letöltés - ITC' : 'ARCHLine.XP Download - ITC';
		$data['tartalom']='downloads/itc';
		$data['csik']=array('home','downloads');
		$data['javascript'] = array('prototype');
		$this->load->view('site',$data);
	}
	
	function validate()
	{
		$this->load->helper('email');
		
		$email = ($this->input->post('strEMail') && $this->input->post('strEMail')!="") ? $this->input->post('strEMail') : $this->input->post('email');
		$do = $this->input->post('do');
		
		$record['stat_lang']=$this->muser->user['lang'];
		$record['stat_date']=time();
		
		if($do && valid_email($email))
		{
			$code = md5($this->config->item('salt').time().$email.$do);
			
			$mezok = array('strName1','strName2','strCompany','strStreet','strCity','strZip','ctrName','strEMail','strTel','nUserProf');
			$infotomb = array();
			foreach($mezok as $mezo)
				$infotomb[$mezo] = $this->input->post($mezo);
			
			if($do == 'trial')
			{
				if($this->input->post('public')=='on' && (!$this->input->post('cim') || $this->input->post('cim')==''))
				    redirect('downloads');
				
				//if( $_SERVER['REMOTE_ADDR']=='87.242.17.127' ){
					$record['stat_version'] = 'trial';
					$record['stat_email'] = $this->input->post('strEMail');
					$record['stat_first'] = trim($this->input->post('strName1')." ".$this->input->post('strName2'));
					$record['stat_country'] = $this->input->post('ctrName');
					$record['stat_lang'] = $this->muser->user['lang'];
					$record['stat_tel'] = $this->input->post('strTel');
					$record['stat_cim'] = $this->input->post('ctrName')." ".$this->input->post('strCity').' '.$this->input->post('strStreet').' '.$this->input->post('strZip');
					$record['stat_code'] = $code;
					$record['stat_date'] = time();
					$record['info']      = json_encode($infotomb);
				//}
				/*else{
					$record['stat_version'] = 'trial';
					$record['stat_email'] = $email;
					$record['stat_first'] = $this->input->post('first');
					$record['stat_country'] = $this->input->post('country');
					$record['stat_lang'] = $this->muser->user['lang'];
					$record['stat_tel'] = $this->input->post('tel');
					$record['stat_cim'] = $this->input->post('cim');
					$record['stat_code'] = $code;
					$record['stat_date'] = time();
					if(hun())
						$record['info'] = $this->input->post('szakmai');
				}*/
				
				if( $this->input->post('infok') == "on" ){
					$record['stat_last'] = $this->input->post('infok');
				}
				
				
				$this->db->insert('download_stats_temp',$record);
				
				//sending the e-mail
				$mail_vars['first'] = $this->muser->string_to_code($this->input->post('first'));
				$mail_vars['email'] = $this->input->post('email',true);
				
				//set the authenticating link
				$mail_vars['confirm_link'] = hun() ? 'http://archline.hu/downloads/confirm/' . $code : 'http://www.archlinexp.com/downloads/confirm/' . $code;
				
				//setting and sending the email
				$this->load->library('email');
				$this->email->initialize();
				$this->email->addOfficialImages();
				
		//		$this->email->setFrom('info@cadline.hu', 'CadLine');
			
				if(hun())
				{
					$this->email->setFrom('info@cadline.hu', 'CadLine');
					$mail_vars['mailcontent'] = 'mail/confirm_dl_hun';
					$this->email->subject('ARCHLine.XP letoltes');
					$this->email->message($this->load->view('mail',$mail_vars,true));
				}
				else
				{
					$this->email->setFrom('info@archlinexp.com', 'CadLine');
					$mail_vars['mailcontent'] = 'mail/confirm_dl_eng';
					$this->email->subject('ARCHLine.XP Download');
					$this->email->message($this->load->view('mail',$mail_vars,true));
				}
				
				//$this->email->send($mail_vars['email'],'smtp');
				$this->email->send($email,'smtp');
				
				
				redirect('downloads/sentconf');
			}
			
			elseif($do=='student')
			{
                if($this->input->post('public_std')=='on' && (!$this->input->post('cim_std') || $this->input->post('cim_std')==''))
				    redirect('downloads/student');

				$record['stat_version'] = 'student';
				$record['stat_email'] = $email;
				$record['stat_first'] = $this->input->post('first_std');
				$record['stat_country'] = $this->input->post('country_std');
				$record['stat_cim'] = $this->input->post('cim_std');
				$record['stat_code'] = $code;
				$record['stat_date'] = time();
				$record['stat_lang'] = $this->muser->user['lang'];
				$record['stat_school'] = $this->input->post('school_std');
				
				if( $this->input->post('infok') == "on" ){
					$record['stat_last'] = $this->input->post('infok');
				}
				
				$this->db->insert('download_stats_temp', $record);
				
				//sending the e-mail
				$mail_vars['first'] = $this->muser->string_to_code($this->input->post('first'));
				$mail_vars['email'] = $email;

				//set the authenticating link
				$mail_vars['confirm_link'] = hun() ? 'http://archline.hu/downloads/confirm/' . $code : 'http://www.archlinexp.com/downloads/confirm/' . $code;

				//setting and sending the email
				$this->load->library('email');
				$this->email->initialize();
				$this->email->addOfficialImages();

		//		$this->email->setFrom('info@cadline.hu', 'CadLine');

				if(hun())
				{
					$this->email->setFrom('info@cadline.hu', 'CadLine');
					$mail_vars['mailcontent'] = 'mail/confirm_dl_hun';
					$this->email->subject('ARCHLine.XP letoltes');
					$this->email->message($this->load->view('mail', $mail_vars, true));
				}
				else
				{
					$this->email->setFrom('info@archlinexp.com', 'CadLine');
					$mail_vars['mailcontent'] = 'mail/confirm_dl_eng';
					$this->email->subject('ARCHLine.XP Download');
					$this->email->message($this->load->view('mail', $mail_vars, true));
				}

				$this->email->send($mail_vars['email'], 'smtp');
								
				redirect('downloads/sentconf');
			}
			elseif($do=='itc')
			{
				$record['stat_version']='trial';
				$record['stat_email']=$this->input->post('email_std');
				
				$record['stat_first'] = $this->input->post('first_itc',true);
				$record['stat_country'] = $this->input->post('country_itc',true);
				
				
				
				$this->db->insert('download_stats',$record);
				
				// E-Mail küldés
				$mail_vars['file'] = $this->muser->get_setting('itc_'.$this->muser->user['lang']);
				$mail_vars['url'] = $this->config->item('base_url').$mail_vars['file'];
				
				$mail_vars['lang']=$this->muser->user['lang'];
				$mail_vars['version']='itc';
				
				$mail_vars['first'] = $this->muser->string_to_code($this->input->post('first_itc',true));
				$mail_vars['country'] = $this->muser->string_to_code($this->input->post('country_itc',true));
				$mail_vars['email'] = $this->input->post('email',true);
				
				///////////
				
				$this->load->library('email');
				$this->email->initialize();
				$this->email->addOfficialImages();
				$this->email->setTextCharset('UTF-8');
	
				$mail_vars['archline']  = $this->input->post('prog_archline');
				$mail_vars['autocad']  = $this->input->post('prog_autocad');
				$mail_vars['archicad'] = $this->input->post('prog_archicad');
				
				if($mail_vars['archline'] == 1)
				{
					$mail_vars['archline'] = '<b>X</b>';
				}
				if($mail_vars['autocad'] == 1)
				{
					$mail_vars['autocad'] = '<b>X</b>';
				}
				if($mail_vars['archicad'] == 1)
				{
					$mail_vars['archicad'] = '<b>X</b>';
				}
				
				$this->email->from('info@cadline.hu', 'CadLine');
				
				if(hun())
				{
					$mail_vars['mailcontent']='downloads/mail_itc_hun';
					$mail_vars['demourl']=$this->muser->get_setting('itc',$this->muser->user['lang']);
					$this->email->subject('ITC Items');
					$this->email->message($this->load->view('mail',$mail_vars,true));
				}
				else
				{
					$mail_vars['mailcontent']='downloads/mail_itc_eng';
					$mail_vars['demourl']=$this->muser->get_setting('itc',$this->muser->user['lang']);
					$this->email->subject('ITC Items');
					$this->email->message($this->load->view('mail',$mail_vars,true));
				}
				
				//$this->load->view('downloads/mail_itc_hun',$mail_vars);
				$this->email->send($mail_vars['email'],'smtp');
				
				// Mail nekünk is

				$this->email->clear();
				$this->email->setTextCharset('UTF-8');

				if(hun())
				{
					$this->email->from('info@cadline.hu', 'CadLine');
					$this->email->subject('ITC Items Let&ouml;lt&eacute;s');
		//			$this->email->message($this->load->view('business/report_dl_itc',$mail_vars,true));
				}
				else
				{
					$this->email->from('info@cadline.hu', 'CadLine');
					$this->email->subject('ITC Items Download');
		//			$this->email->message($this->load->view('business/report_dl_itc',$mail_vars,true));
				}

				$this->email->send('info@cadline.hu','smtp');
							
				redirect('downloads/sent');
			}
			elseif($do=='3months')
			{
				$record['stat_version']='3months';
				$record['stat_email']=$email;
				$record['stat_first'] = $this->input->post('nev',true);
				$record['stat_cim'] = $this->input->post('cim',true);
				$record['stat_tel'] = $this->input->post('tel',true);
				$record['stat_fax'] = $this->input->post('fax',true);
				$record['stat_pron'] = $this->input->post('pron',true);
				$record['stat_company'] = $this->input->post('cegnev',true);
				$record['stat_ucAUC'] = $this->input->post('cb1',true);
				$record['stat_ucARC'] = $this->input->post('cb2',true);
				$record['stat_ucVEW'] = $this->input->post('cb3',true);
				$record['stat_ucJWC'] = $this->input->post('cb4',true);
				$record['stat_ucART'] = $this->input->post('cb5',true);
				$record['stat_ucGSK'] = $this->input->post('cb6',true);
				$record['stat_ucDRC'] = $this->input->post('cb7',true);
				$record['stat_ucSSO'] = $this->input->post('cb8',true);
				$record['stat_ucELS'] = $this->input->post('other',true);
				$record['stat_opinion'] = $this->input->post('comment',true);
				
				//$record['host'] gethostbyaddr($_SERVER['remote_addr']);
				
				
				$this->db->insert('download_stats',$record);
				
				// E-Mail küldés
				$mail_vars['file'] = $this->muser->get_setting('3months',$this->muser->user['lang']);
				$mail_vars['url'] = $this->config->item('base_url').$mail_vars['file'];
				
				$mail_vars['lang']=$this->muser->user['lang'];
				$mail_vars['version']='trial';
				
				$mail_vars['name'] = $this->input->post('nev',true);
				$mail_vars['pron'] = $this->input->post('pron',true);
				$mail_vars['email'] = $this->input->post('email');
				$mail_vars['tel'] = $this->input->post('tel',true);
				$mail_vars['fax'] = $this->input->post('fax',true);
				$mail_vars['cim'] = $this->input->post('cim',true);
				
				$mail_vars['demourl']=$this->muser->get_setting('3months',$this->muser->user['lang']);
				
				$this->load->library('email');
				$this->email->initialize();
			
				$this->email->from('info@cadline.hu', 'ARCHLine.XP Support');
				
				$this->email->subject('ARCHLine.XP');
				$this->email->message($this->load->view('downloads/mail_3m_jap',$mail_vars,true));
				
				$this->email->send($mail_vars['email'],'smtp');
				
				$this->email->clear();
								
				redirect('downloads/sent');
			}
			elseif($do=='japtrial')
			{
				$record['stat_version']='japtrial';
				$record['stat_email']=$email;
				$record['stat_country'] = 'jap';
				$record['stat_first'] = $this->input->post('nev',true);
				$record['stat_cim'] = $this->input->post('cim',true);
				$record['stat_tel'] = $this->input->post('tel',true);
				$record['stat_fax'] = $this->input->post('fax',true);
				$record['stat_pron'] = $this->input->post('pron',true);
				$record['stat_company'] = $this->input->post('cegnev',true);
				$record['stat_ucAUC'] = $this->input->post('cb1',true);
				$record['stat_ucARC'] = $this->input->post('cb2',true);
				$record['stat_ucVEW'] = $this->input->post('cb3',true);
				$record['stat_ucJWC'] = $this->input->post('cb4',true);
				$record['stat_ucART'] = $this->input->post('cb5',true);
				$record['stat_ucGSK'] = $this->input->post('cb6',true);
				$record['stat_ucDRC'] = $this->input->post('cb7',true);
				$record['stat_ucSSO'] = $this->input->post('cb8',true);
				$record['stat_ucELS'] = $this->input->post('other',true);
				$record['stat_opinion'] = $this->input->post('comment',true);
				
				$this->db->insert('download_stats',$record);
				
				// E-Mail küldés
				$mail_vars['file'] = $this->muser->get_setting('3months',$this->muser->user['lang']);
				$mail_vars['url'] = $this->config->item('base_url').$mail_vars['file'];
				
				$mail_vars['lang']=$this->muser->user['lang'];
				$mail_vars['version']='trial';
				
				$mail_vars['name'] = $this->input->post('nev',true);
				$mail_vars['pron'] = $this->input->post('pron',true);
				$mail_vars['email'] = $this->input->post('email');
				$mail_vars['tel'] = $this->input->post('tel',true);
				$mail_vars['fax'] = $this->input->post('fax',true);
				$mail_vars['cim'] = $this->input->post('cim',true);
				
				$mail_vars['demourl']=$this->muser->get_setting('trial',$this->muser->user['lang']);
				
				$this->load->library('email');
				$this->email->initialize();

				$this->email->from('info@cadline.hu', 'ARCHLine.XP Support');
				
				
				$this->email->subject('ARCHLine.XP');
				$this->email->message($this->load->view('downloads/mail_trial_jap',$mail_vars,true));
				
				$this->email->send($mail_vars['email'],'smtp');
				
				$this->email->clear();
								
				redirect('downloads/sent');
			}
			
			elseif($do == 'interior')
			{
                if($this->input->post('public')=='on' && (!$this->input->post('cim') || $this->input->post('cim')==''))
				    redirect('downloads');

    			/*$record['stat_version'] = 'interior';
				$record['stat_email'] = $email;
				$record['stat_first'] = $this->input->post('first');
				$record['stat_country'] = $this->input->post('country');
				$record['stat_cim'] = $this->input->post('cim');
				$record['stat_tel'] = $this->input->post('tel');
				$record['stat_code'] = $code;
				$record['stat_date'] = time();
				$record['stat_lang'] = $this->muser->user['lang'];*/
				$record['stat_version'] = 'interior';
				$record['stat_email'] = $this->input->post('strEMail');
				$record['stat_first'] = trim($this->input->post('strName1')." ".$this->input->post('strName2'));
				$record['stat_country'] = $this->input->post('ctrName');
				$record['stat_lang'] = $this->muser->user['lang'];
				$record['stat_tel'] = $this->input->post('strTel');
				$record['stat_cim'] = $this->input->post('ctrName')." ".$this->input->post('strCity').' '.$this->input->post('strStreet').' '.$this->input->post('strZip');
				$record['stat_code'] = $code;
				$record['stat_date'] = time();
				$record['info']      = json_encode($infotomb);
				
				if( $this->input->post('infok') == "on" ){
					$record['stat_last'] = $this->input->post('infok');
				}
				
				/*if(hun())
					$record['info'] = $this->input->post('szakmai');*/
				

				$this->db->insert('download_stats_temp', $record);

				//sending the e-mail
				$mail_vars['first'] = $this->muser->string_to_code($this->input->post('first'));
				$mail_vars['email'] = $this->input->post('strEMail',true);

				//set the authenticating link
				$mail_vars['confirm_link'] = hun() ? 'http://archline.hu/downloads/confirm/' . $code : 'http://www.archlinexp.com/downloads/confirm/' . $code;

				//setting and sending the email
				$this->load->library('email');
				$this->email->initialize();
				$this->email->addOfficialImages();

			//	$this->email->setFrom('info@cadline.hu', 'CadLine');

				if(hun())
				{
					$this->email->setFrom('info@cadline.hu', 'CadLine');
					$mail_vars['mailcontent'] = 'mail/confirm_dl_hun';
					$this->email->subject('ARCHLine.XP letoltes');
					$this->email->message($this->load->view('mail',$mail_vars,true));
				}
				elseif(esp())
				{
					$this->email->setFrom('info@archlinexp.com', 'CadLine');
					$mail_vars['mailcontent'] = 'mail/confirm_dl_esp';
					$this->email->subject('Descargar ARCHLine.XP');
					$this->email->message($this->load->view('mail',$mail_vars,true));
				}
				else
				{
					$this->email->setFrom('info@archlinexp.com', 'CadLine');
					$mail_vars['mailcontent'] = 'mail/confirm_dl_eng';
					$this->email->subject('ARCHLine.XP Download');
					$this->email->message($this->load->view('mail',$mail_vars,true));
				}

				$this->email->send($email,'smtp');
				//print "email: ".$email;
				
				// átirányítás
				redirect('downloads/sentconf');
			}
			
			
			elseif($do == 'free')
			{
				return;
				
                if($this->input->post('public')=='on' && (!$this->input->post('cim') || $this->input->post('cim')==''))
				    redirect('free');

    			$record['stat_version'] = 'free';
				$record['stat_email'] = $email;
				$record['stat_first'] = $this->input->post('first');
				$record['stat_country'] = $this->input->post('country');
				$record['stat_cim'] = $this->input->post('cim');
				$record['stat_code'] = $code;
				$record['stat_date'] = time();
				$record['stat_tel'] = $this->input->post('tel');
				$record['stat_lang'] = $this->muser->user['lang'];

				$this->db->insert('download_stats_temp', $record);

			
				$mail_vars['first'] = $this->muser->string_to_code($this->input->post('first'));
				$mail_vars['email'] = $this->input->post('email',true);

				
				$mail_vars['confirm_link'] = hun() ? 'http://archline.hu/downloads/confirm/' . $code : 'http://www.archlinexp.com/downloads/confirm/' . $code;

				
				$this->load->library('email');
				$this->email->initialize();
				$this->email->addOfficialImages();

		//		$this->email->setFrom('info@cadline.hu', 'CadLine');

				if(hun())
				{
					$this->email->setFrom('info@cadline.hu', 'CadLine');
					$mail_vars['mailcontent'] = 'mail/confirm_dl_hun';
					$this->email->subject('ARCHLine.XP letoltes');
					$this->email->message($this->load->view('mail',$mail_vars,true));
				}
				elseif(esp())
				{
					$this->email->setFrom('info@archlinexp.com', 'CadLine');
					$mail_vars['mailcontent'] = 'mail/confirm_dl_esp';
					$this->email->subject('Descargar ARCHline XP');
					$this->email->message($this->load->view('mail',$mail_vars,true));
				}
				else
				{
					$this->email->setFrom('info@archlinexp.com', 'CadLine');
					$mail_vars['mailcontent'] = 'mail/confirm_dl_eng';
					$this->email->subject('ARCHLine.XP Download');
					$this->email->message($this->load->view('mail',$mail_vars,true));
				}

				$this->email->send($email,'smtp');
				
				
				redirect('downloads/sentconf');
			}
			
			elseif($do == 'photo')
			{
				return;
				
                if($this->input->post('public')=='on' && (!$this->input->post('cim') || $this->input->post('cim')==''))
				    redirect('photo');

    			$record['stat_version'] = 'photo';
				$record['stat_email'] = $email;
				$record['stat_first'] = $this->input->post('first');
				$record['stat_country'] = $this->input->post('country');
				$record['stat_cim'] = $this->input->post('cim');
				$record['stat_code'] = $code;
				$record['stat_date'] = time();
				$record['stat_tel'] = $this->input->post('tel');
				$record['stat_lang'] = $this->muser->user['lang'];
				
				if( $this->input->post('infok') == "on" ){
					$record['stat_last'] = $this->input->post('infok');
				}
				
				if(hun())
					$record['info'] = $this->input->post('szakmai');

				$this->db->insert('download_stats_temp', $record);

			
				$mail_vars['first'] = $this->muser->string_to_code($this->input->post('first'));
				$mail_vars['email'] = $this->input->post('email',true);

				
				$mail_vars['confirm_link'] = hun() ? 'http://archline.hu/downloads/confirm/' . $code : 'http://www.archlinexp.com/downloads/confirm/' . $code;

				
				$this->load->library('email');
				$this->email->initialize();
				$this->email->addOfficialImages();

		//		$this->email->setFrom('info@cadline.hu', 'CadLine');

				if(hun())
				{
					$this->email->setFrom('info@cadline.hu', 'CadLine');
					$mail_vars['mailcontent'] = 'mail/confirm_dl_hun';
					$this->email->subject('ARCHLine.XP Photo Edition letoltes');
					$this->email->message($this->load->view('mail',$mail_vars,true));
				}
				elseif(esp())
				{
					$this->email->setFrom('info@archlinexp.com', 'CadLine');
					$mail_vars['mailcontent'] = 'mail/confirm_dl_esp';
					$this->email->subject('Descargar ARCHline XP');
					$this->email->message($this->load->view('mail',$mail_vars,true));
				}
				else
				{
					$this->email->setFrom('info@archlinexp.com', 'CadLine');
					$mail_vars['mailcontent'] = 'mail/confirm_dl_eng';
					$this->email->subject('ARCHLine.XP Photo Edition Download');
					$this->email->message($this->load->view('mail',$mail_vars,true));
				}

				$this->email->send($mail_vars['email'],'smtp');
				
				
				redirect('downloads/sentconf');
			}
			
			elseif($do == 'reader'){
				
				$record['stat_version'] = 'reader';
				$record['stat_email']   = $this->input->post('strEMail');
				$record['stat_first']   = trim($this->input->post('strName1')." ".$this->input->post('strName2'));
				$record['stat_country'] = $this->input->post('ctrName');
				$record['stat_lang']    = $this->muser->user['lang'];
				$record['stat_tel']     = $this->input->post('strTel');
				$record['stat_cim']     = $this->input->post('ctrName')." ".$this->input->post('strCity').' '.$this->input->post('strStreet').' '.$this->input->post('strZip');
				$record['stat_code']    = $code;
				$record['stat_date']    = time();
				$record['info']         = json_encode($infotomb);
				
				if( $this->input->post('infok') == "on" ){
					$record['stat_last'] = $this->input->post('infok');
				}
				
				$this->db->insert('download_stats_temp', $record);
				
				//sending the e-mail
				$mail_vars['first'] = $this->muser->string_to_code($record['stat_first']);
				$mail_vars['email'] = $this->input->post('strEMail',true);
				
				//set the authenticating link
				$mail_vars['confirm_link'] = hun() ? 'http://archline.hu/downloads/confirm/' . $code : 'http://www.archlinexp.com/downloads/confirm/' . $code;
				
				//setting and sending the email
				$this->load->library('email');
				$this->email->initialize();
				$this->email->addOfficialImages();
				
				if(hun()){
					$this->email->setFrom('info@cadline.hu', 'CadLine');
					$mail_vars['mailcontent'] = 'mail/confirm_dl_hun';
					$this->email->subject('ARCHLine.XP Reader letöltés - regisztráció');
					$this->email->message($this->load->view('mail',$mail_vars,true));
				}
				else{
					$this->email->setFrom('info@archlinexp.com', 'CadLine');
					$mail_vars['mailcontent'] = 'mail/confirm_dl_eng';
					$this->email->subject('ARCHLine.XP Reader Download - Registration');
					$this->email->message($this->load->view('mail',$mail_vars,true));
				}
				
				$this->email->send($email,'smtp');
				
				// átirányítás
				redirect('downloads/sentconf');
			}
			
			else
			{
				show_404();
			}
		}
		else
		{
			show_404();
		}
		
	}
	
	
	function get()
	{
		$download_id = $this->uri->rsegment(3);
		
		if($download_id==1000){
			$download_id = (hun()) ? 10 : 58;
		}
		
		if(!$download_id || !is_numeric($download_id))
		{
			show_404();
		}
		
		$record = $this->mdownloads->get_row($download_id);
		if(!$record)
		{
			show_404();
		}
		
		$this->db->simple_query("update downloads set download_count=download_count+1 where download_id=$download_id");
		
		//redirect($record->download_file);
		header("Location: ".$record->download_file);
	}
	
	function sentconf()
	{
        $data['title'] = hun() ? 'ARCHLine.XP Letöltés' : 'ARCHLine.XP Download';
		$data['tartalom']='downloads/sentconf';
		$data['csik']=array('Home','Download');
		$data['lang']=$this->muser->user['lang'];

		$this->load->view('site',$data);
	}
	
	function sentstu()
	{
		if( !hun() ){
			include('application/helpers/video.php');
			//$videohtml = video_html('workshop_beginner_level');
			$videok = $this->db->query("SELECT * FROM videos WHERE csoport='workshop_beginner_level' AND sorszam > 0 ORDER BY sorszam")->result();
			$csoport2 = $this->db->query("SELECT * FROM videogroups WHERE azon='workshop_beginner_level'")->row();
			$videohtml = video_strcsere('workshop_beginner_level',$csoport2,$videok);
			
			$data['videohtml']   = $videohtml;
			$data['style']       = array( 'jquery.jscrollpane' );
			$data['javascript']  = array( 'jquery.mousewheel.min', 'jscrollpane/jquery.jscrollpane.min' );
		}
		
		
        $data['title'] = hun() ? 'ARCHLine.XP Diákváltozat Letöltés - Sikeres' : 'ARCHLine.XP Student Download - Successful';
		$data['tartalom']='downloads/sentstu';
		$data['csik']=array('Home','Download');
		$data['lang']=$this->muser->user['lang'];
		
		$this->load->view('site',$data);
	}
	
	
	function senttri()
	{
		if( !hun() ){
			include('application/helpers/video.php');
			//$videohtml = video_html('workshop_beginner_level');
			$videok = $this->db->query("SELECT * FROM videos WHERE csoport='workshop_beginner_level' AND sorszam > 0 ORDER BY sorszam")->result();
			$csoport2 = $this->db->query("SELECT * FROM videogroups WHERE azon='workshop_beginner_level'")->row();
			$videohtml = video_strcsere('workshop_beginner_level',$csoport2,$videok);
			
			$data['videohtml']   = $videohtml;
			$data['style']       = array( 'jquery.jscrollpane' );
			$data['javascript']  = array( 'jquery.mousewheel.min', 'jscrollpane/jquery.jscrollpane.min' );
		}
		
    	$data['title'] = hun() ? 'ARCHLine.XP Próbaverzió Letöltés - Sikeres' : 'ARCHLine.XP Trial Download - Successful';
		$data['tartalom']='downloads/senttri';
		$data['csik']=array('home','downloads');
		$data['lang']=$this->muser->user['lang'];
		
		$this->load->view('site',$data);
	}
	
	function sentint()
	{
		if( !hun() ){
			include('application/helpers/video.php');
			//$videohtml = video_html('workshop_beginner_level');
			$videok    = $this->db->query("SELECT * FROM videos WHERE csoport='workshop_beginner_level' AND sorszam > 0 ORDER BY sorszam")->result();
			$csoport   = $this->db->query("SELECT * FROM videogroups WHERE azon='workshop_beginner_level'")->row();
			$videohtml = video_strcsere('workshop_beginner_level',$csoport,$videok);
			
			$data['videohtml']   = $videohtml;
			$data['style']       = array( 'jquery.jscrollpane' );
			$data['javascript']  = array( 'jquery.mousewheel.min', 'jscrollpane/jquery.jscrollpane.min' );
		}
		
        $data['title'] = hun() ? 'ARCHLine.XP Interior Letöltés - Sikeres' : 'ARCHLine.XP Interior Download - Successful';
		$data['tartalom']='downloads/sentint';
		$data['csik']=array('home','downloads');
		$data['lang']=$this->muser->user['lang'];

		$this->load->view('site',$data);
	}
	
	function sent()
	{
		redirect('downloads/senttri');
	}
	
	
	function updates()
	{
		
		$data['heading']=$this->mdownloads->get_heading('updates');
		$data['downloads']=$this->mdownloads->get_category('updates',$this->muser->user['lang']);
		$data['aktiv']=2;
		
		$data['lang']=$this->muser->user['lang'];
		$data['tartalom']='downloads/list';
		$data['csik']=array('home','downloads','updates');
		$data['title'] = hun() ? 'ARCHline.XP CAD szoftver - Frissítések letöltés' : 'ARCHline.XP CAD Software - Download Updates';
		$this->load->view('site',$data);
	}
	
	function support()
	{
		
		$data['heading']=$this->mdownloads->get_heading('support');
		$data['downloads']=$this->mdownloads->get_category('support',$this->muser->user['lang']);
		$data['aktiv']=4;
		
		$data['lang']=$this->muser->user['lang'];
		$data['title'] = hun() ? 'ARCHLine.XP Támogatás' : 'ARCHLine.XP Support';
		$data['tartalom']='downloads/list';
		$data['csik']=array('home','downloads','support');
		$this->load->view('site',$data);
	}
	
	function drivers()
	{
		$data['heading']=$this->mdownloads->get_heading('drivers');
		$data['downloads']=$this->mdownloads->get_category('drivers',$this->muser->user['lang']);
		$data['aktiv']=3;
		
		$data['lang']=$this->muser->user['lang'];
		
		$data['title'] = hun() ? 'ARCHLine.XP Driverek' : 'ARCHLine.XP Drivers';
		$data['tartalom']='downloads/list';
		$data['csik']=array('home','downloads','drivers');
		$this->load->view('site',$data);
	}
	
	function confirm()
	{
		if(!$this->uri->segment(3))
		    redirect('');
		elseif($this->uri->segment(3) == "sarga"){
			$sargakonyvbe = array();
				
				//$sargaorszagok = $this->db->get('`clusers_eng`.`cl_countries`')->result_array();
				$sargaorszagok = $this->db->query('SELECT * FROM `'.CRMADATBAZIS.'`.`countries` WHERE show_db LIKE "%clusers_eng%"')->result_array();
				foreach( $sargaorszagok as $orszag )
					$sargakonyvbe[$orszag['ctrID']] = strtolower($orszag['ctrNameEng']);
				
				$sargakonyvbe[44] = "united kingdom";
				$sargakonyvbe[70] = "russia";
				unset($sargakonyvbe[34], $sargakonyvbe[67], $sargakonyvbe[77]);
			
			print "<pre>";print_r($sargakonyvbe);print"</pre>";
			print " kod: ".$tomb->nCtrID = array_search('czech republic', $sargakonyvbe);
		}
		else
		{
			$code = $this->uri->segment(3);
			
			$query = $this->db->where('stat_code', $code)->limit(1)->get('download_stats_temp');
			
			$result = $query->result_array();
			
			if(empty($result))
			{
                $data['title'] = hun() ? 'ARCHLine.XP Letöltés - Hiba' : 'ARCHLine.XP Download - Error';
				$data['tartalom'] = 'error/mail_temp_notexists';
				$data['csik'] = array('home', 'downloads');
				$data['lang'] = $this->muser->user['lang'];

				$this->load->view('site', $data);
			}
			else
			{
				$kekkonyvbe = array("magyarország","hungary","magyar","slovakia","szlovákia","románia","romania");
				$pinkkonyvbe = array("spanyolország","spain","argentína","argentina","costa rica","portugália","portugal",/*"csehország","czech republic",*/"mexico","mexikó");
				$sargakonyvbe = array();
				$egyikbese = array("ausztria","austria","olaszország","italy","németország","germany","dél-korea","korea, south","észak-korea","korea, north");
				
				$sargaorszagok = $this->db->query('SELECT * FROM `'.CRMADATBAZIS.'`.`countries` WHERE show_db LIKE "%clusers_eng%"')->result_array();
				foreach( $sargaorszagok as $orszag )
					$sargakonyvbe[$orszag['ctrID']] = strtolower($orszag['ctrNameEng']);
				
				$sargakonyvbe[44] = "united kingdom";
				$sargakonyvbe[70] = "russia";
				unset($sargakonyvbe[34], $sargakonyvbe[39], $sargakonyvbe[43], $sargakonyvbe[67], $sargakonyvbe[77], $sargakonyvbe[420]);
				
                foreach($result as $row)
				{
					foreach($row as $k => $r){
						if($k!='stat_code' && $k!='stat_id')
							$record[$k] = $row[$k];
					}
					
					$jsinfo = json_decode($row['info']);
					
					$record['stat_date'] = time();
					$kisorszag = strtolower($record['stat_country']);
					
	                //inserting to the final table
					$this->db->insert('download_stats', $record);
					
					// kek konyvbe is ha magyar vagy szlovák
					if( in_array(strtolower($record['stat_country']),$kekkonyvbe) ){
						// email szerepel-e az email clusersben
						$this->load->model('mclusers');
						$nUserID = $this->mclusers->get_nUserIDByEmailFirst($record['stat_email']);
						
						$info22 = "Verzió: ".$row['stat_version'];
						$info22 .= " , cím: ".$row['stat_cim'];
						$info22 .= " , tel: ".$row['stat_tel'];
						
						/*if( $row['info'] != "" )
							$info22 .= ", ".$row['info'];*/
						
						if( $row['stat_school'] != "" )
							$info22 .= ", iskola: ".$row['stat_school'];
						
						
						if($nUserID){
							$this->mclusers->addEvent($nUserID, "117", $info22);
							$frissiteni = (array)$jsinfo;
							$this->mclusers->userUpdateIfEmpty($nUserID,$frissiteni);
						}else{
							// user beszúrás
							$tomb->strName    = $row['stat_first'];
							$tomb->strTel     = $row['stat_tel'];
							$tomb->strEMail   = $row['stat_email'];
							$tomb->strStreet  = $jsinfo->strStreet;
							$tomb->strCity    = $jsinfo->strCity;
							$tomb->strZip     = $jsinfo->strZip;
							$tomb->strCompany = $jsinfo->strCompany;
							$tomb->nUserProf  = $jsinfo->nUserProf;
							$tomb->nUserType = "0";
							$tomb->nCtrID    = "36";
							
							switch(strtolower($record['stat_country'])){
								case "slovakia":
								case "szlovákia":
									$tomb->nCtrID = "421";
									break;
								case "romania":
								case "románia":
									$tomb->nCtrID = "40";
									break;
							}
							
							
							
							if( $row['stat_last'] == "on" )
								$tomb->strInfo = "letöltés: '".lang('down_int_keres')."'";
							
							if( $row['stat_version'] != "student" )
								$tomb->nEsely = "3";
							/*else
								$tomb->nUserProf = "10";
							
							if( $row['stat_version'] == "interior" )
								$tomb->nUserProf = "4";*/
							
							$nUserID = $this->mclusers->addUserHun($tomb);
							
							// email beszúrás
							$tomb2->email   = $row['stat_email'];
							$tomb2->nUserID = $nUserID;
							$tomb2->default = "1";
							$tomb2->active  = "1";
							$tomb2->deleted = "0";
							
							$this->mclusers->addUserEmailHun($tomb2);
							if(UJUGYFELKEZELO===true)
								$this->mclusers->addEvent($nUserID, "117", $info22);
							else
								$this->mclusers->addEvent($nUserID, "105", $info22);
							
						}
						
					}
					// end kek konyvbe
					
					// sarga konyvbe is ha az orszag "United Kingdom"
					//elseif( $record['stat_country'] == 'United Kingdom' || in_array($kisorszag,$sargakonyvbe) || ( !in_array($kisorszag,$egyikbese) && !in_array($kisorszag,$pinkkonyvbe) ) ){
					elseif( !in_array($kisorszag,$egyikbese)  ){
						// email szerepel-e az email clusersben
						$this->load->model('mclusers');
						$nUserID = $this->mclusers->get_nUserIDByEmail($row['stat_email'],'eng');
						
						
						$info22 = "Version: ".$row['stat_version'];
						$info22 .= " , address: ".$row['stat_cim'];
						$info22 .= " , tel: ".$row['stat_tel'];
						
						if( $row['stat_school'] != "" )
							$info22 .= ", school: ".$row['stat_school'];
						
						
						if($nUserID){
							$this->mclusers->addEvent($nUserID, "167", $info22, 'eng');
						}else{
							// user beszúrás
							$tomb->strName    = $row['stat_first'];
							$tomb->strTel     = $row['stat_tel'];
							$tomb->strEMail   = $row['stat_email'];
							/*$tomb->strCity  = substr($row['stat_cim'], 0, 30);
							if( strlen($row['stat_cim']) > 30 )
								$tomb->strStreet = substr($row['stat_cim'], 30);*/
					//		$tomb->dateInsert = time();
							$tomb->strStreet  = $jsinfo->strStreet;
							$tomb->strCity    = $jsinfo->strCity;
							$tomb->strZip     = $jsinfo->strZip;
							$tomb->strCompany = $jsinfo->strCompany;
							$tomb->nUserProf  = $jsinfo->nUserProf;
							$tomb->nUserType = "0";
							
							if( $record['stat_country'] == 'United Kingdom' || in_array($kisorszag,$sargakonyvbe) ){
								$tomb->nCtrID = array_search(strtolower($record['stat_country']), $sargakonyvbe);
							}else{
								//$tomb->strCompany = $record['stat_country'];
								$tomb->nCtrID = 0;
							}
							
							if( $row['stat_version'] != "student" )
								$tomb->nEsely = "3";
							
							/*if( $row['stat_version'] == "interior" )
								$tomb->nUserProf = "4";*/
							if( $row['stat_last'] == "on" )
								//$tomb->strInfo = "download: 'Send me software updates for the latest tips & tricks, special offers and product information.'";
								$tomb->strInfo = "download: ".lang('down_int_keres');
							
							
							$nUserID = $this->mclusers->addUserEng($tomb);
							
							
							// email beszúrás
							$tomb2->email = $row['stat_email'];
							$tomb2->nUserID = $nUserID;
							$tomb2->default = "1";
							$tomb2->active = "1";
							$tomb2->deleted = "0";
							
							$this->mclusers->addUserEmailEng($tomb2);
							$this->mclusers->addEvent($nUserID, "167", $info22, 'eng');
							
						}
						
					}
					// end sarga konyvbe
					
					// rozsaszin konyvbe ha spanyol
					elseif( $record['stat_country'] == 'Spain' || $record['stat_country'] == 'Spanyolország' || in_array(strtolower($record['stat_country']),$pinkkonyvbe) ){
						// email szerepel-e az email clusersben
						$this->load->model('mclusers');
						$nUserID = $this->mclusers->get_nUserIDByEmail($row['stat_email'],'esp');
						
						$row['stat_cim'] = $row['stat_cim'];
						
						$info22 = "Verzió: ".$row['stat_version'];
						$info22 .= " , cim: ".$row['stat_cim'];
						$info22 .= " , tel: ".$row['stat_tel'];
						
						if( $row['stat_school'] != "" )
							$info22 .= ", iskola: ".$row['stat_school'];
						
						
						if($nUserID){
							$this->mclusers->addEvent($nUserID, "269", $info22, 'esp');
						}else{
							// user beszúrás
							$tomb->strName = $row['stat_first'];
							$tomb->strTel  = $row['stat_tel'];
							$tomb->strEMail = $row['stat_email'];
							
							$tomb->strStreet  = $jsinfo->strStreet;
							$tomb->strCity    = $jsinfo->strCity;
							$tomb->strZip     = $jsinfo->strZip;
							$tomb->strCompany = $jsinfo->strCompany;
							$tomb->nUserProf  = $jsinfo->nUserProf;
							$tomb->nUserType = "0";
							switch( strtolower($record['stat_country']) ){
								case "argentina":
								case "argentína":
									$tomb->nCtrID = 54;
									break;
								case "portugália":
								case "portugal":
									$tomb->nCtrID = 351;
									break;
								case "costa rica":
									$tomb->nCtrID = 506;
									break;
								case "csehország":
								case "czech republic":
									$tomb->nCtrID = 420;
									break;
								default:
									$tomb->nCtrID = 34;
							}
							
							if( $row['stat_version'] != "student" )
								$tomb->nEsely = "3";
							
							if( $row['stat_last'] == "on" )
								$tomb->strInfo = "download: 'Send me software updates for the latest tips & tricks, special offers and product information.'";
							
							// kéne? SET NAMES latin1 COLLATE latin1_swedish_ci;
							// $this->db->db_set_charset("latin1", "latin1_swedish_ci");
							$nUserID = $this->mclusers->addUserSpa($tomb);
							
							
							// email beszúrás
							$tomb2->email = $row['stat_email'];
							$tomb2->nUserID = $nUserID;
							$tomb2->default = "1";
							$tomb2->active = "1";
							$tomb2->deleted = "0";
							
							$this->mclusers->addUserEmailEng($tomb2);
							
							$this->mclusers->addEvent($nUserID, "269", $info22, 'esp');
							
						}
						
					}
					// end rozsaszin konyvbe

					if($row['stat_version']=='trial')
					{
	                    //sending email
	                    $mail_vars['first'] = $row['stat_first'];
						$mail_vars['country'] = $row['stat_country'];
						$mail_vars['email'] = $row['stat_email'];
						//$mail_vars['demourl'] = $this->muser->get_setting('trial',$this->muser->user['lang']);

	                    //setting and sending the email
						$this->load->library('email');
						$this->email->initialize();
						$this->email->addOfficialImages();

				//		$this->email->setFrom('info@cadline.hu', 'CadLine');

						if(hun())
						{
							$mail_vars['demourl'] = "http://www.archline.hu/public/downloads/eng/ARCHLINE_XP2014_32bit_setup.exe";
							$mail_vars['demourl64'] = "http://www.archline.hu/public/downloads/eng/ARCHLINE_XP2014_64bit_setup.exe";
							$this->email->setFrom('info@cadline.hu', 'CadLine');
							$mail_vars['mailcontent'] = 'downloads/mail_trial_hun';
							$this->email->subject('ARCHLine.XP letoltes');
							$this->email->message($this->load->view('mail',$mail_vars,true));
						}
						else
						{
							$mail_vars['demourl'] = "http://www.archlinexp.com/public/downloads/eng/ARCHLINE_XP2014_32bit_setup.exe"; //"http://download.archlinexp.com/ARCHLINE_XP2013_32bit_setup.exe";
							$mail_vars['demourl64'] = "http://www.archlinexp.com/public/downloads/eng/ARCHLINE_XP2014_64bit_setup.exe"; //"http://download.archlinexp.com/ARCHLINE_XP2013_64bit_setup.exe";
							$this->email->setFrom('info@archlinexp.com', 'CadLine');
							$mail_vars['mailcontent'] = 'downloads/mail_trial_eng';
							$this->email->subject('ARCHLine.XP Download');
							$this->email->message($this->load->view('mail',$mail_vars,true));
						}
						
						$this->email->send($row['stat_email'],'smtp');
						
						//deleting from the temporary table
						$this->db->delete('download_stats_temp', array('stat_code' => $code));
						
	                    //redirect
	                    redirect('downloads/senttri');
					}
					elseif($row['stat_version']=='student')
					{
	                    $mail_vars['first'] = $row['stat_first'];
						$mail_vars['country'] = $row['stat_country'];
						$mail_vars['email'] = $row['stat_email'];

						$this->load->library('email');
						$this->email->initialize();
						$this->email->addOfficialImages();

				//		$this->email->from('info@cadline.hu', 'CadLine');

						if(hun())
						{
							$this->email->setFrom('info@cadline.hu', 'CadLine');
							$mail_vars['mailcontent'] = 'downloads/mail_student_hun';
							$mail_vars['demourl'] = $this->muser->get_setting('student', 'hun');
							$this->email->subject('ARCHLine.XP letoltes');
							$this->email->message($this->load->view('mail', $mail_vars, true));
						}
						else
						{
							$this->email->setFrom('info@archlinexp.com', 'CadLine');
							$mail_vars['mailcontent'] = 'downloads/mail_student_eng';
							$mail_vars['demourl'] = $this->muser->get_setting('student', 'eng');
							$this->email->subject('ARCHLine.XP Download');
							$this->email->message($this->load->view('mail', $mail_vars, true));
						}

						$this->email->send($row['stat_email'],'smtp');

						//deleting from the temporary table
						$this->db->delete('download_stats_temp', array('stat_code' => $code));

						redirect('downloads/sentstu');
					}
					elseif($row['stat_version']=='interior')
					{
						$mail_vars['first'] = $row['stat_first'];
						$mail_vars['country'] = $row['stat_country'];
						$mail_vars['email'] = $row['stat_email'];
						
						if(hun()){
							$mail_vars['demourl'] = "http://www.archline.hu/public/downloads/eng/ARCHLINE_XP2014_32bit_setup.exe";
							$mail_vars['demourl64'] = "http://www.archline.hu/public/downloads/eng/ARCHLINE_XP2014_64bit_setup.exe";
						}elseif(esp()){
							$mail_vars['demourl'] = "http://www.archlinexp.com/public/downloads/eng/ARCHLINE_XP2014_32bit_setup.exe"; //"http://download.archlinexp.com/ARCHLINE_XP2013_32bit_setup.exe";
							$mail_vars['demourl64'] = "http://www.archlinexp.com/public/downloads/eng/ARCHLINE_XP2014_64bit_setup.exe"; //"http://download.archlinexp.com/ARCHLINE_XP2013_64bit_setup.exe";
						}
						else{
							$mail_vars['demourl'] = "http://www.archlinexp.com/public/downloads/eng/ARCHLINE_XP2014_32bit_setup.exe"; //"http://download.archlinexp.com/ARCHLINE_XP2013_32bit_setup.exe";
							$mail_vars['demourl64'] = "http://www.archlinexp.com/public/downloads/eng/ARCHLINE_XP2014_64bit_setup.exe"; //"http://download.archlinexp.com/ARCHLINE_XP2013_64bit_setup.exe";
						}

						$this->load->library('email');
						$this->email->initialize();
						$this->email->addOfficialImages();

			//			$this->email->setFrom('info@cadline.hu', 'CadLine');
						
						if( hun() ){
							$this->email->setFrom('info@cadline.hu', 'CadLine');
							$mail_vars['mailcontent'] = 'downloads/mail_interior_hun';
							$this->email->subject('ARCHLine.XP Interior Letoltes');
						}
						elseif( esp() ){
							$this->email->setFrom('info@archlinexp.com', 'CadLine');
							$mail_vars['mailcontent'] = 'downloads/mail_interior_esp';
							$this->email->subject('Descargar ARCHline XP Interior');
						}
						else{
							$this->email->setFrom('info@archlinexp.com', 'CadLine');
							$mail_vars['mailcontent'] = 'downloads/mail_interior_eng';
							$this->email->subject('ARCHLine.XP Interior Trial version download');
						}
						
						$this->email->message($this->load->view('mail', $mail_vars, true));

						$this->email->send($mail_vars['email'],'smtp');

						//deleting from the temporary table
						$this->db->delete('download_stats_temp', array('stat_code' => $code));

						// átirányítás
						redirect('interior/sentint');
					}
					
					elseif($row['stat_version']=='free')
					{
						$mail_vars['first'] = $row['stat_first'];
						$mail_vars['country'] = $row['stat_country'];
						$mail_vars['email'] = $row['stat_email'];
						
						if(hun())
							$mail_vars['demourl'] = "http://www.archlinexp.com/public/downloads/hun/Hun_XP_2010.exe";
						else
							$mail_vars['demourl'] = "http://www.archlinexp.com/public/downloads/eng/Eng_XP_2010_FREE.exe";

						$this->load->library('email');
						$this->email->initialize();
						$this->email->addOfficialImages();

			//			$this->email->setFrom('info@cadline.hu', 'CadLine');
						
						if( hun() ){
							$this->email->setFrom('info@cadline.hu', 'CadLine');
							$mail_vars['mailcontent'] = 'downloads/mail_free_hun';
							$this->email->subject('ARCHLine.XP Free Edition Letoltes');
						}
						else{
							$this->email->setFrom('info@archlinexp.com', 'CadLine');
							$mail_vars['mailcontent'] = 'downloads/mail_free_eng';
							$this->email->subject('ARCHLine.XP Free Edition download');
						}
						
						$this->email->message($this->load->view('mail', $mail_vars, true));

						$this->email->send($mail_vars['email'],'smtp');

						//deleting from the temporary table
						$this->db->delete('download_stats_temp', array('stat_code' => $code));

						// átirányítás
						redirect('free/sentint');
					}
					
					elseif($row['stat_version']=='photo')
					{
						$mail_vars['first'] = $row['stat_first'];
						$mail_vars['country'] = $row['stat_country'];
						$mail_vars['email'] = $row['stat_email'];
						
						if(hun())
							$mail_vars['demourl'] = "http://www.cadline.hu/public/downloads/eng/Eng_XP_2010_Photo.exe";
						else
							$mail_vars['demourl'] = "http://www.cadline.hu/public/downloads/eng/Eng_XP_2010_Photo.exe";

						$this->load->library('email');
						$this->email->initialize();
						$this->email->addOfficialImages();

			//			$this->email->setFrom('info@cadline.hu', 'CadLine');
						
						if( hun() ){
							$this->email->setFrom('info@cadline.hu', 'CadLine');
							$mail_vars['mailcontent'] = 'downloads/mail_photo_hun';
							$this->email->subject('ARCHLine.XP Photo Edition Letoltes');
						}
						else{
							$this->email->setFrom('info@archlinexp.com', 'CadLine');
							$mail_vars['mailcontent'] = 'downloads/mail_photo_eng';
							$this->email->subject('ARCHLine.XP Photo Edition download');
						}
						
						$this->email->message($this->load->view('mail', $mail_vars, true));

						$this->email->send($mail_vars['email'],'smtp');

						
						$this->db->delete('download_stats_temp', array('stat_code' => $code));

						
						redirect('photo/sentint');
					}
					
					elseif($row['stat_version']=='reader')
					{
						$mail_vars['first']   = $row['stat_first'];
						$mail_vars['country'] = $row['stat_country'];
						$mail_vars['email']   = $row['stat_email'];
						$mail_vars['mailcontent'] = 'downloads/mail_reader';
						$mail_vars['demourl'] = "http://www.archline.hu/public/downloads/eng/ARCHLINE_XP2014_Reader_32.exe";
						
						$this->load->library('email');
						$this->email->initialize();
						$this->email->addOfficialImages();
						
						
						if( hun() ){
							$this->email->setFrom('info@cadline.hu', 'CadLine');
							$this->email->subject('ARCHLine.XP Reader Letoltes');
						}
						else{
							$this->email->setFrom('info@archlinexp.com', 'CadLine');
							$this->email->subject('ARCHLine.XP Reader download');
						}
						
						$this->email->message($this->load->view('mail', $mail_vars, true));
						$this->email->send($mail_vars['email'],'smtp');
						
						//deleting from the temporary table
						$this->db->delete('download_stats_temp', array('stat_code' => $code));
						
						// átirányítás
						redirect('interior/sentint');
					}
					
				}
			}
		}
	}
	
	function workshop(){
		$this->load->model('mdownloads');
		
		if( !eng() )
		    $data['heading']=$this->mdownloads->get_heading('support');
		else
		    $data['heading']='Workshop documentation';
		$data['downloads']=$this->mdownloads->get_category('workshop',$this->muser->user['lang']);
		//$data['aktiv']=6;
		
		$data['support']=true;
		
		$data['lang']=$this->muser->user['lang'];
		$data['title'] = hun() ? 'ARCHLine.XP CAD Software - Letöltés' : 'ARCHLine.XP CAD Software - Downloads';
		$data['tartalom']='downloads/list';
		$data['csik']=array('home');
		$this->load->view('site',$data);
	}
	
	
	function projects(){
		$this->load->model('mclusers');
		
		$temptomb = explode("/", $_SERVER[ 'REQUEST_URI'] );
		$email = str_replace("%40","@",end($temptomb));
		
		$projekt = $this->uri->segment(3);
		
		$egyezes = "public/downloads/eng/projects/".$projekt.".pro";
		$info = "Project download: (http://archlinexp.com/public/downloads/eng/projects/".$projekt.".pro)";
		
		if(UJUGYFELKEZELO===true)
			$this->mclusers->levelesemeny($email, "downloads", "projects", 197, $egyezes, $info, "eng", $projekt);
		else
			$this->mclusers->levelesemeny($email, "downloads", "projects", 188, $egyezes, $info, "eng", $projekt);
		
		redirect("public/downloads/eng/projects/".$projekt.".pro");
	}
	
}
?>