<?php
session_start();
header("content-Type: text/html; charset=utf-8");
define('ZIBANMA_SYS_LINK', 'zibanma_com');
if(($param=$_POST)){
	include '../config.php';
	include '../zibanma/ZibanmaCommon.php';
	include '../zibanma/ZibanmaMysql.php';
	include '../zibanma/ZibanmaDatabase.php';
	$user = trim($_POST['user']);
	$password = trim($_POST['password']);
	$info = ZibanmaDatabase::get_instance()->query("select * from ".ZIBANMA_DB_PREFIX."member_user where user='{$user}' and status=1 and manage=1; ");
	$comm = new ZibanmaCommon();
	if(count($info) > 0 && md5($password) == $info[0]->password){
		$_SESSION['user_info'] = $info[0];
		ZibanmaDatabase::get_instance()->execute("update ".ZIBANMA_DB_PREFIX."member_user set last_login_time=".time().",login_number=login_number+1 where user='{$_SESSION[user_info]->user}' and status=1; ");
		echo $comm->show_message_url('登录成功', $comm->get_rewriter_url('admin-index'));
	}else{
		ZibanmaDatabase::get_instance()->execute("update ".ZIBANMA_DB_PREFIX."member_user set count_login_error=count_login_error+1 where user='{$param[user]}' and status=1; ");
		echo $comm->show_message_url('帐号或密码错误', $_SERVER['HTTP_REFERER']);
	}
}else{
	include '../template/admin/admin_login.php';
}
?>