/** * 获取淘宝响应信息 如果oauth2正常流程,可以走curl_init */ public function getResponseInfo() { $result = $this->checkStatus(); if ($result !== true) { return new PwError($result); } $sessionId = Pw::getCookie($this->_getLoginSessionService()->getCookieName()); $sessionInfo = App_Account_LoginSessionBo::getInstance($sessionId)->getSession(); if (!$sessionId || !$sessionInfo) { return new PwError('验证会话失败,请重试'); } list($top_parameters, $top_sign) = array(trim($_REQUEST['top_parameters']), trim($_REQUEST['top_sign'])); if ($this->_checkSign() === false) { return new PwError('与淘宝通信失败,请重试'); } $userInfo = $this->_getUserInfo(); if ($userInfo === false) { return new PwError('获取用户信息失败,请重试'); } list($user_id, $nick) = $userInfo; //更新数据库 $info = $this->_getTaobaoUserInfoDs()->get($user_id); if (!$info) { $dm = new App_Account_TaobaoUserInfoDm(); $dm->setUserId($user_id)->setNick($nick)->setCreateAt(Pw::getTime()); $this->_getTaobaoUserInfoDs()->add($dm); } //更新session $this->updateSession($user_id, $nick, 'taobao'); return true; }
public function bulidThread($thread) { if ($thread['issort'] && $thread['topped']) { $thread['icon'] = 'headtopic_' . $thread['topped']; } elseif ($thread['digest']) { $thread['icon'] = 'digest'; } elseif (Pw::getstatus($thread['tpcstatus'], PwThread::STATUS_LOCKED)) { $thread['icon'] = 'lock'; } elseif ($thread['special'] && isset($this->specialIcon[$thread['special']])) { $thread['icon'] = $this->specialIcon[$thread['special']]; } elseif ($thread['replies'] > $this->_iconHot) { $thread['icon'] = 'topichot'; } elseif (Pw::getTime() - $thread['created_time'] < $this->_iconNew) { $thread['icon'] = 'topicnew'; } else { $thread['icon'] = 'topic'; } if ($thread['overtime'] && $thread['overtime'] < Pw::getTime()) { $overtimeService = Wekit::load("SRV:forum.srv.PwOvertimeService"); $overtimeService->updateOvertime($thread['tid']); } if ($thread['highlight']) { $highlight = Wekit::load("Lib:utility.PwHighlight"); $thread['highlight_style'] = $highlight->getStyle($thread['highlight']); } if ($thread['inspect']) { $thread['inspect'] = explode("\t", $thread['inspect']); } if ($thread['ifshield']) { $thread['highlight_style'] = 'text-decoration: line-through'; $thread['subject'] = '此帖已被屏蔽'; } return $this->runWithFilters('bulidThread', $thread); }
public function updateOvertime($tid) { $overtimes = $this->_getOvertimeDs()->getOvertimeByTid($tid); $deltop = 0; $dm = new PwTopicDm($tid); if ($overtimes) { $timestamp = Pw::getTime(); $newOvertime = 0; $ids = array(); foreach ($overtimes as $v) { if ($v['overtime'] > $timestamp) { (!$newOvertime || $newOvertime > $v['overtime']) && ($newOvertime = $v['overtime']); } else { switch ($v['m_type']) { case 'topped': $dm->setTopped(0); $deltop = 1; break; case 'highlight': $dm->setHighlight(''); break; } $ids[] = $v['id']; } } $ids && $this->_getOvertimeDs()->batchDelete($ids); $dm->setOvertime($newOvertime); } else { $dm->setOvertime(0); } $this->_getThreadDs()->updateThread($dm); if ($deltop) { Wekit::load('forum.PwSpecialSort')->deleteSpecialSortByTid($tid); } }
/** * 更新我的脚印 * * @param int $spaceUid * @param int $visitUid */ public function signToVisitor($spaceUid, $visitUid) { if ($spaceUid < 1 || $visitUid < 1) { return false; } if ($spaceUid == $visitUid) { return false; } $time = Pw::getTime(); $space = $this->_getSpaceDs()->getSpace($visitUid); $tovisitors = unserialize($space['tovisitors']); $tovisitors = is_array($tovisitors) ? $tovisitors : array(); if (array_key_exists($spaceUid, $tovisitors)) { $keys = array_keys($tovisitors); if (array_shift($keys) == $spaceUid) { return false; } //如果是第一个不需要更新 unset($tovisitors[$spaceUid]); } $tovisitors = array($spaceUid => $time) + $tovisitors; if (count($tovisitors) > 20) { $tovisitors = array_slice($tovisitors, 0, 20, true); } Wekit::load('space.dm.PwSpaceDm'); $dm = new PwSpaceDm($visitUid); $dm->setTovisitors($tovisitors); return $this->_getSpaceDs()->updateInfo($dm); }
/** * 发送动作页面,一般是ajax提交的数据 */ public function sendAction() { $act = $this->getInput('act', 'post'); $uid = $this->getInput('uid', 'post'); if (!$act) { $this->showError('请选择动作'); } if (!$uid) { $this->showError('请选择用户'); } !is_array($uid) && ($uid = array($uid)); Wind::import('EXT:dongta.service.dm.App_Dongta_Dm'); $service = Wekit::load('EXT:dongta.service.App_Dongta'); $users = Wekit::load('user.PwUser')->fetchUserByUid($uid); $actMap = (include Wind::getRealPath('EXT:dongta.conf.dongta.php', true)); $title = '<a href="' . WindUrlHelper::createUrl('space/index/run', array('uid' => $this->loginUser->uid)) . '">' . $this->loginUser->username . '</a> ' . str_replace('{Ta}', '你', $actMap[$act][1]); $content = $title . ' <br>[来自应用 <a href="' . WindUrlHelper::createUrl('app/dongta/index/run') . '">动他一下</a>]'; foreach ($users as $key => $value) { $dm = new App_Dongta_Dm(); $dm->setAct($act)->setTouid($value['uid'])->setCreatedUser($this->loginUser->uid, $this->loginUser->username)->setCreatedTime(Pw::getTime()); $service->add($dm); Wekit::load('message.srv.PwNoticeService')->sendNotice($value['uid'], 'app', 0, array('title' => $title, 'content' => $content)); } $this->showMessage('operate.success'); }
public function afterRegister($userDm) { if ($this->bp->config['type'] != 2) { return false; } /* @var $inviteDs PwInviteCode */ $inviteDs = Wekit::load('invite.PwInviteCode'); if ($this->inviteInfo['created_userid']) { $codeDm = new PwInviteCodeDm(); $codeDm->setInvitedUid($userDm->uid)->setModifiedTime(Pw::getTime())->setIfused(1)->setCode($this->code); //别人赠送的邀请码 $inviteDs->updateCode($codeDm); $creditType = $this->bp->config['invite.reward.credit.type']; $creditNum = $this->bp->config['invite.reward.credit.num']; //邀请人获得加奖励 //[积分日志] 成功邀请好友积分奖励 /* @var $creditBo PwCreditBo */ $creditBo = PwCreditBo::getInstance(); $creditBo->addLog('invite_reward', array($creditType => $creditNum), new PwUserBo($this->inviteInfo['created_userid']), array('friend' => $userDm->getField('username'))); $creditBo->set($this->inviteInfo['created_userid'], $creditType, $creditNum); //邀请成功相互关注 被邀请者关注邀请者 /* @var $attention PwAttentionService */ $attention = Wekit::load('attention.srv.PwAttentionService'); $attention->addFollow($userDm->uid, $this->inviteInfo['created_userid']); // $attention->addFollow($this->inviteInfo['created_userid'], $userDm->uid); } else { $codeDm = new PwInviteCodeDm(); $codeDm->setInvitedUid($userDm->uid)->setIfused(1)->setModifiedTime(Pw::getTime())->setCreateUid($userDm->uid)->setCode($this->code); //自己购买的邀请码 $inviteDs->updateCode($codeDm); } return true; }
/** * 做任务 * * 1、查询当前用户是否有正在进行的任务,没有则不执行 * 2、初始化 * 3、获得用户进行的任务详细信息 * 4、过滤任务中已经过期和关闭的任务,这些任务都不能再被继续完成 * 5、执行任务判断:逐个判断注册过来的任务-将任务的条件和已经完成的step传递给任务:任务判断condition和step,如果step还没有完成则更新该step * * @param string $type 任务类别 后台设置中的“会员”/"论坛“类, * @param string $child 任务类别中的小类, 比如”会员“->'求粉丝' * @return boolean */ public function doTask($type, $child) { if (!$this->doTask) { return false; } $myTasks = $this->_getTaskUserDs()->getMyTaskByStatus($this->uid, 1, $this->num, 0); if (!$myTasks) { return true; } $taskList = $this->_getTaskDs()->gets(array_keys($myTasks)); if (!$taskList) { return true; } $time = Pw::getTime(); foreach ($taskList as $id => $task) { if ($task['end_time'] && $task['end_time'] < $time || $task['is_open'] == 0) { continue; } $conditions = unserialize($task['conditions']); if ($conditions['type'] != $type || $conditions['child'] != $child) { continue; } $myStatus = $myTasks[$id]; $step = unserialize($myStatus['step']); if (!is_array($step)) { $step = $myStatus['step']; } $this->_doTask($task, $conditions, $step); } return true; }
/** * 发送通知 * @param int $uid * @param string $type * @param int $param * @param array $extendParams * @param $updateUnRead 是否更新未读数 */ public function sendNotice($uid, $type, $param = 0, $extendParams = array(), $updateUnRead = true) { $action = $this->_getAction($type); if (!$action) { return new PwError('MESSAGE::notice.type.undefined'); } $typeId = $this->_getTypeId($type); // 看是否发通知 if ($this->_checkPrivate($uid, $typeId) !== true) { return false; } //aggregated notice Wind::import('SRV:message.dm.PwMessageNoticesDm'); $dm = new PwMessageNoticesDm(); $action->aggregate && ($notice = $this->_getNoticesDs()->getNoticeByUid($uid, $typeId, $param)); $extendParams = $action->formatExtendParams($extendParams, $notice); $noticeTitle = $action->buildTitle($param, $extendParams, $notice); $dm->setToUid($uid)->setRead(0)->setType($typeId)->setParam($param)->setExtendParams($extendParams)->setTitle($noticeTitle); if (!$notice) { $noticeId = $this->_getNoticesDs()->addNotice($dm); } else { $dm->setId($notice['id']); $dm->setModifiedTime(Pw::getTime()); $this->_getNoticesDs()->updateNotice($dm); $noticeId = $notice['id']; } //更新通知未读数 if ($updateUnRead && (!$notice || $notice['is_read'])) { Wind::import('SRV:user.dm.PwUserInfoDm'); $dm = new PwUserInfoDm($uid); $dm->addNotice(1); $this->_getUserDs()->editUser($dm, PwUser::FETCH_DATA); } return true; }
/** * 初始化安装程序 */ public function __construct() { $this->_appId = 'L000' . time() . WindUtility::generateRandStr(4); $this->_config = @(include Wind::getRealPath(self::CONF_PATH, true)); $this->tmpPath = Wind::getRealPath($this->getConfig('tmp_dir') . '.' . Pw::getTime(), false); $this->tmpInstallLog = Wind::getRealPath($this->getConfig('log_dir'), false); }
protected function _getActiveUser($fid, $day, $num) { $time = Pw::getTime() - $day * 86400; $array = array(); $thread = Wekit::load('forum.PwThreadExpand')->countUserThreadByFidAndTime($fid, $time, $num); $post = Wekit::load('forum.PwThreadExpand')->countUserPostByFidAndTime($fid, $time, $num); foreach ($thread as $key => $value) { if (!$key) { continue; } $array[$key] = $value['count']; } foreach ($post as $key => $value) { if (!$key) { continue; } if (isset($array[$key])) { $array[$key] += $value['count']; } else { $array[$key] = $value['count']; } } arsort($array); return array_slice($array, 0, $num, true); }
public function gainReward($uid, $reward, $taskname) { $userBo = Wekit::getLoginUser(); list($id) = explode('-', $reward['value'], 2); $time = abs(intval($reward['time'])); /* @var $userBelongDs PwUserBelong */ $userBelongDs = Wekit::load('user.PwUserBelong'); $info = $userBelongDs->getUserBelongs($uid); $_groups = array(); foreach ($info as $_item) { $_groups[$_item['gid']] = $_item['endtime']; } $_groups[$id] = $time ? Pw::getTime() + 24 * 3600 * $time : 0; /* @var $userService PwUserService */ $userService = Wekit::load('user.srv.PwUserService'); list($gid, $groups) = $userService->caculateUserGroupid($userBo->gid, $_groups); $dm = new PwUserInfoDm($uid); $dm->setGroupid($gid)->setGroups($groups); /* @var $userDs PwUser */ $userDs = Wekit::load('user.PwUser'); $result = $userDs->editUser($dm, PwUser::FETCH_MAIN); if ($result instanceof PwError) { return $result; } return true; }
/** * 加入版块 * * @param int $uid * @param int $fid * @param int $time * @return bool */ public function join($uid, $fid, $time = 0) { if (!$uid || !$fid) { return false; } return $this->_getDao()->add(array('uid' => $uid, 'fid' => $fid, 'join_time' => $time ? $time : Pw::getTime())); }
public function editAction() { $tagId = $this->getInput('id', 'Request'); $tagName = $this->getInput('name', 'Request'); $tagType = $this->getInput('type', 'Request'); if ($this->getInput('type', 'post') === 'do') { $tagName = $this->getInput('tagname', 'post'); if (empty($tagName)) { $this->showError('请输入Tag名称'); return; } $hasDuplicate = $this->_getTagDs()->checkDuplicateName($tagName); if ($hasDuplicate) { $this->showError('Tag:' . '"' . $tagName . '"' . '已存在'); return; } $dm = new App_Tag_Dm(); $dm->setTagName($tagName)->setLastUpdateTime(Pw::getTime()); $this->_getTagDs()->update($tagId, $dm); $this->showMessage('更新成功'); } else { $this->setOutput($tagId, 'tagId'); $this->setOutput($tagName, 'tagName'); $this->setOutput($tagType, 'tagType'); } }
public function doSaveInformationAction() { list($openid, $id, $key) = $this->getInput(array('openid', 'pid', 'key')); $this->setOutput($openid, 'openId'); if (!isset($_SESSION)) { @session_start(); } $_SESSION['exchangekey'] = $key; //user validation $userMoney = $this->getUserMoneyByOpenId($openid); if (empty($userMoney) == false && isset($_SESSION['exchangekey'])) { $prize = $this->_getCommonDs()->getPrizeById($id); //check user money if (empty($prize) == false && $prize['dmoney'] <= $userMoney['money']) { $deductDMoeny = 0 - $prize['dmoney']; $isDeduct = $this->_getMyMoneyDS()->updateMyMoney($userMoney['userid'], $deductDMoeny, 0, $prize['name']); if ($isDeduct > 0) { unset($_SESSION['exchangekey']); $this->setOutput($isDeduct, "isDeduct"); } $myMoney = $this->_getMyMoneyDS()->getMyMoney($userMoney['userid']); $this->setOutput($myMoney[0], 'myMoney'); $this->setOutput($prize, "prize"); list($pid, $receiveContactor, $receivePhone, $receiveQQ, $receiveAddress) = $this->getInput(array('pid', 'receiveContactor', 'receivePhone', 'receiveQQ', 'receiveAddress')); $dm = new App_Giftexchange_Dm(); $dm->setUserId($userMoney['userid'])->setContact($receiveContactor)->setPhoneNumber($receivePhone)->setqq($receiveQQ)->setAddress($receiveAddress)->setProductId($prize['id'])->setCreateTime(Pw::getTime()); $saveInfo = $this->_getGiftexchangeDS()->add($dm); $this->setOutput($saveInfo, 'saveInfo'); } } else { $url = WindUrlHelper::createUrl('app/4tmobile/mobilemymoney/run', array('openid' => $openid)); $this->forwardRedirect($url); } }
public function isAllowVote() { if ((!$this->info['poll']['expired_time'] || $this->info['poll']['expired_time'] && $this->info['poll']['expired_time'] > Pw::getTime()) && $this->user->getPermission('allow_participate_vote')) { return true; } return false; }
public function formatExtendParams($extendParams, $aggregatedNotice = null) { $extendParams['condition'] = is_array($extendParams['conditions']) ? $extendParams['conditions'] : unserialize($extendParams['conditions']); $url = $extendParams['condition']['url'] ? $extendParams['condition']['url'] : 'task/index/run'; $array = array('id' => $extendParams['taskid'], 'title' => $extendParams['title'], 'icon' => $extendParams['icon'], 'url' => $url, 'created_time' => Pw::getTime()); $array['complete'] = isset($extendParams['complete']) && $extendParams['complete'] == 1 ? 1 : 0; return $array; }
public function addThread($tid) { $userBo = Wekit::getLoginUser(); $ds = Wekit::load('user.PwUserBehavior'); $time = Pw::getTime(); $ds->replaceBehavior($userBo->uid, 'thread_days', $time); $ds->replaceBehavior($userBo->uid, 'thread_count'); }
/** * 增加单个任务 * * @param int $uid * @return bool */ public function replaceCron($uid) { $uid = intval($uid); if ($uid < 1) { return false; } return $this->_getDao()->replace(array('uid' => $uid, 'created_time' => Pw::getTime())); }
public function welcome(PwuserBo $userBo, $ip) { // $this->_getDs()->deleteByCreatedTime(Pw::getTime()-86400); $this->_getDs()->replaceCron($userBo->uid); $srv = Wekit::load('cron.srv.PwCronService'); $srv->getSysCron('PwCronDoRecommendUser', Pw::getTime()); return true; }
/** * 跟新最后记录 * * @param string $ip ip地址 * @param int $lastDate 更新时间 * @return boolean */ public function updateRecodeByIp($ip, $lastDate) { if (!$ip) { return false; } !$lastDate && ($lastDate = Pw::getTime()); return $this->_getDao()->update($ip, $lastDate); }
/** * 添加日志 * * @param array $fields * @return PwError|Ambigous <boolean, Ambigous, rowCount, number> */ public function add($appId, $logType, $data) { if (!$appId || !$logType) { return new PwError('APPCENTER:validate.fail'); } $fields = array('app_id' => $appId, 'log_type' => $logType, 'data' => serialize($data), 'created_time' => Pw::getTime(), 'modified_time' => Pw::getTime()); return $this->_load()->add($fields); }
/** * 获得出生日期的时间距离 * * @return array array(array(year), array(month), array(day)) */ public static function getBirthDay() { $tyear = date('Y', Pw::getTime()); $year = range($tyear, $tyear - 100, -1); $month = range(1, 12, 1); $day = range(1, 31); return array($year, $month, $day); }
public function __construct() { $config = Wekit::C('site'); $this->time = Pw::getTime(); $this->isVisitorTime = 1; $this->spaceTime = 10; $this->offlineTime = $config['onlinetime'] * 60; }
private function _collectLoginSessionGarbage() { $gcDivisor = 100; $gcProbability = 1; $time = Pw::getTime(); if (rand(1, $gcDivisor) <= $gcProbability) { $this->_getLoginSessionDs()->deleteByExpire($time); } }
public function gleanData($value) { $dm = new PwReplyRecycleDm(); $dm->setPid($value['pid'])->setTid($value['tid'])->setFid($value['fid'])->setOperateTime(Pw::getTime())->setOperateUsername($this->srv->user->username)->setReason($this->srv->reason); $this->record[] = $dm; if ($value['disabled'] == 0) { $this->tids[$value['tid']]++; } }
/** * 添加用户标签 */ public function doAddByidAction() { $tagid = $this->getInput('tagid'); $result = $this->_getService()->addTagRelationWithTagid($this->loginUser->uid, $tagid, Pw::getTime()); if ($result instanceof PwError) { $this->showError($result->getError()); } $this->showMessage('USER:tag.add.success'); }
public function setUptime($uptime) { if ($uptime) { $this->uptime = Pw::getTime() + intval($uptime) * 3600; } else { $this->uptime = Pw::getTime(); } return $this; }
public function getMyAnnounceBySchoolIdAction() { $schoolid = $this->getInput('schoolid', 'get'); if (empty($schoolid)) { $this->output(-1); return; } $result = $this->_getPwAnnounceDs()->getAnnounceBySchoolId($schoolid, Pw::str2time(Pw::time2str(Pw::getTime(), 'Y-m-d')), 9, 0); $this->output($result); }
/** * 检查教育时间是否非法 * * @param int $year * @return int */ public static function checkEducationYear($year) { $endYear = Pw::time2str(Pw::getTime(), 'Y'); if ($year > $endYear) { $year = $endYear; } elseif ($year < $endYear - 100) { $year = $endYear - 100; } return $year; }
public static function makePassKey($user) { $passkey = sha1($user->uid . $user->username . Pw::getTime()); $u = Wekit::load('EXT:torrent.service.PwTorrentUser')->getTorrentUserByPasskey($passkey); if (!empty($u)) { return self::makePassKey($user); } else { return $passkey; } }