Пример #1
0
function myagree_find_by_uid($uid, $page = 1, $pagesize = 20)
{
    $mylist = myagree_find(array('uid' => $uid), array('pid' => -1), $page, $pagesize);
    if (empty($mylist)) {
        return array();
    }
    $threadlist = array();
    foreach ($mylist as &$myagree) {
        $thread = thread_read($myagree['tid']);
        $post = post_read($myagree['pid']);
        $thread['agree_create_date_fmt'] = humandate($myagree['create_date']);
        $thread['message'] = $post['isfirst'] ? '' : htmlspecialchars(mb_substr(strip_tags($post['message']), 0, 42, 'UTF-8'));
        $threadlist[$myagree['pid']] = $thread;
    }
    return $threadlist;
}
Пример #2
0
            if ($subject != $thread['subject']) {
                mb_strlen($subject, 'UTF-8') > 80 and message(1, '标题最长80个字符');
                $arr['subject'] = $subject;
            }
            $arr and thread_update($tid, $arr) === FALSE and message(-1, '更新主题失败');
        }
        $r = post_update($pid, array('message' => $message));
        $r === FALSE and message(-1, '更新帖子失败');
        message(0, array('pid' => $pid, 'subject' => $subject, 'message' => $message));
    }
} 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 {
Пример #3
0
function post_read_cache($pid)
{
    static $cache = array();
    // 用静态变量只能在当前 request 生命周期缓存,要跨进程,可以再加一层缓存: memcached/xcache/apc/
    if (isset($cache[$pid])) {
        return $cache[$pid];
    }
    $cache[$pid] = post_read($pid);
    return $cache[$pid];
}