Created
September 14, 2014 01:58
-
-
Save cxdy/95fe0d700d50df3281de to your computer and use it in GitHub Desktop.
md5 IP example
This file contains 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 | |
$note_name = 'note.txt'; | |
$uniqueNotePerIP = true; | |
if($uniqueNotePerIP){ | |
$note_name = 'notes/'.md5($_SERVER['REMOTE_ADDR']).'.txt'; | |
} | |
if(isset($_SERVER['HTTP_X_REQUESTED_WITH'])){ | |
// This is an AJAX request | |
if(isset($_POST['note'])){ | |
// Write the file to disk | |
file_put_contents($note_name, $_POST['note']); | |
echo '{"saved":1}'; | |
} | |
exit; | |
} | |
$note_content = ' | |
Welcome to your first notepad. | |
Type something here.'; | |
if( file_exists($note_name) ){ | |
$note_content = htmlspecialchars( file_get_contents($note_name) ); | |
} | |
$url = 'http://localhost/notepad/view.php?f='.md5($_SERVER['REMOTE_ADDR']); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment