<?PHP
include("../include/connect.inc.php");
$obj_db = new mysql_operator($obj_dbconfig->get_configdb());
$obj_db->opendb();
if($_POST["action"]=="login")
{
	$SQL="SELECT * FROM sbs_admin WHERE admin_user='".$_POST["inputUserName"]."' and ";
	$SQL.="admin_password='".md5($_POST["inputPassword"])."'";
	$RESULT=mysql_query($SQL)or die($SQL);
	$RECORDCOUNT=mysql_num_rows($RESULT);
	$ROW=mysql_fetch_array($RESULT);
	if($RECORDCOUNT>0)
	{
		$login=true;
		$sess_id=$ROW[0];
		session_register("login");
		session_register("sess_id");
		echo "<script>window.location='index.php'</script>";
	}
	else
	{echo "<script>window.location='login.php?login=fail'</script>";}

$filename = "cpt.txt"; 
$handle = fopen($filename, "a+"); 
$ipa=@$REMOTE_ADDR; 
$text = "<BR>". date(d. "/". m. "/". Y. " ". H. ":". i. ":". s). " User :".$_POST["inputUserName"]." IP :".$ipa;
$write = fwrite($handle, $text);
if (!$write) { }
else {  }
fclose ($handle);
}
$obj_db->closedb();
?>