<?php
if(IN_IQQOL){
if(!isset($_COOKIE['iQQol_Administrator'])) {
if(!isset($_POST['submit'])){
$style->display('admin/index.html');
    }
else{
$spuser=$_POST['spuser'];
$sppass=iqqol_member::sp_auth($_POST['sppass']);
    if(!isset($_POST['spuser'])){
        $style->assign("state",'请输入管理员账号');
        $style->display('admin/index.html');exit();}

        else if(!isset($_POST['rand'])){
        $style->assign("state",'请输入验证码');
        $style->display('admin/index.html');exit();}

        else if(!isset($_POST['sppass'])){
        $style->assign("state",'请输入管理员密码');
        $style->display('admin/index.html');exit();}

        else if($_POST['spuser']!=$spuser){
        $style->assign("state",'管理员账号错误');
        $style->display('admin/index.html');exit();}

        else if($_POST['rand']!=$_SESSION['rand']){
        $style->assign("state",'验证码错误');
        $style->display('admin/index.html');exit();}

        else if($spuser=='iQQol Administrator'){
            if($sppass!=IQQOL_SPPASS){
                $style->assign("state",'管理员密码错误');
                $style->display('admin/index.html');exit();
            }
            else{
                setcookie("iQQol_Administrator",IQQOL_SPPASS,time()+3600);
                echo '<script>location.href="admin.php?action=home"</script>';
            }
        }

        else if($spuser!='iQQol_Administrator'){
            include IQQOL_FILE_ROOT.'/admin/members/super_user.php';
            if(!array_key_exists($spuser,$sp_user)){
                $style->assign("state",'该管理员不存在');
                $style->display('admin/index.html');exit();
            }
            if(!$_POST['sppass']==$sp_user[$spuser]){
                $style->assign("state",'管理员密码错误');
                $style->display('admin/index.html');exit();
            }
            else{
                setcookie("iQQol_Administrator",IQQOL_SPPASS,time()+3600);
                echo '<script>location.href="admin.php?action=home"</script>';
            }
        }
}
}
else{
echo '<script>location.href="admin.php?action=home"</script>';
}
}
?>