<?php
/**
 * @version        Somao_Search X1.0 9:23 2012-1-1 Somao $
 * @package        Somao_Search.Site
 * @copyright      Copyright (c) 2009 - 2012, Somao, Inc.
 * @license        http://www.somao123.com/
 * @link           http://www.somao.cc/
 */
function checklogin( )
{
		global $db;
		$adminname = htmlspecialchars($_POST['adminname']);
		$password= md5(htmlspecialchars($_POST['password']));
		$admins = $db->query( "select * from ve123_admin where adminname='".$adminname."' and password='{$password}'" );
		$rows = $db->num_rows($admins);
		if ( 0 < $rows )
		{
				$rowadmin = $db->fetch_array( $admins );
				$adminloginlog = array(
						"lastloginip" => $rowadmin['loginip'],
						"loginip" => ip( ),
						"lastlogintime" => $rowadmin['logintime'],
						"logintime" => date( "Y-y-d H:i:s" )
				);
				$db->update( "ve123_admin", $adminloginlog, "admin_id=".$rowadmin['admin_id'] );
				setcookie( "adminname", $adminname );
				header( "location:index.php?somao=ok" );
		}
		else
		{
				jsalert( "用户名或密码错误!", "lg.php" );
		}
}

function logou( )
{
		setcookie( "adminname", "", time( ) - 3600 );
		header( "location:login.php" );
}

require( "../../global.php" );
require_once( "global_func.php" );
$action = $_GET['action'];
switch ( $action )
{
case "checklogin" :
		checklogin( );
		break;
case "logou" :
		logou( );
} 
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=gb2312\" /><title>搜猫蜘蛛X系列蜘蛛（优化版） V1.0- 整合Sphinx全文检索系统</title><link rel=\"stylesheet\" href=\"xp.css\" type=\"text/css\">\r\n</style>\r\n</head>\r\n\r\n<body>\r\n<table width=\"300\" border=\"1\" align=\"center\" cellpadding=\"5\" cellspacing=\"0\" bordercolordark=\"#FFFFFF\" bordercolor=\"888888\" style=\"margin-top:100px;\">\r\n<form id=\"adminloginform\" name=\"adminloginform\" method=\"post\" action=\"?action=checklogin\">\r\n  <tr>\r\n    <th colspan=\"2\" class=\"tbtitle\">搜猫蜘蛛X系列蜘蛛（优化版） V1.0</th>\r\n  </tr>\r\n  <tr>\r\n    <td width=\"100\">登录名称:</td>\r\n    <td><input name=\"adminname\" type=\"text\" style=\"width:150px;\" value=\"\"/></td>\r\n  </tr>\r\n  <tr>\r\n    <td>登录密码:</td>\r\n    <td><input name=\"password\" type=\"password\" style=\"width:150px;\" value=\"\"/></td>\r\n  </tr>\r\n  <tr>\r\n    <td>&nbsp;</td>\r\n    <td>\r\n      <input type=\"submit\" name=\"Submit\" value=\"提交\" />    </td>\r\n  </tr></form>\r\n</table>\r\n<script language=\"javascript\">\r\nif (top.location != location) top.location.href = location.href;\r\nself.moveTo(0,0);\r\nself.resizeTo(screen.availWidth,screen.availHeight);\r\nadminloginform.adminname.focus();\r\n</script>\r\n";
foothtml( );
echo "</body>\r\n</html>\r\n";
?>
