本文整理汇总了PHP中backup_copy_file函数的典型用法代码示例。如果您正苦于以下问题:PHP backup_copy_file函数的具体用法?PHP backup_copy_file怎么用?PHP backup_copy_file使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了backup_copy_file函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: webquest_upgrade
function webquest_upgrade($oldversion)
{
/// This function does anything necessary to upgrade
/// older versions to match current functionality
$status = true;
global $CFG;
if ($oldversion < 2007081222) {
require_once $CFG->dirroot . '/backup/lib.php';
//make the change into each course
$courses = get_records("course");
foreach ($courses as $course) {
$newdir = "{$course->id}/{$CFG->moddata}/webquest";
if (make_upload_directory($newdir)) {
$olddir = "{$CFG->dataroot}/{$course->id}/{$CFG->moddata}/webquest/submissions";
//chec k if the old directory exists
if (is_dir($olddir)) {
$status = backup_copy_file($olddir, $CFG->dataroot . "/" . $newdir);
}
if ($status) {
fulldelete($olddir);
}
}
}
}
return $status;
}
示例2: lightboxgallery_restore_files
function lightboxgallery_restore_files($gallery, $restore)
{
global $CFG;
$status = true;
if (is_numeric($gallery)) {
$gallery = get_record('lightboxgallery', 'id', $gallery);
}
$newpath = $CFG->dataroot . '/' . $gallery->course . '/' . $gallery->folder;
$status = check_dir_exists($newpath, true, true);
if ($status) {
$tmppath = $CFG->dataroot . '/temp/backup/' . $restore->backup_unique_code . '/' . $gallery->folder;
if (is_dir($tmppath)) {
$status = backup_copy_file($tmppath, $newpath);
}
}
return $status;
}
示例3: backup_lightboxgallery_files_instance
function backup_lightboxgallery_files_instance($bf, $preferences, $gallery)
{
global $CFG;
$status = true;
if (is_numeric($gallery)) {
$gallery = get_record('lightboxgallery', 'id', $gallery);
}
$tmppath = $CFG->dataroot . '/temp/backup/' . $preferences->backup_unique_code . '/' . $gallery->folder;
$status = check_dir_exists($tmppath, true, true);
if ($status) {
$oldpath = $CFG->dataroot . '/' . $preferences->backup_course . '/' . $gallery->folder;
if (is_dir($oldpath)) {
$status = backup_copy_file($oldpath, $tmppath);
}
}
return $status;
}
示例4: backup_poodllpairwork_files_instance
function backup_poodllpairwork_files_instance($bf, $preferences, $instanceid)
{
global $CFG;
$status = true;
//First we check to moddata exists and create it as necessary
//in temp/backup/$backup_code dir
$status = check_and_create_moddata_dir($preferences->backup_unique_code);
$status = check_dir_exists($CFG->dataroot . "/temp/backup/" . $preferences->backup_unique_code . "/moddata/poodllpairwork/", true);
//Now copy the poodllpairwork dir
if ($status) {
//Only if it exists !! Thanks to Daniel Miksik.
if (is_dir($CFG->dataroot . "/" . $preferences->backup_course . "/" . $CFG->moddata . "/poodllpairwork/" . $instanceid)) {
$status = backup_copy_file($CFG->dataroot . "/" . $preferences->backup_course . "/" . $CFG->moddata . "/poodllpairwork/" . $instanceid, $CFG->dataroot . "/temp/backup/" . $preferences->backup_unique_code . "/moddata/poodllpairwork/" . $instanceid);
}
}
return $status;
}
示例5: backup_imagegallery_files
function backup_imagegallery_files($bf, $preferences, $image)
{
global $CFG;
$status = true;
//First we check to moddata exists and create it as necessary
//in temp/backup/$backup_code dir
$status = check_and_create_moddata_dir($preferences->backup_unique_code);
//Now we check that moddata/glossary dir exists and create it as necessary
//in temp/backup/$backup_code/moddata dir
$gal_dir_to = $CFG->dataroot . "/temp/backup/" . $preferences->backup_unique_code . "/" . $CFG->moddata . "/imagegallery";
//Let's create it as necessary
$status = check_dir_exists($gal_dir_to, true);
// Check imagegalleryid directory.
$gal_dir_to .= '/' . $image->galleryid;
$status = check_dir_exists($gal_dir_to, true);
// structure for imagegallery data directory starting from moddata:
// moddata
// |
// |- imagegallery
// |
// |- <imagegalleryid>
// |
// |- non-categorized images
// |- <categoryid>
// |
// |- categorized images.
if (!empty($image->categoryid)) {
// Copy categorized image under it's directory ( create directory if necessary ).
$gal_dir_to .= '/' . $image->categoryid;
$status = check_dir_exists($gal_dir_to, true);
$filesource = $CFG->dataroot . $image->path;
$filedestin = $gal_dir_to . '/' . $image->name;
if (is_dir($gal_dir_to) && file_exists($filesource)) {
$status = backup_copy_file($filesource, $filedestin);
}
// Copy thumbnail
$filesource = $CFG->dataroot . str_replace($image->name, "thumb_" . $image->name, $image->path);
$filedestin = $gal_dir_to . '/thumb_' . $image->name;
if (is_dir($gal_dir_to) && file_exists($filesource)) {
$status = backup_copy_file($filesource, $filedestin);
}
} else {
// Copy uncategorized image under imagegallery id.
$filesource = $CFG->dataroot . $image->path;
$filedestin = $gal_dir_to . '/' . $image->name;
if (is_dir($gal_dir_to) && file_exists($filesource)) {
$status = backup_copy_file($filesource, $filedestin);
}
// Copy thumbnail
$filesource = $CFG->dataroot . str_replace($image->name, "thumb_" . $image->name, $image->path);
$filedestin = $gal_dir_to . '/thumb_' . $image->name;
if (is_dir($gal_dir_to) && file_exists($filesource)) {
$status = backup_copy_file($filesource, $filedestin);
}
}
return $status;
}
示例6: backup_exercise_student_files
function backup_exercise_student_files($bf, $preferences, $exerciseid)
{
global $CFG;
$status = true;
//First we check to moddata exists and create it as necessary
//in temp/backup/$backup_code dir
$status = check_and_create_moddata_dir($preferences->backup_unique_code);
if ($status) {
//Now copy the submission dirs
if ($submissions = get_records_select("exercise_submissions", "exerciseid = {$exerciseid}\n AND isexercise = 0")) {
foreach ($submissions as $submission) {
//Only if it exists !! Thanks to Daniel Miksik.
if (is_dir("{$CFG->dataroot}/{$preferences->backup_course}/{$CFG->moddata}/exercise/{$submission->id}")) {
$status = backup_copy_file("{$CFG->dataroot}/{$preferences->backup_course}/{$CFG->moddata}/exercise/{$submission->id}", "{$CFG->dataroot}/temp/backup/{$preferences->backup_unique_code}/moddata/exercise/{$submission->id}");
}
}
}
}
return $status;
}
示例7: backup_copy_dir
function backup_copy_dir($from_file, $to_file)
{
global $CFG;
$status = true;
// Initialize this, next code will change its value if needed
if (!is_dir($to_file)) {
//echo "<br />Creating ".$to_file; //Debug
umask(00);
$status = mkdir($to_file, $CFG->directorypermissions);
}
$dir = opendir($from_file);
while (false !== ($file = readdir($dir))) {
if ($file == "." || $file == "..") {
continue;
}
$status = backup_copy_file("{$from_file}/{$file}", "{$to_file}/{$file}");
}
closedir($dir);
return $status;
}
示例8: mail_restore_files
function mail_restore_files($oldmailid, $newmailid, $oldmessageid, $newmessageid, $restore)
{
global $CFG;
$status = true;
$todo = false;
$moddata_path = "";
$mail_path = "";
$temp_path = "";
//First, we check to "course_id" exists and create is as necessary
//in CFG->dataroot
$dest_dir = $CFG->dataroot . "/" . $restore->course_id;
$status = check_dir_exists($dest_dir, true);
//Now, locate course's moddata directory
$moddata_path = $CFG->dataroot . "/" . $restore->course_id . "/" . $CFG->moddata;
//Check it exists and create it
$status = check_dir_exists($moddata_path, true);
//Now, locate assignment directory
if ($status) {
$mail_path = $moddata_path . "/mail";
//Check it exists and create it
$status = check_dir_exists($mail_path, true);
}
//Now locate the temp dir we are gong to restore
if ($status) {
$temp_path = $CFG->dataroot . "/temp/backup/" . $restore->backup_unique_code . "/moddata/mail/" . $oldmailid . "/" . $oldmessageid;
//Check it exists
if (is_dir($temp_path)) {
$todo = true;
}
}
//If todo, we create the neccesary dirs in course moddata/mail
if ($status and $todo) {
//First this assignment id
$this_mail_path = $mail_path . "/" . $newmailid;
$status = check_dir_exists($this_mail_path, true);
//Now this message id
$message_mail_path = $this_mail_path . "/" . $newmessageid;
//And now, copy temp_path to message_mail_path
$status = backup_copy_file($temp_path, $message_mail_path);
}
return $status;
}
示例9: resource_restore_files
function resource_restore_files($oldid, $newid, $resource, $restore)
{
global $CFG;
$status = true;
$status = check_dir_exists($CFG->dataroot . "/" . $restore->course_id, true);
// we need to do anything referenced by $resource->reference and anything in moddata/resource/instance
// do referenced files/dirs first.
$temp_path = $CFG->dataroot . "/temp/backup/" . $restore->backup_unique_code . '/course_files/' . $resource->reference;
if (file_exists($temp_path)) {
// ok, it was backed up, restore it.
$new_path = $CFG->dataroot . '/' . $restore->course_id . '/' . $resource->reference;
// if this is somewhere deeply nested we need to do all the structure stuff first.....
$bits = explode('/', $resource->reference);
$newbit = '';
for ($i = 0; $i < count($bits) - 1; $i++) {
$newbit .= $bits[$i] . '/';
$status = $status && check_dir_exists($CFG->dataroot . '/' . $restore->course_id . '/' . $newbit, true);
}
$status = $status && backup_copy_file($temp_path, $new_path);
}
// and now for moddata.
$temp_path = $CFG->dataroot . "/temp/backup/" . $restore->backup_unique_code . "/moddata/resource/" . $oldid;
if (file_exists($temp_path)) {
// there's something to back up, restore it.
$new_path = $CFG->dataroot . "/" . $restore->course_id . "/" . $CFG->moddata;
$status = $status && check_dir_exists($new_path, true);
$new_path .= '/resource';
$status = $status && check_dir_exists($new_path, true);
$new_path .= '/' . $newid;
$status = $status && backup_copy_file($temp_path, $new_path);
}
return $status;
}
示例10: project_restore_course_files
/**
* コースファイルのコピー
*
* @param object $restore
* @return
*/
function project_restore_course_files(&$restore)
{
global $CFG;
$status = true;
$counter = 0;
// 対象のコース情報の取得
if (!($course = get_record("course", "id", $restore->course_id))) {
error("Course ID was incorrect (can't find it)");
}
// 対象のセクション情報の取得
if (!($section = get_course_section($restore->section, $restore->course_id))) {
error("Section data was incorrect (can't find it)");
}
// 現在のセクションのディレクトリ名を取得
if (!($sectiontitle = project_format_get_title($course, $section->id))) {
error("Section directory was incorrect");
}
//First, we check to "course_id" exists and create is as necessary
//in CFG->dataroot
$dest_dir = $CFG->dataroot . "/" . $restore->course_id . '/' . $restore->newdirectoryname;
$status = check_dir_exists($dest_dir, true);
//Now, we iterate over "course_files" records to check if that file/dir must be
//copied to the "dest_dir" dir.
$rootdir = $CFG->dataroot . "/temp/backup/" . $restore->backup_unique_code . "/course_files/" . $restore->olddirectoryname;
// ディレクトリをまるごとコピーする
if (is_dir($rootdir)) {
$status = backup_copy_file($rootdir, $dest_dir);
}
return $status;
}
示例11: flv_backup_files
function flv_backup_files($bf, $preferences, $flv)
{
global $CFG;
$status = true;
if (!file_exists($CFG->dataroot . '/' . $preferences->backup_course . '/' . $flv->flvfile)) {
return true;
// doesn't exist but we don't want to halt the entire process so still return true.
}
$status = $status && check_and_create_course_files_dir($preferences->backup_unique_code);
// if this is somewhere deeply nested we need to do all the structure stuff first.....
$bits = explode('/', $flv->flvfile);
$newbit = '';
for ($i = 0; $i < count($bits) - 1; $i++) {
$newbit .= $bits[$i] . '/';
$status = $status && check_dir_exists($CFG->dataroot . '/temp/backup/' . $preferences->backup_unique_code . '/course_files/' . $newbit, true);
}
if ($flv->flvfile === '') {
$status = $status && backup_copy_course_files($preferences);
// copy while ignoring backupdata and moddata!!!
} else {
if (strpos($flv->flvfile, 'backupdata') === 0 or strpos($flv->flvfile, $CFG->moddata) === 0) {
// no copying - these directories must not be shared anyway!
} else {
$status = $status && backup_copy_file($CFG->dataroot . "/" . $preferences->backup_course . "/" . $flv->flvfile, $CFG->dataroot . "/temp/backup/" . $preferences->backup_unique_code . "/course_files/" . $flv->flvfile);
}
}
// now, just in case we check moddata ( going forwards, flvs should use this )
$status = $status && check_and_create_moddata_dir($preferences->backup_unique_code);
$status = $status && check_dir_exists($CFG->dataroot . "/temp/backup/" . $preferences->backup_unique_code . "/" . $CFG->moddata . "/flv/", true);
if ($status) {
//Only if it exists !! Thanks to Daniel Miksik.
$instanceid = $flv->id;
if (is_dir($CFG->dataroot . "/" . $preferences->backup_course . "/" . $CFG->moddata . "/flv/" . $instanceid)) {
$status = backup_copy_file($CFG->dataroot . "/" . $preferences->backup_course . "/" . $CFG->moddata . "/flv/" . $instanceid, $CFG->dataroot . "/temp/backup/" . $preferences->backup_unique_code . "/moddata/flv/" . $instanceid);
}
}
return $status;
}
示例12: taoresource_backup_files
function taoresource_backup_files($bf, $preferences, $taoresource_entry)
{
global $CFG;
require_once "{$CFG->dirroot}/mod/taoresource/lib.php";
$status = true;
if (empty($taoresource_entry->file)) {
return true;
}
$filename = $CFG->dataroot . TAORESOURCE_RESOURCEPATH . $taoresource_entry->file;
if (!file_exists($filename)) {
return true;
// doesn't exist but we don't want to halt the entire process so still return true.
}
$status = $status && check_dir_exists($CFG->dataroot . "/temp/backup/" . $preferences->backup_unique_code . TAORESOURCE_RESOURCEPATH, true);
// if this is somewhere deeply nested we need to do all the structure stuff first.....
$status = $status && backup_copy_file($filename, $CFG->dataroot . "/temp/backup/" . $preferences->backup_unique_code . TAORESOURCE_RESOURCEPATH . $taoresource_entry->file);
return $status;
}
示例13: backup_wiki_files
function backup_wiki_files($bf, $preferences)
{
global $CFG;
$status = true;
//First we check to moddata exists and create it as necessary
//in temp/backup/$backup_code dir
$status = check_and_create_moddata_dir($preferences->backup_unique_code);
//Now copy the forum dir
if ($status) {
//Only if it exists !! Thanks to Daniel Miksik.
if (is_dir($CFG->dataroot . "/" . $preferences->backup_course . "/" . $CFG->moddata . "/wiki")) {
$handle = opendir($CFG->dataroot . "/" . $preferences->backup_course . "/" . $CFG->moddata . "/wiki");
while (false !== ($item = readdir($handle))) {
if ($item != '.' && $item != '..' && is_dir($CFG->dataroot . "/" . $preferences->backup_course . "/" . $CFG->moddata . "/wiki/" . $item) && array_key_exists($item, $preferences->mods['wiki']->instances) && !empty($preferences->mods['wiki']->instances[$item]->backup)) {
$status = backup_copy_file($CFG->dataroot . "/" . $preferences->backup_course . "/" . $CFG->moddata . "/wiki/" . $item, $CFG->dataroot . "/temp/backup/" . $preferences->backup_unique_code . "/moddata/wiki/", $item);
}
}
}
}
return $status;
}
示例14: backup_turnitintool_files_instance
function backup_turnitintool_files_instance($bf, $preferences, $instanceid)
{
global $CFG;
$status = true;
$status = check_and_create_moddata_dir($preferences->backup_unique_code);
$status = check_dir_exists($CFG->dataroot . "/temp/backup/" . $preferences->backup_unique_code . "/moddata/turnitintool/", true);
if ($status) {
if (is_dir($CFG->dataroot . "/" . $preferences->backup_course . "/" . $CFG->moddata . "/turnitintool/" . $instanceid)) {
$status = backup_copy_file($CFG->dataroot . "/" . $preferences->backup_course . "/" . $CFG->moddata . "/turnitintool/" . $instanceid, $CFG->dataroot . "/temp/backup/" . $preferences->backup_unique_code . "/moddata/turnitintool/" . $instanceid);
}
}
return $status;
}
示例15: copy_zip_to_course_dir
function copy_zip_to_course_dir($preferences)
{
global $CFG, $DB;
$status = true;
//Define zip location (from)
$from_zip_file = $CFG->dataroot . "/temp/backup/" . $preferences->backup_unique_code . "/" . $preferences->backup_name;
//Initialise $to_zip_file
$to_zip_file = "";
//If $preferences->backup_destination isn't empty, then copy to custom directory
if (!empty($preferences->backup_destination)) {
$to_zip_file = $preferences->backup_destination . "/" . $preferences->backup_name;
//Copy zip file
if ($status) {
$status = backup_copy_file($from_zip_file, $to_zip_file);
}
} else {
//Define zip destination (course dir)
$context = get_context_instance(CONTEXT_COURSE, $preferences->backup_course);
$fs = get_file_storage();
$file_record = array('contextid' => $context->id, 'filearea' => 'course_backup', 'itemid' => 0, 'filepath' => '/', 'filename' => $preferences->backup_name, 'timecreated' => time(), 'timemodified' => time());
$fs->create_file_from_pathname($file_record, $from_zip_file);
}
return $status;
}