add new Westdc\Db\Db class (a extention for Zend_DB adapter),fixed errors
in Account module
This commit is contained in:
parent
f9dbc3e3db
commit
498d3c2f55
|
@ -87,6 +87,7 @@ class AuthenticationService
|
|||
|
||||
public function response($e)
|
||||
{
|
||||
|
||||
//用户已经登录的情况
|
||||
if(view::User() !== false)
|
||||
{
|
||||
|
@ -99,6 +100,7 @@ class AuthenticationService
|
|||
{
|
||||
|
||||
}else{
|
||||
|
||||
$response = $e->getResponse();
|
||||
$response->setStatusCode(404);
|
||||
$response->sendHeaders();
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
namespace Westdc\Db;
|
||||
|
||||
use Westdc\Service\AbstractServiceManager;
|
||||
use Zend\Db\Adapter\Adapter;
|
||||
|
||||
class Db extends AbstractServiceManager
|
||||
{
|
||||
private $db;
|
||||
|
||||
function __construct(&$db,$param = array())
|
||||
{
|
||||
$configService = $this->getServiceManager()->get('Config');
|
||||
$config_local = $configService->get("local.php");
|
||||
|
||||
if(is_array($param) && count($param)>0)
|
||||
{
|
||||
$this->db = new Adapter($param);
|
||||
}else{
|
||||
$this->db = new Adapter(array(
|
||||
'driver' => $config_local->db->driver,
|
||||
'hostname' => $config_local->db->hostname,
|
||||
'database' => $config_local->db->database,
|
||||
'username' => $config_local->db->username,
|
||||
'password' => $config_local->db->password
|
||||
));
|
||||
}
|
||||
|
||||
$db = $this->db;
|
||||
}
|
||||
|
||||
public function getAdapter()
|
||||
{
|
||||
return $this->db;
|
||||
}
|
||||
|
||||
public function setConfig()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -4,10 +4,12 @@ namespace Westdc\Member;
|
|||
use Westdc\EventModel\AbstractEventManager;
|
||||
use Zend\Authentication\AuthenticationService;
|
||||
use Zend\Authentication\Storage\Session as SessionStorage;
|
||||
use Zend\Authentication\Adapter\DbTable;
|
||||
use Westdc\Helpers\Assist as view;
|
||||
use Westdc\Helpers\Config;
|
||||
use Westdc\Helpers\Dbh as dbh;
|
||||
use Westdc\Db\PDO as Db;
|
||||
use Westdc\Db\Pdo as Db;
|
||||
use Westdc\Db\Db as Zend_Db;
|
||||
use Westdc\Mail\Mail;
|
||||
use Westdc\User\Member;
|
||||
|
||||
|
@ -144,29 +146,29 @@ class Account extends AbstractEventManager
|
|||
$auth->setStorage(new SessionStorage($this->config->session_namespace));
|
||||
|
||||
new Zend_Db($dbAdapter);
|
||||
|
||||
$authAdapter = new \Zend\Authentication\Adapter\DbTable(
|
||||
|
||||
$authAdapter = new DbTable(
|
||||
$dbAdapter,
|
||||
$this->memberTable,
|
||||
$this->FieldUsername,
|
||||
$this->FieldPasword
|
||||
'users',
|
||||
'username',
|
||||
'password'
|
||||
);
|
||||
|
||||
if($md5 === true)
|
||||
{
|
||||
$password = md5($data[$this->FieldPasword]);
|
||||
$password = md5($data['password']);
|
||||
}else{
|
||||
$password = $data[$this->FieldPasword];
|
||||
$password = $data['password'];
|
||||
}
|
||||
|
||||
$authAdapter
|
||||
->setIdentity($data[$this->FieldUsername])
|
||||
->setIdentity($data['username'])
|
||||
->setCredential($password)
|
||||
;
|
||||
|
||||
$result = $authAdapter->authenticate();
|
||||
|
||||
$user = $authAdapter->getResultRowObject(null,array($this->FieldPasword));
|
||||
$user = $authAdapter->getResultRowObject(null,array('password'));
|
||||
|
||||
if(!$result->isValid())
|
||||
{
|
||||
|
|
|
@ -44,7 +44,8 @@ class Config {
|
|||
|
||||
if($configFileExt == "php")
|
||||
{
|
||||
return new Zend_Config(include_once($configFile));
|
||||
$config_arr = include $configFile;
|
||||
return new Zend_Config($config_arr);
|
||||
}
|
||||
|
||||
if($configFileExt == 'ini')
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
namespace Westdc\Service\ServiceAgent;
|
||||
|
||||
class Gravatar{
|
||||
|
||||
function Get( $email, $size='' ) {
|
||||
|
||||
$default = "http://www.msgfm.com/static/img/gCons/agent.png";
|
||||
|
||||
if(empty($size))
|
||||
{
|
||||
$size = 40;
|
||||
}
|
||||
|
||||
$url = "http://www.gravatar.com/avatar/" . md5( strtolower( trim( $email ) ) ) . "?d=" . urlencode( $default ) . "&s=" . $size;
|
||||
|
||||
return $url;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue