select("SELECT `customer_id` FROM ".$glob['dbprefix']."CubeCart_customer WHERE `email` = ".$db->MySQLSafe($resArray['EMAIL'])); $countryId = getCountryFormat($resArray["SHIPTOCOUNTRY"],"iso","id"); $state = $db->select("SELECT `name` FROM ".$glob['dbprefix']."CubeCart_iso_counties WHERE `name` = ".$db->MySQLSafe($resArray["SHIPTOSTATE"])." AND `countryId` = '".$countryId."'"); if($state==true) { $stateName = $state[0]['name']; } else { $stateName = $resArray["SHIPTOSTATE"]; } $customerData['title'] = $db->MySQLSafe(""); $customerData['firstName'] = $db->MySQLSafe($resArray["FIRSTNAME"]); $customerData['lastName'] = $db->MySQLSafe($resArray["LASTNAME"]); $customerData['add_1'] = $db->MySQLSafe($resArray["SHIPTOSTREET"]); $customerData['add_2'] = $db->MySQLSafe($resArray["SHIPTOSTREET2"]); $customerData['town'] = $db->MySQLSafe($resArray["SHIPTOCITY"]); $customerData['county'] = $db->MySQLSafe($stateName); $customerData['postcode'] = $db->MySQLSafe($resArray["SHIPTOZIP"]); $customerData['country'] = $db->MySQLSafe($countryId); $customerData['phone'] = $db->MySQLSafe(""); if($customer==TRUE) { $db->update($glob['dbprefix']."CubeCart_customer",$customerData,"`email` = ".$db->MySQLSafe($resArray['EMAIL'])); $customer_id = $customer[0]['customer_id']; } else { // added insert data $password = randomPass(6); $customerData['password'] = $db->MySQLSafe(md5($password)); $customerData['email'] = $db->MySQLSafe($resArray['EMAIL']); $customerData['regTime'] = $db->MySQLSafe(time()); $customerData['ipAddress'] = $db->MySQLSafe(get_ip_address()); // this will be googles IP :-/ // ghost membership $customerData['type'] = $db->MySQLSafe(2); $db->insert($glob['dbprefix']."CubeCart_customer",$customerData); $customer_id = $db->insertid(); // send welcome email if($module['welcomeEmail'] == 1) { $emailLang = getLang("email.inc.php"); include(CC_ROOT_DIR.CC_DS."classes".CC_DS."htmlMimeMail".CC_DS."htmlMimeMail.php"); $lang = getLang("email.inc.php"); $mail = new htmlMimeMail(); $macroArray = array( "CUSTOMER_NAME" => sanitizeVar($resArray["FIRSTNAME"])." ".sanitizeVar($resArray["LASTNAME"]), "EMAIL" => sanitizeVar($resArray['EMAIL']), ##"PASSWORD" => sanitizeVar((isset($randomPass)) ? $randomPass : $_POST['password']), "PASSWORD" => $password, "STORE_URL" => $GLOBALS['storeURL'], "SENDER_IP" => get_ip_address() ); $text = macroSub($lang['email']['new_reg_body'],$macroArray); unset($macroArray); $mail->setText($text); $mail->setFrom($config['masterName'].' <'.$config['masterEmail'].'>'); $mail->setSubject($lang['email']['new_reg_subject']); $mail->setHeader('X-Mailer', 'CubeCart Mailer'); $mail->send(array(sanitizeVar($resArray['EMAIL'])), $config['mailMethod']); } } ## Add Customer ID to session data $data['customer_id'] = $customer_id; $update = $db->update($glob['dbprefix']."CubeCart_sessions", $data,"sessId=".$db->mySQLSafe($_COOKIE[CC_SESSION_NAME])); header("Location: index.php?_g=co&_a=step2"); exit; ?>