<?php session_start();  //Developed by ITechScripts
require 'include/announcements.php'; // ITECHBIDS Configuration File
require'include/options.php';
require'include/itechbids.php';
$step=$_POST[step];
$member=$_GET[member];
$default_currency="select * from genaralsettings where set_id=56";
$default_res=mysql_query($default_currency);
$default_row=mysql_fetch_array($default_res);
$default_cur_code=$default_row[set_value];
if($step==1)
{
include_once 'securimage.php';
$securimage = new Securimage();
$first=$_POST[txtfirst];
$last=$_POST[txtlast];
$member=$_POST[member];
$address=$_POST[txtaddress];
$city=$_POST[txtcity];
$state=$_POST[txtstate];
$code=$_POST[txtzipcode];
$primary=$_POST[txtprimary];
//$primary1=$_POST[txtprimary1];
//$primary2=$_POST[txtprimary2];
$secondary=$_POST[txtsecondary];
//$secondary1=$_POST[txtsecondary1];
$country=$_POST[cbocountry];
$day=$_POST[cboday];
$month=$_POST[cbomonth];
$year=$_POST[txtYear];
$dob=$year."-".$month."-".$day;
$introid=$_POST['introid'];
if($introid=='') $introid=0;
$_SESSION[introid]=$introid;
$email=$_POST[txtemail];
$reemail=$_POST[txtreemail];
$terms=$_POST[chkterms];
$email_enable_status=$_POST[email_status];
$mem_plans=1;
$_SESSION['registration_fee'] = 0;
$_SESSION['mem_plans'] = $mem_plans;

function check_email_address($email) {
// First, we check that there's one @ symbol, and that the lengths are right
if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) {
// Email invalid because wrong number of characters in one section, or wrong number of @ symbols.
return false;
}
// Split it into sections to make life easier
$email_array = explode("@", $email);
$local_array = explode(".", $email_array[0]);
for ($i = 0; $i < sizeof($local_array); $i++) {
if (!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$", $local_array[$i])) {
return false;
}
}
if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) { // Check if domain is IP. If not, it should be valid domain name
$domain_array = explode(".", $email_array[1]);
if (sizeof($domain_array) < 2) {
return false; // Not enough parts to domain
}
for ($i = 0; $i < sizeof($domain_array); $i++) {
if (!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|([A-Za-z0-9]+))$", $domain_array[$i])) {
return false;
}
}
}
return true;
}

if((empty($terms))&&($en_dis[3]=="yes"))
 {
   $err_terms=$err_23;
   $err_flag=1;
 }
  if(empty($first))
   {
   $err_first=$err_23;
   $err_flag=1;
  }
  if(empty($last))
  {
  $err_last=$err_23;
  $err_flag=1;
  }
  if(empty($address))
  {
   $err_add=$err_23;
   $err_flag=1;
  }
    if(empty($city))
	{
   $err_city=$err_23;
    $err_flag=1;
	}
	if(empty($state))
	{
   $err_state=$err_23;
   $err_flag=1;
	}
	if(empty($country))
	{
   $err_country=$err_23;
   $err_flag=1;
	}
    if(empty($primary))
   {
   $err_primary2=$err_23;
   $err_flag=1;
   }
   if(!is_numeric($primary))
   {
   $err_primary2=$err_7;
   $err_flag=1;
   }
	
   if(empty($code))
   {
   $err_code="Please enter this information";
   $err_flag=1;
   }
   
   if(is_string($code))
   {
   $len=strlen($code);
   for($i=0;$i<=$len;$i++)
   {
   $tr=substr($code,$i,1);
   if (strcmp($tr,":")==0 or strcmp($tr,"?")==0 
   or strcmp($tr,"'")==0 or strcmp($tr,";")==0 or strcmp($tr,"#")==0
   or strcmp($tr,"@")==0 or strcmp($tr,"!")==0 or strcmp($tr,"$")==0 
   or strcmp($tr,"%")==0 or strcmp($tr,"^")==0 or strcmp($tr,"&")==0 
   or strcmp($tr,"*")==0 or strcmp($tr,",")==0 or strcmp($tr,"(")==0
   or strcmp($tr,")")==0 or strcmp($tr,"_")==0 or strcmp($tr,"-")==0
   or strcmp($tr,"+")==0 or strcmp($tr,"=")==0 or strcmp($tr,"|")==0
   or strcmp($tr,"/")==0 or strcmp($tr,"{")==0 or strcmp($tr,"}")==0
   or strcmp($tr,"[")==0 or strcmp($tr,"]")==0 or strcmp($tr,">")==0
   or strcmp($tr,"<")==0 or strcmp($tr,",")==0 or strcmp($tr,"\\")==0)
   $c=1;
   }
   if($c==1)
   {
   $err_code="Your Post Code is Invalid (Only alphanumeric keys accepted) ";
   $err_flag=1;
   }
   }
   		
   /*if(empty($primary1))
   {
   $err_primary=$err_23;
	   $err_flag=1;
   }
   if(!is_numeric($primary1))
   {
   $err_primary=$err_7;
   $err_flag=1;
   }
   
   if(empty($primary2))
   {
   $err_primary1=$err_23;
	   $err_flag=1;
   }
   if(!is_numeric($primary2))
   {
   $err_primary1=$err_7;
   $err_flag=1;
   }*/

   
   
    if(empty($secondary))
   {
   $err_secondary=$err_23;
   $err_flag=1;
   }
   if(!is_numeric($secondary))
   {
   $err_secondary=$err_9;
   $err_flag=1;
   }
   /*if(empty($secondary1))
   {
   $err_secondary1=$err_23;
   $err_flag=1;
   }
    if(!is_numeric($secondary1))
	{
   $err_secondary1=$err_9;

	  $err_flag=1;
	}*/
   if(empty($email))
   {
   $err_email=$err_23;
   $err_flag=1;
   }
   else
   {
    
   	$doma=explode('@',$email);
	$domain_table=mysql_query("select * from  blocked_domain where blocked_domain='$doma[1]'");
	$domain_avl=mysql_num_rows($domain_table);
    if(!check_email_address($email))
	{
   $err_email=$err_13;
   $err_flag=1;
	}
	elseif($domain_avl>0)
	{
   $err_email2=$err_86;
   $err_email1=$err_87;
   $err_email="$err_email2".$doma[1]."$err_email1".$doma[1];
   $err_flag=1;
	}
	}
   if(empty($reemail))
   {
  $err_reemail=$err_23;
   $err_flag=1;
	}
  else
  {
    if(!check_email_address($reemail))
	{
  $err_reemail=$err_13;
	
	 $err_flag=1;
	}
	}
   
    if((empty($err_email)) && (empty($err_reemail)))
	{
	if($email!=$reemail)
	{
      $err_email=$err_14;
	  $err_remail=$err_14;
	  $err_flag=1;
	}
	else
	{
	
	 $chk_email="select * from member_details where email='$email'";
	  $chk_res=mysql_query($chk_email);
	 if(mysql_num_rows($chk_res) > 0)
	 {
	 $err_flag=1;
      $err_email=$err_15;
	 }
	
	}

	}
	

	
      if(empty($day))
  {
  $err_day=$err_23;
  
  $err_flag=1;
  }
  if(empty($month))
  {
  
  $err_month=$err_23;
  
  $err_flag=1;
  }
  if(empty($year))
  {
  $err_year=$err_23;
  
  $err_flag=1;
  }
  if(empty($err_day) and empty($err_year) and empty($err_month))
  {
  $chk_year=date("Y:m:d");
  $chk_dob="$year".":"."$month".":"."$day";
  if(($chk_year-$chk_dob) < 18 )
  {
  $err_dob=$err_23;
  
  
  $err_flag=1;
  }
  }

if ($securimage->check($_POST['captcha_code']) == false)
  {
  $err_captcha="Dont match the image";
  $err_flag=1;
  }





   if($err_flag!=1)
  {
   $date_of_registration=date('Y-m-d');
   $ip=$_SERVER['REMOTE_ADDR'];
   $temp_account=1; 
   $primary="$primary1"."$primary2"."$primary";
   $secondary="$secondary1"."$secondary";

$auction_query="select * from genaralsettings where set_id=61";
$table=mysql_query($auction_query);
$row=mysql_fetch_array($table);
$signupcredit=$row['set_value'];


if(!empty($email_enable_status))
{
$email_enable_status1="yes";
}
if(empty($email_enable_status))
{
$email_enable_status1="no";
}


   $sql="insert into member_details(intro_id , date_of_birth,email , first_name , last_name , html_profile , ";
   $sql.="address , city , state , pin_code , country , home_phone , work_phone , status , date_of_registration, ";
   $sql.="member_account , ip_address , email_enable_status , original_account, bid_num)";
   $sql.= "values('$introid','$dob','$reemail','$first','$last','$html_profile','$address','$city',";
   $sql.="'$state','$code','$country','$primary','$secondary','Active','$date_of_registration', ";
   $sql.="$temp_account,'$ip','$email_enable_status1','$member','$signupcredit')"; 
   $res=mysql_query($sql);
   if($res)
   {
   $user_id=mysql_insert_id();
$today = date('Y-m-d H:i:s');
$addfundssql = "insert into addfunds(member_id,fund_date,fund_amount) values($memberid,'$today',$signupcredit)";
$addresult = mysql_query($addfundssql);

    echo '<meta http-equiv="refresh" content="0;url=account_reg.php?user_id='.$user_id.'">';
   echo "$lang_675 <a href=account_reg?user_id=$user_id>$lang_117</a>";
   exit();
   }
   else
   {
   $err_dup_email=$err_15;
    $err_flag=1;
   }
   } 
} //step==1
$state_sql="select * from site_states where country_id=38 ";
$state_res=mysql_query($state_sql);
$country_sql="select * from site_countries";
$country_res=mysql_query($country_sql);

$fee_query="select * from site_fees where status='Active'";
$fee_table=mysql_query($fee_query);


?>
<? require'themes/user_reg.tpl'; ?>
<? require'templates/'.$tfold.'/footer.php'; ?></td></tr>
</table>
</body>
</html>
