<?php
// +----------------------------------------------------------------------
// | YZCMS <XueHen CMS>
// +----------------------------------------------------------------------
// | Copyright (c) http://www.xuehen.org
// +----------------------------------------------------------------------
// | Author XueHen <490860758@qq.com>
// +----------------------------------------------------------------------
namespace Admin\Controller;


class IndexController extends BaseController{
    function index(){
	
        $this->display();
    }
	
	function delFile($dirName){
		if($handle = opendir($dirName)){
			 while($item = readdir($handle)){
				 if($item != "." && $item != ".." && $item != 'index.html'){
					 if(is_dir("$dirName/$item")){
						 $this->delFile("$dirName/$item");
					  }else{
						  unlink("$dirName/$item");
					  }
				}
		      }
		}
		closedir( $handle );  
	}
	
	function clear(){
		
		$this->delFile(CACHE_PATH);
		$this->delFile(LOG_PATH);
		$this->delFile(DATA_PATH.'_fields/');
		unlink(RUNTIME_PATH.'common~runtime.php');
		$this->success('清理成功','home');
	}
	
	function home(){
		$this->article = M('content')->where(array('type'=>'article'))->count();
		$this->acat = M('category')->where(array('type'=>'article'))->count();
		$this->product = M('content')->where(array('type'=>'product'))->count();
		$this->pcat = M('category')->where(array('type'=>'product'))->count();
		$this->page = M('category')->where(array('type'=>'page'))->count();
		$this->book = M('book')->count();
		$this->loginTime = M('master')->where(array('user'=>session('AdminUser')))->getField('lasttime');
		$this->display();
    }
}