Obfuscate keys with some salt. Add empty index.php files to the cache dirs to prevent directory listings. Props to ringmaster. fixes #1851

git-svn-id: https://develop.svn.wordpress.org/trunk@3017 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2005-11-08 22:15:06 +00:00
parent 1412706873
commit b5113fae7c
1 changed files with 11 additions and 3 deletions

View File

@ -105,7 +105,7 @@ class WP_Object_Cache {
return false;
}
$cache_file = $this->cache_dir . $this->get_group_dir($group) . "/" . md5($id);
$cache_file = $this->cache_dir . $this->get_group_dir($group) . "/" . md5($id . DB_PASSWORD);
if (!file_exists($cache_file)) {
$this->cache_misses += 1;
return false;
@ -166,6 +166,10 @@ class WP_Object_Cache {
break;
@ chmod($this->cache_dir . $make_dir, $perms);
}
if (!file_exists($this->cache_dir . $make_dir . "index.php")) {
touch($this->cache_dir . $make_dir . "index.php");
}
}
return $this->cache_dir . "$group_dir/";
@ -191,7 +195,7 @@ class WP_Object_Cache {
}
function save() {
//$this->stats();
$this->stats();
if (!$this->cache_enabled)
return;
@ -209,6 +213,10 @@ class WP_Object_Cache {
return;
@ chmod($this->cache_dir, $dir_perms);
}
if (!file_exists($this->cache_dir . "index.php")) {
touch($this->cache_dir . "index.php");
}
// Acquire a write lock. Semaphore preferred. Fallback to flock.
if (function_exists('sem_get')) {
@ -229,7 +237,7 @@ class WP_Object_Cache {
foreach ($ids as $id) {
// TODO: If the id is no longer in the cache, it was deleted and
// the file should be removed.
$cache_file = $group_dir . md5($id);
$cache_file = $group_dir . md5($id . DB_PASSWORD);
$temp_file = tempnam($group_dir, 'tmp');
$serial = serialize($this->cache[$group][$id]);
$fd = fopen($temp_file, 'w');