Exemplo n.º 1
0
    protected function doLogin($username, $pwd)
    {
        
        if(!$username || !$pwd)
        {
            return errorByCode(1);
        }
        $mod = M('admin');
        $where = array('name'=>$username,'pwd'=>$pwd);
        $row = $mod->where($where)->find();
        if(!$row && !is_array($row))
        {
            ///var_dump($row,$mod->getlastsql());exit();
            return errorByCode(14);
        }

        session('loginid',$row['id']);
        session('loginname',$row['name']);
        session('loginpwd',$row['pwd']);

    
        $this->loginInfo = $row;
        $this->initLoginInfo();

        return successByData();
    }
Exemplo n.º 2
0
function out($data=array(),$code=0,$msg='',$type=0,$outType='',$out=true)
{
    if(!$outType)
    {
        $outType = I('request.t',C('DEFAULT_RESPONSE_TYPE'),'trim');
    }
    
    $result = array();
    if($code != 0)
    {
        $result = errorByCode($code,$msg,$type);
        $result[C('RESPONSE_KEY_DATA')] = $data;
    }
    else
    {
        $result = successByData($data);
    }
    outResult($result,$outType,$out);
}