| 623 | | preg_match_all('/(\S+?)=(["\']?)(.*?)\2/', $match[1], $attribs, PREG_SET_ORDER); |
| 624 | | $namespace = array('rdf' => 'rdf', 'dc' => 'dc', 'trackback' => 'trackback'); |
| 625 | | |
| 626 | | //print_r($attribs); |
| 627 | | |
| 628 | | foreach ($attribs as $attrib) { |
| 629 | | if (substr(strtolower($attrib[1]), 0, 6) == 'xmlns:') { |
| 630 | | $name = substr($attrib[1], 6); |
| 631 | | |
| 632 | | switch (trim($attrib[3])) { |
| 633 | | case 'http://www.w3.org/1999/02/22-rdf-syntax-ns#': |
| 634 | | $namespace['rdf'] = $name; |
| | 623 | if (class_exists('DOMDocument')) { |
| | 624 | $doc = DOMDocument::loadXML($match[0]); |
| | 625 | if (!$doc) { |
| | 626 | return false; |
| | 627 | } |
| | 628 | $desc = $doc->getElementsByTagNameNS('http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'Description')->item(0); |
| | 629 | if ($desc === null) { |
| | 630 | return false; |
| | 631 | } |
| | 632 | return array( |
| | 633 | 'title' => $desc->getAttributeNS('http://purl.org/dc/elements/1.1/', 'title'), |
| | 634 | 'url' => $desc->getAttributeNS('http://purl.org/dc/elements/1.1/', 'identifier'), |
| | 635 | 'trackbackURL' => $desc->getAttributeNS('http://madskills.com/public/xml/rss/module/trackback/', 'ping') |
| | 636 | ); |
| | 637 | } else { |
| | 638 | preg_match_all('/(\S+?)=(["\']?)(.*?)\2/', $match[1], $attribs, PREG_SET_ORDER); |
| | 639 | $namespace = array('rdf' => 'rdf', 'dc' => 'dc', 'trackback' => 'trackback'); |
| | 640 | |
| | 641 | print_r($attribs); |
| | 642 | |
| | 643 | foreach ($attribs as $attrib) { |
| | 644 | if (substr(strtolower($attrib[1]), 0, 6) == 'xmlns:') { |
| | 645 | $name = substr($attrib[1], 6); |
| | 646 | |
| | 647 | switch (trim($attrib[3])) { |
| | 648 | case 'http://www.w3.org/1999/02/22-rdf-syntax-ns#': |
| | 649 | $namespace['rdf'] = $name; |
| | 650 | break; |
| | 651 | case 'http://purl.org/dc/elements/1.1/': |
| | 652 | $namespace['dc'] = $name; |
| | 653 | break; |
| | 654 | case 'http://madskills.com/public/xml/rss/module/trackback/': |
| | 655 | $namespace['trackback'] = $name; |
| | 656 | break; |
| | 657 | } |
| | 658 | } |
| | 659 | } |
| | 660 | |
| | 661 | preg_match_all('/(\S+?)=(["\']?)(.*?)\2/', $match[2], $attribs, PREG_SET_ORDER); |
| | 662 | $result = array('title' => null, 'url' => null, 'trackbackURL' => null); |
| | 663 | |
| | 664 | foreach ($attribs as $attrib) { |
| | 665 | switch ($attrib[1]) { |
| | 666 | case $namespace['dc'].':title': |
| | 667 | $result['title'] = $attrib[3]; |
| 644 | | } |
| 645 | | |
| 646 | | preg_match_all('/(\S+?)=(["\']?)(.*?)\2/', $match[2], $attribs, PREG_SET_ORDER); |
| 647 | | $result = array('title' => null, 'url' => null, 'trackbackURL' => null); |
| 648 | | |
| 649 | | foreach ($attribs as $attrib) { |
| 650 | | switch ($attrib[1]) { |
| 651 | | case $namespace['dc'].':title': |
| 652 | | $result['title'] = $attrib[3]; |
| 653 | | break; |
| 654 | | case $namespace['dc'].':identifier': |
| 655 | | $result['url'] = $attrib[3]; |
| 656 | | break; |
| 657 | | case $namespace['trackback'].':ping': |
| 658 | | $result['trackbackURL'] = $attrib[3]; |
| 659 | | } |
| 660 | | } |
| 661 | | |
| 662 | | return (isset($result['trackbackURL'])) ? $result : false; |
| | 676 | |
| | 677 | return (isset($result['trackbackURL'])) ? $result : false; |
| | 678 | } |