public function save() { GUMP::add_validator("unique", function ($field, $input, $param = NULL) { $checkExistingUser = R::findOne('user', 'user=?', array($input)); if ($checkExistingUser == NULL) { return FALSE; } else { return TRUE; } }); GUMP::add_validator("strong", function ($field, $input, $param = NULL) { return checkPasswordStrength($input); }); $rules = array('reseller_username' => 'required|alpha_numeric|max_len,10|min_len,6|unique', 'reseller_password' => 'required|max_len,10|min_len,7|strong'); $filters = array('reseller_username' => 'trim|sanitize_string', 'reseller_password' => 'trim|sanitize_string|md5'); $app = Slim::getInstance(); $post = $app->request()->post(); // $app - Slim main app instance $postValues = $gump->filter($post, $filters); $validated = $gump->validate($gump->filter($postValues, $filters), $rules); if ($validated === TRUE) { $createUser = R::dispense('user'); $createUser->user = $postValues['reseller_username']; $createUser->user = $postValues['reseller_password']; } else { $this->setError($gump->get_readable_errors(true)); } if ($this->getError() == "") { $this->fails = FALSE; } else { $this->fails = TRUE; } }
$contact_email = $results[0]['email']; $email_info = base64_encode($username_to_contact); $headers = "From: test@mydomain.com"; $msg = "Hello " . $username_to_contact . "\r\n" . "You can now reset your password via this link :" . "\r\n" . "http://localhost:8080/camagru/index.php?resetpass="******"\r\n" . "\r\n" . "Thank you," . "\r\n" . "The Camagru Team"; mail($contact_email, "Camagru : Reset your password", $msg, $headers); $confirm2 = true; } else { $errMsg .= 'User not found<br>'; } } } if (isset($_POST['submitNewPass'])) { if (strcmp($_POST['password'], $_POST['passwordConfirm']) != 0) { $errMsgPass = '******'t match please retype passwords'; } else { if (strcmp($_POST['password'], $_POST['passwordConfirm']) == 0 && checkPasswordStrength($_POST['password']) == false) { $errMsgPass .= 'Password must at least 8 characters long, with numbers, lowercase and uppercase letters and special chars'; } else { try { $temp_user = $_POST['check-username']; $newPass = hash('gost', $_POST['password']); $sql = $db->prepare("UPDATE `user` \n SET `user`.`password` = :newpassword \n WHERE `user`.`username` = :temp_username"); $sql->bindParam(':newpassword', $newPass); $sql->bindParam(':temp_username', $temp_user); $sql->execute(); setcookie('resetsuccess', true, time() + 1, "/"); header("Location: index.php"); } catch (PDOException $e) { $errMsgPass = $e; } }