Discuz Thai

 ลืมรหัสผ่าน
 สมัครสมาชิก

ข้อตกลงการใช้งานกระดานข่าวดิสคัสไทย DiscuzThai Agreement (English Version) ประกาศดิสคัสไทย - ทำเนียบดิสคัสภาษาไทย

Discuz! X3.5 Thai R20231001 Rev.8 (NEW) [วิดีโอช่วยสอน] อัปเกรด Discuz! X3.4 เป็น X3.5 Discord ของ Discuz! Thai Community อย่างเป็นทางการ

Discuz! X3.4 Thai R20220811 (REV.75) สิ้นสุดการสนับสนุน Discuz! X3.4 ภาษาไทยตั้งแต่วันนี้เป็นต้นไป (ขอแนะนำให้อัปเกรดเป็น X3.5 แทน)

ค้นหา
แท็กยอดนิยม: ดิสคัสภาษาไทย Discuz Thai
ดู: 40228|ตอบกลับ: 74

Toplist Top 10 For 7.0

[คัดลอกลิงก์]
suthida โพสต์ 2008-12-18 15:16:09 |โหมดอ่าน
แก้ไขล่าสุด suthida เมื่อ 2009-1-27 11:25

ชื่อ : Toplist Top 10 For 7.0
เครดิต : hxxp://www.dishack.cn/thread-686-1-1.html
ไฟล์ที่ต้องแก้ไข : index.php, discuz.htm

ขั้นตอนอัพโหลดไฟล์ และทำการแก้ไขไฟล์ 2 ไฟล์ค่ะ
หรือสำหรับใครที่ยังไม่ได้ปรับแต่งเว็บบอร์ดอะไรมากนัก ก็ดาวน์โหลดและนำไปทับตำแหน่งเดิมได้เลยค่ะ

ตัวอย่าง



เปิดไฟล์ index.php
ค้นหา

  1. $newthreads = round(($timestamp - $lastvisit + 600) / 1000) * 1000;
คัดลอกไปที่คลิปบอร์ด


ใส่โค๊ดนี้บรรทัดต่อไป

  1. //----Toplist
  2. $colorarray = array('', 'red', 'orange', 'yellow', 'green', 'cyan', 'blue', 'purple', 'gray');
  3. //โพสใหม่
  4. $hack_cut_str = 28; //ความยาวของหัวข้อ
  5. $hack_cut_strauthor = 9;
  6. $new_post_threadlist = array();
  7. $nthread = array();
  8. $query = $db->query("SELECT t.*, f.name FROM {$tablepre}threads t, {$tablepre}forums f WHERE t.fid<>'$fid' AND f.fid=t.fid AND f.fid not in (0) AND t.displayorder not in (-1,-2) ORDER BY t.dateline DESC LIMIT 0, 10");
  9. while($nthread = $db->fetch_array($query)) {
  10.         $nthread['forumname'] = ereg_replace('<[^>]*>','',$nthread['name']);
  11.         $nthread['view_subject'] = cutstr($nthread['subject'],$hack_cut_str);
  12.         $nthread['view_author'] = cutstr($nthread['author'],$hack_cut_strauthor);
  13.         $nthread['date']= gmdate("$dateformat $timeformat", $nthread['dateline'] + $timeoffset * 3600);
  14.         $nthread['lastreplytime']= gmdate("$dateformat $timeformat", $nthread[lastpost] + ($timeoffset * 3600));
  15.         if($nthread['highlight']) {
  16.                 $string = sprintf('%02d', $nthread['highlight']);
  17.                 $stylestr = sprintf('%03b', $string[0]);
  18.                 $nthread['highlight'] = 'style="';
  19.                 $nthread['highlight'] .= $stylestr[0] ? 'font-weight: bold;' : '';
  20.                 $nthread['highlight'] .= $stylestr[1] ? 'font-style: italic;' : '';
  21.                 $nthread['highlight'] .= $stylestr[2] ? 'text-decoration: underline;' : '';
  22.                 $nthread['highlight'] .= $string[1] ? 'color: '.$colorarray[$string[1]] : '';
  23.                 $nthread['highlight'] .= '"';
  24.         } else {
  25.                 $nthread['highlight'] = '';
  26.         }
  27.         $new_post_threadlist[] = $nthread;
  28. }
  29. //ตอบใหม่
  30. $hack_cut_str = 28; //ความยาวของหัวข้อ
  31. $hack_cut_strauthor = 9;
  32. $new_reply_threadlist = array();
  33. $rthread = array();
  34. $query = $db->query("SELECT t.*, f.name FROM {$tablepre}threads t, {$tablepre}forums f WHERE t.fid<>'$fid' AND f.fid=t.fid  AND t.closed NOT LIKE 'moved|%' AND t.replies !=0 AND f.fid not in (0) AND t.displayorder not in (-1,-2) ORDER BY t.lastpost DESC LIMIT 0, 10");
  35. while($rthread = $db->fetch_array($query)) {
  36.         $rthread['forumname'] = ereg_replace('<[^>]*>','',$rthread['name']);
  37.         $rthread['view_subject'] = cutstr($rthread['subject'],$hack_cut_str);
  38.         $rthread['view_lastposter'] = cutstr($rthread['lastposter'],$hack_cut_strauthor);
  39.   $rthread['date']= gmdate("$dateformat $timeformat", $rthread['dateline'] + $timeoffset * 3600);
  40.         $rthread['lastreplytime']= gmdate("$dateformat $timeformat", $rthread[lastpost] + ($timeoffset * 3600));
  41.         if($rthread['highlight']) {
  42.                 $string = sprintf('%02d', $rthread['highlight']);
  43.                 $stylestr = sprintf('%03b', $string[0]);
  44.                 $rthread['highlight'] = 'style="';
  45.                 $rthread['highlight'] .= $stylestr[0] ? 'font-weight: bold;' : '';
  46.                 $rthread['highlight'] .= $stylestr[1] ? 'font-style: italic;' : '';
  47.                 $rthread['highlight'] .= $stylestr[2] ? 'text-decoration: underline;' : '';
  48.                 $rthread['highlight'] .= $string[1] ? 'color: '.$colorarray[$string[1]] : '';
  49.                 $rthread['highlight'] .= '"';
  50.         } else {
  51.                 $rthread['highlight'] = '';
  52.         }
  53.         $new_reply_threadlist[] = $rthread;
  54. }
  55. //หัวข้อเด่นประจำสัปดาห์
  56. $hack_cut_str = 30; //ความยาวของหัวข้อ
  57. $hack_cut_strauthor = 9;
  58. $new_hot_threadlist = array();
  59. $mthread = array();
  60. $ctime=$timestamp-3600*24*7;//ื๎บ๓7สวฬ์สฮชฑพึ  
  61. $query = $db->query("SELECT t.*, f.name FROM {$tablepre}threads t, {$tablepre}forums f WHERE t.fid<>'$fid' AND f.fid=t.fid  AND t.closed NOT LIKE 'moved|%' AND t.replies !=0 AND t.dateline>$ctime AND f.fid not in (0) AND t.displayorder not in (-1,-2) ORDER BY t.replies DESC LIMIT 0, 10");
  62. while($mthread = $db->fetch_array($query)) {
  63.         $mthread['forumname'] = ereg_replace('<[^>]*>','',$mthread['name']);
  64.         $mthread['view_subject'] = cutstr($mthread['subject'],$hack_cut_str);
  65.         $mthread['view_lastposter'] = cutstr($mthread['lastposter'],$hack_cut_strauthor);
  66.   $mthread['date']= gmdate("$dateformat $timeformat", $mthread['dateline'] + $timeoffset * 3600);
  67.         $mthread['lastreplytime']= gmdate("$dateformat $timeformat", $mthread[lastpost] + ($timeoffset * 3600));
  68.         if($mthread['highlight']) {
  69.                 $string = sprintf('%02d', $mthread['highlight']);
  70.                 $stylestr = sprintf('%03b', $string[0]);
  71.                 $mthread['highlight'] = 'style="';
  72.                 $mthread['highlight'] .= $stylestr[0] ? 'font-weight: bold;' : '';
  73.                 $mthread['highlight'] .= $stylestr[1] ? 'font-style: italic;' : '';
  74.                 $mthread['highlight'] .= $stylestr[2] ? 'text-decoration: underline;' : '';
  75.                 $mthread['highlight'] .= $string[1] ? 'color: '.$colorarray[$string[1]] : '';
  76.                 $mthread['highlight'] .= '"';
  77.         } else {
  78.                 $mthread['highlight'] = '';
  79.         }
  80.         $new_hot_threadlist[] = $mthread;
  81. }
  82. //ฝ๑ศีทขฬ๙ลละะ
  83. $tomonth=date(n);
  84. $todate=date(j);
  85. $toyear=date(Y);
  86. $time=mktime(0,0,0,$tomonth,$todate,$toyear);
  87. $query=$db->query("select count(pid) as num,authorid,author from $tablepre"."posts where dateline>=$time group by authorid order by num desc limit 0,10");
  88. while($result=$db->fetch_array($query)){
  89. $poststar.="<a href=space.php?uid=".$result[authorid].">".cutstr($result[author],8)."</a><font color=red>[".$result[num]."]</font>&nbsp; ";
  90. }
  91. //----Toplist
คัดลอกไปที่คลิปบอร์ด


เปิดไฟล์ discuz.htm
ค้นหา

  1. function announcementScrollnext(time) {
  2.    $('annbody').scrollTop++;
  3.    anncount++;
  4.    if(anncount != time) {
  5.     annst = setTimeout('announcementScrollnext(' + time + ')', 10);
  6.    } else {
  7.     annrowcount++;
  8.     annst = setTimeout('announcementScroll()', anndelay);
  9.    }
  10.   }
  11. </script>
  12. <!--{/if}-->
  13. </div>
คัดลอกไปที่คลิปบอร์ด


เพิ่มโค๊ดนี้บรรทัดต่อไป

  1. <!-- Toplist -->
  2. <div class="mainbox forumlist" style="padding:0;">
  3. <table cellspacing="0" cellpadding="0">
  4.   <thead class="category">
  5.   <tr>
  6.    <td align="center" style="padding:0 1px 0 0"><h3>≡ รูปจากระดานข่าว  ≡</h3></td>
  7.    <td align="center" style="padding:0"><h3>≡ กระทู้ล่าสุด  ≡</h3></td>
  8.    <td align="center" style="padding:0 1px 0 1px"><h3>≡ โพสล่าสุด  ≡</h3></td>
  9.    <td align="center" style="padding:0"><h3>≡ กระทู้จากสมาชิก  ≡</h3></td>
  10.    <td></td>
  11.   </tr>
  12.   </thead>
  13.   <tr>
  14.    <td width="24%">
  15.     <script type="text/javascript" src="pic.php"></script>
  16.    </td>
  17.    <td width="25%">
  18.     <table border="0" cellpadding="0" cellspacing="0" width="100%">
  19.      <tr valign="top">
  20.       <td width="24" style="padding:0;border-top:0px;"><img src="images/list.gif" border="0" /></td>
  21.       <td background="images/listbg.gif" style="line-height:20px;padding:0;border-top:0px;background-repeat: repeat-y" width="100%">
  22.       <!--{loop $new_post_threadlist $nthread}-->
  23.        <!--{if $nthread[replies]}-->
  24.         <div style="overflow: hidden;height: 20px;width: 100%;"><a href="viewthread.php?tid=$nthread[tid]" $nthread['highlight'] title='หัวข้อใหม่ {LF}กระดาน: $nthread[forumname]{LF}ชื่อกระทู้: $nthread[subject] {LF}โพสโดย: $nthread[author]{LF}โพสเมื่อ: $nthread[date]{LF}ดูแล้ว: $nthread[views] คน {LF}ตอบแล้ว: $nthread[replies] คน{LF}ตอบล่าสุด: $nthread[lastreplytime]{LF}{lang lastpost}: $nthread[lastposter]'>$nthread[view_subject]</a></div>
  25.                    <!--{else}-->
  26.         <div style="overflow: hidden;height: 20px;width: 100%;"><a href="viewthread.php?tid=$nthread[tid]" $nthread['highlight'] title='หัวข้อใหม่ {LF}กระดาน: $nthread[forumname]{LF}ชื่อกระทู้: $nthread[subject] {LF}โพสโดย: $nthread[author]{LF}โพสเมื่อ: $nthread[date]{LF}ดูแล้ว: $nthread[views] คน {LF}ตอบแล้ว: $nthread[replies] คน{LF}ตอบล่าสุด: ไม่มี'>$nthread[view_subject]</a></div>
  27.        <!--{/if}-->
  28.       <!--{/loop}-->
  29.       </td>
  30.      </tr>
  31.     </table>
  32.    </td>
  33.    <td width="25%">
  34.     <table border="0" cellpadding="0" cellspacing="0" width="100%">
  35.      <tr valign="top">
  36.       <td width="24" style="padding:0;border-top:0px;"><img src="images/list.gif" border="0" /></td>
  37.       <td background="images/listbg.gif" style="line-height:20px;padding:0;border-top:0px;background-repeat: repeat-y" width="100%">
  38.       <!--{loop $new_reply_threadlist $rthread}-->
  39.        <div style="overflow: hidden;height: 20px;width: 100%;"><a href="viewthread.php?tid=$rthread[tid]" $rthread['highlight'] title='โพสล่าสุด {LF}กระดาน: $rthread[forumname]{LF}ชื่อกระทู้: $rthread[subject]{LF}โพสโดย: $rthread[author]{LF}โพสเมื่อ: $rthread[date]{LF}ดูแล้ว: $rthread[views] คน{LF}ตอบแล้ว: $rthread[replies] คน{LF}ตอบล่าสุด: $rthread[lastreplytime]{LF}{lang lastpost}: $rthread[lastposter]'>$rthread[view_subject]</a></div>
  40.       <!--{/loop}-->
  41.       </td>
  42.      </tr>
  43.     </table>
  44.    </td>
  45.    <td width="26%">
  46.     <table border="0" cellpadding="0" cellspacing="0" width="100%">
  47.      <tr valign="top">
  48.       <td width="24" style="padding:0;border-top:0px;"><img src="images/list.gif" border="0" /></td>
  49.       <td background="images/listbg.gif" style="line-height:20px;padding:0;border-top:0px;background-repeat: repeat-y" width="100%">
  50.       <!--{loop $new_hot_threadlist $mthread}-->
  51.        <div style="overflow: hidden;height: 20px;width: 100%;"><a href="viewthread.php?tid=$mthread[tid]" $mthread['highlight'] title='กระทู้จากสมาชิก {LF}กระดาน: $mthread[forumname]{LF}ชื่อกระทู้: $mthread[subject]{LF}โพสโดย: $mthread[author]{LF}โพสเมื่อ: $mthread[date]{LF}ดูแล้ว: $mthread[views] คน{LF}ตอบแล้ว: $mthread[replies] คน{LF}ตอบล่าสุด: $mthread[lastreplytime]{LF}{lang lastpost}: $mthread[lastposter]'>$mthread[view_subject]</a></div>
  52.       <!--{/loop}-->
  53.       </td>
  54.      </tr>
  55.     </table>
  56.    </td>
  57.    <td>
  58.     <table border="0" cellpadding="0" cellspacing="0" width="100%">
  59.      <tr valign="top">
  60.       <td></td>
  61.       <td>
  62.       
  63.       </td>
  64.      </tr>
  65.     </table>
  66.    </td>
  67.   </tr>
  68. </table>
  69. <table cellspacing="2" cellpadding="2">
  70. <tr>
  71. <td><font color=red><b>Top10: </b></font>$poststar</td>
  72. </tr>
  73. </table>
  74. </div>
  75. <!-- Toplist -->
คัดลอกไปที่คลิปบอร์ด


เสร็จเรียบร้อยค่ะ แล้วอย่าลืม อัพเดทแคชด้วยนะคะ :)

**แก้ไขนิดนะคะ สำหรับใครดาวน์โหลดไปแล้วเอาไฟล์ที่ชื่อ discuz.htm ไปไว้ที่ templates\default\discuz.htm**


ปัญหาที่พบปล่อยในการแสดงผลของภาพ
1. การแก้ไขไฟล์ pic.php เป็นการกำหนด ขอบเขตของการแสดงภาพ fid ของกระดาน
ถ้าหากต้องการให้รันแสดงภาพทุกๆกระทู้ก็ให้ปล่อยว่างไว้ค่ะไม่ต้องใส่ตัวเลข fid
2. และก็อีกกรณี ใช้ FF แนบไฟล์รูปอาดทำให้ภาพไม่แสดงค่ะ แต่ถ้าใช้ IE แนบไฟล์ ภาพจะแสดงค่ะ อันนี้เทสแล้วเป็นจริงค่ะ

3. กรณีใช้โฮสฟรีรูปไม่ขึ้น ให้เปิดไฟล์ pic.php

ค้นหา
  1. filetype='image/pjpeg'
คัดลอกไปที่คลิปบอร์ด

แทนที่ด้วย
  1. filetype LIKE 'image/%'
คัดลอกไปที่คลิปบอร์ด


----------------------------------------

แก้ไขข้อที่ 1 ไฟล์ pic เพื่อกำหนด fid เปิดไฟล์ pic.php ค่ะ
ค้นหา
  1. $searchfid        = ' ';//
คัดลอกไปที่คลิปบอร์ด


ในช่อง ' '  ให้คุณใส่ fid ของกระดานข่าวที่อัพโหลดรูปไว้ค่ะ  เช่น fid ที่ 21 และ 22 คือ 2 ฟรั่อมค่ะ
  1. $searchfid        = '21,22';//
คัดลอกไปที่คลิปบอร์ด


ตัวอย่าง fid ของกระดานข่าว

  1. http://www.discuzthai.com/forum-21-1.html
คัดลอกไปที่คลิปบอร์ด


fid = 21

ขออภัย! โพสต์นี้มีไฟล์แนบหรือรูปภาพที่ไม่ได้รับอนุญาตให้คุณเข้าถึง

คุณจำเป็นต้อง ลงชื่อเข้าใช้ เพื่อดาวน์โหลดหรือดูไฟล์แนบนี้ คุณยังไม่มีบัญชีใช่ไหม? สมัครสมาชิก

x

คะแนน

จำนวนผู้เข้าร่วม 14จิตพิศัย +43 ย่อ เหตุผล
surasakounman + 1
sssii + 1
timber2u + 1
YoungterK + 1 mod น่าสนใจ
25chaos27 + 1 ขอบคุณมากๆจ้า เก่งมา ...

ดูบันทึกคะแนน

buachompoox โพสต์ 2008-12-18 15:29:44
คงมีหลายคนหาตัวนี้อยู่ หุๆๆๆ {:14_648:}
trickstertik โพสต์ 2008-12-18 17:35:18
ขอบคุณครับ
uismyfriend โพสต์ 2008-12-19 15:59:41
ขอบคุณนะคะพี่ก้อย
new2007 โพสต์ 2008-12-19 17:56:52
ขอบคุณนะงับ
thailivezone โพสต์ 2008-12-22 00:44:10
ขอบคุณมากครับผมไม่เห็นต้องแก้โค้ดเลยนิครับแก้โค้ดมาแล้ว

แค่อัพทับก็แสดงทอปลิสแล้ว

เยี่ยมไปเลยครับ ขอบคุณจริงๆ
samz โพสต์ 2008-12-22 00:53:20
ขอบคุณมากครับ คุณก้อย
flukenakrab โพสต์ 2008-12-22 08:06:45
ขอบคุณครับ
phoom2526 โพสต์ 2008-12-23 07:13:05
โห แก้มาให้เรียร้อย เจ๋งอ่ะ ขอบคุณครับ
jaideejung007 โพสต์ 2008-12-23 13:46:10
อยากบอกพี่ว่า "ขอบคุณครับ"
คำคำนี้คงจะชินหูแร้ว แต่มันออกมาจากใจง่ะ
ว่าขอบคุณอีกครั้ง
ที่อุตสาห์มาแบ่งปัน
แถมยังไม่คิดตังค์ด้วยครับ
ขอบคุณอีกครั้งที่2
ขอให้เจริญๆๆๆ นะครับ สาธุ ว้าววววว
ขออภัย! คุณไม่ได้รับสิทธิ์ในการดำเนินการในส่วนนี้ กรุณาเลือกอย่างใดอย่างหนึ่ง ลงชื่อเข้าใช้ | สมัครสมาชิก

รายละเอียดเครดิต

รายชื่อผู้กระทำผิด|Archiver|ดิสคัส ไทย Follow us: Become a fan on facebook. Follow us on Twitter.

GMT+7, 2024-4-18 17:29

Powered by Discuz! X3.4, Rev.66

Copyright © 2001-2021 Tencent Cloud. Licensed

ตอบกระทู้ ขึ้นไปด้านบน ไปที่หน้ารายการกระทู้