本文整理汇总了PHP中delDir函数的典型用法代码示例。如果您正苦于以下问题:PHP delDir函数的具体用法?PHP delDir怎么用?PHP delDir使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了delDir函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: delDirConts
/**
* delete directory contents
*/
function delDirConts($dir)
{
try {
if (strlen($dir) - 1 === strrpos($dir, DIRECTORY_SEPARATOR)) {
$dir = substr($dir, 0, strlen($dir) - 1);
}
$odir = scandir($dir);
foreach ($odir as $elm) {
if (0 === strcmp($elm, '.') || 0 === strcmp($elm, '..')) {
continue;
}
$ftype = filetype($dir . DIRECTORY_SEPARATOR . $elm);
if (0 === strcmp($ftype, 'dir')) {
delDir($dir . DIRECTORY_SEPARATOR . $elm);
} else {
$ret = unlink($dir . DIRECTORY_SEPARATOR . $elm);
if (false === $ret) {
throw new Exception();
}
}
}
} catch (Exception $e) {
throw $e;
}
}
示例2: delDir
function delDir($dirName)
{
if (empty($dirName)) {
return;
}
global $Message;
if (file_exists($dirName)) {
$dir = dir($dirName);
while (false !== ($file = $dir->read())) {
if ($file != '.' && $file != '..') {
if (is_dir($dirName . '/' . $file)) {
delDir($dirName . '/' . $file);
$path_dir = "<span class=\"error\">" . str_replace("./", "", $dirName) . "</span>";
$Message = sprintf(A_CHAT_LOGS_34, A_CHAT_LOGS_33, $path_dir);
} else {
$path_dir = "<span class=\"error\">" . str_replace("./", "", $dirName) . "</span>";
$path_file = "<span class=\"error\">" . str_replace("./", "", $dirName . '/' . $file) . "</span>";
@fclose($dirName . '/' . $file);
@unlink($dirName . '/' . $file) or die(sprintf(A_CHAT_LOGS_37, A_CHAT_LOGS_32, $path_dir));
$Message = sprintf(A_CHAT_LOGS_34, A_CHAT_LOGS_32, $path_file);
}
}
}
@rmdir($dirName . '/' . $file) or die(sprintf(A_CHAT_LOGS_37, A_CHAT_LOGS_33, $path_dir));
$Message = sprintf(A_CHAT_LOGS_34, A_CHAT_LOGS_33, $path_dir);
} else {
$path_dir = "<span class=\"error\">" . str_replace("./", "", $dirName) . "</span>";
$Message = sprintf(A_CHAT_LOGS_36, A_CHAT_LOGS_33, $path_dir);
}
}
示例3: delDir
function delDir($dir)
{
$files = array_diff(scandir($dir), array('.', '..'));
foreach ($files as $file) {
is_dir($dir . '/' . $file) ? delDir($dir . '/' . $file) : unlink($dir . '/' . $file);
}
return rmdir($dir);
}
示例4: exec
public function exec()
{
try {
/* check installed module */
if (false === isInstalled($this->parm)) {
/* target module is already installed */
throw new \err\ComErr('specified module is not installed', 'please check \'spac mod list\'');
}
/* confirm */
echo 'Uninstall ' . $this->parm . ' module.' . PHP_EOL;
echo 'Are you sure ?(y,n):';
$line = rtrim(fgets(STDIN), "\n");
if (!(0 === strcmp($line, 'y') || 0 === strcmp($line, 'Y'))) {
exit;
}
/* delete module files */
if (true === isDirExists(__DIR__ . '/../../mod/' . $this->parm)) {
try {
delDir(__DIR__ . '/../../mod/' . $this->parm);
} catch (\Exception $e) {
throw new \err\ComErr('could not delete ' . __DIR__ . '/../../mod/' . $this->parm, 'please check directory');
}
}
/* edit module config */
$modcnf = yaml_parse_file(__DIR__ . '/../../../../conf/module.yml');
if (false === $modcnf) {
throw new \err\ComErr('could not read module config file', 'please check ' . __DIR__ . '/../../../../conf/module.yml');
}
$newcnf = array();
foreach ($modcnf as $elm) {
if (0 === strcmp($this->parm, $elm['name'])) {
continue;
}
$newcnf[] = $elm;
}
if (0 === count($newcnf)) {
$newcnf = null;
}
if (false === copy(__DIR__ . '/../../../../conf/module.yml', __DIR__ . '/../../../../conf/module.yml_')) {
throw new \err\ComErr('could not create backup of module config', 'please check ' . __DIR__ . '/../../../../conf');
}
if (false === file_put_contents(__DIR__ . '/../../../../conf/module.yml', yaml_emit($newcnf))) {
throw new \err\ComErr('could not edit module config file', 'please check ' . __DIR__ . '/../../../../conf/module.yml');
}
unlink(__DIR__ . '/../../../../conf/module.yml_');
echo 'Successful uninstall ' . $this->parm . ' module ' . PHP_EOL;
} catch (\Exception $e) {
throw $e;
}
}
示例5: deleteUser
function deleteUser($deleteFlights = 0, $deleteFiles = 0)
{
global $db, $pilotsTable;
$err = 0;
$sql = "DELETE FROM {$pilotsTable} WHERE pilotID=" . $this->pilotID . " AND serverID=" . $this->serverID;
$res = $db->sql_query($sql);
if ($res <= 0) {
echo "Error deleting pilot from DB {$sql}<BR>";
$err = 1;
}
if ($deleteFiles) {
$pilotPath = $this->getAbsPath();
delDir($pilotPath);
}
return $err;
}
示例6: delDir
function delDir($id)
{
global $db;
$sql = "SELECT *\n\t\t\tFROM `dir_data`\n\t\t\tWHERE `dir_parent` = " . $id;
$result = $db->query($sql);
//尋找有無子資料夾
while ($arr = $db->getarray($result)) {
delDir($arr['dir_id']);
}
//刪除該資料夾下所有檔案
$sql = "DELETE from file_data\n\t\t\twhere file_dir = " . $id;
$db->query($sql);
//刪除該資料夾
$sql = "DELETE from dir_data\n\t\t\twhere dir_id = " . $id;
$db->query($sql);
return;
}
示例7: delDir
/**
* 删除整个目录
* @param $dir
* @return bool
*/
function delDir($dir)
{
//先删除目录下的所有文件:
$dh = opendir($dir);
while ($file = readdir($dh)) {
if ($file != "." && $file != "..") {
$fullpath = $dir . "/" . $file;
if (!is_dir($fullpath)) {
unlink($fullpath);
} else {
delDir($fullpath);
}
}
}
closedir($dh);
//删除当前文件夹:
return rmdir($dir);
}
示例8: delDir
function delDir($directory)
{
if (file_exists($directory)) {
if ($dir_handle = @opendir($directory)) {
while ($filename = readdir($dir_handle)) {
if ($filename != "." && $filename != "..") {
$subFile = $directory . "/" . $filename;
if (is_dir($subFile)) {
delDir($subFile);
}
if (is_file($subFile)) {
unlink($subFile);
}
}
}
closedir($dir_handle);
rmdir($directory);
}
}
}
示例9: delDir
function delDir($dir)
{
$dh = opendir($dir);
while ($file = readdir($dh)) {
if ($file != "." && $file != "..") {
$fullpath = $dir . "/" . $file;
if (!is_dir($fullpath)) {
unlink($fullpath);
} else {
delDir($fullpath);
}
}
}
closedir($dh);
if (rmdir($dir)) {
return true;
} else {
return false;
}
}
示例10: delDir
function delDir($path)
{
//不是目录,直接返回
if (!is_dir($path)) {
return NULL;
}
$dh = opendir($path);
while (($row = readdir($dh)) !== false) {
if ($row == '.' || $row == '..') {
continue;
}
//判断是否是普通文件
if (!is_dir($path . '/' . $row)) {
unlink($path . '/' . $row);
} else {
delDir($path . '/' . $row);
}
echo $row, "<br />";
}
closedir($dh);
rmdir($path);
return true;
}
示例11: Import
//.........这里部分代码省略.........
} elseif (!empty($data['idcat'])) {
if (isset($fields['mprice']) && !empty($data['mprice'])) {
$mprices = array(array('name' => $data['mprice'], 'price' => !empty($data['price']) ? $data['price'] : ''));
$data['mprices'] = serialize($mprices);
}
if (isset($data['mprice'])) {
unset($data['mprice']);
}
if (empty($data['name'])) {
continue;
}
$data['sort'] = $gsort++;
$id = A::$DB->Insert(SECTION . "_catalog", $data);
$images = array();
$files = array();
$curgoods++;
} else {
continue;
}
foreach ($cfiles as $field => $frow) {
if (!empty($row[$frow['id']])) {
switch ($frow['type']) {
case 'image':
$row[$frow['id']] = preg_replace("/[^a-zA-Zа-яА-Я0-9-_.]/iu", "", $row[$frow['id']]);
$path0 = A::$AUTH->isSuperAdmin() ? "ifiles/" . $row[$frow['id']] : "";
$path1 = "files/" . DOMAIN . "/" . A::$OPTIONS['imgpath'] . "/" . $row[$frow['id']];
$path2 = "files/" . DOMAIN . "/reg_images/" . $row[$frow['id']];
$path = is_file($path0) ? $path0 : (is_file($path1) ? $path1 : (is_file($path2) ? $path2 : ""));
if ($path) {
preg_match("/^idimg([0-9]+)\$/i", $field, $mathes);
$sort = $mathes[1];
if (!isset($images[$sort]) || $images[$sort]['path'] != $path) {
$image = array();
$image['path'] = $path;
$image['name'] = basename($row[$frow['id']]);
$image['mime'] = getMimeByFile($row[$frow['id']]);
$image['caption'] = !empty($data['name']) ? $data['name'] : "";
$it = Image_Transform::factory('GD');
$it->load($path);
$image['width'] = $it->img_x;
$image['height'] = $it->img_y;
$image['idsec'] = SECTION_ID;
$image['iditem'] = $id;
$image['sort'] = $sort;
if (isset($images[$sort])) {
A::$DB->Update(DOMAIN . "_images", $image, "id=" . $images[$sort]['id']);
} else {
A::$DB->Insert(DOMAIN . "_images", $image);
}
}
}
break;
case 'file':
$row[$frow['id']] = preg_replace("/[^a-zA-Zа-яА-Я0-9-_.]/iu", "", $row[$frow['id']]);
$path0 = A::$AUTH->isSuperAdmin() ? "ifiles/" . $row[$frow['id']] : "";
$path1 = "files/" . DOMAIN . "/" . A::$OPTIONS['filepath'] . "/" . $row[$frow['id']];
$path2 = "files/" . DOMAIN . "/reg_files/" . $row[$frow['id']];
$path = is_file($path0) ? $path0 : (is_file($path1) ? $path1 : (is_file($path2) ? $path2 : ""));
if ($path) {
preg_match("/^idfile([0-9]+)\$/i", $field, $mathes);
$sort = $mathes[1];
if (!isset($files[$sort]) || $files[$sort]['path'] != $path) {
$file = array();
$file['path'] = $path;
$file['name'] = basename($row[$frow['id']]);
$file['mime'] = getMimeByFile($row[$frow['id']]);
$file['caption'] = !empty($data['name']) ? $data['name'] : "";
$file['idsec'] = SECTION_ID;
$file['iditem'] = $id;
$file['sort'] = $sort;
$file['size'] = filesize($path);
$file['dwnl'] = 0;
if (isset($files[$sort])) {
A::$DB->Update(DOMAIN . "_files", $file, "id=" . $files[$sort]['id']);
} else {
A::$DB->Insert(DOMAIN . "_files", $file);
}
}
}
break;
}
}
}
}
if ($prevgoods > 0 && $prevgoods != $curgoods) {
$this->updateCItems();
} else {
A::$DB->Update(SECTION . "_categories", array('citems' => 0));
foreach ($cats as $id => $count) {
A::$DB->Update(SECTION . "_categories", array('citems' => $count), "id={$id}");
}
$this->updateCItems(0, true);
}
A::$CACHE->resetSection(SECTION);
delDir("files/" . DOMAIN . "/tmp");
return true;
}
}
return false;
}
示例12: annotate
function annotate()
{
require_once 'externals.php';
$filename = $_SESSION['filename'];
$tempdir = get_directory();
chdir($tempdir);
$file = fopen("{$tempdir}/{$filename}", "w");
fwrite($file, $_SESSION['plfile']);
fclose($file);
$annotations = $_POST['annotations'];
$annotations = '[' . $annotations . '].';
if (isset($_POST['filters'])) {
$filters = $_POST['filters'];
} else {
$filters = $_SESSION['filters'];
}
$output = modify_annotations("{$tempdir}/{$filename}", "{$tempdir}/{$filename}.ann", $annotations, $filters);
if ($output[0] != 0) {
$_SESSION['editerror'] = $output[2];
delDir($tempdir);
if (isset($_POST['textedit'])) {
redirect('edit_filters.php');
} else {
redirect('upload_annfile.php');
}
}
$_SESSION['editerror'] = '';
$_SESSION['annfile'] = file_get_contents("{$tempdir}/{$filename}.ann");
$_SESSION['filters'] = $filters;
delDir($tempdir);
}
示例13: qiMsg
qiMsg("插件停用成功!");
} elseif ($isused == '1') {
array_push($app_plugins, $pname);
if (file_exists('plugins/' . $apps . '/' . $pname . '/install.sql')) {
$sql = file_get_contents('plugins/' . $apps . '/' . $pname . '/install.sql');
$sql = str_replace('ts_', '' . dbprefix . '', $sql);
$ret = $db->query($sql);
if ($ret == '1') {
fileWrite($apps . '_plugins.php', 'data', $app_plugins);
$tsMySqlCache->set($apps . '_plugins', $app_plugins);
$msg = '插件启用成功!';
} else {
$msg = $ret;
}
} else {
fileWrite($apps . '_plugins.php', 'data', $app_plugins);
$tsMySqlCache->set($apps . '_plugins', $app_plugins);
$msg = '插件启用成功!';
}
qiMsg($msg);
}
break;
//删除插件
//删除插件
case "delete":
$apps = tsUrlCheck($_GET['apps']);
$pname = tsUrlCheck($_GET['pname']);
delDir('plugins/' . $apps . '/' . $pname);
qiMsg('删除成功!');
break;
}
示例14: delDir
}
if ($sitePublish == 'true') {
delDir('project_sites/' . $pieces[$i]);
}
// if CVS repository enabled
if ($enable_cvs == 'true') {
cvs_delete_repository($pieces[$i]);
}
}
$tmpquery = 'WHERE tas.project IN(' . $id . ')';
$listTasks = new request();
$listTasks->openTasks($tmpquery);
$comptListTasks = count($listTasks->tas_id);
for ($i = 0; $i < $comptListTasks; $i++) {
if ($fileManagement == 'true') {
delDir('../files/' . $id . '/' . $listTasks->tas_id[$i]);
}
$tasks .= $listTasks->tas_id[$i];
if ($i != $comptListTasks - 1) {
$tasks .= ',';
}
}
$tmpquery = 'WHERE topic.project IN(' . $id . ')';
$listTopics = new request();
$listTopics->openTopics($tmpquery);
$comptListTopics = count($listTopics->top_id);
for ($i = 0; $i < $comptListTopics; $i++) {
$topics .= $listTopics->top_id[$i];
if ($i != $comptListTopics - 1) {
$topics .= ',';
}
示例15: str_replace
* (at your option) any later version.
*/
$checkSession = true;
require_once "../includes/library.php";
if ($action == "delete") {
$id = str_replace("**", ",", $id);
$tmpquery1 = "DELETE FROM " . $tableCollab["tasks"] . " WHERE id IN({$id})";
$tmpquery2 = "DELETE FROM " . $tableCollab["assignments"] . " WHERE task IN({$id})";
$tmpquery3 = "DELETE FROM " . $tableCollab["tasks_time"] . " WHERE task IN({$id})";
$tmpquery = "WHERE tas.id IN({$id})";
$listTasks = new request();
$listTasks->openTasks($tmpquery);
$comptListTasks = count($listTasks->tas_id);
for ($i = 0; $i < $comptListTasks; $i++) {
if ($fileManagement == "true") {
delDir("../files/" . $listTasks->tas_project[$i] . "/" . $listTasks->tas_id[$i]);
}
}
connectSql("{$tmpquery1}");
connectSql("{$tmpquery2}");
connectSql("{$tmpquery3}");
if ($project != "") {
header("Location: ../projects/viewproject.php?id={$project}&msg=delete");
exit;
} else {
header("Location: ../general/home.php?msg=delete");
exit;
}
}
$tmpquery = "WHERE pro.id = '{$project}'";
$projectDetail = new request();