当前位置: 首页>>代码示例>>PHP>>正文


PHP check_and_create_backup_dir函数代码示例

本文整理汇总了PHP中check_and_create_backup_dir函数的典型用法代码示例。如果您正苦于以下问题:PHP check_and_create_backup_dir函数的具体用法?PHP check_and_create_backup_dir怎么用?PHP check_and_create_backup_dir使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了check_and_create_backup_dir函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: prepareDir

 protected function prepareDir()
 {
     // 一時ディレクトリを作成して中身を空にする
     if (!check_and_create_backup_dir($this->getUnique()) || !clear_backup_dir($this->getUnique())) {
         throw new SharingCart_Exception('Preparation failure');
     }
     // 残っている古い(=4時間以上前の)バックアップデータを削除
     if (!backup_delete_old_data()) {
         throw new SharingCart_Exception('Preparation failure');
     }
 }
开发者ID:hmatulis,项目名称:RTL-BIDI-Hebrew-Moodle-Plugins,代码行数:11,代码来源:SharingCart_BackupRestoreBase.php

示例2: backup_execute

function backup_execute(&$preferences, &$errorstr)
{
    global $CFG;
    $status = true;
    //Check for temp and backup and backup_unique_code directory
    //Create them as needed
    if (!defined('BACKUP_SILENTLY')) {
        echo "<li>" . get_string("creatingtemporarystructures") . '</li>';
    }
    $status = check_and_create_backup_dir($preferences->backup_unique_code);
    //Empty dir
    if ($status) {
        $status = clear_backup_dir($preferences->backup_unique_code);
    }
    //Delete old_entries from backup tables
    if (!defined('BACKUP_SILENTLY')) {
        echo "<li>" . get_string("deletingolddata") . '</li>';
    }
    $status = backup_delete_old_data();
    if (!$status) {
        if (!defined('BACKUP_SILENTLY')) {
            notify("An error occurred deleting old backup data");
        } else {
            $errorstr = "An error occurred deleting old backup data";
            return false;
        }
    }
    //Create the moodle.xml file
    if ($status) {
        if (!defined('BACKUP_SILENTLY')) {
            echo "<li>" . get_string("creatingxmlfile");
            //Begin a new list to xml contents
            echo "<ul>";
            echo "<li>" . get_string("writingheader") . '</li>';
        }
        //Obtain the xml file (create and open) and print prolog information
        $backup_file = backup_open_xml($preferences->backup_unique_code);
        if (!defined('BACKUP_SILENTLY')) {
            echo "<li>" . get_string("writinggeneralinfo") . '</li>';
        }
        //Prints general info about backup to file
        if ($backup_file) {
            if (!($status = backup_general_info($backup_file, $preferences))) {
                if (!defined('BACKUP_SILENTLY')) {
                    notify("An error occurred while backing up general info");
                } else {
                    $errorstr = "An error occurred while backing up general info";
                    return false;
                }
            }
        }
        if (!defined('BACKUP_SILENTLY')) {
            echo "<li>" . get_string("writingcoursedata");
            //Start new ul (for course)
            echo "<ul>";
            echo "<li>" . get_string("courseinfo") . '</li>';
        }
        //Prints course start (tag and general info)
        if ($status) {
            if (!($status = backup_course_start($backup_file, $preferences))) {
                if (!defined('BACKUP_SILENTLY')) {
                    notify("An error occurred while backing up course start");
                } else {
                    $errorstr = "An error occurred while backing up course start";
                    return false;
                }
            }
        }
        //Metacourse information
        if ($status && $preferences->backup_metacourse) {
            if (!defined('BACKUP_SILENTLY')) {
                echo "<li>" . get_string("metacourse") . '</li>';
            }
            if (!($status = backup_course_metacourse($backup_file, $preferences))) {
                if (!defined('BACKUP_SILENTLY')) {
                    notify("An error occurred while backing up metacourse info");
                } else {
                    $errorstr = "An error occurred while backing up metacourse info";
                    return false;
                }
            }
        }
        if (!defined('BACKUP_SILENTLY')) {
            echo "<li>" . get_string("blocks") . '</li>';
        }
        //Blocks information
        if ($status) {
            if (!($status = backup_course_blocks($backup_file, $preferences))) {
                if (!defined('BACKUP_SILENTLY')) {
                    notify("An error occurred while backing up course blocks");
                } else {
                    $errorstr = "An error occurred while backing up course blocks";
                    return false;
                }
            }
        }
        if (!defined('BACKUP_SILENTLY')) {
            echo "<li>" . get_string("sections") . '</li>';
        }
        //Section info
//.........这里部分代码省略.........
开发者ID:nagyistoce,项目名称:moodle-Teach-Pilot,代码行数:101,代码来源:backuplib.php

示例3: restore_precheck

/**
 * @param string $errorstr passed by reference, if silent is true,
 * errorstr will be populated and this function will return false rather than calling error() or notify()
 * @param boolean $noredirect (optional) if this is passed, this function will not print continue, or
 * redirect to the next step in the restore process, instead will return $backup_unique_code
 */
function restore_precheck($id, $file, &$errorstr, $noredirect = false)
{
    global $CFG, $SESSION;
    //Prepend dataroot to variable to have the absolute path
    $file = $CFG->dataroot . "/" . $file;
    if (!defined('RESTORE_SILENTLY')) {
        //Start the main table
        echo "<table cellpadding=\"5\">";
        echo "<tr><td>";
        //Start the mail ul
        echo "<ul>";
    }
    //Check the file exists
    if (!is_file($file)) {
        if (!defined('RESTORE_SILENTLY')) {
            error("File not exists ({$file})");
        } else {
            $errorstr = "File not exists ({$file})";
            return false;
        }
    }
    //Check the file name ends with .zip
    if (!substr($file, -4) == ".zip") {
        if (!defined('RESTORE_SILENTLY')) {
            error("File has an incorrect extension");
        } else {
            $errorstr = 'File has an incorrect extension';
            return false;
        }
    }
    //Now calculate the unique_code for this restore
    $backup_unique_code = time();
    //Now check and create the backup dir (if it doesn't exist)
    if (!defined('RESTORE_SILENTLY')) {
        echo "<li>" . get_string("creatingtemporarystructures") . '</li>';
    }
    $status = check_and_create_backup_dir($backup_unique_code);
    //Empty dir
    if ($status) {
        $status = clear_backup_dir($backup_unique_code);
    }
    //Now delete old data and directories under dataroot/temp/backup
    if ($status) {
        if (!defined('RESTORE_SILENTLY')) {
            echo "<li>" . get_string("deletingolddata") . '</li>';
        }
        $status = backup_delete_old_data();
    }
    //Now copy he zip file to dataroot/temp/backup/backup_unique_code
    if ($status) {
        if (!defined('RESTORE_SILENTLY')) {
            echo "<li>" . get_string("copyingzipfile") . '</li>';
        }
        if (!($status = backup_copy_file($file, $CFG->dataroot . "/temp/backup/" . $backup_unique_code . "/" . basename($file)))) {
            if (!defined('RESTORE_SILENTLY')) {
                notify("Error copying backup file. Invalid name or bad perms.");
            } else {
                $errorstr = "Error copying backup file. Invalid name or bad perms";
                return false;
            }
        }
    }
    //Now unzip the file
    if ($status) {
        if (!defined('RESTORE_SILENTLY')) {
            echo "<li>" . get_string("unzippingbackup") . '</li>';
        }
        if (!($status = restore_unzip($CFG->dataroot . "/temp/backup/" . $backup_unique_code . "/" . basename($file)))) {
            if (!defined('RESTORE_SILENTLY')) {
                notify("Error unzipping backup file. Invalid zip file.");
            } else {
                $errorstr = "Error unzipping backup file. Invalid zip file.";
                return false;
            }
        }
    }
    //Check for Blackboard backups and convert
    if ($status) {
        require_once "{$CFG->dirroot}/backup/bb/restore_bb.php";
        if (!defined('RESTORE_SILENTLY')) {
            echo "<li>" . get_string("checkingforbbexport") . '</li>';
        }
        $status = blackboard_convert($CFG->dataroot . "/temp/backup/" . $backup_unique_code);
    }
    //Now check for the moodle.xml file
    if ($status) {
        $xml_file = $CFG->dataroot . "/temp/backup/" . $backup_unique_code . "/moodle.xml";
        if (!defined('RESTORE_SILENTLY')) {
            echo "<li>" . get_string("checkingbackup") . '</li>';
        }
        if (!($status = restore_check_moodle_file($xml_file))) {
            if (!is_file($xml_file)) {
                $errorstr = 'Error checking backup file. moodle.xml not found at root level of zip file.';
            } else {
//.........这里部分代码省略.........
开发者ID:kai707,项目名称:ITSA-backup,代码行数:101,代码来源:restorelib.php

示例4: schedule_inc_backup_course_execute

function schedule_inc_backup_course_execute($preferences, $starttime = 0)
{
    global $CFG;
    $status = true;
    //Some parts of the backup doesn't know about $preferences, so we
    //put a copy of it inside that CFG (always global) to be able to
    //use it. Then, when needed I search for preferences inside CFG
    //Used to avoid some problems in full_tag() when preferences isn't
    //set globally (i.e. in scheduled backups)
    $CFG->backup_preferences = $preferences;
    //Check for temp and backup and backup_unique_code directory
    //Create them as needed
    backup_add_to_log($starttime, $preferences->backup_course, "    checking temp structures", 'incrementalbackup');
    $status = check_and_create_backup_dir($preferences->backup_unique_code);
    //Empty backup dir
    if ($status) {
        backup_add_to_log($starttime, $preferences->backup_course, "    cleaning current dir", 'incrementalbackup');
        $status = clear_backup_dir($preferences->backup_unique_code);
    }
    //Create the moodle.xml file
    if ($status) {
        backup_add_to_log($starttime, $preferences->backup_course, "    creating backup file", 'incrementalbackup');
        //Obtain the xml file (create and open) and print prolog information
        $backup_file = backup_open_xml($preferences->backup_unique_code);
        //Prints general info about backup to file
        if ($backup_file) {
            backup_add_to_log($starttime, $preferences->backup_course, "      general info", 'incrementalbackup');
            $status = backup_general_info($backup_file, $preferences);
        } else {
            $status = false;
        }
        //Prints course start (tag and general info)
        if ($status) {
            $status = backup_course_start($backup_file, $preferences);
        }
        //Metacourse information
        if ($status && $preferences->backup_metacourse) {
            backup_add_to_log($starttime, $preferences->backup_course, "      metacourse info", 'incrementalbackup');
            $status = backup_course_metacourse($backup_file, $preferences);
        }
        //Block info
        if ($status) {
            backup_add_to_log($starttime, $preferences->backup_course, "      blocks info", 'incrementalbackup');
            $status = backup_course_blocks($backup_file, $preferences);
        }
        //Section info
        if ($status) {
            backup_add_to_log($starttime, $preferences->backup_course, "      sections info", 'incrementalbackup');
            $status = backup_course_sections($backup_file, $preferences);
        }
        //User info
        if ($status) {
            backup_add_to_log($starttime, $preferences->backup_course, "      user info", 'incrementalbackup');
            $status = backup_user_info($backup_file, $preferences);
        }
        //If we have selected to backup messages and we are
        //doing a SITE backup, let's do it
        if ($status && $preferences->backup_messages && $preferences->backup_course == SITEID) {
            backup_add_to_log($starttime, $preferences->backup_course, "      messages", 'incrementalbackup');
            if (!($status = backup_messages($backup_file, $preferences))) {
                notify("An error occurred while backing up messages");
            }
        }
        //If we have selected to backup blogs and we are
        //doing a SITE backup, let's do it
        if ($status && isset($preferences->backup_blogs) && isset($preferences->backup_course) && $preferences->backup_blogs && $preferences->backup_course == SITEID) {
            schedule_backup_log($starttime, $preferences->backup_course, "      blogs", 'incrementalbackup');
            $status = backup_blogs($backup_file, $preferences);
        }
        //If we have selected to backup quizzes, backup categories and
        //questions structure (step 1). See notes on mod/quiz/backuplib.php
        if ($status and isset($preferences->mods['quiz']->backup)) {
            backup_add_to_log($starttime, $preferences->backup_course, "      categories & questions", 'incrementalbackup');
            $status = backup_question_categories($backup_file, $preferences);
        }
        //Print logs if selected
        if ($status) {
            if ($preferences->backup_logs) {
                backup_add_to_log($starttime, $preferences->backup_course, "      logs", 'incrementalbackup');
                $status = backup_log_info($backup_file, $preferences);
            }
        }
        //Print scales info
        if ($status) {
            backup_add_to_log($starttime, $preferences->backup_course, "      scales", 'incrementalbackup');
            $status = backup_scales_info($backup_file, $preferences);
        }
        //Print groups info
        if ($status) {
            backup_add_to_log($starttime, $preferences->backup_course, "      groups", 'incrementalbackup');
            $status = backup_groups_info($backup_file, $preferences);
        }
        //Print groupings info
        if ($status) {
            backup_add_to_log($starttime, $preferences->backup_course, "      groupings", 'incrementalbackup');
            $status = backup_groupings_info($backup_file, $preferences);
        }
        //Print groupings_groups info
        if ($status) {
            backup_add_to_log($starttime, $preferences->backup_course, "      groupings_groups", 'incrementalbackup');
//.........这里部分代码省略.........
开发者ID:r007,项目名称:PMoodle,代码行数:101,代码来源:backup_sch_incremental.php

示例5: restoreCourse

 public static function restoreCourse($preferences, $session)
 {
     global $Out;
     // the initial set of preferences should be enough to get the restore started.
     // once in progress the restore will obtain the preferences from the backup file
     // itself
     if (!isset($preferences)) {
         return null;
     }
     // Assumes the backup file is in the course data directory and the
     // preferences are in the backup file itself.
     global $CFG;
     // for large files uncomment following code
     //@ini_set("max_execution_time","3000");
     //raise_memory_limit("192M");
     $file = self::createBackupFilePath($preferences->course_id);
     $file .= '/' . $preferences->backup_name;
     //path to file
     //Check the file exists
     if (!is_file($file)) {
         return false;
     }
     //Check the file name ends with .zip
     if (!substr($file, -4) == ".zip") {
         return false;
     }
     //Now calculate the unique_code for this restore
     $backup_unique_code = $preferences->backup_unique_code;
     //Now check and create the backup dir (if it doesn't exist)
     $status = check_and_create_backup_dir($backup_unique_code);
     //Empty dir
     if ($status) {
         $status = clear_backup_dir($backup_unique_code);
     }
     //Now delete old data and directories under dataroot/temp/backup
     if ($status) {
         $status = backup_delete_old_data();
     }
     $tempBackupPath = synch_backup_controller::createTempBackupPath($backup_unique_code);
     //Now copy the zip file to dataroot/temp/backup/backup_unique_code
     if ($status) {
         if (!($status = backup_copy_file($file, $tempBackupPath . "/" . basename($file)))) {
             // There has been a problem. Invalid name or bad perms
             return false;
         }
     }
     //Now unzip the file
     if ($status) {
         if (!($status = restore_unzip($tempBackupPath . "/" . basename($file)))) {
             // error: Invalid zip file
             return false;
         }
     }
     //Check for Blackboard backups and convert
     if ($status) {
         require_once "{$CFG->dirroot}/backup/bb/restore_bb.php";
         $status = blackboard_convert($tempBackupPath);
     }
     // backup file has now been unpacked. Retrieve the serialized preferences
     $preferencesPath = $tempBackupPath . '/' . self::getPreferencesFileName();
     $preferences = FileSystem::unSerializeFromFile($preferencesPath);
     // Now we have the preferences from the backup we need to tailor it to our current needs
     // should we be updating an existing item or creating one.
     $dataItemId = SynchContentHierarchy::generateDataItemId($preferences->course_id, synch_view_controller::$TYPE_ID_COURSE);
     global $SynchManager, $SynchServerController;
     $itemExists = $SynchManager->getSessionItemExistsByServerId($SynchServerController->getServerId(), $session);
     if (isset($itemExists) && is_array($itemExists) && in_array($dataItemId, $itemExists)) {
         $preferences->restoreto = 1;
         $preferences->deleting = 1;
     } else {
         $preferences->restoreto = 2;
     }
     //Now check for the moodle.xml file
     if ($status) {
         $xml_file = $tempBackupPath . "/moodle.xml";
         if (!($status = restore_check_moodle_file($xml_file))) {
             if (!is_file($xml_file)) {
                 //Error checking backup file. moodle.xml not found at root level of zip file
                 return false;
             } else {
                 //Error checking backup file. moodle.xml is incorrect or corrupted.
                 return false;
             }
         }
     }
     //unpack backup file
     //read contents
     //Reading info from file
     $info = restore_read_xml_info($xml_file);
     //Reading course_header from file
     $courseHeader = restore_read_xml_course_header($xml_file);
     //Save course header and info into php session
     if ($status) {
         //$SESSION->info = $info;
         //$SESSION->course_header = $course_header;
     }
     global $restore;
     $restore = $preferences;
     $message = null;
     $restoreSuccess = restore_execute($preferences, $info, $courseHeader, $message);
//.........这里部分代码省略.........
开发者ID:r007,项目名称:PMoodle,代码行数:101,代码来源:synch_backup_controller.php


注:本文中的check_and_create_backup_dir函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。