/**
 * Clear full page cache (/cache directory)
 */
function dbm_delete_pagecache()
{
    global $DB, $Messages, $cache_path;
    // Clear general cache directory
    if (cleardir_r($cache_path . 'general')) {
        $Messages->add(sprintf(T_('General cache deleted: %s'), $cache_path . 'general'), 'note');
    } else {
        $Messages->add(sprintf(T_('Could not delete general cache: %s'), $cache_path . 'general'), 'error');
    }
    $SQL = 'SELECT blog_ID FROM T_blogs
			INNER JOIN T_coll_settings ON ( blog_ID = cset_coll_ID
						AND cset_name = "cache_enabled"
						AND cset_value = "1" )
			WHERE 1=1';
    if ($blog_array = $DB->get_col($SQL)) {
        foreach ($blog_array as $l_blog) {
            // Clear blog cache
            if (cleardir_r($cache_path . 'c' . $l_blog)) {
                $Messages->add(sprintf(T_('Blog %d cache deleted: %s'), $l_blog, $cache_path . 'c' . $l_blog), 'note');
            } else {
                $Messages->add(sprintf(T_('Could not delete blog %d cache: %s'), $l_blog, $cache_path . 'c' . $l_blog), 'error');
            }
            // Create .htaccess file with deny rules
            create_htaccess_deny($cache_path);
        }
    }
    $Messages->add(T_('Page cache deleted.'), 'success');
}
Beispiel #2
0
/**
 * Check if a directory is ready for operation, i-e writable by PHP.
 *
 * @return integer result code, 0 means 'ok'
 */
function system_check_dir($directory = 'media', $relative_path = NULL)
{
    global $media_path, $cache_path;
    switch ($directory) {
        case 'cache':
            $path = $cache_path;
            break;
        case 'media':
            $path = $media_path;
            break;
        default:
            return 1;
    }
    if ($relative_path != NULL) {
        $path .= $relative_path;
    }
    if (!is_dir($path)) {
        return 2;
    } elseif (!is_readable($path)) {
        return 3;
    } elseif (!is_writable($path)) {
        return 4;
    } else {
        $tempfile_path = $path . 'temp.tmp';
        if (!@touch($tempfile_path) || !@unlink($tempfile_path)) {
            return 5;
        }
    }
    if ($directory == 'cache' && $relative_path != NULL) {
        // Create .htaccess file with deny rules
        if (!create_htaccess_deny($cache_path)) {
            return 6;
        }
    }
    return 0;
}
 /**
  * @return boolean true if cache has been successfully created
  */
 function cache_create($clear = true)
 {
     global $cache_path;
     // Create by using the filemanager's default chmod. TODO> we may not want to make these publicly readable
     if (!mkdir_r($this->ads_collcache_path, NULL)) {
         return false;
     }
     if ($clear) {
         // Clear contents of folder, if any:
         cleardir_r($this->ads_collcache_path);
     }
     // Create htaccess file with deny rules
     if (!create_htaccess_deny($cache_path)) {
         return false;
     }
     return true;
 }