📄 misc.php
字号:
<?php
/*
[Discuz!] (C)2001-2006 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$RCSfile: misc.php,v $
$Revision: 1.28 $
$Date: 2006/02/23 13:44:02 $
*/
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);
header("Location: {$boardurl}misc.php?action=customtopics");
}
} 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') {
if(!$allowvote) {
showmessage('group_nopermission', NULL, 'NOPERM');
}
$query = $db->query("SELECT pollopts FROM {$tablepre}polls WHERE tid='$tid'");
$pollarray = unserialize($db->result($query, 0));
if(!is_array($pollarray) || !$pollarray) {
showmessage('undefined_action', NULL, 'HALTED');
}
if(!empty($thread['closed'])) {
showmessage('thread_poll_closed');
}
if(in_array(($discuz_uid ? $discuz_user : $onlineip), $pollarray['voters'])) {
showmessage('thread_poll_voted');
}
if(!is_array($pollanswers) || count($pollanswers) < 1) {
showmessage('thread_poll_invalid');
}
if(empty($pollarray['multiple']) && count($pollanswers) > 1) {
showmessage('undefined_action', NULL, 'HALTED');
}
foreach($pollanswers as $id) {
if(isset($pollarray['options'][$id][0])) {
if(++$pollarray['options'][$id][1] > $pollarray['max']) {
$pollarray['max'] = $pollarray['options'][$id][1];
}
$pollarray['total']++;
} else {
showmessage('undefined_action', NULL, 'HALTED');
}
}
$pollarray['voters'][] = $discuz_uid ? $discuz_user : $onlineip;
$pollopts = addslashes(serialize($pollarray));
$db->query("UPDATE {$tablepre}polls SET pollopts='$pollopts' WHERE tid='$tid'", 'UNBUFFERED');
$db->query("UPDATE {$tablepre}threads SET lastpost='$timestamp' WHERE tid='$tid'", 'UNBUFFERED');
showmessage('thread_poll_succeed', "viewthread.php?tid=$tid");
} elseif($action == 'emailfriend') {
if(!$discuz_uid) {
showmessage('not_loggedin', NULL, 'NOPERM');
}
$discuz_action = 122;
if(!submitcheck('sendsubmit')) {
$threadurl = "{$boardurl}viewthread.php?tid=$tid";
$query = $db->query("SELECT email FROM {$tablepre}members WHERE uid='$discuz_uid'");
$email = $db->result($query, 0);
include template('emailfriend');
} else {
if(empty($fromname) || empty($fromemail) || empty($sendtoname) || empty($sendtoemail)) {
showmessage('email_friend_invalid');
}
sendmail($sendtoemail, 'email_to_friend_subject', 'email_to_friend_message', "$fromname <$fromemail>");
showmessage('email_friend_succeed', "viewthread.php?tid=$tid");
}
} elseif($action == 'rate' && $pid) {
if(!$raterange) {
showmessage('group_nopermission', NULL, 'NOPERM');
} elseif($modratelimit && $adminid == 3 && !$forum['ismoderator']) {
showmessage('thread_rate_moderator_invalid');
}
$reasonpmcheck = $reasonpm == 2 || $reasonpm == 3 ? 'checked disabled' : '';
if(($reasonpm == 2 || $reasonpm == 3) || !empty($sendreasonpm)) {
$forumname = strip_tags($forum['name']);
$sendreasonpm = 1;
} else {
$sendreasonpm = 0;
}
foreach($raterange as $id => $rating) {
$maxratetoday[$id] = $rating['mrpd'];
}
//maxratetoday: how much quota of rating left today
$query = $db->query("SELECT extcredits, SUM(ABS(score)) AS todayrate FROM {$tablepre}ratelog
WHERE uid='$discuz_uid' AND dateline>=$timestamp-86400
GROUP BY extcredits");
while($rate = $db->fetch_array($query)) {
$maxratetoday[$rate['extcredits']] = $raterange[$rate['extcredits']]['mrpd'] - $rate['todayrate'];
}
$query = $db->query("SELECT * FROM {$tablepre}posts WHERE pid='$pid' AND invisible='0' AND authorid<>'0'");
if(!($post = $db->fetch_array($query)) || $post['tid'] != $thread['tid'] || !$post['authorid']) {
showmessage('undefined_action');
} elseif(!$forum['ismoderator'] && $karmaratelimit && $timestamp - $post['dateline'] > $karmaratelimit * 3600) {
showmessage('thread_rate_timelimit');
} elseif($post['authorid'] == $discuz_uid || $post['tid'] != $tid) {
showmessage('thread_rate_member_invalid');
}
if(!$dupkarmarate) {
$query = $db->query("SELECT pid FROM {$tablepre}ratelog WHERE uid='$discuz_uid' AND pid='$pid' LIMIT 1");
if($db->num_rows($query)) {
showmessage('thread_rate_duplicate');
}
}
$discuz_action = 71;
$page = intval($page);
if(!submitcheck('ratesubmit')) {
$referer = $boardurl.'viewthread.php?tid='.$tid.'&page='.$page.'#pid'.$pid;
$ratelist = array();
foreach($raterange as $id => $rating) {
if(isset($extcredits[$id])) {
$ratelist[$id] = '';
$offset = abs(ceil(($rating['max'] - $rating['min']) / 32));
for($vote = $rating['min']; $vote <= $rating['max']; $vote += $offset) {
$ratelist[$id] .= $vote ? '<option value="'.$vote.'">'.($vote > 0 ? '+'.$vote : $vote).'</option>' : '';
}
}
}
include template('rate');
} else {
require_once DISCUZ_ROOT.'./include/misc.func.php';
checkreasonpm();
$rate = $ratetimes = 0;
$creditsarray = array();
foreach($raterange as $id => $rating) {
$score = intval(${'score'.$id});
if(isset($extcredits[$id]) && !empty($score)) {
if(abs($score) <= $maxratetoday[$id]) {
if($score > $rating['max'] || $score < $rating['min']) {
showmessage('thread_rate_range_invalid');
} else {
$creditsarray[$id] = $score;
$rate += $score;
$ratetimes += ceil(max(abs($rating['min']), abs($rating['max'])) / 5);
}
} else {
showmessage('thread_rate_ctrl');
}
}
}
if(!$creditsarray) {
showmessage('thread_rate_range_invalid');
}
updatecredits($post['authorid'], $creditsarray);
$db->query("UPDATE {$tablepre}posts SET rate=rate+($rate), ratetimes=ratetimes+$ratetimes WHERE pid='$pid'");
if($post['first']) {
$threadrate = intval(@($post['rate'] + $rate) / abs($post['rate'] + $rate));
$db->query("UPDATE {$tablepre}threads SET rate='$threadrate' WHERE tid='$tid'");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -