<?php session_start();  //Developed by ITechScripts

require 'include/configurations.php'; // ITECHBIDS Configuration File

require 'include/itechbids.php'; // Server compatibility Patch

require 'include/argvs.php'; // Server compatibility Patch

$mode=$_POST[mode];

$user=$_POST['txtUsername'];

$pass=$_POST['txtPassword'];

$pass=seccheck($pass);

$rand_no=$_SESSION[rand_no];

$turing_no=$_POST['code'];

$ip_address=$_SERVER['REMOTE_ADDR'];

$url=$_POST['url'];

$seccode=$_POST['seccode'];

$productid=$_POST['productid'];

 if($mode=="check")

{

$url=$_GET['url'];

$productid=$_GET['productid'];



$sqlsus="select user_name,password,last_login_date from member_details where user_name='$user' and status='suspended' ";

$resultsus=mysql_query($sqlsus);

$totsus=mysql_num_rows($resultsus);

	if($totsus>0)

{

$msg="Your account has been suspended";

include 'suspended.php';

exit();

}

$sql="select user_name,password,last_login_date from member_details where user_name='$user' ";

$result=mysql_query($sql);

$totsus=mysql_fetch_array($result);

$tot=mysql_num_rows($result);

	if($tot==0)

	{ 

      $msg=$err_53;

	}

if($totsus[status]=="suspended")

{

$msg="Your account has been suspended";

}

    else 

	{

	$sql1="select user_name,password,user_id,last_login_date,ip_address from member_details where user_name='$user' and password='$pass'";

      $result1=mysql_query($sql1);

	if(mysql_num_rows($result1)==0)

	{

      $msg=$err_52; 

	}

	else

	{

	$ip_block=$result1[ip_address];

	$ip_sql="select * from blocked_ip where blocked_ip ='$ip_block'";

	$ip_res=mysql_query($ip_sql);

	$ip_rows=mysql_num_rows($ip_res);

	if($ip_rows==0)

	{

      $sql2="select user_name,password,user_id,last_login_date from member_details where user_name='$user' and password='$pass' and verified='yes' ";

	 $result2=mysql_query($sql2);

	 $chk=mysql_fetch_array($result2);

	 if (mysql_num_rows($result2) == 0) 

	 {

      $msg=$err_79;

	}

    	else

	{

$sql3="select user_name,password,user_id,last_login_date from member_details where user_name='$user' and password='$pass' and approved='yes'";

	 $result3=mysql_query($sql3);

	 $chk=mysql_fetch_array($result3);



	 if (mysql_num_rows($result3) == 0) 

    {

$msg=$err_91;

		

    }

else {

$sql4="select user_name,password,user_id,last_login_date from member_details where user_name='$user' and password='$pass' and payment_status='yes' ";

	 $result4=mysql_query($sql4);

	 $chk=mysql_fetch_array($result4);



	 if (mysql_num_rows($result4) == 0) 

    {

$sql3="select * from member_details where user_name='$user' and password='$pass' ";

		$result3=mysql_query($sql3);

		$chk1=mysql_fetch_array($result3);

		$ip_address1=$chk1[ip_address];

		$ip_address2=$_SERVER['REMOTE_ADDR'];

		if (mysql_num_rows($result3)==0)

		{

		$msg="Invalid Username";

		}

		



	 $date=date("Y-m-d");

     $login=$chk['last_login_date'];

     $log_up="update member_details set onlinestatus='Online',last_login_date='$date' where user_id=".$chk[user_id];

	 $upsql=mysql_query($log_up);

       session_register('userid') ;

       session_register('username');  

	$_SESSION[userid]=$chk1[user_id];

	$_SESSION[username]=$chk1[user_name];

	echo '<meta http-equiv="refresh" content="0;url=member_plans.php?stats=login">';

	echo "<font size=+1 color=#003366>Loading....</font>";

	exit();

		

    }

else {

		$sql3="select * from member_details where user_name='$user' and password='$pass' ";

		$result3=mysql_query($sql3);

		$chk1=mysql_fetch_array($result3);

		$ip_address1=$chk1[ip_address];

		$ip_address2=$_SERVER['REMOTE_ADDR'];

		if (mysql_num_rows($result3)==0)

		{

		$msg="Invalid Username";

		}

		



	 $date=date("Y-m-d");

     $login=$chk['last_login_date'];

     $log_up="update member_details set onlinestatus='Online',last_login_date='$date' where user_id=".$chk[user_id];

	 $upsql=mysql_query($log_up);

	 if(isset($url))

	{

       session_register('userid') ;

       session_register('username');  

	$_SESSION[userid]=$chk[user_id];

	$_SESSION[username]=$chk[user_name];

	echo '<meta http-equiv="refresh" content="0;url='.$url.'?productid='.$productid.'">';

	echo "<font size=+1 color=#003366>Loading....</font>";

	exit();

	}

	else

	 {

     $_SESSION[userid]=$chk[user_id];

	 $_SESSION[username]=$chk[user_name];

	 echo '<meta http-equiv="refresh" content="0;url=myauction.php?user_login='.$login.'">';

     echo "<font size=+1 color=#003366>Loading....</font>";

	exit();

	} 

	}}} 

     }

	 else

	 {

	 	$msg="Sorry ".$user." your id was blocked" ;

	

	 

	 }

	 }

	 }

	 }

?>

<? require 'themes/signin.tpl';?>

</body>

</html>

<script language="JavaScript">



function focus1()

{

document.SignInForm.txtCode.focus();

}

</script>