返回列表 回复 发帖

你好,能否解答下"DZ 7.2的REDIRECT.PHP优化"中的疑问

http://seo.banmutian.org/thread-7-1-1.html

请问这里提到的四处优化,DZ 7.2里面只有三处.按照2楼给出的代码我应该改哪2处?非常感谢
能不能贴下dz7.2的redirect.php的代码,不下载了就.
交流QQ群:13519368
  1. <?php

  2. /*
  3.         [Discuz!] (C)2001-2009 Comsenz Inc.
  4.         This is NOT a freeware, use is subject to license terms

  5.         $Id: redirect.php 21051 2009-11-09 08:13:08Z monkey $
  6. */

  7. define('CURSCRIPT', 'viewthread');

  8. require_once './include/common.inc.php';

  9. if(empty($goto) && !empty($ptid)) {
  10.         $ptid = intval($ptid);
  11.         $postno = intval($postno);
  12.         if($ordertype != 1) {
  13.                 $postno = $postno > 0 ? $postno - 1 : 0;
  14.                 $pid = $db->result_first("SELECT pid FROM {$tablepre}posts WHERE tid='$ptid' AND invisible='0' ORDER BY dateline LIMIT $postno, 1");
  15.         } else {
  16.                 $postno = $postno > 1 ? $postno - 1 : 0;
  17.                 if($postno) {
  18.                         $pid = $db->result_first("SELECT pid FROM {$tablepre}posts WHERE tid='$ptid' AND invisible='0' ORDER BY dateline LIMIT $postno, 1");
  19.                 } else {
  20.                         $pid = $db->result_first("SELECT pid FROM {$tablepre}posts WHERE tid='$ptid' AND first='1' LIMIT 1");
  21.                 }
  22.         }
  23.         $goto = 'findpost';
  24. }

  25. if($goto == 'findpost') {
  26.         $pid = intval($pid);
  27.         $ptid = intval($ptid);
  28.         if($post = $db->fetch_first("SELECT p.tid, p.dateline, t.status, t.special, t.replies FROM {$tablepre}posts p LEFT JOIN {$tablepre}threads t USING(tid) WHERE p.pid='$pid'")) {
  29.                 $ordertype = !isset($_GET['ordertype']) && getstatus($post['status'], 4) ? 1 : intval($ordertype);
  30.                 $sqladd = $post['special'] ? "AND first=0" : '';
  31.                 $curpostnum = $db->result_first("SELECT count(*) FROM {$tablepre}posts WHERE tid='$post[tid]' AND dateline<='$post[dateline]' $sqladd");
  32.                 if($ordertype != 1) {
  33.                         $page = ceil($curpostnum / $ppp);
  34.                 } else {
  35.                         if($curpostnum > 1) {
  36.                                 $page = ceil(($post['replies'] - $curpostnum + 3) / $ppp);
  37.                         } else {
  38.                                 $page = 1;
  39.                         }
  40.                 }
  41.                 if(!empty($special) && $special == 'trade') {
  42.                         dheader("Location: viewthread.php?do=tradeinfo&tid=$post[tid]&pid=$pid");
  43.                 } else {
  44.                         $extra = '';
  45.                         if($discuz_uid && empty($postno)) {
  46.                                 if($db->result_first("SELECT count(*) FROM {$tablepre}favoritethreads WHERE tid='$post[tid]' AND uid='$discuz_uid'")) {
  47.                                         $db->query("UPDATE {$tablepre}favoritethreads SET newreplies=0 WHERE tid='$post[tid]' AND uid='$discuz_uid'", 'UNBUFFERED');
  48.                                         $db->query("DELETE FROM {$tablepre}promptmsgs WHERE uid='$discuz_uid' AND typeid='".$prompts['threads']['id']."' AND extraid='$post[tid]'", 'UNBUFFERED');
  49.                                         $extra = '&fav=yes';
  50.                                 }
  51.                         }
  52.                         dheader("Location: viewthread.php?tid=$post[tid]&rpid=$pid$extra&ordertype=$ordertype&page=$page".(isset($_GET['modthreadkey']) && ($modthreadkey=modthreadkey($post['tid'])) ? "&modthreadkey=$modthreadkey": '')."#pid$pid");
  53.                 }
  54.         } else {
  55.                 $ptid = !empty($ptid) ? intval($ptid) : 0;
  56.                 if($ptid) {
  57.                         dheader("location: viewthread.php?tid=$ptid");
  58.                 }
  59.                 showmessage('post_check', NULL, 'HALTED');
  60.         }
  61. }

  62. $tid = $forum['closed'] < 2 ? $tid : $forum['closed'];

  63. if(empty($tid)) {
  64.         showmessage('thread_nonexistence');
  65. }

  66. if(isset($fid) && empty($forum)) {
  67.         showmessage('forum_nonexistence', NULL, 'HALTED');
  68. }

  69. @include DISCUZ_ROOT.'./forumdata/cache/cache_viewthread.php';

  70. if($goto == 'lastpost') {

  71.         if($tid) {
  72.                 $query = $db->query("SELECT tid, replies, special, status FROM {$tablepre}threads WHERE tid='$tid' AND displayorder>='0'");
  73.         } else {
  74.                 $query = $db->query("SELECT tid, replies, special, status FROM {$tablepre}threads WHERE fid='$fid' AND displayorder>='0' ORDER BY lastpost DESC LIMIT 1");
  75.         }
  76.         if(!$thread = $db->fetch_array($query)) {
  77.                 showmessage('thread_nonexistence');
  78.         }
  79.         if(!getstatus($thread['status'], 4)) {
  80.                 $page = ceil(($thread['special'] ? $thread['replies'] : $thread['replies'] + 1) / $ppp);
  81.         } else {
  82.                 $page = 1;
  83.         }

  84.         $tid = $thread['tid'];

  85.         require_once DISCUZ_ROOT.'./viewthread.php';
  86.         exit();

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

  88.         if($fid && $tid) {
  89.                 $this_lastpost = $db->result_first("SELECT lastpost FROM {$tablepre}threads WHERE tid='$tid' AND displayorder>='0'");
  90.                 if($next = $db->fetch_first("SELECT tid FROM {$tablepre}threads WHERE fid='$fid' AND displayorder>='0' AND lastpost>'$this_lastpost' ORDER BY lastpost ASC LIMIT 1")) {
  91.                         $tid = $next['tid'];
  92.                         require_once DISCUZ_ROOT.'./viewthread.php';
  93.                         exit();
  94.                 } else {
  95.                         showmessage('redirect_nextnewset_nonexistence');
  96.                 }
  97.         } else {
  98.                 showmessage('undefined_action', NULL, 'HALTED');
  99.         }

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

  101.         if($fid && $tid) {
  102.                 $this_lastpost = $db->result_first("SELECT lastpost FROM {$tablepre}threads WHERE tid='$tid' AND displayorder>='0'");
  103.                 if($last = $db->fetch_first("SELECT tid FROM {$tablepre}threads WHERE fid='$fid' AND displayorder>='0' AND lastpost<'$this_lastpost' ORDER BY lastpost DESC LIMIT 1")) {
  104.                         $tid = $last['tid'];
  105.                         require_once DISCUZ_ROOT.'./viewthread.php';
  106.                         exit();
  107.                 } else {
  108.                         showmessage('redirect_nextoldset_nonexistence');
  109.                 }
  110.         } else {
  111.                 showmessage('undefined_action', NULL, 'HALTED');
  112.         }

  113. } else {
  114.         showmessage('undefined_action', NULL, 'HALTED');
  115. }

  116. ?>
复制代码
非常非常感谢你的回复
哦,其实全改了就可以。
第一个lastpost,即最后发表,这个是要改的。
后面两个是“下一主题”和“上一主题”,也是要修改的,7.0页面没有这两个链接,以前版本有,不知道7.2有没有。
交流QQ群:13519368
上面贴的就是7.2的 REDIRECT.PHP

请问哪几个链接需要像原帖里2楼所说的改成
  1.         header("HTTP/1.1 301 Moved Permanently");
  2.         header("Location: thread-{$tid}-{$page}-1.html");
复制代码
require_once DISCUZ_ROOT.'./viewthread.php';

这个都替换了就行了
交流QQ群:13519368
非常感谢你的回复
返回列表