<?php session_start(); include_once '../../config/config.php'; include_once $serverPath . 'utils/db_get.php'; include_once $serverPath . "utils/redirectUtilities.php"; include_once $serverPath . "utils/postUtilities.php"; include_once $serverPath . "utils/generalUtilities.php"; $listOfRequiredPostParameters = ['password', 'username']; runOnPostWithAllRequiredParametersWithErrorReroute('attemptLogin', $listOfRequiredPostParameters); function attemptLogin() { $user = getUserByUsernameOrEmail($_POST['username']); $login_ok = $user != null && isValidLogin($user, $_POST['password']); if ($login_ok) { setUserSession($user); } routeOnSuccessfulLoginOrReturnError($login_ok); } function getUserByUsernameOrEmail($usernameOrEmail) { $possibleUser = findUserByUsernameOrEmail($usernameOrEmail); $listOfRequiredParameters = ['salt', 'password', 'username']; $user = hasAllRequiredParameters($possibleUser, $listOfRequiredParameters) ? $possibleUser : null; return $user; } function findUserByUsernameOrEmail($usernameOrEmail) { $table = getTableQuote("users"); $query = "SELECT * FROM {$table} WHERE (username='******' OR email='{$usernameOrEmail}') AND active=1;"; $queryReturn = runQuery($query);
<?php include_once '../../config/config.php'; include_once $serverPath . "admin/login/requireAdmin.php"; include_once $serverPath . 'utils/db_post.php'; include_once $serverPath . "utils/emailUtilities.php"; include_once $serverPath . "utils/postUtilities.php"; $listOfRequiredPostParameters = ["email"]; runOnPostWithAllRequiredParametersWithErrorReroute('sendInviteEmail', $listOfRequiredPostParameters); function sendInviteEmail() { $emailAddressToSendInviteTo = $_POST['email']; $emailSentSuccessfully = attemptSendInviteEmail($emailAddressToSendInviteTo); redirectToIndexShowErrorOnFailed($emailSentSuccessfully); } function attemptSendInviteEmail($emailAddressToSendInviteTo) { $subject = "You have been invited to create an account for: The Linger Martini Bar"; $headers = getEmailHeader($_SESSION['user']['email'], "html"); $emailContent = getInviteEmailContent($emailAddressToSendInviteTo); $emailSentSuccessfully = mail($emailAddressToSendInviteTo, $subject, $emailContent, $headers); return $emailSentSuccessfully; } function getInviteEmailContent($email) { $link = getInviteLink($email); $message = "\n\t\t\t<html>\n\t\t\t\t<body>\n\t\t\t\t<p>Follow this link and create your account:</p>\n\t\t\t\t<p><a href=" . $link . ">Click Here</a></p>\n\t\t\t\n\t\t\t</body>\n\t\t\t\n\t\t\t</html>\n\t\t\t"; return $message; } function getInviteLink($email) {