Exemplo n.º 1
0
 public static function outside_url_exists($str)
 {
     $str = strtolower($str);
     if (strstr($str, 'http')) {
         preg_match_all('/(?<!!!\\[\\]\\(|"|\'|\\)|>)(https?:\\/\\/[-a-zA-Z0-9@:;%_\\+.~#?\\&\\/\\/=!]+)(?!"|\'|\\)|>)/i', $str, $matches);
     } else {
         preg_match_all('/(www\\.[-a-zA-Z0-9@:;%_\\+\\.~#?&\\/\\/=]+)/i', $str, $matches);
     }
     if ($matches) {
         foreach ($matches as $key => $val) {
             if (!$val) {
                 continue;
             }
             if (!is_inside_url($val[0])) {
                 return true;
             }
         }
     }
     return false;
 }
Exemplo n.º 2
0
function parse_link_callback($matches)
{
    if (preg_match('/^(?!http).*/i', $matches[1])) {
        $url = 'http://' . $matches[1];
    } else {
        $url = $matches[1];
    }
    if (is_inside_url($url)) {
        return '<a href="' . $url . '">' . FORMAT::sub_url($matches[1], 50) . '</a>';
    } else {
        return '<a href="' . $url . '" rel="nofollow" target="_blank">' . FORMAT::sub_url($matches[1], 50) . '</a>';
    }
}