/** * 获取头像上传代码 * * @param int $uid 用户uid * @param int $getHtml 获取代码|配置 * @return string|array */ public function getFlashAction() { $uid = $this->getInput('uid', 'get'); $getHtml = $this->getInput('getHtml', 'get'); if ($getHtml === null) { $getHtml = 1; } $client = Windid::client(); $time = Windid::getTime(); $key = WindidUtility::appKey($client->clientId, $time, $client->clientKey); $postUrl = "postAction=ra_postAction&redirectURL=/&requestURL=" . urlencode($client->serverUrl . "/windid/index.php?m=api&c=avatar&a=doAvatar&uid=" . $uid . '&windidkey=' . $key . '&time=' . $time . '&clientid=' . $client->clientId . '&type=flash') . '&avatar=' . urlencode($this->getAvatar($uid, 'big') . '?r=' . rand(1, 99999)); $result = $getHtml ? '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="700" height="430" id="rainbow" align="middle"> <param name="movie" value="' . Windid::resUrl() . 'swf/avatar/avatar.swf?' . rand(0, 9999) . '" /> <param name="quality" value="high" /> <param name="bgcolor" value="#ffffff" /> <param name="play" value="true" /> <param name="loop" value="true" /> <param name="wmode" value="opaque" /> <param name="scale" value="showall" /> <param name="menu" value="true" /> <param name="devicefont" value="false" /> <param name="salign" value="" /> <param name="allowScriptAccess" value="always" /> <param name="FlashVars" value="' . $postUrl . '"/> <embed src="' . Windid::resUrl() . 'swf/avatar/avatar.swf?' . rand(0, 9999) . '" quality="high" bgcolor="#ffffff" width="700" height="430" name="mycamera" align="middle" allowScriptAccess="always" allowFullScreen="false" scale="exactfit" wmode="transparent" FlashVars="' . $postUrl . '" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /> </object>' : array('width' => '500', 'height' => '405', 'id' => 'uploadAvatar', 'name' => 'uploadAvatar', 'src' => Windid::resUrl() . 'swf/avatar/avatar.swf', 'wmode' => 'transparent', 'postUrl' => $client->serverUrl . "/windid/index.php?m=api&c=avatar&a=doAvatar&uid=" . $uid . '&windidkey=' . $key . '&time=' . $time . '&clientid=' . $client->clientId . '&type=normal', 'token' => $key); $this->output($result); }
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); }
/** * 通知客户端 * Enter description here ... * @param unknown_type $operation * @param unknown_type $data */ protected function queueSend($start = 0) { $time = Windid::getTime(); $appids = $nids = array(); $logDs = $this->_getNotifyLogDs(); $queue = $logDs->getList(0, 0, 10, $start, 0); if (!$queue) { return false; } foreach ($queue as $v) { $appids[] = $v['appid']; $nids[] = $v['nid']; } $apps = $this->_getAppDs()->fetchApp(array_unique($appids)); $notifys = $this->_getNotifyDs()->fetchNotify(array_unique($nids)); $postData = $urls = array(); foreach ($queue as $k => $v) { $appid = $v['appid']; $nid = $v['nid']; $array = array('windidkey' => WindidUtility::appKey($v['appid'], $time, $apps[$appid]['secretkey']), 'operation' => $notifys[$nid]['operation'], 'uid' => (int) $notifys[$nid]['param'], 'clientid' => $v['appid'], 'time' => $time); $urls[$k] = WindidUtility::buildClientUrl($apps[$appid]['siteurl'], $apps[$appid]['apifile']) . http_build_query($array); } if (!$urls) { return false; } $result = WindidUtility::buildMultiRequest($urls); sleep(3); $this->logId = $this->logId + $result; $start += 10; $this->queueSend($start); }
public function doAvatar($uid, $file = '') { $time = Pw::getTime(); $query = array('m' => 'api', 'c' => 'avatar', 'a' => 'doavatar', 'windidkey' => WindidUtility::appKey(WINDID_CLIENT_ID, $time, WINDID_CLIENT_KEY, array('uid' => $uid, 'm' => 'api', 'c' => 'avatar', 'a' => 'doavatar'), array()), 'clientid' => WINDID_CLIENT_ID, 'time' => $time, 'uid' => $uid); $url = WINDID_SERVER_URL . '/index.php?' . http_build_query($query); $result = WindidUtility::uploadRequest($url, $file); if ($result === false) { return WindidError::SERVER_ERROR; } return Pw::jsonDecode($result); }
public static function open($script, $getData = array(), $postData = array(), $method = 'post', $protocol = 'http') { $time = Pw::getTime(); list($c, $a) = explode('/', $script); $query = array('m' => 'api', 'c' => $c, 'a' => $a, 'windidkey' => WindidUtility::appKey(WINDID_CLIENT_ID, $time, WINDID_CLIENT_KEY), 'clientid' => WINDID_CLIENT_ID, 'time' => $time); $url = WINDID_SERVER_URL . '/index.php?' . http_build_query($query) . '&' . http_build_query($getData); $result = WindidUtility::buildRequest($url, $postData); if ($result === false) { return WindidError::SERVER_ERROR; } return Pw::jsonDecode($result); }
public function doAvatar($uid, $file = '') { $client = Windid::client(); $time = time() + $client->timecv * 60; $query = array('m' => 'api', 'c' => 'avatar', 'a' => 'doavatar', 'windidkey' => WindidUtility::appKey($client->clientId, $time, $client->clientKey), 'clientid' => $client->clientId, 'time' => $time, 'uid' => $uid); $url = $client->serverUrl . '/windid/index.php?' . http_build_query($query); $result = WindidUtility::uploadRequest($url, $file); if ($result === false) { return WindidError::SERVER_ERROR; } return WindJson::decode($result, true, $client->clientCharser); }
public static function open($script, $getData = array(), $postData = array(), $method = 'post', $protocol = 'http') { echo "here"; $client = Windid::client(); $time = time() + $client->timecv * 60; list($c, $a) = explode('/', $script); $query = array('m' => 'api', 'c' => $c, 'a' => $a, 'windidkey' => WindidUtility::appKey($client->clientId, $time, $client->clientKey), 'clientid' => $client->clientId, 'time' => $time); $url = $client->serverUrl . '/windid/index.php?' . http_build_query($query) . '&' . http_build_query($getData); $result = WindidUtility::buildRequest($url, $postData); if ($result === false) { return WindidError::SERVER_ERROR; } return WindJson::decode($result, true, $client->clientCharser); }
public function clientTestAction() { $clientid = $this->getInput('clientid'); $client = $this->_getAppDs()->getApp($clientid); if (!$client) { $this->showError('WINDID:fail'); } $time = Pw::getTime(); $array = array('windidkey' => WindidUtility::appKey($client['id'], $time, $client['secretkey']), 'operation' => 999, 'uid' => 1, 'clientid' => $client['id'], 'time' => $time); $url = WindidUtility::buildClientUrl($client['siteurl'], $client['apifile']) . http_build_query($array); $result = WindidUtility::buildRequest($url); if ($result === 'seccess') { $this->showMessage('WINDID:success'); } $this->showError('WINDID:fail'); }
public static function open($script, $getData = array(), $postData = array(), $method = 'post', $protocol = 'http') { $time = Pw::getTime(); list($c, $a) = explode('/', $script); $query = array('m' => 'api', 'c' => $c, 'a' => $a, 'windidkey' => WindidUtility::appKey(WINDID_CLIENT_ID, $time, WINDID_CLIENT_KEY, $getData, $postData), 'clientid' => WINDID_CLIENT_ID, 'time' => $time); $url = WINDID_SERVER_URL . '/index.php?' . http_build_query($query) . '&' . http_build_query($getData); //$result = WindidUtility::buildRequest($url, $postData); //系统自带的函数不知道是什么问题,先用这个函数,并且加上过滤防范了安全。taishici if (!(strpos($url, 'http://') === 0 || strpos($url, 'https://') === 0)) { return false; } $result = file_get_contents($url); if ($result === false) { return WindidError::SERVER_ERROR; } return Pw::jsonDecode($result); }
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 function clientTestAction() { $clientid = $this->getInput('clientid'); $client = $this->_getAppDs()->getApp($clientid); if (!$client) { $this->showError('WINDID:fail'); } $time = Pw::getTime(); $params['params'] = serialize(array('test' => $time)); $windidkey = WindidUtility::appKey($client['id'], $time, $client['secretkey']); $url = WindidUtility::buildClientUrl($client['siteurl'], $client['apifile']) . 'operation=999&windidkey=' . $windidkey . '&clentid=' . $client['id'] . '&time=' . $time; $result = WindidUtility::buildRequest($url, $params); if ($result === 'seccess') { $this->showMessage('ADMIN:success'); } $this->showError('ADMIN:fail'); }
public function beforeAction($handlerAdapter) { parent::beforeAction($handlerAdapter); $_windidkey = $this->getInput('windidkey', 'get'); $_time = (int) $this->getInput('time', 'get'); $_clentid = (int) $this->getInput('clientid', 'get'); $windidConfig = Wekit::C('windid'); define('WINDID_CONNECT', $windidConfig['connect']); define('WINDID_SERVER_URL', $windidConfig['serverUrl']); define('WINDID_CLIENT_ID', $windidConfig['clientId']); define('WINDID_CLIENT_KEY', $windidConfig['clientKey']); if (WindidUtility::appKey(WINDID_CLIENT_ID, $_time, WINDID_CLIENT_KEY) != $_windidkey) { $this->showError('fail'); } $time = Pw::getTime(); if ($time - $_time > 120) { $this->showError('timeout'); } }
/** * 同步登录登出 * * @param string $notify * @param int $uid */ public function syn($method, $uid, $appid = 0) { $operation = $this->getOperation($method); $time = Pw::getTime(); $data = array(); $apps = $this->_getAppDs()->getList(); $syn = false; foreach ($apps as $val) { if (!$val['issyn'] && $val['id'] == $appid) { $syn = true; break; } if (!$val['issyn'] || $val['id'] == $appid) { continue; } $array = array('windidkey' => WindidUtility::appKey($val['id'], $time, $val['secretkey'], array('uid' => $uid), array()), 'operation' => $operation, 'uid' => $uid, 'clientid' => $val['id'], 'time' => $time); $data[] = WindidUtility::buildClientUrl($val['siteurl'], $val['apifile']) . http_build_query($array); } return $syn ? array() : $data; }
protected function _request($queue) { $time = Pw::getTime(); $appids = $nids = array(); foreach ($queue as $v) { $appids[] = $v['appid']; $nids[] = $v['nid']; } $apps = $this->_getAppDs()->fetchApp(array_unique($appids)); $notifys = $this->_getNotifyDs()->fetchNotify(array_unique($nids)); $post = $urls = array(); foreach ($queue as $k => $v) { $appid = $v['appid']; $nid = $v['nid']; $array = array('windidkey' => WindidUtility::appKey($v['appid'], $time, $apps[$appid]['secretkey']), 'operation' => $notifys[$nid]['operation'], 'clientid' => $v['appid'], 'time' => $time); $post[$k] = unserialize($notifys[$nid]['param']); $urls[$k] = WindidUtility::buildClientUrl($apps[$appid]['siteurl'], $apps[$appid]['apifile']) . http_build_query($array); } return WindidUtility::buildMultiRequest($urls, $post); }
public function notifyAction(Request $request) { if (!defined('WEKIT_TIMESTAMP')) { define('WEKIT_TIMESTAMP', time()); } require_once __DIR__ . '/../../../../vendor_user/windid_client/src/windid/WindidApi.php'; //引入windid接口类 require_once __DIR__ . '/../../../../vendor_user/windid_client/src/windid/service/base/WindidUtility.php'; //引入windid工具库 $windidKey = $request->query->get('windidkey'); $queryTime = $request->query->get('time'); $clientId = $request->query->get('clientid'); $operation = $request->query->get('operation'); $currentTimestamp = \Pw::getTime(); if (in_array($operation, array(111, 112))) { unset($_GET['operation']); } if (\WindidUtility::appKey(WINDID_CLIENT_ID, $queryTime, WINDID_CLIENT_KEY, $_GET, $_POST) != $windidKey) { return $this->createWindidResponse('sign error.'); } if ($currentTimestamp->{$queryTime} > 120) { return $this->createWindidResponse('timeout.'); } list($method, $args) = $this->getWindidMethod($operation); if (!$method) { return $this->createWindidResponse('fail'); } $method = 'do' . ucfirst($method); if (!method_exists($this, $method)) { return $this->createWindidResponse('success'); } $filteredArgs = array(); foreach ($args as $key) { $filteredArgs[$key] = $request->get($key); } $result = $this->{$method}($request, $filteredArgs); if ($result == true) { return $this->createWindidResponse('success'); } return $this->createWindidResponse('fail'); }
public static function open($script, $getData = array(), $postData = array(), $method = 'post', $protocol = 'http') { $time = Pw::getTime(); list($c, $a) = explode('/', $script); $getData['m'] = 'api'; $getData['c'] = $c; $getData['a'] = $a; $getData['clientid'] = WINDID_CLIENT_ID; $getData['time'] = $time; $getData['windidkey'] = WindidUtility::appKey(WINDID_CLIENT_ID, $time, WINDID_CLIENT_KEY, $getData, $postData); $url = WINDID_SERVER_URL . '/index.php?' . http_build_query($getData); if (!(strpos($url, 'http://') === 0 || strpos($url, 'https://') === 0)) { return false; } //$result = file_get_contents($url); $result = WindidUtility::buildRequest($url, $postData); if ($result === false) { return WindidError::SERVER_ERROR; } return Pw::jsonDecode($result); }
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'], $this->getRequest()->getGet(null), $this->getRequest()->getPost()) != $_windidkey) { $this->output(WindidError::FAIL); } $time = Pw::getTime(); if ($time - $_time > 1200) { $this->output(WindidError::TIMEOUT); } $this->appid = $_clientid; }
public function showFlash($uid, $appId, $appKey, $getHtml = 1) { $time = Pw::getTime(); $key = WindidUtility::appKey($appId, $time, $appKey, array('uid' => $uid, 'type' => 'flash'), array('uid' => 'undefined')); $key2 = WindidUtility::appKey($appId, $time, $appKey, array('uid' => $uid, 'type' => 'normal'), array()); $postUrl = "postAction=ra_postAction&redirectURL=/&requestURL=" . urlencode(Wekit::app('windid')->url->base . "/index.php?m=api&c=avatar&a=doAvatar&uid=" . $uid . '&windidkey=' . $key . '&time=' . $time . '&clientid=' . $appId . '&type=flash') . '&avatar=' . urlencode($this->getAvatar($uid, 'big') . '?r=' . rand(1, 99999)); return $getHtml ? '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="700" height="430" id="rainbow" align="middle"> <param name="movie" value="' . Wekit::app('windid')->url->res . 'swf/avatar/avatar.swf?' . rand(0, 9999) . '" /> <param name="quality" value="high" /> <param name="bgcolor" value="#ffffff" /> <param name="play" value="true" /> <param name="loop" value="true" /> <param name="wmode" value="opaque" /> <param name="scale" value="showall" /> <param name="menu" value="true" /> <param name="devicefont" value="false" /> <param name="salign" value="" /> <param name="allowScriptAccess" value="never" /> <param name="FlashVars" value="' . $postUrl . '"/> <embed src="' . Wekit::app('windid')->url->res . 'swf/avatar/avatar.swf?' . rand(0, 9999) . '" quality="high" bgcolor="#ffffff" width="700" height="430" name="mycamera" align="middle" allowScriptAccess="never" allowFullScreen="false" scale="exactfit" wmode="transparent" FlashVars="' . $postUrl . '" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /> </object>' : array('width' => '500', 'height' => '405', 'id' => 'uploadAvatar', 'name' => 'uploadAvatar', 'src' => Wekit::app('windid')->url->res . 'swf/avatar/avatar.swf', 'wmode' => 'transparent', 'postUrl' => Wekit::app('windid')->url->base . "/index.php?m=api&c=avatar&a=doAvatar&uid=" . $uid . '&windidkey=' . $key2 . '&time=' . $time . '&clientid=' . $appId . '&type=normal&jcallback=avatarNormal', 'token' => $key2); }
<?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');