minicl55

Untitled

Sep 7th, 2015
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. <?php
  2. session_start();
  3. $baseUrl = 'http://kyleavalani.com/red/';
  4. if (isset($_GET['sessionCookie'])) {
  5. $_SESSION['sessionCookie'] = $_GET['sessionCookie'];
  6. }
  7. if (!isset($_GET['url']) || $_GET['url'] == '') {
  8. echo 'No URL.';
  9. }
  10. else {
  11. //Get base url
  12. $index = 0;
  13. if (substr($_GET['url'], 0, 4) == 'http') {
  14. $index = 2;
  15. }
  16. $basename = explode('/', $_GET['url'])[$index];
  17.  
  18. //Set cookies
  19. $opts = array(
  20. 'http'=>array(
  21. 'method'=>"GET",
  22. 'header'=>"Accept-language: en\r\n" .
  23. "Cookie: reddit_session=".$_SESSION['sessionCookie']
  24. )
  25. );
  26. $context = stream_context_create($opts);
  27. //Make request
  28. $page = file_get_contents($_GET['url'], false, $context);
  29. //We only want to alter the <Body>
  30. $pageArr = explode('</head>', $page);
  31. //Set all links to my page
  32. $pageArr[1] = str_replace('href="', 'href="'.$baseUrl.'?url=', $pageArr[1]);
  33. //Replace /r/ with my_page/r/
  34. if ($basename == 'reddit.com') {
  35. $pageArr[1] = str_replace('?url=/r/', '?url=https://reddit.com/r/', $pageArr[1]);
  36. }
  37. else if ($basename == 'imgur.com') {
  38.  
  39. }
  40. $page = implode($pageArr);
  41. echo $page;
  42. }
Add Comment
Please, Sign In to add comment