isComplete()) { $authFile = GALLERY_CONFIG_DIR . '/login.txt'; $templateData['authKey'] = GallerySetupUtilities::getAuthenticationKey(); if (empty($templateData['authKey'])) { $templateData['authKey'] = GallerySetupUtilities::generateAuthenticationKey(); GallerySetupUtilities::setAuthenticationKey($templateData['authKey']); } $templateData['authFile'] = sprintf( '%s%s%s', basename(GALLERY_CONFIG_DIR), DIRECTORY_SEPARATOR, basename($authFile)); $attempts = GallerySetupUtilities::getLoginAttempts(); if ($attempts === false || $attempts >= G2_SUPPORT_MAX_LOGIN_ATTEMPTS) { if (!file_exists($authFile)) { $templateData['authFileErrors']['missing'] = 1; } else if (!is_readable($authFile)) { $templateData['authFileErrors']['unreadable'] = 1; } else { $authKeyFromFile = trim(join('', file($authFile))); if ($authKeyFromFile == $templateData['authKey']) { GallerySetupUtilities::authenticateThisSession(); } else { $templateData['authFileErrors']['mismatch'] = 1; } } $templateData['renderType'] = 'loginTxtForm'; } else { if (isset($_POST['password_sent'])) { if (empty($_POST['password'])) { $templateData['error']['password'] = _('Error: missing password.'); } else if ($_POST['password'] != $gallery->getConfig('setup.password')) { $templateData['error']['password'] = _('Error: invalid password.'); GallerySetupUtilities::setLoginAttempts(++$attempts); if ($attempts > G2_SUPPORT_MAX_LOGIN_ATTEMPTS) { GallerySetupUtilities::notifySiteAdministrator(); } } else { GallerySetupUtilities::authenticateThisSession(); } } $templateData['renderType'] = 'password'; } if (GallerySetupUtilities::isSessionAuthenticated()) { $this->setComplete(true); } } if ($this->isComplete()) { $templateData['bodyFile'] = 'AuthenticateSuccessful.html'; } else { $templateData['bodyFile'] = 'AuthenticateRequest.html'; } } } ?>