请大家写个支持登录返回的PHP登陆程序!

leesjim 2008-04-17 11:18:23
如题 ,作为参考~~谢谢·
...全文
33 点赞 收藏 2
写回复
2 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
ten789 2008-04-18
private function status(Zend_Controller_Request_Abstract $request)
{
if ($this->auth->hasIdentity()){
$group = $this->auth->getIdentity()->group;
}else {
$group = 'Guest';
}
if (!$this->acl->isAllowed($group, $request->getModuleName(), $request->getControllerName())){
$sessionAuth = new Zend_Session_Namespace('auth');
$sessionAuth->lastUrl = $_SERVER['REQUEST_URI'];
if ($this->auth->hasIdentity()){
$request->setModuleName($this->noPriv['module']);
$request->setControllerName($this->noPriv['controller']);
$request->setActionName($this->noPriv['action']);
}else {
$request->setModuleName($this->noAuth['module']);
$request->setControllerName($this->noAuth['controller']);
$request->setActionName($this->noAuth['action']);
}
}
}
public function isloginAction()
{
$user = $this->getRequest()->getParam('user');
if (!Zend_Validate::is($user, 'Alnum',array(true))){
$this->view->msg = 'userError';
$this->loginAction();
return ;
}
$pass = $this->getRequest()->getParam('pass');
if (!Zend_Validate::is($pass, 'Alnum', array(true))){
$this->view->msg = 'passError';
$this->loginAction();
return ;
}
$auth = Tw_Registry::get('auth');
$authAdapter = new Zend_Auth_Adapter_DbTable(Tw_Registry::get('db'));
$authAdapter->setTableName('user');
$authAdapter->setIdentityColumn('user');
$authAdapter->setCredentialColumn('pass');
$authAdapter->setIdentity($user);
$authAdapter->setCredential(md5($pass));
$authRestule = $authAdapter->authenticate($auth);
if ($authRestule->isValid()){
$auth->getStorage()->write($authAdapter->getResultRowObject(array('user','pass','group')));
$sessionAuth = new Zend_Session_Namespace('auth');
$this->view->Url = $sessionAuth->lastUrl;
$this->view->msg = 'loginOK';
$html = $this->view->render('Auth/GoUrl.tpl.html');
}else {
$this->view->msg = 'userOrPassError';
$this->loginAction();
return ;
}
echo $html;
}
回复
ten789 2008-04-18
private function status(Zend_Controller_Request_Abstract $request)
{
if ($this->auth->hasIdentity()){
$group = $this->auth->getIdentity()->group;
}else {
$group = 'Guest';
}
if (!$this->acl->isAllowed($group, $request->getModuleName(), $request->getControllerName())){
$sessionAuth = new Zend_Session_Namespace('auth');
$sessionAuth->lastUrl = $_SERVER['REQUEST_URI'];
if ($this->auth->hasIdentity()){
$request->setModuleName($this->noPriv['module']);
$request->setControllerName($this->noPriv['controller']);
$request->setActionName($this->noPriv['action']);
}else {
$request->setModuleName($this->noAuth['module']);
$request->setControllerName($this->noAuth['controller']);
$request->setActionName($this->noAuth['action']);
}
}
}
public function isloginAction()
{
$user = $this->getRequest()->getParam('user');
if (!Zend_Validate::is($user, 'Alnum',array(true))){
$this->view->msg = 'userError';
$this->loginAction();
return ;
}
$pass = $this->getRequest()->getParam('pass');
if (!Zend_Validate::is($pass, 'Alnum', array(true))){
$this->view->msg = 'passError';
$this->loginAction();
return ;
}
$auth = Tw_Registry::get('auth');
$authAdapter = new Zend_Auth_Adapter_DbTable(Tw_Registry::get('db'));
$authAdapter->setTableName('user');
$authAdapter->setIdentityColumn('user');
$authAdapter->setCredentialColumn('pass');
$authAdapter->setIdentity($user);
$authAdapter->setCredential(md5($pass));
$authRestule = $authAdapter->authenticate($auth);
if ($authRestule->isValid()){
$auth->getStorage()->write($authAdapter->getResultRowObject(array('user','pass','group')));
$sessionAuth = new Zend_Session_Namespace('auth');
$this->view->Url = $sessionAuth->lastUrl;
$this->view->msg = 'loginOK';
$html = $this->view->render('Auth/GoUrl.tpl.html');
}else {
$this->view->msg = 'userOrPassError';
$this->loginAction();
return ;
}
echo $html;
}
回复
相关推荐
发帖
基础编程
创建于2007-09-28

2.1w+

社区成员

从PHP安装配置,PHP入门,PHP基础到PHP应用
申请成为版主
帖子事件
创建了帖子
2008-04-17 11:18
社区公告
暂无公告