Skip to content

Instantly share code, notes, and snippets.

@cxdy
Created September 14, 2014 01:58
Show Gist options
  • Save cxdy/95fe0d700d50df3281de to your computer and use it in GitHub Desktop.
Save cxdy/95fe0d700d50df3281de to your computer and use it in GitHub Desktop.
md5 IP example
<?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