-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
87 lines (68 loc) · 2.72 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
//force utf8
header( 'Content-Type: text/html; charset=UTF-8' );
//set up some basic configurations
$base_url = "http://apartm.net/hackernews/";
$item_url = 'href="' . $base_url . 'index.php?';
$index_url = 'href="' . $base_url . 'index.php?fnid=';
$info_url = '
<tr>
<td>
<cite class="footnote">Mobile hack brought to you by <a href="http://apartm.net">Apartm.net</a>, available on <a href="https://github.com/apartmnet/Hacker-News">github</a>.</cite>
</td>
</tr>
</table></center></body>';
$url_to_get = "http://news.ycombinator.com/";
if(isset($_GET['fnid'])) {
$url_to_get .= "x?fnid=" . $_GET['fnid'];
} elseif(isset($_GET['id'])) {
$url_to_get .= "item?id=" . $_GET['id'];
}
// create a new cURL resource
$ch = curl_init();
// set URL and other appropriate options
curl_setopt($ch, CURLOPT_URL, $url_to_get);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// grab URL and pass it to the browser
$output = curl_exec($ch);
// close cURL resource, and free up system resources
curl_close($ch);
$inject = '<link rel="stylesheet" href="style.css" />';
$inject .= '<meta name="apple-mobile-web-app-capable" content="no" />';
$inject .= '<link rel="apple-touch-icon" href="icon.png" />';
$inject .= '<meta name="viewport" content="width=320; user-scalable=no">';
$inject .= '<script type="application/x-javascript">
if (navigator.userAgent.indexOf("iPhone") != -1)
{
addEventListener("load", function()
{
setTimeout(hideURLbar, 0);
}, false);
}
function hideURLbar()
{
window.scrollTo(0, 1);
}
</script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push([\'_setAccount\', \'UA-11497872-1\']);
_gaq.push([\'_trackPageview\']);
(function() {
var ga = document.createElement(\'script\'); ga.type = \'text/javascript\'; ga.async = true;
ga.src = (\'https:\' == document.location.protocol ? \'https://ssl\' : \'http://www\') + \'.google-analytics.com/ga.js\';
var s = document.getElementsByTagName(\'script\')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
';
$inject .= "</head>";
$output = str_replace("</head>", $inject, $output);
$output = str_replace('href="/', 'href="http://news.ycombinator.com/', $output);
$output = str_replace('href="reply', 'href="http://news.ycombinator.com/reply', $output);
$output = str_replace('href="vote', 'href="http://news.ycombinator.com/vote', $output);
$output = str_replace('href="user', 'href="http://news.ycombinator.com/user', $output);
$output = str_replace('href="item?', $item_url, $output);
$output = str_replace('href="http://news.ycombinator.com/x?fnid=', $index_url, $output);
$output = str_replace('</table></center></body>', $info_url, $output);
echo $output;