<?php
/***
*
*@package binzcms
*@version $id:ModAdminIndexClass.php, v 1.0
*@author 斌子
*@Sat Jan 10 00:41:21 CST 2009
*@copyright (c) 2009-2010 binzcms
*
*/
if(!defined("BINZCMS")) {
	die("hacking");
}
/**
 *
 * ModAdminIndexClass
 * 后台首页应用类
 * 
 */
class ModAdminIndexClass extends BaseClass {
	/**
	 * __construct
	 *
	 * 构造函数
	 * @access  public（权限）
	 */
	public function __construct($act) {
		parent::__construct($act);
	}
	/**
	 * mod_index_sys_info
	 *
	 * 得到系统信息
	 * @access  public（权限）
	 * 
	 * @return  array	系统信息
	 */
	public function mod_index_sys_info() {
		$cms_sys_info	= array(
		'php_ver'		=>PHP_VERSION,
		'web_server'	=>$_SERVER['SERVER_SOFTWARE'],
		'safe_state'	=>(boolean) ini_get('safe_mode') ?  $this->binz_tpl->var_all['main_safe_state_open']:$this->binz_tpl->var_all['main_safe_state_close'],
		'mysql_ver'		=>$this->binz_db->sql_version(),
		'time_zone'		=>@date_default_timezone_get(),
		'upload_max'	=>ini_get('upload_max_filesize'),
		'cms_ver'		=>CMS_VERSION,
		'socket_state'	=>function_exists('fsockopen') ? $this->binz_tpl->var_all['main_socket_yes'] : $this->binz_tpl->var_all['main_socket_no']);

		return $cms_sys_info;
	}
	/**
	 * mod_admin_login
	 *
	 * 管理员登录操作
	 * @access  public（权限）
	 * 
	 */
	public function mod_admin_login() {

		/*管理员用户名判断*/
		$admin_info		= array();
		$admin_sql		= "SELECT * FROM #binz#admin
							WHERE admin_name='".trim($_POST['username'])."'";
		$admin_info		= $this->binz_db->set_select_sql($admin_sql,0);
		if($admin_info['admin_name'] == '') {
			return 2;		//用户名错误返回信息
		}

		/*管理员密码判断*/
		if(substr(md5(trim($_POST['password'])),0,16) != $admin_info['admin_passwd']) {
			return 3;		//密码错误返回信息
		}
		/*验证码判断*/
		if(strtolower(trim($_POST['login_code'])) != $_SESSION['binz_code']) {
			return 4;		//验证码错误返回信息
		}

		/*用户验证完毕，进行session赋值*/
		$_SESSION['admin_id']		= $admin_info['admin_id'];
		$_SESSION['admin_name']		= $admin_info['admin_name'];
		$_SESSION['admin_power']	= explode(',',$admin_info['admin_power']);

		/*更新最后登录时间*/
		$this->binz_db->set_update_sql('#binz#admin',array('admin_login_time'=>time()),array('field'=>'admin_id','value'=>intval($admin_info['admin_id'])));

		return 1;
	}
	/**
	 * mod_admin_out
	 *
	 * 管理员退出操作
	 * @access  public（权限）
	 * 
	 * @return  bool
	 */
	public function mod_admin_out() {

		$_SESSION['admin_id']		= '';
		$_SESSION['admin_name']		= '';
		$_SESSION['admin_power']	= '';

		return true;
	}
	/**
	 * __destruct
	 *
	 * 析构函数
	 * @access  public（权限）
	 */
	public function __destruct() {

	}
}
?>