Exemple #1
0
function get_uploadcontent($attach, $type = 'portal', $dotype = '')
{
    $return = '';
    $dotype = $dotype ? 'checked' : '';
    if ($attach['isimage']) {
        $pic = pic_get($attach['attachment'], $type, $attach['thumb'], $attach['remote'], 0);
        $small_pic = $attach['thumb'] ? getimgthumbname($pic) : '';
        $check = $attach['pic'] == $type . '/' . $attach['attachment'] ? 'checked' : $dotype;
        $aid = $check ? $attach['aid'] : '';
        $return .= '<a href="javascript:;" class="opattach"><span class="opattach_ctrl">';
        $return .= '<span onclick="insertImage(\'' . $pic . '\');" class="cur1">' . lang('portalcp', 'insert_large_image') . '</span>';
        $return .= '<span class="pipe">|</span>';
        if ($small_pic) {
            $return .= '<span onclick="insertImage(\'' . $small_pic . '\', \'' . $pic . '\');" class="cur1">' . lang('portalcp', 'small_image') . '</span>';
        }
        $return .= '</span><img src="' . ($small_pic ? $small_pic : $pic) . '" onclick="insertImage(\'' . $pic . '\');" class="cur1"></a>';
        $return .= '<label for="setconver' . $attach['attachid'] . '" class="cur1 xi2"><input type="radio" name="setconver" id="setconver' . $attach['attachid'] . '" class="pr" value="1" onclick="setConver(\'' . addslashes(serialize(array('pic' => $type . '/' . $attach['attachment'], 'thumb' => $attach['thumb'], 'remote' => $attach['remote']))) . '\') ' . $check . '>' . lang('portalcp', 'set_to_conver') . '</label>';
        $return .= '<span class="pipe">|</span>';
        if ($type == 'portal') {
            $return .= '<span class="cur1 xi2" onclick="deleteAttach(\'' . $attach['attachid'] . '\', \'portal.php?mod=attachment&id=' . $attach['attachid'] . '&aid=' . $aid . '&op=delete\');">' . lang('portalcp', 'delete') . '</span>';
        }
    } else {
        $attach_url = $type == 'forum' ? 'forum.php?mod=attachment&aid=' . aidencode($attach['attachid'], 1) : 'portal.php?mod=attachment&id=' . $attach['attachid'];
        $return .= '<table id="attach_list_' . $attach['attachid'] . '" width="100%" class="xi2">';
        $return .= '<td width="50" class="bbs"><a href="' . $attach_url . '" target="_blank">' . $attach['filename'] . '</a></td>';
        $return .= '<td align="right" class="bbs">';
        $return .= '<a href="javascript:void(0);" onclick="insertFile(\'' . $attach['filename'] . '\', \'' . $attach_url . '\');return false;">' . lang('portalcp', 'insert_file') . '</a><br>';
        if ($type == 'portal') {
            $return .= '<a href="javascript:void(0);" onclick="deleteAttach(\'' . $attach['attachid'] . '\', \'portal.php?mod=attachment&id=' . $attach['attachid'] . '&op=delete\');return false;">' . lang('portalcp', 'delete') . '</a>';
        }
        $return .= '</td>';
        $return .= '</table>';
    }
    return $return;
}
        while ($attachment = $db->fetch_array($query)) {
            if (!$attachment['remote']) {
                $matched = file_exists($attachdir . '/' . $attachment['attachment']) ? '' : lang('attach_lost');
                $attachment['url'] = $attachurl;
            } else {
                @set_time_limit(0);
                if (@fclose(@fopen($ftp['attachurl'] . '/' . $attachment['attachment'], 'r'))) {
                    $matched = '';
                } else {
                    $matched = lang('attach_lost');
                }
                $attachment['url'] = $ftp['attachurl'];
            }
            $attachsize = sizecount($attachment['filesize']);
            if (!$nomatched || $nomatched && $matched) {
                $attachments .= showtablerow('', array('class="td25"', 'title="' . $attachment['description'] . '" class="td21"'), array("<input class=\"checkbox\" type=\"checkbox\" name=\"delete[]\" value=\"{$attachment['aid']}\" />", $attachment['remote'] ? "<span class=\"diffcolor3\">{$attachment['filename']}" : $attachment['filename'], "<a href=\"{$attachment['url']}/{$attachment['attachment']}\" class=\"smalltxt\" target=\"_blank\">" . cutstr($attachment['attachment'], 30) . "</a>", $attachment['author'], "<a href=\"viewthread.php?tid={$attachment['tid']}\" target=\"_blank\">" . cutstr($attachment['subject'], 20) . "</a>", $attachsize, $attachment['downloads'], $matched ? "<em class=\"error\">{$matched}<em>" : "<a href=\"attachment.php?aid=" . aidencode($attachment['aid']) . "&noupdate=yes\" target=\"_blank\" class=\"act nomargin\">{$lang['download']}</a>"), TRUE);
            }
        }
        $attachmentcount = $db->result_first("SELECT count(*) FROM {$tablepre}attachments a LEFT JOIN {$tablepre}attachmentfields af ON a.aid=af.aid, {$tablepre}posts p, {$tablepre}threads t, {$tablepre}forums f\r\n\t\t\tWHERE t.tid=a.tid AND f.fid=p.fid AND t.displayorder>='0' AND p.invisible='0' AND {$sql}");
        $multipage = multi($attachmentcount, $ppp, $page, "{$BASESCRIPT}?action=attachments");
        $multipage = preg_replace("/href=\"{$BASESCRIPT}\\?action=attachments&amp;page=(\\d+)\"/", "href=\"javascript:page(\\1)\"", $multipage);
        $multipage = str_replace("window.location={$BASESCRIPT}.'?action=attachments&amp;page='+this.value", "page(this.value)", $multipage);
        echo <<<EOT
<script type="text/JavaScript">
\tfunction page(number) {
\t\t\$('attachmentforum').page.value=number;
\t\t\$('attachmentforum').searchsubmit.click();
\t}
</script>
EOT;
        showtagheader('div', 'admin', $searchsubmit);
    } else {
        exit;
    }
}
if ($_G['setting']['attachexpire']) {
    $k = $_G['gp_k'];
    $t = $_G['gp_t'];
    $authk = !$requestmode ? substr(md5($aid . md5($_G['config']['security']['authkey']) . $t . $_G['gp_uid']), 0, 8) : md5($aid . md5($_G['config']['security']['authkey']) . $t);
    if (empty($k) || empty($t) || $k != $authk || TIMESTAMP - $t > $_G['setting']['attachexpire'] * 3600) {
        $aid = intval($aid);
        if ($attach = DB::fetch_first("SELECT pid, tid, isimage FROM " . DB::table('forum_attachment_' . $tableid) . " WHERE aid='{$aid}'")) {
            if ($attach['isimage']) {
                dheader('location: ' . $_G['siteurl'] . 'static/image/common/none.gif');
            } else {
                if (!$requestmode) {
                    showmessage('attachment_expired', '', array('aid' => aidencode($aid, 0, $attach['tid']), 'pid' => $attach['pid'], 'tid' => $attach['tid']));
                } else {
                    exit;
                }
            }
        } else {
            if (!$requestmode) {
                showmessage('attachment_nonexistence');
            } else {
                exit;
            }
        }
    }
}
$readmod = getglobal('config/download/readmod');
$readmod = $readmod > 0 && $readmod < 5 ? $readmod : 2;
 public function connectParseAttachTag($attachId, $attachNames)
 {
     include_once libfile('function/discuzcode');
     if (array_key_exists($attachId, $attachNames)) {
         return '<span class="attach"><a href="' . $_G['siteurl'] . '/attachment.php?aid=' . aidencode($attachId) . '">' . $attachNames[$attachId] . '</a></span>';
     }
     return '';
 }
function parseattachurl($aid, $ext, $ignoretid = 0)
{
    global $_G;
    $_G['forum_skipaidlist'][] = $aid;
    return $_G['siteurl'] . 'forum.php?mod=attachment&aid=' . aidencode($aid, $ext, $ignoretid ? '' : $_G['tid']) . ($ext ? '&request=yes&_f=.' . $ext : '');
}
 function getdata($style, $parameter)
 {
     global $_G;
     $parameter = $this->cookparameter($parameter);
     loadcache('forums');
     $fids = isset($parameter['fids']) && !in_array(0, (array) $parameter['fids']) ? $parameter['fids'] : array_keys($_G['cache']['forums']);
     $tids = !empty($parameter['tids']) ? explode(',', $parameter['tids']) : array();
     $startrow = isset($parameter['startrow']) ? intval($parameter['startrow']) : 0;
     $items = isset($parameter['items']) ? intval($parameter['items']) : 10;
     $digest = isset($parameter['digest']) ? $parameter['digest'] : 0;
     $special = isset($parameter['special']) ? $parameter['special'] : array();
     $rewardstatus = isset($parameter['rewardstatus']) ? intval($parameter['rewardstatus']) : 0;
     $titlelength = !empty($parameter['titlelength']) ? intval($parameter['titlelength']) : 40;
     $summarylength = !empty($parameter['summarylength']) ? intval($parameter['summarylength']) : 80;
     $orderby = isset($parameter['orderby']) ? in_array($parameter['orderby'], array('dateline', 'downloads', 'hourdownloads', 'todaydownloads', 'weekdownloads', 'monthdownloads')) ? $parameter['orderby'] : 'dateline' : 'dateline';
     $threadmethod = !empty($parameter['threadmethod']) ? 1 : 0;
     $isimage = isset($parameter['isimage']) ? intval($parameter['isimage']) : '';
     if ($fids) {
         $thefids = array();
         foreach ($fids as $fid) {
             if ($_G['cache']['forums'][$fid]['type'] == 'group') {
                 $thefids[] = $fid;
             }
         }
         if ($thefids) {
             foreach ($_G['cache']['forums'] as $value) {
                 if ($value['fup'] && in_array($value['fup'], $thefids)) {
                     $fids[] = intval($value['fid']);
                 }
             }
         }
         $fids = array_unique($fids);
     }
     $bannedids = !empty($parameter['bannedids']) ? explode(',', $parameter['bannedids']) : array();
     $datalist = $list = array();
     $sql = ($fids ? ' AND t.fid IN (' . dimplode($fids) . ')' : '') . ($tids ? ' AND t.tid IN (' . dimplode($tids) . ')' : '') . ($digest ? ' AND t.digest IN (' . dimplode($digest) . ')' : '') . ($special ? ' AND t.special IN (' . dimplode($special) . ')' : '') . (in_array(3, $special) && $rewardstatus ? $rewardstatus == 1 ? ' AND t.price < 0' : ' AND t.price > 0' : '') . " AND t.isgroup='0'";
     $orderbysql = $historytime = '';
     switch ($orderby) {
         case 'dateline':
             $orderbysql = "ORDER BY `attach`.`dateline` DESC";
             break;
         case 'downloads':
             $orderbysql = "ORDER BY `attach`.`downloads` DESC";
             break;
         case 'hourdownloads':
             $historytime = TIMESTAMP - 3600;
             $orderbysql = "ORDER BY `attach`.`downloads` DESC";
             break;
         case 'todaydownloads':
             $historytime = mktime(0, 0, 0, date('m', TIMESTAMP), date('d', TIMESTAMP), date('Y', TIMESTAMP));
             $orderbysql = "ORDER BY `attach`.`downloads` DESC";
             break;
         case 'weekdownloads':
             $week = gmdate('w', TIMESTAMP) - 1;
             $week = $week != -1 ? $week : 6;
             $historytime = mktime(0, 0, 0, date('m', TIMESTAMP), date('d', TIMESTAMP) - $week, date('Y', TIMESTAMP));
             $orderbysql = "ORDER BY `attach`.`downloads` DESC";
             break;
         case 'monthdownloads':
             $historytime = mktime(0, 0, 0, date('m', TIMESTAMP), 1, date('Y', TIMESTAMP));
             $orderbysql = "ORDER BY `attach`.`downloads` DESC";
             break;
     }
     $historytime = !$historytime ? TIMESTAMP - 8640000 : $historytime;
     $htsql = "`attach`.`dateline`>='{$historytime}'";
     $sqlfield = $sqljoin = '';
     if ($style['getsummary']) {
         $sqlfield = ',af.description';
         $sqljoin = "LEFT JOIN `" . DB::table('forum_attachmentfield') . "` af ON attach.aid=af.aid";
     }
     if ($isimage) {
         $sql .= $isimage == 1 ? "AND `attach`.`isimage` IN ('1', '-1')" : "AND `attach`.`isimage`='0'";
     }
     $sqlgroupby = '';
     if ($threadmethod) {
         if ($isimage == 1) {
             $sql .= ' AND t.attachment=2';
         } elseif ($isimage == 2) {
             $sql .= ' AND t.attachment=1';
         } else {
             $sql .= ' AND t.attachment>0';
         }
         $sqlgroupby = ' GROUP BY t.tid';
     }
     $sqlban = !empty($bannedids) ? ' AND attach.aid NOT IN (' . dimplode($bannedids) . ')' : '';
     $query = DB::query("SELECT attach.*,t.tid,t.author,t.authorid,t.subject {$sqlfield}\n\t\t\tFROM `" . DB::table('forum_attachment') . "` attach\n\t\t\t{$sqljoin}\n\t\t\tINNER JOIN `" . DB::table('forum_thread') . "` t\n\t\t\tON `t`.`tid`=`attach`.`tid` AND `displayorder`>='0'\n\t\t\tWHERE {$htsql} AND `attach`.`readperm`='0' AND `attach`.`price`='0'\n\t\t\t{$sql}\n\t\t\t{$sqlban}\n\t\t\t{$sqlgroupby}\n\t\t\t{$orderbysql}\n\t\t\tLIMIT {$startrow},{$items};");
     include_once libfile('block/thread', 'class');
     $bt = new block_thread();
     while ($data = DB::fetch($query)) {
         $list[] = array('id' => $data['aid'], 'idtype' => 'aid', 'title' => cutstr(str_replace('\\\'', '&#39;', $data['filename']), $titlelength), 'url' => 'forum.php?mod=attachment&aid=' . aidencode($data['aid']), 'pic' => $data['isimage'] == 1 || $data['isimage'] == -1 ? 'forum/' . $data['attachment'] : '', 'picflag' => $data['remote'] ? '2' : '1', 'summary' => !empty($data['description']) ? cutstr(str_replace('\\\'', '&#39;', $data['description']), $summarylength) : '', 'fields' => array('author' => $data['author'], 'authorid' => $data['authorid'], 'filesize' => sizecount($data['filesize']), 'dateline' => $data['dateline'], 'downloads' => $data['downloads'], 'hourdownloads' => $data['downloads'], 'todaydownloads' => $data['downloads'], 'weekdownloads' => $data['downloads'], 'monthdownloads' => $data['downloads'], 'threadurl' => 'forum.php?mod=viewthread&tid=' . $data['tid'], 'threadsubject' => cutstr(str_replace('\\\'', '&#39;', $data['subject']), $titlelength), 'threadsummary' => $bt->getthread($data['tid'], $summarylength)));
     }
     return array('html' => '', 'data' => $list);
 }
function packaids($attach)
{
    global $_G;
    return aidencode($attach['aid'], 0, $_G['tid']);
}
Exemple #8
0
        if ($status == 1) {
            showmessage('credits_balance_insufficient', '', array('title' => $_G['setting']['extcredits'][$_G['setting']['creditstransextra'][1]]['title'], 'minbalance' => $attach['price']));
        }
        foreach ($aids as $aid) {
            $updateauthor = 1;
            if ($_G['setting']['maxincperthread'] > 0) {
                $extcredit = 'extcredits' . $_G['setting']['creditstransextra'][1];
                if (DB::result_first("SELECT SUM({$extcredit}) FROM " . DB::table('common_credit_log') . " WHERE relatedid='{$aid}' AND uid='{$attach['uid']}' AND operation='SAC'") > $_G['setting']['maxincperthread']) {
                    $updateauthor = 0;
                }
            }
            if ($updateauthor) {
                updatemembercount($attach['uid'], array($_G['setting']['creditstransextra'][1] => $prices[$aid][1]), 1, 'SAC', $aid);
            }
            updatemembercount($_G['uid'], array($_G['setting']['creditstransextra'][1] => -$prices[$aid][0]), 1, 'BAC', $aid);
            $aidencode = aidencode($aid);
        }
        if (count($aids) > 1) {
            showmessage('attachment_buyall', 'forum.php?mod=redirect&goto=findpost&ptid=' . $attach['tid'] . '&pid=' . $attach['pid']);
        } else {
            $_G['forum_attach_filename'] = $attach['filename'];
            showmessage('attachment_buy', "forum.php?mod=attachment&aid={$aidencode}", array('filename' => $_G['forum_attach_filename']), array('redirectmsg' => 1));
        }
    }
} elseif ($_G['gp_action'] == 'viewattachpayments') {
    $aid = intval($_G['gp_aid']);
    $extcreditname = 'extcredits' . $_G['setting']['creditstransextra'][1];
    $loglist = array();
    $query = DB::query("SELECT l.*, m.username FROM " . DB::table('common_credit_log') . " l\r\n\t\tLEFT JOIN " . DB::table('common_member') . " m USING (uid)\r\n\t\tWHERE l.relatedid='{$aid}' AND l.operation='BAC' ORDER BY l.dateline");
    while ($log = DB::fetch($query)) {
        $log['dateline'] = dgmdate($log['dateline'], 'u');
function parseattachurl($aid, $ext) {
	$GLOBALS['skipaidlist'][] = $aid;
	return $GLOBALS['boardurl'].'attachment.php?aid='.aidencode($aid).($ext ? '&request=yes&_f=.'.$ext : '');
}
Exemple #10
0
        if ($status == 1) {
            showmessage('credits_balance_insufficient', '', array('title' => $_G['setting']['extcredits'][$_G['setting']['creditstransextra'][1]]['title'], 'minbalance' => $attach['price']));
        }
        foreach ($aids as $aid) {
            $updateauthor = 1;
            if ($_G['setting']['maxincperthread'] > 0) {
                $extcredit = 'extcredits' . $_G['setting']['creditstransextra'][1];
                if (DB::result_first("SELECT SUM({$extcredit}) FROM " . DB::table('common_credit_log') . " WHERE relatedid='{$aid}' AND uid='{$attach['uid']}' AND operation='SAC'") > $_G['setting']['maxincperthread']) {
                    $updateauthor = 0;
                }
            }
            if ($updateauthor) {
                updatemembercount($attach['uid'], array($_G['setting']['creditstransextra'][1] => $prices[$aid][1]), 1, 'SAC', $aid);
            }
            updatemembercount($_G['uid'], array($_G['setting']['creditstransextra'][1] => -$prices[$aid][0]), 1, 'BAC', $aid);
            $aidencode = aidencode($aid, 0, $_G['gp_tid']);
        }
        if (count($aids) > 1) {
            showmessage('attachment_buyall', 'forum.php?mod=redirect&goto=findpost&ptid=' . $attach['tid'] . '&pid=' . $attach['pid']);
        } else {
            $_G['forum_attach_filename'] = $attach['filename'];
            showmessage('attachment_buy', "forum.php?mod=attachment&aid={$aidencode}", array('filename' => $_G['forum_attach_filename']), array('redirectmsg' => 1));
        }
    }
} elseif ($_G['gp_action'] == 'viewattachpayments') {
    $aid = intval($_G['gp_aid']);
    $extcreditname = 'extcredits' . $_G['setting']['creditstransextra'][1];
    $loglist = array();
    $query = DB::query("SELECT l.*, m.username FROM " . DB::table('common_credit_log') . " l\r\n\t\tLEFT JOIN " . DB::table('common_member') . " m USING (uid)\r\n\t\tWHERE l.relatedid='{$aid}' AND l.operation='BAC' ORDER BY l.dateline");
    while ($log = DB::fetch($query)) {
        $log['dateline'] = dgmdate($log['dateline'], 'u');
Exemple #11
0
        foreach ($_G['setting']['extcredits'] as $id => $credit) {
            if ($log['extcredits' . $id]) {
                $log['update'] .= $credit['title'] . $log['extcredits' . $id] . $credit['unit'] . '&nbsp;';
            }
        }
        $related = '';
        if ($log['operation'] == 'TRC') {
            $related = '<a href="home.php?mod=task&do=view&id=' . $log['relatedid'] . '" target="_blank">' . cplang('logs_task_id') . ':' . $log['relatedid'] . ' ' . cplang('logs_click2view') . '</a>';
        } elseif (in_array($log['operation'], array('RTC', 'RAC', 'STC', 'BTC', 'ACC'))) {
            $related = '<a href="forum.php?mod=viewthread&tid=' . $log['relatedid'] . '" target="_blank">' . cplang('logs_thread_id') . ':' . $log['relatedid'] . ' ' . cplang('logs_click2view') . '</a>';
        } elseif ($log['operation'] == 'MRC') {
            $related = cplang('logs_magic_id') . ':' . $log['relatedid'];
        } elseif (in_array($log['operation'], array('TFR', 'RCV', 'CEC', 'ECU', 'AFD'))) {
            $related = '<a href="home.php?mod=space&uid=' . $log['relatedid'] . '&do=profile" target="_blank">' . cplang('uid') . ':' . $log['relatedid'] . ' ' . cplang('logs_click2view') . '</a>';
        } elseif (in_array($log['operation'], array('BAC', 'SAC'))) {
            $aid = aidencode($log['relatedid']);
            $related = '<a href="forum.php?mod=attachment&aid=' . $aid . '&nothumb=yes" target="_blank">' . cplang('logs_attach_id') . ':' . $log['relatedid'] . ' ' . cplang('logs_click2view') . '</a>';
        } elseif ($log['operation'] == 'PRC') {
            $related = cplang('logs_post_id') . ':' . $log['relatedid'];
        } elseif ($log['operation'] == 'UGP') {
            $related = $_G['cache']['group'][$log['relatedid']]['grouptitle'];
        } elseif ($log['operation'] == 'RPC') {
            $related = cplang('logs_report_id') . ':' . $log['relatedid'];
        }
        showtablerow('', array('class="bold"'), array("<a href=\"home.php?mod=space&uid={$log['uid']}\" target=\"_blank\">{$log['username']}", $log['dateline'], cplang('logs_credit_update_' . $log['operation']), $log['update'], $related));
    }
    showsubmit('', '', '', '', $multipage);
} elseif ($operation == 'mods') {
    $modactioncode = lang('forum/modaction');
    showtablerow('class="header"', array('class="td23"', 'class="td23"', 'class="td23"', 'class="td23"', 'class="td24"', 'class="td24"', 'class="td23"'), array(cplang('operator'), cplang('usergroup'), cplang('ip'), cplang('time'), cplang('forum'), cplang('thread'), cplang('action'), cplang('reason')));
    foreach ($logs as $logrow) {
			foreach($_DTYPE as $optionid => $option) {
				$optionlist[$option['identifier']]['title'] = $_DTYPE[$optionid]['title'];
				$optionlist[$option['identifier']]['unit'] = $_DTYPE[$optionid]['unit'];
				if($_DTYPE[$optionid]['type'] == 'checkbox') {
					$optionlist[$option['identifier']]['value'] = '';
					foreach(explode("\t", $optiondata[$optionid]) as $choiceid) {
						$optionlist[$option['identifier']]['value'] .= $_DTYPE[$optionid]['choices'][$choiceid].'&nbsp;';
					}
				} elseif(in_array($_DTYPE[$optionid]['type'], array('radio', 'select'))) {
					$optionlist[$option['identifier']]['value'] = $_DTYPE[$optionid]['choices'][$optiondata[$optionid]];
				} elseif($_DTYPE[$optionid]['type'] == 'image') {
					$maxwidth = $_DTYPE[$optionid]['maxwidth'] ? 'width="'.$_DTYPE[$optionid]['maxwidth'].'"' : '';
					$maxheight = $_DTYPE[$optionid]['maxheight'] ? 'height="'.$_DTYPE[$optionid]['maxheight'].'"' : '';
					if(preg_match("/^\[aid=(\d+)\]$/", $optiondata[$optionid], $r)) {
						$skipaids[] = $r[1];
						$optiondata[$optionid] = 'attachment.php?aid='.aidencode($r[1]);
					}
					$optionlist[$option['identifier']]['value'] = $optiondata[$optionid] ? "<a href=\"$optiondata[$optionid]\" target=\"_blank\"><img src=\"$optiondata[$optionid]\" onload=\"thumbImg(this)\" $maxwidth $maxheight border=\"0\"></a>" : '';
				} elseif($_DTYPE[$optionid]['type'] == 'url') {
					$optionlist[$option['identifier']]['value'] = $optiondata[$optionid] ? "<a href=\"$optiondata[$optionid]\" target=\"_blank\">$optiondata[$optionid]</a>" : '';
				} elseif($_DTYPE[$optionid]['type'] == 'textarea') {
					$optionlist[$option['identifier']]['value'] = $optiondata[$optionid] ? nl2br($optiondata[$optionid]) : '';
				} else {
					$optionlist[$option['identifier']]['value'] = $optiondata[$optionid];
				}
			}

			if($_DTYPETEMPLATE) {
				foreach($_DTYPE as $option) {
					$searchtitle[] = '/{('.$option['identifier'].')}/e';
					$searchvalue[] = '/\[('.$option['identifier'].')value\]/e';
 function getdata($style, $parameter)
 {
     global $_G;
     $parameter = $this->cookparameter($parameter);
     loadcache('grouptype');
     $typeids = array();
     if (!empty($parameter['gtids'])) {
         if ($parameter['gtids'][0] == '0') {
             unset($parameter['gtids'][0]);
         }
         $typeids = $parameter['gtids'];
     }
     $startrow = isset($parameter['startrow']) ? intval($parameter['startrow']) : 0;
     $items = isset($parameter['items']) ? intval($parameter['items']) : 10;
     $titlelength = !empty($parameter['titlelength']) ? intval($parameter['titlelength']) : 40;
     $summarylength = !empty($parameter['summarylength']) ? intval($parameter['summarylength']) : 80;
     $digest = isset($parameter['digest']) ? $parameter['digest'] : 0;
     $special = isset($parameter['special']) ? $parameter['special'] : array();
     $rewardstatus = isset($parameter['rewardstatus']) ? intval($parameter['rewardstatus']) : 0;
     $orderby = isset($parameter['orderby']) ? in_array($parameter['orderby'], array('dateline', 'downloads')) ? $parameter['orderby'] : 'dateline' : 'dateline';
     $dateline = isset($parameter['dateline']) ? intval($parameter['dateline']) : '8640000';
     $threadmethod = !empty($parameter['threadmethod']) ? 1 : 0;
     $isimage = isset($parameter['isimage']) ? intval($parameter['isimage']) : '';
     $gviewperm = isset($parameter['gviewperm']) ? intval($parameter['gviewperm']) : -1;
     $bannedids = !empty($parameter['bannedids']) ? explode(',', $parameter['bannedids']) : array();
     $gviewwhere = $gviewperm == -1 ? '' : " AND ff.gviewperm='{$gviewperm}'";
     $groups = array();
     if (empty($fids) && $typeids) {
         $query = DB::query('SELECT f.fid, f.name, ff.description FROM ' . DB::table('forum_forum') . " f LEFT JOIN " . DB::table('forum_forumfield') . " ff ON f.fid = ff.fid WHERE f.fup IN (" . dimplode($typeids) . ") AND threads > 0{$gviewwhere}");
         while ($value = DB::fetch($query)) {
             $groups[$value['fid']] = $value;
             $fids[] = intval($value['fid']);
         }
         if (empty($fids)) {
             return array('html' => '', 'data' => '');
         }
     }
     $datalist = $list = array();
     $sql = ($fids ? ' AND t.fid IN (' . dimplode($fids) . ')' : '') . ($tids ? ' AND t.tid IN (' . dimplode($tids) . ')' : '') . ($digest ? ' AND t.digest IN (' . dimplode($digest) . ')' : '') . ($special ? ' AND t.special IN (' . dimplode($special) . ')' : '') . (in_array(3, $special) && $rewardstatus ? $rewardstatus == 1 ? ' AND t.price < 0' : ' AND t.price > 0' : '');
     if (empty($fids)) {
         $sql .= " AND t.isgroup='1'";
         if ($gviewwhere) {
             $sql .= $gviewwhere;
         }
     }
     $orderbysql = $historytime = '';
     switch ($orderby) {
         case 'dateline':
             $orderbysql = "ORDER BY `attach`.`dateline` DESC";
             break;
         case 'downloads':
             $orderbysql = "ORDER BY `attach`.`downloads` DESC";
             break;
     }
     $htsql = '';
     $dateline = !empty($dateline) ? intval($dateline) : 8640000;
     $historytime = TIMESTAMP - $dateline;
     $htsql = "`attach`.`dateline`>='{$historytime}'";
     $sqlfield = $sqljoin = '';
     if ($style['getsummary']) {
         $sqlfield = ',af.description';
         $sqljoin = "LEFT JOIN `" . DB::table('forum_attachmentfield') . "` af ON attach.aid=af.aid";
     }
     if ($isimage) {
         $sql .= $isimage == 1 ? "AND `attach`.`isimage` IN ('1', '-1')" : "AND `attach`.`isimage`='0'";
     }
     $sqlgroupby = '';
     if ($threadmethod) {
         if ($isimage == 1) {
             $sql .= ' AND t.attachment=2';
         } elseif ($isimage == 2) {
             $sql .= ' AND t.attachment=1';
         } else {
             $sql .= ' AND t.attachment>0';
         }
         $sqlgroupby = ' GROUP BY t.tid';
     }
     $sqlban = !empty($bannedids) ? ' AND attach.tid NOT IN (' . dimplode($bannedids) . ')' : '';
     if (empty($fids)) {
         $sqlfield = ', f.name groupname';
         $sqljoin .= ' LEFT JOIN ' . DB::table('forum_forum') . ' f ON t.fid=f.fid LEFT JOIN ' . DB::table('forum_forumfield') . ' ff ON f.fid = ff.fid';
     }
     $query = DB::query("SELECT attach.*,t.tid,t.author,t.authorid,t.subject {$sqlfield}\r\n\t\t\tFROM `" . DB::table('forum_attachment') . "` attach\r\n\t\t\tINNER JOIN `" . DB::table('forum_thread') . "` t\r\n\t\t\tON `t`.`tid`=`attach`.`tid` AND `displayorder`>='0'\r\n\t\t\t{$sqljoin}\r\n\t\t\tWHERE {$htsql} AND `attach`.`readperm`='0' AND `attach`.`price`='0'\r\n\t\t\t{$sql}\r\n\t\t\t{$sqlban}\r\n\t\t\t{$sqlgroupby}\r\n\t\t\t{$orderbysql}\r\n\t\t\tLIMIT {$startrow},{$items};");
     require_once libfile('block_thread', 'class/block/forum');
     $bt = new block_thread();
     while ($data = DB::fetch($query)) {
         $list[] = array('id' => $data['aid'], 'idtype' => 'aid', 'title' => cutstr(str_replace('\\\'', '&#39;', $data['filename']), $titlelength, ''), 'url' => 'forum.php?mod=attachment&aid=' . aidencode($data['aid']), 'pic' => $data['isimage'] == 1 || $data['isimage'] == -1 ? 'forum/' . $data['attachment'] : '', 'picflag' => $data['remote'] ? '2' : '1', 'summary' => $data['description'] ? cutstr(str_replace('\\\'', '&#39;', $data['description']), $summarylength, '') : '', 'fields' => array('fulltitle' => str_replace('\\\'', '&#39;', addslashes($data['subject'])), 'author' => $data['author'], 'authorid' => $data['authorid'], 'filesize' => sizecount($data['filesize']), 'dateline' => $data['dateline'], 'downloads' => $data['downloads'], 'hourdownloads' => $data['downloads'], 'todaydownloads' => $data['downloads'], 'weekdownloads' => $data['downloads'], 'monthdownloads' => $data['downloads'], 'threadurl' => 'forum.php?mod=viewthread&tid=' . $data['tid'], 'threadsubject' => cutstr(str_replace('\\\'', '&#39;', $data['subject']), $titlelength, ''), 'threadsummary' => $bt->getthread($data['tid'], $summarylength)));
     }
     return array('html' => '', 'data' => $list);
 }
function attachinpost($attach) {
global $attachrefcheck, $extcredits, $creditstrans, $creditstransextra, $ftp, $thumbstatus, $attachimgpost;
$attach['refcheck'] = (!$attach['remote'] && $attachrefcheck) || ($attach['remote'] && ($ftp['hideurl'] || ($attach['isimage'] && $attachimgpost && strtolower(substr($ftp['attachurl'], 0, 3)) == 'ftp')));
$aidencode = aidencode($attach['aid']);
 ?><?
$__IMGDIR = IMGDIR;$return = <<<EOF


EOF;
 if(!isset($attach['unpayed'])) { if($attach['attachimg']) { if(!IS_ROBOT) { 
$return .= <<<EOF

<span style="position: absolute; display: none" id="attach_{$attach['aid']}" onmouseover="showMenu({'ctrlid':this.id,'pos':'13'})"><img src="{$__IMGDIR}/attachimg.gif" border="0"></span>

EOF;
 if($thumbstatus && $attach['thumb']) { 
$return .= <<<EOF

<a href="javascript:;"><img onclick="zoom(this, '
EOF;
 if($attach['refcheck']) { 
$return .= <<<EOF
attachment.php?aid={$aidencode}&amp;noupdate=yes&amp;nothumb=yes
EOF;
 } else { 
$return .= <<<EOF
{$attach['url']}/{$attach['attachment']}
EOF;
 } 
$return .= <<<EOF
')" src="
EOF;
 if($attach['refcheck']) { 
$return .= <<<EOF
attachment.php?aid={$aidencode}
EOF;
 } else { 
$return .= <<<EOF
{$attach['url']}/{$attach['attachment']}.thumb.jpg
EOF;
 } 
$return .= <<<EOF
" border="0" id="aimg_{$attach['aid']}" onmouseover="showMenu({'ctrlid':this.id,'pos':'12'})" /></a>

EOF;
 } else { $GLOBALS['aimgs'][$attach['pid']][] = $attach['aid']; $widthcode = attachwidth($attach['width']); 
$return .= <<<EOF
<img src="images/common/none.gif" file="
EOF;
 if($attach['refcheck']) { 
$return .= <<<EOF
attachment.php?aid={$aidencode}&amp;noupdate=yes
EOF;
 } else { 
$return .= <<<EOF
{$attach['url']}/{$attach['attachment']}
EOF;
 } 
$return .= <<<EOF
" {$widthcode} id="aimg_{$attach['aid']}" onmouseover="showMenu({'ctrlid':this.id,'pos':'12'})" alt="{$attach['filename']}" />

EOF;
 } 
$return .= <<<EOF

<div class="t_attach" id="aimg_{$attach['aid']}_menu" style="position: absolute; display: none">				
<a href="attachment.php?aid={$aidencode}&amp;nothumb=yes" title="{$attach['filename']}" target="_blank"><strong>下载</strong></a> ({$attach['attachsize']})<br />

EOF;
 if($attach['description']) { 
$return .= <<<EOF
{$attach['description']}<br />
EOF;
 } } else { 
$return .= <<<EOF

<dl class="t_attachlist attachimg">

EOF;
 if(!$attach['price'] || $attach['payed']) { if($attach['description']) { 
$return .= <<<EOF
<p>{$attach['description']}</p>
EOF;
 } 
$return .= <<<EOF

<img src="
EOF;
 if($attach['refcheck']) { 
$return .= <<<EOF
attachment.php?aid={$aidencode}&amp;noupdate=yes
EOF;
 } else { 
$return .= <<<EOF
{$attach['url']}/{$attach['attachment']}
EOF;
 } 
$return .= <<<EOF
" alt="{$attach['filename']}" />

EOF;
 } 
$return .= <<<EOF

<div style="display: none">

EOF;
 } } else { 
$return .= <<<EOF

{$attach['attachicon']} <span style="white-space: nowrap" id="attach_{$attach['aid']}" onmouseover="showMenu({'ctrlid':this.id,'pos':'12'})"><a href="attachment.php?aid={$aidencode}" target="_blank"
EOF;
 if(!$attach['attachimg'] && $GLOBALS['attachcredits']) { 
$return .= <<<EOF
 onclick="return creditconfirm('{$GLOBALS['attachcredits']}');"
EOF;
 } 
$return .= <<<EOF
><strong>{$attach['filename']}</strong></a></span> ({$attach['attachsize']})
<div class="t_attach" id="attach_{$attach['aid']}_menu" style="position: absolute; display: none">

EOF;
 if($attach['description']) { 
$return .= <<<EOF
{$attach['description']}<br />
EOF;
 } 
$return .= <<<EOF

下载次数: {$attach['downloads']}<br />

EOF;
 if($attach['readperm']) { 
$return .= <<<EOF
阅读权限: {$attach['readperm']}<br />
EOF;
 } } if($attach['price']) { 
$return .= <<<EOF

售价: {$extcredits[$creditstransextra['1']]['title']} {$attach['price']} {$extcredits[$creditstransextra['1']]['unit']}<br />
<a href="misc.php?action=viewattachpayments&amp;aid={$attach['aid']}" onclick="showWindow('attachpay', this.href);return false;" target="_blank">[记录]</a>

EOF;
 } 
$return .= <<<EOF

<div class="t_smallfont">{$attach['dateline']}</div>

EOF;
 if(!$attach['attachimg'] && $GLOBALS['attachcredits']) { 
$return .= <<<EOF
下载消耗 {$GLOBALS['attachcredits']}<br />
EOF;
 } 
$return .= <<<EOF

</div>

EOF;
 } else { 
$return .= <<<EOF

{$attach['attachicon']} <strong>收费附件: {$attach['filename']}</strong>

EOF;
 } 
$return .= <<<EOF


EOF;
?><? return $return; }
function threadsortshow($sortid, $tid)
{
    global $_G;
    loadcache(array('threadsort_option_' . $sortid, 'threadsort_template_' . $sortid));
    $sortoptionarray = $_G['cache']['threadsort_option_' . $sortid];
    $templatearray = $_G['cache']['threadsort_template_' . $sortid];
    $threadsortshow = $optiondata = $searchtitle = $searchvalue = $searchunit = $memberinfofield = $_G['forum_option'] = array();
    $sql = "SELECT p.pid,p.fid,p.authorid FROM " . DB::table('forum_post') . " p WHERE p.tid =" . $tid . " and p.position=1 LIMIT 0, 1";
    $query = DB::query($sql);
    $vanfon_tid = 0;
    $vanfon_fid = 0;
    $vanfon_uid = 0;
    while ($result = DB::fetch($query)) {
        $vanfon_tid = $result['pid'];
        $vanfon_fid = $result['fid'];
        $vanfon_uid = $result['authorid'];
    }
    $vanfon_verify = '';
    $verifyuids = array();
    $verifyuids[$vanfon_uid] = $vanfon_uid;
    foreach (C::t('common_member_verify')->fetch_all($verifyuids) as $value) {
        foreach ($_G['setting']['verify'] as $vid => $vsetting) {
            if ($vsetting['available'] && $vsetting['showicon'] && $value['verify' . $vid] == 1) {
                $srcurl = '';
                if (!empty($vsetting['icon'])) {
                    $srcurl = $vsetting['icon'];
                }
                $vanfon_verify .= "<a href=\"home.php?mod=spacecp&ac=profile&op=verify&vid={$vid}\" target=\"_blank\">" . (!empty($srcurl) ? '<img src="' . $srcurl . '" class="vm" alt="' . $vsetting['title'] . '" title="' . $vsetting['title'] . '" />' : $vsetting['title']) . '</a>';
            } else {
                /*$srcurl = '';
                		$srcurl =   $vsetting['unverifyicon'];
                			$vanfon_verify .= "<a href=\"home.php?mod=spacecp&ac=profile&op=verify&vid=$vid\" target=\"_blank\">".(!empty($srcurl) ? '<img src="'.$srcurl.'" class="vm" alt="'.$vsetting['title'].'" title="'.$vsetting['title'].'" />' : $vsetting['title']).'</a>';*/
            }
        }
    }
    $sql = "SELECT m.groupid,g.icon FROM " . DB::table('common_member') . " m ," . DB::table('common_usergroup') . " g WHERE m.uid =" . $vanfon_uid . " and m.groupid=g.groupid LIMIT 0, 1";
    $query = DB::query($sql);
    $vanfon_usergroup = 0;
    while ($result = DB::fetch($query)) {
        $vanfon_usergroup = $result['icon'];
    }
    if ($sortoptionarray) {
        foreach (C::t('forum_typeoptionvar')->fetch_all_by_tid_optionid($tid) as $option) {
            $optiondata[$option['optionid']]['value'] = $option['value'];
            $optiondata[$option['optionid']]['expiration'] = $option['expiration'] && $option['expiration'] <= TIMESTAMP ? 1 : 0;
            $sortdataexpiration = $option['expiration'];
        }
        foreach ($sortoptionarray as $optionid => $option) {
            $_G['forum_option'][$option['identifier']]['title'] = $option['title'];
            $_G['forum_option'][$option['identifier']]['unit'] = $option['unit'];
            $_G['forum_option'][$option['identifier']]['type'] = $option['type'];
            if ($option['expiration'] && !$optiondata[$optionid]['expiration'] || empty($option['expiration'])) {
                if (!protectguard($option['protect'])) {
                    if ($option['type'] == 'checkbox') {
                        $_G['forum_option'][$option['identifier']]['value'] = '';
                        foreach (explode("\t", $optiondata[$optionid]['value']) as $choiceid) {
                            $_G['forum_option'][$option['identifier']]['value'] .= $option['choices'][$choiceid] . '&nbsp;';
                        }
                    } elseif ($option['type'] == 'radio') {
                        $_G['forum_option'][$option['identifier']]['value'] = $option['choices'][$optiondata[$optionid]['value']];
                    } elseif ($option['type'] == 'select') {
                        $tmpchoiceid = $tmpidentifiervalue = array();
                        foreach (explode('.', $optiondata[$optionid]['value']) as $choiceid) {
                            $tmpchoiceid[] = $choiceid;
                            $tmpidentifiervalue[] = $option['choices'][implode('.', $tmpchoiceid)];
                        }
                        $_G['forum_option'][$option['identifier']]['value'] = implode(' &raquo; ', $tmpidentifiervalue);
                        unset($tmpchoiceid, $tmpidentifiervalue);
                    } elseif ($option['type'] == 'image') {
                        $imgoptiondata = dunserialize($optiondata[$optionid]['value']);
                        $threadsortshow['sortaids'][] = $imgoptiondata['aid'];
                        if (empty($templatearray['viewthread'])) {
                            $maxwidth = $option['maxwidth'] ? 'width="' . $option['maxwidth'] . '"' : '';
                            $maxheight = $option['maxheight'] ? 'height="' . $option['maxheight'] . '"' : '';
                            if (!defined('IN_MOBILE')) {
                                $_G['forum_option'][$option['identifier']]['value'] = $imgoptiondata['url'] ? "<img src=\"" . $imgoptiondata['url'] . "\" onload=\"thumbImg(this)\" {$maxwidth} {$maxheight} border=\"0\">" : '';
                            } else {
                                $_G['forum_option'][$option['identifier']]['value'] = $imgoptiondata['url'] ? "<a href=\"" . $imgoptiondata['url'] . "\" target=\"_blank\">" . lang('forum/misc', 'click_view') . "</a>" : '';
                            }
                        } else {
                            $_G['forum_option'][$option['identifier']]['value'] = $imgoptiondata['url'] ? $imgoptiondata['url'] : './static/image/common/nophoto.gif';
                        }
                    } elseif ($option['type'] == 'face') {
                        $faceoptiondata = dunserialize($optiondata[$optionid]['value']);
                        $_G['forum_option'][$option['identifier']]['value'] = "forum.php?mod=attachment&aid=" . aidencode($faceoptiondata['aid']);
                        $attach = C::t('forum_attachment')->fetch($faceoptiondata['aid']);
                        $_G['forum_option'][$option['identifier']]['downloads'] = $attach['downloads'];
                        $threadsortshow['sortaids'][] = $faceoptiondata['aid'];
                    } elseif ($option['type'] == 'url') {
                        $_G['forum_option'][$option['identifier']]['value'] = $optiondata[$optionid]['value'] ? "<a href=\"" . $optiondata[$optionid]['value'] . "\" target=\"_blank\">" . $optiondata[$optionid]['value'] . "</a>" : '';
                    } elseif ($option['type'] == 'number') {
                        $_G['forum_option'][$option['identifier']]['value'] = $optiondata[$optionid]['value'];
                    } else {
                        if ($option['protect']['status'] && $optiondata[$optionid]['value']) {
                            $optiondata[$optionid]['value'] = $option['protect']['mode'] == 1 ? '<image src="' . stringtopic($optiondata[$optionid]['value']) . '">' : (!defined('IN_MOBILE') ? '<span id="sortmessage_' . $option['identifier'] . '"><a href="###" onclick="ajaxget(\'forum.php?mod=misc&action=protectsort&tid=' . $tid . '&optionid=' . $optionid . '\', \'sortmessage_' . $option['identifier'] . '\');return false;">' . lang('forum/misc', 'click_view') . '</a></span>' : $optiondata[$optionid]['value']);
                            $_G['forum_option'][$option['identifier']]['value'] = $optiondata[$optionid]['value'] ? $optiondata[$optionid]['value'] : $option['defaultvalue'];
                        } elseif ($option['type'] == 'textarea') {
                            $_G['forum_option'][$option['identifier']]['value'] = $optiondata[$optionid]['value'] ? nl2br($optiondata[$optionid]['value']) : '';
                        } else {
                            $_G['forum_option'][$option['identifier']]['value'] = $optiondata[$optionid]['value'] ? $optiondata[$optionid]['value'] : $option['defaultvalue'];
                        }
                    }
                } else {
                    if (empty($option['permprompt'])) {
                        $_G['forum_option'][$option['identifier']]['value'] = lang('forum/misc', 'view_noperm');
                    } else {
                        $_G['forum_option'][$option['identifier']]['value'] = $option['permprompt'];
                    }
                }
            } else {
                $_G['forum_option'][$option['identifier']]['value'] = lang('forum/misc', 'has_expired');
            }
        }
        $typetemplate = '';
        if ($templatearray['viewthread']) {
            foreach ($sortoptionarray as $option) {
                $searchtitle[] = '/{(' . $option['identifier'] . ')}/e';
                $searchvalue[] = '/\\[(' . $option['identifier'] . ')value\\]/e';
                $searchvalue[] = '/{(' . $option['identifier'] . ')_value}/e';
                $searchunit[] = '/\\[(' . $option['identifier'] . ')unit\\]/e';
                $searchunit[] = '/{(' . $option['identifier'] . ')_unit}/e';
                $searchdownloads[] = '/\\[(' . $option['identifier'] . ')downloads\\]/e';
                $searchdownloads[] = '/{(' . $option['identifier'] . ')_downloads}/e';
            }
            $threadexpiration = $sortdataexpiration ? dgmdate($sortdataexpiration) : lang('forum/misc', 'never_expired');
            $typetemplate = preg_replace(array("/\\{expiration\\}/i"), array($threadexpiration), stripslashes($templatearray['viewthread']));
            $typetemplate = preg_replace($searchtitle, "showoption('\\1', 'title')", $typetemplate);
            $typetemplate = preg_replace($searchvalue, "showoption('\\1', 'value')", $typetemplate);
            $typetemplate = preg_replace($searchunit, "showoption('\\1', 'unit')", $typetemplate);
            $typetemplate = preg_replace($searchdownloads, "showoption('\\1', 'downloads')", $typetemplate);
            $typetemplate = str_replace("{vanfon_uid}", $vanfon_uid, $typetemplate);
            $typetemplate = str_replace("{vanfon_pid}", $vanfon_tid, $typetemplate);
            $typetemplate = str_replace("{vanfon_tid}", $tid, $typetemplate);
            $typetemplate = str_replace("{vanfon_fid}", $vanfon_fid, $typetemplate);
            $typetemplate = str_replace("{vanfon_verify}", $vanfon_verify, $typetemplate);
            $typetemplate = str_replace("{vanfon_usergroup}", $vanfon_usergroup, $typetemplate);
        }
    }
    $threadsortshow['optionlist'] = !$optionexpiration ? $_G['forum_option'] : 'expire';
    $threadsortshow['typetemplate'] = $typetemplate;
    $threadsortshow['expiration'] = dgmdate($sortdataexpiration, 'd');
    return $threadsortshow;
}
Exemple #16
0
function baidu_schema_body_build($forum, $thread)
{
    if (!in_array($forum['status'], array(1, 3))) {
        return false;
    }
    if ($forum['status'] == 1 && $forum['viewperm']) {
        $_p = explode("\t", $forum['viewperm']);
//检查游客组
        if (!in_array('7', $_p)) {
            return false;
        }
    }
    if ($forum['status'] == 3 && $forum['gviewperm'] == 0) {
        return false;
    }
    if ($thread['readperm'] > 1) {
        return false;
    }
    $schema = new BaiduThreadSchema();
    $schema->setForumIcon($forum['icon']);
    $schema->setModerators($forum['moderators']);
    $schema->setAuthorIcon($thread['authorid']);
    $schema->setAuthor($thread['author']);
    $schema->setForumName($forum['name']);
    $schema->setSupportCount($thread['recommend_add']);
    $schema->setOpposeCount($thread['recommend_sub']);
    $schema->setStickyLevel($thread['displayorder']);
    $schema->setIsDigest($thread['digest']);
    $schema->setLastReplier($thread['lastposter']);
    $schema->setFavorCount($thread['favtimes']);
    $schema->setSharedCount($thread['sharetimes']);
//是否启用伪静态
    $schema->setThreadUrl(baidu_gen_thread_url($thread['tid'], 1, 1, $forum['fid']));
    $schema->setThreadTitle($thread['subject']);
    $schema->setReplyCount($thread['replies']);
    $schema->setViewCount($thread['views']);
    $schema->setLastReplyTime($thread['lastpost']);

    $postlist = C::t('forum_post')->fetch_all_by_tid($thread['posttableid'], $thread['tid'], true, 'ASC', 0, $_G['ppp']);
//如果没有内容
    if (empty($postlist)) {
        return false;
    }

    $attachpids = array();
    foreach ($postlist as $row) {
        $row['attachment'] > 0 && $attachpids[] = $row['pid'];
    }

//附件
    $attachlist = empty($attachpids) ? array() : baidu_get_attachment_by_pids($attachpids, $thread['tid']);
    $sequenceNumber = 1;
    foreach ($postlist as $pid => $eachpost) {
        $post = false;
        $images = array(); //附件
        if (1 == $eachpost['first']) {           //主题帖
            $post = new BaiduPostSchema();
            if ($thread['price'] > 0 || $eachpost['status'] % 2 == 1) { //主题价格 看相应主题帖需要花金币
                $post->setViewAuthority(lang('plugin/baidusubmit', 'haveperm'));
            } else {
                if (false !== stripos($eachpost['message'], '[/hide]')) {
                    $post->setViewAuthority(lang('plugin/baidusubmit', 'hidecontent'));
                } else {
                    $post->setViewAuthority(lang('plugin/baidusubmit', 'noperm'));
                }
            }
            $post->setIsHost(1);
            $post->setPostSequenceNumber(1);
        } else {
            $post = new BaiduPostSchema();
            if (false !== stripos($eachpost['message'], '[/hide]')) {
                $post->setViewAuthority(lang('plugin/baidusubmit', 'hidecontent'));
            } else {
                $post->setViewAuthority(lang('plugin/baidusubmit', 'noperm'));
            }
            $post->setIsHost(0);
            $post->setPostSequenceNumber($sequenceNumber);
        }
        $content = baidu_content_filter($eachpost, $forum, $images);
        $post->setPostContent($content);
        $post->setCreatedTime($eachpost['dateline']);
        $post->setAuthor($eachpost['author']);
        $post->setAuthorIcon($eachpost['authorid']);
        $schema->addPost($post);
        $sequenceNumber++;
//如果有附件
        if ($post && !empty($attachlist[$pid])) {
            foreach ($attachlist[$pid] as $a) {

                $_obj = new BaiduAttachmentSchema();
                $_obj->setName($a['filename']);
                $_obj->setSize($a['filesize']);
                $_obj->setDownloadCount($a['downloads']);
                $ap = baidu_get_attachment_authority($a);
                if ($ap > 0) {
                    $authority = $ap;
                } elseif (empty($forum['getattachperm']) || (($t = explode("\t", $forum['getattachperm'])) && in_array(7, $t))) {
                    $authority = 0;
                } else {
                    $authority = 4;
                }
                if ($ap == 0) {
                    $attachurl = $_G['setting']['attachurl'] . '/forum/' . $a['attachment'];
                    $attachurl = str_replace(array('/./', '//'), '/', $attachurl);
                } else {
                    $attachurl = 'forum.php?mod=attachment&aid=' . aidencode($a['aid']);
                }
                $_obj->setDownloadAuthority($authority);
                $_obj->setUrl($_G['siteurl'] . $attachurl);
                $post->addAttachment($_obj);
            }
        }
//图片
        if ($post && !empty($images)) {
            foreach ($images as $x) {
                if (intval($x) > 0)
                    continue; //不要附件
                if (0 != strncasecmp($x, 'http://', 7))
                    continue; //非网络图片不要
                $_obj = new BaiduAttachmentSchema();
                $_obj->setUrl($x);
                $_obj->setDownloadAuthority(0);
                $post->addAttachment($_obj);
            }
        }
    }
    return $schema->toXml() . "\n";
}
            $updateauthor = 1;
            $authorEarn = $prices[$aid][1];
            if ($_G['setting']['maxincperthread'] > 0) {
                $extcredit = 'extcredits' . $_G['setting']['creditstransextra'][1];
                $alog = C::t('common_credit_log')->count_credit_by_uid_operation_relatedid($attach['uid'], 'SAC', $aid, $_G['setting']['creditstransextra'][1]);
                if ($alog['credit'] >= $_G['setting']['maxincperthread']) {
                    $updateauthor = 0;
                } else {
                    $authorEarn = min($_G['setting']['maxincperthread'] - $alog['credit'], $prices[$aid][1]);
                }
            }
            if ($updateauthor) {
                updatemembercount($attach['uid'], array($_G['setting']['creditstransextra'][1] => $authorEarn), 1, 'SAC', $aid);
            }
            updatemembercount($_G['uid'], array($_G['setting']['creditstransextra'][1] => -$prices[$aid][0]), 1, 'BAC', $aid);
            $aidencode = aidencode($aid, 0, $_GET['tid']);
        }
        if (count($aids) > 1) {
            showmessage('attachment_buyall', 'forum.php?mod=redirect&goto=findpost&ptid=' . $attach['tid'] . '&pid=' . $attach['pid']);
        } else {
            $_G['forum_attach_filename'] = $attach['filename'];
            showmessage('attachment_buy', "forum.php?mod=attachment&aid={$aidencode}", array('filename' => $_G['forum_attach_filename']), array('redirectmsg' => 1));
        }
    }
} elseif ($_GET['action'] == 'viewattachpayments') {
    $aid = intval($_GET['aid']);
    $extcreditname = 'extcredits' . $_G['setting']['creditstransextra'][1];
    $loglist = array();
    $logs = C::t('common_credit_log')->fetch_all_by_uid_operation_relatedid(0, 'BAC', $aid);
    $luids = array();
    foreach ($logs as $log) {
Exemple #18
0
function updaterequest($requestdata, $requesttemplatebody, $requesttemplate, $specialfid, $mode, $key, &$nocache)
{
    global $db, $tablepre, $timestamp, $dateformat, $timeformat, $rewritestatus, $uc, $_DCACHE;
    $function = $requestdata['function'];
    $fids = isset($requestdata['fids']) ? $requestdata['fids'] : NULL;
    $startrow = isset($requestdata['startrow']) ? intval($requestdata['startrow']) : 0;
    $items = isset($requestdata['items']) ? intval($requestdata['items']) : 10;
    $digest = isset($requestdata['digest']) ? intval($requestdata['digest']) : 0;
    $stick = isset($requestdata['stick']) ? intval($requestdata['stick']) : 0;
    $newwindow = isset($requestdata['newwindow']) ? $requestdata['newwindow'] : 1;
    $LinkTarget = $newwindow == 1 ? " target='_blank'" : ($newwindow == 2 ? " target='main'" : NULL);
    $sidestatus = !empty($requestdata['sidestatus']) ? 1 : 0;
    $boardurl = empty($requestdata['boardurl']) ? $mode ? $GLOBALS['boardurl'] : '' : $requestdata['boardurl'] . '/';
    if ($function == 'threads') {
        $orderby = isset($requestdata['orderby']) ? in_array($requestdata['orderby'], array('lastpost', 'dateline', 'replies', 'views', 'heats', 'recommends', 'hourviews', 'todayviews', 'weekviews', 'monthviews')) ? $requestdata['orderby'] : 'lastpost' : 'lastpost';
        $hours = isset($requestdata['hours']) ? intval($requestdata['hours']) : 0;
        $highlight = isset($requestdata['highlight']) ? $requestdata['highlight'] : 0;
        $picpre = isset($requestdata['picpre']) ? urldecode($requestdata['picpre']) : NULL;
        $maxlength = !empty($requestdata['maxlength']) ? intval($requestdata['maxlength']) : 50;
        $fnamelength = isset($requestdata['fnamelength']) ? intval($requestdata['fnamelength']) : 0;
        $recommend = !empty($requestdata['recommend']) ? 1 : 0;
        $tids = isset($requestdata['tids']) ? $requestdata['tids'] : NULL;
        $keyword = !empty($requestdata['keyword']) ? $requestdata['keyword'] : NULL;
        $typeids = isset($requestdata['typeids']) ? $requestdata['typeids'] : NULL;
        $sortids = isset($requestdata['sortids']) ? $requestdata['sortids'] : NULL;
        $special = isset($requestdata['special']) ? intval($requestdata['special']) : 0;
        $rewardstatus = isset($requestdata['rewardstatus']) ? intval($requestdata['rewardstatus']) : 0;
        $threadtype = isset($requestdata['threadtype']) ? intval($requestdata['threadtype']) : 0;
        $threadsort = isset($requestdata['threadsort']) ? intval($requestdata['threadsort']) : 0;
        $tag = !empty($requestdata['tag']) ? trim($requestdata['tag']) : NULL;
        $messagelength = !empty($requestdata['messagelength']) ? intval($requestdata['messagelength']) : 255;
        include DISCUZ_ROOT . './forumdata/cache/cache_forums.php';
        require_once DISCUZ_ROOT . './include/post.func.php';
        $datalist = array();
        $threadtypeids = array();
        if ($keyword) {
            if (preg_match("(AND|\\+|&|\\s)", $keyword) && !preg_match("(OR|\\|)", $keyword)) {
                $andor = ' AND ';
                $keywordsrch = '1';
                $keyword = preg_replace("/( AND |&| )/is", "+", $keyword);
            } else {
                $andor = ' OR ';
                $keywordsrch = '0';
                $keyword = preg_replace("/( OR |\\|)/is", "+", $keyword);
            }
            $keyword = str_replace('*', '%', addcslashes($keyword, '%_'));
            foreach (explode('+', $keyword) as $text) {
                $text = trim($text);
                if ($text) {
                    $keywordsrch .= $andor;
                    $keywordsrch .= "t.subject LIKE '%{$text}%'";
                }
            }
            $keyword = " AND ({$keywordsrch})";
        } else {
            $keyword = '';
        }
        $sql = ($specialfid && $sidestatus ? ' AND t.fid = ' . $specialfid : ($fids ? ' AND t.fid IN (\'' . str_replace('_', '\',\'', $fids) . '\')' : '')) . $keyword . ($tids ? ' AND t.tid IN (\'' . str_replace('_', '\',\'', $tids) . '\')' : '') . ($typeids ? ' AND t.typeid IN (\'' . str_replace('_', '\',\'', $typeids) . '\')' : '') . ($sortids ? ' AND t.sortid IN (\'' . str_replace('_', '\',\'', $sortids) . '\')' : '') . ($special >= 0 && $special < 127 ? threadrange($special, 't.special', 7) : '') . ($special & 16 && $rewardstatus ? $rewardstatus == 1 ? ' AND t.price < 0' : ' AND t.price > 0' : '') . ($digest > 0 && $digest < 15 ? threadrange($digest, 't.digest') : '') . ($stick > 0 && $stick < 15 ? threadrange($stick, 't.displayorder') : '');
        if (in_array($orderby, array('hourviews', 'todayviews', 'weekviews', 'monthviews'))) {
            $historytime = 0;
            switch ($orderby) {
                case 'hourviews':
                    $historytime = $timestamp - 3600 * $hours;
                    break;
                case 'todayviews':
                    $historytime = mktime(0, 0, 0, date('m', $timestamp), date('d', $timestamp), date('Y', $timestamp));
                    break;
                case 'weekviews':
                    $week = gmdate('w', $timestamp) - 1;
                    $week = $week != -1 ? $week : 6;
                    $historytime = mktime(0, 0, 0, date('m', $timestamp), date('d', $timestamp) - $week, date('Y', $timestamp));
                    break;
                case 'monthviews':
                    $historytime = mktime(0, 0, 0, date('m', $timestamp), 1, date('Y', $timestamp));
                    break;
            }
            $sql .= ' AND t.dateline>=' . $historytime;
            $orderby = 'views';
        } elseif ($orderby == 'heats') {
            $heatdateline = $timestamp - 86400 * $GLOBALS['indexhot']['days'];
            $sql .= " AND t.dateline>'{$heatdateline}' AND t.heats>'0'";
        }
        $sqlfrom = strexists($requesttemplate, '{message}') ? ",p.message FROM `{$tablepre}threads` t LEFT JOIN `{$tablepre}posts` p ON p.tid=t.tid AND p.first='1'" : "FROM `{$tablepre}threads` t";
        if (strexists($requesttemplate, '{imgattach}')) {
            $sqlfrom = ",a.remote,a.attachment,a.thumb {$sqlfrom} INNER JOIN `{$tablepre}attachments` a ON a.tid=t.tid";
            $sql .= " AND a.isimage IN ('1', '-1') AND a.readperm='0' AND a.price='0'";
            $attachadd .= "GROUP BY a.tid";
            $attachurl = $_DCACHE['settings']['attachurl'];
            $attachurl = preg_match("/^((https?|ftps?):\\/\\/|www\\.)/i", $attachurl) ? $attachurl : $boardurl . $attachurl;
        }
        if ($recommend) {
            $sqlfrom .= " INNER JOIN `{$tablepre}forumrecommend` fc ON fc.tid=t.tid";
        }
        if ($tag) {
            $tags = explode(' ', $tag);
            foreach ($tags as $tagk => $tagv) {
                if (!preg_match('/^([\\x7f-\\xff_-]|\\w){3,20}$/', $tagv)) {
                    unset($tags[$tagk]);
                }
            }
            if ($tags = implode("','", $tags)) {
                $sqlfrom .= " INNER JOIN `{$tablepre}threadtags` tag ON tag.tid=t.tid AND tag.tagname IN ('{$tags}')";
            }
        }
        $query = $db->query("SELECT t.tid,t.fid,t.readperm,t.author,t.authorid,t.subject,t.dateline,t.lastpost,t.lastposter,t.views,t.replies,t.highlight,t.digest,t.typeid,t.sortid\r\n\t\t\t{$sqlfrom} WHERE t.readperm='0'\r\n\t\t\t{$sql}\r\n\t\t\tAND t.displayorder>='0'\r\n\t\t\tAND t.fid>'0'\r\n\t\t\t{$attachadd}\r\n\t\t\tORDER BY t.{$orderby} DESC\r\n\t\t\tLIMIT {$startrow},{$items};");
        while ($data = $db->fetch_array($query)) {
            $datalist[$data['tid']]['fid'] = $data['fid'];
            $datalist[$data['tid']]['fname'] = isset($_DCACHE['forums'][$data['fid']]['name']) ? str_replace('\\\'', '&#39;', addslashes($_DCACHE['forums'][$data['fid']]['name'])) : NULL;
            $datalist[$data['tid']]['fnamelength'] = strlen($datalist[$data['tid']]['fname']);
            $datalist[$data['tid']]['subject'] = isset($data['subject']) ? str_replace('\\\'', '&#39;', addslashes($data['subject'])) : NULL;
            $datalist[$data['tid']]['dateline'] = gmdate("{$dateformat} {$timeformat}", $data['dateline'] + $_DCACHE['settings']['timeoffset'] * 3600);
            $datalist[$data['tid']]['lastpost'] = gmdate("{$dateformat} {$timeformat}", $data['lastpost'] + $_DCACHE['settings']['timeoffset'] * 3600);
            $datalist[$data['tid']]['lastposter'] = $data['lastposter'];
            $datalist[$data['tid']]['authorid'] = $data['authorid'];
            $datalist[$data['tid']]['views'] = $data['views'];
            $datalist[$data['tid']]['replies'] = $data['replies'];
            $datalist[$data['tid']]['highlight'] = $data['highlight'];
            $datalist[$data['tid']]['message'] = messagecutstr($data['message'], $messagelength);
            $datalist[$data['tid']]['imgattach'] = ($data['remote'] ? $_DCACHE['settings']['ftp']['attachurl'] : $attachurl) . "/{$data['attachment']}" . ($_DCACHE['settings']['thumbstatus'] && $data['thumb'] ? '.thumb.jpg' : '');
            if ($data['author']) {
                $datalist[$data['tid']]['author'] = $data['author'];
            } else {
                $datalist[$data['tid']]['author'] = 'Anonymous';
                $datalist[$data['tid']]['authorid'] = 0;
            }
            if ($data['lastposter']) {
                $datalist[$data['tid']]['lastposter'] = $data['lastposter'];
            } else {
                $datalist[$data['tid']]['lastposter'] = '';
            }
            $datalist[$data['tid']]['typeid'] = $data['typeid'];
            $datalist[$data['tid']]['sortid'] = $data['sortid'];
            $datalist[$data['tid']]['subjectprefix'] = '';
            $threadtypeids[] = $data['typeid'];
            $threadtypeids[] = $data['sortid'];
        }
        if (($threadsort || $threadtype) && $threadtypeids) {
            $typelist = array();
            $query = $db->query("SELECT typeid, name FROM {$tablepre}threadtypes WHERE typeid IN ('" . implode('\',\'', $threadtypeids) . "')");
            while ($typearray = $db->fetch_array($query)) {
                $typelist[$typearray['typeid']] = $typearray['name'];
            }
            foreach ($datalist as $tid => $value) {
                $subjectprefix = '';
                if ($threadsort && $value['sortid'] && isset($typelist[$value['sortid']])) {
                    $subjectprefix .= '[' . $typelist[$value['sortid']] . ']';
                }
                if ($threadtype && $value['typeid'] && isset($typelist[$value['typeid']])) {
                    $subjectprefix .= '[' . $typelist[$value['typeid']] . ']';
                }
                $datalist[$tid]['subjectprefix'] = $subjectprefix;
            }
        }
        $writedata = '';
        if (is_array($datalist)) {
            $colorarray = array('', '#EE1B2E', '#EE5023', '#996600', '#3C9D40', '#2897C5', '#2B65B7', '#8F2A90', '#EC1282');
            $prefix = $picpre ? "<img src='{$picpre}' border='0' align='absmiddle'>" : NULL;
            $requesttemplate = !$requesttemplate ? '{prefix} {subject}<br />' : $requesttemplate;
            $order = 1;
            foreach ($datalist as $tid => $value) {
                $SubjectStyles = '';
                if ($highlight && $value['highlight']) {
                    $string = sprintf('%02d', $value['highlight']);
                    $stylestr = sprintf('%03b', $string[0]);
                    $SubjectStyles .= " style='";
                    $SubjectStyles .= $stylestr[0] ? 'font-weight: bold;' : NULL;
                    $SubjectStyles .= $stylestr[1] ? 'font-style: italic;' : NULL;
                    $SubjectStyles .= $stylestr[2] ? 'text-decoration: underline;' : NULL;
                    $SubjectStyles .= $string[1] ? 'color: ' . $colorarray[$string[1]] : NULL;
                    $SubjectStyles .= "'";
                }
                $replace['{fid}'] = $value['fid'];
                $replace['{tid}'] = $tid;
                $replace['{link}'] = $boardurl . "viewthread.php?tid={$tid}";
                $value['prefixlength'] = $value['subjectprefix'] ? strlen(strip_tags($value['subjectprefix'])) : 0;
                $value['maxlength'] = $maxlength - $value['prefixlength'];
                $replace['{subject_nolink}'] = $value['subjectprefix'] . cutstr($value['subject'], $fnamelength ? $value['maxlength'] - $value['fnamelength'] : $value['maxlength'], '');
                $replace['{subject_full}'] = $value['subjectprefix'] . $value['subject'];
                $replace['{prefix}'] = $prefix;
                $replace['{forum}'] = "<a href='" . $boardurl . "forumdisplay.php?fid={$value['fid']}'{$LinkTarget}>{$value['fname']}</a>";
                $replace['{dateline}'] = $value['dateline'];
                $replace['{subject}'] = "<a href='" . $boardurl . "viewthread.php?tid={$tid}' title='{$value['subject']}'{$SubjectStyles}{$LinkTarget}>" . $replace['{subject_nolink}'] . "</a>";
                $replace['{message}'] = $value['message'];
                if ($value['authorid']) {
                    $replace['{author}'] = "<a href='" . $boardurl . "space.php?uid={$value['authorid']}'{$LinkTarget}>{$value['author']}</a>";
                } else {
                    $replace['{author}'] = $value['author'];
                }
                $replace['{author_nolink}'] = $value['author'];
                if ($value['lastposter'] !== '') {
                    $replace['{lastposter}'] = "<a href='" . $boardurl . "space.php?username="******"'{$LinkTarget}>{$value['lastposter']}</a>";
                    $replace['{lastposter_nolink}'] = $value['lastposter'];
                } else {
                    $replace['{lastposter}'] = $replace['{lastposter_nolink}'] = 'Anonymous';
                }
                $replace['{lastpost}'] = $value['lastpost'];
                $replace['{views}'] = $value['views'];
                $replace['{replies}'] = $value['replies'];
                $replace['{imgattach}'] = $value['imgattach'];
                $replace['{order}'] = $order++;
                $writedata .= nodereplace($replace, $requesttemplate);
            }
        }
    } elseif ($function == 'forums') {
        $fups = isset($requestdata['fups']) ? $requestdata['fups'] : NULL;
        $orderby = isset($requestdata['orderby']) ? in_array($requestdata['orderby'], array('displayorder', 'threads', 'posts')) ? $requestdata['orderby'] : 'displayorder' : 'displayorder';
        $datalist = array();
        $query = $db->query("SELECT `fid`,`fup`,`name`,`status`,`threads`,`posts`,`todayposts`,`displayorder`,`type`\r\n\t\t\tFROM `{$tablepre}forums`\r\n\t\t\tWHERE `type`!='group'\r\n\t\t\t" . ($fups ? "AND `fup` IN ('" . str_replace('_', '\',\'', $fups) . "') " : "") . "\r\n\t\t\tAND `status`='1'\r\n\t\t\tORDER BY " . ($orderby == 'displayorder' ? " `displayorder` ASC " : " `{$orderby}` DESC") . "\r\n\t\t\tLIMIT {$startrow}," . ($items > 0 ? $items : 65535) . ";");
        while ($data = $db->fetch_array($query)) {
            $datalist[$data['fid']]['name'] = str_replace('\\\'', '&#39;', addslashes($data['name']));
            $datalist[$data['fid']]['threads'] = $data['threads'];
            $datalist[$data['fid']]['posts'] = $data['posts'];
            $datalist[$data['fid']]['todayposts'] = $data['todayposts'];
        }
        $writedata = '';
        if (is_array($datalist)) {
            $requesttemplate = !$requesttemplate ? '{forumname}<br />' : $requesttemplate;
            $order = 1;
            foreach ($datalist as $fid => $value) {
                $replace['{fid}'] = $fid;
                $replace['{link}'] = $boardurl . "forumdisplay.php?fid={$fid}";
                $replace['{forumname_nolink}'] = $value['name'];
                $replace['{forumname}'] = "<a href='" . $boardurl . "forumdisplay.php?fid={$fid}'{$LinkTarget}>{$value['name']}</a>";
                $replace['{threads}'] = $value['threads'];
                $replace['{posts}'] = $value['posts'];
                $replace['{todayposts}'] = $value['todayposts'];
                $replace['{order}'] = $order++;
                $writedata .= nodereplace($replace, $requesttemplate);
            }
        }
    } elseif ($function == 'memberrank') {
        $orderby = isset($requestdata['orderby']) ? in_array($requestdata['orderby'], array('credits', 'extcredits', 'posts', 'digestposts', 'regdate', 'hourposts', 'todayposts', 'weekposts', 'monthposts')) ? $requestdata['orderby'] : 'credits' : 'credits';
        $hours = isset($requestdata['hours']) ? intval($requestdata['hours']) : 0;
        $datalist = array();
        switch ($orderby) {
            case 'credits':
                $sql = "SELECT m.`username`,m.`uid`,m.`credits` FROM `{$tablepre}members` m ORDER BY m.`credits` DESC";
                break;
            case 'extcredits':
                $requestdata['extcredit'] = intval($requestdata['extcredit']);
                $sql = "SELECT m.`username`,m.`uid`,m.`extcredits{$requestdata['extcredit']}` FROM `{$tablepre}members` m ORDER BY m.`extcredits{$requestdata['extcredit']}` DESC";
                break;
            case 'posts':
                $sql = "SELECT m.`username`,m.`uid`,m.`posts` FROM `{$tablepre}members` m ORDER BY m.`posts` DESC";
                break;
            case 'digestposts':
                $sql = "SELECT m.`username`,m.`uid`,m.`digestposts` FROM `{$tablepre}members` m ORDER BY m.`digestposts` DESC";
                break;
            case 'regdate':
                $sql = "SELECT m.`username`,m.`uid`,m.`regdate` FROM `{$tablepre}members` m ORDER BY m.`regdate` DESC";
                break;
            case 'hourposts':
                $historytime = $timestamp - 3600 * intval($hours);
                $sql = "SELECT DISTINCT(p.author) AS username,p.authorid AS uid,COUNT(p.pid) AS postnum FROM `{$tablepre}posts` p WHERE p.`dateline`>={$historytime} AND p.`authorid`!='0' GROUP BY p.`author` ORDER BY `postnum` DESC";
                break;
            case 'todayposts':
                $historytime = mktime(0, 0, 0, date('m', $timestamp), date('d', $timestamp), date('Y', $timestamp));
                $sql = "SELECT DISTINCT(p.author) AS username,p.authorid AS uid,COUNT(p.pid) AS postnum FROM `{$tablepre}posts` p WHERE p.`dateline`>={$historytime} AND p.`authorid`!='0' GROUP BY p.`author` ORDER BY `postnum` DESC";
                break;
            case 'weekposts':
                $week = gmdate('w', $timestamp) - 1;
                $week = $week != -1 ? $week : 6;
                $historytime = mktime(0, 0, 0, date('m', $timestamp), date('d', $timestamp) - $week, date('Y', $timestamp));
                $sql = "SELECT DISTINCT(p.author) AS username,p.authorid AS uid,COUNT(p.pid) AS postnum FROM `{$tablepre}posts` p LEFT JOIN `{$tablepre}memberfields` mf ON mf.`uid` = p.`authorid` WHERE p.`dateline`>={$historytime} AND p.`authorid`!='0' GROUP BY p.`author` ORDER BY `postnum` DESC";
                break;
            case 'monthposts':
                $historytime = mktime(0, 0, 0, date('m', $timestamp), 1, date('Y', $timestamp));
                $sql = "SELECT DISTINCT(p.author) AS username,p.authorid AS uid,COUNT(p.pid) AS postnum FROM `{$tablepre}posts` p LEFT JOIN `{$tablepre}memberfields` mf ON mf.`uid` = p.`authorid` WHERE p.`dateline`>={$historytime} AND p.`authorid`!='0' GROUP BY p.`author` ORDER BY `postnum` DESC";
                break;
        }
        $query = $db->query($sql . " LIMIT {$startrow},{$items};");
        while ($data = $db->fetch_array($query, MYSQL_NUM)) {
            $data[2] = $orderby == 'regdate' ? gmdate($dateformat, $data[2] + $_DCACHE['settings']['timeoffset'] * 3600) : $data[2];
            $datalist[] = $data;
        }
        $writedata = '';
        if (is_array($datalist)) {
            $requesttemplate = !$requesttemplate ? '{regdate} {member} {value}<br />' : $requesttemplate;
            $order = 1;
            foreach ($datalist as $value) {
                $replace['{regdate}'] = $replace['{value}'] = '';
                if ($orderby == 'regdate') {
                    $replace['{regdate}'] = $value[2];
                } else {
                    $replace['{value}'] = $value[2];
                }
                $replace['{uid}'] = $value[1];
                $replace['{member}'] = "<a href='" . $boardurl . "space.php?uid={$value['1']}'{$LinkTarget}>{$value['0']}</a>";
                $replace['{avatar}'] = "<a title='" . htmlspecialchars($value[0]) . "' href='" . $boardurl . "space.php?uid={$value['1']}'{$LinkTarget}>" . discuz_uc_avatar($value[1]) . "</a>";
                $replace['{avatarsmall}'] = "<a title='" . htmlspecialchars($value[0]) . "' href='" . $boardurl . "space.php?uid={$value['1']}'{$LinkTarget}>" . discuz_uc_avatar($value[1], 'small') . "</a>";
                $replace['{avatarbig}'] = "<a title='" . htmlspecialchars($value[0]) . "' href='" . $boardurl . "space.php?uid={$value['1']}'{$LinkTarget}>" . discuz_uc_avatar($value[1], 'big') . "</a>";
                $replace['{order}'] = $order++;
                $writedata .= nodereplace($replace, $requesttemplate);
            }
        }
    } elseif ($function == 'stats') {
        $info = isset($requestdata['info']) ? $requestdata['info'] : NULL;
        if (is_array($info)) {
            $language = $info;
            $info_index = '';
            $statsinfo = array();
            $statsinfo['forums'] = $statsinfo['threads'] = $statsinfo['posts'] = 0;
            $query = $db->query("SELECT `status`,`threads`,`posts`\r\n\t\t\t\t\tFROM `{$tablepre}forums` WHERE\r\n\t\t\t\t\t`status`='1';\r\n\t\t\t\t\t");
            while ($forumlist = $db->fetch_array($query)) {
                $statsinfo['forums']++;
                $statsinfo['threads'] += $forumlist['threads'];
                $statsinfo['posts'] += $forumlist['posts'];
            }
            unset($info['forums'], $info['threads'], $info['posts']);
            foreach ($info as $index => $value) {
                if ($index == 'members') {
                    $sql = "SELECT COUNT(*) FROM `{$tablepre}members`;";
                } elseif ($index == 'online') {
                    $sql = "SELECT COUNT(*) FROM `{$tablepre}sessions`;";
                } elseif ($index == 'onlinemembers') {
                    $sql = "SELECT COUNT(*) FROM `{$tablepre}sessions` WHERE `uid`>'0';";
                }
                if ($index == 'members' || $index == 'online' || $index == 'onlinemembers') {
                    $statsinfo[$index] = $db->result_first($sql);
                }
            }
            unset($index, $value);
            $writedata = '';
            $requesttemplate = !$requesttemplate ? '{name} {value}<br />' : $requesttemplate;
            foreach ($language as $index => $value) {
                $replace['{name}'] = $value;
                $replace['{value}'] = $statsinfo[$index];
                $writedata .= str_replace(array_keys($replace), $replace, $requesttemplate);
            }
        }
    } elseif ($function == 'images') {
        $maxwidth = isset($requestdata['maxwidth']) ? $requestdata['maxwidth'] : 0;
        $maxheight = isset($requestdata['maxheight']) ? $requestdata['maxheight'] : 0;
        require DISCUZ_ROOT . './forumdata/cache/cache_forums.php';
        $datalist = array();
        $sql = ($specialfid && $sidestatus ? ' AND t.fid = ' . $specialfid : ($fids ? ' AND t.fid IN (\'' . str_replace('_', '\',\'', $fids) . '\')' : '')) . ($digest > 0 && $digest < 15 ? threadrange($digest, 't.digest') : '');
        $imagesql = empty($requestdata['isimage']) ? '' : ($requestdata['isimage'] == 1 ? "AND `attach`.`isimage` IN ('1', '-1')" : ($requestdata['isimage'] == 2 ? "AND `attach`.`isimage`='0'" : ''));
        $methodsql = !empty($requestdata['threadmethod']) ? 'GROUP BY `attach`.`tid`' : '';
        $hours = isset($requestdata['hours']) ? intval($requestdata['hours']) : 0;
        $orderby = isset($requestdata['orderby']) ? in_array($requestdata['orderby'], array('dateline', 'downloads', 'hourdownloads', 'todaydownloads', 'weekdownloads', 'monthdownloads')) ? $requestdata['orderby'] : 'dateline' : 'dateline';
        $orderbysql = $historytime = '';
        switch ($orderby) {
            case 'dateline':
                $orderbysql = "ORDER BY `attach`.`dateline` DESC";
                break;
            case 'downloads':
                $orderbysql = "ORDER BY `attach`.`downloads` DESC";
                break;
            case 'hourdownloads':
                $historytime = $timestamp - 3600 * intval($hours);
                $orderbysql = "ORDER BY `attach`.`downloads` DESC";
                break;
            case 'todaydownloads':
                $historytime = mktime(0, 0, 0, date('m', $timestamp), date('d', $timestamp), date('Y', $timestamp));
                $orderbysql = "ORDER BY `attach`.`downloads` DESC";
                break;
            case 'weekdownloads':
                $week = gmdate('w', $timestamp) - 1;
                $week = $week != -1 ? $week : 6;
                $historytime = mktime(0, 0, 0, date('m', $timestamp), date('d', $timestamp) - $week, date('Y', $timestamp));
                $orderbysql = "ORDER BY `attach`.`downloads` DESC";
                break;
            case 'monthdownloads':
                $historytime = mktime(0, 0, 0, date('m', $timestamp), 1, date('Y', $timestamp));
                $orderbysql = "ORDER BY `attach`.`downloads` DESC";
                break;
        }
        $historytime = !$historytime ? $timestamp - 2592000 : $historytime;
        $htsql = "`attach`.`dateline`>={$historytime}";
        $query = $db->query("SELECT attach.*,af.description,t.tid,t.fid,t.digest,t.author,t.subject,t.displayorder\r\n\t\t\tFROM `{$tablepre}attachments` attach\r\n\t\t\tLEFT JOIN `{$tablepre}attachmentfields` af ON attach.aid=af.aid\r\n\t\t\tINNER JOIN `{$tablepre}threads` t\r\n\t\t\tON `t`.`tid`=`attach`.`tid` AND `displayorder`>='0'\r\n\t\t\tWHERE {$htsql} AND `attach`.`readperm`='0' AND `attach`.`price`='0'\r\n\t\t\t{$imagesql}\r\n\t\t\t{$sql}\r\n\t\t\t{$methodsql}\r\n\t\t\t{$orderbysql}\r\n\t\t\tLIMIT {$startrow},{$items};");
        $attachurl = $_DCACHE['settings']['attachurl'];
        $attachurl = preg_match("/^((https?|ftps?):\\/\\/|www\\.)/i", $attachurl) ? $attachurl : $boardurl . $attachurl;
        $i = 0;
        while ($data = $db->fetch_array($query)) {
            $key = $requestdata['threadmethod'] ? $data['tid'] : $i++;
            $datalist[$key]['aid'] = $data['aid'];
            $datalist[$key]['threadlink'] = $boardurl . "redirect.php?goto=findpost&ptid={$data['tid']}&pid={$data['pid']}";
            $datalist[$key]['imgfile'] = ($data['remote'] ? $_DCACHE['settings']['ftp']['attachurl'] : $attachurl) . "/{$data['attachment']}" . ($_DCACHE['settings']['thumbstatus'] && $data['thumb'] ? '.thumb.jpg' : '');
            $datalist[$key]['file'] = $boardurl . 'attachment.php?aid=' . aidencode($data['aid']);
            $datalist[$key]['subject'] = str_replace('\\\'', '&#39;', $data['subject']);
            $datalist[$key]['filename'] = str_replace('\\\'', '&#39;', $data['filename']);
            $datalist[$key]['author'] = addslashes($data['author']);
            $datalist[$key]['downloads'] = $data['downloads'];
            $datalist[$key]['author'] = $data['author'];
            $datalist[$key]['filesize'] = number_format($data['filesize']);
            $datalist[$key]['dateline'] = gmdate("{$dateformat} {$timeformat}", $data['dateline'] + $_DCACHE['settings']['timeoffset'] * 3600);
            $datalist[$key]['fname'] = isset($_DCACHE['forums'][$data['fid']]['name']) ? str_replace('\\\'', '&#39;', addslashes($_DCACHE['forums'][$data['fid']]['name'])) : NULL;
            $datalist[$key]['description'] = $data['description'] ? str_replace('\\\'', '&#39;', addslashes($data['description'])) : NULL;
        }
        $writedata = '';
        if (is_array($datalist)) {
            $imgsize = ($maxwidth ? " width='{$maxwidth}'" : NULL) . ($maxheight ? " height='{$maxheight}'" : NULL);
            $requesttemplate = !$requesttemplate ? '{file} ({filesize} Bytes)<br />' : $requesttemplate;
            $order = 1;
            foreach ($datalist as $value) {
                $replace['{aid}'] = $value['aid'];
                $replace['{link}'] = $value['threadlink'];
                $replace['{imgfile}'] = $value['imgfile'];
                $replace['{url}'] = $value['file'];
                $replace['{subject}'] = $value['subject'];
                $replace['{filesubject}'] = $value['filename'];
                $replace['{filedesc}'] = $value['description'];
                $replace['{author}'] = $value['author'];
                $replace['{dateline}'] = $value['dateline'];
                $replace['{downloads}'] = $value['downloads'];
                $replace['{filesize}'] = $value['filesize'];
                $replace['{file}'] = "<a href='{$value['file']}'{$LinkTarget}>{$value['filename']}</a>";
                $replace['{image}'] = "<a href='{$value['threadlink']}'{$LinkTarget}><img{$imgsize} src='{$value['imgfile']}' border='0'></a>";
                $replace['{order}'] = $order++;
                $writedata .= nodereplace($replace, $requesttemplate);
            }
        }
    } elseif ($function == 'module') {
        $requestrun = TRUE;
        $settings = unserialize(get_magic_quotes_gpc() ? stripslashes($requestdata['settings']) : $requestdata['settings']);
        if (@(!(include DISCUZ_ROOT . './include/request/' . $requestdata['module']))) {
            return;
        }
    } else {
        return;
    }
    $data = parsenode($writedata, $requesttemplatebody);
    if ($rewritestatus) {
        $searcharray = $replacearray = array();
        if ($GLOBALS['rewritestatus'] & 1) {
            $searcharray[] = "/\\<a href\\=\\'" . preg_quote($boardurl, '/') . "forumdisplay\\.php\\?fid\\=(\\d+)\\'/";
            $replacearray[] = "<a href='{$boardurl}forum-\\1-1.html'";
        }
        if ($GLOBALS['rewritestatus'] & 2) {
            $searcharray[] = "/\\<a href\\=\\'" . preg_quote($boardurl, '/') . "viewthread\\.php\\?tid\\=(\\d+)\\'/";
            $replacearray[] = "<a href='{$boardurl}thread-\\1-1-1.html'";
        }
        if ($GLOBALS['rewritestatus'] & 4) {
            $searcharray[] = "/\\<a href\\=\\'" . preg_quote($boardurl, '/') . "space\\.php\\?uid\\=(\\d+)\\'/";
            $searcharray[] = "/\\<a href\\=\\'" . preg_quote($boardurl, '/') . "space\\.php\\?username\\=([^&]+?)\\'/";
            $replacearray[] = "<a href='{$boardurl}space-uid-\\1.html'";
            $replacearray[] = "<a href='{$boardurl}space-username-\\1.html'";
        }
        $data = preg_replace($searcharray, $replacearray, $data);
    }
    return $data;
}