function resetPassword($email, $token, $newpass) { global $SITE_SECRET; $token = str_replace(array('-','_'), array('.','/'), $token); $check = crypt($email . $SITE_SECRET, $token); if ($check != $token) { return false; } $newpass = db_escape($newpass); $newpass = crypt($newpass); db_query_set("update user set password = '******' where email = '$email'"); $rslt = firstRow(db_query_get("select n.id from note n, user u where u.id = n.userid and u.email = '$email'")); setNoteID($rslt['id']); return true; }
require("_functions.php"); $id = $_GET['id']; $version = $_GET['version']; $content = file_get_contents('php://input'); $success = false; if (!$id) { $rslt = insertNote($content); $id = $rslt['id']; $version = $rslt['version']; $success = true; } else { $conflict = updateNote($id, $version, $content); if ($conflict) { $version = $conflict; } else { $version += 1; } } setNoteID($id); if (!$conflict) { print "OK\n$id\n$version"; } else { print "CONFLICT\n$id\n$version"; } ?>