/** * 获取伪静态设置的扩展 * * @return mixed */ public function getRewriteAddOns() { $r = @(include Wind::getRealPath("APPS:rewrite.conf.rewrite.php", true)); $r || ($r = array()); $r = PwSimpleHook::getInstance('rewrite_config')->runWithFilters($r); return $r; }
/** * 退出系统 * * @return boolean */ public function logout() { $loginUser = Wekit::getLoginUser(); PwSimpleHook::getInstance('PwUserService_logout')->runDo($loginUser); $loginUser->reset(); return Pw::setCookie('winduser', '', -1); }
public function deleteEmotionByCatid($cateId) { $sql = $this->_bindTable('DELETE FROM %s WHERE category_id=?'); $smt = $this->getConnection()->createStatement($sql); $smt->update(array($cateId)); PwSimpleHook::getInstance('PwEmotionDao_deleteEmotionByCatid')->runDo($cateId); return true; }
/** * 获取seo配置 * * @return array */ public function getConfig() { if ($this->config !== null) { return $this->config; } $this->config = @(include Wind::getRealPath('APPS:seo.conf.seoExtends')); $this->config = PwSimpleHook::getInstance('seo_config')->runWithFilters($this->config); return $this->config; }
/** * 设置用户组权限 * * @param PwUserPermissionDm $dm * @return bool */ public function setPermission(PwUserPermissionDm $dm) { if (!($data = $dm->getData())) { return false; } $result = $this->_getGroupPermissionDao()->setGroupPermission($data); PwSimpleHook::getInstance('PwUserGroupPermission_update')->runDo($dm); return $result; }
/** * 后台设置-水印策略设置 */ public function setAction() { $config = Wekit::C()->getValues('attachment'); $this->setOutput($config, 'config'); //扩展:key => title $watermarkExt = array('bbs' => '论坛图片上传'); $watermarkExt = PwSimpleHook::getInstance('attachment_watermark')->runWithFilters($watermarkExt); $this->setOutput($watermarkExt, 'watermarkExt'); }
/** * 站点设置 * * @return void */ public function setAction() { $config = Wekit::C()->getValues('verify'); $this->setOutput($config, 'config'); //扩展:key => title $verifyExt = array(); $verifyExt = PwSimpleHook::getInstance('verify_showverify')->runWithFilters($verifyExt); $this->setOutput($verifyExt, 'verifyExt'); }
/** * 返回附件存储类型 * * @return array */ public function getStorages() { $conf = Wind::getRealPath('APPS:config.conf.storages.php', true); $tmp = array('name' => '', 'alias' => '', 'managelink' => '', 'description' => '', 'components' => array()); $storages = @(include $conf); $storages = PwSimpleHook::getInstance('PwAttacmentService_getStorages')->runWithFilters($storages); foreach ($storages as $key => $value) { $storages[$key] = array_merge($tmp, $value); } return $storages; }
private function __construct() { $config = (include Wind::getRealPath($this->_config, true)); $config = PwSimpleHook::getInstance('PwCreditOperationConfig')->runWithFilters($config); foreach ($config as $key => $value) { if ($value[1] && $value[3]) { $this->_map[$value[1]][] = $key; } } $this->_data = $config; }
public function replaceInfo($data) { if (!($data = $this->_filterStruct($data))) { return false; } if (!$data['uid'] || !$data['behavior']) { return false; } $sql = $this->_bindSql('REPLACE INTO %s SET %s', $this->getTable(), $this->sqlSingle($data)); $r = $this->getConnection()->execute($sql); PwSimpleHook::getInstance('PwUserBehaviorDao_replaceInfo')->runDo($data); return $r; }
/** * 添加一条微博评论 * * @param object $dm PwWeiboCommnetDm * @return bool|PwError */ public function addComment(PwWeiboCommnetDm $dm, PwUserBo $user) { if (($result = $this->_getDs()->addComment($dm)) instanceof PwError) { return $result; } Wind::import('SRV:weibo.dm.PwWeiboDm'); $weibo_id = $dm->getField('weibo_id'); $dm1 = new PwWeiboDm($weibo_id); $dm1->addComments(1); $this->_getDs()->updateWeibo($dm1); PwSimpleHook::getInstance('weibo_addComment')->runDo($result, $dm, $user); return $result; }
/** * 验证验证码 * */ public function checkVerify($mobile, $inputCode) { if (!$mobile || !$inputCode) { return new PwError('USER:mobile.code.mobile.empty'); } $info = $this->_getDs()->getMobileVerify($mobile); if (!$info) { return new PwError('USER:mobile.code.error'); } if ($info['expired_time'] < Pw::getTime()) { return new PwError('USER:mobile.code.expired_time.error'); } if ($inputCode !== $info['code']) { return new PwError('USER:mobile.code.error'); } // 手机验证通过后扩展 PwSimpleHook::getInstance('PwMobileService_checkVerify')->runDo($mobile); return true; }
/** * 获得菜单列表 * * @return array */ private function registerMenus() { if (!empty($this->extend)) { return $this->extend; } $menus = $this->_getFromFile(); $menus = PwSimpleHook::getInstance('profile_menus')->runWithFilters($menus); $_menus = array(); foreach ($menus['profile_left'] as $key => $value) { null == $this->first && ($this->first = $key); if (isset($value['tabs']) && $value['tabs'] && isset($menus[$key . '_tabs'])) { $value['tabs'] = $menus[$key . '_tabs']; } else { $value['tabs'] = array(); } $_menus[$key] = $value; } $this->extend = $_menus; return $this->extend; }
public function doavatarAction() { $uid = (int) $this->getInput('uid', 'get'); Wind::import('WINDID:service.upload.action.WindidAvatarUpload'); Wind::import('WINDID:service.upload.WindidUpload'); $bhv = new WindidAvatarUpload($uid); $upload = new WindidUpload($bhv); if (($result = $upload->check()) === true) { $result = $upload->execute(); } if ($result !== true) { $array = array("isSuccess" => false, "msg" => WindConvert::convert('上传失败', 'utf8', Wekit::app()->charset), "erCode" => "000"); //$this->showMessage($result->getMessage()); } else { //用户上传头像之后的钩子 PwSimpleHook::getInstance('update_avatar')->runDo($uid); $array = array("isSuccess" => true, "msg" => WindConvert::convert('上传成功', 'utf8', Wekit::app()->charset), "erCode" => "000"); } echo WindJson::encode($array, Windid::client()->clientCharser); exit; }
protected function _batchDelete($ids) { $sql = $this->_bindSql('DELETE FROM %s WHERE %s IN %s', $this->getTable(), $this->_pk, $this->sqlImplode($ids)); $this->getConnection()->execute($sql); PwSimpleHook::getInstance($this->_class() . '_batchDelete')->runDo($ids); return true; }
public function uploadAvatar($uid) { PwSimpleHook::getInstance('update_avatar')->runDo($uid); return true; }
public function __construct() { $this->tType = PwSimpleHook::getInstance('PwThreadType')->runWithFilters($this->tType); }
/** * 删除关系 * * @param int $uid * @param int $tag_id * @return boolean */ public function deleteRelation($uid, $tag_id) { $sql = $this->_bindTable('DELETE FROM %s WHERE `uid` = ? AND `tag_id` = ?'); $result = $this->getConnection()->createStatement($sql)->execute(array($uid, $tag_id), true); if ($result) { PwSimpleHook::getInstance('PwUserTagRelationDao_deleteRelation')->runDo($tag_id, array(), array('used_count' => -1)); } return $result; }
public function __construct($hookKey) { $this->hook = PwSimpleHook::getInstance($hookKey); }
/** * 用户(A)取消了对用户(B)关注 * * @param int $uid 用户A * @param int $touid 用户B * @return bool| object PwError() */ public function deleteFollow($uid, $touid) { if (($result = $this->_getAttention()->deleteFollow($uid, $touid)) instanceof PwError) { return $result; } $this->_getTypeDs()->deleteUserType($uid, $touid); $user = $this->_getUser(); $dm = new PwUserInfoDm($uid); $dm->addFollows(-1); $user->editUser($dm, PwUser::FETCH_DATA); $dm = new PwUserInfoDm($touid); $dm->addFans(-1); $user->editUser($dm, PwUser::FETCH_DATA); $this->_getFresh()->deleteAttentionFreshByUid($uid, $touid); PwSimpleHook::getInstance('deleteFollow')->runDo($uid, $touid); return true; }
/** * 获得菜单数据table,该菜单节点table并不展示节点间的层级关系. * * 该方法解析所有扩展菜单表或者扩展菜单配置文件,并将菜单合并为一份完整的菜单table并返回. * * @example <code> 节点列表'admin' => array('admin', array()), * 'admin_install' => array('应用菜单安装', 'install/run', '', '', * 'admin'), * 'admin_auth' => array('菜单权限', 'auth/*', '', '', 'admin'),</code> * @return array */ private function _getMenuTable() { if ($this->menuTable === null) { /* @var $_configParser WindConfigParser */ $_configParser = Wind::getComponent('configParser'); // 'ADMIN:conf.mainmenu.php' $mainMenuConfFile = Wind::getRealPath(Wekit::app()->menuPath, true); $menus = $_configParser->parse($mainMenuConfFile); /* extend menus by file */ if (isset($menus['_extensions'])) { $_extensions = $menus['_extensions']; foreach ($_extensions as $_extName => $_ext) { if (!isset($_ext['resource'])) { continue; } $_tmp = Wind::getRealPath($_ext['resource'], true); $cacheKey .= filemtime($_tmp); $_extensions[$_extName]['resource'] = $_tmp; } unset($menus['_extensions']); } else { $_extensions = array(); } $menus = PwSimpleHook::getInstance('admin_menu')->runWithFilters($menus); foreach ($_extensions as $key => $value) { if (!isset($value['resource'])) { continue; } $_tmp = $_configParser->parse($value['resource']); $menus = WindUtility::mergeArray($menus, $_tmp); } AdminMenuHelper::verifyMenuConfig($menus, $menus, $this->menuTable); } return $this->menuTable; }
/** * 打卡 - 更新用户数据 * * @param int $uid * @return bool */ private function _punchBehavior($userInfo, $awardNum, $behaviorNum = '') { $reward = $this->config['punch.reward']; $punchData = array('username' => $this->loginUser->username, 'time' => Pw::getTime(), 'cNum' => $awardNum, 'cUnit' => $this->_creditBo->cUnit[$reward['type']], 'cType' => $this->_creditBo->cType[$reward['type']], 'days' => $behaviorNum); // 更新用户data表信息 Wind::import('SRV:user.dm.PwUserInfoDm'); $dm = new PwUserInfoDm($userInfo['uid']); $dm->setPunch($punchData); $this->_getUserDs()->editUser($dm, PwUser::FETCH_DATA); //埋点[s_punch] PwSimpleHook::getInstance('punch')->runDo($dm); //记录行为 return $this->_getUserBehaviorDs()->replaceBehavior($userInfo['uid'], 'punch_day', $punchData['time']); }
/** * 转化ubb标签 * * @param string $message * @param object $config ubb转换配置 * @return string */ public static function convert($message, PwUbbCodeConvertConfig $config = null) { is_null($config) && ($config = new PwUbbCodeConvertConfig()); self::_init(); self::_startParse(); self::$_cvtimes = $config->cvtimes; self::hasTag($message, 'code') && ($message = self::parseCode($message)); $message = PwSimpleHook::getInstance('PwUbbCode_convert')->runWithFilters($message); $message = self::convertTag($message, array('u', 'b', 'i', 'sub', 'sup', 'strike', 'blockquote')); $message = self::convertHr($message); $message = self::convertList($message); $message = self::convertFont($message); $message = self::convertColor($message); $message = self::convertBackColor($message); $message = self::convertSize($message, $config->maxSize); $message = self::convertEmail($message); $message = self::convertAlign($message); $message = self::convertGlow($message); self::_startParse(); strpos($message, '[s:') !== false && ($message = self::parseEmotion($message)); $message = self::parseAttachment($message, $config); self::hasTag($message, 'img') && ($message = self::parseImg($message, $config->isConverImg, $config->imgWidth, $config->imgHeight, $config->imgLazy)); self::hasTag($message, 'url') && ($message = self::parseUrl($message)); self::hasTag($message, 'flash') && ($message = self::parseFlash($message, $config->isConvertFlash)); $config->remindUser && ($message = self::parseRemind($message, $config->remindUser)); $config->isConvertMedia && ($message = self::parseMedia($message, $config->isConvertMedia == 2)); $config->isConvertIframe && self::hasTag($message, 'iframe') && ($message = self::parseIframe($message, $config->isConvertIframe == 2)); $config->isConvertPost && self::hasTag($message, 'post') && ($message = self::parsePost($message, $config)); $config->isConvertHide && self::hasTag($message, 'hide') && ($message = self::parseHide($message, $config)); $config->isConvertSell && self::hasTag($message, 'sell') && ($message = self::parseSell($message, $config)); self::hasTag($message, 'quote') && ($message = self::parseQuote($message)); $config->isConvertTable && ($message = self::convertTable($message, $config->isConvertTable)); $message = self::convertParagraph($message); $message = self::_convertCode($message); $message = self::_convertCode($message); self::$_cvtimes = -1; return $message; }
public function delLike($uid, $logid) { $info = $this->allowEditLike($uid, $logid); if ($info instanceof PwError) { return false; } if (!$this->_getLikeLogDs()->deleteInfo($logid)) { return false; } $likeInfo = $this->_getLikeContentDs()->getLikeContent($info['likeid']); if (!$likeInfo) { return false; } list($beLikeUid, $isspecial, $count, $fid) = $this->_getSourceInfo($likeInfo['typeid'], $likeInfo['fromid']); $count--; $this->_updateLikeCount($likeInfo['typeid'], $likeInfo['fromid'], $count); //删除喜欢tag if ($info['tagids']) { $this->_getLikeRelationsDs()->deleteInfosBylogid($logid); $tagids = explode(',', $info['tagids']); foreach ($tagids as $tagid) { $this->_getLikeTagDs()->updateNumber($tagid, false); } } //写入喜欢统计 Wind::import('SRV:user.dm.PwUserInfoDm'); $userDs = Wekit::load('user.PwUser'); $userStatistics = $userDs->getUserByUid($uid, PwUser::FETCH_DATA); $likeNumber = isset($userStatistics['likes']) ? intval($userStatistics['likes']) : 0; $likeNumber--; $dm = new PwUserInfoDm($uid); $dm->setLikes($likeNumber); Wekit::load('user.PwUser')->editUser($dm, PwUser::FETCH_DATA); //喜欢后续操作 //$this->_getHook()->runDo('delLike', $uid, $beLikeUid); PwSimpleHook::getInstance('PwLikeService_delLike')->runDo($uid, $beLikeUid); return true; }
/** * 根据用户ID列表批量删除用户信息 * * @param array $uids 用户ID列表 * @return boolean */ public function batchDeleteUserByUid($uids) { if (empty($uids)) { return false; } $uids = (array) $uids; $this->_getDao(self::FETCH_ALL)->batchDeleteUser($uids); $this->_getWindid()->batchDeleteUser($uids); PwSimpleHook::getInstance('PwUser_batchDelete')->runDo($uids); return true; }
/** * 获取权限点配置 * * @return array */ public function getPermissionConfig() { if (!$this->_config) { /* @var $_configParser WindConfigParser */ $_configParser = Wind::getComponent('configParser'); $file = Wind::getRealPath('SRV:usergroup.srv.permission.permissions'); $this->_config = $_configParser->parse($file); $this->_config = PwSimpleHook::getInstance('permissionConfig')->runWithFilters($this->_config); } return $this->_config; }
/** * 批量删除标签 * * @param array $tag_ids * @return boolean */ public function batchDeleteTag($tag_ids) { PwSimpleHook::getInstance('PwUserTagDao_batchDeleteTag')->runDo($tag_ids); return $this->_batchDelete($tag_ids); }
/** * 删除配置项 * * @param string $namespace 配置项所属空间 * @param string $name 配置项名字 * @return boolean */ public function deleteConfigByName($namespace, $name) { $sql = $this->_bindTable('DELETE FROM %s WHERE namespace=? AND name=?'); $smt = $this->getConnection()->createStatement($sql); $result = $smt->update(array($namespace, $name)); PwSimpleHook::getInstance('PwConfigDao_update')->runDo($namespace); return $result; }
/** * 初始化用户头像 * @param int $uid * @param string $url 腾讯头像地址 */ function restore_avatar($uid, $url) { $store = Wind::getComponent('storage'); Wind::import('SRV:upload.PwUpload'); Wind::import('LIB:image.PwImage'); $fileDir = sprintf('avatar/%s/', Pw::getUserDir($uid)); $_avatar = array('.jpg' => 200, '_middle.jpg' => 120, '_small.jpg' => 50); $file = tempnam(sys_get_temp_dir(), 'avatar'); $img = httpget($url); file_put_contents($file, $img); $img = new PwImage($file); $thumb = new PwImageThumb($img); foreach ($_avatar as $des => $size) { $toPath = $store->getAbsolutePath($uid . $des, $fileDir); PwUpload::createFolder(dirname($toPath)); if ($size < 100) { $thumb->setWidth($size); $thumb->setHeight($size); $thumb->setDstFile($toPath); $thumb->execute(); } else { copy($file, $toPath); } } Wind::import('SRV:upload.action.PwAvatarUpload'); Wind::import('SRV:upload.PwUpload'); PwSimpleHook::getInstance('update_avatar')->runDo($uid); @unlink($file); return true; }
/** * 复制帖子 | 复制特殊帖、附件等待做。。。 * * @param int $topictype * @return int */ public function run() { foreach ($this->threads as $v) { $topicDm = new PwTopicDm($v['tid']); $topicDm->setLastpost($v['lastpost_userid'], $v['lastpost_username'], $v['lastpost_time'])->setSpecial($v['special'])->setDigest($v['digest'])->setTopped($v['topped'])->setSpecialsort($v['special_sort'])->setTopictype($this->topictype)->setTpcstatus($v['tpcstatus'])->setHighlight($v['highlight'])->setOvertime($v['overtime'])->addHits($v['hits'])->setTitle($v['subject'])->setContent($v['content'])->setFid($this->fid)->setAuthor($v['created_userid'], $v['created_username'], $v['created_ip'])->setModifyInfo($v['modified_userid'], $v['modified_username'], $v['modified_ip'], $v['modified_time'])->setCreatedTime($v['created_time'])->setDisabled($v['disabled'])->setAids($v['aids'])->setIfupload($v['ifupload'])->setReplyNotice($v['reply_notice'])->setLikeCount($v['like_count'])->setSellCount($v['sell_count'])->addReplies($v['replies'])->addSellCount($v['sell_count'])->setReminds($v['reminds'])->setWordVersion($v['word_version'])->setTags($v['tags']); $tid = $this->_getThreadDs()->addThread($topicDm); if ($tid) { PwSimpleHook::getInstance('PwThreadManageDoCopy')->runDo($topicDm, $tid); $forumDm = new PwForumDm($this->fid); $forumDm->addThreads(1); $forumDm->addArticle(1); Wekit::load('SRV:forum.PwForum')->updateForum($forumDm); } } //管理日志添加 Wekit::load('log.srv.PwLogService')->addThreadManageLog($this->srv->user, 'copy', $this->threads, $this->_reason, $this->fid . '|' . $this->topictype); }