Esempio n. 1
0
function removeRelatedCache($siteAccess)
{
    // Delete compiled template
    $ini = eZINI::instance();
    $iniPath = eZSiteAccess::findPathToSiteAccess($siteAccess);
    $siteINI = eZINI::instance('site.ini.append', $iniPath);
    if ($siteINI->hasVariable('FileSettings', 'CacheDir')) {
        $cacheDir = $siteINI->variable('FileSettings', 'CacheDir');
        if ($cacheDir[0] == "/") {
            $cacheDir = eZDir::path(array($cacheDir));
        } else {
            if ($siteINI->hasVariable('FileSettings', 'VarDir')) {
                $varDir = $siteINI->variable('FileSettings', 'VarDir');
                $cacheDir = eZDir::path(array($varDir, $cacheDir));
            }
        }
    } else {
        if ($siteINI->hasVariable('FileSettings', 'VarDir')) {
            $varDir = $siteINI->variable('FileSettings', 'VarDir');
            $cacheDir = $ini->variable('FileSettings', 'CacheDir');
            $cacheDir = eZDir::path(array($varDir, $cacheDir));
        } else {
            $cacheDir = eZSys::cacheDirectory();
        }
    }
    $compiledTemplateDir = $cacheDir . "/template/compiled";
    eZDir::unlinkWildcard($compiledTemplateDir . "/", "*pagelayout*.*");
    eZCache::clearByTag('template-block');
    // Expire content view cache
    eZContentCacheManager::clearAllContentCache();
}
Esempio n. 2
0
if ( $module->isCurrentAction( 'ClearContentCache' ) )
{
    eZCache::clearByTag( 'content' );
    $cacheCleared['content'] = true;
}

if ( $module->isCurrentAction( 'ClearINICache' ) )
{
    eZCache::clearByTag( 'ini' );
    $cacheCleared['ini'] = true;
}

if ( $module->isCurrentAction( 'ClearTemplateCache' ) )
{
    eZCache::clearByTag( 'template' );
    $cacheCleared['template'] = true;
}

if ( $module->isCurrentAction( 'ClearCache' ) && $module->hasActionParameter( 'CacheList' ) && is_array( $module->actionParameter( 'CacheList' ) ) )
{
    $cacheClearList = $module->actionParameter( 'CacheList' );
    eZCache::clearByID( $cacheClearList );
    $cacheItemList = array();
    foreach ( $cacheClearList as $cacheClearItem )
    {
        foreach ( $cacheList as $cacheItem )
        {
            if ( $cacheItem['id'] == $cacheClearItem )
            {
                $cacheItemList[] = $cacheItem;
    $nodeID = $module->actionParameter('NodeID');
}
if ($module->hasActionParameter('ObjectID')) {
    $objectID = $module->actionParameter('ObjectID');
}
if ($cacheType == 'All') {
    eZCache::clearAll();
} elseif ($cacheType == 'Template') {
    eZCache::clearByTag('template');
} elseif ($cacheType == 'Content') {
    eZCache::clearByTag('content');
} elseif ($cacheType == 'TemplateContent') {
    eZCache::clearByTag('template');
    eZCache::clearByTag('content');
} elseif ($cacheType == 'Ini') {
    eZCache::clearByTag('ini');
} elseif ($cacheType == 'Static') {
    // get staticCacheHandler instance
    $optionArray = array('iniFile' => 'site.ini', 'iniSection' => 'ContentSettings', 'iniVariable' => 'StaticCacheHandler');
    $options = new ezpExtensionOptions($optionArray);
    $staticCacheHandler = eZExtension::getHandlerClass($options);
    $staticCacheHandler->generateCache(true, true);
    $cacheCleared['static'] = true;
} elseif ($cacheType == 'ContentNode') {
    $contentModule = eZModule::exists('content');
    if ($contentModule instanceof eZModule) {
        $contentModule->setCurrentAction('ClearViewCache', 'action');
        $contentModule->setActionParameter('NodeID', $nodeID, 'action');
        $contentModule->setActionParameter('ObjectID', $objectID, 'action');
        $contentModule->run('action', array($nodeID, $objectID));
    }
/**
 * @package nxcMasterPassword
 * @author  Serhey Dolgushev <*****@*****.**>
 * @date    22 Sep 2011
 **/
require 'autoload.php';
$cli = eZCLI::instance();
$scriptSettings = array('description' => 'Creates transaltion files', 'use-session' => false, 'use-modules' => false, 'use-extensions' => true);
$script = eZScript::instance($scriptSettings);
$script->startup();
$script->initialize();
$options = $script->getOptions('', '[password]', array('password' => 'New password'));
if (count($options['arguments']) < 1 || strlen($options['arguments'][0]) === 0) {
    $cli->error('Specify new password');
    $script->shutdown(1);
}
$ini = eZINI::instance('nxcmasterpassword.ini');
$password = $options['arguments'][0];
$password = md5(md5($password) . $ini->variable('General', 'Seed'));
$ini->setVariable('General', 'MasterPassword', $password);
$file = 'nxcmasterpassword.ini.append.php';
$path = eZExtension::baseDirectory() . '/nxc_master_password/settings';
$result = $ini->save($file, false, false, false, $path, false, true);
if ($result === false) {
    $cli->error('Cannot update "' . $path . '/' . $file . '" settings file');
    $script->shutdown(1);
}
eZCache::clearByTag('Ini');
$cli->output('Password stored');
$script->shutdown(0);