_uniqueKey = GallerySetupUtilities::generateAuthenticationKey(); $this->_firstTime = true; } function stepName() { return _('Authenticate'); } function processRequest() { if (!empty($_GET['downloadLogin'])) { GallerySetupUtilities::generateTextFileForDownload('login.txt', $this->_uniqueKey); return false; } return true; } function loadTemplateData(&$templateData) { $authenticationDir = dirname(dirname(dirname(__FILE__))); if (!$this->isComplete()) { /* Authenticate */ $authenticated = false; $authFile = dirname(__FILE__) . '/../../login.txt'; if (!file_exists($authFile)) { if (!$this->_firstTime) { $templateData['errors'][] = sprintf(_('Error: could not locate login.txt. ' . 'Please place it in your %s/ directory.'), basename($authenticationDir)); } } else if (!is_readable($authFile)) { $templateData['errors'][] = _('Error: your login.txt file is not readable. ' . 'Please give Gallery read permissions on the file.'); } else { $fileAuth = trim(join('', file($authFile))); if ($fileAuth == $this->_uniqueKey) { /* Authenticate, but don'treset the login attempts because we have no db */ GallerySetupUtilities::authenticateThisSession(false); $this->setComplete(true); } else { $templateData['errors'][] = _('Error: your login.txt key does not match correctly. ' . 'Please download a new authentication string from below and try again.'); } } } $this->_firstTime = false; $templateData['authenticationDir'] = basename($authenticationDir); if ($this->isComplete()) { $templateData['bodyFile'] = 'AuthenticateSuccessful.html'; } else { $templateData['bodyFile'] = 'AuthenticateRequest.html'; } } function getUniqueKey() { return $this->_uniqueKey; } } ?>