• Downloading from our site will require you to have a paid membership. Upgrade to a Premium Membership from 10$ a month today!

    Dont forget read our Rules! Also anyone caught Sharing this content will be banned. By using this site you are agreeing to our rules so read them. Saying I did not know is simply not an excuse! You have been warned.

[JohnCMS] Share code auto tag lấy từ kết quả hiển thị của Google

Yeukodamnoi

New Member
Vip
Chèn vào incfiles/classes/functions.php
PHP:
//  Giacmovn.com
public static function  get_googleapis($key = '')
{
global  $textl, $set;
$body  = '';
if (!empty( $key)) {
$googleapis  = ' http://ajax.googleapis.com /ajax/services/search /web?v=1.0&q=' . rawurlencode($key) . '&rsz=large&start=1';
} else {
$googleapis  = ' http://ajax.googleapis.com /ajax/services/search /web?v=1.0&q=' . rawurlencode($textl) . '&rsz=large&start=1';
}
if ( function_exists('curl_init')) {
$ch  = curl_init();
curl_setopt ($ch, CURLOPT_URL, $googleapis);
curl_setopt ($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.31 (KHTML, like Gecko) Chrome/26.0.1410.64 Safari/537.31');
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_REFERER, ' http://google.com.vn/');
$body  = curl_exec($ch);
curl_close ($ch);
}
if (( $json = json_decode($body))) {
$total  = count($json->responseData->results);
$tag  = array();
for ( $i = 0; $i < $total; $i++) {
$search  = mb_substr($json->responseData->results[$i]->titleNoFormatting, 0, 64, 'UTF-8');
$tag [] = '<a href="' . $set['homeurl'] . '/forum/search.php?t=1&amp;search=' . urlencode($search) . '">' . $search . '</a>'; // Nếu Rewrite url thì sửa cái này
}
return  implode(', ', $tag);
}
return  'Có lỗi xảy ra!';
}
Cách sử dụng:
- Chèn vào forum/index.php (chỗ nào muốn hiển thị): functions::get_googleapis=()
Mặc định get từ tiêu đề bài viết, nếu chèn từ khóa vào thì get theo từ khóa đó!
Ví dụ:
- Mặc định:
PHP:
echo '<div class="list1">' . functions::get_googleapis() . '</div>';
- Tùy biến:
PHP:
$key = $res['text'];
echo '<div class="list1">' . functions::get_googleapis($key) . '</div>';
Demo: PHẦN MỀM GOOGLE MAP 3D (phần Google Tags cuối trang)
 
Last edited:

Facebook Comments

New posts New threads New resources

Back
Top