logEvent("validate-create-user", is_null($code), $code, $email, $inviteCode); return $code ? $securityMsgs[$code] : null; } function restRequestSecurity($action, $email, $password, $confirm, $inviteCode) { $securityMsgs = array("bad-invite-code" => "Invite code is missing, expired, or invalid.", "bad-credentials" => "The email address or password you entered is incorrect.", "invalid-email" => "Please enter a valid email address.", "mismatch" => "Passwords do not match.", "user-exists" => "That email address is already in use.", "create-fail" => "Cannot create user."); $email = strtolower(trim($email)); $accountsDb = readAccountsDb(); $user = array_key_exists($email, $accountsDb->users) ? $accountsDb->users->{$email} : null; if ($action === "login") { $msg = verifyPassword($user, $password) ? loginUser($email) : $securityMsgs["bad-credentials"]; } elseif ($action === "create") { $msg = validateCreateUser($accountsDb, $email, $password, $confirm, $inviteCode, $securityMsgs); } else { $msg = "Invalid request."; } $success = is_null($msg); logEvent("security-request", $action, $success, $email, $msg); return array("authenticated" => $success, "email" => $email, "message" => $success ? "Success." : $msg); } $loggedIn = isset($_SESSION["user"]) && time() < $_SESSION["active"] + $sessionTimout && userEnabled(); if ($loggedIn) { $_SESSION["active"] = time(); } if ($loggedIn && $redirectAuth) { redirectToPage($redirectAuth); } elseif (!$loggedIn && !$noAuth) { redirectToPage("sign-in"); } initializeFile($loginMsgFile, $loginMsg);
function setupCustomCss($dataFolder) { $defaultCss = array("/* Paradise PHP Photo Gallery */", "/* Edit this CSS file to customize the look of the gallery. */", "/* Put custom images in: gallery/~data~/graphics */", "", "body { color: whitesmoke; background-color: dimgray; }", "body >footer { background-color: gray; border-color: black; }", ".gallery-images .image img { border-color: black; }"); $filename = "{$dataFolder}/custom-style.css"; initializeFile($filename, implode(PHP_EOL, $defaultCss)); }