diff --git a/index.php b/index.php index bd0ed37..777938c 100644 --- a/index.php +++ b/index.php @@ -35,9 +35,23 @@ function savenote($title, $content) { global $dir; - file_put_contents($dir . '/' . $title, $content); + $path = $dir . '/' . $title; + $lastchanged = filemtime($path); + $previous = $_POST['lastchanged']; + if ( (int)$lastchanged > (int)$previous) + { + $tempcontent = file_get_contents($path); + if ($tempcontent != $content) + { + $temptitle = $title . '_' . $lastchanged; + file_put_contents($dir . '/' . $temptitle, $tempcontent); + array_unshift($_SESSION['index'], $dir . '/' . $temptitle); + echo '