• 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.

Admin

Well-Known Member
Staff member
Administrator
-Nhiệm vụ tự động tìm tất cả link trong biến vào.
-Rút gọn tất cả link, ngoại trừ link images và link trong wap.
-Kiểm tra đã rút gọn thành công chưa?
+Nếu chưa giữ nguyên link gốc
+Nếu rút gọn thành công, thay thế link gốc bằng link rút gọn.

PHP:
<?php
/*
-----------------------------------------------------------------
Create ****** Short URLs Using PHP: API Version 3
-----------------------------------------------------------------
*/
public static function fixlink($text) {
 
/* returns the shortened url */
function get_short_url($url) {
    $homeurl = strtolower($_SERVER['HTTP_HOST']);
    $tempurl = strtolower($url);
    //Kiem tra link co phai hinh anh
    $img = '/[.](jpg|png|gif|jpeg|bmp)$/i';
        if (preg_match($img, $url)) { return ' [img]' . $url . '[/img]'; }
    // Kiem tra xem link hop le khong
        if (strpos($tempurl, $homeurl) || strpos($tempurl, "******") || mb_strlen($url) < 20) { return ' ' . $url; }
    $login = '***';
    $appkey = '***';
    $format = 'txt';
    $connectURL = 'http://api.******/v3/shorten?login='.$login.'&apiKey='.$appkey.'&uri='.urlencode($url).'&format='.$format;
    return get_result($connectURL, $url, $d);
}
 
/* returns a result form url */
function get_result($connectURL, $url, $d) {
    $ch = curl_init();
    $timeout = 5;
    curl_setopt($ch,CURLOPT_URL,$connectURL);
    curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
    curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
    $data = trim(curl_exec($ch));
    curl_close($ch);
    //Kiem tra rut gon thanh cong hay khong?
        if (preg_match("/(^https?\:\/\/)|(^www\.)/i", $data)) { return ' ' . $data; } 
        else { return ' ' . $url; }
}
//Find url in text
    $url_match = $url_replace = array();
    $url_match[] = '#(^|[\n\t (>.])([a-z][a-z\d+]*:/{2}(?:(?:[a-z0-9\-._~!$&\'(*+,;=:@|]+|%[\dA-F]{2})+|[0-9.]+|\[[a-z0-9.]+:[a-z0-9.]+:[a-z0-9.:]+\])(?::\d*)?(?:/(?:[a-z0-9\-._~!$&\'(*+,;=:@|]+|%[\dA-F]{2})*)*(?:\?(?:[a-z0-9\-._~!$&\'(*+,;=:@/?|]+|%[\dA-F]{2})*)?(?:\#(?:[a-z0-9\-._~!$&\'(*+,;=:@/?|]+|%[\dA-F]{2})*)?)#ieu';
    $url_replace[] = "get_short_url('$2')";
    return preg_replace($url_match, $url_replace, $text);
}
?>
<?php
$login = '***';
$appkey = '***';?>

*** là tài khoản ****** nhé
 
Dán vào đâu đây admin....
 
rút gọn link làm gì cho mệt :D
 

Facebook Comments

Similar threads

New posts New threads New resources

Back
Top