public function beforeAction($handlerAdapter) { parent::beforeAction($handlerAdapter); $charset = 'utf-8'; $_windidkey = $this->getInput('windidkey', 'get'); $_time = (int) $this->getInput('time', 'get'); $_clientid = (int) $this->getInput('clientid', 'get'); if (!$_time || !$_clientid) { $this->output(WindidError::FAIL); } $clent = $this->_getAppDs()->getApp($_clientid); if (!$clent) { $this->output(WindidError::FAIL); } if (WindidUtility::appKey($clent['id'], $_time, $clent['secretkey']) != $_windidkey) { $this->output(WindidError::FAIL); } $time = Windid::getTime(); if ($time - $_time > 120) { $this->output(WindidError::TIMEOUT); } $charset = $clent['charset'] == 1 ? 'utf8' : 'gbk'; $baseUrl = Wind::getApp()->getRequest()->getBaseUrl(true) . '/'; $config = array('windid' => 'client', 'serverUrl' => $baseUrl, 'clientId' => $clent['id'], 'clientKey' => $clent['secretkey'], 'clientDb' => 'mysql', 'clientCharser' => $charset); WindidClientBo::getInstance($config); }
public static function getInstance($config = array()) { if (!isset(self::$_clientBo)) { self::$_clientBo = new self($config); } return self::$_clientBo; }
public function beforeAction($handlerAdapter) { parent::beforeAction($handlerAdapter); $_windidkey = $this->getInput('windidkey', 'get'); $_time = (int) $this->getInput('time', 'get'); $_clentid = (int) $this->getInput('clientid', 'get'); WindidClientBo::getInstance(); $client = Windid::client(); if (WindidUtility::appKey($client->clientId, $_time, $client->clientKey) != $_windidkey) { $this->showError('fail'); } $time = Windid::getTime(); if ($time - $_time > 120) { $this->showError('timeout'); } }
public static function client() { return WindidClientBo::getInstance(); }
<?php require_once 'windid/src/windid/WindidApi.php'; require_once 'windid/src/windid/service/client/bo/WindidClientBo.php'; require_once 'windid/src/windid/library/WindidUtility.php'; $notify = array('999' => 'test', '101' => 'addUser', '111' => 'synLogin', '112' => 'synLogout', '201' => 'editUser', '202' => 'editUserInfo', '203' => 'uploadAvatar', '211' => 'editCredit', '222' => 'editMessageNum', '301' => 'deleteUser'); //check $_windidkey = getInput('windidkey', 'get'); $_time = (int) getInput('time', 'get'); $_clentid = (int) getInput('clientid', 'get'); WindidClientBo::getInstance(); $client = Windid::client(); if (WindidUtility::appKey($client->clientId, $_time, $client->clientKey, $_GET, $_POST) != $_windidkey) { $this->showError('fail'); } $time = Windid::getTime(); if ($time - $_time > 120) { showError('timeout'); } $operation = (int) getInput('operation', 'get'); $uid = (int) getInput('uid', 'get'); if (!$uid) { showError('fail'); } if (!isset($notify[$operation])) { showError('fail'); } $method = $notify[$operation]; $notify = new notify(); if (!method_exists($notify, $method)) { showError('fail');