getFilename();
if (!preg_match('/\.class\.php$/', $fn) or preg_match('/\/core-views\//', $fn))
continue;
$c = str_replace('.class.php', '', $fn);
if (!class_exists($c)) {
$cache[$c] = ($pn = $entry->getPathname());
++$n;
}
}
}
ksort($cache);
file_put_contents(AUTOLOADER_MAP, serialize($cache));
return $n;
}
function buildReleaseMap() {
$hash = array();
$exclude = array(
'/.svn\//', '/^ctrl\//', '/^view\/app\//', '/^doc\//', '/^test\//', '/^i18n\//', '/^examples\//',
'/^patch\//', '/^var\/log\//', '/^var\/cache\/.*\.map/', '/^var\/cache\/password\.hash/', '/^var\/smarty\//', '/^var\/sqlite\//'
);
$n = 0;
foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator('.')) as $entry) {
if ($entry->isDir()) {
continue;
}
$fn = preg_replace('/^\.\//', '', $entry->getPathname());
$ok = true;
foreach ($exclude as $ex) {
if (preg_match($ex, $fn)) {
$ok = false;
}
}
if ($ok) {
$hash[] = md5_file($fn) . "\t" . $fn;
++$n;
}
}
file_put_contents(RELEASE_MAP, implode("\n", $hash));
return $n;
}
function getHash($password) {
return sha1($password . crc32($password));
}
function authenticate($password) {
return trim(file_get_contents(PASSWORD_FILE)) == getHash($password);
}
function updatePassword($password) {
$exists = file_exists(PASSWORD_FILE);
if ($exists and !is_writable(PASSWORD_FILE) or !$exists and !is_writable(dirname(PASSWORD_FILE))) {
return false;
}
file_put_contents(PASSWORD_FILE, getHash($password));
return true;
}
if (@$_POST['password']) {
if (authenticate($_POST['password'])) {
if (is_writable(AUTOLOADER_MAP) and is_writable(RELEASE_MAP)) {
$out = file_get_contents('var/auth/build.html');
$out = str_replace('{autoloader}', buildAutoloaderMap(), $out);
$out = str_replace('{release}', buildReleaseMap(), $out);
die($out);
} else {
die(str_replace('{message}', 'All *.map files in var/cache/ directory
must be writable', file_get_contents('var/auth/auth.html')));
}
} else {
die(str_replace('{message}', 'Incorrect password', file_get_contents('var/auth/auth.html')));
}
} elseif (@$_POST['new1'] and @$_POST['new2']) {
if ($_POST['new1'] != $_POST['new2']) {
die(str_replace('{message}', 'New passwords must be identical', file_get_contents('var/auth/change.html')));
} elseif (!file_exists(PASSWORD_FILE) or authenticate($_POST['old'])) {
if (updatePassword($_POST['new1'])) {
die(str_replace('{message}', 'Password upated sucessfully', file_get_contents('var/auth/auth.html')));
} else {
die(str_replace('{message}', 'File ' . PASSWORD_FILE . ' is not writable', file_get_contents('var/auth/auth.html')));
}
} else {
die(str_replace('{message}', 'Incorrect password', file_get_contents('var/auth/change.html')));
}
} elseif (!file_exists(PASSWORD_FILE) or @$_GET['change']) {
die(str_replace('{message}', '', file_get_contents('var/auth/change.html')));
}
print(str_replace('{message}', 'Please enter your password', file_get_contents('var/auth/auth.html')));
?>