function agree_update($touid, $pid, $tid, $fid, $isfirst) { global $conf, $time, $group, $longip, $sid, $uid, $gid, $user; //user_login_check($user); if (!forum_access_user($fid, $gid, 'allowagree')) { return xn_error(10, '您(' . $user['groupname'] . ')无权限在此版块点喜欢'); } if ($uid > 0) { // 每日最大喜欢数限制 if ($time - $user['last_agree_date'] > 86400) { user__update($uid, array('last_agree_date' => $time)); $user['today_agrees'] = 0; } $user['last_agree_date'] = $time; $user['today_agrees']++; if ($user['today_agrees'] > $group['maxagrees']) { return xn_error(-1, '请您休息会,您所在的用户组每日最大喜欢数为:' . $group['maxagrees']); } $agree = myagree_read($pid, $uid); if ($agree) { // 取消喜欢 $r = myagree_delete($uid, $pid, $isfirst); if ($r === FALSE) { return xn_error(2, '取消喜欢失败'); } thread_tids_cache_delete_by_order($fid, 'agree'); return xn_error(1, '取消喜欢成功'); // 1 表示取喜欢喜欢,前台会根据此项判断减1 } else { // 点击喜欢 $r = myagree_create($uid, $touid, $pid, $tid, $isfirst); if ($r === FALSE) { return xn_error(2, '点喜欢失败'); } thread_tids_cache_delete_by_order($fid, 'agree'); return xn_error(0, '点喜欢成功'); } } else { // ip 限制 $n = guest_agree_count_by_ip($longip); if ($n > $group['maxagrees']) { return xn_error(-1, '请您休息会,您所在的用户组每日最大喜欢数为:' . $group['maxagrees']); } // sid 限制 $agree = guest_agree_read($sid, $pid); if ($agree) { // 取消喜欢 $r = guest_agree_delete($sid, $pid, $touid, $isfirst ? $tid : 0); if ($r === FALSE) { return xn_error(2, '取消喜欢失败'); } thread_tids_cache_delete_by_order($fid, 'agree'); return xn_error(1, '取消喜欢成功'); // 1 表示取消喜欢,前台会根据此项判断减1 } else { // 点击喜欢 $r = guest_agree_create($sid, $longip, $pid, $touid, $isfirst ? $tid : 0); if ($r === FALSE) { return xn_error(2, '点喜欢失败'); } thread_tids_cache_delete_by_order($fid, 'agree'); return xn_error(0, '点喜欢成功'); } } }
} } elseif ($action == 'delete') { $pid = param(2, 0); if ($method != 'POST') { message(-1, '方法不对'); } $post = post_read($pid); empty($post) and message(-1, '帖子不存在:' . $pid); $tid = $post['tid']; $thread = thread_read($tid); empty($thread) and message(-1, '主题不存在:' . $tid); $fid = $thread['fid']; $forum = forum_read($fid); empty($forum) and message(-1, '板块不存在:' . $fid); $isfirst = $post['isfirst']; !forum_access_user($fid, $gid, 'allowpost') and message(-1, '您(' . $user['groupname'] . ')无权限在此版块回帖'); $allowdelete = forum_access_mod($fid, $gid, 'allowdelete'); !$allowdelete and !$post['allowdelete'] and message(-1, '无权删除该帖'); if ($isfirst) { // 清除所有的回复。喜欢。还有相关资源 thread_delete($tid); } else { post_delete($pid); post_list_cache_delete($tid); } message(0, '删除成功'); // 接受 base64 文件上传 } elseif ($action == 'upload') { // 允许的文件后缀名 $types = (include './conf/attach.conf.php'); $allowtypes = $types['all'];
$first = $postlist[$thread['firstpid']]; unset($postlist[$thread['firstpid']]); $header['title'] = $thread['subject'] . '-' . $forum['name'] . '-' . $conf['sitename']; // 网站标题 $header['keywords'] = $header['title']; // 关键词 $keyword = param('keyword'); // 可能有关键字需要高亮显示 if ($keyword) { $thread['subject'] = post_highlight_keyword($thread['subject'], $keyword); //$first['message'] = post_highlight_keyword($first['subject']); } $allowpost = forum_access_user($fid, $gid, 'allowpost') ? 1 : 0; $allowupdate = forum_access_mod($fid, $gid, 'allowupdate') ? 1 : 0; $allowdelete = forum_access_mod($fid, $gid, 'allowdelete') ? 1 : 0; forum_access_user($fid, $gid, 'allowread') or message(-1, '您所在的用户组无权访问该板块。'); // ajax 不需要以下数据 // threadlist $page = 1; $pagesize = $conf['pagesize']; $pages = pages("forum-{$fid}-{page}.htm", $forum['threads'], $page, $pagesize); $threadlist = thread_find(array('fid' => $fid), array('tid' => -1), $page = 1, $pagesize); $seo_url = $thread['seo_url']; // 模板需要 // 升级需要查找附件 $attachlist = $imagelist = $filelist = array(); if ($first['images'] || $first['files']) { $attachlist = attach_find_by_pid($first['pid']); list($imagelist, $filelist) = attach_list_not_in_message($attachlist, $first['message']); } thread_inc_views($tid);
$action = param(1); $user = user_read($uid); empty($user) and $user = user_guest(); // 帖子列表数据,返回 html 格式 if ($action == 'list') { $pid = param(2); $post = post_read($pid); empty($post) and message(-1, '帖子不存在:' . $pid); $tid = $post['tid']; $thread = thread_read($tid); empty($thread) and message(-1, '主题不存在:' . $tid); $fid = $thread['fid']; $forum = forum_read($fid); empty($forum) and message(1, '板块不存在:' . $fid); $isfirst = $post['isfirst']; !forum_access_user($fid, $gid, 'allowread') and message(10, '您(' . $user['groupname'] . ')无权限查看此版块'); // 只提取前 100 个用户,过多用户展示无意义。 $agreelist = post_agree_find_by_pid($pid, 1, 100); $header['title'] = '赞过的用户:' . $post['agrees'] . '人'; include './pc/view/agree_list.htm'; } elseif ($action == 'update') { $pid = param(2); $post = post_read($pid); empty($post) and message(-1, '帖子不存在:' . $pid); $tid = $post['tid']; $thread = thread_read($tid); empty($thread) and message(-1, '主题不存在:' . $tid); $fid = $thread['fid']; $forum = forum_read($fid); empty($forum) and message(1, '板块不存在:' . $fid); $r = agree_update($post['uid'], $pid, $tid, $fid, $post['isfirst']);
!defined('DEBUG') and exit('Access Denied.'); include './xiunophp/xn_html_safe.func.php'; // 模板初始化依赖 $keyword = param('keyword'); !$keyword and $keyword = xn_urldecode(param(1)); $threadlist = thread_find_by_keyword($keyword); // 去除无权限的主题 thread_list_access_filter($threadlist, $gid); if (empty($threadlist) || empty($threadlist[0])) { $fid = 0; $tid = 0; $thread = array(); $postlist = array(); $first = array(); } else { $thread = $threadlist[0]; $tid = $thread['tid']; $fid = $thread['fid']; $postlist = post_find_by_tid($tid); $first = $postlist[$thread['firstpid']]; unset($postlist[$thread['firstpid']]); $allowpost = forum_access_user($fid, $gid, 'allowpost'); $allowupdate = forum_access_mod($fid, $gid, 'allowupdate'); $allowdelete = forum_access_mod($fid, $gid, 'allowdelete'); } $header['title'] = $keyword . '-' . $conf['sitename']; // 网站标题 $header['keywords'] = $keyword; // 关键词 $order = 'tid'; include './flarum/view/search.htm';
function thread_list_access_filter(&$threadlist, $gid) { global $conf, $forumlist; if (empty($threadlist)) { return; } foreach ($threadlist as $tid => $thread) { if (empty($forumlist[$thread['fid']]['accesson'])) { continue; } if ($thread['top'] > 0) { continue; } if (!forum_access_user($thread['fid'], $gid, 'allowread')) { unset($threadlist[$tid]); } } }