Search

language

Mod tự động lấy tiêu đề bằng URL cho JohnCMS

Wednesday, July 8, 2015

Băt Đầu Nhé
Cái đầu tiên mà mởi host :D
Với một URL dạng http://domaincuaban.com và trang đó có tiêu đề là Diễn đàn ModJohn thì các bạn chỉ cần nhập http://domaincuaban.com nó sẽ tự GET tiêu đề luôn 
Code nhé các bạn
Bước 1: mở incfiles/classes/bbcode.php tìm
<?phpclass bbcode extends core{?>

Thêm trên nó đoạn Code sau:
<?php//Mod by ModJohn.Comfunction get_title($url){
  
$str file_get_contents($url);
      
$str trim(preg_replace('/\s+/'' '$str));     
    
preg_match("/\<title\>(.*)\<\/title\>/i",$str,$title);
if(
strlen($title[1]) > 0){
  return 
$title[1];
} else {
return 
$url;
}
}
?>

Tìm tiếp:
<?phpcase 2:
                        
$text $short_url;
                        if (!isset(
core::$user_set['direct_url']) || !core::$user_set['direct_url']) {$url core::$system_set['homeurl'] . '/go.php?url=' rawurlencode($url);?>
thay lại thành
<?phpcase 2:
                        
$text $short_url;
                        if (!isset(
core::$user_set['direct_url']) || !core::$user_set['direct_url']) {
   
$url $url;?>

Tìm tiếp:
<?phpreturn $whitespace '<a href="' $url '">' $text '</a>' $append;?>
thay lại thành
<?phpreturn $whitespace '<a href="' $url '">' get_title($text) . '</a>' $append;?>

Xong lưu lại là OK
Share

No comments:

Post a Comment

 
Copyright © 2015 Share Code Web - Vinacode
Giao Diện By sackaboy | Design By Sackaboy