Skip to content

Instantly share code, notes, and snippets.

@abdallah
Created November 26, 2013 09:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abdallah/7655537 to your computer and use it in GitHub Desktop.
Save abdallah/7655537 to your computer and use it in GitHub Desktop.
email tracking
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !\.(png|css)$
RewriteRule (.*) n.php [L,QSA]
<?php
require_once('recaptchalib.php');
if (array_key_exists('act', $_POST)){
$privatekey = "ThisIsMyPrivateRecaptchaKey-jos888Qo";
$resp = recaptcha_check_answer ($privatekey,
$_SERVER["REMOTE_ADDR"],
$_POST["recaptcha_challenge_field"],
$_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
// What happens when the CAPTCHA was entered incorrectly
die ("The reCAPTCHA wasn't entered correctly. Go back and try it again." .
"(reCAPTCHA said: " . $resp->error . ")");
} else {
echo "Here's the link to use: <a href='http://tracker.example.com/n.php?tag=".$_POST['tag']."&myemail=".$_POST['myemail']."&myip=".$_POST['myip']."'>copy link</a>";
exit;
}
}
$name = './ok.png';
$fp = fopen($name, 'rb');
header("Content-Type: image/png");
header("Content-Length: " . filesize($name));
fpassthru($fp);
if (array_key_exists('myemail', $_GET)) {
$recipient = $_GET['myemail'];
} else {
$recipient = 'default.address@example.com';
}
if ($_GET['myip']==$_SERVER['REMOTE_ADDR']) {
exit;
}
/* requesting info:
REMOTE_ADDR
QUERY_STRING
REQUEST_TIME
*/
$from = 'TrackerPic <tracker@example.com>';
$subject = 'Your mail was read';
$message = "Hi,
Your email with the following tracking code was read: ".
"\nTag: ".$_GET['tag'].
"\nRemote Address: ".$_SERVER['REMOTE_ADDR'].
"\nRequest Time: ".date('l, F j, Y g:i a', $_SERVER['REQUEST_TIME']).
"\ndebug: ".$_SERVER['QUERY_STRING'].
"
Sincerely,
TrackerPic";
mail($recipient, $subject, $message, "From: $from\r\n");
exit;
<form action="n.php" method="post">
Tag: <input type="text" name="tag" /><br />
My email: <input type="text" name="myemail" /><br />
<input type="hidden" name="myip" value="<?php echo $_SERVER['REMOTE_ADDR']; ?>" />
<?php
require_once('recaptchalib.php');
$publickey = "ThisIsMyPublicRecaptchaKey_38U2XXX_e";
echo recaptcha_get_html($publickey);
?>
<input type="submit" name="act" value="generate" />
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment