Advertisement
Sorceress

log and redirect

Jun 24th, 2018
425
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1.  
  2.  
  3. <?php
  4.  
  5. //get IP
  6. if (getenv("HTTP_CLIENT_IP")) $ip = getenv("HTTP_CLIENT_IP");
  7. else if(getenv("HTTP_X_FORWARDED_FOR")) $ip = getenv("HTTP_X_FORWARDED_FOR");
  8. else if(getenv("REMOTE_ADDR")) $ip = getenv("REMOTE_ADDR");
  9. else $ip = "UNKNOWN";
  10.  
  11. // log download and redirect to file
  12. if (isset($_GET['dl']))
  13. {
  14. $filename = $_GET['dl'];
  15. $ff = fopen('down_log.txt', 'a');
  16. $today = date("Y-m-d H:i");
  17. fwrite($ff,"$today - $ip - $filename<br>");
  18. fclose($ff);
  19. header("Location: https://mydomain.tld/$filename");
  20. die;
  21. }
  22.  
  23. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement