Esempio n. 1
0
function updatespacecache($uid, $module, $list = FALSE)
{
    global $_DCOOKIE, $db, $mod, $tablepre, $timestamp, $tpp, $page, $multipage, $starttime, $endtime, $spacedata, $lastvisit, $videoopen, $tradetypeid;
    if (!file_exists(DISCUZ_ROOT . './forumdata/cache/cache_spacesettings.php')) {
        require_once DISCUZ_ROOT . './include/cache.func.php';
        updatespacesettings();
    }
    require DISCUZ_ROOT . './forumdata/cache/cache_spacesettings.php';
    if ($list) {
        $tpp = $mod != 'mytrades' ? $tpp : 15;
        $page = max(1, intval($page));
        $start_limit = ($page - 1) * $tpp;
        $parms['items'] = "{$start_limit}, {$tpp}";
    } else {
        $parms['items'] = intval($spacedata['limit' . $module]);
    }
    $parms['list'] = $list;
    $parms['conditions'] = $parms['extraquery'] = '';
    $parms['cols'] = '*';
    $user_func = 'module_' . $module;
    $user_func($parms);
    $tids = $datalist = array();
    $query = $db->query("SELECT {$parms['cols']} FROM {$tablepre}{$parms['table']} {$parms['conditions']} LIMIT {$parms['items']}");
    while ($data = $db->fetch_array($query)) {
        if (!empty($data['message'])) {
            $data['message'] = spacecutstr($data['message'], $spacedata['textlength']);
            $videoopen && ($data['message'] = videocode($data['message'], $data['tid'], $data['pid']));
        }
        if ($data['tid'] && $lastvisit < $data['lastpost'] && (empty($_DCOOKIE['oldtopics']) || strpos($_DCOOKIE['oldtopics'], 'D' . $data['tid'] . 'D') === FALSE)) {
            $data['subject'] .= ' <a href="redirect.php?tid=' . $data['tid'] . '&amp;goto=newpost#newpost" target="_blank"><img src="' . IMGDIR . '/firstnew.gif" border="0" alt="" /></a>';
        }
        if ($parms['extraquery']) {
            $tids[] = $data['tid'];
            $datalist[$data['tid']] = $data;
        } else {
            $datalist[] = $data;
        }
    }
    if ($tids) {
        $query = $db->query($parms['extraquery'] . '(' . implodeids($tids) . ')');
        while ($data = $db->fetch_array($query)) {
            $datalist[$data['tid']] = array_merge($datalist[$data['tid']], $data);
        }
    }
    if (!$list) {
        $db->query("REPLACE INTO {$tablepre}spacecaches (uid, variable, value, expiration) VALUES ('{$uid}', '{$module}', '" . addslashes(serialize($datalist)) . "', '" . ($timestamp + $spacedata['cachelife']) . "')");
    } else {
        $num = $db->result_first("SELECT count(*) FROM {$tablepre}{$parms['table']} {$parms['conditions']}");
        $module = empty($parms['pagemodule']) ? $module : $parms['pagemodule'];
        $multipage = spacemulti($num, $tpp, $page, "space.php?uid={$uid}&amp;mod={$module}" . ($starttime ? "&amp;starttime={$starttime}" : '') . ($endtime ? "&amp;endtime={$endtime}" : '') . (isset($tradetypeid) ? "&amp;tradetypeid={$tradetypeid}" : ''));
    }
    return $datalist;
}
Esempio n. 2
0
function viewthread_procpost($post, $special = 0)
{
    global $_DCACHE, $newpostanchor, $numpost, $thisbg, $postcount, $ratelogpids, $onlineauthors, $lastvisit, $thread, $attachpids, $attachtags, $forum, $dateformat, $timeformat, $timeoffset, $userstatusby, $allowgetattach, $ratelogrecord, $showimages, $forum, $discuz_uid, $showavatars, $pagebydesc, $ppp, $ppp2, $ppp3, $firstpid, $videoopen, $threadpay, $sigviewcond;
    if (!$newpostanchor && $post['dateline'] > $lastvisit) {
        $post['newpostanchor'] = '<a name="newpost"></a>';
        $newpostanchor = 1;
    } else {
        $post['newpostanchor'] = '';
    }
    $post['lastpostanchor'] = $numpost == $thread['replies'] ? '<a name="lastpost"></a>' : '';
    if ($pagebydesc) {
        $post['number'] = $numpost + $ppp2--;
        $post['count'] = $ppp == $ppp3 ? $ppp - $postcount - 1 : $ppp3 - $postcount - 1;
    } else {
        $post['number'] = ++$numpost;
        $post['count'] = $postcount;
    }
    $postcount++;
    $post['dbdateline'] = $post['dateline'];
    $post['dateline'] = dgmdate("{$dateformat} {$timeformat}", $post['dateline'] + $timeoffset * 3600);
    $post['groupid'] = $_DCACHE['usergroups'][$post['groupid']] ? $post['groupid'] : 7;
    if ($post['username']) {
        $onlineauthors[] = $post['authorid'];
        $post['usernameenc'] = rawurlencode($post['username']);
        !$special && ($post['groupid'] = getgroupid($post['authorid'], $_DCACHE['usergroups'][$post['groupid']], $post));
        $post['readaccess'] = $_DCACHE['usergroups'][$post['groupid']]['readaccess'];
        if ($_DCACHE['usergroups'][$post['groupid']]['userstatusby'] == 1) {
            $post['authortitle'] = $_DCACHE['usergroups'][$post['groupid']]['grouptitle'];
            $post['stars'] = $_DCACHE['usergroups'][$post['groupid']]['stars'];
        } elseif ($_DCACHE['usergroups'][$post['groupid']]['userstatusby'] == 2) {
            foreach ($_DCACHE['ranks'] as $rank) {
                if ($post['posts'] > $rank['postshigher']) {
                    $post['authortitle'] = $rank['ranktitle'];
                    $post['stars'] = $rank['stars'];
                    break;
                }
            }
        }
        $post['taobaoas'] = addslashes($post['taobao']);
        $post['authoras'] = !$post['anonymous'] ? ' ' . addslashes($post['author']) : '';
        $post['regdate'] = gmdate($dateformat, $post['regdate'] + $timeoffset * 3600);
        $post['lastdate'] = gmdate($dateformat, $post['lastactivity'] + $timeoffset * 3600);
        if ($post['medals']) {
            @(include_once DISCUZ_ROOT . './forumdata/cache/cache_medals.php');
            foreach ($post['medals'] = explode("\t", $post['medals']) as $key => $medalid) {
                list($medalid, $medalexpiration) = explode("|", $medalid);
                if (isset($_DCACHE['medals'][$medalid]) && (!$medalexpiration || $medalexpiration > $timestamp)) {
                    $post['medals'][$key] = $_DCACHE['medals'][$medalid];
                } else {
                    unset($post['medals'][$key]);
                }
            }
        }
        if ($showavatars) {
            $post['avatar'] = discuz_uc_avatar($post['authorid']);
            if ($_DCACHE['usergroups'][$post['groupid']]['groupavatar']) {
                $post['avatar'] .= '<br /><img src="' . $_DCACHE['usergroups'][$post['groupid']]['groupavatar'] . '" border="0" alt="" />';
            }
        } else {
            $post['avatar'] = '';
        }
        $post['status'] = sprintf('%b', $post['status']);
        $post['banned'] = substr($post['status'], -1, 1);
        $post['warned'] = substr($post['status'], -2, 1);
        $post['msn'] = explode("\t", $post['msn']);
    } else {
        if (!$post['authorid']) {
            $post['useip'] = substr($post['useip'], 0, strrpos($post['useip'], '.')) . '.x';
        }
    }
    $post['attachments'] = array();
    if ($post['attachment']) {
        if ($allowgetattach && !$threadpay) {
            $attachpids .= ",{$post['pid']}";
            $post['attachment'] = 0;
            if (preg_match_all("/\\[attach\\](\\d+)\\[\\/attach\\]/i", $post['message'], $matchaids)) {
                $attachtags[$post['pid']] = $matchaids[1];
            }
        } else {
            $post['message'] = preg_replace("/\\[attach\\](\\d+)\\[\\/attach\\]/i", '', $post['message']);
        }
    }
    $ratelogpids .= $ratelogrecord && $post['rate'] ? ',' . $post['pid'] : '';
    $forum['allowbbcode'] = $forum['allowbbcode'] ? $_DCACHE['usergroups'][$post['groupid']]['allowcusbbcode'] ? 2 : 1 : 0;
    $post['signature'] = $post['usesig'] ? $sigviewcond ? strlen($post['message']) > $sigviewcond ? $post['signature'] : '' : $post['signature'] : '';
    $post['message'] = discuzcode($post['message'], $post['smileyoff'], $post['bbcodeoff'], $post['htmlon'] & 1, $forum['allowsmilies'], $forum['allowbbcode'], $forum['allowimgcode'] && $showimages ? 1 : 0, $forum['allowhtml'], $forum['jammer'] && $post['authorid'] != $discuz_uid ? 1 : 0, 0, $post['authorid'], $forum['allowmediacode'], $post['pid']);
    $videoopen && ($post['message'] = videocode($post['message'], $post['tid'], $post['pid']));
    $post['first'] && ($firstpid = $post['pid']);
    $firstpid = intval($firstpid);
    return $post;
}
Esempio n. 3
0
                        $post['authortitle'] = $rank['ranktitle'];
                        $post['stars'] = $rank['stars'];
                        break;
                    }
                }
            }
            $post['regdate'] = gmdate($dateformat, $post['regdate'] + $timeoffset * 3600);
        } else {
            if (!$post['authorid']) {
                $post['useip'] = substr($post['useip'], 0, strrpos($post['useip'], '.')) . '.x';
            }
            $post['posts'] = $post['credits'] = $post['regdate'] = 'N/A';
        }
        $post['dateline'] = gmdate("{$dateformat} {$timeformat}", $post['dateline'] + $timeoffset * 3600);
        $post['message'] = discuzcode($post['message'], $post['smileyoff'], $post['bbcodeoff'], sprintf('%00b', $post['htmlon']), $forum['allowsmilies'], $forum['allowbbcode'], $forum['allowimgcode'] && $showimages ? 1 : 0, $forum['allowhtml'], $forum['jammer'] && $post['authorid'] != $discuz_uid ? 1 : 0, 0, $post['authorid'], $post['pid']);
        $videoopen && ($post['message'] = videocode($post['message'], $tid, $post['pid']));
        $post['attachments'] = array();
        if ($post['attachment'] && (!empty($forum['allowgetattach']) || $allowgetattach && !$forum['getattachperm'] || forumperm($forum['getattachperm']))) {
            $attachpids .= ",{$post['pid']}";
            $post['attachment'] = 0;
            if (preg_match_all("/\\[attach\\](\\d+)\\[\\/attach\\]/i", $post['message'], $matchaids)) {
                $attachtags[$post['pid']] = $matchaids[1];
            }
        }
        $commentlist[$post['pid']] = $post;
    }
    if ($attachpids) {
        require_once DISCUZ_ROOT . './include/attachment.func.php';
        parseattach($attachpids, $attachtags, $commentlist);
    }
}