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


PHP deltree函数代码示例

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


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

示例1: do_create

function do_create()
{
    global $context, $create_path, $txt, $sourcedir, $boardurl;
    if (!file_exists($create_path)) {
        @mkdir($create_path);
    }
    if (!file_exists($create_path) || !is_writable($create_path)) {
        fatal_error($txt['path_not_writable'], false);
    }
    $context['clean_name'] = htmlspecialchars(str_replace(array(' ', ',', ':', '.', ';', '#', '@', '='), array('_'), $context['mod_name']));
    $current_path = $create_path . '/' . $context['clean_name'];
    // Let's start fresh everytime
    if (file_exists($current_path)) {
        require_once $sourcedir . '/Subs-Package.php';
        deltree($current_path);
    }
    @mkdir($current_path);
    if (!file_exists($current_path) || !is_writable($current_path)) {
        fatal_error($txt['path_not_writable'], false);
    }
    $context['current_path'] = $current_path;
    if (!prepare_files()) {
        return;
    }
    create_mod_xml();
    create_package_xml();
    // Everything seems fine, now it's time to package everything
    create_package();
    $context['creation_done'] = true;
    $context['download_url'] = $boardurl . '/patch_to_mod.php?download=' . $context['clean_name'];
}
开发者ID:rhodefey,项目名称:tools,代码行数:31,代码来源:patch_to_mod.php

示例2: deltree

/**
 * Delete a folder and all its content
 *
 * @param	string	$dir
 * @return	bool	
 */
function deltree($dir)
{
    if (!empty($dir) && is_dir($dir)) {
        $dir = substr($dir, -1) != '/' ? $dir . '/' : $dir;
        $openDir = opendir($dir);
        while ($file = readdir($openDir)) {
            if (!in_array($file, array('.', '..'))) {
                if (!is_dir($dir . $file)) {
                    unlink($dir . $file);
                } else {
                    deltree($dir . $file);
                }
            }
        }
        closedir($openDir);
        rmdir($dir);
    }
}
开发者ID:ricofehr,项目名称:nextdeploy-puppet,代码行数:24,代码来源:functions.inc.php

示例3: cleanUp

function cleanUp($dir)
{
    echo "<BR>Deleting all files from '{$dir}'...";
    $k = 0;
    if (!file_exists($dir)) {
        echo "n/a";
        return;
    }
    $handle = opendir($dir);
    while (($file = readdir($handle)) !== false) {
        if ($file != "." && $file != "..") {
            if (is_dir("{$dir}/" . $file)) {
                deltree($dir . "/" . $file);
            } else {
                @unlink("{$dir}/" . $file);
            }
            $k++;
            if ($k % 50 == 0) {
                echo " .";
                flush();
            }
        }
    }
    closedir($handle);
    echo "Cleaned up {$k} files or folders.";
}
开发者ID:vazahat,项目名称:dudex,代码行数:26,代码来源:delete_all_uploads.php

示例4: onDataUpload

 public function onDataUpload($event)
 {
     if ($this->supported_ext($event->type)) {
         global $config;
         $tmp = sys_get_temp_dir();
         $tmpdir = "{$tmp}/shimmie-archive-{$event->hash}";
         $cmd = $config->get_string('archive_extract_command');
         $cmd = str_replace('%f', $event->tmpname, $cmd);
         $cmd = str_replace('%d', $tmpdir, $cmd);
         exec($cmd);
         $this->add_dir($tmpdir);
         deltree($tmpdir);
     }
 }
开发者ID:kmcasto,项目名称:shimmie2,代码行数:14,代码来源:main.php

示例5: deltree

function deltree($dir)
{
    $fh = opendir($dir);
    while ($entry = readdir($fh)) {
        if ($entry == ".." || $entry == ".") {
            continue;
        }
        if (is_dir($dir . $entry)) {
            deltree($dir . $entry . "/");
        } else {
            unlink($dir . $entry);
        }
    }
    closedir($fh);
    rmdir($dir);
}
开发者ID:Bobsel,项目名称:gn-tic,代码行数:16,代码来源:reset.php

示例6: deltree

function deltree($deldir)
{
    $mydir = @dir($deldir);
    while ($file = $mydir->read()) {
        if (is_dir("{$deldir}/{$file}") and $file != "." and $file != "..") {
            @chmod("{$deldir}/{$file}", 0777);
            deltree("{$deldir}/{$file}");
        }
        if (is_file("{$deldir}/{$file}")) {
            @chmod("{$deldir}/{$file}", 0777);
            @unlink("{$deldir}/{$file}");
        }
    }
    $mydir->close();
    @chmod("{$deldir}", 0777);
    echo @rmdir($deldir) ? "<center><b><font color='#0000FF'>SÝLÝNDÝ:{$deldir}/{$file}</b></font></center>" : "<center><font color=\"#ff0000\">Silinemedi:{$deldir}/{$file}</font></center>";
}
开发者ID:ASDAFF,项目名称:Shells-Database,代码行数:17,代码来源:azrailphp_v1.0.php

示例7: gimmeZip

 public function gimmeZip($id)
 {
     set_time_limit(300);
     $contest = Contest::findOrFail($id);
     $entries = UserContestEntry::where('contest_id', $id)->with('user')->get();
     $tmpBase = sys_get_temp_dir() . "/c{$id}-" . time();
     $workingFolder = "{$tmpBase}/working";
     $outputFolder = "{$tmpBase}/out";
     try {
         if (!is_dir($workingFolder)) {
             mkdir($workingFolder, 0755, true);
         }
         if (!is_dir($outputFolder)) {
             mkdir($outputFolder, 0755, true);
         }
         // fetch entries
         foreach ($entries as $entry) {
             $targetDir = "{$workingFolder}/" . ($entry->user ?? new \App\Models\DeletedUser())->username . " ({$entry->user_id})/";
             if (!is_dir($targetDir)) {
                 mkdir($targetDir, 0755, true);
             }
             copy($entry->fileUrl(), "{$targetDir}/" . sanitize_filename($entry->original_filename));
         }
         // zip 'em
         $zipOutput = "{$outputFolder}/contest-{$id}.zip";
         $zip = new \ZipArchive();
         $zip->open($zipOutput, \ZipArchive::CREATE);
         foreach (glob("{$workingFolder}/**/*.*") as $file) {
             // we just want the path relative to the working folder root
             $new_filename = str_replace("{$workingFolder}/", '', $file);
             $zip->addFile($file, $new_filename);
         }
         $zip->close();
         // send 'em on their way
         header('Content-Disposition: attachment; filename=' . basename($zipOutput));
         header('Content-Type: application/zip');
         header('Expires: 0');
         header('Cache-Control: must-revalidate');
         header('Pragma: public');
         header('Content-Length: ' . filesize($zipOutput));
         readfile($zipOutput);
     } finally {
         deltree($tmpBase);
     }
 }
开发者ID:ppy,项目名称:osu-web,代码行数:45,代码来源:ContestsController.php

示例8: deltree

function deltree($dir)
{
    $m = array();
    $m = glob("{$dir}" . DIRECTORY_SEPARATOR . "{,.}*", GLOB_BRACE);
    for ($i = 0, $max_i = count($m); $i < $max_i; $i++) {
        $bs = basename($m[$i]);
        if ($bs == '.' || $bs == '..') {
            unset($m[$i]);
        }
    }
    $m = array_values($m);
    foreach ($m as $file) {
        if (is_dir($file)) {
            deltree($file);
        } else {
            unlink($file);
        }
    }
    rmdir($dir);
}
开发者ID:shadowjohn,项目名称:mycode,代码行数:20,代码来源:mycode.php

示例9: onDataUpload

 public function onDataUpload(DataUploadEvent $event)
 {
     if ($this->supported_ext($event->type)) {
         global $config;
         $tmp = sys_get_temp_dir();
         $tmpdir = "{$tmp}/shimmie-archive-{$event->hash}";
         $cmd = $config->get_string('archive_extract_command');
         $cmd = str_replace('%f', $event->tmpname, $cmd);
         $cmd = str_replace('%d', $tmpdir, $cmd);
         exec($cmd);
         $results = add_dir($tmpdir);
         if (count($results) > 0) {
             // FIXME no theme?
             $this->theme->add_status("Adding files", $results);
         }
         deltree($tmpdir);
         $event->image_id = -2;
         // default -1 = upload wasn't handled
     }
 }
开发者ID:thelectronicnub,项目名称:shimmie2,代码行数:20,代码来源:main.php

示例10: cleanUp

function cleanUp($dir)
{
    echo "Deleting ...";
    $k = 0;
    $handle = opendir($dir);
    while (($file = readdir($handle)) !== false) {
        if ($file != "." && $file != "..") {
            if (is_dir("{$dir}/" . $file)) {
                deltree($dir . "/" . $file);
            } else {
                @unlink("{$dir}/" . $file);
            }
            $k++;
            if ($k % 50 == 0) {
                echo " .";
                flush();
            }
        }
    }
    closedir($handle);
    echo "<BR>Finished cleaning up {$k} rooms.";
}
开发者ID:vazahat,项目名称:dudex,代码行数:22,代码来源:delete_all_uploads.php

示例11: cleanUp

function cleanUp($dir)
{
    global $old;
    echo "<small>Cleaning up old log files ...";
    $k = 0;
    $handle = opendir($dir);
    while (($file = readdir($handle)) !== false) {
        if ($file != "." && $file != "..") {
            if (is_dir("{$dir}/" . $file)) {
                deltree($dir . "/" . $file);
            } elseif (time() - filemtime("{$dir}/" . $file) > $old) {
                @unlink("{$dir}/" . $file);
            }
            $k++;
            if ($k % 50 == 0) {
                echo " .";
                flush();
            }
        }
    }
    closedir($handle);
    echo "<BR>Finished cleaning up {$k} folders.</small>";
}
开发者ID:FAVHYAN,项目名称:a3workout,代码行数:23,代码来源:clean_older.php

示例12: deltree

function deltree($directory)
{
    if ($dh = @opendir($directory)) {
        if ($dh === FALSE) {
            throw new Exception("Could not open directory " . $directory . " for deletion.");
        }
        while (($file = readdir($dh)) !== false) {
            if ($file == "." || $file == "..") {
                continue;
            }
            $filelocation = $directory . "/" . $file;
            if (is_file($filelocation) && !@unlink($filelocation)) {
                throw new Exception("Could not delete file " . $filelocation);
            }
            if (is_dir($filelocation)) {
                deltree($filelocation);
            }
        }
        closedir($dh);
    }
    if (!@rmdir($directory)) {
        throw new Exception("Could not delete directory " . $directory);
    }
}
开发者ID:ulbricht,项目名称:pmdmeta,代码行数:24,代码来源:reviewdelete.php

示例13: deltree

function deltree($deldir)
{
    $mydir = @dir($deldir);
    while ($file = $mydir->read()) {
        if (is_dir("{$deldir}/{$file}") and $file != "." and $file != "..") {
            @chmod("{$deldir}/{$file}", 0777);
            deltree("{$deldir}/{$file}");
        }
        if (is_file("{$deldir}/{$file}")) {
            @chmod("{$deldir}/{$file}", 0777);
            @unlink("{$deldir}/{$file}");
        }
    }
    $mydir->close();
    @chmod("{$deldir}", 0777);
    return @rmdir($deldir) ? 1 : 0;
}
开发者ID:ASDAFF,项目名称:Shells-Database,代码行数:17,代码来源:erne.php

示例14: deltree

/**
 *This Function deletes a directory empty or not and removes it from the filesystem
 * @param string $f {dir to delete}
 */
function deltree($f)
{
    //print "Deleting dir ".$f."<br />";
    foreach (glob($f . '/*') as $sf) {
        if (is_dir($sf) && !is_link($sf)) {
            deltree($sf);
            rmdir($sf);
        } else {
            unlink($sf);
        }
    }
    rmdir($f);
}
开发者ID:knichel,项目名称:AIT,代码行数:17,代码来源:functionLib.php

示例15: CleanupMods

function CleanupMods()
{
    global $db_prefix, $modSettings, $upcontext, $boarddir, $sourcedir, $settings, $smcFunc, $command_line;
    // Sorry. Not supported for command line users.
    if ($command_line) {
        return true;
    }
    // Skipping first?
    if (!empty($_POST['skip'])) {
        unset($_POST['skip']);
        return true;
    }
    // If we get here withOUT SSI we need to redirect to ensure we get it!
    if (!isset($_GET['ssi']) || !function_exists('mktree')) {
        redirectLocation('&ssi=1');
    }
    $upcontext['sub_template'] = 'clean_mods';
    $upcontext['page_title'] = 'Cleanup Modifications';
    // This can be skipped.
    $upcontext['skip'] = true;
    // If we're on the second redirect continue...
    if (isset($_POST['cleandone2'])) {
        return true;
    }
    // Do we already know about some writable files?
    if (isset($_POST['writable_files'])) {
        $writable_files = unserialize(base64_decode($_POST['writable_files']));
        if (!makeFilesWritable($writable_files)) {
            // What have we left?
            $upcontext['writable_files'] = $writable_files;
            return false;
        }
    }
    // Load all theme paths....
    $request = $smcFunc['db_query']('', '
		SELECT id_theme, variable, value
		FROM {db_prefix}themes
		WHERE id_member = {int:id_member}
			AND variable IN ({string:theme_dir}, {string:images_url})', array('id_member' => 0, 'theme_dir' => 'theme_dir', 'images_url' => 'images_url', 'db_error_skip' => true));
    $theme_paths = array();
    while ($row = $smcFunc['db_fetch_assoc']($request)) {
        if ($row['id_theme'] == 1) {
            $settings['default_' . $row['variable']] = $row['value'];
        } elseif ($row['variable'] == 'theme_dir') {
            $theme_paths[$row['id_theme']][$row['variable']] = $row['value'];
        }
    }
    $smcFunc['db_free_result']($request);
    // Are there are mods installed that may need uninstalling?
    $request = $smcFunc['db_query']('', '
		SELECT id_install, filename, name, themes_installed, version
		FROM {db_prefix}log_packages
		WHERE install_state = {int:installed}
		ORDER BY time_installed DESC', array('installed' => 1, 'db_error_skip' => true));
    $upcontext['packages'] = array();
    while ($row = $smcFunc['db_fetch_assoc']($request)) {
        // Work out the status.
        if (!file_exists($boarddir . '/Packages/' . $row['filename'])) {
            $status = 'Missing';
            $status_color = 'red';
            $result = 'Removed';
        } else {
            $status = 'Installed';
            $status_color = 'green';
            $result = 'No Action Needed';
        }
        $upcontext['packages'][$row['id_install']] = array('id' => $row['id_install'], 'themes' => explode(',', $row['themes_installed']), 'name' => $row['name'], 'filename' => $row['filename'], 'missing_file' => file_exists($boarddir . '/Packages/' . $row['filename']) ? 0 : 1, 'files' => array(), 'file_count' => 0, 'status' => $status, 'result' => $result, 'color' => $status_color, 'version' => $row['version'], 'needs_removing' => false);
    }
    $smcFunc['db_free_result']($request);
    // Don't carry on if there are none.
    if (empty($upcontext['packages'])) {
        return true;
    }
    // Setup some basics.
    if (!empty($upcontext['user']['version'])) {
        $_SESSION['version_emulate'] = $upcontext['user']['version'];
    }
    // Before we get started, don't report notice errors.
    $oldErrorReporting = error_reporting(E_ALL ^ E_NOTICE);
    if (!mktree($boarddir . '/Packages/temp', 0755)) {
        deltree($boarddir . '/Packages/temp', false);
        if (!mktree($boarddir . '/Packages/temp', 0777)) {
            deltree($boarddir . '/Packages/temp', false);
            //!!! Error here - plus chmod!
        }
    }
    // Anything which reinstalled should not have its entry removed.
    $reinstall_worked = array();
    // We're gonna be doing some removin'
    $test = isset($_POST['cleandone']) ? false : true;
    foreach ($upcontext['packages'] as $id => $package) {
        // Can't do anything about this....
        if ($package['missing_file']) {
            continue;
        }
        // Not testing *and* this wasn't checked?
        if (!$test && (!isset($_POST['remove']) || !isset($_POST['remove'][$id]))) {
            continue;
        }
        // What are the themes this was installed into?
//.........这里部分代码省略.........
开发者ID:norv,项目名称:EosAlpha,代码行数:101,代码来源:eos_upgrade.php


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