/** * 通知客户端 * 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 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); }
/** * 获取头像上传代码 * * @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); }
/** * 按用户ID发送私信 * * @param int $uid * @param string $content * @param int $fromUid * @return WindidError|boolean */ public function sendMessageByUid($uid, $content, $fromUid = 0) { if (!$uid || !$fromUid) { return false; } if (!isset($this->_blackList[$uid])) { $this->_blackList[$uid] = $this->_getUserBlackDs()->getBlacklist($uid); } //生成新消息 $dm = new WindidMessageDm(); $dm->setCreatedUserId($fromUid)->setToUid($uid)->setContent($content); if (($result = $dm->beforeAdd()) instanceof WindidError) { return $result; } $messageId = $this->_getMessageDs()->addMessage($dm); $lastMessage = $this->_getLastMessage($fromUid, $uid, $content); //=========================发件人对话信息========================= $dm = new WindidMessageDm(); $dm->setLastMessage($lastMessage); $dialog = $this->_getMessageDs()->getDialogByUid($fromUid, $uid); if ($dialog) { $dialogId = $dialog['dialog_id']; $dm->increaseMessageCount()->setModifiedTime(Windid::getTime()); $this->_getMessageDs()->updateDialog($dialogId, $dm); } else { $dm->setToUid($fromUid)->setFromUid($uid)->setMessageCount(1); $dialogId = $this->_getMessageDs()->addDialog($dm); } //添加发件人联系 $dm = new WindidMessageDm(); $dm->setDialogId($dialogId)->setMessageId($messageId)->setIsRead(1)->setIsSend(1); $this->_getMessageDs()->addRelation($dm); $dm = new WindidMessageDm(); $dm->setLastMessage($lastMessage); if (in_array($fromUid, $this->_blackList[$uid])) { return false; } //=========================收件人对话信息========================= $dialog = $this->_getMessageDs()->getDialogByUid($uid, $fromUid); // 分组已存在更新数量 if ($dialog) { $dialogId = $dialog['dialog_id']; $dm->increaseUnreadCount()->increaseMessageCount()->setModifiedTime(Windid::getTime()); $this->_getMessageDs()->updateDialog($dialogId, $dm); } else { // 分组不存在添加一条 $dm->setToUid($uid)->setFromUid($fromUid)->setUnreadCount(1)->setMessageCount(1); //新增私信分组记录 $dialogId = $this->_getMessageDs()->addDialog($dm); } //添加收件人联系 $dm = new WindidMessageDm(); $dm->setDialogId($dialogId)->setMessageId($messageId); $this->_getMessageDs()->addRelation($dm); $this->resetUserMessages($uid); //TODO后期要改掉 return true; }
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 beforeAction($handlerAdapter) { parent::beforeAction($handlerAdapter); echo "<pre/>"; $orderStatuses = $this->_getMyOrderDS()->getAllStatus(); $shopOrders = $this->_getMyOrderDS()->getShopOrders(1, 11045, 1, $orderStatuses, '', -1, 2, 0); print_r($shopOrders); //UPDATE `pw4t`.`pw_windid_user` SET `password` = 'b3ff2df1b3ca95d9ae2c03d93f821201' WHERE `pw_windid_user`.`uid` =1 LIMIT 1 ; //UPDATE `pw4t`.`pw_user` SET `password` = 'ece4f4a60b764339b94a07c84e338a27' WHERE `pw_user`.`uid` =1 LIMIT 1 ; echo md5(md5('ece4f4a60b764339b94a07c84e338a27') . "2GGDpd"); date_default_timezone_set("Asia/Shanghai"); $now = date("Y-m-d H:i:s", strtotime('now')); echo $now; $info = $this->_getMyOrderDS()->updateOrderItemStatus("464,465", -1); $myOrderShops = $this->_getSchoolPeopleDS()->getPeopleSchedule($this->loginUser->uid, 11045, 0, '2013-08-08 00:00:00', '2013-08-08 23:59:59'); $shopids = " -1 "; foreach ($myOrderShops as $day => $shopSchedules) { foreach ($shopSchedules as $shopid => $eachshopschedules) { $shopids = $shopids . "," . $shopid; foreach ($eachshopschedules as $key => &$eachschedule) { $eachschedule['datetimeBegin'] = $day . " " . $eachschedule['datetimeBegin']; $eachschedule['datetimeEnd'] = $day . " " . $eachschedule['datetimeEnd']; $schedules[] = $eachschedule; } } } print_r($shopids); print_r($schedules); print_r($myOrderShops); echo "<br/>"; $estimatetime = $this->_getShopDS()->getShopOrderTimeBase(1); print_r($estimatetime); date_default_timezone_set("Asia/Shanghai"); $schoolSchedule = (include Wind::getRealPath('ROOT:conf.schoolOpenSchedule.php', true)); $opening = $this->_getSchoolDS()->isSchoolOpenNow(11045); var_dump($opening); $result = $this->_getMyOrderDS()->getSchoolPeopleStatistics(11045, 10, 0); print_r($result); $time = Windid::getTime(); echo "time:" . $time; echo "<br/>"; echo "key_1: " . md5('1' . '||' . 'b6a76c3e4aa21dbf9aeee10bfaba1f2a'); echo "<br/>"; print md5(md5('1' . '||' . 'b6a76c3e4aa21dbf9aeee10bfaba1f2a') . $time); die; }
/** * 同步登录登出 * Enter description here ... * @param string $notify * @param int $uid */ public function syn($method, $uid) { $operation = array_search($method, $this->notify); $time = Windid::getTime(); $data = array(); $apps = $this->_getAppDs()->getList(); $client = Windid::client(); $syn = false; //TODO foreach ($apps as $val) { if (!$val['issyn'] && $val['id'] == $client->clientId) { $syn = true; break; } if (!$val['issyn'] || $val['id'] == $client->clientId) { continue; } $array = array('windidkey' => WindidUtility::appKey($val['id'], $time, $val['secretkey']), 'operation' => $operation, 'uid' => $uid, 'clientid' => $val['id'], 'time' => $time); $data[] = WindidUtility::buildClientUrl($val['siteurl'], $val['apifile']) . http_build_query($array); } return $syn ? array() : $data; }
/** * 获取附件上传时存储在本地的文件地址 * * @param string $filename 文件名 * @param string $dir 目录名 * @return string */ public function getAbsolutePath($filename, $dir) { return DATA_PATH . 'upload/' . gmdate('j', Windid::getTime()) . '/' . str_replace('/', '_', $dir) . $filename; }
<?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');
/** * 设置创建时间 * */ private function _setCreatedTime() { $this->_data['created_time'] = Windid::getTime(); }