11 public function add($def, $config)
17 if (file_exists(
$file)) {
23 return $this->
_write(
$file, serialize($def), $config);
31 public function set($def, $config)
40 return $this->
_write(
$file, serialize($def), $config);
54 if (!file_exists(
$file)) {
60 return $this->
_write(
$file, serialize($def), $config);
67 public function get($config)
70 if (!file_exists(
$file)) {
73 return unserialize(file_get_contents(
$file));
80 public function remove($config)
83 if (!file_exists(
$file)) {
100 while (
false !== (
$filename = readdir($dh))) {
122 while (
false !== (
$filename = readdir($dh))) {
130 if ($this->
isOld($key, $config)) {
171 $base = $config->get(
'Cache.SerializerPath');
172 $base = is_null($base) ? HTMLPURIFIER_PREFIX .
'/HTMLPurifier/DefinitionCache/Serializer' : $base;
188 $chmod = $config->get(
'Cache.SerializerPermissions');
192 $chmod = $chmod & 0666;
193 chmod(
$file, $chmod);
206 $chmod = $config->get(
'Cache.SerializerPermissions');
210 if (!is_dir($directory)) {
212 if (!is_dir($base)) {
214 'Base directory ' . $base .
' does not exist,
215 please create or change using %Cache.SerializerPath',
223 mkdir($directory, $chmod);
241 if (is_writable($dir)) {
248 'Directory ' . $dir .
' does not exist',
253 if (function_exists(
'posix_getuid')) {
255 if (fileowner($dir) === posix_getuid()) {
257 $chmod = $chmod | 0700;
258 if (chmod($dir, $chmod)) {
261 } elseif (filegroup($dir) === posix_getgid()) {
262 $chmod = $chmod | 0070;
266 $chmod = $chmod | 0777;
269 'Directory ' . $dir .
' not writable, ' .
270 'please chmod to ' . decoct($chmod),
276 'Directory ' . $dir .
' not writable, ' .
277 'please alter file permissions',