From d5bd89e1d64d00f0d10926c470bc850646f4a969 Mon Sep 17 00:00:00 2001 From: Horus3 Date: Sun, 16 Mar 2014 23:39:07 +0100 Subject: Added func change_password --- www/functions/func_password.php | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 www/functions/func_password.php (limited to 'www/functions/func_password.php') diff --git a/www/functions/func_password.php b/www/functions/func_password.php new file mode 100644 index 0000000..9d2d08a --- /dev/null +++ b/www/functions/func_password.php @@ -0,0 +1,30 @@ +query("SELECT id FROM user WHERE email='" . SQLite3::escapeString($_POST['email']) . "';"); + $username_ar = $username_db->fetchArray(SQLITE3_NUM); + $username = $username_ar[0]; + } + + if($first_password != $second_password || !isset($first_password) || empty($first_password) || $first_password == ""){ + return PASSWORD_PASSWORD; + } + + $pepper = file_get_contents("../database/pepper.txt"); + $password = $first_password . $pepper; + + $hash_password = password_hash($password, PASSWORD_DEFAULT); + + if($db->exec(" + BEGIN TRANSACTION; + UPDATE user SET password='" . $hash_password . "' WHERE id=" . $username . "; + COMMIT; + ")){ + return PASSWORD_SUCCESS; + } else { + return PASSWORD_DATABASE; + } +} -- cgit v1.2.3