<?php

add_hook('ShoppingCartValidateProductUpdate', 1, function($vars) {
	
	if($vars['a']=="confproduct"){
		$pid=$_SESSION['cart']['products'][$vars['i']]['pid'];
		if(empty($pid)) return []; 
		$sql = "select servertype from tblproducts where id = '$pid'";
		$res = mysql_fetch_array(full_query($sql));
		if($res['servertype']!="zjmfcloud") return []; 
		define('ZJMFCLOUD_FILE', ROOTDIR . '/modules/servers/zjmfcloud/');
		include ZJMFCLOUD_FILE."zjmf/function.php";	
		zjmfcloud_lang();
		global $_LANG; 
		// if(empty($vars['hostname'])){
		// 	$error[]=$_LANG['zjmf_cart_check_hostname'];
		// }
		if(empty($vars['rootpw'])){
			$error[]=$_LANG['zjmf_cart_check_rootpw'];
		}
		// if(!preg_match('/^[a-zA-Z]{1}[a-zA-Z\d_@\.]{5,15}$/', $vars['hostname']) && !empty($vars['hostname'])){
  //           $error[]=$_LANG['zjmf_cart_check_hostname2'];
  //       } 
		if(!preg_match('/^(?=.*[a-z])(?=.*[A-Z])[a-zA-Z\d_@\.]{6,16}$/', $vars['rootpw']) && !empty($vars['rootpw'])){
            $error[]=$_LANG['zjmf_cart_check_rootpw2'];
        } 
		return $error;
	} 
	
});
