/** * 格式化时间 * @param int $time */ protected final function _formatTime($time) { if (!$time) { return ''; } return $this->_viewSet['timefmt'] ? Pw::time2str($time, $this->_viewSet['timefmt']) : Pw::time2str($time, 'auto'); }
/** * 根据用户的行为数据分析并发送自动任务 * * @param array $behavior * @return boolean */ public function sendAutoTask($behavior) { if (!Wekit::C('site', 'task.isOpen')) { return false; } $whitBehavior = array('login_days', 'post_days', 'thread_count'); if (!in_array($behavior['behavior'], $whitBehavior)) { return false; } $tody = Pw::time2str(Pw::getTime(), 'Y-m-d'); $isSend = false; switch ($behavior['behavior']) { case 'login_days': $isSend = $behavior['number'] % 3 == 0; break; case 'post_days': $is_tody = $tody == Pw::time2str($behavior['extend_info'], 'Y-m-d'); $isSend = $is_tody && $behavior['number'] % 2 == 0; break; case 'thread_count': $isSend = $behavior['number'] == 1 || $behavior['number'] % 50 == 0; break; } if (!$isSend) { return false; } Wind::import('SRV:task.srv.PwTaskApply'); $userTask = new PwTaskApply($behavior['uid']); $userTask->autoApplies($this->getAutoApplicableTaskList($behavior['uid'], 1)); return true; }
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; }
/** * 通过公告记录组装前台显示效果 * 帖子列表滚动展示标题用 * * @return array */ public function getAnnounceForBbsScroll() { $announces = array(); $announceInfos = $this->_getPwAnnounceDs()->getAnnounceByTimeOrderByVieworder(Pw::str2time(Pw::time2str(Pw::getTime(), 'Y-m-d')), 9, 0); foreach ($announceInfos as $value) { $announces[$value['aid']] = $value; $announces[$value['aid']]['start_date'] = Pw::time2str($value['start_date'], 'Y-m-d'); if (Pw::strlen($value['subject']) > 18) { $announces[$value['aid']]['subject'] = Pw::substrs($value['subject'], 18); } } return $announces; }
/** * 发帖页我的草稿 * * @return void */ public function myDraftsAction() { $drafts = $this->_getDraftDs()->getByUid($this->loginUser->uid, $this->maxNum); $data = array(); foreach ($drafts as $v) { $_tmp['id'] = $v['id']; $_tmp['title'] = $v['title']; $_tmp['content'] = $v['content']; $_tmp['created_time'] = Pw::time2str($v['created_time'], 'auto'); $data[] = $_tmp; } echo Pw::jsonEncode(array('state' => 'success', 'data' => $data)); exit; }
public function run() { $aid = $this->getInput('aid', 'get'); $page = $this->getInput('page'); $this->page = $page < 1 ? 1 : intval($page); list($start, $limit) = Pw::page2limit($this->page, $this->perpage); $total = $this->_getPwAnnounceDs()->countAnnounceByTime(Pw::str2time(Pw::time2str(Pw::getTime(), 'Y-m-d'))); $list = $total ? $this->_getPwAnnounceService()->formatAnnouncesUsername($this->_getPwAnnounceDs()->getAnnounceByTimeOrderByVieworder(Pw::str2time(Pw::time2str(Pw::getTime(), 'Y-m-d')), $limit, $start)) : array(); $this->setOutput($total, 'total'); $this->setOutput($list, 'list'); $this->setOutput($aid, 'aid'); $this->setOutput($this->page, 'page'); $this->setOutput($this->perpage, 'perpage'); }
/** * 空间首页列出审核过的贴子 * * @access public * @return void */ public function run() { $spaceUid = $this->getInput('uid', 'get'); $page = $this->getInput('page', 'get'); // $space = new PwSpaceModel($spaceUid); $space->setTome($spaceUid, $this->uid); // $tids = $this->_getPwNativeThreadDs()->getThreadListByUid($spaceUid, $page, $this->uid == $spaceUid ? 'my' : 'space'); $myThreadList = $this->_getPwNativeThreadDs()->getThreadContent($tids); //pids 默认是0; $attList = $this->_getPwNativeThreadDs()->getThreadAttach($tids, array(0)); $threadList = $this->_getPwNativeThreadDs()->gather($myThreadList, $attList); // $prev_val = ''; $_tids = $_threadList = array(); foreach ($threadList as $k => $v) { $_created_time = Pw::time2str($v['created_time'], 'auto'); list($_key, $_time) = explode(' ', $_created_time); if (!preg_match('/-/', $_created_time)) { $_key = '今天'; } if ($prev_val != $_key) { $threadList[$k]['barName'] = $_key; $prev_val = $_key; } else { $threadList[$k]['barName'] = ''; } $_threadList[] = $threadList[$k]; $_tids[] = $v['tid']; } //获得登陆用户是否喜欢过帖子|回复 $threadLikeData = array(); if ($this->uid && $_tids) { $_threadLikeData = $this->_getLikeReplyService()->getAllLikeUserids(PwLikeContent::THREAD, $_tids); foreach ($_tids as $v) { if (isset($_threadLikeData[$v])) { $threadLikeData[$v] = array_search($this->uid, $_threadLikeData[$v]) === false ? 0 : 1; } } } //帖子发布来源 $threadFromtypeList = $this->_getThreadsPlaceService()->getThreadFormTypeByTids($_tids); $location_text = Wekit::loadDao('native.dao.PwNativeThreadsDao')->getCityByUid($spaceUid); $location_text || ($location_text = Wekit::loadDao('native.dao.PwPostsPlaceDao')->getCityByUid($spaceUid)); $location_text || ($location_text = $space->spaceUser['location_text']); $data = array('uid' => $this->uid, 'userInfo' => isset($space->spaceUser) ? array('username' => $space->spaceUser['username'], 'gender' => $space->spaceUser['gender'], 'location_text' => $location_text, 'avatar' => Pw::getAvatar($spaceUid), 'attentionNum' => $space->spaceUser['follows'], 'fansNum' => $space->spaceUser['fans']) : array('username' => '', 'gender' => 0, 'location_text' => '', 'avatar' => '', 'attentionNum' => 0, 'fansNum' => 0), 'tome' => isset($space->tome) ? $space->tome : 0, 'pageCount' => $this->_getPwNativeThreadDs()->getThreadPageCount(), 'threadList' => $_threadList, 'threadFromtypeList' => $threadFromtypeList); $this->setOutput($data, 'data'); $this->showMessage('success'); }
public function getUrl(PwPayVo $vo) { strlen($this->bill) == 11 && ($this->bill .= '01'); $param = array('inputCharset' => $this->charset == 'gbk' ? 2 : 1, 'pageUrl' => $this->baseurl, 'version' => 'v2.0', 'language' => 1, 'signType' => 1, 'merchantAcctId' => $this->bill, 'payerName' => 'admin', 'orderId' => $vo->getOrderNo(), 'orderAmount' => $vo->getFee() * 100, 'orderTime' => Pw::time2str(Pw::getTime(), 'YmdHis'), 'productName' => $vo->getBody(), 'productNum' => 1, 'payType' => '00', 'redoFlag' => 1); $url = $this->bill_url; $arg = ''; foreach ($param as $key => $value) { $value = trim($value); if (strlen($value) > 0) { $arg .= "{$key}={$value}&"; $url .= "{$key}=" . urlencode($value) . "&"; //$inputMsg .= "<input type=\"hidden\" name=\"$key\" value=\"$value\" />"; } } $url .= 'signMsg=' . strtoupper(md5($arg . 'key=' . $this->bill_key)); return $url; }
/** * 编辑用户信息 * * @return void */ public function editAction() { $uid = (int) $this->getInput('uid', 'get'); $user = Windid::load('user.WindidUser'); $_info = $user->getUserByUid($uid, WindidUser::FETCH_ALL); if (!$_info) { $this->showError('WINDID:fail'); } $tYear = Pw::time2str(Pw::getTime(), 'Y'); $birMin = $tYear - 100; $birMax = $tYear + 100; $this->setOutput($this->_buildArea($_info['location']), 'location'); $this->setOutput($this->_buildArea($_info['hometown']), 'hometown'); $this->setOutput($birMin . '-01-01', 'bmin'); $this->setOutput($birMax . '-12-31', 'bmax'); $this->setOutput($_info, 'info'); $this->setOutput($_info['online'] / 3600, 'online'); }
public function welcome(PwUserBo $userBo, $ip) { if (!Wekit::C('site', 'task.isOpen')) { return true; } /* @var $behaviorDs PwUserBehavior */ $behaviorDs = Wekit::load('user.PwUserBehavior'); $info = $behaviorDs->getBehavior($userBo->uid, 'login_days'); $time = $info['extend_info'] ? $info['extend_info'] : 0; if (!$time || Pw::time2str($time, 'Y-m-d') < Pw::time2str(Pw::getTime(), 'Y-m-d')) { /* @var $taskService PwTaskService */ $taskService = Wekit::load('SRV:task.srv.PwTaskService'); $userTask = new PwTaskApply($userBo->uid); $autoTaskIds = $taskService->getAutoApplicableTaskList($userBo->uid, 5); $userTask->autoApplies($autoTaskIds); } return true; }
public function run() { $aid = $this->getInput('id', 'get'); $this->setOutput($aid, 'id'); $pagetag = $this->getInput('pagetag', 'get'); $this->setOutput($pagetag, 'pagetag'); $schoolid = $this->getCurrentSchoolId(); if (empty($pagetag)) { $info = $this->_getPwAnnounceDs()->getAnnounce($aid); } else { $info = $this->_getPwAnnounceDs()->getAnnouncePageTurn($schoolid, $aid, $pagetag); } $currentime = time(); $this->setOutput($currentime, 'currentime'); $this->setOutput(Pw::time2str($info['start_date'], 'Y-m-d'), 'startdate'); $this->setOutput(Pw::time2str($info['end_date'], 'Y-m-d'), 'enddate'); $this->setOutput($info, 'schoolAnnounceInfo'); }
/** * 清除三个月前操作 */ public function clearAction() { if (!$this->isFounder($this->adminUser->getUsername())) { $this->showError('fail'); } $step = $this->getInput('step', 'post'); if ($step != 2) { $this->showError('fail'); } list($year, $month) = explode('-', Pw::time2str(Pw::getTime(), 'Y-n')); if ($month > 3) { $month = $month - 3; } else { $month = 9 - $month; $year = $year - 1; } Wekit::load('log.PwLoginLog')->clearLogBeforeDatetime(Pw::str2time($year . '-' . $month . '-1')); $this->showMessage('success'); }
public function run() { if ($this->regist['type'] != 2) { $this->forwardRedirect(WindUrlHelper::createUrl('my/invite/inviteFriend')); // $this->showError('USER:invite.close'); } Wind::import('SRV:credit.bo.PwCreditBo'); /* @var $pwCreditBo PwCreditBo */ $pwCreditBo = PwCreditBo::getInstance(); $startTime = Pw::str2time(Pw::time2str(Pw::getTime(), 'Y-m-d')); $readyBuy = $this->_getDs()->countByUidAndTime($this->loginUser->uid, $startTime); $gidLimit = abs(ceil($this->loginUser->getPermission('invite_limit_24h'))); $price = abs(ceil($this->loginUser->getPermission('invite_buy_credit_num'))); $_tmpId = $this->regist['invite.credit.type']; $_credit = array('id' => $_tmpId, 'name' => $pwCreditBo->cType[$_tmpId], 'unit' => $pwCreditBo->cUnit[$_tmpId]); $this->setOutput($_credit, 'creditWithBuy'); //用于购买的积分信息 $_tmpId = $this->regist['invite.reward.credit.type']; $_credit = array('id' => $_tmpId, 'name' => $pwCreditBo->cType[$_tmpId], 'unit' => $pwCreditBo->cUnit[$_tmpId]); $this->setOutput($_credit, 'rewardCredit'); //奖励的积分信息 $this->setOutput($readyBuy > $gidLimit ? 0 : $gidLimit - $readyBuy, 'canBuyNum'); //还能购买的邀请数 $this->setOutput($price, 'pricePerCode'); //每个邀请码需要积分的单价 $this->setOutput($this->loginUser->info['credit' . $this->regist['invite.credit.type']], 'myCredit'); //我拥有的积分 $this->setOutput($this->regist['invite.reward.credit.num'], 'rewardNum'); //奖励积分数 $this->setOutput($this->regist['invite.expired'], 'codeExpired'); //邀请码有效期 $this->setOutput($this->loginUser->getPermission('invite_allow_buy'), 'canInvite'); //该用户组是否可以购买邀请码 $this->setOutput($this->regist['invite.pay.money'], 'money'); $this->setOutput(false, 'canBuyWithMoney'); $this->listCode(); // seo设置 Wind::import('SRV:seo.bo.PwSeoBo'); $seoBo = PwSeoBo::getInstance(); $lang = Wind::getComponent('i18n'); $seoBo->setCustomSeo($lang->getMessage('SEO:bbs.invite.run.title'), '', ''); Wekit::setV('seo', $seoBo); }
/** * 整理合并贴子内容 * * @param mixed $tids * @param mixed $pids * @access public * @return void */ public function gather($threadList, $attList) { if (!is_array($threadList) || !is_array($attList)) { return array(); } foreach ($threadList as $key => $thread) { $pic_key = $thread['tid'] . '_0'; $threadList[$key]['pic'] = isset($attList[$pic_key]) ? $attList[$pic_key] : array(); //列表数据,过滤掉图片及附件url等标签 $_shareData = Pw::formatContent($threadList[$key]['content']); $threadList[$key]['share'] = $_shareData['share']; $threadList[$key]['content'] = preg_replace('/(\\[)[^\\]]*$/i', '', mb_substr($_shareData['content'], 0, 90)); //截字并修正表情标签 // $threadList[$key]['created_user_avatar'] = Pw::getAvatar($threadList[$key]['created_userid'], ''); // $threadList[$key]['lastpost_time'] = Pw::time2str($threadList[$key]['lastpost_time'], 'auto'); } krsort($threadList, SORT_NUMERIC); return $threadList; }
public function recordAction() { list($tid, $pid, $page) = $this->getInput(array('tid', 'pid', 'page')); $perpage = 10; $page < 1 && ($page = 1); list($offset, $limit) = Pw::page2limit($page, $perpage); $count = Wekit::load('forum.PwThreadBuy')->countByTidAndPid($tid, $pid); if (!$count) { $this->showError('BBS:thread.buy.error.norecord'); } Wind::import('SRV:credit.bo.PwCreditBo'); $record = Wekit::load('forum.PwThreadBuy')->getByTidAndPid($tid, $pid, $limit, $offset); $users = Wekit::load('user.PwUser')->fetchUserByUid(array_keys($record)); $data = array(); $cType = PwCreditBo::getInstance()->cType; foreach ($record as $key => $value) { $data[] = array('uid' => $value['created_userid'], 'username' => $users[$value['created_userid']]['username'], 'cost' => $value['cost'], 'ctype' => $cType[$value['ctype']], 'created_time' => Pw::time2str($value['created_time'])); } $totalpage = ceil($count / $perpage); $nextpage = $page + 1; $nextpage = $nextpage > $totalpage ? $totalpage : $nextpage; $this->setOutput(array('data' => $data, 'totalpage' => $totalpage, 'page' => $nextpage), 'data'); $this->showMessage('success'); }
/** * 获取附件上传时存储在本地的文件地址 * * @param string $filename 文件名 * @param string $dir 目录名 * @return string */ public function getAbsolutePath($filename, $dir) { return DATA_PATH . 'upload/' . Pw::time2str(WEKIT_TIMESTAMP, 'j') . '/' . str_replace('/', '_', $dir) . $filename; }
public static function makePassKey($user) { return sha1($user->username . Pw::time2str(Pw::getTime(), 'Y-m-d H:i:s') . $user->info['password']); }
/** * 更新成功后备份 * * @return multitype:string */ private function _backSuccess() { $data_dir = Wind::getRealDir('DATA:'); $suffix = '[' . Pw::time2str(WEKIT_TIMESTAMP, 'Y-m-d Hi') . ']'; $up_source = $data_dir . 'upgrade'; $up_target = $data_dir . 'upgrade' . $suffix; PwApplicationHelper::copyRecursive($up_source, $up_target); $status = Wekit::cache()->get('system_upgrade'); $ba_source = $data_dir . 'backup' . DIRECTORY_SEPARATOR . 'phpwind_' . str_replace('.', '', $status['oldversion']) . '_' . $status['oldrelease']; $ba_target = $data_dir . 'backup' . $suffix; PwApplicationHelper::copyRecursive($ba_source, $ba_target); WindFolder::clearRecur($up_source, true); WindFolder::clearRecur($ba_source, true); return array($up_target, $ba_target); }
/** * 生成文件前缀 * * @return string */ public function getDirectoryName() { $version = str_replace('.', '-', $this->_version); //return 'pw_' . $version . '_' . Pw::time2str(Pw::getTime(), 'YmdHis') . '_' . WindUtility::generateRandStr(5); return WindUtility::generateRandStr(8) . '_pw_' . $version . '_' . Pw::time2str(Pw::getTime(), 'YmdHis'); }
private function _getBehavior($time, $number) { $time = $time + 86400 * 2; $time = Pw::str2time(Pw::time2str($time, 'Y-m-d')); if ($time > 0 && $time < Pw::getTime()) { $number = 0; } return $number; }
public function install($patch) { $tmpfiles = $this->bakFiles = array(); WindFolder::mkRecur($this->tmpPath); if ($this->ftp && !is_object($this->ftp)) { try { $this->ftp = $this->ftp['sftp'] ? new PwSftpSave($this->ftp) : new PwFtpSave($this->ftp); } catch (WindFtpException $e) { return false; } } foreach ($patch['rule'] as $rule) { $rule['filename'] = $this->sortFile($rule['filename']); $filename = ROOT_PATH . $rule['filename']; $search = base64_decode($rule['search']); $replace = base64_decode($rule['replace']); $count = $rule['count']; $nums = $rule['nums']; $str = WindFile::read($filename); $realCount = substr_count($str, $search); if ($realCount != $count) { return new PwError('APPCENTER:upgrade.patch.update.fail', array($patch['id'])); } $bakfile = basename($rule['filename']) . '.' . Pw::time2str(WEKIT_TIMESTAMP, 'Ymd') . '.bak'; $bakfile = $this->ftp ? dirname($rule['filename']) . '/' . $bakfile : dirname($filename) . '/' . $bakfile; $tmpfile = tempnam($this->tmpPath, 'patch'); $replacestr = PwSystemHelper::replaceStr($str, $search, $replace, $count, $nums); WindFile::write($tmpfile, $replacestr); if ($this->ftp) { try { $this->ftp->upload($filename, $bakfile); $this->ftp->upload($tmpfile, $rule['filename']); } catch (WindFtpException $e) { return false; } } else { if (!@copy($filename, $bakfile)) { return new PwError('APPCENTER:upgrade.copy.fail', array($rule['filename'])); } if (!@copy($tmpfile, $filename)) { return new PwError('APPCENTER:upgrade.copy.fail', array($rule['filename'])); } } $tmpfiles[] = $tmpfile; $this->bakFiles[] = $bakfile; } $this->_ds()->addLog($patch['id'], $patch, 2); return true; }
/** * 获得信息的标题和内容 * * @param string $titleKey 标题key * @param string $contentKey 内容key * @param string $username 用户名 * @param string $url 链接地址 * @return array */ private function _buildTitleAndContent($titleKey, $contentKey, $username, $url = '') { $search = array('{username}', '{sitename}'); $replace = array($username, Wekit::C('site', 'info.name')); $title = str_replace($search, $replace, $this->config[$titleKey]); $search[] = '{time}'; $search[] = '{url}'; $replace[] = Pw::time2str(Pw::getTime(), 'Y-m-d H:i:s'); $replace[] = $url ? sprintf('<a href="%s">%s</a>', $url, $url) : ''; $content = str_replace($search, $replace, $this->config[$contentKey]); return array($title, $content); }
/** * 获取列表页展示的帖子数据 */ public function fetchThreadsList($tids, $uid = 0, $result_type = 'ASSOC') { if (!$tids) { return array(); } Wind::import('SRV:like.PwLikeContent'); $threads = Wekit::loadDao('native.dao.PwNativeThreadsDao')->fetchThreads($tids); $threads_place = Wekit::loadDao('native.dao.PwThreadsPlaceDao')->fetchByTids($tids); $threads_content = Wekit::loadDao('forum.dao.PwThreadsContentDao')->fetchThread($tids); $PwThreadService = Wekit::load('forum.srv.PwThreadService'); $PwNativeThreadService = Wekit::load('native.PwNativeThread'); $threadLikeData = Wekit::load('like.srv.reply.do.PwLikeDoReply')->getAllLikeUserids(PwLikeContent::THREAD, $tids); foreach ($threadLikeData as $k => $v) { if (!in_array($uid, $v)) { unset($threadLikeData[$k]); } } $tag_names_str = ''; foreach ($threads as $k => $v) { $content = isset($threads_content[$k]['content']) ? $threads_content[$k]['content'] : ''; $threads[$k]['tags'] = $threads[$k]['tags_origin'] = isset($threads_content[$k]['tags']) ? $threads_content[$k]['tags'] : ''; $threads[$k]['from_type'] = isset($threads_place[$k]['from_type']) ? $threads_place[$k]['from_type'] : 0; $threads[$k]['created_address'] = isset($threads_place[$k]['created_address']) ? $threads_place[$k]['created_address'] : ''; $threads[$k]['area_code'] = isset($threads_place[$k]['area_code']) ? $threads_place[$k]['area_code'] : ''; $threads[$k]['tags'] && ($tag_names_str .= ',' . $threads[$k]['tags']); $threads[$k]['avatar'] = Pw::getAvatar($v['created_userid'], 'small'); $threads[$k]['created_time'] = Pw::time2str($v['created_time'], 'auto'); $threads[$k]['lastpost_time'] = Pw::time2str($v['lastpost_time'], 'auto'); preg_match("/\\[mp3.*?\\].*?\\[\\/mp3\\]/i", $content, $matches); $threads[$k]['have_mp3'] = $matches ? true : false; preg_match("/\\[flash.*?\\].*?\\[\\/flash\\]/i", $content, $matches); $threads[$k]['have_flash'] = $matches ? true : false; $format_content = Pw::formatContent($content); //格式化移动端帖子内容去除ubb标签、分享链接内容、推广链接内容 $threads[$k]['isliked'] = isset($threadLikeData[$k]) ? true : false; $imgs = array_shift($PwNativeThreadService->getThreadAttach(array($k), array(0))); ksort($imgs); $imgs = array_slice($imgs, 0, 9); foreach ($imgs as $imgs_k => $imgs_v) { $imgs[$imgs_k]['realpath'] = str_replace("/thumb/mini", "", $imgs_v['path']); } $threads[$k]['content'] = array('text' => preg_replace('/(\\[)[^\\]]*$/i', '', Pw::substrs($format_content['content'], 70, 0, false)), 'imgs' => $imgs, 'share' => $format_content['share'], 'origin_content' => $content, 'format_content' => $format_content); } $tag_names_arr = array_unique(explode(',', trim($tag_names_str, ','))); $tag_names = Wekit::loadDao('tag.dao.PwTagDao')->getTagsByNames($tag_names_arr); // var_dump($tag_names);exit; foreach ($threads as $k => $v) { if ($v['tags']) { $tag_arr = explode(',', $v['tags']); $tag_tmp = array(); foreach ($tag_arr as $name) { array_key_exists($name, $tag_names) && ($tag_tmp[] = array('tag_id' => $tag_names[$name]['tag_id'], 'tag_name' => $name)); } $threads[$k]['tags'] = $tag_tmp; } } $threads_tmp = array(); $sort_num = 0; if ($result_type == 'ASSOC') { //按照tids的顺序重新排序结果集,tid作为索引 foreach ($tids as $v) { if (isset($threads[$v])) { $threads_tmp[$v] = $threads[$v]; $threads_tmp[$v]['sort'] = $sort_num++; } } } else { //tid会有重复的情况,置顶帖在列表中显示2次,数字顺序索引 foreach ($tids as $v) { if (isset($threads[$v])) { $threads[$v]['sort'] = $sort_num++; $threads_tmp[] = $threads[$v]; } } } // print_r($threads_tmp);exit; return $threads_tmp; }
protected function _getHighlightManage($manage) { Wind::import('SRV:forum.srv.manage.PwThreadManageDoHighlight'); $do = new PwThreadManageDoHighlight($manage); if (!$this->doAction) { if ($this->singleData) { Wind::import("LIB:utility.PwHighlight"); $hightlight = new PwHighlight(); $hightlightStyle = $hightlight->parseHighlight($this->singleData['highlight']); $overtime = Wekit::load('forum.PwOvertime')->getOvertimeByTidAndType($this->singleData['tid'], 'highlight'); $hightlightOvertime = $overtime && $overtime['overtime'] ? Pw::time2str($overtime['overtime'], 'Y-m-d') : ''; } else { $hightlightStyle = array('color' => '#F50'); $hightlightOvertime = ''; } $this->setOutput($hightlightStyle, 'hightlightStyle'); $this->setOutput($hightlightOvertime, 'hightlightOvertime'); } else { list($bold, $italic, $underline, $color, $highlightOvertime) = $this->getInput(array('bold', 'italic', 'underline', 'color', 'highlight_overtime'), 'post'); Wind::import("LIB:utility.PwHighlight"); $hightlight = new PwHighlight(); $hightlight->setColor($color); $hightlight->setBold($bold); $hightlight->setItalic($italic); $hightlight->setUnderline($underline); $do->setHighlight($hightlight->getHighlight()); $do->setOvertime($highlightOvertime); $do->setReason($this->getInput('reason', 'post')); if (!$color && !$bold && !$italic && !$underline) { $this->doCancel[] = 'dohighlight'; } } return $do; }
/** * 允许数据更新的时间 * * @return 允许更新的开始时间,允许更新的结束时间,更新的时间 * */ public function refreshTime($time) { $expired = $this->getCache(); if ($expired['expired'] < 1) { return array($time, 0, 0); } list($y, $m, $d) = explode('-', Pw::time2str($time, 'Y-m-d')); $start = Pw::str2time($y . '-' . $m . '-' . $d . ' ' . $expired['start_hour'] . ':' . $expired['start_minute'] . ':0'); if ($expired['end_hour'] < $expired['start_hour']) { $d++; } $end = Pw::str2time($y . '-' . $m . '-' . $d . ' ' . $expired['end_hour'] . ':' . $expired['end_minute'] . ':0'); if ($start == $end) { $end += 86400; } if ($time < $start) { $refreshTime = $start; } elseif ($time > $start && $time < $end) { $refreshTime = $time + (int) $expired['expired'] * 60; } else { $refreshTime = $start + 86400; } return array($start, $end, $refreshTime); }
/** * 判断当前的时间,是否在允许的时间段内 * * @param int $startHour 开始时间/小时 * @param int $startMin 开始时间/分钟 * @param int $endHour 结束时间/小时 * @param int $endMin 结束时间/分钟 * @return bool */ public static function inTime($startHour, $startMin, $endHour, $endMin) { list($currentHour, $currentMin) = explode(':', Pw::time2str(Pw::getTime(), 'H:i')); $startTime = self::times($startHour, $startMin); $endTime = self::times($endHour, $endMin); $currentTime = self::times($currentHour, $currentMin); if ($startTime == $endTime && $currentTime != $startTime) { return false; } if ($startTime < $endTime && $currentTime < $startTime || $currentTime > $endTime) { return false; } if ($startTime > $endTime && $currentTime > $endTime && $currentTime < $startTime) { return false; } return true; }
/** * 设置公告发布时间 * * @param int $startDate * @return object */ public function setStartDate($startDate) { $time = $startDate ? Pw::str2time($startDate) : Pw::str2time(Pw::time2str(Pw::getTime(), 'Y-m-d')); $this->_data['start_date'] = (int) $time; return $this; }
/** * 编辑公告 * * @return void */ public function updateAction() { $showType = array(); $aid = $this->getInput('aid', 'get'); if ($aid < 1) { $this->showError('ADMIN:fail'); } $announceInfo = $this->_getPwAnnounceDs()->getAnnounce($aid); $announceInfo['start_date'] && ($announceInfo['start_date'] = Pw::time2str($announceInfo['start_date'], 'Y-m-d')); $announceInfo['end_date'] && ($announceInfo['end_date'] = Pw::time2str($announceInfo['end_date'], 'Y-m-d')); $showType[$announceInfo['typeid']] = 'checked'; $this->setOutput($announceInfo, 'announceInfo'); $this->setOutput($showType, 'showType'); }
public function createOrderNo() { return '3' . str_pad(Wekit::getLoginUser()->uid, 10, "0", STR_PAD_LEFT) . Pw::time2str(Pw::getTime(), 'YmdHis') . WindUtility::generateRandStr(5); }