7 public function add($def, $config) {
10 if (file_exists(
$file))
return false;
12 return $this->
_write(
$file, serialize($def), $config);
15 public function set($def, $config) {
19 return $this->
_write(
$file, serialize($def), $config);
25 if (!file_exists(
$file))
return false;
27 return $this->
_write(
$file, serialize($def), $config);
30 public function get($config) {
32 if (!file_exists(
$file))
return false;
33 return unserialize(file_get_contents(
$file));
36 public function remove($config) {
38 if (!file_exists(
$file))
return false;
42 public function flush($config) {
46 while (
false !== (
$filename = readdir($dh))) {
57 while (
false !== (
$filename = readdir($dh))) {
91 $base = $config->get(
'Cache.SerializerPath');
92 $base = is_null($base) ? HTMLPURIFIER_PREFIX .
'/HTMLPurifier/DefinitionCache/Serializer' : $base;
107 $chmod = $config->get(
'Cache.SerializerPermissions');
111 $chmod = $chmod & 0666;
112 chmod(
$file, $chmod);
124 $chmod = $config->get(
'Cache.SerializerPermissions');
128 if (!is_dir($directory)) {
130 if (!is_dir($base)) {
131 trigger_error(
'Base directory '.$base.
' does not exist,
132 please create or change using %Cache.SerializerPath',
139 mkdir($directory, $chmod);
156 if (is_writable($dir))
return true;
160 trigger_error(
'Directory '.$dir.
' does not exist',
164 if (function_exists(
'posix_getuid')) {
166 if (fileowner($dir) === posix_getuid()) {
168 $chmod = $chmod | 0700;
169 if (chmod($dir, $chmod))
return true;
170 } elseif (filegroup($dir) === posix_getgid()) {
171 $chmod = $chmod | 0070;
175 $chmod = $chmod | 0777;
177 trigger_error(
'Directory '.$dir.
' not writable, '.
178 'please chmod to ' . decoct($chmod),
182 trigger_error(
'Directory '.$dir.
' not writable, '.
183 'please alter file permissions',