3 require_once('library/HTML5/Parser.php');
6 function parse_url_content(&$a) {
8 $url = trim($_GET['url']);
12 $template = "<a href=\"%s\" >%s</a>%s";
15 $arr = array('url' => $url, 'text' => '');
17 call_hooks('parse_link', $arr);
19 if(strlen($arr['text'])) {
33 echo sprintf($template,$url,$url,'');
37 $dom = @HTML5_Parser::parse($s);
42 $items = $dom->getElementsByTagName('title');
45 foreach($items as $item) {
46 $title = trim($item->textContent);
52 $divs = $dom->getElementsByTagName('div');
54 foreach($divs as $div) {
55 $class = $div->getAttribute('class');
56 if($class && stristr($class,'article')) {
57 $items = $div->getElementsByTagName('p');
59 foreach($items as $item) {
60 $text = $item->textContent;
61 $text = strip_tags($text);
62 if(strlen($text) < 100)
64 $text = substr($text,0,250) . '...' ;
73 $items = $dom->getElementsByTagName('p');
75 foreach($items as $item) {
76 $text = $item->textContent;
77 $text = strip_tags($text);
78 if(strlen($text) < 100)
80 $text = substr($text,0,250) . '...' ;
87 $text = '<br />' . $text;
90 echo sprintf($template,$url,$title,$text);