2013-11-22 04:20:00 +00:00
|
|
|
<?php
|
|
|
|
namespace Open;
|
|
|
|
|
2014-11-04 02:32:01 +00:00
|
|
|
use Open\Client;
|
|
|
|
use Helpers\Curl;
|
|
|
|
use Helpers\Table;
|
|
|
|
|
2013-11-22 04:20:00 +00:00
|
|
|
class OAuth2 extends \Zend_Controller_Plugin_Abstract
|
|
|
|
{
|
|
|
|
public $db;
|
|
|
|
public $auth = NULL;
|
|
|
|
public $user;
|
|
|
|
private $config;
|
|
|
|
public $table;
|
|
|
|
|
|
|
|
public function __construct($db = NULL,$auth = NULL){
|
|
|
|
|
|
|
|
if(empty($db))
|
|
|
|
{
|
|
|
|
$this->db = \Zend_Registry::get('db');
|
|
|
|
}else{
|
|
|
|
$this->db = $db;
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->config = \Zend_Registry::get('config');
|
|
|
|
$this->table = new Table();
|
|
|
|
|
|
|
|
}
|
2014-11-04 02:32:01 +00:00
|
|
|
|
|
|
|
//登录测试
|
|
|
|
public function loginTest()
|
|
|
|
{
|
|
|
|
try {
|
|
|
|
$client = new Client();
|
|
|
|
$url = $client->makeRequestCodeUrl("escience");
|
|
|
|
|
|
|
|
$curl = new Curl();
|
|
|
|
$curl->port = 443;
|
|
|
|
$curl->initOptions(array('verifyssl' => false));
|
|
|
|
$data = $curl->request($url, array(), "POST");
|
|
|
|
|
|
|
|
$cache_data = $data;
|
|
|
|
|
|
|
|
if (isset($data['headers']['http_code']) && $data['headers']['http_code'] == 302) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}catch (\Exception $e)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2013-11-22 04:20:00 +00:00
|
|
|
}
|