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

📄 redirect.php

📁 xm2sv1.0寻梦二手网 v1.0,一个经过我调试的PHP原代码,有机会大家多交流哈
💻 PHP
字号:
<?php

/*
	[DISCUZ!] redirect.php - lastpost redirection
	This is NOT a freeware, use is subject to license terms

	Version: 2.0.0
	Author: Crossday (info@discuz.net)
	Copyright: Crossday Studio (www.crossday.com)
	Last Modified: 2002/12/6 17:00
*/

require './include/common.php';

if(isset($fid) && empty($forum)) {
	showmessage('forum_nonexistence');
}

if($goto == 'lastpost') {

	if($highlight) {
		$highlight = "&highlight=".rawurlencode($highlight);
	}
	if($tid) {
		$query = $db->query("SELECT p.pid, p.dateline, t.tid, t.replies FROM $table_threads t, $table_posts p WHERE p.tid=t.tid AND t.tid='$tid' ORDER BY p.dateline DESC LIMIT 0,1");
		$post = $db->fetch_array($query);
		$page = ceil(($post['replies'] + 1) / $ppp);

		header("Location: {$boardurl}viewthread.php?tid=$post[tid]&page=$page&sid=$sid#pid$post[pid]$highlight");
	} else {
		$query = $db->query("SELECT p.pid, p.dateline, t.tid, t.replies FROM $table_threads t, $table_posts p WHERE p.tid=t.tid AND t.fid='$fid' ORDER BY p.dateline DESC LIMIT 0,1");
		$post = $db->fetch_array($query);
		$page = '&page='.ceil(($post['replies'] + 1) / $ppp);

		header("Location: {$boardurl}viewthread.php?tid=$post[tid]&page=$page&sid=$sid#pid$post[pid]");
	}

} elseif($goto == 'newpost') {

	if($highlight) {
		$highlight = "&highlight=".rawurlencode($highlight);
	}

	$posts = 0;
	$query = $db->query("SELECT pid, dateline FROM $table_posts WHERE tid='$tid' AND dateline>'$lastvisit' ORDER BY dateline");
	while($post = $db->fetch_array($query)) {
		if($post['dateline'] < $lastvisit) {
			$posts++;
		} else {
			break;
		}
	}

	$page = ceil($posts / $ppp);
	header("Location: viewthread.php?tid=$tid&page=$page&#pid$post[pid]");

} elseif($goto == 'nextnewset') {

	if($fid && $tid) {
		$query = $db->query("SELECT lastpost FROM $table_threads WHERE tid='$tid'");
		$this_lastpost = $db->result($query, 0);
		$query = $db->query("SELECT tid FROM $table_threads WHERE fid='$fid' AND lastpost>'$this_lastpost' ORDER BY lastpost ASC LIMIT 0, 1");
		if($next = $db->fetch_array($query)) {
			header("Location: {$boardurl}viewthread.php?tid=$next[tid]&sid=$sid");
		} else {
			showmessage('reditect_nextnewset_nonexistence');
		}
	} else {
		showmessage('undefined_action');
	}

} elseif($goto == 'nextoldset') {

	if($fid && $tid) {
		$query = $db->query("SELECT lastpost FROM $table_threads WHERE tid='$tid'");
		$this_lastpost = $db->result($query, 0);
		$query = $db->query("SELECT tid FROM $table_threads WHERE fid='$fid' AND lastpost<'$this_lastpost' ORDER BY lastpost DESC LIMIT 0, 1");
		if($last = $db->fetch_array($query)) {
			header("Location: {$boardurl}viewthread.php?tid=$last[tid]&sid=$sid");
		} else {
			showmessage('reditect_nextoldset_nonexistence');
		}
	} else {
		showmessage('undefined_action');
	}

}

?>

⌨️ 快捷键说明

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