/**
  * 客户端接口
  *
  * @see \Zend\Mvc\Controller\AbstractActionController::indexAction()
  */
 public function indexAction()
 {
     $response = $this->getResponse();
     $options = $this->getServiceLocator()->get('ucenter_client_module_options');
     $_DCACHE = $get = $post = array();
     $query = $this->getRequest()->getQuery();
     $code = $query->get('code');
     parse_str(Services\Plugin\Utils::ucAuthcode($code, 'DECODE', $options->getUcKey()), $get);
     defined('MAGIC_QUOTES_GPC') || define('MAGIC_QUOTES_GPC', get_magic_quotes_gpc());
     if (MAGIC_QUOTES_GPC) {
         $get = $this->_stripslashes($get);
     }
     if (empty($get)) {
         return $response->setContent('Invalid Request');
     }
     $timestamp = time();
     if (isset($get['time']) && $timestamp - $get['time'] > 3600) {
         return $response->setContent('Authracation has expiried');
     }
     $post = SerializerXml::unserialize(file_get_contents('php://input'));
     if (isset($get['action']) && in_array($get['action'], array('test', 'deleteuser', 'renameuser', 'gettag', 'synlogin', 'synlogout', 'updatepw', 'updatebadwords', 'updatehosts', 'updateapps', 'updateclient', 'updatecredit', 'getcreditsettings', 'updatecreditsettings'))) {
         return $response->setContent($this->ucNote()->{$get}['action']($get, $post));
     } else {
         return $response->setContent(UcenterInterface::API_RETURN_FAILED);
     }
 }
Beispiel #2
0
 public function synlogin($get, $post)
 {
     $uid = $get['uid'];
     $username = $get['username'];
     if (!Ui::API_SYNLOGIN) {
         return Ui::API_RETURN_FORBIDDEN;
     }
     $cookie = new SetCookie('ucenter_auth', Services\Plugin\Utils::ucAuthcode($uid . "\t" . $username, 'ENCODE'), time() + 3600, '/', null, false, true);
     $this->getController()->getResponse()->getHeaders()->addHeader($cookie)->addHeaderLine('P3P: CP="CURa ADMa DEVa PSAo PSDo OUR BUS UNI PUR INT DEM STA PRE COM NAV OTC NOI DSP COR"');
     // 登录
     /* @var $options \UcenterClient\Options\ModuleOptions */
     $options = $this->getServiceLocator()->get('ucenter_client_module_options');
     $ucAuthAdapter = $this->getServiceLocator()->get($options->getUcAuthAdapter());
     $ucAuthService = $this->getServiceLocator()->get($options->getUcAuthService());
     // clear adapters
     $ucAuthAdapter->resetAdapters();
     $ucAuthService->clearIdentity();
     $result = $ucAuthAdapter->prepareForAuthentication($this->getController()->getRequest());
     // Return early if an adapter returned a response
     if ($result instanceof Response) {
         return $result;
     }
     // authenticate
     $auth = $ucAuthService->authenticate($ucAuthAdapter);
     if (!$auth->isValid()) {
         return Ui::API_RETURN_FAILED;
     }
     return Ui::API_RETURN_SUCCEED;
 }
Beispiel #3
0
 private function ucApiInput($data)
 {
     $options = $this->getOptions();
     $s = urlencode(Plugin\Utils::ucAuthcode($data . '&agent=' . md5($_SERVER['HTTP_USER_AGENT']) . "&time=" . time(), 'ENCODE', $options->getUcKey()));
     return $s;
 }