本文整理汇总了PHP中eZDir::recursiveDelete方法的典型用法代码示例。如果您正苦于以下问题:PHP eZDir::recursiveDelete方法的具体用法?PHP eZDir::recursiveDelete怎么用?PHP eZDir::recursiveDelete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZDir
的用法示例。
在下文中一共展示了eZDir::recursiveDelete方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tearDown
public function tearDown()
{
// restore the previous file handler
if ($this->previousFileHandler !== null) {
$fileINI = eZINI::instance('file.ini');
$fileINI->setVariable('ClusteringSettings', 'FileHandler', $this->previousFileHandler);
$this->previousFileHandler = null;
eZClusterFileHandler::resetHandler();
}
if ($this->haveToRemoveDFSPath) {
eZDir::recursiveDelete($this->DFSPath);
}
parent::tearDown();
}
示例2: clearGlobalINICache
/**
* Clear global ini cache
*/
static function clearGlobalINICache($cacheItem)
{
eZDir::recursiveDelete($cacheItem['path']);
}
示例3: array
{
$notRemoved[] = array( 'filename' => $fileName );
}
}
if ( $overrideINI->save( "siteaccess/$siteAccess/override.ini.append" ) == false )
{
$overrideINISaveFailed = true;
}
// Expire content view cache
eZContentCacheManager::clearAllContentCache();
// Clear override cache
$cachedDir = eZSys::cacheDirectory();
$cachedDir .= "/override/";
eZDir::recursiveDelete( $cachedDir );
}
}
$overrideArray = eZTemplateDesignResource::overrideArray( $siteAccess );
$templateSettings = false;
if ( isset( $overrideArray[$template] ) )
{
$templateSettings = $overrideArray[$template];
}
if ( !isset( $templateSettings['custom_match'] ) )
$templateSettings['custom_match'] = 0;
$tpl->setVariable( 'template_settings', $templateSettings );
示例4: tearDown
public function tearDown()
{
ezpINIHelper::restoreINISettings();
if (isset($GLOBALS['eZClusterFileHandler_chosen_handler'])) {
unset($GLOBALS['eZClusterFileHandler_chosen_handler']);
}
if ($this->haveToRemoveDFSPath) {
eZDir::recursiveDelete(self::$DFSPath);
}
parent::tearDown();
}
示例5: downloadPackages
function downloadPackages($packageList, $packageURL, $packageDir, $packageRepository)
{
global $cli;
showMessage2("Configuring...");
if (!is_array($packageList) || count($packageList) == 0) {
showError("Package list is empty. Aborting...");
}
// 1. check if packages specified in $packageList exist in $packageRepository(means already downloaded and imported).
// if yes - ask user to do download or not. If not - go out
foreach (array_keys($packageList) as $k) {
$packageName = $packageList[$k];
$package = eZPackage::fetch($packageName);
if (is_object($package)) {
global $autoMode;
if ($autoMode == 'on') {
$action = 'y';
} else {
$action = getUserInput("Package '{$packageName}' already imported. Import it anyway? [y/n]: ");
}
if (strpos($action, 'n') === 0) {
unset($packageList[$k]);
} else {
eZDir::recursiveDelete(eZPackage::repositoryPath() . "/{$packageRepository}/{$packageName}");
}
}
}
if (count($packageList) == 0) {
// all packages are imported.
return true;
}
// 2. check $packgesList exists in $packageDir(means packages downloaded but not imported)
// if yes - ask user to import or not. If not - go out
if (!checkDir($packageDir)) {
return false;
}
$downloadPackageList = array();
foreach ($packageList as $packageName) {
if (file_exists("{$packageDir}/{$packageName}.ezpkg")) {
global $autoMode;
if ($autoMode == 'on') {
$action = 'y';
} else {
$action = getUserInput("Package '{$packageName}' already downloaded. Download it anyway? [y/n]: ");
}
if (strpos($action, 'n') === 0) {
continue;
}
}
$downloadPackageList[] = $packageName;
}
//
// download
//
showMessage2("Downloading...");
if (count($downloadPackageList) > 0) {
// TODO: using 'eZStepSiteTypes' is hack.
// need to exclude 'downloadFile' from that class.
$tpl = false;
$http = false;
$ini = false;
$persistenceList = false;
$downloader = new eZStepSiteTypes($tpl, $http, $ini, $persistenceList);
foreach ($downloadPackageList as $packageName) {
showMessage("{$packageName}");
$archiveName = $downloader->downloadFile("{$packageURL}/{$packageName}.ezpkg", $packageDir);
if ($archiveName === false) {
showError("download error - " . $downloader->ErrorMsg);
}
}
}
//
// import
//
showMessage2("Importing...");
foreach ($packageList as $packageName) {
showMessage("{$packageName}");
$package = eZPackage::import("{$packageDir}/{$packageName}.ezpkg", $packageName, false, $packageRepository);
if (!is_object($package)) {
showError("Faild to import '{$packageName}' package: err = {$package}");
}
}
return true;
}
示例6: setUp
public function setUp()
{
eZDir::recursiveDelete(eZINI::instance()->variable('FileSettings', 'VarDir'));
eZContentLanguage::expireCache();
}
示例7: purge
/**
* Purges local and remote file data for current file path.
*
* Can be given a file or a folder. In order to clear a folder, do NOT add
* a trailing / at the end of the file's path: path/to/file instead of
* path/to/file/.
*
* By default, only expired files will be removed (ezdfsfile.expired = 1).
* If you specify an $expiry time, it will replace the expired test and
* only purge files older than the given expiry timestamp.
*
* @param callback $printCallback
* Callback called after each delete iteration (@see $max) to print
* out a report of the deleted files. This callback expects two
* parameters, $file (delete pattern used to perform deletion) and
* $count (number of deleted items)
* @param int $microsleep
* Wait interval before each purge batch of $max items
* @param int $max
* Maximum number of items to delete in one batch (default: 100)
* @param int $expiry
* If specificed, only files older than this date will be purged
* @return void
*/
function purge($printCallback = false, $microsleep = false, $max = false, $expiry = false)
{
eZDebugSetting::writeDebug('kernel-clustering', "dfs::purge( '{$this->filePath}' )");
$file = $this->filePath;
if ($max === false) {
$max = 100;
}
$count = 0;
/**
* The loop starts without knowing how many files are to be deleted.
* When _purgeByLike is called, it returns the number of affected rows.
* If rows were affected, _purgeByLike will be called again
*/
do {
// @todo this won't work on windows, make a wrapper that uses
// either usleep or sleep depending on the OS
if ($count > 0 && $microsleep) {
usleep($microsleep);
// Sleep a bit to make the database happier
}
$count = self::$dbbackend->_purgeByLike($file . "/%", true, $max, $expiry, 'purge');
self::$dbbackend->_purge($file, true, $expiry, 'purge');
if ($printCallback) {
call_user_func_array($printCallback, array($file, $count));
}
// @todo Compare $count to $max. If $count < $max, no more files are to
// be purged, and we can exit the loop
} while ($count > 0);
// Remove local copies
if (is_file($file)) {
@unlink($file);
} elseif (is_dir($file)) {
eZDir::recursiveDelete($file);
}
eZClusterFileHandler::cleanupEmptyDirectories($file);
}
示例8: recursiveDelete
/**
* Removes a directory and all it's contents, recursively.
*
* @param string $dir Directory to remove
* @param bool $rootCheck Check whether $dir is supposed to be contained in
* eZ Publish root directory
* @return bool True if the operation succeeded, false otherwise
*/
static function recursiveDelete($dir, $rootCheck = true)
{
// RecursiveDelete fails if ...
// $dir is not a directory
if (!is_dir($dir)) {
eZDebug::writeError("The path: {$dir} is not a folder", __METHOD__);
return false;
}
if ($rootCheck) {
// rootCheck is enabled, check if $dir is part of authorized directories
$allowedDirs = eZINI::instance()->variable('FileSettings', 'AllowedDeletionDirs');
// Also adding eZ Publish root dir.
$rootDir = eZSys::rootDir() . DIRECTORY_SEPARATOR;
array_unshift($allowedDirs, $rootDir);
$dirRealPath = dirname(realpath($dir)) . DIRECTORY_SEPARATOR;
$canDelete = false;
foreach ($allowedDirs as $allowedDir) {
if (strpos($dirRealPath, realpath($allowedDir)) === 0) {
$canDelete = true;
break;
}
}
if (!$canDelete) {
eZDebug::writeError("Recursive delete denied for '{$dir}' as its realpath '{$dirRealPath}' is outside eZ Publish root and not registered in AllowedDeletionDirs.");
return false;
}
}
// the directory cannot be opened
if (!($handle = @opendir($dir))) {
eZDebug::writeError("Cannot access folder:" . dirname($dir), __METHOD__);
return false;
}
while (($file = readdir($handle)) !== false) {
if ($file == "." || $file == "..") {
continue;
}
if (is_dir($dir . '/' . $file)) {
eZDir::recursiveDelete($dir . '/' . $file, false);
} else {
unlink($dir . '/' . $file);
}
}
@closedir($handle);
return rmdir($dir);
}
示例9: purge
function purge($printCallback = false, $microsleep = false, $max = false, $expiry = false)
{
$file = $this->filePath;
if ($max === false) {
$max = 100;
}
$count = 0;
do {
if ($count > 0 && $microsleep) {
usleep($microsleep);
}
// Sleep a bit to make the database happier
$count = $this->backend->_purgeByLike($file . "/%", true, $max, $expiry, 'purge');
$this->backend->_purge($file, true, $expiry, 'purge');
if ($printCallback) {
call_user_func_array($printCallback, array($file, $count));
}
} while ($count > 0);
// Remove local copy
if (is_file($file)) {
@unlink($file);
} else {
if (is_dir($file)) {
eZDir::recursiveDelete($file);
}
}
}
示例10: removeIcons
/**
* Removes icons for given application
* @param string $appIdentifier Identifier of app
* @param string $clusterIdentifier Identifier of cluster
*/
function removeIcons()
{
global $appIdentifier, $clusterIdentifier;
$imageDirPath = eZDir::path( array( StaticData::directory(), $clusterIdentifier, 'apps', $appIdentifier ) );
eZDir::recursiveDelete($imageDirPath);
}
示例11: tearDown
public function tearDown()
{
ezpINIHelper::restoreINISettings();
eZClusterFileHandler::resetHandler();
if ($this->haveToRemoveDFSPath) {
eZDir::recursiveDelete(self::$DFSPath);
}
parent::tearDown();
}
示例12: purge
function purge( $printCallback = false, $microsleep = false, $max = false, $expiry = false )
{
$file = $this->filePath;
if ( $max === false )
$max = 100;
$count = 0;
do
{
if ( $count > 0 && $microsleep )
usleep( $microsleep ); // Sleep a bit to make the database happier
$count = self::$dbbackend->_purgeByLike( $file . "/%", true, $max, $expiry, 'purge' );
self::$dbbackend->_purge( $file, true, $expiry, 'purge' );
if ( $printCallback )
call_user_func_array( $printCallback,
array( $file, $count ) );
} while ( $count > 0 );
// Remove local copy
if ( is_file( $file ) )
{
@unlink( $file );
}
else if ( is_dir( $file ) )
{
eZDir::recursiveDelete( $file );
}
eZClusterFileHandler::cleanupEmptyDirectories( $file );
}
示例13: changeDBCharsetORACLE
//.........这里部分代码省略.........
//$dropdb = "dropdb $connectionParams";
//$createdb = "createdb $connectionParams";
foreach( $oracleUsers as $user )
{
$alterdb .= "
DROP USER $user CASCADE;";
}
$alterdb .= "
SHUTDOWN IMMEDIATE;
STARTUP MOUNT;
ALTER SYSTEM ENABLE RESTRICTED SESSION;
ALTER SYSTEM SET JOB_QUEUE_PROCESSES=0;
ALTER SYSTEM SET AQ_TM_PROCESSES=0;
ALTER DATABASE OPEN;
ALTER DATABASE CHARACTER SET AL32UTF8;
SHUTDOWN IMMEDIATE; -- or SHUTDOWN NORMAL;
STARTUP;
EXIT;
";
*/
// finalizing changes. Note that since we asked for admin connection before,
// disconnecting and reconnecting, this is surely a NOOP
//showMessage3( 'finalizing current changes' );
//$db->commit();
/// @todo add a database logfile switch or checkpoint here? it would be nice...
// close current connection
$db->close();
showMessage3(' sleeping..');
sleep(5);
// dump db
showMessage3(" taking the db dump, tmp storage is '{$dumpPath1}', '{$dumpPath2}'");
eZDir::mkdir($dumpDir, false, true);
chdir($oracleHome . '/bin');
eZExecuteShellCommand($expdb1, "failed to dump db schema. tried command '{$expdb1}'", true, true);
eZExecuteShellCommand($expdb2, "failed to dump db data. tried command '{$expdb2}'", true, true);
chdir($eZDir);
// verify that dump files exist
if (!file_exists($dumpPath1) || !file_exists($dumpPath2)) {
showError("DB Dump files cannot be found. Aborting...");
}
/*
showMessage3( "altering db with charset '$charset'" );
$command = $sqlplus . " @$commandPath";
file_put_contents( $commandPath, $alterdb );
eZExecuteShellCommand( $command, "failed to alter db. tried command '$command'");
*/
showMessage3('');
showMessage3("Now you will have to alter the database character set.");
showMessage3("The recommended way is to create a new database from scratch");
showMessage3("using AL32UTF8 as character set (THIS IS VERY IMPORTANT),");
showMessage3("and delete the existing one.");
showMessage3("The new database should be empty (all schemas will be recreated by this script)");
showMessage3("and have the same DBA account as the old one.");
showMessage3("It should also use the same connect identifier as the old one.");
showMessage3('');
showMessage3("PLEASE do not terminate this php script while doing that,");
showMessage3("use a different command line shell.");
showMessage3('');
$continue = eZGetUserInput("Press Y when you are ready to continue... ");
if ($continue != 'y' && $continue != 'Y') {
showError("Aborting");
}
// connect to new db with dba account, check that charset is OK
while (true) {
$db = eZDB::instance(false, array('user' => $oracleDbaAccount['user'], 'password' => $oracleDbaAccount['password']), true);
if (!$db->isConnected()) {
showWarning("Cannot connect to the new database.\n" . "Please check that it is up and running before continuing");
} else {
$oracleCharset = $db->arrayQuery("select value from nls_database_parameters where parameter = 'NLS_CHARACTERSET'");
$oracleCharset = $oracleCharset[0]['value'];
$db->close();
if ($oracleCharset == 'AL32UTF8') {
break;
} else {
showWarning("The new database uses the {$oracleCharset} character set instead of AL32UTF8.\n" . "Please recreate the database using AL32UTF8 before continuing");
}
}
$continue = eZGetUserInput("Press Y when you are ready to continue. Any other letter to abort ");
if ($continue != 'y' && $continue != 'Y') {
showError("Aborting");
}
}
// restore dump into newly created db
showMessage3(" restoring db dump");
chdir($oracleHome . '/bin');
eZExecuteShellCommand($impdb1, "failed to restore db dump. tried command '{$impdb1}'");
eZExecuteShellCommand($impdb2, "failed to restore db dump. tried command '{$impdb2}'");
chdir($eZDir);
showMessage3(" cleaning up");
// clean up
eZDir::recursiveDelete($dumpPath1);
eZDir::recursiveDelete($dumpPath2);
}
// re-initialize db interface, *** this time in UTF8 - with the standard user ***
$db = eZDB::instance(false, array('charset' => 'utf8'), true);
if (!$db->isConnected()) {
showError("Cannot reconnect to DB. Aborting...");
}
//$db->begin();
}
示例14: clearTemplateCompileCache
/**
* Clear Template Compile cache
*/
static function clearTemplateCompileCache()
{
eZDir::recursiveDelete(eZTemplateCompiler::compilationDirectory());
}
示例15: install
function install( $package, $installType, $parameters,
$name, $os, $filename, $subdirectory,
$content, &$installParameters,
&$installData )
{
//$this->Package =& $package;
$trans = eZCharTransform::instance();
$name = $content->getAttribute( 'name' );
$extensionName = $trans->transformByGroup( $name, 'urlalias' );
if ( strcmp( $name, $extensionName ) !== 0 )
{
$description = ezpI18n::tr( 'kernel/package', 'Package contains an invalid extension name: %extensionname', false, array( '%extensionname' => $name ) );
$installParameters['error'] = array( 'error_code' => false,
'element_id' => $name,
'description' => $description );
return false;
}
$siteINI = eZINI::instance();
$extensionRootDir = $siteINI->variable( 'ExtensionSettings', 'ExtensionDirectory' );
$extensionDir = $extensionRootDir . '/' . $extensionName;
$packageExtensionDir = $package->path() . '/' . $parameters['sub-directory'] . '/' . $extensionName;
// Error: extension already exists.
if ( file_exists( $extensionDir ) )
{
$description = ezpI18n::tr( 'kernel/package', "Extension '%extensionname' already exists.",
false, array( '%extensionname' => $extensionName ) );
$choosenAction = $this->errorChoosenAction( self::ERROR_EXISTS,
$installParameters, $description, $this->HandlerType );
switch( $choosenAction )
{
case self::ACTION_SKIP:
return true;
case eZPackage::NON_INTERACTIVE:
case self::ACTION_REPLACE:
eZDir::recursiveDelete( $extensionDir );
break;
default:
$installParameters['error'] = array( 'error_code' => self::ERROR_EXISTS,
'element_id' => $extensionName,
'description' => $description,
'actions' => array( self::ACTION_REPLACE => ezpI18n::tr( 'kernel/package', "Replace extension" ),
self::ACTION_SKIP => ezpI18n::tr( 'kernel/package', 'Skip' ) ) );
return false;
}
}
eZDir::mkdir( $extensionDir, false, true );
eZDir::copy( $packageExtensionDir, $extensionRootDir );
// Regenerate autoloads for extensions to pick up the newly created extension
ezpAutoloader::updateExtensionAutoloadArray();
// Activate extension
$siteINI = eZINI::instance( 'site.ini', 'settings/override', null, null, false, true );
if ( $siteINI->hasVariable( 'ExtensionSettings', "ActiveExtensions" ) )
{
$selectedExtensions = $siteINI->variable( 'ExtensionSettings', "ActiveExtensions" );
}
else
{
$selectedExtensions = array();
}
if ( !in_array( $extensionName, $selectedExtensions ) )
{
$selectedExtensions[] = $extensionName;
$siteINI->setVariable( "ExtensionSettings", "ActiveExtensions", $selectedExtensions );
$siteINI->save( 'site.ini.append', '.php', false, false );
}
return true;
}