/** * @param integer sid 资源ID,如分享小名片就是对应用户的用户ID,分享微博就是微博的ID * @param string stable 资源所在的表,如小名片就是contact表,微博就是feed表 * @param string appname 资源所在的应用 * @param integer nums 该资源被分享的次数 * @param string initHTML 默认的内容 */ public function render($data) { $var = array(); $var['appname'] = 'public'; $var['cancomment'] = intval(CheckPermission('core_normal', 'feed_comment')); $var['feed_type'] = 'repost'; is_array($data) && ($var = array_merge($var, $data)); // 获取资源是否被删除 switch ($data['appname']) { case 'weiba': $wInfo = D('WeibaPost', 'weiba')->where('post_id=' . $var['sid'])->find(); $sInfo = model('Feed')->getFeedInfo($sInfo['feed_id']); break; default: $sInfo = model('Feed')->getFeedInfo($var['sid']); } $var['s_is_del'] = $sInfo['is_del']; extract($var, EXTR_OVERWRITE); if ($nums > 0) { $showNums = " ({$nums})"; } else { $showNums = ""; } if ($s_is_del == 1) { return "<span>" . L('PUBLIC_SHARE_STREAM') . $showNums . "</span>"; } else { return "<a event-node=\"share\" href=\"javascript:void(0);\" event-args='sid={$sid}&stable={$stable}&curtable={$current_table}&curid={$current_id}&initHTML={$initHTML}&appname={$appname}&cancomment={$cancomment}&feedtype={$feed_type}&is_repost={$is_repost}'>" . L('PUBLIC_SHARE_STREAM') . $showNums . "</a>"; } // //渲染模版 // $content = $this->renderFile(dirname(__FILE__)."/Share.html",$var); // unset($var,$data); // //输出数据 // return $content; }
public function CheckPermission() { $Content = $this->_Sender->Data('Content'); if (CheckPermission('Candy.Page.Edit') || IsContentOwner($Content) && CheckPermission('Candy.Page.Add')) { return True; } }
public function ToString() { $Session = Gdn::Session(); $Controller = Gdn::Controller(); $UserID = $Controller->User->UserID; $MemberOptions = array(); $ProfileOptions = array(); $Controller->EventArguments['UserID'] = $UserID; $Controller->EventArguments['ProfileOptions'] =& $ProfileOptions; $Controller->EventArguments['MemberOptions'] =& $MemberOptions; if ($Controller->EditMode) { return '<div class="ProfileOptions">' . Anchor(T('Back to Profile'), UserUrl($Controller->User), array('class' => 'ProfileButtons')) . '</div>'; // $ProfileOptions[] = array('Text' => T('Back to Profile'), 'Url' => UserUrl($Controller->User), 'CssClass' => 'BackToProfile'); } else { // Profile Editing if (hasEditProfile($Controller->User->UserID)) { $ProfileOptions[] = array('Text' => Sprite('SpEditProfile') . ' ' . T('Edit Profile'), 'Url' => UserUrl($Controller->User, '', 'edit')); } // Ban/Unban $MayBan = CheckPermission('Garden.Moderation.Manage') || CheckPermission('Garden.Users.Edit') || CheckPermission('Moderation.Users.Ban'); if ($MayBan && $UserID != $Session->UserID) { if ($Controller->User->Banned) { $ProfileOptions[] = array('Text' => Sprite('SpBan') . ' ' . T('Unban'), 'Url' => "/user/ban?userid={$UserID}&unban=1", 'CssClass' => 'Popup'); } elseif (!$Controller->User->Admin) { $ProfileOptions[] = array('Text' => Sprite('SpBan') . ' ' . T('Ban'), 'Url' => "/user/ban?userid={$UserID}", 'CssClass' => 'Popup'); } } // Delete content. if (CheckPermission('Garden.Moderation.Manage')) { $ProfileOptions[] = array('Text' => Sprite('SpDelete') . ' ' . T('Delete Content'), 'Url' => "/user/deletecontent?userid={$UserID}", 'CssClass' => 'Popup'); } } return parent::ToString(); }
/** * Show NoIndex meta tag on discussions list. */ public function Base_BeforeDiscussionMeta_Handler($Sender, $Args) { $NoIndex = GetValue('NoIndex', GetValue('Discussion', $Args)); if (CheckPermission(array('Garden.Moderation.Manage', 'Garden.Curation.Manage'), FALSE) && $NoIndex) { echo ' <span class="Tag Tag-NoIndex">' . T('NoIndex') . '</span> '; } }
public function __construct($Sender = '') { if (!CheckPermission('Conversations.Conversations.Add')) { throw PermissionException(); } $Session = Gdn::Session(); if (property_exists($Sender, 'Conversation')) { $this->Conversation = $Sender->Conversation; } $this->Form = Gdn::Factory('Form', 'AddPeople'); // $this->Form->Action = $Sender->SelfUrl; // If the form was posted back, check for people to add to the conversation if ($this->Form->AuthenticatedPostBack()) { $NewRecipientUserIDs = array(); $NewRecipients = explode(',', $this->Form->GetFormValue('AddPeople', '')); $UserModel = Gdn::Factory("UserModel"); foreach ($NewRecipients as $Name) { if (trim($Name) != '') { $User = $UserModel->GetByUsername(trim($Name)); if (is_object($User)) { $NewRecipientUserIDs[] = $User->UserID; } } } $Sender->ConversationModel->AddUserToConversation($this->Conversation->ConversationID, $NewRecipientUserIDs); // if ($Sender->DeliveryType() == DELIVERY_TYPE_ALL) // Redirect('/messages/'.$this->Conversation->ConversationID); $Sender->InformMessage(T('Your changes were saved.')); $Sender->RedirectUrl = Url('/messages/' . $this->Conversation->ConversationID); } $this->_ApplicationFolder = $Sender->Application; $this->_ThemeFolder = $Sender->Theme; }
/** * 分享控制 * @return void */ public function index() { $shareInfo['sid'] = intval($_GET['sid']); $shareInfo['stable'] = t($_GET['stable']); $shareInfo['initHTML'] = h($_GET['initHTML']); $shareInfo['curid'] = t($_GET['curid']); $shareInfo['curtable'] = t($_GET['curtable']); $shareInfo['appname'] = t($_GET['appname']); $shareInfo['cancomment'] = intval($_GET['cancomment']); $shareInfo['is_repost'] = intval($_GET['is_repost']); if (empty($shareInfo['stable']) || empty($shareInfo['sid'])) { echo L('PUBLIC_TYPE_NOEMPTY'); exit; } if (!($oldInfo = model('Source')->getSourceInfo($shareInfo['stable'], $shareInfo['sid'], false, $shareInfo['appname']))) { echo L('PUBLIC_INFO_SHARE_FORBIDDEN'); exit; } empty($shareInfo['appname']) && ($shareInfo['appname'] = $oldInfo['app']); if ($shareInfo['appname'] != '' && $shareInfo['appname'] != 'public') { addLang($shareInfo['appname']); } if (empty($shareInfo['initHTML']) && !empty($shareInfo['curid'])) { //判断是否为转发的分享 if ($shareInfo['curid'] != $shareInfo['sid'] && $shareInfo['is_repost'] == 1) { $app = $curtable == $shareInfo['stable'] ? $shareInfo['appname'] : 'public'; $curInfo = model('Source')->getSourceInfo($shareInfo['curtable'], $shareInfo['curid'], false, $app); $userInfo = $curInfo['source_user_info']; // if($userInfo['uid'] != $this->mid){ //分享其他人的分享,非自己的 $shareInfo['initHTML'] = ' //@' . $userInfo['uname'] . ':' . $curInfo['source_content']; // } $shareInfo['initHTML'] = str_replace(array("\n", "\r"), array('', ''), $shareInfo['initHTML']); } } if (!CheckPermission('core_normal', 'feed_comment')) { $shareInfo['cancomment'] = 0; } if ($shareInfo['sid'] != $shareInfo['curid']) { //获取被评论的分享信息 $source = model('Feed')->get($shareInfo['sid']); //判断是否有权限评论当前用户 if ($this->mid != $source['uid']) { $userPrivacy = model('UserPrivacy')->getPrivacy($this->mid, $source['uid']); if ($userPrivacy['comment_weibo'] == 1) { $shareInfo['cancomment'] = 0; } else { $shareInfo['cancomment'] = 1; } } } $shareInfo['shareHtml'] = !empty($oldInfo['shareHtml']) ? $oldInfo['shareHtml'] : ''; $weiboSet = model('Xdata')->get('admin_Config:feed'); $canShareFeed = in_array('repost', $weiboSet['weibo_premission']) ? 1 : '0'; $this->assign('canShareFeed', $canShareFeed); $this->assign('initNums', $weiboSet['weibo_nums']); $this->assign('shareInfo', $shareInfo); $this->assign('oldInfo', $oldInfo); $this->display(); }
public function delLZLReply($id) { $lzl = D('ForumLzlReply')->where('id=' . $id)->find(); $data['is_del'] = 1; CheckPermission(array($lzl['uid'])) && ($res = $this->where('id=' . $id)->save($data)); D('ForumPost')->where(array('id' => $lzl['post_id']))->setDec('reply_count'); S('post_replylist_' . $lzl['post_id'], null); S('post_replylzllist_' . $lzl['to_f_reply_id'], null); return $res; }
public function LoadData() { $UserID = Gdn::Controller()->Data('Profile.UserID', Gdn::Session()->UserID); $this->User = Gdn::UserModel()->GetID($UserID); $this->Roles = Gdn::UserModel()->GetRoles($UserID)->ResultArray(); // Hide personal info roles if (!CheckPermission('Garden.PersonalInfo.View')) { $this->Roles = array_filter($this->Roles, 'RoleModel::FilterPersonalInfo'); } }
/** * Render the module. * * @return string Rendered HTML. */ public function ToString() { // Simplify our permission logic $ConversationExists = is_object($this->Conversation) && $this->Conversation->ConversationID > 0; $CanAddUsers = $this->AddUserAllowed && CheckPermission('Conversations.Conversations.Add'); if ($ConversationExists && $CanAddUsers) { return parent::ToString(); } return ''; }
/** * Show alternate locale options in Foot. */ public function Base_Render_Before($Sender) { // Not in Dashboard // Block guests until guest sessions are restored if ($Sender->MasterView == 'admin' || !CheckPermission('Garden.SignIn.Allow')) { return; } $Sender->AddModule('LocaleChooserModule'); // Add a simple style $Sender->AddAsset('Head', '<style>.LocaleOption { padding-left: 10px; } .LocaleOptions { padding: 10px; } .Dashboard .LocaleOptions { display: none; }</style>'); }
public function PluginController_MembersListEnh_Create($Sender) { $Session = Gdn::Session(); if ($Sender->Menu && (CheckPermission('Plugins.MembersListEnh.GenView') || CheckPermission('Plugins.MembersListEnh.IPEmailView'))) { $Sender->ClearCssFiles(); $Sender->AddCssFile('style.css'); $Sender->MasterView = 'default'; $Sender->Render('memtable', '', 'plugins/MembersListEnh'); } else { echo Wrap(Anchor(Img('/plugins/MembersListEnh/design/AccessDenied.png', array('width' => '100%'), array('title' => T('You Have No Permission To View This Page Go Back'))), '/discussions', array('target' => '_self')), 'h1'); } }
/** * @param integer sid 资源ID,如分享小名片就是对应用户的用户ID,分享微博就是微博的ID * @param string stable 资源所在的表,如小名片就是contact表,微博就是feed表 * @param string appname 资源所在的应用 * @param integer nums 该资源被分享的次数 * @param string initHTML 默认的内容 */ public function render($data) { $var = array(); $var['appname'] = 'public'; $var['cancomment'] = intval(CheckPermission('core_normal', 'feed_comment')); $var['feed_type'] = 'repost'; is_array($data) && ($var = array_merge($var, $data)); //渲染模版 $content = $this->renderFile(dirname(__FILE__) . "/Share.html", $var); unset($var, $data); //输出数据 return $content; }
/** * Output user agent information. */ protected function AttachInfo($Sender, $Attributes) { if (!CheckPermission('Garden.Moderation.Manage')) { return; } $Info = ''; if ($Value = GetValue('Browser', $Attributes)) { $Info .= Wrap('Browser', 'dt') . ' ' . Wrap($Value, 'dd'); } if ($Value = GetValue('Platform', $Attributes)) { $Info .= Wrap('OS', 'dt') . ' ' . Wrap($Value, 'dd'); } echo Wrap($Info, 'dl', array('class' => "About UserAgentInfo")); }
/** * Set DateLastComment to null & sink & close if this is an insert and 'Show as Page' was selected. */ public function discussionModel_beforeSaveDiscussion_handler($sender, &$args) { if (CheckPermission('Garden.Community.Manage') || CheckPermission('Garden.Settings.Manage')) { if ($args['Insert'] && $args['FormPostValues']['Page'] == 1) { $args['FormPostValues']['DateLastComment'] = NULL; $args['FormPostValues']['Sink'] = 1; $args['FormPostValues']['Closed'] = 1; $args['FormPostValues']['Type'] = 'SimplePage'; if (StringIsNullOrEmpty($args['FormPostValues']['ForeignID'])) { $sender->Validation->AddValidationResult('ForeignID', 'URL Slug required for pages.'); } } } }
/** * Allow mods to bump via discussion options. */ public function Base_DiscussionOptions_Handler($Sender, $Args) { $Discussion = $Args['Discussion']; if (CheckPermission('Garden.Moderation.Manage')) { $Label = T('Bump'); $Url = "/discussion/bump?discussionid={$Discussion->DiscussionID}"; // Deal with inconsistencies in how options are passed if (isset($Sender->Options)) { $Sender->Options .= Wrap(Anchor($Label, $Url, 'Bump'), 'li'); } else { $Args['DiscussionOptions']['Bump'] = array('Label' => $Label, 'Url' => $Url, 'Class' => 'Bump'); } } }
public function doLogin() { $login = model('Passport')->adminLogin(); if ($login) { if (CheckPermission('core_admin', 'admin_login')) { $this->success(L('PUBLIC_LOGIN_SUCCESS')); } else { $this->assign('jumpUrl', SITE_URL); $this->error(L('PUBLIC_NO_FRONTPLATFORM_PERMISSION_ADMIN')); } } else { $this->error(model('Passport')->getError()); } }
/** * 用户管理爆料列表 * @param integer user_id 用户UID * @param integer count 每页显示条数 * @param integer page 显示第几页 * @param integer order 排序(1:时间,2:评论,3:奖金) * @return array 微吧列表 */ function get_tipofflistbyuidmanage() { $this->user_id = empty($this->user_id) ? $this->mid : $this->user_id; if (!$this->user_id) { return false; } if (!(model('UserGroup')->isAdmin($this->user_id) || CheckPermission('tipoff_admin', 'tipoff_setStatus'))) { return false; } $data = D('Tipoff', 'tipoff')->get_tipofflist_forapi($this->since_id, $this->max_id, $this->count, $this->page, $this->data['order'], $this->user_id, 3); if ($data) { return $data; } else { return array(); } }
public function check() { if (APP_NAME == 'admin' || APP_NAME == 'w3g' || CheckPermission('core_admin', 'admin_login')) { return; } if (self::$checked) { return; } //避免重复检查 self::$checked = true; //标注已经检查 $uid = intval($_SESSION['mid']); //当前用户 //获取唯一测试编号,针对局域网IP重复 $uniqid = t(cookie('_testrand')); if (!$uniqid) { $uniqid = uniqid(); cookie('_testrand', $uniqid, 86400 * 365); } //取得当前的邀请码 if (!empty($_SESSION['InviteTest'])) { $invitecode = $_SESSION['InviteTest']; } elseif (!empty($_REQUEST['invitecode'])) { $invitecode = t($_REQUEST['invitecode']); cookie('invitetest', $invitecode, 86400 * 365); } $model = $this->model('InviteTest'); //检查邀请码是否可用 if (!empty($invitecode)) { if (!$model->check($invitecode, $uid, $uniqid)) { $this->assign('errorMsg', $model->getError()); $_SESSION['InviteTest'] = null; } else { $_SESSION['InviteTest'] = $invitecode; } $this->assign('invitecode', $invitecode); } else { $this->assign('invitecode', cookie('invitetest')); } //没有邀请码 if (empty($_SESSION['InviteTest'])) { $this->assign('config', $model->getConfig()); $this->display('index'); exit; //结束后面的代码 } }
public function delPostReply($id) { $reply = D('ForumPostReply')->where('id=' . $id)->find(); $data['status'] = 0; CheckPermission(array($reply['uid'])) && ($res = $this->where('id=' . $id)->save($data)); if ($res) { $lzlReply_idlist = D('ForumLzlReply')->where('is_del=0 and to_f_reply_id=' . $id)->field('id')->select(); $info['is_del'] = 1; foreach ($lzlReply_idlist as $val) { D('ForumLzlReply')->where('id=' . $val['id'])->save($info); D('ForumPost')->where(array('id' => $reply['post_id']))->setDec('reply_count'); } } D('ForumPost')->where(array('id' => $reply['post_id']))->setDec('reply_count'); S('post_replylist_' . $reply['post_id'], null); return $res; }
/** * @param integer sid 资源ID,如分享小名片就是对应用户的用户ID,分享分享就是分享的ID * @param string stable 资源所在的表,如小名片就是contact表,分享就是feed表 * @param string appname 资源所在的应用 * @param integer nums 该资源被分享的次数 * @param string initHTML 默认的内容 */ public function render($data) { $var = array(); $var['appname'] = 'public'; $var['cancomment'] = intval(CheckPermission('core_normal', 'feed_comment')); $var['feed_type'] = 'repost'; is_array($data) && ($var = array_merge($var, $data)); // 获取资源是否被删除 switch ($data['appname']) { case 'weiba': $wInfo = D('WeibaPost', 'weiba')->where('post_id=' . $var['sid'])->find(); $sInfo = model('Feed')->getFeedInfo($sInfo['feed_id']); break; case 'event': $eInfo = D('event')->where('id=' . $var['sid'])->find(); $sInfo = model('Feed')->getFeedInfo($eInfo['feed_id']); break; case 'blog': $bInfo = D('blog')->where('id=' . $var['sid'])->find(); $sInfo = model('Feed')->getFeedInfo($bInfo['feed_id']); break; case 'vote': $vInfo = D('vote')->where('id=' . $var['sid'])->find(); $sInfo = model('Feed')->getFeedInfo($vInfo['feed_id']); break; case 'photo': $pInfo = D('photo_album')->where('id=' . $var['sid'])->find(); $sInfo = model('Feed')->getFeedInfo($pInfo['feed_id']); break; default: $sInfo = model('Feed')->getFeedInfo($var['sid']); } extract($var, EXTR_OVERWRITE); if ($nums > 0) { $showNums = " ({$nums})"; } else { $showNums = ""; } if ($s_is_del == 1) { return "<span>" . L('PUBLIC_SHARE_STREAM') . $showNums . "</span>"; } elseif ($var['tpl'] == 'share_repost') { return "<a event-node=\"share\" class=\"repost\" href=\"javascript:void(0);\" event-args='sid={$sid}&stable={$stable}&curtable={$current_table}&curid={$current_id}&initHTML={$initHTML}&appname={$appname}&cancomment={$cancomment}&feedtype={$feed_type}&is_repost={$is_repost}'>我的主页</a>"; } else { return "<a event-node=\"" . ($var['enode'] ? $var['enode'] : 'share') . "\"" . ($var['class'] ? ' class="' . $var['class'] . '"' : '') . ($var['title'] ? ' title="' . $var['title'] . '"' : '') . " href=\"javascript:void(0);\" event-args='sid={$sid}&stable={$stable}&curtable={$current_table}&curid={$current_id}&initHTML={$initHTML}&appname={$appname}&cancomment={$cancomment}&feedtype={$feed_type}&is_repost={$is_repost}'>" . ($var['text'] ? $var['text'] : L('PUBLIC_SHARE_STREAM') . $showNums) . "</a>"; } }
public function doLogin() { //检查验证码 if (md5(strtoupper($_POST['verify'])) != $_SESSION['verify']) { $this->error('验证码错误'); } $login = model('Passport')->adminLogin(); if ($login) { if (CheckPermission('core_admin', 'admin_login')) { $this->success(L('PUBLIC_LOGIN_SUCCESS')); } else { $this->assign('jumpUrl', SITE_URL); $this->error(L('PUBLIC_NO_FRONTPLATFORM_PERMISSION_ADMIN')); } } else { $this->error(model('Passport')->getError()); } }
/** * Renders a list of available actions that also contains the current count of * reactions an item has received if allowed * * @param int $ID * @param string $Type 'discussion', 'activity', or 'comment' * @param bool $Echo Should it be echoed? * @return mixed String if $Echo is false, TRUE otherwise */ function RenderReactionList($ID, $Type, $Echo = TRUE) { $Reactions = Yaga::ReactionModel()->GetList($ID, $Type); $ShowCount = Gdn::Session()->CheckPermission('Yaga.Reactions.View'); $ActionsString = ''; foreach ($Reactions as $Action) { if (CheckPermission($Action->Permission)) { $CountString = $ShowCount && $Action->Count ? $Action->Count : ''; $ActionsString .= Anchor(Wrap(' ', 'span', array('class' => 'ReactSprite React-' . $Action->ActionID . ' ' . $Action->CssClass)) . WrapIf($CountString, 'span', array('class' => 'Count')) . Wrap($Action->Name, 'span', array('class' => 'ReactLabel')), 'react/' . $Type . '/' . $ID . '/' . $Action->ActionID, array('class' => 'Hijack ReactButton', 'title' => $Action->Tooltip)); } } $AllActionsString = Wrap($ActionsString, 'span', array('class' => 'ReactMenu')); if ($Echo) { echo $AllActionsString; return true; } else { return $AllActionsString; } }
public function Gdn_Form_UploadBox_Create($Form) { $FieldName =& $Form->EventArguments[0]; $Attributes =& $Form->EventArguments[1]; $Result = $Form->TextBox($FieldName, $Attributes); $Folder = GetValue('Folder', $Attributes, '', True); $AddYear = GetValue('AddYear', $Attributes, '', True); $AddMonth = GetValue('AddMonth', $Attributes, '', True); if (!$Folder) { $Folder = GetValue('UploadTo', $Attributes, '', True); if (Debug() && $Folder) { trigger_error("You should use 'Folder' instead of 'UploadTo'.", E_USER_DEPRECATED); } } if (CheckPermission('Plugins.Morf.Upload.Allow')) { $Data = compact('Folder', 'AddYear', 'AddMonth'); $Result .= $Form->Hidden($FieldName . 'UploadBox', array('value' => json_encode($Data))); } return $Result; }
public function delPostReply($id) { $reply = M('ForumPostReply')->where('id=' . $id)->find(); $data['status'] = -1; CheckPermission(array($reply['uid'])) && ($res = $this->where('id=' . $id)->save($data)); if ($res) { $lzlReply_idlist = M('ForumLzlReply')->where('is_del=0 and to_f_reply_id=' . $id)->field('id')->select(); $info['is_del'] = 1; foreach ($lzlReply_idlist as $val) { M('ForumLzlReply')->where('id=' . $val['id'])->save($info); } } $reply_list = M('ForumPostReply')->where(array('post_id' => $reply['post_id']))->field('id')->select(); $reply_count = count($reply_list); $reply_list = array_column($reply_list, 'id'); $reply_count += M('ForumLzlReply')->where(array('id' => array('in', $reply_list)))->count(); M('ForumPost')->where(array('id' => $reply['post_id']))->setField('reply_count', $reply_count); S('post_replylist_' . $reply['post_id'], null); return $res; }
/** * [ 获取评论的评论列表] * @return [type] [description] */ public function reply_commentList() { if (!CheckPermission('weiba_normal', 'weiba_reply')) { return false; } $var = $_POST; $var['initNums'] = model('Xdata')->getConfig('weibo_nums', 'feed'); $var['commentInfo'] = model('Comment')->getCommentInfo($var['comment_id'], false); $var['canrepost'] = $var['commentInfo']['table'] == 'feed' ? 1 : 0; $var['cancomment'] = 1; // 获取原作者信息 $rowData = model('Feed')->get(intval($var['commentInfo']['row_id'])); $appRowData = model('Feed')->get($rowData['app_row_id']); $var['user_info'] = $appRowData['user_info']; // 微博类型 $var['feedtype'] = $rowData['type']; // $var['cancomment_old'] = ($var['commentInfo']['uid'] != $var['commentInfo']['app_uid'] && $var['commentInfo']['app_uid'] != $this->uid) ? 1 : 0; if ($var['flag'] != 1) { $var['initHtml'] = L('PUBLIC_STREAM_REPLY') . '@' . $var['commentInfo']['user_info']['uname'] . ' :'; } //获取回评 $commentList = D('weiba_reply')->where('is_del = 0 and to_reply_id=' . $var['to_reply_id'])->order('ctime')->select(); foreach ($commentList as $k => $v) { $commentList[$k]['content'] = parse_html(h(htmlspecialchars($v['content']))); } $this->assign('commentList', $commentList); $uids = getSubByKey($commentList, 'uid'); $this->_assignUserInfo($uids); $this->assign('reply_id', $var['to_reply_id']); $this->assign('var', $var); if ($var[type] == 2) { $con = $this->fetch('reply_commentList1'); } else { $con = $this->fetch(); } echo $con; }
/** * Renders a chunk of text * * @param mixed $Identify ChunckID. * @param mixed $Options type of chunk (Textarea [default], Text) * @return mixed $Result. */ function Chunk($Identify, $Options = False) { static $ChunkModel; if (is_null($ChunkModel)) { $ChunkModel = new ChunkModel(); } static $PermissionChunksEdit; if (is_null($PermissionChunksEdit)) { $PermissionChunksEdit = CheckPermission('Candy.Chunks.Edit'); } $Data = $ChunkModel->GetID($Identify); if ($Data != False) { $String = Gdn_Format::To($Data->Body, $Data->Format); $Type = ArrayValueI('type', $Options, 'Textarea'); $Class = ArrayValueI('class', $Options, ''); if ($Type) { if ($PermissionChunksEdit) { $Class .= ' Editable Editable' . $Type; } $String = Wrap($String, 'div', array('class' => trim($Class), 'id' => 'Chunk' . $Data->ChunkID)); } return $String; } }
/** * 渲染评论页面 在addcomment方法中调用 */ public function parseComment($data) { $data['userInfo'] = model('User')->getUserInfo($GLOBALS['ts']['uid']); // 获取用户组信息 $data['userInfo']['groupData'] = model('UserGroupLink')->getUserGroupData($GLOBALS['ts']['uid']); $data['content'] = preg_html($data['content']); $data['content'] = parse_html($data['content']); $data['iscommentdel'] = CheckPermission('core_normal', 'comment_del'); return $this->renderFile(dirname(__FILE__) . "/_parseComment.html", $data); }
/** * 根据关键字进行搜索 * @return void */ public function index() { if (!CheckPermission('core_normal', 'search_info')) { $this->error('对不起,您没有权限进行该操作!'); } $this->setTitle('搜索' . $this->key); $this->setKeywords('搜索' . $this->key); $this->setDescription('搜索' . $this->key); if ($this->curType == 2) { //搜索用户 if ($this->key != "") { if (t($_GET['Stime']) && t($_GET['Etime'])) { $Stime = strtotime(t($_GET['Stime'])); $Etime = strtotime(t($_GET['Etime'])); $this->assign('Stime', t($_GET['Stime'])); $this->assign('Etime', t($_GET['Etime'])); } //关键字匹配 采用搜索引擎兼容函数搜索 后期可能会扩展为搜索引擎 $feed_type = !empty($_GET['feed_type']) ? t($_GET['feed_type']) : ''; $list = model('Feed')->searchFeeds($this->key, $feed_type, 20, $Stime, $Etime); //赞功能 $feed_ids = getSubByKey($list['data'], 'feed_id'); $diggArr = model('FeedDigg')->checkIsDigg($feed_ids, $GLOBALS['ts']['mid']); $this->assign('diggArr', $diggArr); $this->assign('feed_type', $feed_type); $this->assign('searchResult', $list); //搜索微博 $weiboSet = model('Xdata')->get('admin_Config:feed'); $this->assign('weibo_premission', $weiboSet['weibo_premission']); } $this->display('search_feed'); } else { if ($this->key != "") { if ($this->curType == 3) { //按标签搜索 $data['name'] = $this->key; $tagid = D('tag')->where($data)->getField('tag_id'); $maps['app'] = 'public'; $maps['table'] = 'user'; $maps['tag_id'] = $tagid; $user_ids = getSubByKey(D('app_tag')->where($maps)->field('row_id as uid')->order('row_id desc')->findAll(), 'uid'); $map['uid'] = array('in', $user_ids); $map['is_active'] = 1; $map['is_audit'] = 1; $map['is_init'] = 1; $userlist = D('user')->where($map)->field('uid')->findpage(10); foreach ($userlist['data'] as &$v) { $v = model('User')->getUserInfo($v['uid']); unset($v); } } else { $userlist = model('User')->searchUser($this->key, 0, 100, '', '', 0, 10); } $uids = getSubByKey($userlist['data'], 'uid'); $usercounts = model('UserData')->getUserDataByUids($uids); $userGids = model('UserGroupLink')->getUserGroup($uids); $followstatus = model('Follow')->getFollowStateByFids($this->mid, $uids); foreach ($userlist['data'] as $k => $v) { $userlist['data'][$k]['usercount'] = $usercounts[$v['uid']]; $userlist['data'][$k]['userTag'] = model('Tag')->setAppName('User')->setAppTable('user')->getAppTags($v['uid']); // 获取用户用户组信息 // $userGids = model('UserGroupLink')->getUserGroup($v['uid']); $userGroupData = model('UserGroup')->getUserGroupByGids($userGids[$v['uid']]); foreach ($userGroupData as $key => $value) { if ($value['user_group_icon'] == -1) { unset($userGroupData[$key]); continue; } $userGroupData[$key]['user_group_icon_url'] = THEME_PUBLIC_URL . '/image/usergroup/' . $value['user_group_icon']; } $userlist['data'][$k]['userGroupData'] = $userGroupData; // 获取用户积分信息 //$userlist['data'][$k]['userCredit'] = model('Credit')->getUserCredit($this->uid); //关注状态 $userlist['data'][$k]['follow_state'] = $followstatus[$v['uid']]; } $this->assign('searchResult', $userlist); } $this->display('search_user'); } }
/** * 添加评论操作 * @param array $data 评论数据 * @param boolean $forApi 是否用于API,默认为false * @param boolean $notCount 是否统计到未读评论 * @param array $lessUids 除去@用户ID * @return boolean 是否添加评论成功 */ public function addComment($data, $forApi = false, $notCount = false, $lessUids = null) { // 判断用户是否登录 if (!$GLOBALS['ts']['mid']) { $this->error = L('PUBLIC_REGISTER_REQUIRED'); // 请先登录 return false; } if (isSubmitLocked()) { $this->error = '发布内容过于频繁,请稍后再试!'; return false; } /* # 将Emoji编码 */ $data['content'] = formatEmoji(true, $data['content']); // 检测数据安全性 $add = $this->_escapeData($data); if ($add['content'] === '') { $this->error = L('PUBLIC_COMMENT_CONTENT_REQUIRED'); // 评论内容不可为空 return false; } $add['is_del'] = 0; //判断是否先审后发 $filterStatus = filter_words($add['content']); $weiboSet = model('Xdata')->get('admin_Config:feed'); $weibo_premission = $weiboSet['weibo_premission']; if (in_array('audit', $weibo_premission) || CheckPermission('core_normal', 'feed_audit') || $filterStatus['type'] == 2) { $add['is_audit'] = 0; } else { $add['is_audit'] = 1; } $add['client_ip'] = get_client_ip(); $add['client_port'] = get_client_port(); if ($res = $this->add($add)) { //锁定发布 lockSubmit(); //添加楼层信息 弃用 20130607 /* $storeyCount = $this->where("table='".$add['table']."' and row_id=".$data['row_id'].' and comment_id<'.$res)->count(); $this->where('comment_id='.$res)->setField('storey',$storeyCount+1); */ if (!$add['is_audit']) { $touid = D('user_group_link')->where('user_group_id=1')->field('uid')->findAll(); $touidArr = getSubByKey($touid, 'uid'); model('Notify')->sendNotify($touidArr, 'comment_audit'); } // 获取排除@用户ID $lessUids[] = intval($data['app_uid']); !empty($data['to_uid']) && ($lessUids[] = intval($data['to_uid'])); // 获取用户发送的内容,仅仅以//进行分割 $scream = explode('//', $data['content']); model('Atme')->setAppName('Public')->setAppTable('comment')->addAtme(trim($scream[0]), $res, null, $lessUids); // 被评论内容的“评论统计数”加1,同时可检测出app,table,row_id的有效性 $pk = D($add['table'])->getPk(); $where = "`{$pk}`={$add['row_id']}"; D($add['table'])->setInc('comment_count', $where); //兼容旧版本app // D($add['table'])->setInc('commentCount', $where); // D($add['table'])->setInc('comment_all_count', $where); D($add['app'])->setInc('commentCount', $where); D($add['app'])->setInc('comment_all_count', $where); //评论时间 M($add['app'])->where('feed_id=' . $add['row_id'])->setField('rTime', time()); // 给应用UID添加一个未读的评论数 原作者 if ($GLOBALS['ts']['mid'] != $add['app_uid'] && $add['app_uid'] != '' && $add['app_uid'] != $add['to_uid']) { !$notCount && model('UserData')->updateKey('unread_comment', 1, true, $add['app_uid']); } // 回复发送提示信息 if (!empty($add['to_uid']) && $add['to_uid'] != $GLOBALS['ts']['mid']) { !$notCount && model('UserData')->updateKey('unread_comment', 1, true, $add['to_uid']); } // 加积分操作 if ($add['table'] == 'feed') { model('Credit')->setUserCredit($GLOBALS['ts']['mid'], 'comment_weibo'); model('Credit')->setUserCredit($data['app_uid'], 'commented_weibo'); model('Feed')->cleanCache($add['row_id']); } // 发邮件 if ($add['to_uid'] != $GLOBALS['ts']['mid'] || $add['app_uid'] != $GLOBALS['ts']['mid'] && $add['app_uid'] != '') { $author = model('User')->getUserInfo($GLOBALS['ts']['mid']); $config['name'] = $author['uname']; $config['space_url'] = $author['space_url']; $config['face'] = $author['avatar_small']; $sourceInfo = model('Source')->getCommentSource($add, $forApi); $config['content'] = parse_html($add['content']); $config['ctime'] = date('Y-m-d H:i:s', time()); $config['sourceurl'] = $sourceInfo['source_url']; $config['source_content'] = parse_html($sourceInfo['source_content']); $config['source_ctime'] = isset($sourceInfo['ctime']) ? date('Y-m-d H:i:s', $sourceInfo['ctime']) : date('Y-m-d H:i:s'); if (!empty($add['to_uid'])) { // 回复 $config['comment_type'] = '回复 我 的评论:'; model('Notify')->sendNotify($add['to_uid'], 'comment', $config); } else { // 评论 $config['comment_type'] = '评论 我 的分享:'; if (!empty($add['app_uid'])) { model('Notify')->sendNotify($add['app_uid'], 'comment', $config); } } } } $this->error = $res ? L('PUBLIC_CONCENT_IS_OK') : L('PUBLIC_CONCENT_IS_ERROR'); // 评论成功,评论失败 return $res; }
<?php $ajaxPage = true; if ($_GET["key"] != $loguser["token"]) { die("Nope!"); } CheckPermission('user.voteposts'); $pid = (int) $_GET["id"]; $post = Fetch(Query("SELECT * FROM {posts} WHERE id = {0}", $pid)); if (!$post) { die("Unknown post"); } if ($post["user"] == $loguserid) { die("Nope!"); } $thread = Fetch(Query("SELECT * FROM {threads} WHERE id = {0}", $post["thread"])); if (!$thread) { die("Unknown thread"); } if (!HasPermission('forum.viewforum', $thread['forum'])) { die('Nice try hacker kid, but no.'); } if ($thread["closed"]) { die(__("Thread is closed")); } $vote = Fetch(Query("SELECT * FROM {postplusones} WHERE post = {0} AND user = {1}", $pid, $loguserid)); if (!$vote) { Query("UPDATE {posts} SET postplusones = postplusones+1 WHERE id = {0} LIMIT 1", $pid); Query("UPDATE {users} SET postplusones = postplusones+1 WHERE id = {0} LIMIT 1", $post["user"]); Query("UPDATE {users} SET postplusonesgiven = postplusonesgiven+1 WHERE id = {0} LIMIT 1", $loguserid); Query("INSERT INTO {postplusones} (user, post) VALUES ({0}, {1})", $loguserid, $pid);