Created
June 28, 2015 03:53
-
-
Save santosh/3f9743c4c77e3bf0d997 to your computer and use it in GitHub Desktop.
Collect useragent and ipaddress data from friends. I created this note redirect script to do the same. They were pointed to this script saying that they will be shown a note they must read.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
@scriptName: noteredirect.php | |
@author: Santosh Kumar | |
@authorURL: http://sntsh.com | |
*/ | |
// set the content type which is read by browser | |
header("Content-type: text/plain"); | |
// must set the timezone so that you don't confuse about time later | |
date_default_timezone_set('Asia/Kolkata'); | |
// define IP address and user agent | |
$ip = $_SERVER["REMOTE_ADDR"]; | |
$ua = $_SERVER["HTTP_USER_AGENT"]; | |
// define timestamp | |
$fulltime = strftime('%c'); | |
// write them at once | |
$format = $ip . " __on__ " . $fulltime . " __with__ " . $ua . "\n\n"; | |
// write them to file, NOTE: They must already have been created | |
$fp = fopen('noteredirect.txt', 'a'); | |
fwrite($fp, $format); | |
fclose($fp); | |
// redirect to the real note.. or wherever | |
header("Location: https://twitter.com/sntshk"); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment