<?php
if(!defined('IN_ADMIN')) exit('Access Denied');

@set_time_limit(0);
require_once TM_ROOT.'include/login.class.php';
$login = new login();
if(!isset($action)) $action = 'login';
switch ($action){
	case 'login':
            if($dosubmit){  	
				if(!$login->admin_login($username,$password)) {
					showmessage($login->msg(),'goback');
				}
        		$_SESSION['name'] = $username;
        		$_SESSION['admin'] = 'NewsTeng';
				showmessage('登陆成功！', '/admin.php');
            }else{   
                include admin_tpl('login');
            }
	break;

    case 'logout':
    	if($_SESSION["admin"]!="NewsTeng")showmessage('请登陆', SCRIPT_NAME.'?file=login');
    	$login->logout(); 
		showmessage('退出成功！', '/admin.php');
	break;
}
?>