10 if (file_exists(
$file))
return false;
25 if (!file_exists(
$file))
return false;
32 if (!file_exists(
$file))
return false;
33 return unserialize(file_get_contents(
$file));
38 if (!file_exists(
$file))
return false;
46 while (
false !== ($filename = readdir($dh))) {
47 if (empty($filename))
continue;
48 if ($filename[0] ===
'.')
continue;
49 unlink(
$dir .
'/' . $filename);
57 while (
false !== ($filename = readdir($dh))) {
58 if (empty($filename))
continue;
59 if ($filename[0] ===
'.')
continue;
60 $key = substr($filename, 0, strlen($filename) - 4);
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',