_hash[$key] = $value; } function getConfig($key) { if (isset($this->_hash[$key])) { return $this->_hash[$key]; } return null; } function setDebug() { } function setDebugLogFile() { } function setProfile() { } } $gallery = new GalleryStub(); /* Load config.php */ if (!defined('GALLERY_CONFIG_DIR')) { define('GALLERY_CONFIG_DIR', dirname(dirname(dirname(__FILE__)))); } if (file_exists(GALLERY_CONFIG_DIR . '/config.php')) { include(GALLERY_CONFIG_DIR . '/config.php'); } else { $baseUrl = ''; render('missingConfig'); exit; } if ($baseUrl = $gallery->getConfig('galleryBaseUrl')) { $baseUrl .= 'lib/support/'; } $setupPassword = $gallery->getConfig('setup.password'); if (empty($setupPassword)) { render('missingPassword'); exit; } if (passwordProvided()) { if (passwordIsCorrect()) { savePasswordCookie(); redirectBackToSelf(); exit; } else { askForPassword(); exit; } } else if (!isset($_COOKIE['g2Setup'])) { askForPassword(); exit; } else if ($_COOKIE['g2Setup'] == md5($setupPassword)) { return; } else { askForPassword(); exit; } function passwordProvided() { return isset($_POST['g2_password']); } function passwordIsCorrect() { global $gallery; return $_POST['g2_password'] == $gallery->getConfig('setup.password'); } function savePasswordCookie() { global $gallery; header(sprintf('Set-Cookie: g2Setup=%s', md5($gallery->getConfig('setup.password')))); } function askForPassword() { global $message, $gallery; $message = array(); if (!empty($_POST['g2_password'])) { $message['password'] = $_POST['g2_password']; } render('passwordForm'); } function redirectBackToSelf() { require_once(dirname(__FILE__) . '/../../modules/core/classes/GalleryUrlGenerator.class'); $urlGenerator = new GalleryUrlGenerator(); header('Location: ' . $urlGenerator->getCurrentUrl()); } function render($renderType) { global $baseUrl; ?>
$gallery->setConfig('setup.password', 'your password here');