<?php
/*
	osCommerce, Open Source E-Commerce Solutions 
	http://www.oscommerce.com 
	
	Copyright (c) 2003 osCommerce 
	
	osCommRes, Services Oline 
	http://www.oscommres.com 
	Copyright (c) 2005 osCommRes 
	
	Freeway eCommerce 
	http://www.zac-ware.com/freeway 
	Copyright (c) 2007 ZacWare
	
	Released under the GNU General Public License
*/



// Set flag that this is a parent file
	define( '_FEXEC', 1 );
	
	$format=array('d-m-Y'=>'dd-mm-yyyy',
				  'm-d-Y'=>'mm-dd-yyyy',
				  'Y-m-d'=>'yyyy-mm-dd');
	if(isset($joomla_include)) $usersConfig = &JComponentHelper::getParams('com_users');	
	require('includes/application_top.php');	
	$serverDate = date('Y-m-d H:i:s',getServerDate(false));
	$command=isset($HTTP_GET_VARS['command'])?(tep_db_prepare_input($HTTP_GET_VARS['command'])):'';
	$country=isset($HTTP_GET_VARS['country_id'])?(tep_db_prepare_input($HTTP_GET_VARS['country_id'])):0; 
	$content="";
	//ajax start
	if($command=='show_state'){
		  $zone_ids="";
		  $zone_name="";
		  $zones_query = tep_db_query("select zone_id,zone_name from " . TABLE_ZONES . " where zone_country_id = '" . tep_db_input($country) . "' order by zone_name");
		  while ($zones_values = tep_db_fetch_array($zones_query)) {
			 $zone_ids.=$zones_values['zone_id']."{}";
			 $zone_name.=$zones_values['zone_name']."{}";
		  }
	   echo 'show_state^'.substr($zone_ids,0,-2)."^".substr($zone_name,0,-2)."^".$zone;     
	   exit;
	}   
 //ajax end
 if(tep_session_is_registered('customer_id')) tep_redirect(tep_href_link('account.php'));
// needs to be included earlier to set the success message in the messageStack
  require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_CREATE_ACCOUNT);
  $process = false;
  if (isset($HTTP_POST_VARS['action']) && ($HTTP_POST_VARS['action'] == 'process')) {
    $process = true;

    if (ACCOUNT_GENDER == 'true') {
      if (isset($HTTP_POST_VARS['gender'])) {
        $gender = tep_db_prepare_input($HTTP_POST_VARS['gender']);
      } else {
        $gender = false;
      }
    }
    $firstname = tep_db_prepare_input($HTTP_POST_VARS['firstname']);
    $lastname = tep_db_prepare_input($HTTP_POST_VARS['lastname']);
    if (ACCOUNT_DOB == 'true') $dob = str_replace("/","-",tep_db_prepare_input($HTTP_POST_VARS['dob']));
    $email_address = tep_db_prepare_input($HTTP_POST_VARS['email_address']);
    $confirm_email_address=tep_db_prepare_input($HTTP_POST_VARS['confirm_email_address']);
   
   	
	if (ACCOUNT_USERNAME == 'true') {
  	  $username = tep_db_prepare_input($HTTP_POST_VARS['username']);
	}
	
    if (ACCOUNT_SECOND_EMAIL == 'true') $second_email_address = tep_db_prepare_input($HTTP_POST_VARS['second_email_address']);
    	if($second_email_address!='')
    		$second_confirm_email_address = tep_db_prepare_input($HTTP_POST_VARS['second_confirm_email_address']); 			
    if (ACCOUNT_COMPANY == 'true') $company = tep_db_prepare_input($HTTP_POST_VARS['company']);
    $street_address = tep_db_prepare_input($HTTP_POST_VARS['street_address']);
    if (ACCOUNT_SUBURB == 'true') $suburb = tep_db_prepare_input($HTTP_POST_VARS['suburb']);
    $postcode = tep_db_prepare_input($HTTP_POST_VARS['postcode']);
    $city = tep_db_prepare_input($HTTP_POST_VARS['city']);
    if (ACCOUNT_STATE == 'true') {
	  $state = (!is_numeric($HTTP_POST_VARS['state']))?tep_db_prepare_input($HTTP_POST_VARS['state']):"";
      if ($state=="" && isset($HTTP_POST_VARS['zone_id'])) {
        $state = tep_db_prepare_input($HTTP_POST_VARS['zone_id']);
      } else {
        $zone_id = false;
      }
    }
    $country = tep_db_prepare_input($HTTP_POST_VARS['country']);
    if (ACCOUNT_TELEPHONE=='true') $telephone = tep_db_prepare_input($HTTP_POST_VARS['telephone']);
    if (ACCOUNT_SECOND_PHONE == 'true') $second_telephone = tep_db_prepare_input($HTTP_POST_VARS['second_telephone']);
    $mobile = tep_db_prepare_input($HTTP_POST_VARS['mobile']);

    if (ACCOUNT_NEWSLETTER=='true') $newsletter = tep_db_prepare_input($HTTP_POST_VARS['newsletter']);
    if (ACCOUNT_RESERVATION_NEWSLETTER=='true') $reserve_newsletter = tep_db_prepare_input($HTTP_POST_VARS['reserve_newsletter']);
	if (ACCOUNT_SUBSCRIPTION_NEWSLETTER=='true') $subscription_newsletter=tep_db_prepare_input($HTTP_POST_VARS['subscription_newsletter']);

    $password = tep_db_prepare_input($HTTP_POST_VARS['password']);
    $confirmation = tep_db_prepare_input($HTTP_POST_VARS['confirmation']);
	
//rmh referral start
	$source="";
	$source_other="";
	if (HIDE_REFERRAL_FRONT=='false'){
		$source = tep_db_prepare_input($HTTP_POST_VARS['source']);
		if (isset($HTTP_POST_VARS['source_other'])) $source_other = tep_db_prepare_input($HTTP_POST_VARS['source_other']);
//rmh referral end
	}
	if (HIDE_CUSTOMER_OCCUPATION_FRONT=='false'){
		$occupation = tep_db_prepare_input($HTTP_POST_VARS['occupation']);
	}
	if (HIDE_CUSTOMER_INTEREST_FRONT=='false'){
		$interest = tep_db_prepare_input($HTTP_POST_VARS['interest']);
	}
    $error = false;

    if (ACCOUNT_GENDER == 'true') {
      if ( ($gender != 'm') && ($gender != 'f') ) {
        $error = true;

        $messageStack->add('create_account', ENTRY_GENDER_ERROR);
      }
    }

    if (strlen($firstname) < ENTRY_FIRST_NAME_MIN_LENGTH) {
      $error = true;

      $messageStack->add('create_account', ENTRY_FIRST_NAME_ERROR);
    }

    if (strlen($lastname) < ENTRY_LAST_NAME_MIN_LENGTH) {
      $error = true;

      $messageStack->add('create_account', ENTRY_LAST_NAME_ERROR);
    }

    if (ACCOUNT_DOB == 'true') {
      if (!tep_check_date_raw($dob,EVENTS_DATE_FORMAT)) {
        $error = true;

        $messageStack->add('create_account', ENTRY_EVENT_DATE_OF_BIRTH_ERROR);
      }
    }

	if (ACCOUNT_USERNAME == 'true') {
		if (strlen($username) < ENTRY_USERNAME_MIN_LENGTH) {
		  $error = true;
	
		  $messageStack->add('create_account', ENTRY_USERNAME_ERROR);
		} else {

		  $check_name_query = tep_db_query("select count(*) as total from " . TABLE_CUSTOMERS . " where LOWER(customers_username) = '" . strtolower(tep_db_input($username)) . "'");
		  $check_name = tep_db_fetch_array($check_name_query);
		  if ($check_name['total'] > 0) {
			$error = true;
	
			$messageStack->add('create_account', ENTRY_USERNAME_ERROR_EXISTS);
		  }
		}
	}
	
   if (strlen($email_address) < ENTRY_EMAIL_ADDRESS_MIN_LENGTH) {
      $error = true;

      $messageStack->add('create_account', ENTRY_EMAIL_ADDRESS_ERROR);
    } elseif (tep_validate_email($email_address) == false) {
      $error = true;

      $messageStack->add('create_account', ENTRY_EMAIL_ADDRESS_CHECK_ERROR);
    }else if($email_address!=$confirm_email_address){
    	$error = true;
	   $messageStack->add('create_account', ENTRY_CONFIRM_EMAIL_ADDRESS_ERROR);
    }  else {
      $check_email_query = tep_db_query("select count(*) as total from " . TABLE_CUSTOMERS . " where customers_email_address = '" . tep_db_input($email_address) . "'");
      $check_email = tep_db_fetch_array($check_email_query);
      if ($check_email['total'] > 0) {
        $error = true;

        $messageStack->add('create_account', ENTRY_EMAIL_ADDRESS_ERROR_EXISTS);
      }
    }
   
   //check second email address
	   if ($second_email_address!='' && (tep_validate_email($second_email_address) == false || $email_address==$second_email_address)) {
			$error = true;
	      $messageStack->add('create_account', ENTRY_SECOND_EMAIL_ADDRESS_CHECK_ERROR);   
	   } else if($second_email_address!='' && $second_email_address!=$second_confirm_email_address){
	    	$error = true;
		   $messageStack->add('create_account', ENTRY_SECOND_CONFIRM_EMAIL_ADDRESS_ERROR);
	   }
	//check second email address
	
   if (strlen($street_address) < ENTRY_STREET_ADDRESS_MIN_LENGTH) {
      $error = true;

      $messageStack->add('create_account', ENTRY_STREET_ADDRESS_ERROR);
    }

    if (strlen($postcode) < ENTRY_POSTCODE_MIN_LENGTH) {
      $error = true;

      $messageStack->add('create_account', ENTRY_POST_CODE_ERROR);
    }

    if (strlen($city) < ENTRY_CITY_MIN_LENGTH) {
      $error = true;

      $messageStack->add('create_account', ENTRY_CITY_ERROR);
    }

    if (is_numeric($country) == false) {
      $error = true;

      $messageStack->add('create_account', ENTRY_COUNTRY_ERROR);
    }

    if (ACCOUNT_STATE == 'true') {      
      $zone_id=0;
	  $check_query = tep_db_query("select count(*) as total from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country . "'");
      $check = tep_db_fetch_array($check_query);
      $entry_state_has_zones = ($check['total'] > 0);
      if ($entry_state_has_zones == true) {
        $zone_query = tep_db_query("select distinct zone_id from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country . "' and zone_id='" . tep_db_input($state) . "'");
        if (tep_db_num_rows($zone_query) == 1) {
          $zone = tep_db_fetch_array($zone_query);
          $zone_id = $zone['zone_id'];
        } else {
          $error = true;
          $messageStack->add('create_account', ENTRY_STATE_ERROR_SELECT);
        }
      } else {
        if (strlen($state) < ENTRY_STATE_MIN_LENGTH) {
          $error = true;
          $messageStack->add('create_account', ENTRY_STATE_ERROR);
        }
      }
    }

  if (ACCOUNT_TELEPHONE=='true'){
		if (strlen($telephone) < ENTRY_TELEPHONE_MIN_LENGTH) {
		  $error = true;
	
		  $messageStack->add('create_account', ENTRY_TELEPHONE_NUMBER_ERROR);
		}
	}
    if (strpos($mobile,"+")!==false) {
      $error = true;

      $messageStack->add('create_account', ENTRY_MOBILE_NUMBER_ERROR);
    }

//rmh referral start
    if ((HIDE_REFERRAL_FRONT == 'false') && (is_numeric($source) == false)) {
        $error = true;

        $messageStack->add('create_account', ENTRY_SOURCE_ERROR);
    }

//rmh referral end

    if ((HIDE_CUSTOMER_OCCUPATION_FRONT == 'false') && (is_numeric($occupation) == false)) {
        $error = true;

        $messageStack->add('create_account', ENTRY_OCCUPATION_ERROR);
    }

    if ((HIDE_CUSTOMER_INTEREST_FRONT == 'false') && (is_numeric($interest) == false)) {
        $error = true;

        $messageStack->add('create_account', ENTRY_INTEREST_ERROR);
    }
	
    if (strlen($password) < ENTRY_PASSWORD_MIN_LENGTH) {
      $error = true;

      $messageStack->add('create_account', ENTRY_PASSWORD_ERROR);
	

    } elseif ($password != $confirmation) {
      $error = true;

      $messageStack->add('create_account', ENTRY_PASSWORD_ERROR_NOT_MATCHING);
    }
/*   if(MODULE_CUSTOMERS_PASSWORD_STRENGTH==4)
  {
  	if(!tep_check_password_strength($password))
	{
		$error=true;
		$messageStack->add('create_account', ENTRY_PASSWORD_STRENGTH_ERROR);
	}
  }*/
    if ($error == false) {
		$hash_id=md5(time());
    	$encryption_style=(defined('ENCRYPTION_STYLE'))?ENCRYPTION_STYLE:'O';
      $sql_data_array = array('customers_firstname' => $firstname,
                              'customers_lastname' => $lastname,
                              'customers_email_address' => $email_address,
                              'customers_fax' => $mobile,
                              'customers_newsletter' => $newsletter,
                              'customers_reserve_newsletter' => $reserve_newsletter,
							  			'customers_subscription_newsletter'=>$subscription_notify,
                              'customers_password' => tep_encrypt_password($password),
                              'encryption_style'=>$encryption_style							  
							  );

		if (ACCOUNT_USERNAME == 'true') $sql_data_array['customers_username'] = $username;
      if (ACCOUNT_SECOND_EMAIL == 'true') $sql_data_array['customers_second_email_address'] = $second_email_address;
      if (ACCOUNT_TELEPHONE=='true') $sql_data_array['customers_telephone']=$telephone;
      if (ACCOUNT_SECOND_PHONE == 'true') $sql_data_array['customers_second_telephone'] = $second_telephone;
      if (ACCOUNT_GENDER == 'true') $sql_data_array['customers_gender'] = $gender;
      if (ACCOUNT_DOB == 'true') $sql_data_array['customers_dob'] = tep_convert_date_raw($dob,EVENTS_DATE_FORMAT);
		if (ACCOUNT_NEWSLETTER=='true') $newsletter = tep_db_prepare_input($HTTP_POST_VARS['newsletter']);
		if (ACCOUNT_RESERVATION_NEWSLETTER=='true') $sql_data_array['customers_reserve_newsletter'] = $reserve_newsletter;
		if (ACCOUNT_SUBSCRIPTION_NEWSLETTER=='true') $sql_data_array['customers_subscription_newsletter']=$subscription_newsletter;
 		if (HIDE_CUSTOMER_OCCUPATION_FRONT=="false") $sql_data_array["customers_occupation"]=$occupation;
 		if (HIDE_CUSTOMER_INTEREST_FRONT=="false") $sql_data_array["customers_interest"]=$interest;

      tep_db_perform(TABLE_CUSTOMERS, $sql_data_array);

      $customer_id = tep_db_insert_id();

      $sql_data_array = array('customers_id' => $customer_id,
                              'entry_firstname' => $firstname,
                              'entry_lastname' => $lastname,
                              'entry_street_address' => $street_address,
                              'entry_postcode' => $postcode,
                              'entry_city' => $city,
                              'entry_country_id' => $country);

      if (ACCOUNT_GENDER == 'true') $sql_data_array['entry_gender'] = $gender;
      if (ACCOUNT_COMPANY == 'true') $sql_data_array['entry_company'] = $company;
      if (ACCOUNT_SUBURB == 'true') $sql_data_array['entry_suburb'] = $suburb;
      if (ACCOUNT_STATE == 'true') {
        if ($zone_id > 0) {
          $sql_data_array['entry_zone_id'] = $zone_id;
          $sql_data_array['entry_state'] = '';
        } else {
          $sql_data_array['entry_zone_id'] = '0';
          $sql_data_array['entry_state'] = $state;
        }
      }

      tep_db_perform(TABLE_ADDRESS_BOOK, $sql_data_array);

      $address_id = tep_db_insert_id();

      tep_db_query("update " . TABLE_CUSTOMERS . " set customers_default_address_id = '" . (int)$address_id . "' where customers_id = '" . (int)$customer_id . "'");


	  // store the details in customers info
  	  $sql_array=array(	"customers_info_id"=>$customer_id,
						"customers_info_number_of_logons"=>0,
						"customers_info_date_account_created"=> $serverDate 
						);
 		if (HIDE_REFERRAL_FRONT=="false") $sql_array["customers_info_source_id"]=$source;
		
		tep_db_perform(TABLE_CUSTOMERS_INFO,$sql_array);
		
	  if (HIDE_REFERRAL_FRONT=="false" && $source=="9999") {
        	tep_db_query("insert into " . TABLE_SOURCES_OTHER . " (customers_id, sources_other_name) values ('" . (int)$customer_id . "', '". tep_db_input($source_other) . "')");
      }
//rmh referral end
      $customer_first_name = $firstname;
      $customer_default_address_id = $address_id;
      $customer_country_id = $country;
      $customer_zone_id = $zone_id;
      tep_session_register('customer_id');
      tep_session_register('customer_first_name');
      tep_session_register('customer_default_address_id');
      tep_session_register('customer_country_id');
      tep_session_register('customer_zone_id');

// restore cart contents
      $cart->restore_contents();

// build the message content using built in template
      $send_details=array();
      
      //build merge details
      $merge_details=array();
      $merge_details[TEXT_FN]=$firstname;
      $merge_details[TEXT_LN]=$lastname;

      if (ACCOUNT_GENDER == 'true') {
         if ($gender == 'm') {
           $merge_details[TEXT_GR] = sprintf(EMAIL_GREET_MR, $lastname);
         } else {
           $merge_details[TEXT_GR] = sprintf(EMAIL_GREET_MS, $lastname);
         }
      } else {
        $merge_details[TEXT_GR] = sprintf(EMAIL_GREET_NONE, $firstname);
      }
      $merge_details[TEXT_SM]=STORE_NAME;
	  $merge_details[TEXT_SN]=STORE_OWNER;
      $merge_details[TEXT_SE]=STORE_OWNER_EMAIL_ADDRESS;
      $merge_details[TEXT_LE]=$email_address;
      $merge_details[TEXT_LP]=$password;
      $merge_details[TEXT_SP]=HTTP_SERVER . DIR_WS_CATALOG . "images/".COMPANY_LOGO;
      $send_details[0]['to_name'] = $firstname . ' ' . $lastname;
      $send_details[0]['to_email'] = $email_address;
      $send_details[0]['from_name']=STORE_OWNER;
      $send_details[0]['from_email']=STORE_OWNER_EMAIL_ADDRESS;
/*    $send_details[1]['to_name'] = STORE_OWNER;
      $send_details[1]['to_email'] = STORE_OWNER_EMAIL_ADDRESS
      $send_details[1]['from_name']=STORE_OWNER;
      $send_details[1]['from_email']=STORE_OWNER_EMAIL_ADDRESS;*/

      tep_send_default_email("CUS",$merge_details,$send_details);
       	  
  if ((NEW_SIGNUP_GIFT_VOUCHER_AMOUNT > 0) || 
(NEW_SIGNUP_DISCOUNT_COUPON != '')) {
    $email_text .= EMAIL_TEXT . EMAIL_CONTACT . EMAIL_WARNING;
	}
// ICW - CREDIT CLASS CODE BLOCK ADDED  ******************************************************* BEGIN
  if (NEW_SIGNUP_GIFT_VOUCHER_AMOUNT > 0) {
    $coupon_code = create_coupon_code();
    $insert_query = tep_db_query("insert into " . TABLE_COUPONS . " (coupon_code, coupon_type, coupon_amount, date_created) values ('" . tep_db_input($coupon_code) . "', 'G', '" . NEW_SIGNUP_GIFT_VOUCHER_AMOUNT . "', '". $serverDate ."')");
    $insert_id = tep_db_insert_id($insert_query);
    $insert_query = tep_db_query("insert into " . TABLE_COUPON_EMAIL_TRACK . " (coupon_id, customer_id_sent, sent_firstname, emailed_to, date_sent) values ('" . tep_db_input($insert_id) ."', '0', 'Admin', '" . tep_db_input($email_address) . "', '". $serverDate ."' )");

    $email_text .= sprintf(EMAIL_GV_INCENTIVE_HEADER, $currencies->format(NEW_SIGNUP_GIFT_VOUCHER_AMOUNT)) . "\n\n" .
                   sprintf(EMAIL_GV_REDEEM, $coupon_code) . "\n\n" .
                   EMAIL_GV_LINK . tep_href_link(FILENAME_GV_REDEEM, 'gv_no=' . $coupon_code) .
                   "\n\n";
  }
  if (NEW_SIGNUP_DISCOUNT_COUPON != '') {
    $coupon_id = NEW_SIGNUP_DISCOUNT_COUPON;
    $coupon_query = tep_db_query("select * from " . TABLE_COUPONS . " where coupon_id = '" . tep_db_input($coupon_id) . "'");
    $coupon_desc_query = tep_db_query("select * from " . TABLE_COUPONS_DESCRIPTION . " where coupon_id = '" . tep_db_input($coupon_id) . "' and language_id = '" . tep_db_input(languages_id) . "'");
    $coupon = tep_db_fetch_array($coupon_query);
    $coupon_desc = tep_db_fetch_array($coupon_desc_query);
    $insert_query = tep_db_query("insert into " . TABLE_COUPON_EMAIL_TRACK . " (coupon_id, customer_id_sent, sent_firstname, emailed_to, date_sent) values ('" . tep_db_input($coupon_id) ."', '0', 'Admin', '" . tep_db_input($email_address) . "', '". $serverDate ."' )");
    $email_text .= EMAIL_COUPON_INCENTIVE_HEADER .  "\n\n" .
                   $coupon_desc['coupon_description'] .
                   sprintf(EMAIL_COUPON_REDEEM, $coupon['coupon_code']) . "\n\n" .
                   "\n\n";

  }    
// ICW - CREDIT CLASS CODE BLOCK ADDED  ******************************************************* END
      //tep_m($name, $email_address, EMAIL_SUBJECT, $email_text, STORE_OWNER, STORE_OWNER_EMAIL_ADDRESS);
	//JOOMLA5 extend  start
	if ($joomla_include){
	$db = &JFactory::getDBO();
	$db->setQuery("select id from #__users where username='".tep_db_prepare_input($HTTP_POST_VARS['username'])."'");
	$userid=$db->loadResult();
	$already_user_found=false;
	if($userid<=0) {
		$name=stripslashes(tep_db_prepare_input($HTTP_POST_VARS['firstname']).' '.tep_db_prepare_input($HTTP_POST_VARS['lastname']));
		$username=stripslashes(tep_db_prepare_input($HTTP_POST_VARS['username']));
		jimport('joomla.user.helper');
		$salt = JUserHelper::genRandomPassword(32);
		$crypt = JUserHelper::getCryptedPassword(tep_db_prepare_input($HTTP_POST_VARS['password']),$salt);
		$password = $crypt.':'.$salt;
		$hash_id=md5(time());
		$email_address=stripslashes(tep_db_prepare_input($HTTP_POST_VARS['email_address']));
	    $query=sprintf("INSERT INTO #__users (name, username, email, password, usertype, registerDate, gid, block,activation) VALUES (%s,%s,%s,%s,'%s','%s','%s',%s,%s)",$db->Quote($name),$db->Quote($username),$db->Quote($email_address),$db->Quote($password),$usersConfig->get('new_usertype'), date( 'Y-m-d H:i:s' ), 18, 0,$db->Quote($hash_id));
	    $db->Execute($query);
	    $user_id = intval($db->insertid());
	    if ($user_id>0){
		  $query="INSERT INTO #__core_acl_aro (section_value, value, order_value, name, hidden) VALUES ('users', ".tep_db_input($user_id).", 0, '".tep_db_input($name)."', 0)";
		  $db->setQuery($query);
		  $db->query();
		  $aro_id = $db->insertid();
		  $query="INSERT INTO #__core_acl_groups_aro_map (group_id, aro_id) VALUES (18, ".tep_db_input($aro_id).")";
		  $db->setQuery($query);
		  $db->query();
		  $query=sprintf("UPDATE #__session set username=%s,time='%s',guest=0,userid=%s,usertype='".$usersConfig->get('new_usertype')."',gid=18 where session_id=%s",$db->Quote($username),time(),$user_id,$db->Quote($check_id));
		  $db->setQuery($query);
		  $db->query(); 
		  $raw_password=tep_db_prepare_input($HTTP_POST_VARS['password']);
		  $already_user_found=true;
	  }
	}else {
		$username=tep_db_prepare_input($HTTP_POST_VARS['username']);
		$raw_password=tep_db_prepare_input($HTTP_POST_VARS['password']);
		$already_user_found=true;	
	}
		$uri = JFactory::getURI();
		$url=$uri->_scheme.'://'.str_replace("//","/",$uri->_host.'/'.JRoute::_('index.php', true));
	?>
		  <html><head></head><body><form action="<?php echo $url; ?>" method="post" name="frm_login" id="frm_login">
		  <input id="modlgn_username" type="hidden" value="<?php echo tep_output_string($username);?>" name="username" class="inputbox" size="18" />
		  <input id="modlgn_passwd" type="hidden" value="<?php echo tep_output_string($raw_password);?>" name="passwd" class="inputbox" size="18"/>	
		  <input type="hidden" name="option" value="com_user" />
		  <input type="hidden" name="task" value="login" />
		  <input type="hidden" name="<?php echo JUtility::getToken();?>" value="1" />
		  <input type="hidden" name="return" value="<?php echo base64_encode(tep_href_link('checkout_shipping.php')); ?>" />
	      </form>
	      <script language="javascript">if(document.frm_login) document.frm_login.submit();</script></body></html>
<?php     exit;
	}
  	  tep_redirect(tep_href_link(FILENAME_CREATE_ACCOUNT_SUCCESS, '', 'SSL'));
   }
   //JOOMLA5 extend  end    
  }
  
  $breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_CREATE_ACCOUNT, '', 'SSL'));
  $javascript = 'form_check.js.php';
  $content = CONTENT_CREATE_ACCOUNT;

  require(DIR_WS_TEMPLATES . TEMPLATE_NAME . '/' . TEMPLATENAME_MAIN_PAGE);
  require(DIR_WS_INCLUDES . 'application_bottom.php');
?>
