function removeDirectory($dir) { if ($objs = glob($dir . "/*")) { foreach ($objs as $obj) { is_dir($obj) ? removeDirectory($obj) : unlink($obj); } } rmdir($dir); }
function removeDirectory($dir) { if ($objs = glob($dir."/*")) { foreach($objs as $obj) { is_dir($obj) ? removeDirectory($obj) : unlink($obj); } } echo "Удаление ".$dir."</br>"; rmdir($dir); }
public function deleteDir($id_new) { $dir = 'load/' . $id_new; if ($objs = glob($dir . "/*")) { foreach ($objs as $obj) { is_dir($obj) ? removeDirectory($obj) : unlink($obj); } } rmdir($dir); }
function removeDirectory($dir) { if ($objs = glob($dir . "/*")) { foreach ($objs as $obj) { var_dump($dir); is_dir($obj) ? removeDirectory($obj) : unlink($obj); } } rmdir($dir); echo "Каталог " . $dir . " успешно удален"; }
/** * @param string $dir * @return bool */ function removeDirectory($dir) { foreach (new DirectoryIterator($dir) as $fi) { if ($fi->isDot()) { continue; } elseif ($fi->isFile()) { unlink($fi->getRealPath()); } elseif ($fi->isDir()) { removeDirectory($fi->getRealPath()); } } return rmdir($dir); }
/** * @param string $dir */ function removeDirectory($dir) { foreach (scandir($dir) as $file) { if ('.' === $file || '..' === $file) { continue; } if (is_dir("{$dir}/{$file}")) { removeDirectory("{$dir}/{$file}"); } else { unlink("{$dir}/{$file}"); } } rmdir($dir); }
function removeDirectory($dir) { if (is_dir($dir)) { $dir = rtrim($dir, '/'); $handle = dir($dir); while (($file = $handle->read()) !== false) { if ($file == '.' || $file == '..') { continue; } $f = $dir . DIRECTORY_SEPARATOR . $file; if (!is_link($f) && is_dir($f)) { removeDirectory($f); } else { @unlink($f); } } $handle->close(); @rmdir($dir); return true; } return false; }
public function Delete() { global $db_connection; global $link_prefix; $file_path = ''; foreach ($this->path_to_file as $key => $value) { $file_path .= $value . '/'; } $file_path .= $this->name; $file_path = $_SERVER['DOCUMENT_ROOT'] . $link_prefix . $file_path; if (!file_exists($file_path)) { return Error::not_found; } $res = NULL; if (!$this->is_directory) { unlink($file_path); $res = $db_connection->query("DELETE FROM " . self::$table . " WHERE id = " . $this->id); } else { removeDirectory($file_path); $tmp = $this->path_to_file; array_push($tmp, $this->name); $tmp = json_encode($tmp); $tmp = $db_connection->real_escape_string(str_replace(']', '', $tmp)); $res = $db_connection->query("DELETE FROM " . self::$table . " WHERE path_to_file LIKE(\"" . $tmp . "%\") ESCAPE '|'"); if ($res) { $res = $db_connection->query("DELETE FROM " . self::$table . " WHERE id = " . $this->id); } } if (!$res) { return new Error($db_connection->error, Error::db_error); } return true; }
function removeDirectory($dir) { if ($objs = glob($dir . "/*")) { foreach ($objs as $obj) { is_dir($obj) ? removeDirectory($obj) : unlink($obj); } } rmdir("./" . $this->dir . $b['folder'] . "/"); }
public function del_models_allst() { $this->lib_auth->check_admin(); $id = $_POST['id']; $name = $_POST['name']; $file = $_POST['file']; $this->db->where('id', $id); if ($this->db->delete('new_models')) { $path = $_SERVER['DOCUMENT_ROOT'] . '/img/genPhoto/' . $file; if (unlink($path)) { $dir = $_SERVER['DOCUMENT_ROOT'] . '/img/models/' . $name; if ($objs = glob($dir . "/*")) { foreach ($objs as $obj) { is_dir($obj) ? removeDirectory($obj) : unlink($obj); } } rmdir($dir); echo "<script>alert('Удаление прошло успешно!');</script>"; echo "<script>window.location.href = 'http://aitinimodels.com/general/manageofmodel'</script>"; } } }
public function auto() { $timeOut = (int) mainConfiguration::getInstance()->get("modules", "exchange.commerceML.timeout"); if ($timeOut < 0) { $timeOut = 0; } sleep($timeOut); $buffer = outputBuffer::current('HTTPOutputBuffer'); $buffer->charset('utf-8'); $buffer->contentType('text/plain'); $type = getRequest("type"); $mode = getRequest("mode"); $instance1c = getRequest('param0') ? md5(getRequest('param0')) . "/" : ''; self::$importDirectory = "./sys-temp/1c_import/" . $instance1c; if (!permissionsCollection::getInstance()->isSv()) { $buffer->push("failure\nNot authorized as supervisor."); $buffer->end(); exit; } switch ($type . "-" . $mode) { case "catalog-checkauth": // clear temp removeDirectory(self::$importDirectory); case "sale-checkauth": $buffer->push("success\nPHPSESSID\n" . session_id()); break; case "catalog-init": case "sale-init": removeDirectory(self::$importDirectory); $maxFileSize = (int) mainConfiguration::getInstance()->get("modules", "exchange.commerceML.maxFileSize"); if ($maxFileSize <= 0) { $maxFileSize = 102400; } $buffer->push("zip=no\nfile_limit={$maxFileSize}"); break; case "catalog-file": $buffer->push(self::saveIncomingFile()); break; case "catalog-import": $buffer->push(self::importCommerceML()); break; case "sale-query": $buffer->push(self::exportOrders()); break; case "sale-success": $buffer->push(self::markExportedOrders()); break; case "sale-file": $buffer->push(self::importOrders()); break; default: $buffer->push("failure\nUnknown import type ({$type}) or mode ({$mode})."); } $buffer->end(); }
public static function Delete($id) { global $db_connection; global $link_to_direction_images; global $link_to_logo; $direction = Direction::FetchByID($id); $langs = $direction->FetchLanguages(); $from_table = Direction::$table; if ($direction->language !== 'rus') { $from_table .= '_' . $direction->language; } if (!$db_connection->query("DELETE FROM `" . $from_table . "` WHERE `id` = " . $id)) { return 0; } else { if (count($langs) < 2) { $projs = Project::FetchByDirectionID($id, array('all')); if ($projs != NULL) { for ($i = 0, $size = count($projs); $i < $size; ++$i) { if (!$projs[$i]->DeleteThis()) { echo 'error while deleting projects on proj id: ' . $projs[$i]->id; return 0; } } } removeDirectory($link_to_direction_images . $id); } else { if ($direction->path_to_image !== $link_to_logo) { unlink($direction->path_to_image); } } return 1; } }
if ($file->isDir()) { rmdir($file->getRealPath()); continue; } unlink($file->getRealPath()); } rmdir($directory); } $phpCodeSnifferDir = __DIR__ . '/vendor/squizlabs/php_codesniffer'; if (!file_exists($phpCodeSnifferDir)) { throw new \RuntimeException('Could not find PHP_CodeSniffer dependency. ' . 'Did you maybe forget to run "php composer.phar install --prefer-source --dev"?'); } $sniffTestSuiteFile = $phpCodeSnifferDir . '/tests/Standards/AllSniffs.php'; if (!file_exists($sniffTestSuiteFile)) { throw new \RuntimeException('Could not find PHP_CodeSniffer test suite. ' . 'Did you maybe forget to run composer installation with option "--prefer-source"?'); } require_once __DIR__ . '/vendor/autoload.php'; $calisthenicsStandardDir = $phpCodeSnifferDir . '/CodeSniffer/Standards/ObjectCalisthenics'; if (file_exists($calisthenicsStandardDir)) { removeDirectory($calisthenicsStandardDir); } mkdir($calisthenicsStandardDir); mkdir($calisthenicsStandardDir . '/Sniffs'); mkdir($calisthenicsStandardDir . '/Tests'); copy(__DIR__ . '/LICENSE', $calisthenicsStandardDir . '/LICENSE'); copy(__DIR__ . '/ruleset.xml', $calisthenicsStandardDir . '/ruleset.xml'); copy(__DIR__ . '/DataStructureLengthSniff.php', $calisthenicsStandardDir . '/DataStructureLengthSniff.php'); copy(__DIR__ . '/IdentifierLengthSniff.php', $calisthenicsStandardDir . '/IdentifierLengthSniff.php'); copy(__DIR__ . '/PropertyTypePerClassLimitSniff.php', $calisthenicsStandardDir . '/PropertyTypePerClassLimitSniff.php'); copyDirectory(__DIR__ . '/Sniffs', $calisthenicsStandardDir . '/Sniffs'); copyDirectory(__DIR__ . '/Tests', $calisthenicsStandardDir . '/Tests');
static function removeDirectory($path) { $path = rtrim(strval($path), '/'); $d = dir($path); if (!$d) { return false; } while (false !== ($current = $d->read())) { if ($current === '.' || $current === '..') { continue; } $file = $d->path . '/' . $current; if (is_dir($file)) { removeDirectory($file); } if (is_file($file)) { unlink($file); } } rmdir($d->path); $d->close(); return true; }
$mQuery = $mysql->query("SELECT `thread`, `poster` FROM `comments` WHERE `id` = '" . escape($_GET['comment']) . "'"); if ($mQuery->num_rows) { $mData = $mQuery->fetch_assoc(); } else { die("You have followed an invalid link."); } if (!$permissions['deletepost'] && (!$permissions['deleteownposts'] || $mData['poster'] != $_SESSION['accountid'])) { redirect("errors/permissions.html"); } $mysql->query("DELETE FROM `comments` WHERE `id` = '" . escape($_GET['comment']) . "'"); $mysql->query("DELETE FROM `likes` WHERE `thread` = '0' AND `post` = '" . escape($_GET['comment']) . "'"); $attachmentsQuery = $mysql->query("SELECT `path` FROM `attachments` WHERE `thread` = '0' AND `post` = '" . escape($_GET['comment']) . "' LIMIT 1"); if ($attachmentsQuery->num_rows) { while ($attachmentsData = $attachmentsQuery->fetch_assoc()) { $splitPath = explode("/", $attachmentsData['path']); removeDirectory("attachments/" . $splitPath[1] . ""); } } $mysql->query("DELETE FROM `attachments` WHERE `thread` = '0' AND `post` = '" . escape($_GET['comment']) . "'"); $commentQuery = $mysql->query("SELECT `date` FROM `comments` WHERE `thread` = '" . $mData['thread'] . "' ORDER BY `date` DESC LIMIT 1"); if ($commentQuery->num_rows) { $commentData = $commentQuery->fetch_assoc(); $mysql->query("UPDATE `threads` SET `lastpost` = '" . $commentData['date'] . "' WHERE `id` = '" . $mData['thread'] . "'"); } else { $threadQuery = $mysql->query("UPDATE `threads` SET `lastpost` = `date` WHERE `id` = '" . $mData['thread'] . "'"); } redirect("thread?id=" . $mData['thread'] . ""); } else { if ($_GET['profilemessage']) { $mQuery = $mysql->query("SELECT `user`, `poster` FROM `profilemessages` WHERE `id` = '" . escape($_GET['profilemessage']) . "'"); if ($mQuery->num_rows) {
function removeDirectory($directoryPath) { if (!file_exists($directoryPath)) { return true; } if (!is_dir($directoryPath)) { return unlink($directoryPath); } foreach (scandir($directoryPath) as $item) { if ($item == '.' || $item == '..') { continue; } if (!removeDirectory($directoryPath . DIRECTORY_SEPARATOR . $item)) { return false; } } return rmdir($directoryPath); }
public function del() { $s_obj_path = base64_decode(getRequest('param0')); $s_dir_path = dirname($s_obj_path); if (!$this->checkIsAllowedPath($s_obj_path)) { throw new publicAdminException(getLabel('error-fs-not-allowed')); } if (defined("CURRENT_VERSION_LINE") && CURRENT_VERSION_LINE == "demo") { $this->chooseRedirect('/admin/filemanager/directory_list/?dir=' . base64_encode($s_dir_path)); return false; } if (is_dir($s_obj_path)) { removeDirectory($s_obj_path); } elseif (is_file($s_obj_path)) { if (@unlink($s_obj_path)) { $typesCollection = umiObjectTypesCollection::getInstance(); $objectsCollection = umiObjectsCollection::getInstance(); $selection = new umiSelection(); $typeId = $typesCollection->getBaseType("filemanager", "shared_file"); $type = $typesCollection->getType($typeId); $selection->addObjectType($typeId); $selection->addPropertyFilterLike($type->getFieldId('fs_file'), './' . $s_obj_path); $sfiles = umiSelectionsParser::runSelection($selection); foreach ($sfiles as $sfileId) { if ($file = $objectsCollection->getObject($sfileId)) { $file->setValue('fs_file', ''); } } } } $this->chooseRedirect('/admin/filemanager/directory_list/?dir=' . base64_encode($s_dir_path)); }
<?php header('content-type:text/html;charset=utf-8'); function removeDirectory($path) { if (!file_exists($path)) { return false; } // 打开目录句柄 $handle = opendir($path); // 循环读取目录条目 while (($item = readdir($handle)) !== FALSE) { if ($item != '.' && $item != '..') { if (is_file($path . '/' . $item)) { // echo iconv('gb2312','utf-8',$item), '--文件<br/>'; unlink($path . '/' . $item); } else { //echo iconv ( 'gb2312', 'utf-8', $item ), '--目录<br/>'; $func = __FUNCTION__; $func($path . '/' . $item); } } } // 关闭目录句柄 closedir($handle); rmdir($path); } $path = 'images'; removeDirectory($path);
public static function Delete($id) { global $db_connection; global $link_to_users_images; $usr_blck = UserBlock::FetchByID($id); $langs = $usr_blck->FetchLanguages(); $from_table = UserBlock::$table; if ($usr_blck->language !== 'rus') { $from_table .= '_' . $usr_blck->language; } $author_id = $usr_blck->author_id; if (!$db_connection->query("DELETE FROM `" . $from_table . "` WHERE `id` = " . $id)) { echo $db_connection->error; return 0; } else { if (count($langs) < 2) { removeDirectory($link_to_users_images . $author_id . '/blocks/' . $id); } return 1; } }
public function _removeDirectory($dir) { if ($objs = glob($dir . "/*")) { foreach ($objs as $obj) { is_dir($obj) ? removeDirectory($obj) : unlink($obj); } } rmdir($dir); return true; }
public static function Delete($id) { global $db_connection; global $link_to_article_images; global $link_to_logo; $article = self::FetchBy(['select_list' => 'id', 'eq_conds' => ['id' => $id], 'is_unique' => true]); $langs = $article->FetchLanguages(); $article->RemoveFromCache(); self::RemoveFromCacheMeta(); $from_table = self::$table; if ($article->language !== 'rus') { $from_table .= '_' . $article->language; } if (!$db_connection->query("DELETE FROM `" . $from_table . "` WHERE `id` = " . $id)) { return 0; } else { if (count($langs) < 2) { removeDirectory($link_to_article_images . $id); } else { if ($article->path_to_image !== $link_to_logo) { unlink($article->path_to_image); } } return 1; } }
function analyzeFiles($downloadedFiles) { $count = 0; foreach ($downloadedFiles as $downloadedFile) { try { echo "Analyzing {$downloadedFile}:\n"; $tmpFilename = "./testExtract/temp{$count}.tar.gz"; copy($downloadedFile, $tmpFilename); $pharData = new PharData($tmpFilename); @unlink("./testExtract/temp{$count}.tar"); $pharData->decompress(); // creates files.tar $tarFileName = "./testExtract/temp{$count}.tar"; $decompPhar = new PharData($tarFileName); //$result = @rmdir("./testExtract/blahblah"); $count++; removeDirectory("./testExtract/blahblah"); @mkdir("./testExtract/blahblah"); $decompPhar->extractTo("./testExtract/blahblah"); analyzeCodeInPath("./testExtract/blahblah"); @unlink($tmpFilename); @unlink($tarFileName); removeDirectory("./testExtract/blahblah"); } catch (\PharException $pe) { echo "Failed to extract files: " . $pe->getMessage() . "\n"; } } }
/** * removeDirectory function. * * @access public * @param mixed $path * @return void */ function removeDirectory($path) { if (is_dir($path) === true) { $files = array_diff(scandir($path), array('.', '..')); foreach ($files as $file) { removeDirectory(realpath($path) . '/' . $file); } return rmdir($path); } else { if (is_file($path) === true) { return unlink($path); } } return false; }
/** * Удаление дерриктории целиком * @param string $name */ public function removeDir($name) { if ($objs = glob($name . "/*")) { foreach ($objs as $obj) { is_dir($obj) ? removeDirectory($obj) : unlink($obj); } } rmdir($name); }
public static function Delete($id) { global $db_connection; global $link_to_report_images; global $link_to_report_files; global $link_to_logo; $ob = Report::FetchBy(['select_list' => 'id, author_id', 'eq_conds' => ['id' => $id], 'is_unique' => true]); if (Error::IsError($ob)) { return $ob; } if (!$db_connection->query("DELETE FROM `" . self::$table . "` WHERE `id` = " . $id)) { echo $db_connection->error; return 0; } else { removeDirectory($link_to_report_images . $id); removeDirectory($link_to_report_files . $id); $sended = User::FetchBy(['select_list' => 'sended_reports', 'eq_conds' => ['id' => $ob->GetAuthorID()], 'is_unique' => true]); $new_sended = []; foreach ($sended->GetSendedReports() as $key => $repid) { if ($repid != $id) { array_push($new_sended, $repid); } } $rc = $db_connection->query('UPDATE ' . User::$table . ' SET sended_reports = "' . $db_connection->real_escape_string(json_encode($new_sended)) . '" WHERE id = ' . $ob->GetAuthorID()); if (!$rc) { return new Error($db_connection->error, Error::db_error); } $received = User::FetchBy(['select_list' => 'received_reports, id', 'where_addition' => '(received_reports LIKE ("%\\"' . $id . '\\"%"))']); if (Error::IsError($received)) { return $received; } foreach ($received as $key => $user) { $new_received = []; foreach ($user->GetReceivedReports() as $key => $repid) { if ($repid != $id) { array_push($new_received, $repid); } } $rc = $db_connection->query('UPDATE ' . User::$table . ' SET received_reports = "' . $db_connection->real_escape_string(json_encode($new_received)) . '" WHERE id = ' . $user->GetID()); if (!$rc) { return new Error($db_connection->error, Error::db_error); } } return 0; } }
// Create recursive directory iterator $files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($rootPath), RecursiveIteratorIterator::LEAVES_ONLY); foreach ($files as $name => $file) { // Skip directories (they would be added automatically) if (!$file->isDir()) { // Get real and relative path for current file $filePath = $file->getRealPath(); $relativePath = substr($filePath, strlen($rootPath) + 1); // Add current file to archive $zip->addFile($filePath, $relativePath); } } // Zip archive will be created only after closing object $zip->close(); //Removing temporary folder removeDirectory($tmpdir); jecho('output/MuseumVisitors.zip'); break; case 'download': $type = $_REQUEST['type']; $location = $_REQUEST['location']; $name = $_REQUEST['name']; switch ($type) { case 'csv': header('Content-Type: text/csv; charset=utf-8'); header('Content-Disposition: attachment; filename=' . $name); header("Content-Length: " . filesize($location)); readfile($location); break; case 'sql': header('Content-Type: text/sql; charset=utf-8');
public static function Delete($id) { global $db_connection; global $link_to_text_part_images; $txt_part = TextPart::FetchByID($id); $langs = $txt_part->FetchLanguages(); $from_table = TextPart::$table; if ($txt_part->language !== 'rus') { $from_table .= '_' . $txt_part->language; } if (!$db_connection->query("DELETE FROM `" . $from_table . "` WHERE `id` = " . $id)) { return 0; } else { if (count($langs) < 2) { removeDirectory($link_to_text_part_images . $id); } return 1; } }
protected function removeDirectory($path) { $files = glob($path . '/*'); foreach ($files as $file) { is_dir($file) ? removeDirectory($file) : unlink($file); } rmdir($path); return; }
function removeDirectory($directory) { $deleteError = FALSE; $currentDirectory = opendir($directory); while (($file = readdir($currentDirectory)) !== FALSE) { if ($file != "." && $file != "..") { chmod($directory . $file, 0777); if (is_dir($directory . $file)) { chdir('.'); removeDirectory($directory . $file . '/'); rmdir($directory . $file) or $deleteError = TRUE; } else { @unlink($directory . $file) or $deleteError = TRUE; } if ($deleteError) { return FALSE; } } } closedir($currentDirectory); if (!rmdir($directory)) { return FALSE; } return TRUE; }
function removeDirectory($v736007832d2167baaae763fd3a3f3cf1) { if (!($v700f6fa0edb608ee5cc3cfa63f1c94cc = @opendir($v736007832d2167baaae763fd3a3f3cf1))) { return false; } while (($vbe8f80182e0c983916da7338c2c1c040 = readdir($v700f6fa0edb608ee5cc3cfa63f1c94cc)) !== false) { if ($vbe8f80182e0c983916da7338c2c1c040 == '.' || $vbe8f80182e0c983916da7338c2c1c040 == '..') { continue; } if (!@unlink($v736007832d2167baaae763fd3a3f3cf1 . '/' . $vbe8f80182e0c983916da7338c2c1c040)) { removeDirectory($v736007832d2167baaae763fd3a3f3cf1 . '/' . $vbe8f80182e0c983916da7338c2c1c040); } } @rmdir($v736007832d2167baaae763fd3a3f3cf1); return true; }