help me to get link title

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    help me to get link title

    this is my php code please anyone add here when some one post a link automatically get link title like Facebook

    PHP Code:
    <?
    function img_preg($arr)
    {
    return '<img src="http://'.$_SERVER['HTTP_HOST'].'/go.php?go='.base64_encode(html_entity_decode($arr[1])).'" alt="img" />';
    }
    function links_preg1($arr)
    {
    global $set;
    if (ereg('^http://'.$_SERVER['HTTP_HOST'],$arr[1]) || !ereg('://',$arr[1]))
    return '<a href="'.$arr[1].'">'.$arr[2].'</a>';
    else
    return '<a'.($set['web']?' target="_blank"':null).' href="http://'.$_SERVER['HTTP_HOST'].'/go.php?go='.base64_encode(html_entity_decode($arr[1])).'">'.$arr[2].'</a>';
    }
    function links_preg2($arr)
    {
    global $set;
    if (ereg('^http://'.$_SERVER['HTTP_HOST'],$arr[2]))
    return $arr[1].'<a href="'.$arr[2].'">'.$arr[2].'</a>'.$arr[4];
    else
    return $arr[1].'<a'.($set['web']?' target="_blank"':null).' href="http://'.$_SERVER['HTTP_HOST'].'/go.php?go='.base64_encode(html_entity_decode($arr[2])).'">'.$arr[2].'</a>'.$arr[4];
    }
    function links($msg)
    {
    global $set;
    if ($set['bb_img'])$msg=preg_replace_callback('/\[img\](.+)\[\/img\]/isU', 'img_preg', $msg);
    if ($set['bb_url'])$msg=preg_replace_callback('/\[url=(.+)\](.+)\[\/url\]/isU', 'links_preg1', $msg); 
    if ($set['bb_http'])$msg=preg_replace_callback('~(^|\s)([a-z]+://([^ \r\n\t`\'"]+))(\s|$)~iu', 'links_preg2', $msg);
    return $msg;
    }

    ?>
    Last edited by arnage; 02.07.12, 13:23.

    #2
    use the search function you will find your answer

    Comment


      #3
      PHP Code:
      $site_url $_REQUEST['site_url'];
          if(
      filter_var($site_urlFILTER_VALIDATE_URL))
          {
              
      $html file_get_contents($site_url);
              if(!empty(
      $html))
              {
                  
      //parsing begins here:
                  
      $doc = new DOMDocument();
                  @
      $doc->loadHTML($html);
                  
      $nodes $doc->getElementsByTagName('title');
                  
                  
      //get and display what you need:
                  
      $tags['title'] = $nodes->item(0)->nodeValue;
                  if(empty(
      $tags['title']))
                  {
                      
      $parse parse_url($site_url);
                      
      $tags['title'] = $parse['host'];
                  }
                  
      $metas $doc->getElementsByTagName('meta');
                  
                  for (
      $i 0$i $metas->length$i++)
                  {
                      
      $meta $metas->item($i);
                      if(
      $meta->getAttribute('name') == 'description')
                              
      $tags['description'] = $meta->getAttribute('content');
                      if(
      $meta->getAttribute('name') == 'keywords')
                              
      $tags['keywords'] = $meta->getAttribute('content');
                  }
              }
          }

      print_r($tags); 
      Advertise your mobile site for FREE with AdTwirl

      Comment

      Working...
      X