3 require_once('library/HTML5/Parser.php');
6 function parse_url_content(&$a) {
8 logger('parse_url: ' . $_GET['url']);
10 $url = trim(hex2bin($_GET['url']));
12 logger('parse_url: ' . $url);
16 $template = "<a href=\"%s\" >%s</a>\n%s";
19 $arr = array('url' => $url, 'text' => '');
21 call_hooks('parse_link', $arr);
23 if(strlen($arr['text'])) {
37 echo sprintf($template,$url,$url,'');
41 $dom = @HTML5_Parser::parse($s);
46 $items = $dom->getElementsByTagName('title');
49 foreach($items as $item) {
50 $title = trim($item->textContent);
56 $divs = $dom->getElementsByTagName('div');
58 foreach($divs as $div) {
59 $class = $div->getAttribute('class');
60 if($class && stristr($class,'article')) {
61 $items = $div->getElementsByTagName('p');
63 foreach($items as $item) {
64 $text = $item->textContent;
65 $text = strip_tags($text);
66 if(strlen($text) < 100)
68 $text = substr($text,0,250) . '...' ;
77 $items = $dom->getElementsByTagName('p');
79 foreach($items as $item) {
80 $text = $item->textContent;
81 $text = strip_tags($text);
82 if(strlen($text) < 100)
84 $text = substr($text,0,250) . '...' ;
91 $text = '<br />' . $text;
94 echo sprintf($template,$url,$title,$text);