function deleteFolder($folder) { $glob = glob($folder); foreach ($glob as $g) { if (!is_dir($g)) { unlink($g); } else { deleteFolder("{$g}/*"); rmdir($g); } } }
/** * Recursively deletes a folder and its contents * @return Bool True on success, false otherwise * @param $folder String Path to folder */ static function deleteFolder($folder) { // Sanity check if (!file_exists($folder)) { return false; } // Simple delete for a file if (is_file($folder) || is_link($folder)) { return unlink($folder); } // Loop through the folder $dir = dir($folder); while (false !== ($entry = $dir->read())) { // Skip pointers if ($entry == '.' || $entry == '..') { continue; } // Recurse deleteFolder($folder . DIRECTORY_SEPARATOR . $entry); } // Clean up $dir->close(); return rmdir($folder); }
function clearCache() { DeleteFile($GLOBALS['WEB_CACHEFile']); deleteFolder('./../cache/html'); CreateFolder('./../cache/html'); Rw(getMsg1(setL('清除缓冲完成,正在进入后台界面...'), '?act=displayAdminLogin')); }
function deleteFolder($folder, $path) { global $conn_id; global $lang_cant_delete; global $lang_folder_doesnt_exist; global $lang_folder_cant_delete; $isError = 0; // List contents of folder if ($path != "/" && $path != "~") { $folder_path = $path . "/" . $folder; } else { if ($_SESSION["win_lin"] == "lin" || $_SESSION["win_lin"] == "mac") { if ($_SESSION["dir_current"] == "/") { $folder_path = "/" . $folder; } } if ($_SESSION["dir_current"] == "~") { $folder_path = "~/" . $folder; } if ($_SESSION["win_lin"] == "win") { $folder_path = "/" . $folder; } } $ftp_rawlist = getFtpRawList($folder_path); // Go through array of files/folders if (sizeof($ftp_rawlist) > 0) { $count = 0; foreach ($ftp_rawlist as $ff) { $count++; // Split up array into values (Lin) if ($_SESSION["win_lin"] == "lin") { $ff = preg_split("/[\\s]+/", $ff, 9); $perms = $ff[0]; $file = $ff[8]; if (getFileType($perms) == "d") { $isFolder = 1; } else { $isFolder = 0; } } // Split up array into values (Mac) // skip first line if ($_SESSION["win_lin"] == "mac") { if ($count == 1) { continue; } $ff = preg_split("/[\\s]+/", $ff, 9); $perms = $ff[0]; $file = $ff[8]; if (getFileType($perms) == "d") { $isFolder = 1; } else { $isFolder = 0; } } // Split up array into values (Win) if ($_SESSION["win_lin"] == "win") { $ff = preg_split("/[\\s]+/", $ff, 4); $size = $ff[2]; $file = $ff[3]; if ($size == "<DIR>") { $isFolder = 1; } else { $isFolder = 0; } } if ($file != "." && $file != "..") { // Check for sub folders and then perform this function if ($isFolder == 1) { deleteFolder($file, $folder_path); } else { // otherwise delete file $file_path = $folder_path . "/" . $file; if (!@ftp_delete($conn_id, "" . $file_path . "")) { if (checkFirstCharTilde($file_path) == 1) { if (!@ftp_delete($conn_id, "" . replaceTilde($file_path) . "")) { recordFileError("file", replaceTilde($file_path), $lang_cant_delete); } } else { recordFileError("file", $file_path, $lang_cant_delete); } } } } } } // Check if file exists if (checkFileExists("d", $folder, $folder_path) == 1) { $_SESSION["errors"][] = str_replace("[file]", "<strong>" . tidyFolderPath($folder_path, $folder) . "</strong>", $lang_folder_doesnt_exist); } else { // Chage dir up before deleting ftp_cdup($conn_id); // Delete the empty folder if (!@ftp_rmdir($conn_id, "" . $folder_path . "")) { if (checkFirstCharTilde($folder_path) == 1) { if (!@ftp_rmdir($conn_id, "" . replaceTilde($folder_path) . "")) { recordFileError("folder", replaceTilde($folder_path), $lang_folder_cant_delete); $isError = 1; } } else { recordFileError("folder", $folder_path, $lang_folder_cant_delete); $isError = 1; } } // Remove directory from history if ($isError == 0) { deleteFtpHistory($folder_path); } } }
$fdata = scandir($system["contentPath"] . "fdata"); for ($i = 0; $i < count($fdata); $i++) { $id = substr($fdata[$i], 1, strpos($fdata[$i], "X_") - 1); if (is_numeric($id) && strpos($fdata[$i], "_") !== 0 && $id == $id_alt) { $fdata_double[] = array($name_old, $fdata[$i]); } $name_old = $fdata[$i]; $id_alt = $id; } for ($i = 0; $i < count($fdata_double); $i++) { $path1 = $system["contentPath"] . "fdata/" . $fdata_double[$i][0]; $time1 = filemtime($path1); echo $path1 . " - " . date("Y-m-d H:i:s.", filemtime($path1)) . "<br/>"; $path2 = $system["contentPath"] . "fdata/" . $fdata_double[$i][1]; $time2 = filemtime($path2); echo $path2 . " - " . date("Y-m-d H:i:s.", filemtime($path2)) . "<br/>"; if ($time1 < $time2) { echo "deleted 1"; deleteFolder($path1); } else { echo "deleted 2"; deleteFolder($path2); } echo "<hr/>"; } $fdata = scandir($system["contentPath"] . "fdata"); for ($i = 0; $i < count($fdata); $i++) { if (strpos($fdata[$i], "F") === 0) { echo $fdata[$i] . "<br/>"; } }
function copyHtmlToWeb() { $webDir = ''; $toWebDir = ''; $toFilePath = ''; $filePath = ''; $fileName = ''; $fileList = ''; $splStr = ''; $content = ''; $s = ''; $s1 = ''; $c = ''; $webImages = ''; $webCss = ''; $webJs = ''; $splJs = ''; $webFolderName = ''; $jsFileList = ''; $setFileCode = ''; $nErrLevel = ''; $jsFilePath = ''; $url = ''; $setFileCode = @$_REQUEST['setcode']; //设置文件保存编码 handlePower('复制生成HTML页面'); //管理权限处理 writeSystemLog('', '复制生成HTML页面'); //系统日志 $webFolderName = $GLOBALS['cfg_webTemplate']; if (left($webFolderName, 1) == '/') { $webFolderName = mid($webFolderName, 2, -1); } if (right($webFolderName, 1) == '/') { $webFolderName = mid($webFolderName, 1, len($webFolderName) - 1); } if (inStr($webFolderName, '/') > 0) { $webFolderName = mid($webFolderName, inStr($webFolderName, '/') + 1, -1); } $webDir = '/htmladmin/' . $webFolderName . '/'; $toWebDir = '/htmlw' . 'eb/viewweb/'; CreateDirFolder($toWebDir); $toWebDir = $toWebDir . pinYin2($webFolderName) . '/'; deleteFolder($toWebDir); //删除 CreateFolder('/htmlweb/web'); //创建文件夹 防止web文件夹不存在20160504 deleteFolder($webDir); CreateDirFolder($webDir); $webImages = $webDir . 'Images/'; $webCss = $webDir . 'Css/'; $webJs = $webDir . 'Js/'; copyFolder($GLOBALS['cfg_webImages'], $webImages); copyFolder($GLOBALS['cfg_webCss'], $webCss); CreateFolder($webJs); //创建Js文件夹 //处理Js文件夹 $splJs = aspSplit(getDirJsList($webJs), vbCrlf()); foreach ($splJs as $key => $filePath) { if ($filePath != '') { $toFilePath = $webJs . getFileName($filePath); aspEcho('js', $filePath); moveFile($filePath, $toFilePath); } } //处理Css文件夹 $splStr = aspSplit(getDirCssList($webCss), vbCrlf()); foreach ($splStr as $key => $filePath) { if ($filePath != '') { $content = getFText($filePath); $content = replace($content, $GLOBALS['cfg_webImages'], '../images/'); $content = deleteCssNote($content); $content = PHPTrim($content); //设置为utf-8编码 20160527 if (lCase($setFileCode) == 'utf-8') { $content = replace($content, 'gb2312', 'utf-8'); } WriteToFile($filePath, $content, $setFileCode); aspEcho('css', $GLOBALS['cfg_webImages']); } } //复制栏目HTML $GLOBALS['isMakeHtml'] = true; $rssObj = $GLOBALS['conn']->query('select * from ' . $GLOBALS['db_PREFIX'] . 'webcolumn where isonhtml=true'); while ($rss = $GLOBALS['conn']->fetch_array($rssObj)) { $GLOBALS['glb_filePath'] = replace(getColumnUrl($rss['columnname'], 'name'), $GLOBALS['cfg_webSiteUrl'] . '/', ''); if (right($GLOBALS['glb_filePath'], 1) == '/' || right($GLOBALS['glb_filePath'], 1) == '') { $GLOBALS['glb_filePath'] = $GLOBALS['glb_filePath'] . 'index.html'; } if (right($GLOBALS['glb_filePath'], 5) == '.html') { if (right($GLOBALS['glb_filePath'], 11) == '/index.html') { $fileList = $fileList . $GLOBALS['glb_filePath'] . vbCrlf(); } else { $fileList = $GLOBALS['glb_filePath'] . vbCrlf() . $fileList; } $fileName = replace($GLOBALS['glb_filePath'], '/', '_'); $toFilePath = $webDir . $fileName; copyFile($GLOBALS['glb_filePath'], $toFilePath); aspEcho('导航', $GLOBALS['glb_filePath']); } } //复制文章HTML $rssObj = $GLOBALS['conn']->query('select * from ' . $GLOBALS['db_PREFIX'] . 'articledetail where isonhtml=true'); while ($rss = $GLOBALS['conn']->fetch_array($rssObj)) { $GLOBALS['glb_url'] = getHandleRsUrl($rss['filename'], $rss['customaurl'], '/detail/detail' . $rss['id']); $GLOBALS['glb_filePath'] = replace($GLOBALS['glb_url'], $GLOBALS['cfg_webSiteUrl'] . '/', ''); if (right($GLOBALS['glb_filePath'], 1) == '/' || right($GLOBALS['glb_filePath'], 1) == '') { $GLOBALS['glb_filePath'] = $GLOBALS['glb_filePath'] . 'index.html'; } if (right($GLOBALS['glb_filePath'], 5) == '.html') { if (right($GLOBALS['glb_filePath'], 11) == '/index.html') { $fileList = $fileList . $GLOBALS['glb_filePath'] . vbCrlf(); } else { $fileList = $GLOBALS['glb_filePath'] . vbCrlf() . $fileList; } $fileName = replace($GLOBALS['glb_filePath'], '/', '_'); $toFilePath = $webDir . $fileName; copyFile($GLOBALS['glb_filePath'], $toFilePath); aspEcho('文章' . $rss['title'], $GLOBALS['glb_filePath']); } } //复制单面HTML $rssObj = $GLOBALS['conn']->query('select * from ' . $GLOBALS['db_PREFIX'] . 'onepage where isonhtml=true'); while ($rss = $GLOBALS['conn']->fetch_array($rssObj)) { $GLOBALS['glb_url'] = getHandleRsUrl($rss['filename'], $rss['customaurl'], '/page/page' . $rss['id']); $GLOBALS['glb_filePath'] = replace($GLOBALS['glb_url'], $GLOBALS['cfg_webSiteUrl'] . '/', ''); if (right($GLOBALS['glb_filePath'], 1) == '/' || right($GLOBALS['glb_filePath'], 1) == '') { $GLOBALS['glb_filePath'] = $GLOBALS['glb_filePath'] . 'index.html'; } if (right($GLOBALS['glb_filePath'], 5) == '.html') { if (right($GLOBALS['glb_filePath'], 11) == '/index.html') { $fileList = $fileList . $GLOBALS['glb_filePath'] . vbCrlf(); } else { $fileList = $GLOBALS['glb_filePath'] . vbCrlf() . $fileList; } $fileName = replace($GLOBALS['glb_filePath'], '/', '_'); $toFilePath = $webDir . $fileName; copyFile($GLOBALS['glb_filePath'], $toFilePath); aspEcho('单页' . $rss['title'], $GLOBALS['glb_filePath']); } } //批量处理html文件列表 //call echo(cfg_webSiteUrl,cfg_webTemplate) //call rwend(fileList) $sourceUrl = ''; $replaceUrl = ''; $splStr = aspSplit($fileList, vbCrlf()); foreach ($splStr as $key => $filePath) { if ($filePath != '') { $filePath = $webDir . replace($filePath, '/', '_'); aspEcho('filePath', $filePath); $content = getFText($filePath); foreach ($splStr as $key => $s) { $s1 = $s; if (right($s1, 11) == '/index.html') { $s1 = left($s1, len($s1) - 11) . '/'; } $sourceUrl = $GLOBALS['cfg_webSiteUrl'] . $s1; $replaceUrl = $GLOBALS['cfg_webSiteUrl'] . replace($s, '/', '_'); //Call echo(sourceUrl, replaceUrl) '屏蔽 否则大量显示20160613 $content = replace($content, $sourceUrl, $replaceUrl); } $content = replace($content, $GLOBALS['cfg_webSiteUrl'], ''); //删除网址 $content = replace($content, $GLOBALS['cfg_webTemplate'] . '/', ''); //删除模板路径 记 //content=nullLinkAddDefaultName(content) foreach ($splJs as $key => $s) { if ($s != '') { $fileName = getFileName($s); $content = replace($content, 'Images/' . $fileName, 'js/' . $fileName); } } if (inStr($content, '/Jquery/Jquery.Min.js') > 0) { $content = replace($content, '/Jquery/Jquery.Min.js', 'js/Jquery.Min.js'); copyFile('/Jquery/Jquery.Min.js', $webJs . '/Jquery.Min.js'); } $content = replace($content, '<a href="" ', '<a href="index.html" '); //让首页加index.html createFileGBK($filePath, $content); } } //把复制网站夹下的images/文件夹下的js移到js/文件夹下 20160315 $htmlFileList = ''; $splHtmlFile = ''; $splJsFile = ''; $htmlFilePath = ''; $jsFileName = ''; $jsFileList = getDirJsNameList($webImages); $htmlFileList = getDirHtmlList($webDir); $splHtmlFile = aspSplit($htmlFileList, vbCrlf()); $splJsFile = aspSplit($jsFileList, vbCrlf()); foreach ($splHtmlFile as $key => $htmlFilePath) { $content = getFText($htmlFilePath); foreach ($splJsFile as $key => $jsFileName) { $content = regExp_Replace($content, 'Images/' . $jsFileName, 'js/' . $jsFileName); } $nErrLevel = 0; $content = handleHtmlFormatting($content, false, $nErrLevel, '|删除空行|'); //|删除空行| $content = handleCloseHtml($content, true, ''); //闭合标签 $nErrLevel = checkHtmlFormatting($content); if (checkHtmlFormatting($content) == false) { echoRed($htmlFilePath . '(格式化错误)', $nErrLevel); //注意 } //设置为utf-8编码 if (lCase($setFileCode) == 'utf-8') { $content = replace($content, '<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />', '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />'); } $content = PHPTrim($content); WriteToFile($htmlFilePath, $content, $setFileCode); } //images下js移动到js下 foreach ($splJsFile as $key => $jsFileName) { $jsFilePath = $webImages . $jsFileName; $content = getFText($jsFilePath); $content = PHPTrim($content); WriteToFile($webJs . $jsFileName, $content, $setFileCode); DeleteFile($jsFilePath); } copyFolder($webDir, $toWebDir); //使htmlWeb文件夹用php压缩 if (@$_REQUEST['isMakeZip'] == '1') { makeHtmlWebToZip($webDir); } //使网站用xml打包20160612 if (@$_REQUEST['isMakeXml'] == '1') { makeHtmlWebToXmlZip('/htmladmin/', $webFolderName); } //浏览地址 $url = 'http://10.10.10.57/' . $toWebDir; aspEcho('浏览', '<a href=\'' . $url . '\' target=\'_blank\'>' . $url . '</a>'); }
$srcFile = $filename; $dis = $_REQUEST['disFile']; $msg = copyFolder($srcFile, 'file' . "/" . $dis); alertMsg($msg, $urlt); } elseif ($mode == 'cutFolder') { $str = "\n <form action='index.php?mode=doCutFolder' method='post'>\n <input type='hidden' name='filename' value='{$filename}' />\n <input type='hidden' name='path' value='{$path}' />\n <label>前切:</label>\n <input type='text' name='disFile' placeholder='前切到'>\n <input type='submit' value='确定'/>\n </form>"; echo $str; } else { if ($mode == 'doCutFolder') { $dirpath = $filename; $distpath = $_REQUEST['disFile']; $msg = cutFolder($dirpath, $path . "/" . $distpath); alertMsg($msg, $url); } else { if ($mode == 'deleteFolder') { $msg = deleteFolder($filename); alertMsg($msg, $url); } } } } } } } } ?> <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8"> <title>文件管理系统</title>
/** * Löscht das angegeben Verzeichnis und alle darin enthaltenen Unterverzeichnisse, * sowie die darin enthaltenen Files * @return int Fehlernummer * @param string $path Pfad zum Ornder */ function deleteFolder($path) { // schau' nach, ob das ueberhaupt ein Verzeichnis ist if (!is_dir($path)) { return -1; } // oeffne das Verzeichnis $dir = @opendir($path); // Fehler? if (!$dir) { return -2; } // gehe durch das Verzeichnis while (($entry = @readdir($dir)) !== false) { // wenn der Eintrag das aktuelle Verzeichnis oder das Elternverzeichnis // ist, ignoriere es if ($entry == '.' || $entry == '..') { continue; } // wenn der Eintrag ein Verzeichnis ist, dann if (is_dir($path . '/' . $entry)) { // rufe mich selbst auf $res = deleteFolder($path . '/' . $entry); // wenn ein Fehler aufgetreten ist if ($res == -1) { // dies duerfte gar nicht passieren @closedir($dir); // Verzeichnis schliessen return -2; // normalen Fehler melden } else { if ($res == -2) { // Fehler? @closedir($dir); // Verzeichnis schliessen return -2; // Fehler weitergeben } else { if ($res == -3) { // nicht unterstuetzer Dateityp? @closedir($dir); // Verzeichnis schliessen return -3; // Fehler weitergeben } else { if ($res != 0) { // das duerfe auch nicht passieren... @closedir($dir); // Verzeichnis schliessen return -2; // Fehler zurueck } } } } } else { if (is_file($path . '/' . $entry) || is_link($path . '/' . $entry)) { // ansonsten loesche diese Datei / diesen Link $res = @unlink($path . '/' . $entry); // Fehler? if (!$res) { @closedir($dir); // Verzeichnis schliessen return -2; // melde ihn } } else { // ein nicht unterstuetzer Dateityp @closedir($dir); // Verzeichnis schliessen return -3; // tut mir schrecklich leid... } } } // schliesse nun das Verzeichnis @closedir($dir); // versuche nun, das Verzeichnis zu loeschen $res = @rmdir($path); // gab's einen Fehler? if (!$res) { return -2; // melde ihn } // alles ok return 0; }
function delete_folder($path) { if ($handle = opendir($path)) { while (false !== ($item = readdir($handle))) { if ($item != '.' && $item != '..') { if (is_dir($path . '/' . $item)) { deleteFolder($path . '/' . $item); } else { @unlink($path . '/' . $item); } } } closedir($handle); rmdir($path); } }
function deleteFolder($path) { if (is_dir($path) === true) { $files = array_diff(scandir($path), array('.', '..')); foreach ($files as $file) { deleteFolder(realpath($path) . '/' . $file); } return rmdir($path); } else { if (is_file($path) === true) { return unlink($path); } } return false; }
deleteFile(); break; case 'getfolderinfo': getFolderinfo(); break; case 'createfolder': createFolder(); break; case 'renamefolder': renameFolder(); break; case 'movefolder': moveFolder(); break; case 'deletefolder': deleteFolder(); break; case 'sharefolder': shareFolder(); break; case 'unsharefolder': unshareFolder(); break; case 'getshareinfo': getShareInfo(); break; case 'sendfile': sendFile(); break; case 'filerevisions': getFileRevisions();
function deleteFolder($filePath) { if (file_exists($filePath)) { $handler = opendir($filePath); while (($item = readdir($handler)) !== false) { if ($item != "." && $item != "..") { if (is_file($filePath . "/" . $item)) { unlink($filePath . "/" . $item); } else { deleteFolder($filePath . "/" . $item); } } } closedir($handler); rmdir($filePath); $msg = "文件夹删除成功"; } else { $msg = "目标文件夹不存在"; } return $msg; }
function deleteFolder($folder_id, $course_id, $user_profile_id, $user_id) { if (!$this->checkFolderPerms("w", $course_id, $user_profile_id, $folder_id)) { return FALSE; } /* * Get & delete inside folders recursively */ $folders = $this->Select("folder", "folder_id", "course_id = {$course_id} AND folder_parent_id = {$folder_id}"); foreach ($folders as $thisfolder) { deleteFolder($thisfolder, $course_id, $user_profile_id, $user_id); } /* * Delete inside files */ $documents = $this->Select("document", "document_id", "course_id = {$course_id} AND folder_parent_id = {$folder_id}"); foreach ($documents as $thisdocument) { if (!deleteFile($thisdocument, $course_id, $user_profile_id, $user_id)) { return FALSE; } } /* * Finally, delete Folder */ $this->Delete("folder", "course_id = {$course_id} AND folder_id = {$folder_id}"); if ($this->hasError()) { return FALSE; } return TRUE; }
$database->query(sprintf($rawUpdtSQL, $newSettings['catpic'], 'catpic')); $database->query(sprintf($rawUpdtSQL, $newSettings['lightbox'], 'lightbox')); $database->query(sprintf($rawUpdtSQL, serialize($newSettings['tbSettings']), 'tbSettings')); if (serialize($oldSettings['tbSettings']) != serialize($newSettings['tbSettings']) && !isset($_POST['noNew'])) { // Ok, thumb_size hat gewechselt, also alte Thumbs löschen $sql = 'SELECT `parent`, `categorie` FROM ' . TABLE_PREFIX . 'mod_foldergallery_categories WHERE section_id=' . $oldSettings['section_id'] . ';'; $query = $database->query($sql); echo '<div class="info">' . $MOD_FOLDERGALLERY['DELETE_OLD_THUMBS'] . ':'; while ($link = $query->fetchRow()) { $pathToFolder = $path . $oldSettings['root_dir'] . $link['parent'] . '/' . $link['categorie'] . $thumbdir; echo '<br/>' . $MOD_FOLDERGALLERY['DELETE'] . ': ' . $pathToFolder; deleteFolder($pathToFolder); } $pathToFolder = $path . $oldSettings['root_dir'] . $thumbdir; echo '<br/>Delete: ' . $pathToFolder . '</div>'; deleteFolder($pathToFolder); } if ($oldSettings['root_dir'] != $newSettings['root_dir']) { // Und jetzt noch alte DB Einträge $sql = 'SELECT `parent`, `categorie` FROM ' . TABLE_PREFIX . 'mod_foldergallery_categories WHERE section_id=' . $oldSettings['section_id'] . ';'; $query = $database->query($sql); while ($cat = $query->fetchRow()) { $sql = 'DELETE FROM ' . TABLE_PREFIX . 'mod_foldergallery_files WHERE parent_id=' . $cat['parent']; $database->query($sql); } $sql = 'DELETE FROM ' . TABLE_PREFIX . 'mod_foldergallery_categories WHERE section_id=' . $oldSettings['section_id'] . ';'; $database->query($sql); // Root als Kategorie eintragen $sql = 'INSERT INTO ' . TABLE_PREFIX . "mod_foldergallery_categories ( `section_id`,`parent_id`,`categorie`,`parent`,`cat_name`,`active`,`is_empty`,`position`,`niveau`,`has_child`,`childs`,`description` )\n VALUES ( '{$section_id}', '-1', 'Root', '-1', 'Root', '1', '0', '0', '-1', '0', '', 'Root Description' );"; $query = $database->query($sql); if ($database->is_error()) {
function deleteFolder($root, $staticFolders = array(), $first = 1) { $earray = array(); array_push($staticFolders, '.'); array_push($staticFolders, '..'); $files = array_diff(scandir($root), $staticFolders); foreach ($files as $file) { if (is_dir($root . $file)) { $funres = deleteFolder($root . $file . '/', $earray, 0); } else { @unlink($root . $file); } } if ($first == 0) { rmdir($root); } }
/** * "Deletes" a database: makes a .sql dump of the database content * and zips all files related to this db. * * @param mixed $db Database name WITHOUT hdb extension */ function db_delete($db, $verbose = true) { if (db_dump($db)) { // Create DELETED_DATABASES directory if needed $folder = HEURIST_UPLOAD_ROOT . "DELETED_DATABASES/"; if (!file_exists($folder)) { mkdir($folder, 0777, true); } // Zip $source to $file $source = HEURIST_UPLOAD_ROOT . $db; $destination = $folder . $db . "_" . time() . ".zip"; if (zip($source, $destination)) { // Delete $source folder deleteFolder($source); if ($verbose) { echo "<br/>Folder " . $source . " has been deleted"; } // Delete from MySQL $mysqli = server_connect(); $mysqli->query("DROP DATABASE hdb_" . $db); $mysqli->close(); if ($verbose) { echo "<br/>Database " . $db . " has been dropped"; } return true; } else { if ($verbose) { echo "<br/>Failed to zip " . $source . " to " . $destination; } } } else { if ($verbose) { echo "<br/>Failed to dump database " . $db . " to a .sql file"; } } return false; }
<?php require "../settings.php"; // store the post vars in get vars, so that both vars can be accessed at once // it is done this was around, so post vars get's higher priority and overwrites duplicated in get vars if (isset($_POST)) { foreach ($_POST as $arr => $arrval) { $_GET[$arr] = $arrval; } } // see what to do if (isset($_GET["key"])) { switch ($_GET["key"]) { case "delete": case "confirm_delete": $OUTPUT = deleteFolder(); break; default: $OUTPUT = viewFolder(); } } else { $OUTPUT = viewFolder(); } # display output require "../template.php"; # enter new data function viewFolder() { global $_GET; global $user_admin; foreach ($_GET as $key => $value) {
//process request by calling the correct functions if (isset($_POST["action"])) { switch ($_POST["action"]) { case "load-path": $path = findPath($connection->escape_string($_POST["folder"])); displayFiles($path); break; case "update-breadcrumb": $path = findPath($connection->escape_string($_POST["folder"])); displayBreadcrumbs($path); break; case "delete-file": deleteFile($connection->escape_string($_POST["path"]), $connection->escape_string($_POST["container"])); break; case "delete-folder": deleteFolder($connection->escape_string($_POST["id"])); break; case "new-folder": newFolder($connection->escape_string($_POST["name"]), $connection->escape_string($_POST["path"])); break; case "edit-folder": editFolder($connection->escape_string($_POST["name"]), $connection->escape_string($_POST["id"])); break; case "get-usage": getDiskUsage(); break; case "get-edit-user": populateEditModal(); break; case "update-user": updateUser($connection->escape_string($_POST["user"]));