<?php
/**
 * 管理员表模型
 * @copyright reginx.com
 * $Id: admin.tab.php 7 2013-01-24 00:30:29Z reginx $
 */ 
class admin_tab extends tab {
    
    public $filter = array(
        'passwd'    => array('filter' , 'code')
    );
    
    /**
     * 验证规则
     *
     * @var unknown_type
     */
    public $validate = array(
        array(
            'key'       => 'uname',
            'type'      => 0,
            'rule'      => 'require',
            'msg'       => '请输入帐号!'
        ),
        array(
            'key'       => 'passwd',
            'type'      => 0,
            'rule'      => 'passwd',
            'msg'       => '请输入密码!'
        )
    );
    
    /**
     * 获取 md5 附加串
     *
     * @return string
     */
    public function getsalt(){
        return substr(REQUEST_TIME , -4);
    }
    
    /**
     * 检测登录
     * @abstract 示例没有使用salt附加串 , 可以考虑扩展chklogin方法
     * @return mixed
     */
    public function chklogin(){
        $row = $this->where("uname = '{$this->data['uname']}'")->where("passwd = '".md5($this->data['passwd'])."'")->get();
        return $row ? $row : false;
    }
}
?>