本文整理汇总了PHP中rm_full_dir函数的典型用法代码示例。如果您正苦于以下问题:PHP rm_full_dir函数的具体用法?PHP rm_full_dir怎么用?PHP rm_full_dir使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rm_full_dir函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: rm_full_dir
/**
* Function to remove a non-empty directory
*
* @param string $directory
* @return boolean
*/
function rm_full_dir($directory)
{
// If suplied dirname is a file then unlink it
if (is_file($directory)) {
return unlink($directory);
}
// Empty the folder
if (is_dir($directory)) {
$dir = dir($directory);
while (false !== ($entry = $dir->read())) {
// Skip pointers
if ($entry == '.' || $entry == '..') {
continue;
}
// Deep delete directories
if (is_dir($directory . '/' . $entry)) {
rm_full_dir($directory . '/' . $entry);
} else {
unlink($directory . '/' . $entry);
}
}
// Now delete the folder
$dir->close();
return rmdir($directory);
}
}
示例2: cleanup
function cleanup()
{
if (0 == func_num_args()) {
return true;
}
$all_args = func_get_args();
foreach ($all_args as &$file) {
if (true === file_exists($file)) {
if (true === is_dir($file)) {
rm_full_dir($file);
} else {
unlink($file);
}
}
}
return true;
}
示例3: rename_recursive_dirs
function rename_recursive_dirs($dirsource, $dirdest, $deep = 0)
{
if (true === is_dir($dirsource)) {
$dir = dir($dirsource);
while ($file = $dir->read()) {
if ($file[0] != ".") {
if (!is_dir($dirsource . "/" . $file)) {
copy($dirsource . "/" . $file, $dirdest . "/" . $file);
change_mode($dirdest . "/" . $file);
} else {
make_dir($dirdest . "/" . $file);
rename_recursive_dirs($dirsource . "/" . $file, $dirdest . '/' . $file, $deep + 1);
}
}
}
$dir->close();
}
if ($deep == 0) {
rm_full_dir($dirsource);
}
return true;
}
示例4: while
}
// Run the modules uninstall script if there is one
if (file_exists(LEPTON_PATH . '/modules/' . $file . '/uninstall.php')) {
$temp_css = LEPTON_PATH . '/modules/' . $file . '/backend.css';
if (file_exists($temp_css)) {
echo "\n<link href=\"" . (LEPTON_URL . '/modules/' . $file . '/backend.css') . " rel=\"stylesheet\" type=\"text/css\" media=\"screen, projection\" />\n";
} else {
$temp_css = LEPTON_PATH . '/modules/' . $file . '/css/backend.css';
if (file_exists($temp_css)) {
echo "\n<link href=\"" . (LEPTON_URL . '/modules/' . $file . '/css/backend.css') . " rel=\"stylesheet\" type=\"text/css\" media=\"screen, projection\" />\n";
}
}
require LEPTON_PATH . '/modules/' . $file . '/uninstall.php';
}
// Try to delete the module dir
if (!rm_full_dir(LEPTON_PATH . '/modules/' . $file)) {
$admin->print_error($MESSAGE['GENERIC_CANNOT_UNINSTALL']);
} else {
// Remove entry from DB
$database->query("DELETE FROM " . TABLE_PREFIX . "addons WHERE directory = '" . $file . "' AND type = 'module'");
}
// remove module permissions
$stmt = $database->query('SELECT * FROM `' . TABLE_PREFIX . 'groups` WHERE `group_id` <> 1');
if ($stmt->numRows() > 0) {
while ($row = $stmt->fetchRow(MYSQL_ASSOC)) {
$gid = $row['group_id'];
// get current value
$modules = explode(',', $row['module_permissions']);
// remove uninstalled module
if (in_array($file, $modules)) {
$i = array_search($file, $modules);
示例5: wb_handle_export
function wb_handle_export($filename = 'drop_export', $export_id = 0)
{
global $database, $admin, $MESSAGE;
$name = NULL;
$list = isset($_POST['markeddroplet']) ? $_POST['markeddroplet'] : array();
if ($export_id != 0) {
$list = $export_id;
}
if (!is_array($list)) {
$list = array($list);
}
if (count($list) < 1 and $export_id == 0) {
echo '<div class="drfail">Please mark some Droplets first!</div>';
return;
}
$temp_dir = WB_PATH . '/temp/droplets/';
// make the temporary working directory
@mkdir($temp_dir);
foreach ($list as $id) {
// Added by PCWacht
// Get id - needed $admin to be global!
if (version_compare(WB_VERSION, '2.8.2', '>=') && WB_VERSION != "2.8.x" and $export_id == 0) {
$id = $admin->checkIDKEY($id, false, '');
if (!$id) {
$admin->print_error($MESSAGE['GENERIC_SECURITY_ACCESS']);
exit;
}
}
// End add
$result = $database->query("SELECT * FROM " . TABLE_PREFIX . "mod_droplets WHERE id='{$id}'");
if ($result->numRows() > 0) {
$droplet = $result->fetchRow();
$name = $droplet["name"];
echo 'Saving: ' . $name . '.php<br />';
$sFile = $temp_dir . $name . '.php';
$fh = fopen($sFile, 'w');
fwrite($fh, '//:' . $droplet['description'] . "\n");
fwrite($fh, '//:' . str_replace("\n", " ", $droplet['comments']) . "\n");
fwrite($fh, $droplet['code']);
fclose($fh);
}
}
// if there's only a single droplet to export, name the zip-file after this droplet
if (count($list) === 1) {
$filename = 'droplet_' . $name;
}
// add current date to filename
$filename .= '_' . date('Y-m-d-His');
// while there's an existing file, add a number to the filename
if (file_exists(WB_PATH . '/temp/' . $filename . '.zip')) {
$n = 1;
while (file_exists(WB_PATH . '/temp/' . $filename . '_' . $n . '.zip')) {
$n++;
}
$filename .= '_' . $n;
}
$temp_file = WB_PATH . '/temp/' . $filename . '.zip';
// create zip
require_once WB_PATH . '/include/pclzip/pclzip.lib.php';
$archive = new PclZip($temp_file);
$file_list = $archive->create($temp_dir, PCLZIP_OPT_REMOVE_ALL_PATH);
if ($file_list == 0) {
echo "Packaging error: ", $archive->errorInfo(true), "<br />";
die("Error : " . $archive->errorInfo(true));
} else {
// create the export folder if it doesn't exist
if (!file_exists(WB_PATH . '/modules/droplets/export')) {
mkdir(WB_PATH . '/modules/droplets/export');
}
if (!copy($temp_file, WB_PATH . '/modules/droplets/export/' . $filename . '.zip')) {
echo '<div class="drfail">Unable to move the exported ZIP-File!</div>';
$download = WB_URL . '/temp/' . $filename . '.zip';
} else {
unlink($temp_file);
$download = WB_URL . '/modules/droplets/export/' . $filename . '.zip';
}
echo '<div class="drok">Backup created - <a href="' . $download . '">Download</a></div>';
}
rm_full_dir($temp_dir);
}
示例6: rm_full_dir
} else {
$tpl->parse('show_settings', 'show_settings_block', true);
}
$tpl->set_block('main_block', 'show_admintools_block', 'show_admintools');
if ($admin->get_permission('admintools') != true) {
$tpl->set_var('DISPLAY_ADMINTOOLS', 'display:none;');
$tpl->set_block('show_admintools', '');
} else {
$tpl->parse('show_admintools', 'show_admintools_block', true);
}
/**
* Try to delete install directory - it's still not needed anymore.
* Additional check for the user to be logged in with administrator-rights.
*/
if (file_exists(LEPTON_PATH . '/install/') && in_array(1, $admin->get_groups_id())) {
$result = rm_full_dir(LEPTON_PATH . '/install/');
if (false === $result) {
/**
* Removing the install directory failed! So we are
* in the need to throw an error-message to the user.
*/
$tpl->set_var("WARNING", "<br />" . $MESSAGE['START_INSTALL_DIR_EXISTS'] . "<br />");
}
}
// Insert "Add-ons" section overview (pretty complex compared to normal)
$addons_overview = $TEXT['MANAGE'] . ' ';
$addons_count = 0;
if ($admin->get_permission('modules') == true) {
$addons_overview .= '<a href="' . ADMIN_URL . '/modules/index.php">' . $MENU['MODULES'] . '</a>';
$addons_count = 1;
}
示例7: array
$values = array('type' => 'Template', 'type_name' => $file, 'pages' => $add);
$msg = replace_all($msg_template_str, $values);
$page_names = "";
while ($data = $info->fetchRow()) {
$page_info = array('id' => $data['page_id'], 'title' => $data['page_title']);
$page_names .= replace_all($page_template_str, $page_info);
}
/**
* Printing out the error-message and die().
*/
$admin->print_error($MESSAGE['GENERIC_CANNOT_UNINSTALL_IN_USE'] . $msg . $page_names);
}
}
// Check if we have permissions on the directory
if (!is_writable(WB_PATH . '/templates/' . $file)) {
$admin->print_error($MESSAGE['GENERIC_CANNOT_UNINSTALL'] . WB_PATH . '/templates/' . $file);
}
// Try to delete the template dir
if (!rm_full_dir(WB_PATH . '/templates/' . $file)) {
$admin->print_error($MESSAGE['GENERIC_CANNOT_UNINSTALL']);
} else {
// Remove entry from DB
$database->query("DELETE FROM " . TABLE_PREFIX . "addons WHERE directory = '" . $file . "' AND type = 'template'");
}
// Update pages that use this template with default template
// $database = new database();
$database->query("UPDATE " . TABLE_PREFIX . "pages SET template = '" . DEFAULT_TEMPLATE . "' WHERE template = '{$file}'");
// Print success message
$admin->print_success($MESSAGE['GENERIC_UNINSTALLED']);
// Print admin footer
$admin->print_footer();
示例8: PclZip
$archive = new PclZip($temp_file);
// extract Add-on files into WBCE temp folder
$addon_root_path = find_addon_root_path($archive);
$list = $archive->extract(PCLZIP_OPT_PATH, $temp_unzip, PCLZIP_CB_PRE_EXTRACT, 'pclzip_extraction_filter', PCLZIP_OPT_REPLACE_NEWER);
// Check if uploaded file is a valid Add-On zip file
if (!($list && file_exists($temp_unzip . 'info.php'))) {
$admin->print_error($MESSAGE['GENERIC_INVALID_ADDON_FILE']);
}
// Include module info file
unset($module_directory);
require $temp_unzip . 'info.php';
// Perform Add-on requirement checks before proceeding
require WB_PATH . '/framework/addon.precheck.inc.php';
preCheckAddon($temp_file);
// Delete temporary unzip directory
rm_full_dir($temp_unzip);
// Check if the file is valid
if (!isset($module_directory)) {
if (file_exists($temp_file)) {
unlink($temp_file);
}
// Remove temp file
$admin->print_error($MESSAGE['GENERIC_INVALID']);
}
// Check if this module is already installed
// and compare versions if so
$new_module_version = $module_version;
$action = "install";
if (is_dir(WB_PATH . '/modules/' . $module_directory)) {
if (file_exists(WB_PATH . '/modules/' . $module_directory . '/info.php')) {
require WB_PATH . '/modules/' . $module_directory . '/info.php';
示例9: build_page
//.........这里部分代码省略.........
$rimg = new RESIZEIMAGE($target_path . '/' . $filename);
$rimg->resize_limitwh($pathsettings[$resizepath]['width'], $pathsettings[$resizepath]['height'], $target_path . '/' . $filename);
$rimg->close();
}
}
}
// store file name of first file for possible unzip action
if ($x == 1) {
$filename1 = $target_path . '/' . $filename;
}
}
}
}
}
if (isset($_POST['delzip'])) {
if (file_exists($filename1)) {
unlink($filename1);
}
}
if ($good_uploads == 1) {
$admin->print_success($good_uploads . ' ' . $MESSAGE['MEDIA_SINGLE_UPLOADED'], $backlink);
} else {
$admin->print_success($good_uploads . ' ' . $MESSAGE['MEDIA_UPLOADED'], $backlink);
}
break;
case 'media_create':
// $directory = rawurldecode(trim(stripslashes($admin->get_post('current_dir'))));
// Remove bad characters from user folder name
$target = $admin->get_post('target') != null ? media_filename(trim(stripslashes($admin->get_post('target')))) : $current_dir;
$userPath = LEPTON_PATH . MEDIA_DIRECTORY;
$err_msg = array();
if ($target == null || $target == $current_dir) {
$err_msg[] = $MESSAGE['MEDIA_BLANK_NAME'];
} else {
// Try and make the dir
$target = trim($target, '.');
$dirname = $userPath . $current_dir . '/' . $target;
if (file_exists($dirname)) {
$err_msg[] = $MESSAGE['MEDIA_DIR_EXISTS'];
} else {
if (make_dir($dirname)) {
change_mode($dirname);
if (is_writable($dirname)) {
// Create default "index.php" file
$rel_pages_dir = str_replace(LEPTON_PATH . MEDIA_DIRECTORY, '', dirname($dirname));
$step_back = str_repeat('../', substr_count($rel_pages_dir, '/') + 1);
$content = '<?php' . "\n";
$content .= '// This file is generated by LEPTON Ver.' . VERSION . ';' . "\n";
$content .= "\t" . 'header(\'Location: ' . $step_back . 'index.php\');' . "\n";
$content .= '?>';
$filename = $dirname . '/index.php';
// write content into file
$handle = fopen($filename, 'w');
fwrite($handle, $content);
fclose($handle);
change_mode($filename, 'file');
} else {
$err_msg[] = $MESSAGE['GENERIC_BAD_PERMISSIONS'];
}
} else {
$err_msg[] = $MESSAGE['GENERIC_BAD_PERMISSIONS'];
}
}
}
if (sizeof($err_msg) > 0) {
$admin->print_error(implode('<br />', $err_msg));
} else {
$admin->print_success($MESSAGE['MEDIA_DIR_MADE'], $backlink);
}
break;
case 'media_delete':
$filetype = isset($_POST['filetype']) ? trim(stripslashes($admin->get_post('filetype'))) : '';
$filename = isset($_POST['filename']) ? trim(stripslashes($admin->get_post('filename'))) : '';
$relative_path = LEPTON_PATH . MEDIA_DIRECTORY . $directory;
// Find out whether its a file or folder
if ($filetype == 'dir') {
// Try and delete the directory
if (rm_full_dir($relative_path . '/' . $filename)) {
$admin->print_success($MESSAGE['MEDIA_DELETED_DIR'], $backlink);
} else {
$admin->print_error($MESSAGE['MEDIA_CANNOT_DELETE_DIR'], $backlink);
}
} elseif ($filetype == 'file') {
// Try and delete the file
if (unlink($relative_path . '/' . $filename)) {
$admin->print_success($MESSAGE['MEDIA_DELETED_FILE'], $backlink);
} else {
$admin->print_error($MESSAGE['MEDIA_CANNOT_DELETE_FILE'], $backlink);
}
} else {
$admin->print_error($MESSAGE['MEDIA_CANNOT_DELETE_FILE'], $backlink);
}
break;
}
// Parse template for preferences form
$tpl->parse('main', 'main_wrapper_block', false);
$tpl->parse('main', 'main_block', false);
$output = $tpl->finish($tpl->parse('output', 'page'));
return $output;
}
示例10: while
* @copyright 2004-2010 WebsiteBaker Project
* @copyright 2010-2015 LEPTON Project
* @link http://www.LEPTON-cms.org
* @license http://www.gnu.org/licenses/gpl.html
* @license_terms please see info.php of this module
*
*/
// include class.secure.php to protect this file and the whole CMS!
if (defined('LEPTON_PATH')) {
include LEPTON_PATH . '/framework/class.secure.php';
} else {
$oneback = "../";
$root = $oneback;
$level = 1;
while ($level < 10 && !file_exists($root . '/framework/class.secure.php')) {
$root .= $oneback;
$level += 1;
}
//( $level < 10 ) && ( !file_exists( $root . '/framework/class.secure.php' ) )
if (file_exists($root . '/framework/class.secure.php')) {
include $root . '/framework/class.secure.php';
} else {
trigger_error(sprintf("[ <b>%s</b> ] Can't include class.secure.php!", $_SERVER['SCRIPT_NAME']), E_USER_ERROR);
}
}
// end include class.secure.php
// delete table
$database->query("DROP TABLE IF EXISTS `" . TABLE_PREFIX . "mod_wrapper`");
// Delete directory
rm_full_dir(LEPTON_PATH . '/modules/wrapper');
示例11: exit
<?php
/**
* @category modules
* @package wysiwyg
* @author WebsiteBaker Project, Michael Tenschert
* @copyright 2010, Michael Tenschert
* @link http://www.websitebaker2.org/
* @license http://www.gnu.org/licenses/lgpl.html
*/
// Must include code to stop this file being access directly
if (defined('WB_PATH') == false) {
exit("Cannot access this file directly");
}
// Delete the editor directory
rm_full_dir(WB_PATH . '/modules/ckeditor/ckeditor');
示例12: while
*
* @author Website Baker Project, LEPTON Project, Black Cat Development
* @copyright 2004-2010, Website Baker Project
* @copyright 2011-2012, LEPTON Project
* @copyright 2013, Black Cat Development
* @link http://blackcat-cms.org
* @license http://www.gnu.org/licenses/gpl.html
* @category CAT_Module
* @package wrapper
*
*/
if (defined('CAT_PATH')) {
include CAT_PATH . '/framework/class.secure.php';
} else {
$root = "../";
$level = 1;
while ($level < 10 && !file_exists($root . '/framework/class.secure.php')) {
$root .= "../";
$level += 1;
}
if (file_exists($root . '/framework/class.secure.php')) {
include $root . '/framework/class.secure.php';
} else {
trigger_error(sprintf("[ <b>%s</b> ] Can't include class.secure.php!", $_SERVER['SCRIPT_NAME']), E_USER_ERROR);
}
}
// delete table
$database->query("DROP TABLE IF EXISTS `" . CAT_TABLE_PREFIX . "mod_wrapper`");
// Delete the editor directory
rm_full_dir(CAT_PATH . '/modules/wrapper');
示例13: exit
exit("Cannot access this file directly");
}
// Get some default values
require_once WB_PATH . '/modules/bakery/config.php';
// Get module pages directory from general setting table
$query_general_settings = $database->query("SELECT pages_directory FROM " . TABLE_PREFIX . "mod_bakery_general_settings");
$general_settings = $query_general_settings->fetchRow();
$module_pages_directory = '/' . $general_settings['pages_directory'];
// Delete
$database->query("DELETE FROM " . TABLE_PREFIX . "search WHERE name = 'module' AND value = 'bakery'");
$database->query("DELETE FROM " . TABLE_PREFIX . "search WHERE extra = 'bakery'");
$database->query("DROP TABLE " . TABLE_PREFIX . "mod_bakery_items");
$database->query("DROP TABLE " . TABLE_PREFIX . "mod_bakery_images");
$database->query("DROP TABLE " . TABLE_PREFIX . "mod_bakery_options");
$database->query("DROP TABLE " . TABLE_PREFIX . "mod_bakery_attributes");
$database->query("DROP TABLE " . TABLE_PREFIX . "mod_bakery_item_attributes");
$database->query("DROP TABLE " . TABLE_PREFIX . "mod_bakery_customer");
$database->query("DROP TABLE " . TABLE_PREFIX . "mod_bakery_order");
$database->query("DROP TABLE " . TABLE_PREFIX . "mod_bakery_general_settings");
$database->query("DROP TABLE " . TABLE_PREFIX . "mod_bakery_page_settings");
$database->query("DROP TABLE " . TABLE_PREFIX . "mod_bakery_payment_methods");
// Include WB functions file
require_once WB_PATH . '/framework/functions.php';
$directory = WB_PATH . PAGES_DIRECTORY . $module_pages_directory;
if (is_dir($directory)) {
rm_full_dir($directory);
}
$directory = WB_PATH . MEDIA_DIRECTORY . '/' . $img_dir;
if (is_dir($directory)) {
rm_full_dir($directory);
}
示例14: opf_register_filter
if(!defined('WB_PATH')) die(header('Location: index.php'));
// experimental feature, export human-readable:
opf_register_filter({$filter_dump})
// if this fails to import, try the serialized version:
or opf_register_filter('{$filter_ser}', TRUE);
EOD;
$file_contents = array('plugin_info.php' => $file_info, 'index.php' => $file_index, 'plugin_install.php' => $file_install, 'filter.php' => $filter_func);
foreach ($file_contents as $file => $contents) {
if ($fh = fopen($temp_dir . $temp_name . '/' . $file, 'wb')) {
fputs($fh, $contents);
fclose($fh);
} else {
$export_message = sprintf($text_failed, $LANG['MOD_OPF']['TXT_WRITE_FAILED'], $temp_dir . $temp_name . '/' . $file);
rm_full_dir($temp_dir . $temp_name);
return FALSE;
}
}
// zip it
if (!$archive->create($temp_dir . $temp_name, PCLZIP_OPT_REMOVE_PATH, $temp_dir . $temp_name)) {
$export_message = sprintf($text_failed, $archive->errorInfo(true));
rm_full_dir($temp_dir . $temp_name);
return FALSE;
}
}
rm_full_dir($temp_dir . $temp_name);
$link = $temp_link . $temp_file;
$export_message = $LANG['MOD_OPF']['TXT_PLUGIN_EXPORTED'];
$export_ok = TRUE;
return $link;
// the created zip still remains in media/opf_plugins/ and should be deleted manually
示例15: wbce_handle_upload
/**
* handle import
**/
function wbce_handle_upload()
{
global $DR_TEXT, $TEXT, $database, $admin;
if (isset($_POST['cancel'])) {
return;
}
$return = '';
if (isset($_FILES['userfile']) && isset($_FILES['userfile']['name'])) {
// Set temp vars
$temp_dir = WB_PATH . '/temp/';
$temp_file = $temp_dir . $_FILES['userfile']['name'];
$temp_unzip = WB_PATH . '/temp/unzip/';
$errors = array();
// Try to upload the file to the temp dir
if (!move_uploaded_file($_FILES['userfile']['tmp_name'], $temp_file)) {
echo $DR_TEXT['Upload failed'];
return;
}
$result = wbce_unpack_and_import($temp_file, $temp_unzip);
// Delete the temp zip file
if (file_exists($temp_file)) {
unlink($temp_file);
}
rm_full_dir($temp_unzip);
// show errors
if (isset($result['errors']) && is_array($result['errors']) && count($result['errors']) > 0) {
$return = '<div style="border: 1px solid #f00; padding: 5px; color: #f00; font-weight: bold;">' . $DR_TEXT['IMPORT_ERRORS'] . "<br />\n";
foreach ($result['errors'] as $droplet => $error) {
$return .= 'Droplet: ' . $droplet . '<br />' . '<span style="padding-left: 15px">' . $error . '</span>';
}
$return .= "</div><br /><br />\n";
}
$return .= '<div class="drok">' . $result['count'] . " " . $DR_TEXT['IMPORTED'] . '</div><br /><br />';
}
$return .= wbce_twig_display(array(), 'upload', true);
return $return;
}