<?php

define( 'AFA_HUN', 0.27);

class Services extends Controller
{
	function Services(){
		parent::Controller();
	}
	
	function index(){
		//$this->virtuallyfurnish();
		redirect('services/virtuallyfurnish');
	}
	
	function virtuallyfurnish(){
		
		$harmadik = $this->uri->segment(3);
		if( $harmadik == "pricing" ){
			$this->pricing("vf");
			return;
		}elseif( $harmadik == "upload" ){
			$this->upload("vf");
			return;
		}
		if( is_numeric($harmadik) ){
			if( $harmadik > 0 && $harmadik <= 4 ){
				$this->order("vf", $harmadik);
				return;
			}
			else{
				print "?";
				return;
			}
		}
		
		if(!hun()){
		// új oldalra
		Header("HTTP/1.1 301 Moved Permanently");
		Header("Location: http://www.archlinexp.eu/packages/virtual-photo-staging");
		exit;
		}
		
		
		
		$data['szolg_cim'] = "Virtually Furnish";
		$data['infok'] = $this->mpages->get_row(651);
		$data['infix'] = "vf";
		
		$data['virtuallyfurnish'] = true;
		
		$data['meta']['desc'] = strip_tags(lang('services_vf_h3'));
		
		$data['tartalom'] = 'services/index';
		
		$data['title'] = hun() ? 'Virtual staging szolgáltatás - CadLine Kft.' : 'Virtual Staging service - CadLine Network';
		$data['javascript'] = array('jquery.corner','fancybox-1.3.4/fancybox/jquery.fancybox-1.3.4.pack','jquery.mousewheel.min');
		$data['style'] = array('workshop','../js/fancybox-1.3.4/fancybox/jquery.fancybox-1.3.4v2');
		$data['csik']  = array('home', 'services','virtuallyfurnish');
		
		$this->load->view('site',$data);
	}
	
	function rendering(){
		
		
		$harmadik = $this->uri->segment(3);
		if( $harmadik == "pricing" ){
			$this->pricing("re");
			return;
		}elseif( $harmadik == "upload" ){
			$this->upload("re");
			return;
		}
		if( is_numeric($harmadik) ){
			if( $harmadik > 0 && $harmadik <= 5 ){
				$this->order("re", $harmadik);
				return;
			}
			else{
				print "?";
				return;
			}
		}
		
		if(!hun()){
		// új oldalra
		Header("HTTP/1.1 301 Moved Permanently");
		Header("Location: http://www.archlinexp.eu/packages/photorealistic-rendering");
		exit;
		}
		
		
		$data['szolg_cim'] = "Rendering";
		$data['infok'] = $this->mpages->get_row(652);
		$data['infix'] = "re";
		
		$data['rendering'] = true;
		
		$data['meta']['desc'] = end(explode('<br />',lang('services_re_h3')));
		
		$data['tartalom'] = 'services/index';
		
		$data['title'] = hun() ? 'CadLine Kft. Szolgáltatások - '.lang('services_re') : lang('services_re').' - CadLine  Services';
		$data['javascript'] = array('jquery.corner','fancybox-1.3.4/fancybox/jquery.fancybox-1.3.4.pack','jquery.mousewheel.min');
		$data['style'] = array('workshop','../js/fancybox-1.3.4/fancybox/jquery.fancybox-1.3.4v2');
		$data['csik'] = array('home', 'services', 'servrendering');
		
		$this->load->view('site',$data);
	}
	
	function sketch(){
		
		$harmadik = $this->uri->segment(3);
		if( $harmadik == "pricing" ){
			$this->pricing("sk");
			return;
		}elseif( $harmadik == "upload" ){
			$this->upload("sk");
			return;
		}
		if( is_numeric($harmadik) ){
			if( $harmadik > 0 && $harmadik <= 6 ){
				$this->order("sk", $harmadik);
				return;
			}
			else{
				print "?";
				return;
			}
		}
		
		
		if(!hun()){
		// új oldalra
		Header("HTTP/1.1 301 Moved Permanently");
		Header("Location: http://www.archlinexp.eu/packages/3d-interior-modeling");
		exit;
		}
		
		
		
		
		$data['szolg_cim'] = "Convert sketch into 3D model";
		$data['infok'] = $this->mpages->get_row(653);
		$data['infix'] = "sk";
		
		$data['sketch'] = true;
		
		$data['meta']['desc'] = strip_tags(lang('services_sk_h3'));
		
		$data['tartalom'] = 'services/index';
		
		$data['title'] = hun() ? '3D modell készítése - CadLine Kft. Szolgáltatások' : 'Convert sketch into 3D model - CadLine Services';
		$data['javascript'] = array('jquery.corner','fancybox-1.3.4/fancybox/jquery.fancybox-1.3.4.pack','jquery.mousewheel.min');
		$data['style'] = array('workshop','../js/fancybox-1.3.4/fancybox/jquery.fancybox-1.3.4v2');
		$data['csik'] = array('home', 'services', 'servsketch');
		
		$this->load->view('site',$data);
	}
	
	function animation(){
		$harmadik = $this->uri->segment(3);
		if( $harmadik == "pricing" ){
			$this->pricing("an");
			return;
		}elseif( $harmadik == "upload" ){
			$this->upload("an");
			return;
		}
		if( is_numeric($harmadik) ){
			if( $harmadik > 0 && $harmadik <= 5 ){
				$this->order("an", $harmadik);
				return;
			}
			else{
				print "?";
				return;
			}
		}
		
		$data['szolg_cim'] = "Animation";
		$data['infok'] = $this->mpages->get_row(652);
		$data['infix'] = "an";
		
		$data['rendering'] = true;
		
		$data['meta']['desc'] = lang('services_an');
		
		$data['tartalom'] = 'services/index';
		
		$data['title'] = hun() ? 'CadLine Kft. Szolgáltatások - '.lang('services_an') : 'CadLine  Services - '.lang('services_an');
		$data['javascript'] = array('jquery.corner');
		$data['style'] = array('workshop');
		$data['csik'] = array('home', 'services', 'servrendering');
		
		$this->load->view('site',$data);
	}
	
	function pricing($service = ""){
		if( $service == "" )
			redirect('services');
		
		$data['infix'] = $service;
		
		switch($service){
			case "vf":
				
				if(!hun()){
				// új oldalra
				Header("HTTP/1.1 301 Moved Permanently");
				Header("Location: http://www.archlinexp.eu/packages/virtual-photo-staging/details");
				exit;
				}
				
				$data['urlservice'] = 'virtuallyfurnish';
				$data['service'] = 'virtuallyfurnish';
				break;
			case "re":
				
				if(!hun()){
				// új oldalra
				Header("HTTP/1.1 301 Moved Permanently");
				Header("Location: http://www.archlinexp.eu/packages/photorealistic-rendering/details");
				exit;
				}
				
				$data['urlservice'] = 'servrendering';
				$data['service'] = 'rendering';
				break;
			case "sk":
				if(!hun()){
				// új oldalra
				Header("HTTP/1.1 301 Moved Permanently");
				Header("Location: http://www.archlinexp.eu/packages/3d-interior-modeling/details");
				exit;
				}
				
				$data['urlservice'] = 'servsketch';
				$data['service'] = 'sketch';
				break;
			case "an":
				$data['urlservice'] = 'servanimation';
				$data['service'] = 'animation';
				break;
		}
		
		
		$data['mobilink'] = "/mobile/services/".$data['service'];
		$data['tartalom'] = 'services/pricing';
		
		$data['title'] = hun() ? 'CadLine Kft. - '.lang('services_'.$service).', Árak' : 'CadLine Network Ltd. - '.lang('services_'.$service).', Pricing';
		$data['javascript'] = array('jquery_ui');
		$data['style'] = array('workshop');
		$data['csik'] = array('home', 'services', $data['urlservice'], $service.'pricing');
		
		if( $service == "an" ){
			$data['javascript'][] = 'fancybox-1.3.4/fancybox/jquery.mousewheel-3.0.4.pack';
			$data['javascript'][] = 'fancybox-1.3.4/fancybox/jquery.easing-1.3.pack';
			$data['javascript'][] = 'fancybox-1.3.4/fancybox/jquery.fancybox-1.3.4.pack';
			
			$data['style'][]      = '../js/fancybox-1.3.4/fancybox/jquery.fancybox-1.3.4';
		}
		
		$this->load->view('site',$data);
		
	}
	
	function ordersubmit(){
		$service = $this->input->post('service');
		if( isset($_POST['darab1']) )
			$darab = 1;
		if( isset($_POST['darab2']) )
			$darab = 2;
		if( isset($_POST['darab3']) )
			$darab = 3;
		
		if( $this->input->post('twoday') == "on" )
			$darab += 3;
		
		
		switch($service){
			case "vf":
				switch($darab){
					case 1:
						$termekkod = 300499462;
						break;
					case 2:		/* ez at lett irva az elso +50%-osara */
						$termekkod = 300499466;
						break;
					case 3:
						$termekkod = 300499467;
						break;
					case 4:		/* 1. +50%-kal */
						$termekkod = 300499466;
						break;
				}
				break;
			case "re":
				switch($darab){
					case 1:
						$termekkod = 300499468;
						break;
					case 2:
						$termekkod = 300499469;
						break;
					case 3:		/* ez at lett irva az elso +50%-osara */
						$termekkod = 300499470;
						break;
					case 4:		/* 1. +50%-kal */
						$termekkod = 300499470;
						break;
					case 5:		/* 2. +50%-kal */
						$termekkod = 300505801;
						break;
				}
				break;
			case "sk":
				switch($darab){
					case 1:
						$termekkod = 300505796;
						break;
					case 2:
						$termekkod = 300505802;
						break;
					case 3:
						$termekkod = 300505804;
						break;
					case 4:		/* 1. +50%-kal */
						$termekkod = 300505800;
						break;
					case 5:		/* 2. +50%-kal */
						$termekkod = 300505803;
						break;
					case 6:		/* 3. +50%-kal */
						$termekkod = 300505805;
						break;
				}
				break;
			case "an":
				switch($darab){
					case 1:
						$termekkod = 300525589;
						break;
					case 2:
						$termekkod = 300499469;
						break;
					case 3:		/* ez at lett irva az elso +50%-osara */
						$termekkod = 300499470;
						break;
					case 4:		/* 1. +50%-kal */
						$termekkod = 300525591;
						break;
					case 5:		/* 2. +50%-kal */
						$termekkod = 300505801;
						break;
				}
				break;
		}
		
		if( !$termekkod )
			redirect('services');
		
		$link = "https://secure.shareit.com/shareit/checkout.html?PRODUCT[";
		$link .= $termekkod;
		$link .= "]=1&amp;DELIVERY[";
		$link .= $termekkod;
		$link .= "]=EML&amp;stylefrom=300457611&js=-1";
		
		
		header("Location: ".$link);
	}
	
	// magyar megrendeles
	function order(){
		$service = $this->input->post('service');
		if( isset($_POST['darab1']) )
			$darab = 1;
		if( isset($_POST['darab2']) )
			$darab = 2;
		if( isset($_POST['darab3']) )
			$darab = 3;
		
		if( $this->input->post('twoday') == "on" )
			$darab += 3;
		
		
		switch($service){
			case "vf": $data['urlservice'] = 'virtuallyfurnish';
				break;
			case "re": $data['urlservice'] = 'servrendering';
				break;
			case "sk": $data['urlservice'] = 'servsketch';
				break;
		}
		
		$alapar = $darab%3;
		if( $alapar == 0 )
			$alapar = 3;
		
		$data['szolg_cim'] = $lang['services_'.$infix];
		$data['csomag']    = strip_tags(lang('services_'.$service.'_rend'.$alapar),"<sup>");
		$data['ar']        = $darab;
		$data['alapar']    = lang('services_'.$service.'_price'.$alapar);
		preg_match_all('/[0-9]+/', $data['alapar'], $matches);
		$data['tenyleges'] = implode("",$matches[0]);
		$data['infok']     = $this->mpages->get_row(653);
		$data['infix']     = $service;
		
		$data['tartalom'] = 'services/order';
		
		$data['title'] = 'Megrendelés: '.$lang['services_'.$infix].' CadLine Kft. Szolgáltatások';
		$data['csik'] = array('home', 'services', $data['urlservice']);
		$data['style'] = array('workshop');
		
		$this->load->view('site',$data);
	}
	
	function upload($service = ""){
		if( $service == "" )
			redirect('services');
		
		$data['infix'] = $service;
		
		switch($service){
			case "vf": $data['urlservice'] = 'virtuallyfurnish';
				break;
			case "re": $data['urlservice'] = 'servrendering';
				break;
			case "sk": $data['urlservice'] = 'servsketch';
				break;
		}
		
		$data['azonosito'] = $this->getazon();
		$data['tartalom'] = 'services/upload';
		
		$data['title'] = hun() ? 'CadLine Kft. Szolgáltatások' : 'CadLine Network Ltd. Upload';
		$data['javascript'] = array('../uploadify-v2.1.4/jquery-1.4.2.min','../uploadify-v2.1.4/swfobject','../uploadify-v2.1.4/jquery.uploadify.v2.1.4.min');
		$data['style'] = array('workshop');
		$data['csik'] = array('home', 'services', $data['urlservice'], $service.'order');
		
		$this->load->view('site',$data);
	}
	
	function submitvf(){
		if(!hun()){
			$this->submit("vf");
			return;
		}
		
		// magyaroknak e-mail + esemeny
		$this->submithun("vf");
	}
	
	function submitre(){
		if(!hun()){
			$this->submit("re");
			return;
		}
		
		// magyaroknak e-mail + esemeny
		$this->submithun("re");
	}
	
	function submitsk(){
		if(!hun()){
			$this->submit("sk");
			return;
		}
		
		// magyaroknak e-mail + esemeny
		$this->submithun("sk");
	}
	
	function submitan(){
		if(!hun()){
			$this->submit("an");
			return;
		}
		
		// magyaroknak e-mail + esemeny
		$this->submithun("an");
	}
	
	function submit($service = ""){
		if($service == "")
			redirect("services");
		
		$this->load->model('mclusers');
		
		foreach( $_POST as $k=>$v )
			$$k = $v;
		
		if( !$email || $url ){
			$record->osztaly = "Services";
			$record->fv = "submit".$service;
			$record->hiba = "Nincs e-mail: ".$email."\nvagy van url: ".$url."\n".print_r($_POST,true);
			$record->datum = date('Y-m-d H:i:s',time());
			$this->db->insert('a_hibak',$record);
			
			$this->upload($service); // ?? 
			return;
		}
		
		$nUserID = $this->mclusers->get_nUserIDByEmail($email,'eng');
		
		if( !$nUserID ){
			// user beszúrás
			$tomb->strName = $name;
			$tomb->strTel = $tel;
			$tomb->strMobil = $tel;
			$tomb->strEMail = $email;
			$tomb->strCity = $city;
			$tomb->strZip = $zip;
			$tomb->strStreet = $street;
			$tomb->nUserType = 0;
			$tomb->nCtrID = 0;
			$tomb->strCompany = $company;
			$tomb->strInfo = "";
			
			$nUserID = $this->mclusers->addUserEng($tomb);
			
			
			// email beszúrás
			$tomb2->email = $email;
			$tomb2->nUserID = $nUserID;
			$tomb2->default = "1";
			$tomb2->active = "1";
			$tomb2->deleted = "0";
			
			$this->mclusers->addUserEmailEng($tomb2);
		}
		
		$fajlok = "";
		$mappa = "/var/www/hosting/cadline.hu/www/public/img/services/uploads/{$service}/{$azonosito}/";
		$fajlokmind = scandir($mappa);
		foreach($fajlokmind as $fajl){
			if( substr($fajl,0,7) == $azonosito2 ){
				$fajlok .= $fajl.", ";
			}else{
			//	print "<br />nem egyezik ".substr($fajl,0,12)." es ".$azonosito2;
			}
		}
		
		switch($service){
			case 'vf':
				$info = "Services, Virtually Furnish";
				$topicID = 167;
				$emailpage = 655;
				break;
			case 're':
				$info = "Services, Rendering";
				$topicID = 168;
				$emailpage = 672;
				break;
			case 'sk':
				$info = "Services, Digital Decoration";
				$topicID = 169;
				$emailpage = 673;
				break;
			case 'an':
				$info = "Services, Animation";
				$topicID = 168;			// ??
				$emailpage = 672;		// ??
				break;
		}
		
		// azonosito es fajlok az infoba
		$fajlok = trim(trim($fajlok," "),",");
		$info .= ", fajlok helye a cadline.hu szerveren: /public/img/services/uploads/{$service}/{$azonosito}/{$azonosito2}, feltoltott fajlok: ".$fajlok;
		if($comment)
			$info .= ", Comment: ".$comment;
		$this->mclusers->addEvent($nUserID, $topicID, $info, 'eng');
		
		
		$page = $this->mpages->get_row($emailpage);
		$emailinfo = str_ireplace('#name#', $name, $page->page_body);
		
		$this->load->library('email');
		$this->email->initialize();
		$this->email->from('info@archlinexp.com', 'ARCHLineXP.com');
		$this->email->subject("CadLine Network Ltd. - Service");
		$this->email->message("New Request:<br>Name: ".$name."<br>Company: ".$company."<br>Tel: ".$tel."<br>E-mail: ".$email."<br>Zip: ".$zip."<br>City: ".$city."<br>Street: ".$street."<br><br>Comment: ".$comment."<br><br>".$info);
		
		$this->email->send('info@archlinexp.com', 'smtp');
	//	$this->email->send('sztikee@gmail.com', 'smtp');
		
		$this->email->clear();
		
		$this->load->library('email');
		$this->email->initialize();
		$this->email->from('info@archlinexp.com', 'Cadline Website');
		$this->email->subject('CadLine Network Ltd. Service');
		$this->email->message($emailinfo);
		
		$this->email->send($email, 'smtp');
		
		
	//	redirect('services/info');
		
		// ertesito nekem
		$record->osztaly = "Services";
		$record->fv = "submit".$service;
		$record->hiba = "Adatok: ".print_r($_POST,true)."\nfajlok: {$fajlok}";
		$record->datum = date('Y-m-d H:i:s',time());
		$this->db->insert('a_hibak',$record);
		
		$page = $this->mpages->get_row(654);
		$data['title'] = 'CadLine Services, Thank You for upload!';
        $data['tartalom'] = '/services/submit';
        $data['info'] = $page->page_body;
		$data['csik'] = array('home', 'services');
		$this->load->view('site',$data);
	}
	
	// megrendelés submit
	function submithun($service = ""){
		$this->load->model('mclusers');
		
		foreach($_POST as $k=>$v)
			$$k = $v;
		
		// ellenőrzések
		$hiba = "";
		
		if( !$name )
			$hiba .= "Hiányzó név!<br />";
		
		if( !$tel )
			$hiba .= "Hiányzó telefonszám!<br />";
		
		if( !$email )
			$hiba .= "Hiányzó e-mail cím!<br />";
		
		if( !$zip )
			$hiba .= "Hiányzó irányítószám!<br />";
		
		if( !$city )
			$hiba .= "Hiányzó város!<br />";
		
		if( !$street )
			$hiba .= "Hiányzó utca!<br />";
		
		if( !in_array($service,array("vf","re","sk")) )
			$redirect = "services";
		
		if( !is_numeric($darab) || $darab <1 || $darab>6 )
			$redirect = "services";
		
		if( $redirect || $hiba ){
			$record->osztaly = "services";
			$record->fv = "submithun";
			$record->hiba = "Hibás megrnedelés: \n".print_r($_POST,true);
			$record->datum = date('Y-m-d H:i:s',time());
			$this->db->insert('a_hibak',$record);
		}
		
		if( $redirect != "" )
			redirect($redirect);
		
		if( $hiba != "" ){
			$_SESSION['szolg_hiba'] = $hiba;
			header("Location: ".$_SERVER['HTTP_REFERER']);
		}
		// end ellenőrzések
		
		$dbalap = $darab%3;
		if( $dbalap == 0 )
			$dbalap = 3;
		
		$emailar = lang('services_'.$service.'_price'.$dbalap)." + Áfa";
		$veglegesnetto = $tenyleges;
		if( $darab > 3 ){
			$veglegesnetto *= 1.5;
			$emailar .= " + ".lang('services_prices_50fee')." = ".$veglegesnetto." Ft + Áfa";
		}
		$rendelessorszam = $this->db->query("SELECT value FROM settings WHERE id=33")->row();
		$rendelessorszam = $rendelessorszam->value;
		$this->db->update('settings',array('value'=>($rendelessorszam+1)),"id=33");
		
		$eseminfo = lang('services_'.$service)." megrendelés: ";
		$eseminfo .= "\nNév: ".$name;
		$eseminfo .= "\nCég: ".$company;
		$eseminfo .= "\nTelefon: ".$tel;
		$eseminfo .= "\nÜzenet: ".$comment;
		$eseminfo .= "\nCsomag: ".strip_tags(lang('services_'.$service.'_rend'.$dbalap));
		$eseminfo .= "\nÁr: ".$emailar." , bruttó: ".($veglegesnetto*(1+AFA_HUN));
		
		switch($service){
			case 'vf':
				$topicID = 145;
				break;
			case 're':
				$topicID = 144;
				break;
			case 'sk':
				$topicID = 143;
				break;
		}
		
		$nUserID = $this->mclusers->get_nUserIDByEmail($email,'hun');
		if( !$nUserID ){
			// user beszúrás
			$tomb->strName = $name;
			$tomb->strTel = $tel;
			$tomb->strMobil = $tel;
			$tomb->strEMail = $email;
			$tomb->strCity = $city;
			$tomb->strZip = $zip;
			$tomb->strStreet = $street;
			$tomb->nUserType = 0;
			$tomb->nCtrID = 36;
			$tomb->strCompany = $company;
			$tomb->strInfo = "";
			
			$nUserID = $this->mclusers->addUserHun($tomb);
			
			
			// email beszúrás
			$tomb2->email = $email;
			$tomb2->nUserID = $nUserID;
			$tomb2->default = "1";
			$tomb2->active = "1";
			$tomb2->deleted = "0";
			
			$this->mclusers->addUserEmailHun($tomb2);
		}
		
		$this->mclusers->addEvent($nUserID, $topicID, mysql_real_escape_string($eseminfo), 'hun');
		
		
		// kimenő levél szövege
		
		$page = $this->mpages->get_row(676);
		$emailinfo = str_ireplace('#nev#', $name, $page->page_body);
		$emailinfo = str_ireplace('#szolgaltatas#', lang('services_'.$service), $emailinfo);
		$emailinfo = str_ireplace('#rendeles#', strip_tags(lang('services_'.$service.'_rend'.$dbalap),"<sup>"), $emailinfo);
		$emailinfo = str_ireplace('#ar#', $emailar, $emailinfo);
		$emailinfo = str_ireplace('#brutto#', ($veglegesnetto*(1+AFA_HUN)), $emailinfo);
		$emailinfo = str_ireplace('#sorszam#', $rendelessorszam, $emailinfo);
		
		$emailinfo = str_ireplace('#email#', $email, $emailinfo);
		$emailinfo = str_ireplace('#tel#', $tel, $emailinfo);
		$emailinfo = str_ireplace('#zip#', $zip, $emailinfo);
		$emailinfo = str_ireplace('#varos#', $city, $emailinfo);
		$emailinfo = str_ireplace('#utca#', $street, $emailinfo);
		$emailinfo = str_ireplace('#ceg#', $company, $emailinfo);
		$emailinfo = str_ireplace('#uzenet#', $comment, $emailinfo);
		// számlázás
		if( $kuloncim != "on" ){
			$sz_name = $name; $sz_zip = $zip; $sz_city = $city; $sz_street = $street;
		}
		$emailinfo = str_ireplace('#sz_nev#', $sz_name, $emailinfo);
		$emailinfo = str_ireplace('#sz_zip#', $sz_zip, $emailinfo);
		$emailinfo = str_ireplace('#sz_varos#', $sz_city, $emailinfo);
		$emailinfo = str_ireplace('#sz_utca#', $sz_street, $emailinfo);
		
		
		// e-mail nekünk
		
		$this->load->library('email');
		$this->email->initialize();
		$this->email->from('info@cadline.hu', 'ARCHLine.hu');
		$this->email->subject("Megrendelés: ".lang('services_'.$service));
		$this->email->message("Új megrendelés, ".lang('services_'.$service).":<br><br>".$emailinfo);
		
		$this->email->send('info@cadline.hu', 'smtp');
	//	$this->email->send('sztikee@gmail.com', 'smtp');
		
		$this->email->clear();
		
		
		
		// e-mail neki
		
		$this->email->from('info@cadline.hu', 'Cadline Website');
		$this->email->subject('Megrendelés: '.lang('services_'.$service));
		$this->email->message($emailinfo);
		
		$this->email->send($email, 'smtp');
		
		
		// megjelenő oldal
		
		$page = $this->mpages->get_row(677);
		$data['title'] = 'CadLine szolgáltatás, megrendelés rögzítve!';
        $data['tartalom'] = '/services/ordersubmit';
        $data['info'] = $page->page_body;
		$data['csik'] = array('home', 'services');
		$this->load->view('site',$data);
	}
	
	function uploadswf(){
		// felhasznalo azonositas (IP-bol)
		$azonosito = end( explode( "/", $_REQUEST['folder'] ) );
		if( !empty($_FILES) && $azonosito == $this->getazon() ){
			if( $this->uri->segment(3) == "vf" || $this->uri->segment(3) == "re" || $this->uri->segment(3) == "sk" )
				$almappa = $this->uri->segment(3)."/";
			
			// aktualis feltoltes azonositas
			if( isset($_SESSION['servicespw']) && $_SESSION['servicespw'] != "" )
				$pass = $_SESSION['servicespw'];
			else{
				$chars = "abcdefghijkmnopqrstuvwxyzABCDEFGHIJKMNOPQRSTUVWXYZ0123456789";
				$pass = '' ;
				for($i=0; $i<7; $i++){
					$num = rand() % strlen($chars);
					$pass = $pass . $chars[$num];
				}
				$_SESSION['servicespw'] = $pass;
			}
			
			
			$fajlnev = $pass."_".$_FILES['Filedata']['name'];
			$tempFile = $_FILES['Filedata']['tmp_name'];
			$targetPath = "public/img/services/uploads/".$almappa.$azonosito."/";
			if( !is_dir($targetPath) )
				mkdir(str_replace('//','/',$targetPath), 0777, true);
			else
				chmod(str_replace('//','/',$targetPath), 0777);
			$targetFile =  str_replace('//','/',$targetPath) . $fajlnev;
			
			if(file_exists($targetFile))
				$targetFile = str_replace('//','/',$targetPath) .substr($fajlnev,0,-4)."_". rand(100,500).substr($fajlnev,-4);
			
			move_uploaded_file($tempFile,$targetFile);
			echo $pass;
			
		}else{
			echo "ERROR";
		}
	}
	
	// fajl feltolteshez kapcsolodo azonositas
	function getazon(){
		$ip = $_SERVER['REMOTE_ADDR'];
	//	$bongeszo = substr($_SERVER['HTTP_USER_AGENT'],-15);
		$pw = "WEdsds456";
		
		return(substr(md5($ip.$pw),0,12));
		//return $ip." , ".$bongeszo." , ".$pw;
	}
	
	function gallery(){
		$data['kepek']      = scandir('public/img/services/gallery/');
		
		$data['utvonal']    = 'public/img/services/gallery/';
		$data['tartalom']   = 'other/gallery';
		
		$data['javascript'] = array('choco-slider/jquery.chocoslider.min');
		$data['style']      = array('../js/choco-slider/chocoslider');
		
		$this->load->view('site_new',$data);
	}
	
	function videogallery(){
		$data['tartalom']   = 'services/videogallery';
		
		$data['javascript'] = array(
					'jquery.mousewheel.min',
					'jscrollpane/jquery.jscrollpane.min'
				);
		$data['style']     = array('jquery.jscrollpane');
		
		$data['csik'] = array('home', 'services', 'servidgal');
		
		$this->load->view('site',$data);
	}
	
}
?>