n $r; } // 版块版主权限判断: allowtop, allowmove, allowupdate, allowdelete, allowbanuser, allowviewip, allowdeleteuser function forum_access_mod($fid, $gid, $access) { global $grouplist, $forumlist, $uid; // 结果缓存,加速判断! static $result = array(); $k = $fid . '-' . $gid . '-' . $access; if (isset($result[$k])) return $result[$k]; if (1 == $gid || 2 == $gid) return TRUE; // 管理员有所有权限 if (3 == $gid || 4 == $gid) { $group = $grouplist[$gid]; $forum = $forumlist[$fid]; $r = !empty($group[$access]) && in_string($uid, $forum['moduids']); } else { $r = FALSE; } $result[$k] = $r; return $r; } function forum_is_mod($fid, $gid, $uid) { global $grouplist, $forumlist; if (1 == $gid || 2 == $gid) return TRUE; // 管理员有所有权限 if (3 == $gid || 4 == $gid) { if (0 == $fid) return TRUE; // 此处不严谨! $group = $grouplist[$gid]; $forum = $forumlist[$fid]; return in_string($uid, $forum['moduids']); } return FALSE; } // ------------> 其他方法 function forum_access_format(&$access) { if (empty($access)) return; } function forum_access_count($cond = array()) { $n = db_count('forum_access', $cond); return $n; } ?> // 入库过滤 非管理员全部过滤 $post['message'] = isset($post['gid']) && 1 == $post['gid'] ? $post['message'] : xn_html_safe($post['message']); break; case '1': $post['message'] = xn_txt_to_html($post['message']); break; default: $post['message'] = htmlspecialchars($post['message'], ENT_QUOTES); // html标签全部转换 break; } // 对引用进行处理 !empty($post['quotepid']) && $post['quotepid'] > 0 && $post['message'] = comment_quote($post['quotepid']) . $post['message']; } unset($post['gid']); } /*公用的附件模板,采用函数,效率比 include 高 * @param $filelist 附件列表 * @param bool $include_delete 删除 * @param bool $access TRUE编辑时附件路径 * @param bool $path TRUE后台编辑时附件路径 * @return string */ function data_file_list_html($filelist, $include_delete = FALSE, $access = FALSE, $path = FALSE) { global $conf; if (empty($filelist)) return ''; if (FALSE != $path) { if ($conf['url_rewrite_on'] > 1) { $path = $conf['path']; } else { $path = '../'; } } else { $path = ''; } $s = '
' . "\r\n"; return $s; } //--------------------------cache-------------------------- // 从缓存中读取,避免重复从数据库取数据 function data_read_cache($tid) { global $conf; $key = 'website_data_' . $tid; static $cache = array(); // 用静态变量只能在当前 request 生命周期缓存,要跨进程,可以再加一层缓存: memcached/xcache/apc/ if (isset($cache[$key])) return $cache[$key]; if ('mysql' == $conf['cache']['type']) { $r = data_read($tid); } else { $r = cache_get($key); if (NULL === $r) { $r = data_read($tid); $r and cache_set($key, $r, 1800); // 30分钟 } } $cache[$key] = $r ? $r : NULL; return $cache[$key]; } ?>