[JohnCMS] Share code auto tag lấy từ kết quả hiển thị của Google
admin(06.08.2013/12:06)
Chèn vào [b]incfiles/classes/functions.php[/b]
[code]// Giacmovn.com
public static function get_googleapis($key = '')
{
global $textl, $set;
$body = '';
if (!empty($key)) {
$googleapis = '[url=http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=']http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q='[/url] . rawurlencode($key) . '&rsz=large&start=1';
} else {
$googleapis = '[url=http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=']http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q='[/url] . 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, '[url=http://google.com.vn/');]http://google.com.vn/');[/url]
$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[] = '
' . $search . ''; // Nếu Rewrite url thì sửa cái này
}
return implode(', ', $tag);
}
return 'Có lỗi xảy ra!';
}[/code]
Cách sử dụng:
- Chèn vào forum/index.php (chỗ nào muốn hiển thị): [color=#f82e00][b]functions::get_googleapis()[/b][/color]
[b]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 đó![/b]
[b]Ví dụ:[/b]
- Mặc định:
[code]echo '
' . functions::get_googleapis() . '
';[/code]
- Tùy biến:
[code]$key = $res['text'];
echo '
' . functions::get_googleapis($key) . '
';[/code]
_yeu_(06.08.2013/12:07)
Vừa ol đã thấy :)
hotboy(06.08.2013/12:09)
Top rất hiếm...
c_m_punked(06.08.2013/12:11)
lâu lắm ông ad mới lập top
ND_ViP_VL(06.08.2013/12:17)
like cho daik :D lâu lâu mới có top wapmaster của daik.
Gru(06.08.2013/12:22)
Ad có kái host nào up data voi code sẵn hoq cho Gru ik :13:
_yeu_(06.08.2013/12:45)
Ko ai quan tâm
kothemyeuz(06.08.2013/12:52)
Lỗi rùi admin ơi em add mod vào die
kothemyeuz(06.08.2013/12:54)
[quote=[b]admin[/b] ([time]06.08.2013 12:06[/time])]Chèn vào incfiles/classes/functions.php
// Giacmovn.com
public static function get_googleapis($key = '')
{
global $textl, $set;
$body = '';
if (!empty($key)) {
[/quote]admin xem lại em mod ko được!!! cái trên lỗi là phải thay cái gì
admin(06.08.2013/12:59)
[quote=[b]kothemyeuz[/b] ([time]06.08.2013 12:54[/time])]admin xem lại em mod ko được!!! cái trên lỗi là phải thay cái gì[/quote]Chắc chắn không lỗi. Chèn vào đâu? Cái func ấy phải nằm trong [b]class functions[/b]
Mở functions.php ra chèn ngay dưới chỗ này:
[r]class functions extends core
{[/r]
Keyover(06.08.2013/13:02)
like thôi. Hiếm khi pro online
kothemyeuz(06.08.2013/13:02)
[quote=[b]admin[/b] ([time]06.08.2013 12:59[/time])]Chắc chắn không lỗi. Chèn vào đâu? Cái func ấy phải nằm trong class functions
Mở functions.php ra chèn ngay dưới chỗ này:
class functions extends core
{[/quote]đã add mod được nhưng forum/index.php lại ko hiển thị
Keyover(06.08.2013/13:05)
à. Admin làm cái tool auto đóng dấu logo gmvn vào ảnh [ảnh trong zip] để em làm truyện tranh cho gmvn
kothemyeuz(06.08.2013/13:05)
[quote=[b]admin[/b] ([time]06.08.2013 12:59[/time])]Chắc chắn không lỗi. Chèn vào đâu? Cái func ấy phải nằm trong class functions
Mở functions.php ra chèn ngay dưới chỗ này:
class functions extends core
{[/quote]ko báo lỗi nữa!! Nhưng nó ko hiển thị
admin(06.08.2013/13:08)
[quote=[b]kothemyeuz[/b] ([time]06.08.2013 13:02[/time])]đã add mod được nhưng forum/index.php lại ko hiển thị[/quote]Ặc! mở forum/index.php tìm
[b]case 'm':[/b]
Ở ngay trên [b]case 'm':[/b] sẽ nhìn thấy [b]break;[/b]
Chèn ngay trên [b]break;[/b] đoạn code này:
[php]echo '
' . functions::get_googleapis() . '
';[/php]
Sẽ nhìn thấy nó hiển thị cuỗi trang