3 require_once('library/HTML5/Parser.php');
5 function parse_url_content(&$a) {
7 logger('parse_url: ' . $_GET['url']);
9 $url = trim(hex2bin($_GET['url']));
11 logger('parse_url: ' . $url);
15 $template = "<a href=\"%s\" >%s</a>\n%s";
18 $arr = array('url' => $url, 'text' => '');
20 call_hooks('parse_link', $arr);
22 if(strlen($arr['text'])) {
36 echo sprintf($template,$url,$url,'');
40 $dom = @HTML5_Parser::parse($s);
45 $items = $dom->getElementsByTagName('title');
48 foreach($items as $item) {
49 $title = trim($item->textContent);
55 $divs = $dom->getElementsByTagName('div');
57 foreach($divs as $div) {
58 $class = $div->getAttribute('class');
59 if($class && stristr($class,'article')) {
60 $items = $div->getElementsByTagName('p');
62 foreach($items as $item) {
63 if($item->getElementsByTagName('script'))
65 $text = $item->textContent;
66 $text = strip_tags($text);
67 if(strlen($text) < 100)
69 $text = substr($text,0,250) . '...' ;
78 $items = $dom->getElementsByTagName('p');
80 foreach($items as $item) {
81 if($item->getElementsByTagName('script'))
83 $text = $item->textContent;
84 $text = strip_tags($text);
85 if(strlen($text) < 100)
87 $text = substr($text,0,250) . '...' ;
94 $text = '<br />' . $text;
97 echo sprintf($template,$url,$title,$text);