本文整理汇总了PHP中files::deltree方法的典型用法代码示例。如果您正苦于以下问题:PHP files::deltree方法的具体用法?PHP files::deltree怎么用?PHP files::deltree使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类files
的用法示例。
在下文中一共展示了files::deltree方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: deltree
function deltree($dir)
{
$current_dir = opendir($dir);
while ($entryname = readdir($current_dir)) {
if (is_dir($dir . '/' . $entryname) and ($entryname != '.' and $entryname != '..')) {
if (!files::deltree($dir . '/' . $entryname)) {
return false;
}
} elseif ($entryname != '.' and $entryname != '..') {
if (!@unlink($dir . '/' . $entryname)) {
return false;
}
}
}
closedir($current_dir);
return @rmdir($dir);
}
示例2: Markdown
exit;
}
# affichage des notes d'un thème
if (!empty($_GET['notes']) && file_exists(OKT_THEMES_PATH . '/' . $_GET['notes'] . '/notes.md')) {
include_once OKT_VENDOR_PATH . '/phpmarkdown/extra/markdown.php';
echo Markdown(file_get_contents(OKT_THEMES_PATH . '/' . $_GET['notes'] . '/notes.md'));
exit;
}
# Ré-initialisation filtres
if (!empty($_GET['init_filters'])) {
$oFilters->initFilters();
$okt->redirect('configuration.php?action=themes');
}
# Suppression d'un thème
if (!empty($_GET['delete']) && isset($aInstalledThemes[$_GET['delete']]) && !$aInstalledThemes[$_GET['delete']]['is_active']) {
if (files::deltree(OKT_THEMES_PATH . '/' . $_GET['delete'])) {
$okt->redirect('configuration.php?action=themes&deleted=1');
}
}
# Utilisation d'un thème
if (!empty($_GET['use'])) {
try {
# write config
$okt->config->write(array('theme' => $_GET['use']));
# modules config sheme
$sTplScheme = OKT_THEMES_PATH . '/' . $_GET['use'] . '/modules_config_scheme.php';
if (file_exists($sTplScheme)) {
include $sTplScheme;
}
$okt->redirect('configuration.php?action=themes&used=1');
} catch (InvalidArgumentException $e) {
示例3: installPackage
/**
* Install a module from a zip file
*
* @param string $zip_file
* @param oktModules $modules
*/
public static function installPackage($zip_file, oktModules $modules)
{
$zip = new fileUnzip($zip_file);
$zip->getList(false, '#(^|/)(__MACOSX|\\.svn|\\.DS_Store|Thumbs\\.db)(/|$)#');
$zip_root_dir = $zip->getRootDir();
if ($zip_root_dir !== false) {
$target = dirname($zip_file);
$destination = $target . '/' . $zip_root_dir;
$define = $zip_root_dir . '/_define.php';
$has_define = $zip->hasFile($define);
} else {
$target = dirname($zip_file) . '/' . preg_replace('/\\.([^.]+)$/', '', basename($zip_file));
$destination = $target;
$define = '_define.php';
$has_define = $zip->hasFile($define);
}
if ($zip->isEmpty()) {
$zip->close();
unlink($zip_file);
throw new Exception(__('Empty module zip file.'));
}
if (!$has_define) {
$zip->close();
unlink($zip_file);
throw new Exception(__('The zip file does not appear to be a valid module.'));
}
$ret_code = 1;
if (is_dir($destination)) {
copy($target . '/_define.php', $target . '/_define.php.bak');
# test for update
$sandbox = clone $modules;
$zip->unzip($define, $target . '/_define.php');
$sandbox->resetCompleteList();
$sandbox->requireDefine($target, basename($destination));
unlink($target . '/_define.php');
$new_modules = $sandbox->getCompleteList();
$old_modules = $modules->getModulesFromFileSystem();
$modules->disableModule(basename($destination));
$modules->generateCacheList();
if (!empty($new_modules)) {
$tmp = array_keys($new_modules);
$id = $tmp[0];
$cur_module = $old_modules[$id];
if (!empty($cur_module) && $new_modules[$id]['version'] != $cur_module['version']) {
# delete old module
if (!files::deltree($destination)) {
throw new Exception(__('An error occurred during module deletion.'));
}
$ret_code = 2;
} else {
$zip->close();
unlink($zip_file);
if (file_exists($target . '/_define.php.bak')) {
rename($target . '/_define.php.bak', $target . '/_define.php');
}
throw new Exception(sprintf(__('Unable to upgrade "%s". (same version)'), basename($destination)));
}
} else {
$zip->close();
unlink($zip_file);
if (file_exists($target . '/_define.php.bak')) {
rename($target . '/_define.php.bak', $target . '/_define.php');
}
throw new Exception(sprintf(__('Unable to read new _define.php file')));
}
}
$zip->unzipAll($target);
$zip->close();
unlink($zip_file);
return $ret_code;
}
示例4: deleteTemplate
/**
* Delete a template
*
* @param string $sId
* @return boolean
*/
protected function deleteTemplate($sId)
{
$aTemplatesInfos = $this->getTplInfos();
$aTplInfos = $aTemplatesInfos[$sId];
if (!is_dir($aTplInfos['dir']) || !is_writable($aTplInfos['dir'])) {
return false;
}
files::deltree($aTplInfos['dir']);
}
示例5: deleteImage
/**
* Suppression d'une image donnée d'un élément donné.
*
* @param integer $iItemId
* @param array $aCurrentImages
* @param integer $iImgId
* @return array
*/
public function deleteImage($iItemId, $aCurrentImages, $iImgId)
{
if (!isset($aCurrentImages[$iImgId])) {
$this->error->set('L’image n’existe pas.');
return false;
}
$sCurrentImagesDir = $this->getCurrentUploadDir($iItemId);
$sCurrentImagesUrl = $this->getCurrentUploadUrl($iItemId);
# suppression des fichiers sur le disque
if (files::isDeletable($sCurrentImagesDir . $aCurrentImages[$iImgId]['img_name'])) {
unlink($sCurrentImagesDir . $aCurrentImages[$iImgId]['img_name']);
}
if (files::isDeletable($sCurrentImagesDir . 'o-' . $aCurrentImages[$iImgId]['img_name'])) {
unlink($sCurrentImagesDir . 'o-' . $aCurrentImages[$iImgId]['img_name']);
}
if (files::isDeletable($sCurrentImagesDir . 'min-' . $aCurrentImages[$iImgId]['img_name'])) {
unlink($sCurrentImagesDir . 'min-' . $aCurrentImages[$iImgId]['img_name']);
}
if (files::isDeletable($sCurrentImagesDir . 'min2-' . $aCurrentImages[$iImgId]['img_name'])) {
unlink($sCurrentImagesDir . 'min2-' . $aCurrentImages[$iImgId]['img_name']);
}
if (files::isDeletable($sCurrentImagesDir . 'min3-' . $aCurrentImages[$iImgId]['img_name'])) {
unlink($sCurrentImagesDir . 'min3-' . $aCurrentImages[$iImgId]['img_name']);
}
if (files::isDeletable($sCurrentImagesDir . 'min4-' . $aCurrentImages[$iImgId]['img_name'])) {
unlink($sCurrentImagesDir . 'min4-' . $aCurrentImages[$iImgId]['img_name']);
}
if (files::isDeletable($sCurrentImagesDir . 'min5-' . $aCurrentImages[$iImgId]['img_name'])) {
unlink($sCurrentImagesDir . 'min5-' . $aCurrentImages[$iImgId]['img_name']);
}
if (files::isDeletable($sCurrentImagesDir . 'sq-' . $aCurrentImages[$iImgId]['img_name'])) {
unlink($sCurrentImagesDir . 'sq-' . $aCurrentImages[$iImgId]['img_name']);
}
# suppression du nom pour les infos de la BDD
unset($aCurrentImages[$iImgId]);
$aNewImages = array();
$j = 1;
for ($i = 1; $i <= $this->aConfig['number']; $i++) {
if (!isset($aCurrentImages[$i])) {
continue;
}
$sExtension = pathinfo($aCurrentImages[$i]['img_name'], PATHINFO_EXTENSION);
$sNewName = $j . '.' . $sExtension;
if (file_exists($sCurrentImagesDir . $aCurrentImages[$i]['img_name'])) {
rename($sCurrentImagesDir . $aCurrentImages[$i]['img_name'], $sCurrentImagesDir . $sNewName);
}
if (file_exists($sCurrentImagesDir . 'o-' . $aCurrentImages[$i]['img_name'])) {
rename($sCurrentImagesDir . 'o-' . $aCurrentImages[$i]['img_name'], $sCurrentImagesDir . 'o-' . $sNewName);
}
if (file_exists($sCurrentImagesDir . 'min-' . $aCurrentImages[$i]['img_name'])) {
rename($sCurrentImagesDir . 'min-' . $aCurrentImages[$i]['img_name'], $sCurrentImagesDir . 'min-' . $sNewName);
}
if (file_exists($sCurrentImagesDir . 'min2-' . $aCurrentImages[$i]['img_name'])) {
rename($sCurrentImagesDir . 'min2-' . $aCurrentImages[$i]['img_name'], $sCurrentImagesDir . 'min2-' . $sNewName);
}
if (file_exists($sCurrentImagesDir . 'min3-' . $aCurrentImages[$i]['img_name'])) {
rename($sCurrentImagesDir . 'min3-' . $aCurrentImages[$i]['img_name'], $sCurrentImagesDir . 'min3-' . $sNewName);
}
if (file_exists($sCurrentImagesDir . 'min4-' . $aCurrentImages[$i]['img_name'])) {
rename($sCurrentImagesDir . 'min4-' . $aCurrentImages[$i]['img_name'], $sCurrentImagesDir . 'min4-' . $sNewName);
}
if (file_exists($sCurrentImagesDir . 'min5-' . $aCurrentImages[$i]['img_name'])) {
rename($sCurrentImagesDir . 'min5-' . $aCurrentImages[$i]['img_name'], $sCurrentImagesDir . 'min5-' . $sNewName);
}
if (file_exists($sCurrentImagesDir . 'sq-' . $aCurrentImages[$i]['img_name'])) {
rename($sCurrentImagesDir . 'sq-' . $aCurrentImages[$i]['img_name'], $sCurrentImagesDir . 'sq-' . $sNewName);
}
# récupération des infos des images
$aNewImages[$j] = self::getImagesFilesInfos($sCurrentImagesDir, $sCurrentImagesUrl, $sNewName);
$j++;
}
if (!util::dirHasFiles($sCurrentImagesDir)) {
files::deltree($sCurrentImagesDir);
}
return array_filter($aNewImages);
}
示例6: foreach
if (!empty($_POST['buttons'])) {
foreach ($_POST['buttons'] as $plugin_name => $button_name) {
$plugins[$plugin_name]['button'] = $button_name;
}
}
$core->blog->settings->dcCKEditorAddons->put('plugins', json_encode($plugins), 'string');
if ($_POST['action'] == 'activate') {
$verb = 'activated';
} else {
$verb = 'deactivated';
}
dcPage::addSuccessNotice(sprintf(__('Selected addon has been ' . $verb . '.', 'Selected (%d) addons have been ' . $verb . '.', count($_POST['plugins'])), count($_POST['plugins'])));
http::redirect($p_url);
} elseif ($_POST['action'] == 'delete') {
try {
foreach ($_POST['plugins'] as $plugin_name) {
if (!files::deltree($dcckeditor_addons_repository_path . '/' . $dcckeditor_addons_plugins[$plugin_name]['path'])) {
throw new Exception(sprintf(__('Cannot remove addon "%s" files'), $plugin_name));
}
unset($plugins[$plugin_name]);
}
dcPage::addSuccessNotice(sprintf(__('Selected addon has been deleted.', 'Selected (%d) addons have been deleted.', count($_POST['plugins'])), count($_POST['plugins'])));
$core->blog->settings->dcCKEditorAddons->put('plugins', json_encode($plugins), 'string');
} catch (Exception $e) {
dcPage::addErrorNotice($e->getMessage());
}
http::redirect($p_url);
}
}
}
include __DIR__ . '/tpl/index.tpl';
示例7: dotclearUpgrade
//.........这里部分代码省略.........
continue;
}
$f = $root . '/daInstaller/_disabled';
if (!file_exists($f)) {
@file_put_contents($f, '');
}
}
}
if (version_compare($version, '2.5.1', '<=')) {
// Flash enhanced upload no longer needed
@unlink(DC_ROOT . '/' . 'inc/swf/swfupload.swf');
}
if (version_compare($version, '2.6', '<=')) {
// README has been replaced by README.md and CONTRIBUTING.md
@unlink(DC_ROOT . '/' . 'README');
// trackbacks are now merged into posts
@unlink(DC_ROOT . '/' . 'admin/trackbacks.php');
# daInstaller has been integrated to the core.
# Try to remove it
$path = explode(PATH_SEPARATOR, DC_PLUGINS_ROOT);
foreach ($path as $root) {
if (!is_dir($root) || !is_readable($root)) {
continue;
}
if (substr($root, -1) != '/') {
$root .= '/';
}
if (($p = @dir($root)) === false) {
continue;
}
if (($d = @dir($root . 'daInstaller')) === false) {
continue;
}
files::deltree($root . '/daInstaller');
}
# Some settings change, prepare db queries
$strReqFormat = 'INSERT INTO ' . $core->prefix . 'setting';
$strReqFormat .= ' (setting_id,setting_ns,setting_value,setting_type,setting_label)';
$strReqFormat .= ' VALUES(\'%s\',\'system\',\'%s\',\'string\',\'%s\')';
$strReqSelect = 'SELECT count(1) FROM ' . $core->prefix . 'setting';
$strReqSelect .= ' WHERE setting_id = \'%s\'';
$strReqSelect .= ' AND setting_ns = \'system\'';
$strReqSelect .= ' AND blog_id IS NULL';
# Add date and time formats
$date_formats = array('%Y-%m-%d', '%m/%d/%Y', '%d/%m/%Y', '%Y/%m/%d', '%d.%m.%Y', '%b %e %Y', '%e %b %Y', '%Y %b %e', '%a, %Y-%m-%d', '%a, %m/%d/%Y', '%a, %d/%m/%Y', '%a, %Y/%m/%d', '%B %e, %Y', '%e %B, %Y', '%Y, %B %e', '%e. %B %Y', '%A, %B %e, %Y', '%A, %e %B, %Y', '%A, %Y, %B %e', '%A, %Y, %B %e', '%A, %e. %B %Y');
$time_formats = array('%H:%M', '%I:%M', '%l:%M', '%Hh%M', '%Ih%M', '%lh%M');
if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') {
$date_formats = array_map(create_function('$f', 'return str_replace(\'%e\',\'%#d\',$f);'), $date_formats);
}
$rs = $core->con->select(sprintf($strReqSelect, 'date_formats'));
if ($rs->f(0) == 0) {
$strReq = sprintf($strReqFormat, 'date_formats', serialize($date_formats), 'Date formats examples');
$core->con->execute($strReq);
}
$rs = $core->con->select(sprintf($strReqSelect, 'time_formats'));
if ($rs->f(0) == 0) {
$strReq = sprintf($strReqFormat, 'time_formats', serialize($time_formats), 'Time formats examples');
$core->con->execute($strReq);
}
# Add repository URL for themes and plugins as daInstaller move to core
$rs = $core->con->select(sprintf($strReqSelect, 'store_plugin_url'));
if ($rs->f(0) == 0) {
$strReq = sprintf($strReqFormat, 'store_plugin_url', 'http://update.dotaddict.org/dc2/plugins.xml', 'Plugins XML feed location');
$core->con->execute($strReq);
}
$rs = $core->con->select(sprintf($strReqSelect, 'store_theme_url'));
示例8: deleteModule
public function deleteModule($id, $disabled = false)
{
if ($disabled) {
$p =& $this->disabled;
} else {
$p =& $this->modules;
}
if (!isset($p[$id])) {
throw new Exception(__('No such module.'));
}
if (!files::deltree($p[$id]['root'])) {
throw new Exception(__('Cannot remove module files'));
}
}
示例9: removeAssetsFiles
protected function removeAssetsFiles($sAssetsDir, $aLockedFiles = array())
{
$aFiles = files::getDirList($sAssetsDir);
foreach ($aFiles['files'] as $sFiles) {
if (!in_array($sFiles, $aLockedFiles)) {
unlink($sFiles);
}
}
foreach (array_reverse($aFiles['dirs']) as $sDir) {
if (!util::dirHasFiles($sDir)) {
files::deltree($sDir);
}
}
return true;
}
示例10: deleteUser
/**
* Suppression d'un utilisateur.
*
* @param $id
* @return boolean
*/
public function deleteUser($id)
{
$rsUser = $this->getUsers(array('id' => $id));
if ($rsUser->isEmpty()) {
$this->error->set(sprintf(__('m_users_error_user_%s_not_exists'), $id));
return false;
}
# si on veut supprimer un super-admin alors il faut vérifier qu'il y en as d'autres
if ($rsUser->group_id == oktAuth::superadmin_group_id) {
$iCountSudo = $this->getUsers(array('group_id' => oktAuth::superadmin_group_id), true);
if ($iCountSudo < 2) {
$this->error->set(__('m_users_error_cannot_remove_last_super_administrator'));
return false;
}
}
# si on veut supprimer un admin alors il faut vérifier qu'il y en as d'autres
if ($rsUser->group_id == oktAuth::admin_group_id) {
$iCountAdmin = $this->getUsers(array('group_id' => oktAuth::admin_group_id), true);
if ($iCountAdmin < 2) {
$this->error->set(__('m_users_error_cannot_remove_last_administrator'));
return false;
}
}
$sQuery = 'DELETE FROM ' . $this->t_users . ' ' . 'WHERE id=' . (int) $id;
if (!$this->db->execute($sQuery)) {
return false;
}
$this->db->optimize($this->t_users);
# delete user custom fields
if ($this->config->enable_custom_fields) {
$this->fields->delUserValue($id);
}
# delete user directory
$user_dir = $this->upload_dir . $id . '/';
if (files::isDeletable($user_dir)) {
files::deltree($user_dir);
}
return true;
}
示例11: header
header('Location: tools.php?p=toolsmng');
exit;
}
}
}
# Changement de status d'un plugin
$switch = !empty($_GET['switch']) ? $_GET['switch'] : '';
if ($is_writable && $switch != '' && in_array($switch, array_keys($plugins_list)) && $switch != 'toolsmng') {
$plugins->switchStatus($switch);
header('Location: tools.php?p=toolsmng');
exit;
}
# Suppression d'un thème
$delete = !empty($_GET['delete']) ? $_GET['delete'] : '';
if ($is_writable && $delete != '' && in_array($delete, array_keys($plugins_list)) && $delete != 'toolsmng') {
files::deltree($plugins_root . '/' . $delete);
header('Location: tools.php?p=toolsmng');
exit;
}
if ($err != '') {
buffer::str('<div class="erreur"><p><strong>' . __('Error(s)') . ' :</strong></p>' . $err . '</div>');
}
buffer::str('<h2>' . __('Plugins manager') . '</h2>' . '<h3>' . __('Install a plugin') . '</h3>');
if (!$is_writable) {
buffer::str('<p>' . sprintf(__('The folder %s is not writable, please check its permissions.'), DC_ECRIRE . '/tools/') . '</p>');
} else {
buffer::str('<form action="tools.php" method="get">' . '<p><label for="tool_url">' . __('Please give the URL (http or ftp) of the plugin\'s file') . ' :</label>' . form::field('tool_url', 50, '', $tool_url) . '</p>' . '<p><input type="submit" class="submit" value="' . __('install') . '" />' . '<input type="hidden" name="p" value="toolsmng" /></p>' . '</form>');
}
buffer::str('<p><a href="http://www.wikini.net">' . __('Install new plugins') . '</a></p>');
# Traduction des plugins
foreach ($plugins_list as $k => $v) {
示例12: __
}
}
/* Traitements
------------------------------------------------------------*/
/* Affichage
------------------------------------------------------------*/
# En-tête
$title = __('i_end_' . $_SESSION['okt_install_process_type'] . '_title');
require OKT_INSTAL_DIR . '/header.php';
?>
<p><?php
_e('i_end_' . $_SESSION['okt_install_process_type'] . '_congrat');
?>
</p>
<p><?php
printf(__('i_end_connect'), './../' . OKT_ADMIN_DIR . '/' . OKT_ADMIN_LOGIN_PAGE . '?user_id=' . $user . '&user_pwd=' . $password);
?>
</p>
<?php
# Pied de page
require OKT_INSTAL_DIR . '/footer.php';
# destroy session data
$_SESSION = array();
session_destroy();
if (defined('OKT_ENVIRONMENT') && OKT_ENVIRONMENT == 'prod') {
@files::deltree(OKT_INSTAL_DIR, true);
}
示例13: deleteOktPublicCacheFiles
/**
* Supprime les fichiers cache public d'Okatea
*
* @return void
*/
public static function deleteOktPublicCacheFiles($bForce = false)
{
$aCacheFiles = self::getOktPublicCacheFiles($bForce);
foreach ($aCacheFiles as $file) {
if (is_dir(OKT_PUBLIC_PATH . '/cache/' . $file)) {
files::deltree(OKT_PUBLIC_PATH . '/cache/' . $file);
} else {
unlink(OKT_PUBLIC_PATH . '/cache/' . $file);
}
}
}
示例14: sprintf
message_die(GENERAL_MESSAGE, $message);
exit;
}
break;
case 'supprime':
// on veut supprimer son mod
if (!$plugins->supprime($titre, $id_mod)) {
$message = $lang['mod_non_supprime'] . '<br /><br />';
$message .= sprintf($lang['Click_return_areabb_mods'], '<a href="' . append_sid('admin_areabb_mods.' . $phpEx) . '">', '</a>');
message_die(GENERAL_MESSAGE, $message);
exit;
}
// On vire le dossier du site
load_function('lib.files');
$mod = new files();
$mod->deltree(CHEMIN_MODS . $titre);
break;
}
// --------------------------------------------------------------------------------------------
// RECUPERATION des mods déjà installés et NON installés
//
$sql = 'SELECT id_mod, nom
FROM ' . AREABB_MODS . '
ORDER BY nom ASC';
if (!($result = $db->sql_query($sql))) {
message_die(GENERAL_ERROR, "Impossible d'afficher la liste des blocs", '', __LINE__, __FILE__, $sql);
}
$listes_mods = array();
$liste_id = array();
while ($row = $db->sql_fetchrow($result)) {
$listes_mods[] = $row['nom'];
示例15: array
}
$iItemId = $okt->galleries->items->addItem($okt->galleries->items->openItemCursor(array('gallery_id' => $iGalleryId, 'active' => 1)), $aItemLocalesData);
$sDestination = $okt->galleries->upload_dir . '/img/items/' . $iItemId . '/1.' . $sFileExtension;
files::makeDir(dirname($sDestination), true);
$oZip->unzip($sFileName, $sDestination);
$aNewImagesInfos = $okt->galleries->items->getImageUploadInstance()->buildImagesInfos($iItemId, array(1 => basename($sDestination)));
if (isset($aNewImagesInfos[1])) {
$aNewItemImages = $aNewImagesInfos[1];
$aNewItemImages['original_name'] = utf8_encode(basename($sFileName));
} else {
$aNewItemImages = array();
}
$okt->galleries->items->updImages($iItemId, $aNewItemImages);
}
$oZip->close();
files::deltree($sTempDir);
} catch (Exception $e) {
$okt->error->set($e->getMessage());
}
if ($okt->error->isEmpty()) {
$okt->galleries->items->regenMinImages($iGalleryId);
$okt->redirect('module.php?m=galleries&action=items&gallery_id=' . $iGalleryId);
}
}
/* Affichage
----------------------------------------------------------*/
$okt->page->addButton('galleriesBtSt', array('permission' => true, 'title' => __('c_c_action_Go_back'), 'url' => $iGalleryId ? 'module.php?m=galleries&action=items&gallery_id=' . $iGalleryId : 'module.php?m=galleries&action=index', 'ui-icon' => 'arrowreturnthick-1-w'), 'before');
$okt->page->addGlobalTitle(__('m_galleries_zip_main_title'));
# Récupération de la liste complète des galeries
$rsGalleries = $okt->galleries->tree->getGalleries(array('language' => $okt->user->language, 'active' => 2));
# Lang switcher