|
1 | | -<h3>Featured at:</h3> |
2 | 1 | <txp:php> |
3 | 2 | if (!gps('txpreview')) { |
4 | | - global $prefs; |
5 | | - |
6 | | - require_once __DIR__ .'/../../vendor/autoload.php'; |
7 | | - |
8 | | - // Do not let them slow us down. |
9 | 3 | $opts = array('http' => array('timeout' => 1.6)); |
10 | | - $url = 'https://website.informer.com/w/textpatternwidget.php'; |
11 | | - |
| 4 | + $url = 'https://website.informer.com/widget/textpattern.com-2'; |
12 | 5 | $context = stream_context_create($opts); |
13 | 6 | $widget = file_get_contents($url, false, $context); |
14 | 7 |
|
15 | | - if (($widget)) { |
16 | | - // Don't let them inject unwanted HTML. |
17 | | - $config = HTMLPurifier_Config::createDefault(); |
18 | | - $config->set('Cache.SerializerPath', $prefs['tempdir']); |
19 | | - $config->set('HTML.Allowed', 'div[class|id], a[class|href]'); |
20 | | - $config->set('Attr.EnableID', true); |
21 | | - $config->set('Attr.IDPrefix', 'informer-'); |
22 | | - $config->set('URI.AllowedSchemes', array('http', 'https')); |
23 | | - $purifier = new HTMLPurifier($config); |
24 | | - |
25 | | - $widget = $purifier->purify($widget); |
26 | | - |
27 | | - // Wrangle the output to simplify the returned markup. |
28 | | - $doc = new \DOMDocument(); |
29 | | - $doc->loadHTML(mb_convert_encoding($widget, 'HTML-ENTITIES', 'UTF-8')); |
30 | | - $finder = new \DomXPath($doc); |
31 | | - |
32 | | - // Extract the header string. |
33 | | - $classname = "b-webi-header"; |
34 | | - $heading = $finder->query("//*[contains(concat(' ', normalize-space(@class), ' '), ' $classname ')]"); |
35 | | - $headStr = trim($heading->item(0)->nodeValue); |
36 | | - |
37 | | - // Extract all the anchors and their attributes. |
38 | | - $classname = "b-webi-link"; |
39 | | - $links = $finder->query("//*[contains(concat(' ', normalize-space(@class), ' '), ' $classname ')]"); |
40 | | - |
41 | | - $linkInfo = array(); |
42 | | - |
43 | | - for ($idx = 0; $idx < $links->length; $idx++) { |
44 | | - $me = $links->item($idx); |
45 | | - $linkInfo[$idx]['href'] = $me->getAttribute('href'); |
46 | | - $linkInfo[$idx]['content'] = trim($me->nodeValue); |
47 | | - } |
48 | | - |
49 | | - // Create the simpler HTML. |
50 | | - $out = <<<EOHTML |
51 | | -<ul class="list--no-bullets ellipsis"> |
52 | | - |
53 | | -EOHTML; |
54 | | - |
55 | | - foreach ($linkInfo as $row) { |
56 | | - $out .= '<li><a rel="external" referrerpolicy="origin" href="'.$row['href'].'">'.$row['content'].'</a></li>'.n; |
57 | | - } |
58 | | - |
59 | | - // Hard-code the footer, since it's easier than trying to get innerHTML from DOMDocument. |
60 | | - $out .= <<<EOHTML |
61 | | -</ul> |
62 | | -<small>Powered by <a rel="external" href="https://website.informer.com/">website.informer.com</a></small> |
63 | | -EOHTML; |
64 | | - |
65 | | - echo n,comment(date('c')); |
66 | | - echo $out; |
| 8 | + if ($widget) { |
| 9 | + echo $widget; |
67 | 10 | } |
68 | 11 | } |
69 | 12 | </txp:php> |
0 commit comments