diff options
author | Case Duckworth | 2022-12-13 12:38:43 -0600 |
---|---|---|
committer | Case Duckworth | 2022-12-13 12:38:43 -0600 |
commit | 89726167483fb68b16955d587cf7736f3b404921 (patch) | |
tree | 647c6c9cda5b62106701444d9c981ea1ab9e52d3 /superstack.php | |
download | superstack-89726167483fb68b16955d587cf7736f3b404921.tar.gz superstack-89726167483fb68b16955d587cf7736f3b404921.zip |
Initial commit
Diffstat (limited to 'superstack.php')
-rw-r--r-- | superstack.php | 48 |
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); | ||
4 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | ||
5 | $page = curl_exec($ch); | ||
6 | if (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>'; | ||
24 | echo '<p><em>' . $site . '</em>'; | ||
25 | echo ' <a href="' . $site . '">[orig]</a></p>'; | ||
26 | |||
27 | $content = $doc->getElementsBytagName('div'); | ||
28 | |||
29 | foreach ($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> | ||