[New2th] โชว์บอทใน online list
แก้ไขครั้งสุดท้ายโดย New2th เมื่อ 2011-4-26 14:12http://image.free.in.th/z/ik/ggggg.png
ขอบคุณรูปจาก StaFF_PiRcH
กรุณาสำรองไฟล์ก่อนทำการแก้ไขใดๆ
๑. ขั้นแรกไปที่ Admin CP / เว็บมาสเตอร์ / จัดการฐานข้อมูล / อัพเกรด / ช่อง Discuz! 數據庫升級 - 請將數據庫升級語句粘貼在下面: ใส่โค้ดALTER TABLEpre_common_session ADDbotid TINYINT(2) UNSIGNED NOT NULL DEFAULT 0 AFTER tidhttp://2th.me/i/1/z/z.png
๒. เปิดไฟล์ ./source/function/function_core.php
เพิ่มfunction user2idbot($user_agent){
$user_agent = strtolower($user_agent);
if (strstr($user_agent, 'yandex')){ $bot=1;}
else if (strstr($user_agent, 'googlebot')){$bot=2;}
else if (strstr($user_agent, 'mediapartners-google')){$bot=3;}
else if (strstr($user_agent, 'slurp')){$bot=4;}
else if (strstr($user_agent, 'webcrawler')){$bot=5;}
else if (strstr($user_agent, 'zyborg')){$bot=6;}
else if (strstr($user_agent, 'scooter')){$bot=7;}
else if (strstr($user_agent, 'stackrambler')){$bot=8;}
else if (strstr($user_agent, 'aport')){$bot=9;}
else if (strstr($user_agent, 'lycos')){$bot=10;}
else if (strstr($user_agent, 'webalta')){$bot=11;}
else if (strstr($user_agent, 'yahoo')){$bot=12;}
else if (strstr($user_agent, 'msnbot')){$bot=13;}
else if (strstr($user_agent, 'ia_archiver')){$bot=14;}
else if (strstr($user_agent, 'fast')){$bot=15;}
else if (strstr($user_agent, 'facebook')){$bot=16;}
else if (strstr($user_agent, 'ia_archiver')){$bot=17;}
return $bot;
}
function idbot2user($botid){
if($botid==0){$user='';}
elseif($botid==1){$user='Yandex';}
elseif($botid==2){$user='<img src="static/image/google.gif" alt="Google" />';}
elseif($botid==3){$user='<img src="static/image/google.gif" alt="Google" /> <span style="font-weight:bold;">Adsense</span>';}
elseif($botid==4){$user='Hot Bot search';}
elseif($botid==5){$user='WebCrawler search';}
elseif($botid==6){$user='Wisenut search';}
elseif($botid==7){$user='AltaVista';}
elseif($botid==8){$user='Rambler';}
elseif($botid==9){$user='Aport';}
elseif($botid==10){$user='Lycos';}
elseif($botid==11){$user='WebAlta';}
elseif($botid==12){$user='<span style="color:#65106e;font-weight:bold;">Yahoo!</span>';}
elseif($botid==13){$user='<span style="color:#eea930;font-weight:bold;">Bing</span>';}
elseif($botid==14){$user='Alexa search engine';}
elseif($botid==15){$user='AllTheWeb';}
// elseif($botid==16){$user='<span style="background:#3b5999;color:#ffffff;padding:0 2px 0 2px;font-weight:bold;">facebook</span>';}
elseif($botid==16){$user='<span style="color:#3b5999;font-weight:bold;">facebook</span>';}
elseif($botid==17){$user='Alexa';}
return $user;
}
หลังdefine('DISCUZ_CORE_FUNCTION', true);๓. เปิดไฟล์ ./source/class/class_core.php
หา function update() {
if($this->sid !== null) {
$data = daddslashes($this->var);
if($this->isnew) {
$this->delete();
DB::insert('common_session', $data, false, false, true);
} else {
DB::update('common_session', $data, "sid='$data'");
}
dsetcookie('sid', $this->sid, 86400);
}
}เปลี่ยนเป็น function update() {
if($this->sid !== null) {
$data = daddslashes($this->var);
if($this->isnew) {
$this->delete();
DB::insert('common_session', $data, false, false, true);
$bot = user2idbot($_SERVER['HTTP_USER_AGENT']);
if($bot){
DB::query('UPDATE pre_common_session SET botid='.$bot.' WHERE sid=\''.$this->sid.'\'');
}
} else {
DB::update('common_session', $data, "sid='$data'");
}
dsetcookie('sid', $this->sid, 86400);
}
}๔. เปิดไฟล์ ./source/module/forum/forum_index.php
หา$query = DB::query("SELECT uid, username, groupid, invisible, lastactivity, fid FROM ".DB::table('common_session')." WHERE uid='0' ORDER BY uid DESC LIMIT ".($_G['setting']['maxonlinelist'] - $membercount));แก้เป็น$query = DB::query("SELECT uid, username, groupid, invisible, lastactivity, fid, botid FROM ".DB::table('common_session')." WHERE uid='0' ORDER BY uid DESC LIMIT ".($_G['setting']['maxonlinelist'] - $membercount));หา$online['username'] = $_G['cache']['onlinelist']['guest'];แก้เป็น if($online['botid']){
$online['username'] = idbot2user($online['botid']);
}else{
$online['username'] = $_G['cache']['onlinelist']['guest'];
}๕. ก็อบรูปนี้ไปไว้ที่ โฟลเดอร์ ./static/image/
เสร็จสิ้น
New2th
อนุญาตให้เผยแพร่เฉพาะใน http://forum.discuzthai.com รอมานาน{:22_871:} ขอบคุณครับ sm907dz ของผมเช็คจาก ip บอกตรงๆ เยี่ยม
บอกทางอ้อม โมยังจัง
บอกตามความรู้สึก ขอบคุณนะ ใช้กับX1ได้มั้ยครับ แล้วเฟสบุ๊คล่ะ แก้ไขครั้งสุดท้ายโดย jaideejung007 เมื่อ 2011-4-19 21:05
สีตัวอักษรของ Google ทั้ง 5 ตัว เผื่อใครไม่อยากใช้รูปภาพ
Google#0039b6
#c41200
#f3c518
#0039b6
#30a72f
#c41200Thank to New2th เฮียก็ว่าจะถามนิวนานละ เห็นกระทู้นี้เลยมากดบวกซะเรย
ขอบใจนะน้องเฮีย อยากบอกว่าโดนใจที่สุดเลยครับ แต่เศร้าใจเพราะตอนนี้ที่เว็บดันใช้แบบไม่โชว์ไอคอนออนไลน์เรียบร้อยเพราะคนออนเยอะๆหลายๆวัน เปลืองแบนด์วิดท์ 555 แต่ยัง+ ให้ครับสำหรับน้ำใจ+ข้อมูลดีดี ครับ