<?php
/*
+--------------------------------------------------------+
| O-BLOG - PHP Blog System                               |
| Copyright (c) 2004 phpBlog.CN                          |
| Support : http://www.phpBlog.cn                        |
| Author : ShiShiRui (shishirui@163.com)                 |
|--------------------------------------------------------+
*/
error_reporting(7);
require('global.php');

header("content-type:text/html; charset=$charset");
if ($_GET['frame'] == "all")
{
	echo "<script>if (window.location != top.location) top.location=window.location;</script>";
	$title = "O-blog $version 控制面板";
	include("temp/admin_frame.php");
	loginsucceed($username);
	die;
}

if($_POST['username'] && $_POST['password'])
{
	$user = $DB->query("SELECT `username`, `password`, `id` FROM `".$mysql_prefix."admin` WHERE `username` = '".trim($_POST['username'])."'");
	$userRe = $DB->fetch_array($user);
	$userR = $userRe['username'];
	$passR = $userRe['password'];
	$idR = $userRe['id'];
	$username=addslashes(trim($_POST['username']));
	$password=addslashes(trim($_POST['password']));

	//判断用户名和密码
	if($userR == $username && $passR == md5($password))
	{
		mkcookie("ob_login","o-blog");
		mkcookie("ob_userid",$idR);
		mkcookie("ob_password",$passR);
		mkcookie("ob_ip",md5(getip()));
		$FORM->ob_exit("登录成功！","index.php?frame=all","","点击这里进入控制面板",0);
	}
	else
	{
		sleep(10);	  //防止暴力破解
		loginfaile($username);
		$FORM->ob_exit("抱歉，用户名或密码错误","index.php");
	}
}
else //login form
{
	$title = 'O-blog '.$version.' 管理员登录';
	include("temp/header.php");
	include("temp/login.php");
	include("temp/footer.php");
}

?>