本文整理汇总了PHP中delete_dir_contents函数的典型用法代码示例。如果您正苦于以下问题:PHP delete_dir_contents函数的具体用法?PHP delete_dir_contents怎么用?PHP delete_dir_contents使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了delete_dir_contents函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: clean_temp_data
function clean_temp_data($preferences)
{
global $CFG, $DB;
$status = true;
//true->do it, false->don't do it. To debug if necessary.
if (true) {
//Now delete from tables
$status = $DB->delete_records('backup_ids', array('backup_code' => $preferences->backup_unique_code)) && $DB->delete_records('backup_files', array('backup_code' => $preferences->backup_unique_code));
//Now, delete temp directory (if exists)
$file_path = $CFG->dataroot . "/temp/backup/" . $preferences->backup_unique_code;
if (is_dir($file_path)) {
$status = delete_dir_contents($file_path);
//There is nothing, delete the directory itself
if ($status) {
$status = rmdir($file_path);
}
}
}
return $status;
}
示例2: wiki_export_html
function wiki_export_html(&$WS)
{
global $CFG;
check_dir_exists("{$CFG->dataroot}/temp", true);
check_dir_exists("{$CFG->dataroot}/temp/html", true);
check_dir_exists("{$CFG->dataroot}/temp/html/dfwiki{$WS->cm->id}", true);
check_dir_exists("{$CFG->dataroot}/temp/html/dfwiki{$WS->cm->id}/atachments", true);
check_dir_exists("{$CFG->dataroot}/{$WS->dfwiki->course}", true);
check_dir_exists("{$CFG->dataroot}/{$WS->dfwiki->course}/moddata", true);
check_dir_exists("{$CFG->dataroot}/{$WS->dfwiki->course}/moddata/dfwiki{$WS->cm->id}", true);
//export contents
wiki_export_html_content($WS);
//export attached files
$flist = list_directories_and_files("{$CFG->dataroot}/{$WS->dfwiki->course}/moddata/dfwiki{$WS->cm->id}");
if ($flist != null) {
foreach ($flist as $fil) {
$from_file = "{$CFG->dataroot}/{$WS->dfwiki->course}/moddata/dfwiki{$WS->cm->id}/{$fil}";
$to_file = "{$CFG->dataroot}/temp/html/dfwiki{$WS->cm->id}/atachments/{$fil}";
copy($from_file, $to_file);
}
}
//zip file name
$times = time();
$name = $WS->dfwiki->name . '-' . $times . '.zip';
$cleanzipname = clean_filename($name);
//List of files and directories
$filelist = list_directories_and_files("{$CFG->dataroot}/temp/html");
//Convert them to full paths
$files = array();
if ($filelist != null) {
foreach ($filelist as $file) {
$files[] = "{$CFG->dataroot}/temp/html/{$file}";
}
}
check_dir_exists("{$CFG->dataroot}/{$WS->dfwiki->course}", true);
check_dir_exists("{$CFG->dataroot}/{$WS->dfwiki->course}/exportedhtml", true);
$destination = "{$CFG->dataroot}/{$WS->dfwiki->course}/exportedhtml/{$cleanzipname}";
$status = zip_files($files, $destination);
//delete the folder created in temp
$filelist2 = list_directories_and_files("{$CFG->dataroot}/temp/html");
if ($filelist2 != null) {
$del = delete_dir_contents("{$CFG->dataroot}/temp/html");
}
//show it all to be albe to download the file
$prop = null;
$prop->class = "textcenter";
wiki_div_start($prop);
wiki_size_text(get_string("exporthtmlcorrectly", "wiki"), 2);
wiki_div_end();
$prop = null;
$prop->border = "0";
$prop->class = "boxaligncenter";
$prop->classtd = "nwikileftnow";
wiki_table_start($prop);
$wdir = '/exportedhtml';
$fileurl = "{$wdir}/{$cleanzipname}";
$ffurl = "/file.php?file=/{$WS->cm->course}{$fileurl}";
$icon = mimeinfo("icon", $cleanzipname);
link_to_popup_window($ffurl, "display", "<img src=\"{$CFG->pixpath}/f/{$icon}\" height=\"16\" width=\"16\" alt=\"File\" />", 480, 640);
echo "\n" . ' ';
link_to_popup_window($ffurl, "display", htmlspecialchars($cleanzipname), 480, 640);
$prop = null;
$prop->class = "nwikileftnow";
wiki_change_row($prop);
echo ' ';
wiki_table_end();
$prop = null;
$prop->border = "0";
$prop->class = "boxaligncenter";
$prop->classtd = "nwikileftnow";
wiki_table_start($prop);
$prop = null;
$prop->id = "form";
$prop->method = "post";
$prop->action = '../xml/index.php?id=' . $WS->dfwiki->course . '&wdir=/exportedhtml';
wiki_form_start($prop);
wiki_div_start();
$prop = null;
$prop->name = "dfform[viewexported]";
$prop->value = get_string('viewexported', 'wiki');
wiki_input_submit($prop);
wiki_div_end();
wiki_form_end();
wiki_change_column();
print_continue("{$CFG->wwwroot}/mod/wiki/view.php?id={$WS->cm->id}");
wiki_table_end();
}
示例3: print_error
print_error('confirmsesskeybad', 'error');
} else {
if (!has_capability('moodle/course:manageactivities', get_context_instance(CONTEXT_COURSE, $courseid))) {
print_error('onlyeditingteachers', 'error');
}
}
///
/// Main process, where everything is deployed
///
/// Set some variables
/// Create directories
if (!($resourcedir = make_upload_directory($courseid . '/' . $CFG->moddata . '/resource/' . $resource->id))) {
print_error('errorcreatingdirectory', 'error', '', $CFG->moddata . '/resource/' . $resource->id);
}
/// Ensure it's empty
if (!delete_dir_contents($resourcedir)) {
print_error('errorcleaningdirectory', 'error', '', $resourcedir);
}
/// Copy files
$origin = $CFG->dataroot . '/' . $courseid . '/' . $file;
if (!is_file($origin)) {
print_error('filenotfound', 'error', '', $file);
}
$mimetype = mimeinfo("type", $file);
if ($mimetype != "application/zip") {
print_error('invalidfiletype', 'error', '', $file);
}
$resourcefile = $resourcedir . '/' . basename($origin);
if (!backup_copy_file($origin, $resourcefile)) {
print_error('errorcopyingfiles', 'error');
}
示例4: restore_execute
function restore_execute(&$restore, $info, $course_header, &$errorstr)
{
global $CFG, $USER;
$status = true;
//Checks for the required files/functions to restore every module
//and include them
if ($allmods = get_records("modules")) {
foreach ($allmods as $mod) {
$modname = $mod->name;
$modfile = "{$CFG->dirroot}/mod/{$modname}/restorelib.php";
//If file exists and we have selected to restore that type of module
if (file_exists($modfile) and !empty($restore->mods[$modname]) and $restore->mods[$modname]->restore) {
include_once $modfile;
}
}
}
if (!defined('RESTORE_SILENTLY')) {
//Start the main table
echo "<table cellpadding=\"5\">";
echo "<tr><td>";
//Start the main ul
echo "<ul>";
}
//Location of the xml file
$xml_file = $CFG->dataroot . "/temp/backup/" . $restore->backup_unique_code . "/moodle.xml";
//Preprocess the moodle.xml file spliting into smaller chucks (modules, users, logs...)
//for optimal parsing later in the restore process.
if (!empty($CFG->experimentalsplitrestore)) {
if (!defined('RESTORE_SILENTLY')) {
echo '<li>' . get_string('preprocessingbackupfile') . '</li>';
}
//First of all, split moodle.xml into handy files
if (!restore_split_xml($xml_file, $restore)) {
if (!defined('RESTORE_SILENTLY')) {
notify("Error proccessing moodle.xml file. Process ended.");
} else {
$errorstr = "Error proccessing moodle.xml file. Process ended.";
}
return false;
}
}
//If we've selected to restore into new course
//create it (course)
//Saving conversion id variables into backup_tables
if ($restore->restoreto == RESTORETO_NEW_COURSE) {
if (!defined('RESTORE_SILENTLY')) {
echo '<li>' . get_string('creatingnewcourse') . '</li>';
}
$oldidnumber = $course_header->course_idnumber;
if (!($status = restore_create_new_course($restore, $course_header))) {
if (!defined('RESTORE_SILENTLY')) {
notify("Error while creating the new empty course.");
} else {
$errorstr = "Error while creating the new empty course.";
return false;
}
}
//Print course fullname and shortname and category
if ($status) {
if (!defined('RESTORE_SILENTLY')) {
echo "<ul>";
echo "<li>" . $course_header->course_fullname . " (" . $course_header->course_shortname . ")" . '</li>';
echo "<li>" . get_string("category") . ": " . $course_header->category->name . '</li>';
if (!empty($oldidnumber)) {
echo "<li>" . get_string("nomoreidnumber", "moodle", $oldidnumber) . "</li>";
}
echo "</ul>";
//Put the destination course_id
}
$restore->course_id = $course_header->course_id;
}
if ($status = restore_open_html($restore, $course_header)) {
if (!defined('RESTORE_SILENTLY')) {
echo "<li>Creating the Restorelog.html in the course backup folder</li>";
}
}
} else {
$course = get_record("course", "id", $restore->course_id);
if ($course) {
if (!defined('RESTORE_SILENTLY')) {
echo "<li>" . get_string("usingexistingcourse");
echo "<ul>";
echo "<li>" . get_string("from") . ": " . $course_header->course_fullname . " (" . $course_header->course_shortname . ")" . '</li>';
echo "<li>" . get_string("to") . ": " . format_string($course->fullname) . " (" . format_string($course->shortname) . ")" . '</li>';
if ($restore->deleting) {
echo "<li>" . get_string("deletingexistingcoursedata") . '</li>';
} else {
echo "<li>" . get_string("addingdatatoexisting") . '</li>';
}
echo "</ul></li>";
}
//If we have selected to restore deleting, we do it now.
if ($restore->deleting) {
if (!defined('RESTORE_SILENTLY')) {
echo "<li>" . get_string("deletingolddata") . '</li>';
}
$status = remove_course_contents($restore->course_id, false) and delete_dir_contents($CFG->dataroot . "/" . $restore->course_id, "backupdata");
if ($status) {
//Now , this situation is equivalent to the "restore to new course" one (we
//have a course record and nothing more), so define it as "to new course"
//.........这里部分代码省略.........
示例5: judge
function judge($config)
{
global $CFG, $course, $id, $block;
print_box_start('generalbox', 'notice');
print_string('prepareing', 'block_anti_plagiarism');
flush();
$submission_path = extract_to_temp($CFG->dataroot . '/' . $course->id . '/' . $CFG->moddata . '/assignment/' . $id . '/');
$command = eval('return ' . $config->judger . '_command($config, $submission_path);');
if (debugging('', DEBUG_DEVELOPER)) {
print_object($command);
}
$output = array();
$return = null;
print_string('done', 'block_anti_plagiarism');
echo '<br />';
flush();
$descriptorspec = array(0 => array('pipe', 'r'), 1 => array('pipe', 'w'), 2 => array('pipe', 'w'));
$proc = proc_open($command, $descriptorspec, $pipes);
if (!is_resource($proc)) {
delete_dir_contents($submission_path);
rmdir($submission_path);
error(get_string('failed', 'block_anti_plagiarism'));
}
//Wait for the process to finish.
$output = eval('return ' . $config->judger . '_waiting($pipes[1], $pipes[2]);');
$return = proc_close($proc);
print_string('done', 'block_anti_plagiarism');
echo '<br />';
if (debugging('', DEBUG_DEVELOPER)) {
print_object($output);
}
if ($return) {
//Error
error(get_string('failed', 'block_anti_plagiarism'));
} else {
$results = eval('return ' . $config->judger . '_parse($output);');
foreach ($results as $result) {
insert_record('block_anti_plagiarism_pairs', $result);
}
print_string('done', 'block_anti_plagiarism');
echo '<br />';
print_string('numberofplagiarism', 'block_anti_plagiarism', count($results));
}
if (!debugging('', DEBUG_DEVELOPER)) {
fulldelete($submission_path);
}
print_box_end();
print_continue($CFG->wwwroot . '/blocks/anti_plagiarism/view.php?id=' . $id . '&block=' . $block . '&action=view');
}
示例6: wiki_config_course_module
function wiki_config_course_module($wiki)
{
global $CFG;
if ($entry = get_record_sql('SELECT *
FROM ' . $CFG->prefix . 'wiki_entries
WHERE wikiid=\'' . $wiki->id . '\'')) {
$dfwiki->pagename = $entry->pagename;
} else {
$dfwiki->pagename = 'first';
}
$dfwiki->course = $wiki->course;
$dfwiki->name = $wiki->name;
$dfwiki->timemodified = time();
$dfwiki->editable = '1';
$dfwiki->attach = '0';
$dfwiki->restore = '0';
switch ($wiki->htmlmode) {
case '0':
$dfwiki->editor = 'ewiki';
break;
case '1':
$dfwiki->editor = 'ewiki';
break;
case '2':
$dfwiki->editor = 'htmleditor';
break;
default:
break;
}
//look for the old wiki cm->id
$modul = get_record("modules", "name", 'wiki');
$coursemodule = get_record_sql('SELECT *
FROM ' . $CFG->prefix . 'course_modules
WHERE module=' . $modul->id . ' AND instance=' . $wiki->id);
$dfwiki->groupmode = $coursemodule->groupmode;
$dfwikiid = insert_record("dfwiki", addslashes($dfwiki));
backup_flush(300);
//modify the course_modules entry which was pointing to the old wiki so as to point to the new dfwiki
$moduldfwiki = get_record("modules", "name", 'dfwiki');
$quer = 'UPDATE ' . $CFG->prefix . 'course_modules
SET module=\'' . $moduldfwiki->id . '\'
WHERE id=\'' . $coursemodule->id . '\'';
execute_sql($quer, false);
$quer2 = 'UPDATE ' . $CFG->prefix . 'course_modules
SET instance=\'' . $dfwikiid . '\'
WHERE id=\'' . $coursemodule->id . '\'';
execute_sql($quer2, false);
//copy the attached files to the new dfwiki
$oldentryids = get_records_sql('SELECT *
FROM ' . $CFG->prefix . 'wiki_entries
WHERE wikiid=\'' . $wiki->id . '\'');
//get all the wiki entries
foreach ($oldentryids as $oldentryid) {
wiki_copy_attachments($wiki->id, $wiki->course, $coursemodule->id, $oldentryid->id);
}
//delete all old wiki attached files
delete_dir_contents("{$CFG->dataroot}/{$wiki->course}/moddata/wiki/{$wiki->id}");
return $dfwikiid;
}
示例7: clean_temp_data
function clean_temp_data($preferences)
{
global $CFG;
$status = true;
//true->do it, false->don't do it. To debug if necessary.
if (true) {
//Now delete from tables
$status = execute_sql("DELETE FROM {$CFG->prefix}backup_ids\n WHERE backup_code = '{$preferences->backup_unique_code}'", false);
if ($status) {
$status = execute_sql("DELETE FROM {$CFG->prefix}backup_files\n WHERE backup_code = '{$preferences->backup_unique_code}'", false);
}
//Now, delete temp directory (if exists)
$file_path = $CFG->dataroot . "/temp/backup/" . $preferences->backup_unique_code;
if (is_dir($file_path)) {
$status = delete_dir_contents($file_path);
//There is nothing, delete the directory itself
if ($status) {
$status = rmdir($file_path);
}
}
}
return $status;
}
示例8: get_string
$strtop = get_string('top', 'book');
add_to_log($course->id, 'book', 'generateimscp', 'generateimscp.php?id=' . $cm->id, $book->id, $cm->id);
/// Get all the chapters
$chapters = get_records('book_chapters', 'bookid', $book->id, 'pagenum');
/// Generate the manifest and all the contents
chapters2imsmanifest($chapters, $book, $cm);
/// Now zip everything
make_upload_directory('temp');
$zipfile = $CFG->dataroot . "/temp/" . time() . '.zip';
$files = get_directory_list($CFG->dataroot . "/{$cm->course}/moddata/book/{$book->id}", basename($zipfile), false, true, true);
foreach ($files as $key => $value) {
$files[$key] = $CFG->dataroot . "/{$cm->course}/moddata/book/{$book->id}/" . $value;
}
zip_files($files, $zipfile);
/// Now delete all the temp dirs
delete_dir_contents($CFG->dataroot . "/{$cm->course}/moddata/book/{$book->id}");
/// Now serve the file
send_temp_file($zipfile, clean_filename($book->name) . '.zip');
/**
* This function will create the default imsmanifest plus contents for the book chapters passed as array
* Everything will be created under the book moddata file area *
*/
function chapters2imsmanifest($chapters, $book, $cm)
{
global $CFG;
/// Init imsmanifest and others
$imsmanifest = '';
$imsitems = '';
$imsresources = '';
/// Moodle and Book version
$moodle_release = $CFG->release;
示例9: get_ewikis
function get_ewikis($zip)
{
global $CFG;
$listewikis = null;
//unpack the .zip
check_dir_exists("{$CFG->dataroot}/temp", true);
check_dir_exists("{$CFG->dataroot}/temp/ewikis", true);
$destination = "{$CFG->dataroot}/temp/ewikis";
unzip_file($zip, $destination, false);
//take the .xml
$filelist = list_directories_and_files("{$CFG->dataroot}/temp/ewikis");
if ($filelist == null) {
return $listewikis;
}
foreach ($filelist as $file) {
$extension = explode(".", $file);
$num = count($extension) - 1;
if ($extension[$num] == "xml") {
$goodfile = $file;
}
}
$newfile = "{$CFG->dataroot}/temp/ewikis/{$goodfile}";
$info = restore_read_xml_bis($newfile);
if ($info != null) {
foreach ($info as $mod) {
if ($mod->modtype == 'wiki' || $mod->modtype == 'dfwiki') {
$listewikis[] = $mod;
}
}
}
//delete the folder created in temp
$filelist2 = list_directories_and_files("{$CFG->dataroot}/temp/ewikis");
if ($filelist2 != null) {
$del = delete_dir_contents("{$CFG->dataroot}/temp/ewikis");
}
return $listewikis;
}
示例10: wiki_import_wiki_XML
function wiki_import_wiki_XML(&$WS)
{
global $CFG, $file, $infopages, $oldid, $oldentryid;
$e_wiki = get_ewikis_bis($WS->path, $file);
if (is_array($e_wiki)) {
wiki_validate_and_insert_content($e_wiki[0], $WS);
} else {
error("Not exists wiki pages to import in the backup file!!");
}
wiki_import_atachment_wiki($e_wiki[0]['importfrombackup'][1], $WS);
//delete the folder that we've created on temp
$filelist2 = list_directories_and_files("{$CFG->dataroot}/temp/ewikis");
if ($filelist2 != null) {
$del = delete_dir_contents("{$CFG->dataroot}/temp/ewikis");
}
}
示例11: rebuild_course
/**
* @see /course/lib.php - create_course
* - empty course contents, and clear backups
* - doesn't create new course records
* - doesn't change sort order
* - doesn't update restricted modules
*/
function rebuild_course($cid)
{
global $CFG;
require_once $CFG->dirroot . '/backup/lib.php';
require_once $CFG->libdir . '/pagelib.php';
empty_course_contents($cid);
delete_dir_contents($CFG->dataroot . '/' . $cid, 'backupdata');
$course = get_record('course', 'id', $cid);
// Setup the blocks
$page = page_create_object(PAGE_COURSE_VIEW, $cid);
blocks_repopulate_page($page);
// Return value not checked because you can always edit later
}