当前位置: 首页>>代码示例>>PHP>>正文


PHP recursive_remove_directory函数代码示例

本文整理汇总了PHP中recursive_remove_directory函数的典型用法代码示例。如果您正苦于以下问题:PHP recursive_remove_directory函数的具体用法?PHP recursive_remove_directory怎么用?PHP recursive_remove_directory使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了recursive_remove_directory函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: clean_d

 function clean_d()
 {
     $dh1 = opendir(ROOT_PATH . '/d/');
     if (!$dh1) {
         return;
     }
     # Error
     while (($file1 = readdir($dh1)) !== false) {
         if ($file1[0] == '.' || !is_dir(ROOT_PATH . '/d/' . $file1)) {
             continue;
         }
         # Hidden
         # Clean sub-d level 1
         $dh2 = opendir(ROOT_PATH . '/d/' . $file1);
         if (!$dh2) {
             continue;
         }
         # Error
         while (($file2 = readdir($dh2)) !== false) {
             if ($file2[0] == '.' || !is_dir(ROOT_PATH . '/d/' . $file1 . '/' . $file2)) {
                 continue;
             }
             # Hidden
             # Okay, we got key!
             $code = $file1 . $file2;
             $res = ldb_select_one('upload', array('id'), $code, 'code');
             if (!$res && !ldb_error()) {
                 # Delete this fuck'n file
                 echo 'Deleting: ' . ROOT_PATH . '/d/' . $file1 . '/' . $file2 . "\n";
                 recursive_remove_directory(ROOT_PATH . '/d/' . $file1 . '/' . $file2);
             }
         }
     }
 }
开发者ID:petrows,项目名称:Upload-service,代码行数:34,代码来源:del_files.php

示例2: recursive_remove_directory

/**
 * Recursively delete an entire directory.
 *
 * @since 4.6
 * @package all
 * @param string $directory The dir you want to remove.
 * @param bool $empty Should the dir remain empty?
 * @return bool
 */
function recursive_remove_directory($directory, $empty = false)
{
    if (substr($directory, -1) == '/') {
        $directory = substr($directory, 0, -1);
    }
    if (!file_exists($directory) || !is_dir($directory)) {
        return false;
    } elseif (is_readable($directory)) {
        $handle = opendir($directory);
        while (false !== ($item = readdir($handle))) {
            if ($item != '.' && $item != '..') {
                $path = $directory . '/' . $item;
                if (is_dir($path)) {
                    recursive_remove_directory($path);
                } else {
                    unlink($path);
                }
            }
        }
        closedir($handle);
        if (!$empty) {
            if (!rmdir($directory)) {
                return false;
            }
        }
    }
    return true;
}
开发者ID:billcreswell,项目名称:plucke,代码行数:37,代码来源:functions.all.php

示例3: actionClear

 public function actionClear()
 {
     $type = isset($_REQUEST['type']) ? $_REQUEST['type'] : 'cache';
     switch ($type) {
         case 'cache':
             if (Yii::app()->cache instanceof CApcCache) {
                 // Not support Cache for APC Cache
                 user()->setFlash('error', t('cms', 'Not support for APC Cache!'));
             } else {
                 if (Yii::app()->cache->flush()) {
                     user()->setFlash('success', t('cms', 'Cache cleared!'));
                 } else {
                     user()->setFlash('error', t('cms', 'Error whilte clearing cache!'));
                 }
             }
             break;
         case 'asset':
             # Clear Asset Cache
             $path = Yii::getPathOfAlias('webroot.assets');
             $get_sub_folders = get_subfolders_name($path);
             foreach ($get_sub_folders as $folder) {
                 recursive_remove_directory($path . DIRECTORY_SEPARATOR . $folder);
             }
             user()->setFlash('success', t('cms', 'Assets cleared!'));
             break;
     }
     $this->redirect(Yii::app()->createUrl('cache/default/index'));
 }
开发者ID:pramana08,项目名称:GXC-CMS-2,代码行数:28,代码来源:DefaultController.php

示例4: unlinkRecursive

 /**
  * @param string $directory
  * @param bool $deleteDir
  * @return success
  * implementation from http://lixlpixel.org/recursive_function/php/recursive_directory_delete/
  */
 public static function unlinkRecursive($directory, $deleteDir = FALSE)
 {
     if (substr($directory, -1) == '/') {
         $directory = substr($directory, 0, -1);
     }
     if (!file_exists($directory) || !is_dir($directory)) {
         return FALSE;
     } elseif (is_readable($directory)) {
         $handle = opendir($directory);
         while (FALSE !== ($item = readdir($handle))) {
             if ($item != '.' && $item != '..') {
                 $path = $directory . '/' . $item;
                 if (is_dir($path)) {
                     recursive_remove_directory($path);
                 } else {
                     unlink($path);
                 }
             }
         }
         closedir($handle);
         if ($deleteDir == FALSE) {
             if (!rmdir($directory)) {
                 return FALSE;
             }
         }
     }
     return TRUE;
 }
开发者ID:jasir,项目名称:testbase,代码行数:34,代码来源:Tools.php

示例5: __construct

 public function __construct()
 {
     $this->baseDirectory = 'renders/' . Season::getInstance()->nefub_id . '/' . date('Y') . '_wk' . date('W');
     parent::__construct();
     if (isset($_GET['clear']) && $_GET['clear'] == 1 && (isset($_GET['clearall']) && $_GET['clearall'] == 1)) {
         recursive_remove_directory($this->baseDirectory);
     }
 }
开发者ID:rjpijpker,项目名称:nefub-mobile,代码行数:8,代码来源:FrontRenderer.php

示例6: recursive_remove_directory

function recursive_remove_directory($directory, $empty = TRUE)
{
    // if the path has a slash at the end we remove it here
    if (substr($directory, -1) == '../cache') {
        $directory = substr($directory, 0, -1);
    }
    // if the path is not valid or is not a directory ...
    if (!file_exists($directory) || !is_dir($directory)) {
        // ... we return false and exit the function
        return FALSE;
        // ... if the path is not readable
    } elseif (!is_readable($directory)) {
        // ... we return false and exit the function
        return FALSE;
        // ... else if the path is readable
    } else {
        // we open the directory
        $handle = opendir($directory);
        // and scan through the items inside
        while (FALSE !== ($item = readdir($handle))) {
            // if the filepointer is not the current directory
            // or the parent directory
            if ($item != '.' && $item != '..') {
                // we build the new path to delete
                $path = $directory . '/' . $item;
                // if the new path is a directory
                if (is_dir($path)) {
                    // we call this function with the new path
                    recursive_remove_directory($path);
                    // if the new path is a file
                } else {
                    // we remove the file
                    unlink($path);
                }
            }
        }
        // close the directory
        closedir($handle);
        // if the option to empty is not set to true
        if ($empty == FALSE) {
            // try to delete the now empty directory
            if (!rmdir($directory)) {
                // return false if not possible
                return FALSE;
            }
        }
        //rebuild blank index.html files
        $html = '';
        file_put_contents('../cache/index.html', $html);
        file_put_contents('../cache/admin_c/index.html', $html);
        file_put_contents('../cache/templates_c/index.html', $html);
        // return success
        return TRUE;
    }
}
开发者ID:Grprashanthkumar,项目名称:ColfusionWeb,代码行数:55,代码来源:admin_delete_cache.php

示例7: build

 /**
  *
  * @global  $htmlwarrior
  * @param string site_name What site to build
  */
 public function build($arr = array())
 {
     global $htmlwarrior, $txt;
     $site_path = $htmlwarrior->config['basepath'] . '/' . $arr['site_name'];
     // cleanup - delete contents of build dir prior to copy and compile
     recursive_remove_directory($site_path . '/' . $htmlwarrior->config['build_dir'], true);
     // compile templates
     // todo: also compile loggedin templates
     $files = array();
     if ($handle = opendir($site_path . '/templates/pages')) {
         while (false !== ($file = readdir($handle))) {
             if ($file != '.' && $file != '..') {
                 $tpl_files[] = $file;
             }
         }
         closedir($handle);
         foreach ($tpl_files as $tpl_file) {
             file_get_contents($htmlwarrior->config['baseurl'] . '/' . $arr['site_name'] . '/' . str_replace('.tpl', '.html', $tpl_file) . '?debug=0');
         }
     }
     // copy dirs to build dir
     // all except build, templates, overlays and cfg
     $site_root_files = glob($site_path . '/*');
     foreach ($site_root_files as $path) {
         if (is_dir($path)) {
             // check if dir is templates dir
             $path_templates = str_replace('/', '\\/', $htmlwarrior->config['path_templates']);
             $is_templates_dir = preg_match('/' . $path_templates . '$/imsU', $path, $mt);
             // check if dir is cfg dir
             $path_cfg = str_replace('/', '\\/', $htmlwarrior->config['path_cfg']);
             $is_cfg_dir = preg_match('/' . $path_cfg . '$/imsU', $path, $mt);
             // check if dir is build dir
             $path_build = str_replace('/', '\\/', $htmlwarrior->config['path_build']);
             $is_build_dir = preg_match('/' . $path_build . '$/imsU', $path, $mt);
             // check if dir is overlays dir
             $path_overlays = str_replace('/', '\\/', $htmlwarrior->config['path_overlays']);
             $is_overlays_dir = preg_match('/' . $path_overlays . '$/imsU', $path, $mt);
             if (!$is_templates_dir && !$is_cfg_dir && !$is_build_dir && !$is_overlays_dir) {
                 $dir = end(explode('/', $path));
                 $target = $site_path . '/' . $htmlwarrior->config['build_dir'] . '/' . $dir;
                 recursive_remove_directory($target);
                 full_copy($path, $target);
             }
         }
     }
     printf($txt['site_build_done'], $arr['site_name'], $arr['return_url']);
 }
开发者ID:halka139,项目名称:html-warrior,代码行数:52,代码来源:site.php

示例8: recursive_remove_directory

/**
 *
 * Will remove a directory deleting all its files.
 *
 * @see http://lixlpixel.org/recursive_function/php/recursive_directory_delete/
 **/
function recursive_remove_directory($directory, $empty = FALSE)
{
    if (substr($directory, -1) == '/') {
        $directory = substr($directory, 0, -1);
    }
    if (!file_exists($directory) || !is_dir($directory)) {
        return FALSE;
    } elseif (!is_readable($directory)) {
        return FALSE;
    } else {
        $handle = opendir($directory);
        while (FALSE !== ($item = readdir($handle))) {
            // if the filepointer is not the current directory
            // or the parent directory
            if ($item != '.' && $item != '..') {
                // we build the new path to delete
                $path = $directory . '/' . $item;
                // if the new path is a directory
                if (is_dir($path)) {
                    // we call this function with the new path
                    recursive_remove_directory($path);
                    // if the new path is a file
                } else {
                    // we remove the file
                    unlink($path);
                }
            }
        }
        // close the directory
        closedir($handle);
        // if the option to empty is not set to true
        if ($empty == FALSE) {
            // try to delete the now empty directory
            if (!rmdir($directory)) {
                // return false if not possible
                return FALSE;
            }
        }
        // return success
        return TRUE;
    }
}
开发者ID:nnset,项目名称:OpenDocumentParserComponent,代码行数:48,代码来源:AppController.php

示例9: delete

 /**
  * Proxies deleting a folder to the restore.php version
  *
  * @param   string  $folderName  The path to the folder to be deleted
  *
  * @return  void
  *
  * @since   3.5.1
  */
 public static function delete($folderName)
 {
     recursive_remove_directory($folderName);
 }
开发者ID:lyrasoft,项目名称:lyrasoft.github.io,代码行数:13,代码来源:restore_finalisation.php

示例10: while

             //izbriše definicijo
             $db->query('DELETE FROM cms_modules_def WHERE ID=' . $id . '');
         }
     }
     echo "ok";
     exit;
 } else {
     if ($db->filter('type') == 'DD_#com') {
         $id = $crypt->decrypt($db->filter('id'));
         $query = $db->fetch($db->query('SELECT ID, componentName, tables FROM cms_components_def WHERE ID="' . $id . '"'));
         //izbris datotek
         $q = $db->query('SELECT name FROM cms_domains');
         while ($r = $db->fetch($q)) {
             if (is_dir('../../modules/' . $r['name'] . '/' . $query['componentName'])) {
                 recursive_remove_directory('../../modules/' . $query['componentName']);
                 recursive_remove_directory('../modules/' . $query['componentName']);
             }
         }
         //izbris iz system.xml
         if (ob_get_length() > 0) {
             ob_end_clean();
         }
         header('Content-Type: text/xml;charset=UTF-8');
         $xdoc = new DOMDocument('1.0', 'UTF-8');
         $xdoc->formatOutput = true;
         $xdoc->preserveWhiteSpace = false;
         $xdoc->load('../modules/system.xml');
         $xmlDialog = $xdoc->getElementsByTagName('dialog')->item(0);
         $newItems = $xmlDialog->getElementsByTagName('item');
         $length = $newItems->length;
         for ($i = $length - 1; $i >= 0; $i--) {
开发者ID:NejcZdovc,项目名称:sumo2,代码行数:31,代码来源:trash.php

示例11: cleanCacheDir

 public static function cleanCacheDir($aCacheGroup = self::GROUP_GLOBAL)
 {
     recursive_remove_directory(CACHEDIR_ROOT . $aCacheGroup);
 }
开发者ID:Gninety,项目名称:Microweber,代码行数:4,代码来源:MY_CacheGroups.php

示例12: delete

 public function delete($book_id = 0)
 {
     if (empty($book_id)) {
         return false;
     }
     $this->load->helper('directory');
     $this->db->select('slug');
     $this->db->from($this->books_table);
     $this->db->where('book_id', $book_id);
     $query = $this->db->get();
     $result = $query->result();
     if (!isset($result[0])) {
         throw new Exception('Could not find book');
     }
     $slug = $result[0]->slug;
     if (empty($slug)) {
         die('Could not determine slug.');
     }
     if (file_exists($slug) && !recursive_remove_directory($slug)) {
         die('Could not remove directory from file structure.');
     }
     $CI =& get_instance();
     $CI->load->model('page_model', 'pages');
     // NOTE: loading a model within a model
     $pages = $CI->pages->get_all($book_id);
     foreach ($pages as $page) {
         $CI->pages->delete($page->content_id);
         usleep(500);
         // .0005 seconds -- let MySQL locked tables catch up
     }
     $this->db->where('book_id', $book_id);
     $this->db->delete($this->books_table);
     $this->db->where('book_id', $book_id);
     $this->db->delete($this->user_book_table);
     return true;
 }
开发者ID:austinvernsonger,项目名称:scalar,代码行数:36,代码来源:book_model.php

示例13: end

     $extension = end(explode('.', $oldFile));
     $path = str_replace($oldFile, '', $old);
     if (rename($old, $path . $newName . '.' . $extension)) {
         echo 'done';
     } else {
         echo 'problem - ' . $old . ' - ' . $path . $newName . '.' . $extension;
     }
 } else {
     if ($db->is('delete')) {
         $old = $db->filter('path');
         unlink($old);
         echo 'ok';
     } else {
         if ($db->is('deletef')) {
             $old = $db->filter('path');
             recursive_remove_directory($old);
             echo 'ok';
         } else {
             if ($db->is('renamef')) {
                 $old = $db->filter('path');
                 $newName = $db->filter('name');
                 $oldFile = end(explode('/', $old));
                 $new = str_replace($oldFile, $newName, $old);
                 if (rename($old, $new)) {
                     echo 'done';
                 } else {
                     echo 'problem - ' . $old . ' - ' . $new;
                 }
             } else {
                 if ($db->is('newf')) {
                     $old = $db->filter('path');
开发者ID:NejcZdovc,项目名称:sumo2,代码行数:31,代码来源:file.manager.php

示例14: header

    FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
    OTHER DEALINGS IN THE SOFTWARE.
*/
$_page_title = $step_desc[$language] . " " . (array_search($_GET['step'], $_SESSION['steps']) + 1) . " - " . $webgen_delete_title[$language];
// spracovanie formulara
if (count($_POST)) {
    // sem spracovanie/osetrenie prislich premennych
    // presmerovani zpet na editaci
    $next_step = "3";
    $next_type = "all";
    header("Location: ./index.php?step={$next_step}&type={$next_type}");
    exit;
}
echo "<h1>" . $webgen_delete_title[$language] . "</h1>";
if (strlen($_SESSION['step_all_2']['user_name']) > 2 && strlen($_SESSION['step_all_3']['delete_presentation_name']) > 2) {
    if (recursive_remove_directory("./presentations/" . $_SESSION['step_all_2']['user_name'] . "/" . $_SESSION['step_all_3']['delete_presentation_name'])) {
        echo "<h2 class=\"ok\">" . $webgen_delete_info[$language] . " " . $_SESSION['step_all_3']['delete_presentation_name'] . " " . $webgen_delete_info2[$language] . "</h2>";
    } else {
        echo "<h2 class=\"error\">" . $webgen_delete_error[$language] . "</h2>";
    }
} else {
    echo "<h2 class=\"error\">" . $webgen_delete_error[$language] . "</h2>";
}
?>

<form action="<?php 
echo $_SERVER['REQUEST_URI'];
?>
" method="post">
    <input name="empty" type="hidden" />
    
开发者ID:xplhak,项目名称:WebGen,代码行数:30,代码来源:step_delete_4.php

示例15: check_referrer

include '../config.php';
include mnminclude . 'html1.php';
include mnminclude . 'link.php';
include mnminclude . 'user.php';
include mnminclude . 'smartyvariables.php';
check_referrer();
// require user to log in
force_authentication();
// restrict access to admins
$canIhaveAccess = 0;
$canIhaveAccess = $canIhaveAccess + checklevel('admin');
if ($canIhaveAccess == 0) {
    header("Location: " . getmyurl('admin_login', $_SERVER['REQUEST_URI']));
    die;
}
recursive_remove_directory('../cache', TRUE);
?>
<div class="modal-dialog">
	<div class="modal-content">
		<div class="modal-header">
			<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
			<h4 class="modal-title"><?php 
echo $main_smarty->get_config_vars('PLIGG_Visual_AdminPanel_Cleared_Cache');
?>
</h4>
		</div>
		<div class="modal-body">
			<p><?php 
echo $main_smarty->get_config_vars('PLIGG_Visual_AdminPanel_Cleared_Cache_Message');
?>
</p>
开发者ID:hyrmedia,项目名称:pligg-cms,代码行数:31,代码来源:admin_delete_cache.php


注:本文中的recursive_remove_directory函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。