⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 misc.php

📁 Discuz功能源码(开源)
💻 PHP
📖 第 1 页 / 共 3 页
字号:

	$discuz_action = 123;

	$floodctrl = $floodctrl * 3;
	if($timestamp - $lastpost < $floodctrl) {
		showmessage('thread_report_flood_ctrl');
	}

	if($db->result_first("SELECT id FROM {$tablepre}reportlog WHERE pid='$pid' AND uid='$discuz_uid'")) {
		showmessage('thread_report_existence');
	}

	if(!submitcheck('reportsubmit')) {

		include template('reportpost');
		exit;

	} else {

		$type = intval($type) ? 1 : 0;
		$reason = cutstr(dhtmlspecialchars($reason), 40);

		$db->query("INSERT INTO {$tablepre}reportlog (fid, pid, uid, username, type, reason, dateline)
			VALUES ('$fid', '$pid', '$discuz_uid', '$discuz_user', '$type', '$reason', '$timestamp')");
		$db->query("UPDATE {$tablepre}forums SET modworks='1' WHERE fid='$fid'");
		$db->query("UPDATE {$tablepre}members SET lastpost='$timestamp' WHERE uid='$discuz_uid'");

		showmessage('thread_report_succeed', "viewthread.php?tid=$tid");

	}

} elseif($action == 'viewthreadmod' && $tid) {

	$loglist = array();
	$query = $db->query("SELECT * FROM {$tablepre}threadsmod WHERE tid='$tid' ORDER BY dateline DESC");
	while($log = $db->fetch_array($query)) {
		$log['dateline'] = dgmdate("$dateformat $timeformat", $log['dateline'] + $timeoffset * 3600);
		$log['expiration'] = !empty($log['expiration']) ? gmdate("$dateformat", $log['expiration'] + $timeoffset * 3600) : '';
		$log['status'] = empty($log['status']) ? 'style="text-decoration: line-through" disabled' : '';
		if($log['magicid']) {
			require_once DISCUZ_ROOT.'./forumdata/cache/cache_magics.php';
			$log['magicname'] = $_DCACHE['magics'][$log['magicid']]['name'];
		}
		$loglist[] = $log;
	}

	if(empty($loglist)) {
		showmessage('threadmod_nonexistence');
	} else {
		include_once language('modactions');
	}

	include template('viewthread_mod');

} elseif($action == 'bestanswer' && $tid && $pid && submitcheck('bestanswersubmit')) {

	$forward = 'viewthread.php?tid='.$tid;

	$post = $db->fetch_first("SELECT authorid, first FROM {$tablepre}posts WHERE pid='$pid' and tid='$tid'");

	if(!($thread['special'] == 3 && $post && ($forum['ismoderator'] || $thread['authorid'] == $discuz_uid) && $post['authorid'] != $thread['authorid'] && $post['first'] == 0 && $discuz_uid != $post['authorid'])) {
		showmessage('reward_cant_operate');
	} elseif($post['authorid'] == $thread['authorid']) {
		showmessage('reward_cant_self');
	} elseif($thread['price'] < 0) {
		showmessage('reward_repeat_selection');
	}
	$thread['netprice'] = ceil($price * ( 1 + $creditstax) );
	$db->query("UPDATE {$tablepre}members SET extcredits$creditstransextra[2]=extcredits$creditstransextra[2]+$thread[price] WHERE uid='$post[authorid]'");
	$db->query("DELETE FROM {$tablepre}rewardlog WHERE tid='$tid' and answererid='$post[authorid]'");
	$db->query("UPDATE {$tablepre}rewardlog SET answererid='$post[authorid]' WHERE tid='$tid' and authorid='$thread[authorid]'");
	$thread['price'] = '-'.$thread['price'];
	$db->query("UPDATE {$tablepre}threads SET price='$thread[price]' WHERE tid='$tid'");
	$db->query("UPDATE {$tablepre}posts SET dateline=$thread[dateline]+1 WHERE pid='$pid'");

	$thread['dateline'] = dgmdate("$dateformat $timeformat", $thread['dateline'] + $timeoffset * 3600);
	if($discuz_uid != $thread['authorid']) {
		sendpm($thread['authorid'], 'reward_question_subject', 'reward_question_message', 0);
	}
	sendpm($post['authorid'], 'reward_bestanswer_subject', 'reward_bestanswer_message', 0);

	showmessage('reward_completion', $forward);

} elseif($action == 'activityapplies') {

	if(!$discuz_uid) {
		showmessage('undefined_action', NULL, 'HALTED');
	}

	if(submitcheck('activitysubmit')) {
		$expiration = $db->result_first("SELECT expiration FROM {$tablepre}activities WHERE tid='$tid'");
		if($expiration && $expiration < $timestamp) {
			showmessage('activity_stop');
		}

		$query = $db->query("SELECT applyid FROM {$tablepre}activityapplies WHERE tid='$tid' and username='$discuz_user'");
		if($db->num_rows($query)) {
			showmessage('activity_repeat_apply', "viewthread.php?tid=$tid&amp;extra=$extra");
		}
		$payvalue = intval($payvalue);
		$payment = $payment ? $payvalue : -1;
		$message = cutstr(dhtmlspecialchars($message), 200);
		$contact = cutstr(dhtmlspecialchars($contact), 200);

		$db->query("INSERT INTO {$tablepre}activityapplies (tid, username, uid, message, verified, dateline, payment, contact)
			VALUES ('$tid', '$discuz_user', '$discuz_uid', '$message', '0', '$timestamp', '$payment', '$contact')");

		if($customaddfeed & 4) {
			$feed['icon'] = 'activity';
			$feed['title_template'] = 'feed_reply_activity_title';
			$feed['title_data'] = array(
				'subject' => "<a href=\"{$boardurl}viewthread.php?tid=$tid\">$thread[subject]</a>"
			);
			postfeed($feed);
		}

		showmessage('activity_completion', "viewthread.php?tid=$tid&viewpid=$pid");
	}

} elseif($action == 'activityapplylist') {

	$activity = $db->fetch_first("SELECT * FROM {$tablepre}activities WHERE tid='$tid'");
	if(!$activity || $thread['special'] != 4 || $thread['authorid'] != $discuz_uid) {
		showmessage('undefined_action');
	}

	if(!submitcheck('applylistsubmit')) {
		$sqlverified = $thread['authorid'] == $discuz_uid ? '' : 'AND verified=1';

		if(!empty($uid) && $thread['authorid'] == $discuz_uid) {
			$sqlverified .= " AND uid='$uid'";
		}

		$applylist = array();
		$query = $db->query("SELECT applyid, username, uid, message, verified, dateline, payment, contact FROM {$tablepre}activityapplies WHERE tid='$tid' $sqlverified ORDER BY dateline DESC");
		while($activityapplies = $db->fetch_array($query)) {
			$activityapplies['dateline'] = dgmdate("$dateformat $timeformat", $activityapplies['dateline'] + $timeoffset * 3600);
			$applylist[] = $activityapplies;
		}

		$activity['starttimefrom'] = dgmdate("$dateformat $timeformat", $activity['starttimefrom'] + $timeoffset * 3600);
		$activity['starttimeto'] = $activity['starttimeto'] ? dgmdate("$dateformat $timeformat", $activity['starttimeto'] + $timeoffset * 3600) : 0;
		$activity['expiration'] = $activity['expiration'] ? dgmdate("$dateformat $timeformat", $activity['expiration'] + $timeoffset * 3600) : 0;

		$applynumbers = $db->result_first("SELECT COUNT(*) FROM {$tablepre}activityapplies WHERE tid='$tid' AND verified=1");

		include template('activity_applylist');
	} else {
		if(empty($applyidarray)) {
			showmessage('activity_choice_applicant', "viewthread.php?tid=$tid&do=viewapplylist");
		} else {
			$uidarray = array();
			$ids = implode('\',\'', $applyidarray);
			$query=$db->query("SELECT a.uid FROM {$tablepre}activityapplies a RIGHT JOIN {$tablepre}members m USING(uid) WHERE a.applyid IN ('$ids')");
			while($uid = $db->fetch_array($query)) {
				$uidarray[] = $uid['uid'];
			}
			$activity_subject = $thread['subject'];
			if($operation == 'delete') {
				$db->query("DELETE FROM {$tablepre}activityapplies WHERE applyid IN ('$ids')", 'UNBUFFERED');

				sendpm(implode(',', $uidarray), 'activity_delete_subject', 'activity_delete_message', 0);
				showmessage('activity_delete_completion', "viewthread.php?tid=$tid&do=viewapplylist");
			} else {
				$db->query("UPDATE {$tablepre}activityapplies SET verified=1 WHERE applyid IN ('$ids')", 'UNBUFFERED');

				sendpm(implode(',', $uidarray), 'activity_apply_subject', 'activity_apply_message', 0);
				showmessage('activity_auditing_completion', "viewthread.php?tid=$tid&do=viewapplylist");
			}
		}
	}

} elseif($action == 'tradeorder') {

	$trades = array();
	$query=$db->query("SELECT * FROM {$tablepre}trades WHERE tid='$tid' ORDER BY displayorder");

	if($thread['authorid'] != $discuz_uid) {
		showmessage('undefined_action', NULL, 'HALTED');
	}

	if(!submitcheck('tradesubmit')) {

		$stickcount = 0;$trades = $tradesstick = array();
		while($trade = $db->fetch_array($query)) {
			$stickcount = $trade['displayorder'] > 0 ? $stickcount + 1 : $stickcount;
			$trade['displayorderview'] = $trade['displayorder'] < 0 ? 128 + $trade['displayorder'] : $trade['displayorder'];
			if($trade['expiration']) {
				$trade['expiration'] = ($trade['expiration'] - $timestamp) / 86400;
				if($trade['expiration'] > 0) {
					$trade['expirationhour'] = floor(($trade['expiration'] - floor($trade['expiration'])) * 24);
					$trade['expiration'] = floor($trade['expiration']);
				} else {
					$trade['expiration'] = -1;
				}
			}
			if($trade['displayorder'] < 0) {
				$trades[] = $trade;
			} else {
				$tradesstick[] = $trade;
			}
		}
		$trades = array_merge($tradesstick, $trades);
		include template('trade_displayorder');

	} else {

		$count = 0;
		while($trade = $db->fetch_array($query)) {
			$displayordernew = abs(intval($displayorder[$trade['pid']]));
			$displayordernew = $displayordernew > 128 ? 0 : $displayordernew;
			if($stick[$trade['pid']]) {
				$count++;
				$displayordernew = $displayordernew == 0 ? 1 : $displayordernew;
			}
			if(!$stick[$trade['pid']] || $displayordernew > 0 && $tradestick < $count) {
				$displayordernew = -1 * (128 - $displayordernew);
			}
			$db->query("UPDATE {$tablepre}trades SET displayorder='".$displayordernew."' WHERE tid='$tid' AND pid='$trade[pid]'");
		}

		showmessage('trade_displayorder_updated', "viewthread.php?tid=$tid");

	}

} elseif($action == 'debatevote') {

	if(!empty($thread['closed'])) {
		showmessage('thread_poll_closed');
	}

	if(!$discuz_uid) {
		showmessage('debate_poll_nopermission');
	}

	$isfirst = empty($pid) ? TRUE : FALSE;

	$debate = $db->fetch_first("SELECT uid, endtime, affirmvoterids, negavoterids FROM {$tablepre}debates WHERE tid='$tid'");

	if(empty($debate)) {
		showmessage('debate_nofound');
	}

	$feed = array();
	if($customaddfeed & 4) {
		$feed['icon'] = 'debate';
		$feed['title_template'] = 'feed_thread_debatevote_title';
		$feed['title_data'] = array(
			'subject' => "<a href=\"{$boardurl}viewthread.php?tid=$tid\">$thread[subject]</a>",
			'author' => "<a href=\"space.php?uid=$thread[authorid]\">$thread[author]</a>"
		);
	}

	if($isfirst) {
		$stand = intval($stand);

		if($stand == 1 || $stand == 2) {
			if(strpos("\t".$debate['affirmvoterids'], "\t$discuz_uid\t") !== FALSE || strpos("\t".$debate['negavoterids'], "\t$discuz_uid\t") !== FALSE) {
				showmessage('debate_poll_voted');
			} elseif($debate['uid'] == $discuz_uid) {
				showmessage('debate_poll_myself');
			} elseif($debate['endtime'] && $debate['endtime'] < $timestamp) {
				showmessage('debate_poll_end');
			}
		}
		if($stand == 1) {
			$db->query("UPDATE {$tablepre}debates SET affirmvotes=affirmvotes+1 WHERE tid='$tid'");
			$db->query("UPDATE {$tablepre}debates SET affirmvoterids=CONCAT(affirmvoterids, '$discuz_uid\t') WHERE tid='$tid'");
		} elseif($stand == 2) {
			$db->query("UPDATE {$tablepre}debates SET negavotes=negavotes+1 WHERE tid='$tid'");
			$db->query("UPDATE {$tablepre}debates SET negavoterids=CONCAT(negavoterids, '$discuz_uid\t') WHERE tid='$tid'");
		}

		if($feed) {
			postfeed($feed);
		}
		showmessage('debate_poll_succeed');
	}

	$debatepost = $db->fetch_first("SELECT stand, voterids, uid FROM {$tablepre}debateposts WHERE pid='$pid' AND tid='$tid'");
	if(empty($debatepost)) {
		showmessage('debate_nofound');
	}
	$debate = array_merge($debate, $debatepost);
	unset($debatepost);

	if($debate['uid'] == $discuz_uid) {
		showmessage('debate_poll_myself', "viewthread.php?tid=$tid");
	} elseif(strpos("\t".$debate['voterids'], "\t$discuz_uid\t") !== FALSE) {
		showmessage('debate_poll_voted', "viewthread.php?tid=$tid");
	} elseif($debate['endtime'] && $debate['endtime'] < $timestamp) {
		showmessage('debate_poll_end', "viewthread.php?tid=$tid");
	}




	/*
	if($isfirst) {
		$sqladd = $debate['stand'] == 1 ? 'affirmvotes=affirmvotes+1' : ($debate['stand'] == 2 ? 'negavotes=negavotes+1' : '');
		if($sqladd) {
			$db->query("UPDATE {$tablepre}debates SET $sqladd WHERE tid='$tid'");
		}
		unset($sqladd);
	}
	*/

	$db->query("UPDATE {$tablepre}debateposts SET voters=voters+1, voterids=CONCAT(voterids, '$discuz_uid\t') WHERE pid='$pid'");

	if($feed) {
		postfeed($feed);
	}
	showmessage('debate_poll_succeed', "viewthread.php?tid=$tid");

} elseif($action == 'debateumpire') {

	$debate = $db->fetch_first("SELECT * FROM {$tablepre}debates WHERE tid='$tid'");

	if(empty($debate)) {
		showmessage('debate_nofound');
	}elseif(!empty($thread['closed']) && $timestamp - $debate['endtime'] > 3600) {
		showmessage('debate_umpire_edit_invalid');
	} elseif($discuz_userss != $debate['umpire']) {
		showmessage('debate_umpire_nopermission');
	}

	$debate = array_merge($debate, $thread);

	if(!submitcheck('umpiresubmit')) {
		$query = $db->query("SELECT SUM(dp.voters) as voters, dp.stand, m.uid, m.username FROM {$tablepre}debateposts dp
			LEFT JOIN {$tablepre}members m ON m.uid=dp.uid
			WHERE dp.tid='$tid' AND dp.stand<>0
			GROUP BY m.uid
			ORDER BY voters DESC
			LIMIT 30");
		$candidate = $candidates = array();
		while($candidate = $db->fetch_array($query)) {
			$candidate['username'] = dhtmlspecialchars($candidate['username']);
			$candidates[$candidate['username']] = $candidate;
		}
		$winnerchecked = array($debate['winner'] => ' checked="checked"');

		list($debate['bestdebater']) = preg_split("/\s/", $debate['bestdebater']);

		include template('debate_umpire');
	} else {
		if(empty($bestdebater)) {
			showmessage('debate_umpire_nofound_bestdebater');
		} elseif(empty($winner)) {
			showmessage('debate_umpire_nofound_winner');
		} elseif(empty($umpirepoint)) {
			showmessage('debate_umpire_nofound_point');
		}
		$bestdebateruid = $db->result_first("SELECT uid FROM {$tablepre}members WHERE username='$bestdebater' LIMIT 1");
		if(!$bestdebateruid) {
			showmessage('debate_umpire_bestdebater_invalid');
		}
		if(!$bestdebaterstand = $db->result_first("SELECT stand FROM {$tablepre}debateposts WHERE tid='$tid' AND uid='$bestdebateruid' AND stand>'0' AND uid<>'$debate[uid]' AND uid<>'$discuz_uid' LIMIT 1")) {
			showmessage('debate_umpire_bestdebater_invalid');
		}
		$arr = $db->fetch_first("SELECT SUM(voters) as voters, COUNT(*) as replies FROM {$tablepre}debateposts WHERE tid='$tid' AND uid='$bestdebateruid'");
		$bestdebatervoters = $arr['voters'];
		$bestdebaterreplies = $arr['replies'];

		$umpirepoint = dhtmlspecialchars($umpirepoint);
		$bestdebater = dhtmlspecialchars($bestdebater);
		$winner = intval($winner);
		$db->query("UPDATE {$tablepre}threads SET closed='1' WHERE tid='$tid'");
		$db->query("UPDATE {$tablepre}debates SET umpirepoint='$umpirepoint', winner='$winner', bestdebater='$bestdebater\t$bestdebateruid\t$bestdebaterstand\t$bestdebatervoters\t$bestdebaterreplies', endtime='$timestamp' WHERE tid='$tid'");
		showmessage('debate_umpire_comment_succeed', 'viewthread.php?tid='.$tid);
	}

}

?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -