about summary refs log tree commit diff stats
path: root/superstack.php
diff options
context:
space:
mode:
Diffstat (limited to 'superstack.php')
-rw-r--r--superstack.php48
1 files changed, 48 insertions, 0 deletions
diff --git a/superstack.php b/superstack.php new file mode 100644 index 0000000..84d0a04 --- /dev/null +++ b/superstack.php
@@ -0,0 +1,48 @@
1<?php
2$site = urldecode($_GET['page']);
3$ch = curl_init($site);
4curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
5$page = curl_exec($ch);
6if (curl_error($ch)) {
7 echo curl_error($ch);
8}
9$doc = new DOMDocument();
10$doc->loadHTML($page);
11$title = $doc->getElementsByTagName('title')[0]->textContent;
12?>
13 <!DOCTYPE html>
14 <html>
15 <head><title><?= $title ?> -- Superstack</title>
16 <style>
17 body{max-width:42em;padding:1em;margin:auto;font:18px/1.4 sans-serif;}
18</style>
19 <body>
20
21<?php
22
23 echo '<h1>' . $title . '</h1>';
24echo '<p><em>' . $site . '</em>';
25echo ' <a href="' . $site . '">[orig]</a></p>';
26
27$content = $doc->getElementsBytagName('div');
28
29foreach ($content as $el) {
30 if (stripos($el->getAttribute('class'), 'body') !== false) {
31
32 $ret = new DOMDocument();
33 $node = $ret->importNode($el, true);
34 $ret->appendChild($node);
35 echo $ret->saveHTML();
36
37 // echo $el->nodeValue;
38 // echo '<tr>';
39 // echo '<td>' . $el->getAttribute('class') . '</td>';
40 // echo '<td>' . stripos($el->getAttribute('class'), 'body') . '</td>';
41 // echo '</tr>';
42 }
43}
44
45?>
46
47 </body>
48 </html>