Created
July 10, 2014 09:06
-
-
Save jakeydevs/8de758a40b695a220b18 to your computer and use it in GitHub Desktop.
Basic email detection from images
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
RewriteRule ^images/email/([a-zA-Z0-9_-]*)/images.gif$ email_detect.php?string=$1 [L,NC,QSA] |
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 | |
//-- Called when a server looks at our email | |
//-- We'll find out who looked at our email now | |
//-- Woah - do some filtering on this! | |
$string = $_GET['string']; | |
//-- Who's email was this? | |
$user = DB::table('email_stuff')->where('string', $string)->first(); | |
//-- Do some sanity checks here such as making sure row exists etc | |
//-- This is a great place to do some $_SERVER magic, such as finding the referrer etc | |
//-- Store hit | |
DB::table('email_view')->insert(array('email_address' => $email, 'time_viewed' => time())); | |
//-- Serve the image | |
//-- Here we are serving a 1 by 1 gif image | |
header( 'Content-type: image/gif' ); | |
echo chr(71).chr(73).chr(70).chr(56).chr(57).chr(97). | |
chr(1).chr(0).chr(1).chr(0).chr(128).chr(0). | |
chr(0).chr(0).chr(0).chr(0).chr(0).chr(0).chr(0). | |
chr(33).chr(249).chr(4).chr(1).chr(0).chr(0). | |
chr(0).chr(0).chr(44).chr(0).chr(0).chr(0).chr(0). | |
chr(1).chr(0).chr(1).chr(0).chr(0).chr(2).chr(2). | |
chr(68).chr(1).chr(0).chr(59); |
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 | |
//-- Really simple email detection code | |
//-- You'll need a connection to a DB, so we can store emails -> random images | |
$emails = array('[email protected]', '[email protected]'); //etc | |
foreach($emails AS $email) | |
{ | |
//-- Generate random string (Your guna want a better function here, one that checks for duplicates etc) | |
$random_string = time() . "_" . "icanhaz"; | |
//-- Create Image URL | |
$my_image_url = "http://mywebsite.com/images/" . $random_string . "/image.gif"; | |
//-- Store this | |
DB::table('email_stuff')->insert(array('email_address' => $email, 'string' => $random_string)); | |
//-- Send mail, with the Create Image URL in the HTML body | |
Mail::send(...) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment