<?php
	$postAct 	= $_POST['postAct'];

	// Language
	if($postAct == 'sesslang'){
		$langweb = $_POST['langweb'];
		session_start();
		$_SESSION['langweb'] = $langweb;
	}
	elseif ($postAct == 'sendproposal') { // Career Form
        $fromName 	= $_POST['proposName'];
		$fromMail 	= $_POST['proposMail'];
		$fromPhone 	= $_POST['proposPhone'];
		$fromSubj 	= $_POST['proposSubject'];
		$fromMess 	= $_POST['proposMess'];

		//Get uploaded file data using $_FILES array 
	    $tmp_name    = $_FILES['file']['tmp_name']; // get the temporary file name of the file on the server 
	    $file_name	 = $_FILES['file']['name'];  // get the name of the file

	    include "../classes/class.phpmailer.php";
        $mail = new PHPMailer; 
        $mail->IsSMTP();
        $mail->SMTPSecure = 'ssl'; 
        $mail->Host = "cnaindo.com"; //host masing2 provider email
        $mail->SMTPDebug = 2;
        $mail->Port = 465;
        $mail->SMTPAuth = true;
        $mail->Username = "adminweb@cnaindo.com"; //user email
        $mail->Password = "cnaindo7"; //password email 
        $mail->AddAttachment($tmp_name, $file_name);
        $mail->SetFrom($fromMail, $fromName); //set email pengirim
        $mail->Subject = $fromSubj; //subyek email
        $mail->AddAddress("mocorono@yahoo.com","Suritno");  //tujuan email
        $mail->MsgHTML("Nama : ".$fromName."<br>"."Email : ".$fromMail."<br>"."Phone : ".$fromPhone."<br><br><br>".$fromMess);
        if($mail->Send()){
            session_start();
            // Mail Sent Successfully
    		$_SESSION['startCont'] = time(); // Taking now logged in time.
            // Ending a session in 30 minutes from the starting time.
            $_SESSION['expireCont'] = $_SESSION['startCont'] + (0.01 * 60);
            echo "Message has been sent";
        } 
        else {
            echo "Failed to sending message";
        }
		
	}
	elseif ($postAct == 'sendmailmessage') { // Contact Form
        $fromName 	= $_POST['contactName'];
		$fromMail 	= $_POST['contactMail'];
		$fromPhone 	= $_POST['contactPhone'];
		$fromSubj 	= $_POST['contactSubject'];
		$fromMess 	= $_POST['contactMess'];

	    include "../classes/class.phpmailer.php";
        $mail = new PHPMailer; 
        $mail->IsSMTP();
        $mail->SMTPSecure = 'ssl'; 
        $mail->Host = "cnaindo.com"; //host masing2 provider email
        $mail->SMTPDebug = 2;
        $mail->Port = 465;
        $mail->SMTPAuth = true;
        $mail->Username = "adminweb@cnaindo.com"; //user email
        $mail->Password = "cnaindo7"; //password email 
        $mail->SetFrom($fromMail, $fromName); //set email pengirim
        $mail->Subject = $fromSubj; //subyek email
        $mail->AddAddress("mocorono@yahoo.com","Suritno");  //tujuan email
        $mail->MsgHTML("Nama : ".$fromName."<br>"."Email : ".$fromMail."<br>"."Phone : ".$fromPhone."<br><br><br>".$fromMess);
        if($mail->Send()){
            session_start();
            // Mail Sent Successfully
    		$_SESSION['startCont'] = time(); // Taking now logged in time.
            // Ending a session in 30 minutes from the starting time.
            $_SESSION['expireCont'] = $_SESSION['startCont'] + (0.01 * 60);
            echo "Message has been sent";
        } 
        else {
            echo "Failed to sending message";
        }
		
	}

?>