17 if (file_exists($file)) {
54 if (!file_exists($file)) {
70 if (!file_exists($file)) {
73 return unserialize(file_get_contents($file));
83 if (!file_exists($file)) {
106 while (
false !== (
$filename = readdir($dh))) {
134 while (
false !== (
$filename = readdir($dh))) {
186 $base = is_null(
$base) ? HTMLPURIFIER_PREFIX .
'/HTMLPurifier/DefinitionCache/Serializer' :
$base;
202 $chmod =
$config->get(
'Cache.SerializerPermissions');
203 if ($chmod !== null) {
204 chmod($file, $chmod & 0666);
218 $chmod =
$config->get(
'Cache.SerializerPermissions');
219 if ($chmod === null) {
220 if (!@mkdir($directory) && !is_dir($directory)) {
222 'Could not create directory ' . $directory .
'',
229 if (!is_dir($directory)) {
231 if (!is_dir(
$base)) {
233 'Base directory ' .
$base .
' does not exist, 234 please create or change using %Cache.SerializerPath',
241 if (!@mkdir($directory, $chmod) && !is_dir($directory)) {
243 'Could not create directory ' . $directory .
'',
267 if (is_writable($dir)) {
274 'Directory ' . $dir .
' does not exist',
279 if (function_exists(
'posix_getuid') && $chmod !== null) {
281 if (fileowner($dir) === posix_getuid()) {
283 $chmod = $chmod | 0700;
284 if (chmod($dir, $chmod)) {
287 } elseif (filegroup($dir) === posix_getgid()) {
288 $chmod = $chmod | 0070;
292 $chmod = $chmod | 0777;
295 'Directory ' . $dir .
' not writable, ' .
296 'please chmod to ' . decoct($chmod),
302 'Directory ' . $dir .
' not writable, ' .
303 'please alter file permissions',
generateBaseDirectoryPath($config)
Generates path to base directory that contains all definition type serials.
Abstract class representing Definition cache managers that implements useful common methods and is a ...
generateDirectoryPath($config)
Generates the path to the directory contain this cache's serial files.
checkDefType($def)
Checks if a definition's type jives with the cache's type.
_prepareDir($config)
Prepares the directory that this type stores the serials in.
_write($file, $data, $config)
Convenience wrapper function for file_put_contents.
generateFilePath($config)
Generates the file path to the serial file corresponding to the configuration and definition name...
_testPermissions($dir, $chmod)
Tests permissions on a directory and throws out friendly error messages and attempts to chmod it itse...
isOld($key, $config)
Tests whether or not a key is old with respect to the configuration's version and revision number...
generateKey($config)
Generates a unique identifier for a particular configuration.