<?php 

	//include the cooltoolloader
	include('../loader.php');


    $therminol_d12_access_email_domains = ['mattreeves@gmail.com','@boeing.com', '@wlv.com', '@wieland-microcool.com', '@microcooling.com'];

    function hasAccess($arr,$keyword) {
        foreach ($arr as $index => $string) {
            if (strpos($keyword, $string) !== FALSE)
                return true;
        }
        return false;
    }


	if( isset($_POST["form_id"]) && !empty($_POST["form_id"]) ) {

		$_SESSION['sim_data'][$_POST["form_id"]] = @$_POST;

		if( array_key_exists('mat',$_SESSION['sim_data']) && array_key_exists('material_fluid',$_SESSION['sim_data']['mat'])) {

		    if( ($_SESSION['sim_data']['mat']['material_fluid'] == 'TherminolD12' ) && hasAccess($therminol_d12_access_email_domains,$user->data['email'] ) == false ) {
                $_SESSION['sim_data']['mat']['material_fluid'] = null;
                $_SESSION['sim_data']['mat']['isvalid'] = 'false';
            }

        }


	}


?>