Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- $baseUrl = 'https://kyleavalani.com/red/';
- $toOutput = '';
- if (isset($_GET['sessionCookie'])) {
- $_SESSION['sessionCookie'] = $_GET['sessionCookie'];
- }
- else if (!isset($_SESSION['sessionCookie'])) {
- $_SESSION['sessionCookie'] = '';
- $toOutput = '<b>WARNING:</b> No sessionCookie has been set.<br>';
- }
- if (!isset($_GET['url']) || $_GET['url'] == '') {
- echo 'No URL.';
- }
- else {
- //Get base url
- $index = 0;
- if (substr($_GET['url'], 0, 4) == 'http') {
- $index = 2;
- }
- $basename = explode('/', $_GET['url'])[$index];
- //Set cookies
- $opts = array(
- 'http'=>array(
- 'method'=>"GET",
- 'header'=>"Accept-language: en\r\n" .
- "Cookie: reddit_session=".$_SESSION['sessionCookie']
- )
- );
- $context = stream_context_create($opts);
- //Make request
- $page = file_get_contents($_GET['url'], false, $context);
- if ($basename == 'i.imgur.com') {
- // Output just the image
- header("Content-type: image/png");
- }
- else {
- //We only want to alter the <Body>
- $pageArr = explode('</head>', $page);
- //Set all links to my page
- $pageArr[1] = str_replace('href="', 'href="'.$baseUrl.'?url=', $pageArr[1]);
- if ($basename == 'reddit.com') {
- //Replace /r/ with my_page/r/
- $pageArr[1] = str_replace('?url=/r/', '?url=https://reddit.com/r/', $pageArr[1]);
- }
- $page = implode($pageArr);
- }
- echo $toOutput.$page;
- }
Add Comment
Please, Sign In to add comment