本文整理汇总了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;
}
}
示例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);
}
}
示例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;
}
示例4: delete_directory
function delete_directory($directory)
{
foreach (glob("{$directory}/*") as $file) {
if (is_dir($file)) {
delete_directory($file);
} else {
unlink($file);
}
}
rmdir($directory);
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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);
}
示例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);
}
}
示例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);
}
示例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();
}
示例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');
}
}
示例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");
示例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);
}