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


PHP delete_directory函数代码示例

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


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

示例1: delete_directory

 function delete_directory($directory)
 {
     // Retrieve all of the files
     $files = glob($directory . '*', GLOB_MARK);
     // Check if files exist
     if ($files) {
         // Files exist, loop through each file
         foreach ($files as $file) {
             // Check if file is a folder
             if (substr($file, -1) == '/') {
                 // File is a folder, delete the folder
                 delete_directory($file);
             } else {
                 // File is a file, delete the file
                 unlink($file);
             }
         }
     }
     // Check if the directory exists
     if (is_dir($directory)) {
         // Directory exists, remove the directory
         rmdir($directory);
         // Return TRUE
         return TRUE;
     } else {
         // Directory doesn't exist, return FALSE
         return FALSE;
     }
 }
开发者ID:BsWiM,项目名称:The-Clan-CMS-Project,代码行数:29,代码来源:ClanCMS_directory_helper.php

示例2: delete_tmp_files

/**
 * This function delete temp files (mostly image temporaly serialize data)
 */
function delete_tmp_files()
{
    if (function_exists(sys_get_temp_dir)) {
        $dir = sys_get_temp_dir();
    } else {
        $dir = "/tmp";
    }
    if ($dh = opendir($dir)) {
        while (($file = readdir($dh)) !== false) {
            if (strpos("___" . $file, "integria_serialize") || strpos("___" . $file, "tmpIntegriaFileSharing")) {
                if (file_exists($dir . "/" . $file)) {
                    if (is_dir($dir . "/" . $file)) {
                        delete_directory($dir . "/" . $file);
                    } else {
                        $fdate = filemtime($dir . "/" . $file);
                        $now = time();
                        if ($now - $fdate > 3600) {
                            @unlink($dir . "/" . $file);
                        }
                    }
                }
            }
        }
        closedir($dh);
    }
}
开发者ID:keunes,项目名称:integriaims,代码行数:29,代码来源:integria_cron.php

示例3: delete_directory

function delete_directory($dirname)
{
    global $db_path, $msgstr;
    $ix = strlen($db_path);
    $dir_handle = false;
    if (is_dir($dirname)) {
        echo "<p>" . $msgstr["dirname"] . ": " . substr($dirname, $ix) . "<br>";
        $dir_handle = opendir($dirname);
    }
    if (!$dir_handle) {
        return false;
    }
    while ($file = readdir($dir_handle)) {
        if ($file != "." && $file != "..") {
            echo $msgstr["file"] . ": " . $file . "<br>";
            if (!is_dir($dirname . "/" . $file)) {
                unlink($dirname . "/" . $file);
            } else {
                delete_directory("{$dirname}" . '/' . $file);
            }
        }
    }
    closedir($dir_handle);
    rmdir($dirname);
    return true;
}
开发者ID:rgevaert,项目名称:ABCD,代码行数:26,代码来源:eliminarbd.php

示例4: delete_directory

function delete_directory($directory)
{
    foreach (glob("{$directory}/*") as $file) {
        if (is_dir($file)) {
            delete_directory($file);
        } else {
            unlink($file);
        }
    }
    rmdir($directory);
}
开发者ID:vasiliy-mk,项目名称:apartment-rent,代码行数:11,代码来源:helpers.php

示例5: delete_directory

/**
 * Delete a directory.
 *
 * @param string $dir    the directory deleting
 * @return boolean whether success true
 *
 */
function delete_directory($dir)
{
    $deleteOk = true;
    $current_dir = opendir($dir);
    while ($entryname = readdir($current_dir)) {
        if (is_dir("{$dir}/{$entryname}") && ($entryname != "." && $entryname != '..')) {
            delete_directory("{$dir}/{$entryname}");
        } elseif ($entryname != '.' && $entryname != '..') {
            unlink("{$dir}/{$entryname}");
        }
    }
    closedir($current_dir);
    rmdir(${dir} . "/");
    return $deleteOk;
}
开发者ID:rhertzog,项目名称:lcs,代码行数:22,代码来源:course.lib.inc.php

示例6: delete_directory

function delete_directory($dir)
{
    if ($dh = @opendir($dir)) {
        while (($file = readdir($dh)) != false) {
            if ($file == "." || $file == "..") {
                continue;
            }
            if (is_dir($dir . '/' . $file)) {
                delete_directory($dir . '/' . $file);
            } else {
                unlink($dir . '/' . $file);
            }
        }
        @closedir($dh);
        rmdir($dir);
    }
}
开发者ID:kikoseijo,项目名称:sunny-php-ado,代码行数:17,代码来源:files.php

示例7: delete_files

function delete_files($path, $del_dir = FALSE)
{
    if (!($current_dir = @opendir($path))) {
        return;
    }
    while ($filename = @readdir($current_dir)) {
        if (@is_dir($path . '/' . $filename) and ($filename != "." and $filename != "..")) {
            delete_directory($path . '/' . $filename, TRUE);
        } elseif ($filename != "." and $filename != "..") {
            @unlink($path . '/' . $filename);
        }
    }
    @closedir($current_dir);
    if ($del_dir == TRUE) {
        @rmdir($path);
    }
}
开发者ID:Calico90,项目名称:codeigniter-version-scan,代码行数:17,代码来源:file_helper.php

示例8: delete_directory

function delete_directory($dirname) {
   if (is_dir($dirname))
      $dir_handle = opendir($dirname);
   if (!$dir_handle)
      return false;
   while($file = readdir($dir_handle)) {
      if ($file != "." && $file != "..") {
         if (!is_dir($dirname."/".$file))
            unlink($dirname."/".$file);
         else
            delete_directory($dirname.'/'.$file);
      }
   }
   closedir($dir_handle);
   rmdir($dirname);
   return true;
}
开发者ID:TrinataBhayanaka,项目名称:simbada-tangsel,代码行数:17,代码来源:proses_upload_photo.php

示例9: delete_directory

function delete_directory($dir)
{
    if (!file_exists($dir)) {
        return true;
    }
    if (!is_dir($dir)) {
        return unlink($dir);
    }
    foreach (scandir($dir) as $item) {
        if ($item == '.' || $item == '..') {
            continue;
        }
        if (!delete_directory($dir . DIRECTORY_SEPARATOR . $item)) {
            return false;
        }
    }
    return rmdir($dir);
}
开发者ID:famoser,项目名称:onepagecreator,代码行数:18,代码来源:fileshelper.php

示例10: delete_directory

function delete_directory($dir)
{
    if ($handle = opendir($dir)) {
        $array = array();
        while (false !== ($file = readdir($handle))) {
            if ($file != "." && $file != "..") {
                if (is_dir($dir . $file)) {
                    if (!@rmdir($dir . $file)) {
                        delete_directory($dir . $file . '/');
                        // Not empty? Delete the files inside it
                    }
                } else {
                    @unlink($dir . $file);
                }
            }
        }
        closedir($handle);
        @rmdir($dir);
    }
}
开发者ID:jeffthestampede,项目名称:excelsior,代码行数:20,代码来源:DelDirectoryFnc.php

示例11: delete_directory

function delete_directory($dir)
{
    if (!preg_match("/\\/\$/", $dir)) {
        $dir .= '/';
    }
    if ($handle = @opendir($dir)) {
        while (strlen($file = readdir($handle))) {
            if ($file != '.' && $file != '..') {
                if (is_dir($dir . $file)) {
                    if (!@rmdir($dir . $file)) {
                        delete_directory($dir . $file . '/');
                    }
                } else {
                    @unlink($dir . $file);
                }
            }
        }
    }
    @closedir($handle);
    @rmdir($dir);
}
开发者ID:Staalkoper,项目名称:microweber-hosting-scripts,代码行数:21,代码来源:file-util.php

示例12: index

 public function index($page = 0)
 {
     if ($_POST) {
         if (!is_dir(MODULEPATH)) {
             mkdir(MODULEPATH, 0777);
         }
         if ($this->Parameter->_get('network_proxy') !== '') {
             $context = stream_context_create(array('http' => array('proxy' => 'tcp://' . $this->Parameter->_get('network_proxy'))));
             file_put_contents(MODULEPATH . "/module.zip", fopen($_POST['url'], 'r', false, $context));
         } else {
             file_put_contents(MODULEPATH . "/module.zip", fopen($_POST['url'], 'r'));
         }
         $zip = new ZipArchive();
         if ($zip->open(MODULEPATH . '/module.zip') === TRUE) {
             $zip->extractTo(MODULEPATH);
             $zip->close();
             $name = explode('-', $_POST['name']);
             chmod(MODULEPATH . '/module.zip', 0777);
             if (is_dir(MODULEPATH . '/' . $name[0])) {
                 delete_directory(MODULEPATH . '/' . $_POST['name']);
             } else {
                 rename(MODULEPATH . '/' . $_POST['name'], MODULEPATH . '/' . $name[0]);
             }
             if (file_exists(MODULEPATH . '/' . $name[0] . '/database.sql')) {
                 $queries = file(MODULEPATH . '/' . $name[0] . '/database.sql');
                 for ($i = 0; $i < count($queries); $i++) {
                     $this->db->query($queries[$i]);
                 }
             }
             $this->data['message_type'] = "success";
             $this->data['message'] = 'Module Installed into "' . MODULEPATH . '/' . $name[0] . '"';
             unlink(MODULEPATH . '/module.zip');
         }
     }
     $this->load->library('GitHubClient');
     $this->githubclient->setCredentials('brajola', 'h4n6iui0');
     $this->data['available_modules'] = $this->githubclient->repos->listUserRepositories('brajola');
     $this->render();
 }
开发者ID:brajola,项目名称:dashboard,代码行数:39,代码来源:Installer.php

示例13: handleUpload

 /**
  * Returns array('success'=>true) or array('error'=>'error message')
  */
 function handleUpload($uploadDirectory, $random_dir, $p_api_id, $replaceOldFile = FALSE)
 {
     $uploadDirectory .= '/' . $random_dir . '/';
     if (!is_writable($uploadDirectory)) {
         return array('error' => "Server error. Upload directory isn't writable.");
     }
     if (!$this->file) {
         return array('error' => 'No files were uploaded.');
     }
     $size = $this->file->getSize();
     if ($size == 0) {
         return array('error' => 'File is empty');
     }
     if ($size > $this->sizeLimit) {
         return array('error' => 'File is too large');
     }
     $pathinfo = pathinfo($this->file->getName());
     $filename = $pathinfo['filename'];
     //$filename = md5(uniqid());
     $ext = @$pathinfo['extension'];
     // hide notices if extension is empty
     if ($this->allowedExtensions && !in_array(strtolower($ext), $this->allowedExtensions)) {
         $these = implode(', ', $this->allowedExtensions);
         return array('error' => 'File has an invalid extension, it should be one of ' . $these . '.');
     }
     $ext = $ext == '' ? $ext : '.' . $ext;
     if (!$replaceOldFile) {
         /// don't overwrite previous files that were uploaded
         while (file_exists($uploadDirectory . $filename . $ext)) {
             $filename .= rand(10, 99);
         }
     }
     $this->uploadName = $filename . $ext;
     if ($this->file->save($uploadDirectory . $filename . $ext)) {
         // If file pushed to temp directory, push it to MMC agent
         $filename = $filename . $ext;
         $upload_tmp_dir = sys_get_temp_dir();
         $files = array();
         // If mmc-agent is not on the same machine than apache server
         // send binary files with XMLRPC (base64 encoded)
         // else mmc-agent will directly get it from tmp directory
         $mmc_ip = xmlrpc_getMMCIP();
         $local_mmc = in_array($mmc_ip, array('127.0.0.1', 'localhost', $_SERVER['SERVER_ADDR'])) ? True : False;
         $filebinary = False;
         if (!$local_mmc) {
             $file = $upload_tmp_dir . '/' . $random_dir . '/' . $filename;
             // Read and put content of $file to $filebinary
             $filebinary = fread(fopen($file, "r"), filesize($file));
         }
         $files[] = array("filename" => $filename, "filebinary" => $local_mmc ? False : base64_encode($filebinary), "tmp_dir" => $local_mmc ? $upload_tmp_dir : False);
         $push_package_result = pushPackage($p_api_id, $random_dir, $files, $local_mmc);
         // Delete package from PHP /tmp dir
         delete_directory($upload_tmp_dir . '/' . $random_dir);
         if (!isXMLRPCError() and $push_package_result) {
             return array('success' => true);
         } else {
             return array('error' => 'Could not save uploaded file.' . 'The upload was cancelled, or server error encountered');
         }
     } else {
         return array('error' => 'Could not save uploaded file.' . 'The upload was cancelled, or server error encountered');
     }
 }
开发者ID:sebastiendu,项目名称:mmc,代码行数:65,代码来源:fileuploader.php

示例14: session_start

<?php

session_start();
if (!isset($_SESSION["user_id"])) {
    header("location: ../index.php");
    exit;
}
require_once "../../classes/db_class.php";
require_once "includes/functions.php";
$objDb = new db();
$data = array();
if (isset($_GET["id"]) && $_GET["id"] != "" && $_GET["id"] != 1) {
    $sqlLanguage = "select * from job_language where id = " . $_GET["id"] . "";
    $resultLang = $objDb->ExecuteQuery($sqlLanguage);
    $rowCount = mysql_num_rows($resultLang);
    if ($rowCount == 1) {
        $rsLang = mysql_fetch_object($resultLang);
        delete_directory("../../langues/" . $rsLang->language_name . "/");
        $sql = "ALTER TABLE `language` DROP `" . $rsLang->language_shortname . "`";
        $result = $objDb->ExecuteQuery($sql);
        $objDb->DeleteData("job_language", "id", $_GET["id"]);
    }
}
header("location:index.php");
开发者ID:beyondkeysystem,项目名称:testone,代码行数:24,代码来源:remove_language.php

示例15: delete_directory

/**
 * Deletes a folder and its contents (recursive)
 * TODO: error checking
 *
 * @param string $folder_path
 */
function delete_directory($dir)
{
    if (!file_exists($dir)) {
        return false;
    }
    if (!($dh = @opendir($dir))) {
        return false;
    }
    while (false !== ($obj = readdir($dh))) {
        if ($obj == '.' || $obj == '..') {
            continue;
        }
        if (!@unlink($dir . '/' . $obj)) {
            delete_directory($dir . '/' . $obj);
        }
    }
    @closedir($dh);
    return @rmdir($dir);
}
开发者ID:sauruscms,项目名称:Saurus-CMS-Community-Edition,代码行数:25,代码来源:adminpage.inc.php


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