📄 misc.php
字号:
<?php
/*
[Discuz!] (C)2001-2007 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$RCSfile: misc.php,v $
$Revision: 1.110.2.9 $
$Date: 2007/03/21 15:52:04 $
*/
define('NOROBOT', TRUE);
require_once './include/common.inc.php';
if($action == 'maxpages') {
$pages = intval($pages);
if(empty($pages)) {
showmessage('undefined_action', NULL, 'HALTED');
} else {
showmessage('max_pages');
}
} elseif($action == 'customtopics') {
if(!submitcheck('keywordsubmit', 1)) {
if($_DCOOKIE['customkw']) {
$customkwlist = array();
foreach(@explode("\t", trim($_DCOOKIE['customkw'])) as $key => $keyword) {
$keyword = dhtmlspecialchars(trim(stripslashes($keyword)));
$customkwlist[$key]['keyword'] = $keyword;
$customkwlist[$key]['url'] = '<a href="topic.php?keyword='.rawurlencode($keyword).'" target="_blank">'.$keyword.'</a> ';
}
}
include template('customtopics');
} else {
if(!empty($delete) && is_array($delete)) {
$keywords = implode("\t", array_diff(explode("\t", $_DCOOKIE['customkw']), $delete));
} else {
$keywords = $_DCOOKIE['customkw'];
}
if($newkeyword = cutstr(dhtmlspecialchars(preg_replace("/[\s\|\t\,\'\<\>]/", '', $newkeyword)), 20)) {
if($_DCOOKIE['customkw']) {
if(!preg_match("/(^|\t)".preg_quote($newkeyword, '/')."($|\t)/i", $keywords)) {
if(count(explode("\t", $keywords)) >= $qihoo_maxtopics) {
$keywords = substr($keywords, (strpos($keywords, "\t") + 1))."\t".$newkeyword;
} else {
$keywords .= "\t".$newkeyword;
}
}
} else {
$keywords = $newkeyword;
}
}
dsetcookie('customkw', stripslashes($keywords), 315360000);
dheader("Location: {$boardurl}misc.php?action=customtopics");
}
} elseif($action == 'attachpay') {
$aid = intval($aid);
if(!$aid) {
showmessage('undefined_action', NULL, 'HALTED');
} elseif(!isset($extcredits[$creditstrans])) {
showmessage('credits_transaction_disabled');
} elseif(!$discuz_uid) {
showmessage('group_nopermission', NULL, 'NOPERM');
} else {
$query = $db->query("SELECT a.tid, a.uid, a.price, a.filename, a.description, m.username AS author FROM {$tablepre}attachments a LEFT JOIN {$tablepre}members m ON a.uid=m.uid WHERE a.aid='$aid'");
$attach = $db->fetch_array($query);
if($attach['price'] <= 0) {
showmessage('undefined_action', NULL, 'HALTED');
}
}
if(($balance = ${'extcredits'.$creditstrans} - $attach['price']) < ($minbalance = 0)) {
showmessage('credits_balance_insufficient');
}
$query = $db->query("SELECT COUNT(*) FROM {$tablepre}attachpaymentlog WHERE aid='$aid' AND uid='$discuz_uid'");
if($db->result($query, 0)) {
showmessage('attachment_yetpay', "attachment.php?aid=$aid");
}
$discuz_action = 81;
$attach['netprice'] = floor($attach['price'] * (1 - $creditstax));
if(!submitcheck('paysubmit')) {
include template('attachpay');
} else {
$updateauthor = 1;
if($maxincperthread > 0) {
$query = $db->query("SELECT SUM(netamount) FROM {$tablepre}attachpaymentlog WHERE aid='$aid'");
if(($db->result($query, 0)) > $maxincperthread) {
$updateauthor = 0;
}
}
if($updateauthor) {
$db->query("UPDATE {$tablepre}members SET extcredits$creditstrans=extcredits$creditstrans+$attach[netprice] WHERE uid='$attach[uid]'");
}
$db->query("UPDATE {$tablepre}members SET extcredits$creditstrans=extcredits$creditstrans-$attach[price] WHERE uid='$discuz_uid'");
$db->query("INSERT INTO {$tablepre}attachpaymentlog (uid, aid, authorid, dateline, amount, netamount)
VALUES ('$discuz_uid', '$aid', '$attach[uid]', '$timestamp', '$attach[price]', '$attach[netprice]')");
showmessage('attachment_buy', "attachment.php?aid=$aid");
}
} elseif($action == 'viewattachpayments') {
$discuz_action = 82;
$loglist = array();
$query = $db->query("SELECT a.*, m.username FROM {$tablepre}attachpaymentlog a
LEFT JOIN {$tablepre}members m USING (uid)
WHERE aid='$aid' ORDER BY dateline");
while($log = $db->fetch_array($query)) {
$log['dateline'] = gmdate("$dateformat $timeformat", $log['dateline'] + $timeoffset * 3600);
$loglist[] = $log;
}
include template('attachpay_view');
} elseif($action == 'getonlines') {
$query = $db->query("SELECT COUNT(*) FROM {$tablepre}sessions");
$num = $db->result($query, 0);
showmessage($num);
} else {
if(empty($forum['allowview'])) {
if(!$forum['viewperm'] && !$readaccess) {
showmessage('group_nopermission', NULL, 'NOPERM');
} elseif($forum['viewperm'] && !forumperm($forum['viewperm'])) {
showmessage('forum_nopermission', NULL, 'NOPERM');
}
} elseif($thread['readperm'] && $thread['readperm'] > $readaccess && !$forum['ismoderator'] && $thread['authorid'] != $discuz_uid) {
showmessage('thread_nopermission', NULL, 'NOPERM');
}
$query = $db->query("SELECT * FROM {$tablepre}threads WHERE tid='$tid' AND displayorder>='0'");
if(!$thread = $db->fetch_array($query)) {
showmessage('thread_nonexistence');
}
if($forum['type'] == 'forum') {
$navigation = "» <a href=\"forumdisplay.php?fid=$fid\">$forum[name]</a> » <a href=\"viewthread.php?tid=$tid\">$thread[subject]</a> ";
$navtitle = strip_tags($forum['name']).' - '.$thread['subject'];
} elseif($forum['type'] == 'sub') {
$query = $db->query("SELECT name, fid FROM {$tablepre}forums WHERE fid='$forum[fup]'");
$fup = $db->fetch_array($query);
$navigation = "» <a href=\"forumdisplay.php?fid=$fup[fid]\">$fup[name]</a> » <a href=\"forumdisplay.php?fid=$fid\">$forum[name]</a> » <a href=\"viewthread.php?tid=$tid\">$thread[subject]</a> ";
$navtitle = strip_tags($fup['name']).' - '.strip_tags($forum['name']).' - '.$thread['subject'];
}
}
if($action == 'votepoll' && submitcheck('pollsubmit')) {
if($supe['status'] && $forum['status'] == 2 && $thread['sgid']) {
require_once DISCUZ_ROOT.'./include/supesite.func.php';
$allowvote = supe_circlepermission($thread['sgid']);
}
if(!$allowvote) {
showmessage('group_nopermission', NULL, 'NOPERM');
}
if(!empty($thread['closed'])) {
showmessage('thread_poll_closed');
}
if(empty($pollanswers)) {
showmessage('thread_poll_invalid');
}
$query = $db->query("SELECT maxchoices, expiration FROM {$tablepre}polls WHERE tid='$tid'");
if(!$pollarray = $db->fetch_array($query)) {
showmessage('undefined_action', NULL, 'HALTED');
} elseif($pollarray['expiration'] && $pollarray['expiration'] < $timestamp) {
showmessage('poll_overdue');
} elseif($pollarray['maxchoices'] && $pollarray['maxchoices'] < count($pollanswers)) {
showmessage('poll_choose_most');
}
$voterids = $discuz_uid ? $discuz_uid : $onlineip;
$polloptionid = array();
$query = $db->query("SELECT polloptionid, voterids FROM {$tablepre}polloptions WHERE tid='$tid'");
while($pollarray = $db->fetch_array($query)) {
if(strexists("\t".$pollarray['voterids']."\t", "\t".$voterids."\t")) {
showmessage('thread_poll_voted');
}
$polloptionid[] = $pollarray['polloptionid'];
}
$polloptionids = '';
foreach($pollanswers as $key => $id) {
if(!in_array($id, $polloptionid)) {
showmessage('undefined_action', NULL, 'HALTED');
}
unset($polloptionid[$key]);
$polloptionids[] = $id;
}
$pollanswers = implode('\',\'', $polloptionids);
$db->query("UPDATE {$tablepre}polloptions SET votes=votes+1, voterids=CONCAT(voterids,'$voterids\t') WHERE polloptionid IN ('$pollanswers')", 'UNBUFFERED');
$db->query("UPDATE {$tablepre}threads SET lastpost='$timestamp' WHERE tid='$tid'", 'UNBUFFERED');
updatecredits($discuz_uid, $creditspolicy['votepoll']);
showmessage('thread_poll_succeed', "viewthread.php?tid=$tid");
} elseif($action == 'viewvote') {
if(empty($forum['allowview'])) {
if(!$forum['viewperm'] && !$readaccess) {
showmessage('group_nopermission', NULL, 'NOPERM');
} elseif($forum['viewperm'] && !forumperm($forum['viewperm'])) {
showmessage('forum_nopermission', NULL, 'NOPERM');
}
}
if($thread['readperm'] && $thread['readperm'] > $readaccess && !$forum['ismoderator'] && $thread['authorid'] != $discuz_uid) {
showmessage('thread_nopermission', NULL, 'NOPERM');
}
if($forum['password'] && $forum['password'] != $_DCOOKIE['fidpw'.$fid]) {
dheader("Location: {$boardurl}forumdisplay.php?fid=$fid&sid=$sid");
}
$voterpp = 180;
$page = $_GET['page'];
if(empty($polloptionid)) {
$voterids = '';
$query = $db->query("SELECT voterids FROM {$tablepre}polloptions WHERE tid='$tid'");
while($polloption = $db->fetch_array($query)) {
$voterids .= ($voterids ? "\t" : '').trim($polloption['voterids']);
}
unset($polloption);
$arrvoterids = explode("\t", trim($voterids));
$num = count($arrvoterids);
$page = max(1, intval($page));
$start_limit = ($page - 1) * $voterpp;
$multipage = multi($num, $voterpp, $page, "misc.php?action=viewvote&tid=$tid");
} elseif($adminid == 1) {
$voterids = '';
$query = $db->query("SELECT voterids FROM {$tablepre}polloptions WHERE polloptionid='$polloptionid'");
$voterids = $db->result($query, 0);
$arrvoterids = explode("\t", trim($voterids));
$num = count($arrvoterids);
$page = max(1, intval($page));
$start_limit = ($page - 1) * $voterpp;
$multipage = multi($num, $voterpp, $page, "misc.php?action=viewvote&tid=$tid&polloptionid=$polloptionid");
}
$arrvoterids = @array_slice($arrvoterids, $start_limit, $voterpp);
$voterids = @implode("','", $arrvoterids);
$voterlist = $voter = array();
$query = $db->query("SELECT uid, username FROM {$tablepre}members WHERE uid IN ('$voterids')");
while($voter = $db->fetch_array($query)) {
$voterlist[] = $voter;
}
include template('viewthread_poll_voters');
} elseif($action == 'emailfriend') {
if(!$discuz_uid) {
showmessage('not_loggedin', NULL, 'NOPERM');
}
$discuz_action = 122;
if(!submitcheck('sendsubmit')) {
$fromuid = $creditspolicy['promotion_visit'] ? '&fromuid='.$discuz_uid : '';
$threadurl = "{$boardurl}viewthread.php?tid=$tid$fromuid";
$query = $db->query("SELECT email FROM {$tablepre}members WHERE uid='$discuz_uid'");
$email = $db->result($query, 0);
include template('emailfriend');
} else {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -