function post_format(&$post) { global $conf; if (empty($post)) { return; } $post['create_date_fmt'] = humandate($post['create_date']); $user = $post['uid'] ? user_read_cache($post['uid']) : user_guest(); $post['username'] = $user['username']; $post['user_avatar_url'] = $user['avatar_url']; !isset($post['floor']) and $post['floor'] = ''; $post['agrees_class'] = 'agrees_' . thread_get_level($post['agrees'], $conf['agrees_level']); // 权限判断 global $uid, $sid, $longip; $post['allowupdate'] = $uid != 0 && $uid == $post['uid'] || $uid == 0 && $post['uid'] == 0 && $post['userip'] == $longip && $post['sid'] == $sid ? 1 : 0; $post['allowdelete'] = $uid != 0 && $uid == $post['uid'] || $uid == 0 && $post['uid'] == 0 && $post['userip'] == $longip && $post['sid'] == $sid ? 1 : 0; $post['user_url'] = "user-{$post['uid']}" . ($post['uid'] ? '' : "-{$post['pid']}") . ".htm"; }
function thread_format(&$thread) { global $conf, $forumlist; if (empty($thread)) { return; } $thread['create_date_fmt'] = humandate($thread['create_date']); $thread['last_date_fmt'] = humandate($thread['last_date']); $user = user_read_cache($thread['uid']); empty($user) and $user = user_guest(); $thread['username'] = $user['username']; $thread['user_avatar_url'] = $user['avatar_url']; $forum = $forumlist[$thread['fid']]; $thread['forumname'] = $forum['name']; if ($thread['last_date'] == $thread['create_date']) { //$thread['last_date'] = 0; $thread['last_date_fmt'] = ''; $thread['lastuid'] = 0; $thread['lastusername'] = ''; } else { $lastuser = $thread['lastuid'] ? user_read_cache($thread['lastuid']) : array(); $thread['lastusername'] = $thread['lastuid'] ? $lastuser['username'] : '******'; } $thread['seo_url'] = $conf['seo_url_rewrite'] && $thread['url_on'] ? thread_url_read($thread['tid']) : ''; $thread['url'] = $thread['seo_url'] ? $thread['seo_url'] : "thread-{$thread['tid']}.htm"; $thread['user_url'] = "user-{$thread['uid']}" . ($thread['uid'] ? '' : "-{$thread['firstpid']}") . ".htm"; $n = $thread['agrees'] + $thread['posts']; $agree_level = thread_get_level($n, $conf['agrees_level']); $thread['posts_class'] = 'posts_' . thread_get_level($thread['posts'], $conf['posts_level']); $thread['agrees_class'] = 'agrees_' . $agree_level; $thread['thread_class'] = 'thread_agrees_' . $agree_level; $thread['top_class'] = $thread['top'] ? 'thread_top_' . $thread['top'] : ''; }