assign('b_country_ids', $b_country_ids); $smarty->assign('b_country_code', $b_country_code); $smarty->assign('b_country_name', $b_country_name); } if (isset($_POST['b_country'])) { $smarty->assign('b_default_country', $b_country); } else { $smarty->assign('b_default_country', $b_default_country); } ////////////////////////////////////////////////////////////////////////////////////////////////////////////*\ ///////////////////////////////////////////////// get billing state //////////////////////////////////////////////* $query = "SELECT stateid, state FROM diffshop_states WHERE country_code='$b_country' ORDER BY state ASC"; $result = mysql_query($query) or die("error in query - $query - ".mysql_error()); $results_states = mysql_num_rows($result); if ($results_states) { while($row_state = mysql_fetch_array($result)) { $b_state_rows[] = $row_state; } } if ($results_states) { $i = 0; foreach($b_state_rows as $b_state_row) { $b_state_ids[] = $i++; $b_stateid[] = $b_state_row[0]; $bil_state[] = $b_state_row[1]; } } if ($results_states) { $smarty->assign('b_state_ids', $b_state_ids); $smarty->assign('b_stateid', $b_stateid); $smarty->assign('b_state', $bil_state); $smarty->assign('b_default_state', $b_state); } else { $smarty->assign('b_state_ids', NA); $smarty->assign('b_stateid', NA); $smarty->assign('b_state', "N/A"); } ////////////////////////////////////////////////////////////////////////////////////////////////////////////*\ ///////////////////////////////////////////////// get shipping country ////////////////////////////////////////////* $query = "SELECT code, country_name FROM diffshop_countries WHERE active='Y' ORDER BY country_name ASC"; $result = mysql_query($query) or die("error in query - $query - ".mysql_error()); $results_countries = mysql_num_rows($result); if ($results_countries) { while($row_country = mysql_fetch_array($result)) { $s_country_rows[] = $row_country; } } if ($results_countries) { $i = 0; foreach($s_country_rows as $s_country_row) { $s_country_ids[] = $i++; $s_country_code[] = $s_country_row[0]; $s_country_name[] = $s_country_row[1]; } $smarty->assign('s_country_ids', $s_country_ids); $smarty->assign('s_country_code', $s_country_code); $smarty->assign('s_country_name', $s_country_name); } if (isset($_POST['s_country'])) { $smarty->assign('s_default_country', $s_country); } else { $smarty->assign('s_default_country', $s_default_country); } ////////////////////////////////////////////////////////////////////////////////////////////////////////////*\ ///////////////////////////////////////////////// get shipping state //////////////////////////////////////////////* $query = "SELECT stateid, state FROM diffshop_states WHERE country_code='$s_country' ORDER BY state ASC"; $result = mysql_query($query) or die("error in query - $query - ".mysql_error()); $results_states = mysql_num_rows($result); if ($results_states) { while($row_state = mysql_fetch_array($result)) { $s_state_rows[] = $row_state; } } if ($results_states) { $i = 0; foreach($s_state_rows as $s_state_row) { $s_state_ids[] = $i++; $s_stateid[] = $s_state_row[0]; $shi_state[] = $s_state_row[1]; } } if ($results_states) { $smarty->assign('s_state_ids', $s_state_ids); $smarty->assign('s_stateid', $s_stateid); $smarty->assign('s_state', $shi_state); $smarty->assign('s_default_state', $s_state); } else { $smarty->assign('s_state_ids', NA); $smarty->assign('s_stateid', NA); $smarty->assign('s_state', "N/A"); } ////////////////////////////////////////////////////////////////////////////////////////////////////////////*\ ///////////////////////////////////////////////// verify posted data /////////////////////////////////////////////* $errors = 0; $error = array(); if(!valid_email($email)) { $errors++; $error[] = $lang['49']; } if(!valid_password($password)) { $errors++; $error[] = $lang['50']; } if(!valid_password($password2)) { $errors++; $error[] = $lang['51']; } if ($password !== $password2) { $errors++; $error[] = $lang['52']; } if (empty($firstname)) { $errors++; $error[] = $lang['53']; } if (empty($lastname)) { $errors++; $error[] = $lang['53']; } if (empty($b_address)) { $errors++; $error[] = $lang['53']; } if (empty($b_city)) { $errors++; $error[] = $lang['53']; } if (empty($b_zipcode)) { $errors++; $error[] = $lang['53']; } if (empty($phone)) { $errors++; $error[] = $lang['53']; } if (empty($cnp)) { $errors++; $error[] = $lang['53']; } if ($errors == 0) { $sql = "SELECT customer_email FROM diffshop_customers WHERE customer_email = '$email' ORDER BY customer_id ASC"; $result= mysql_query($sql); if(mysql_num_rows($result) > 0) { $email_exist = "YES"; } else { $email_exist = "NO"; } } if ($email_exist == "YES") { $errors++; $error[] = $lang['54']; } $smarty->assign('errors', $errors); $email = $email; $password = $password; $password2 = $password2; $firstname = magic_quotes_add($firstname); $lastname = magic_quotes_add($lastname); $b_address = magic_quotes_add($b_address); $b_city = magic_quotes_add($b_city); $b_state = magic_quotes_add($b_state); $b_country = magic_quotes_add($b_country); $b_zipcode = magic_quotes_add($b_zipcode); $s_address = magic_quotes_add($s_address); $s_city = magic_quotes_add($s_city); $s_state = magic_quotes_add($s_state); $s_country = magic_quotes_add($s_country); $s_zipcode = magic_quotes_add($s_zipcode); $phone = magic_quotes_add($phone); $cnp = magic_quotes_add($cnp); $smarty->assign('email', $email); $smarty->assign('password', $password); $smarty->assign('password2', $password2); $smarty->assign('firstname', $firstname); $smarty->assign('lastname', $lastname); $smarty->assign('b_address', $b_address); $smarty->assign('b_city', $b_city); $smarty->assign('b_zipcode', $b_zipcode); $smarty->assign('s_address', $s_address); $smarty->assign('s_city', $s_city); $smarty->assign('s_zipcode', $s_zipcode); $smarty->assign('phone', $phone); $smarty->assign('cnp', $cnp); if ($errors > 0) { $error = array_unique($error); foreach ($error as $key => $value) { $register_errors .= $value."
"; } $smarty->assign('register_errors', $register_errors); } if (isset($_POST['register_x'])) { $smarty->assign('post_registers', "YES"); } if ($errors == 0) { if (empty($s_address) || empty($s_city) || empty($s_zipcode)) { $s_address = $b_address; $s_city = $b_city; $s_state = $b_state; $s_country = $b_country; $s_zipcode = $b_zipcode; } /////// insert into database $password_crypt = md5($password); $sql = "INSERT INTO diffshop_customers (customer_id, customer_email, customer_password, firstname, lastname, cnp, cui, reg_com, banca, cont, iban, company, b_address, b_city, b_state, b_country, b_zipcode, s_address, s_city, s_state, s_country, s_zipcode, phone, fax, url, membership, pending_membership, registration_date) VALUES ('', '$email', '$password_crypt', '$firstname', '$lastname', '$cnp', '', '', '', '', '', '$company', '$b_address', '$b_city', '$b_state', '$b_country', '$b_zipcode', '$s_address', '$s_city', '$s_state', '$s_country', '$s_zipcode', '$phone', '', '', '1', 'N', ".time().")"; $result = mysql_query($sql) or die("error in query - $sql - ".mysql_error()); $showdetail_register = mysql_insert_id(); $get_ip = $_SERVER['REMOTE_ADDR']; $sql = "INSERT INTO diffshop_register_ip (id, customer_id, registered_ip) VALUES ('', '$showdetail_register', '$get_ip')"; $result = mysql_query($sql) or die("error in query - $sql - ".mysql_error()); //////// get email message $query = "SELECT shop_name, shop_email, ".select_language('shop_email_subject_lang1', 'shop_email_subject_lang2', 'shop_email_subject_lang3', 'shop_email_subject_lang4', 'shop_email_subject_lang5', 'shop_email_subject_lang6').", ".select_language('shop_email_description_lang1', 'shop_email_description_lang2', 'shop_email_description_lang3', 'shop_email_description_lang4', 'shop_email_description_lang5', 'shop_email_description_lang6')." FROM diffshop_general_settings_register_email WHERE id='1'"; $result = mysql_query($query) or die("error in query - $query - ".mysql_error()); while($row = mysql_fetch_array($result)) { $shop_name = $row[0]; $shop_email = $row[1]; $shop_email_subject = magic_quotes_strip($row[2]); $shop_email_description = magic_quotes_strip($row[3]); } $shop_email_description = str_replace('%email%', $email, $shop_email_description); $shop_email_description = str_replace('%password%', $password, $shop_email_description); ///////// convert message //////////// $filename = "templates-email/template_email_register.html"; $fd = fopen($filename, "r"); $html_receipt_template = fread($fd, filesize($filename)); fclose($fd); $html_receipt_template = str_replace('-=CONTENT=-', $shop_email_description, $html_receipt_template); $mail_header = "From: $shop_email\n"; $mail_header .= "Reply-to: $shop_email\n"; $mail_header .= "Content-Type: text/html\n"; mail($email, $shop_email_subject, $html_receipt_template, $mail_header); ///// insert into newsletter if (isset($_POST['agree'])) { $sql = "SELECT email FROM diffshop_newsletter WHERE email = '$email' ORDER BY newsletter_id ASC"; $result= mysql_query($sql); if(mysql_num_rows($result) > 0) { $email_exist = "YES"; } else { $email_exist = "NO"; } if ($email_exist == "NO") { $sql = "INSERT INTO diffshop_newsletter (newsletter_id, firstname, lastname, email, format, active, date_added, date_last_sent) VALUES ('', '$firstname', '$lastname', '$email', 'HTML', 'Y', ".time().", '0')"; $result = mysql_query($sql) or die("error in query - $sql - ".mysql_error()); } } ////////// } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////*\ $smarty->display('register.tpl'); include ("close_mysql.php"); ?>