2011-12-28 06:37:46 +00:00
|
|
|
<?php
|
2013-11-11 10:04:03 +00:00
|
|
|
use Mail\Mail;
|
2014-04-21 08:10:45 +00:00
|
|
|
use Open\Client;
|
2014-12-12 06:52:16 +00:00
|
|
|
use Open\OAuth2;
|
2014-04-21 08:10:45 +00:00
|
|
|
use Users\Account;
|
|
|
|
use Users\Member;
|
|
|
|
use Helpers\Captcha;
|
|
|
|
use Helpers\View as view;
|
2013-11-11 10:04:03 +00:00
|
|
|
|
2011-12-28 06:37:46 +00:00
|
|
|
class AccountController extends Zend_Controller_Action
|
|
|
|
{
|
2013-03-15 04:16:07 +00:00
|
|
|
function preDispatch()
|
|
|
|
{
|
|
|
|
$this->view->config = Zend_Registry::get('config');
|
|
|
|
$this->_request->setParam('return', $this->_request->getServer('REQUEST_URI'));
|
|
|
|
$this->db = Zend_Registry::get('db');
|
|
|
|
$this->view->messages = $this->messenger->getMessages();
|
|
|
|
$this->view->theme = new Theme();
|
|
|
|
}
|
|
|
|
|
2011-12-28 06:37:46 +00:00
|
|
|
function indexAction()
|
|
|
|
{
|
2013-03-15 04:16:07 +00:00
|
|
|
$this->view->pageID = "account-index";
|
|
|
|
|
|
|
|
include_once("Users.php");
|
|
|
|
$usr = new Users($this->db);
|
|
|
|
|
|
|
|
$auth = Zend_Auth::getInstance();
|
|
|
|
if($auth->hasIdentity())
|
|
|
|
{
|
|
|
|
$user = $auth->getIdentity();
|
|
|
|
$uid = $user->id;
|
|
|
|
}
|
|
|
|
|
|
|
|
include_once("Avatar.php");
|
|
|
|
$avatar = new Avatar();
|
|
|
|
$this->view->avatar = $avatar->Get($user->email,140);
|
|
|
|
|
|
|
|
$this->view->info = $usr->getUserInfo($uid);
|
|
|
|
}
|
|
|
|
|
|
|
|
function editAction()
|
|
|
|
{
|
|
|
|
$this->view->pageID = "account-edit";
|
|
|
|
|
|
|
|
include_once("Users.php");
|
|
|
|
$usr = new Users($this->db);
|
|
|
|
|
|
|
|
$auth = Zend_Auth::getInstance();
|
|
|
|
if($auth->hasIdentity())
|
|
|
|
{
|
|
|
|
$user = $auth->getIdentity();
|
|
|
|
$uid = $user->id;
|
|
|
|
}
|
|
|
|
|
|
|
|
include_once("Avatar.php");
|
|
|
|
$avatar = new Avatar();
|
|
|
|
$this->view->avatar = $avatar->Get($user->email,140);
|
|
|
|
|
|
|
|
$this->view->projectType = array(
|
2014-03-03 07:00:54 +00:00
|
|
|
"None" => '',
|
|
|
|
"National Funding" => "National Funding",
|
|
|
|
"Thesis or Dissertation"=>"Thesis or Dissertation",
|
|
|
|
"Others" => "Others"
|
2013-03-15 04:16:07 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
$submit = $this->_getParam('submit');
|
|
|
|
|
|
|
|
if(!empty($submit))
|
|
|
|
{
|
|
|
|
$data = $this->AccountEditParamFilter();
|
|
|
|
|
|
|
|
if($this->db->update("users",$data,"id=$uid"))
|
|
|
|
{
|
|
|
|
$this->view->AlertType = "alert-success";
|
2014-03-03 07:00:54 +00:00
|
|
|
$this->view->msg = "Update success.";
|
2013-03-15 04:16:07 +00:00
|
|
|
$this->view->jump_url = "/account/edit";
|
|
|
|
return true;
|
|
|
|
}else{
|
|
|
|
$this->view->AlertType = "alert-error";
|
2014-03-03 07:00:54 +00:00
|
|
|
$this->view->error = "Update failure.";
|
2013-03-15 04:16:07 +00:00
|
|
|
$this->view->info = $data;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
$this->view->info = $usr->getUserInfo($uid);
|
|
|
|
}
|
2011-12-28 06:37:46 +00:00
|
|
|
}
|
2013-03-15 04:16:07 +00:00
|
|
|
|
|
|
|
function AccountEditParamFilter(){
|
|
|
|
$data = array();
|
|
|
|
$data['realname'] = substr(trim($this->_getParam('realname')),0,40);
|
|
|
|
$data['unit'] = substr(trim($this->_getParam('unit')),0,100);
|
|
|
|
$data['address'] = substr(trim($this->_getParam('address')),0,100);
|
|
|
|
$data['phone'] = substr(trim($this->_getParam('phone')),0,15);
|
|
|
|
$data['postcode'] = substr(trim($this->_getParam('postcode')),0,15);
|
|
|
|
$data['project_type'] = substr(trim($this->_getParam('project_type')),0,100);
|
|
|
|
$data['project_id'] = substr(trim($this->_getParam('project_id')),0,40);
|
|
|
|
$data['project_title'] = substr(trim($this->_getParam('project_title')),0,100);
|
|
|
|
$data['project'] = substr(trim($this->_getParam('project')),0,600);
|
|
|
|
|
|
|
|
foreach($data as $k=>$v)
|
|
|
|
{
|
|
|
|
$data[$k] = $this->StringFilter($v);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
|
|
|
|
function StringFilter($string){
|
|
|
|
$string = preg_replace ('/<[^>]*>/', ' ', $string);
|
|
|
|
return $string;
|
|
|
|
}
|
|
|
|
|
|
|
|
function secureAction()
|
|
|
|
{
|
|
|
|
$this->view->pageID = "account-secure";
|
|
|
|
|
|
|
|
include_once("Users.php");
|
|
|
|
$usr = new Users($this->db);
|
|
|
|
|
|
|
|
$auth = Zend_Auth::getInstance();
|
|
|
|
if($auth->hasIdentity())
|
|
|
|
{
|
|
|
|
$user = $auth->getIdentity();
|
|
|
|
$uid = $user->id;
|
|
|
|
}
|
|
|
|
|
2013-05-09 03:53:27 +00:00
|
|
|
$opt = $this->_getParam('opt');
|
2013-03-15 04:16:07 +00:00
|
|
|
$submit = $this->_getParam('submit');
|
|
|
|
|
2013-05-09 03:53:27 +00:00
|
|
|
if(empty($opt))
|
2013-03-15 04:16:07 +00:00
|
|
|
{
|
2013-05-09 03:53:27 +00:00
|
|
|
$this->view->section = "password";
|
|
|
|
if(!empty($submit))
|
2013-03-15 04:16:07 +00:00
|
|
|
{
|
2013-05-09 03:53:27 +00:00
|
|
|
$data = $this->AccountSecureParamFilter();
|
|
|
|
|
|
|
|
$this->view->AlertType = "alert-error";
|
|
|
|
if(strlen($data['password'])>18 || strlen($data['new_password'])>18)
|
|
|
|
{
|
2014-03-03 07:00:54 +00:00
|
|
|
$this->view->error = view::Error("Password too long.");
|
2013-05-09 03:53:27 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if(strlen($data['new_password'])<=6 || strlen($data['new_password_confrim'])<=6)
|
|
|
|
{
|
2014-03-03 07:00:54 +00:00
|
|
|
$this->view->error = view::Error("Too short password. The min length is 6.");
|
2013-05-09 03:53:27 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
if(md5($data['new_password']) != md5($data['new_password_confrim']))
|
|
|
|
{
|
2014-03-03 07:00:54 +00:00
|
|
|
$this->view->error = view::Error("Twice password are not same.");
|
2013-05-09 03:53:27 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
$sql = "SELECT password FROM users WHERE id=$uid";
|
|
|
|
$rs = $this->db->query($sql);
|
|
|
|
$row = $rs->fetch();
|
|
|
|
|
|
|
|
if(md5($data['password']) != $row['password'])
|
|
|
|
{
|
2014-03-03 07:00:54 +00:00
|
|
|
$this->view->error = view::Error("The old password is wrong.");
|
2013-05-09 03:53:27 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
$data['password'] = md5($data['new_password']);
|
|
|
|
|
|
|
|
unset($data['new_password']);
|
|
|
|
unset($data['new_password_confrim']);
|
|
|
|
|
|
|
|
if($this->db->update("users",$data,"id=$uid"))
|
|
|
|
{
|
2014-03-03 07:00:54 +00:00
|
|
|
view::Post($this,array("content"=>'Update success.','url'=>'/account/secure'));
|
2013-05-09 03:53:27 +00:00
|
|
|
return true;
|
|
|
|
}else{
|
2014-03-03 07:00:54 +00:00
|
|
|
$this->view->error = view::Error("Update failure.");
|
2013-05-09 03:53:27 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
$this->view->info = $usr->getUserInfo($uid);
|
2013-03-15 04:16:07 +00:00
|
|
|
}
|
2013-05-09 03:53:27 +00:00
|
|
|
}//password
|
|
|
|
|
|
|
|
if($opt == "email")
|
|
|
|
{
|
|
|
|
$this->view->section = "email";
|
|
|
|
if(!empty($submit))
|
2013-03-15 04:16:07 +00:00
|
|
|
{
|
2013-05-09 03:53:27 +00:00
|
|
|
$email = $this->_getParam('email');
|
|
|
|
$password = $this->_getParam('password');
|
|
|
|
|
|
|
|
if(!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/i",$email))
|
|
|
|
{
|
2014-03-03 07:00:54 +00:00
|
|
|
$this->view->error = view::Error("Wrong email.");
|
2013-05-09 03:53:27 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
$sql = "SELECT password FROM users WHERE id=$uid";
|
|
|
|
$rs = $this->db->query($sql);
|
|
|
|
$row = $rs->fetch();
|
|
|
|
|
|
|
|
if(md5($password) != $row['password'])
|
|
|
|
{
|
2014-03-03 07:00:54 +00:00
|
|
|
$this->view->error = view::Error("The old password is wrong.");
|
2013-05-09 03:53:27 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
$data['email'] = $email;
|
|
|
|
|
|
|
|
if($this->db->update("users",$data,"id=$uid"))
|
|
|
|
{
|
2014-03-03 07:00:54 +00:00
|
|
|
view::Post($this,array("content"=>'Update success.','url'=>'/account/secure'));
|
2013-05-09 03:53:27 +00:00
|
|
|
return true;
|
|
|
|
}else{
|
2014-03-03 07:00:54 +00:00
|
|
|
$this->view->error = view::Error("Update failure.");
|
2013-05-09 03:53:27 +00:00
|
|
|
return true;
|
|
|
|
}
|
2013-03-15 04:16:07 +00:00
|
|
|
}else{
|
2013-05-09 03:53:27 +00:00
|
|
|
$this->view->info = $usr->getUserInfo($uid);
|
2013-03-15 04:16:07 +00:00
|
|
|
}
|
2013-05-09 03:53:27 +00:00
|
|
|
}//email
|
2013-03-15 04:16:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function AccountSecureParamFilter(){
|
|
|
|
$data = array();
|
|
|
|
$data['password'] = trim($this->_getParam('password'));
|
|
|
|
$data['new_password'] = trim($this->_getParam('new_password'));
|
|
|
|
$data['new_password_confrim'] = trim($this->_getParam('new_password_confrim'));
|
|
|
|
foreach($data as $k=>$v)
|
|
|
|
{
|
|
|
|
$data[$k] = $this->StringFilter($v);
|
|
|
|
}
|
|
|
|
return $data;
|
|
|
|
}
|
|
|
|
|
2011-12-28 06:37:46 +00:00
|
|
|
function init()
|
|
|
|
{
|
|
|
|
$this->messenger=$this->_helper->getHelper('FlashMessenger');
|
|
|
|
}
|
2013-03-15 04:16:07 +00:00
|
|
|
|
2011-12-28 06:37:46 +00:00
|
|
|
function postDispatch()
|
|
|
|
{
|
|
|
|
//$this->view->messages = $this->messenger->getMessages();
|
2013-03-15 04:16:07 +00:00
|
|
|
}
|
2011-12-28 06:37:46 +00:00
|
|
|
|
|
|
|
function registerAction()
|
|
|
|
{
|
2014-05-08 13:25:27 +00:00
|
|
|
$order = new \Order\Order();
|
2014-04-21 08:10:45 +00:00
|
|
|
|
2014-05-08 13:25:27 +00:00
|
|
|
$this->view->projectType = array_merge(array("None"=>""),$order->projectType);
|
|
|
|
|
|
|
|
$submit = $this->_getParam("submit");
|
2014-04-21 08:10:45 +00:00
|
|
|
|
|
|
|
if(!empty($submit))
|
|
|
|
{
|
|
|
|
$account = new Account();
|
|
|
|
$this->view->data = $data = $account->getRegisterParam();
|
|
|
|
$status = $account->register($data);
|
|
|
|
|
|
|
|
if(isset($status['error']))
|
|
|
|
{
|
|
|
|
$this->view->error = view::Error($status['error']);
|
|
|
|
if(isset($status['place']))
|
|
|
|
{
|
|
|
|
$this->view->place = $status['place'];
|
|
|
|
}
|
|
|
|
}else{
|
2014-05-08 13:25:27 +00:00
|
|
|
view::Post($this,"Successful register.","/");
|
2014-04-21 08:10:45 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-28 06:37:46 +00:00
|
|
|
}
|
2013-03-15 04:16:07 +00:00
|
|
|
|
2011-12-28 06:37:46 +00:00
|
|
|
function loginAction()
|
2014-12-12 06:52:16 +00:00
|
|
|
{
|
2013-06-20 14:39:11 +00:00
|
|
|
$options = array(
|
|
|
|
'module' => $this->_request->getModuleName(),
|
|
|
|
'controller' => $this->_request->getControllerName(),
|
|
|
|
'action' => $this->_request->getActionName(),
|
|
|
|
);
|
2013-10-28 14:54:21 +00:00
|
|
|
|
2011-12-28 06:37:46 +00:00
|
|
|
$auth = Zend_Auth::getInstance();
|
2013-06-20 14:39:11 +00:00
|
|
|
if ($auth->hasIdentity())
|
|
|
|
{
|
2014-05-08 13:25:27 +00:00
|
|
|
view::Post($this,"You are login now.","/index");
|
2013-06-20 14:39:11 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
$tohref = $this->_request->getParam('href');
|
|
|
|
|
2014-05-08 13:25:27 +00:00
|
|
|
if($_SERVER['REQUEST_URI'] !== "/account/login")
|
2013-06-20 14:39:11 +00:00
|
|
|
{
|
2013-10-28 14:54:21 +00:00
|
|
|
$this->view->href = $_SERVER['REQUEST_URI'];
|
2014-05-08 13:25:27 +00:00
|
|
|
}else{
|
|
|
|
$this->view->href = "/";
|
2013-06-20 14:39:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(!empty($tohref))
|
|
|
|
{
|
|
|
|
$this->view->href = $tohref;
|
|
|
|
}
|
2014-12-12 06:52:16 +00:00
|
|
|
|
|
|
|
$oauth2 = new OAuth2();
|
|
|
|
if($oauth2->loginTest())
|
|
|
|
{
|
|
|
|
$client = new Client();
|
|
|
|
$url = $client->makeRequestCodeUrl("escience");
|
|
|
|
|
|
|
|
view::Post($this,"为您转入科技网登录入口",$url);
|
|
|
|
}
|
2013-06-20 14:39:11 +00:00
|
|
|
|
2014-05-08 13:25:27 +00:00
|
|
|
$captcha = new Captcha();
|
2013-06-20 14:39:11 +00:00
|
|
|
|
|
|
|
$submit = $this->_getParam("submit");
|
|
|
|
if(!empty($submit))
|
|
|
|
{
|
|
|
|
$username = trim($this->_request->getParam('username'));
|
|
|
|
$password = trim($this->_request->getParam('password'));
|
|
|
|
$captchaword = trim($this->_request->getParam('captcha'));
|
|
|
|
|
2014-05-08 13:25:27 +00:00
|
|
|
if($captcha->isValid($captchaword) !== true)
|
2013-06-20 14:39:11 +00:00
|
|
|
{
|
2014-05-08 13:25:27 +00:00
|
|
|
$this->view->error = view::Error("Wrong captcha.");
|
|
|
|
$this->view->captcha = $captcha->setCaptcha();
|
2013-06-20 14:39:11 +00:00
|
|
|
return true;
|
|
|
|
}
|
2012-07-06 03:30:59 +00:00
|
|
|
|
2014-05-08 13:25:27 +00:00
|
|
|
$account = new Account();
|
|
|
|
$status = $account->login(array(
|
|
|
|
'username' => $username,
|
|
|
|
'password' => $password
|
|
|
|
));
|
2013-06-20 14:39:11 +00:00
|
|
|
|
2014-05-08 13:25:27 +00:00
|
|
|
if(isset($status['error']))
|
2012-07-06 03:30:59 +00:00
|
|
|
{
|
2014-05-08 13:25:27 +00:00
|
|
|
$this->view->error = view::Error($status['error']);
|
|
|
|
$this->view->captcha = $captcha->setCaptcha();
|
2013-06-20 14:39:11 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-05-08 13:25:27 +00:00
|
|
|
|
|
|
|
view::Post($this,"Login successful, jumping...",$tohref);
|
|
|
|
return true;
|
2013-06-20 14:39:11 +00:00
|
|
|
}else{
|
2014-05-08 13:25:27 +00:00
|
|
|
$this->view->captcha = $captcha->setCaptcha();
|
2011-12-28 06:37:46 +00:00
|
|
|
}
|
2013-06-20 14:39:11 +00:00
|
|
|
|
2014-05-08 13:25:27 +00:00
|
|
|
|
2011-12-28 06:37:46 +00:00
|
|
|
}
|
2013-06-20 14:39:11 +00:00
|
|
|
|
2014-04-21 08:10:45 +00:00
|
|
|
public function captchaAction()
|
2013-06-20 14:39:11 +00:00
|
|
|
{
|
2014-04-21 08:10:45 +00:00
|
|
|
if(view::isXmlHttpRequest($this))
|
|
|
|
{
|
|
|
|
$captcha = new Captcha();
|
|
|
|
$url = $captcha->setCaptcha();
|
|
|
|
echo $url;
|
|
|
|
return true;
|
|
|
|
}else{
|
|
|
|
echo "bad request!";
|
|
|
|
exit();
|
|
|
|
}
|
2013-06-20 14:39:11 +00:00
|
|
|
}
|
2014-05-08 13:25:27 +00:00
|
|
|
|
|
|
|
|
|
|
|
public function logoutAction()
|
2011-12-28 06:37:46 +00:00
|
|
|
{
|
|
|
|
$auth = Zend_Auth::getInstance();
|
|
|
|
$auth->clearIdentity();
|
2014-05-08 13:25:27 +00:00
|
|
|
Member::flushcookie();
|
2011-12-28 06:37:46 +00:00
|
|
|
$this->_redirect('/');
|
|
|
|
}
|
2014-05-08 13:25:27 +00:00
|
|
|
|
|
|
|
public function fetchpwdAction()
|
2011-12-28 06:37:46 +00:00
|
|
|
{
|
2014-05-08 13:25:27 +00:00
|
|
|
$salt = trim($this->_getParam('salt'));
|
|
|
|
$submit = $this->_getParam('submit');
|
|
|
|
if(empty($salt))
|
|
|
|
{
|
|
|
|
$captcha = new Captcha();
|
|
|
|
|
|
|
|
if(!empty($submit))
|
2011-12-28 06:37:46 +00:00
|
|
|
{
|
2014-05-08 13:25:27 +00:00
|
|
|
$email = trim($this->_request->getParam('email'));
|
|
|
|
$captchaword = trim($this->_request->getParam('captcha'));
|
2013-11-11 10:04:03 +00:00
|
|
|
|
2014-05-08 13:25:27 +00:00
|
|
|
if(!$captcha->isValid($captchaword))
|
|
|
|
{
|
|
|
|
$this->view->error = view::Error("Wrong captcha.");
|
|
|
|
$this->view->captcha = $captcha->setCaptcha();
|
|
|
|
return true;
|
|
|
|
}
|
2013-11-11 10:04:03 +00:00
|
|
|
|
2014-05-08 13:25:27 +00:00
|
|
|
$account = new Account();
|
|
|
|
$status = $account->getMyPassword($email);
|
2013-11-11 10:04:03 +00:00
|
|
|
|
2014-05-08 13:25:27 +00:00
|
|
|
if(isset($status['error']))
|
|
|
|
{
|
|
|
|
$this->view->error = view::Error($status['error']);
|
|
|
|
$this->view->captcha = $captcha->setCaptcha();
|
|
|
|
return true;
|
|
|
|
}
|
2013-11-11 10:04:03 +00:00
|
|
|
|
2014-05-08 13:25:27 +00:00
|
|
|
view::Post($this,"Please check the activation link in your email.");
|
|
|
|
return true;
|
|
|
|
}else{
|
|
|
|
$this->view->captcha = $captcha->setCaptcha();
|
|
|
|
}//提交密码重置申请
|
2011-12-28 06:37:46 +00:00
|
|
|
}
|
2014-05-08 13:25:27 +00:00
|
|
|
|
|
|
|
else{
|
|
|
|
$this->_helper->viewRenderer('account-resetpassword');
|
|
|
|
$this->view->salt = $salt;
|
|
|
|
if(!empty($submit))
|
|
|
|
{
|
|
|
|
$username = trim($this->_request->getParam('username'));
|
|
|
|
$password = trim($this->_request->getParam('password'));
|
|
|
|
$confirm_password = trim($this->_request->getParam('confirm_password'));
|
|
|
|
|
|
|
|
$account = new Account();
|
|
|
|
$status = $account->resetPassword(array(
|
|
|
|
'username' => $username,
|
|
|
|
'password' => $password,
|
|
|
|
'confirm_password' => $confirm_password,
|
|
|
|
'salt' => $salt
|
|
|
|
));
|
|
|
|
|
|
|
|
if(isset($status['error']))
|
|
|
|
{
|
|
|
|
$this->view->error = view::Error($status['error']);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
view::Post($this,"Password change successful, please use the password log in.","/account/login");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}//修改密码
|
|
|
|
|
2013-10-28 14:54:21 +00:00
|
|
|
} //找回密码
|
2014-05-08 13:25:27 +00:00
|
|
|
|
|
|
|
//OAuth2登录跳转页面
|
|
|
|
public function oauth2loginAction()
|
|
|
|
{
|
|
|
|
$type = $this->_getParam('type');
|
|
|
|
$client = new Client();
|
|
|
|
$url = $client->makeRequestCodeUrl($type);
|
|
|
|
|
|
|
|
view::Post($this,"为您转入科技网登录入口",$url);
|
|
|
|
}
|
|
|
|
|
|
|
|
//oauth2登录回调地址
|
|
|
|
public function callbackAction()
|
|
|
|
{
|
|
|
|
$type = $this->_getParam('type');
|
|
|
|
$code = $this->_getParam('code');
|
|
|
|
|
|
|
|
$client = new Client($type);
|
|
|
|
|
|
|
|
$client->initSource();
|
|
|
|
$target = $client->getSource()->getTarget($type);
|
|
|
|
$this->view->target_name = $target['name'];
|
|
|
|
|
|
|
|
$token = $client->requestToken($code);
|
|
|
|
|
|
|
|
if(is_string($token))
|
|
|
|
{
|
|
|
|
view::Post($this,$token,'/account/login');
|
|
|
|
}
|
|
|
|
|
|
|
|
$status = $client->storageTokenData($type,$token);
|
|
|
|
|
|
|
|
if($status === true)
|
|
|
|
{
|
|
|
|
echo "<script>self.location='/index'</script>";
|
|
|
|
}else{
|
|
|
|
echo $status;
|
|
|
|
}
|
|
|
|
}
|
2013-10-28 14:54:21 +00:00
|
|
|
|
2011-12-28 06:37:46 +00:00
|
|
|
}
|
|
|
|
|