Beispiel #1
0
    }
    if (!array_key_exists('smf_tag', $btit_settings)) {
        $btit_settings['smf_tag'] = '';
    }
    if (!array_key_exists('invitation_only', $btit_settings)) {
        $btit_settings['invitation_only'] = false;
    }
    if (!array_key_exists('invitation_reqvalid', $btit_settings)) {
        $btit_settings['invitation_reqvalid'] = false;
    }
}
$btit_settings = get_cached_config('SELECT `key`,`value` FROM ' . $TABLE_PREFIX . 'settings', $reload_cfg_interval);
if (!is_array($btit_settings)) {
    $btit_settings = array();
}
apply_default_settings();
/* Tracker Configuration
 *
 *  This file provides configuration informatino for
 *  the tracker. The user-editable variables are at the top. It is
 *  recommended that you do not change the database settings
 *  unless you know what you are doing.
 */
//Maximum reannounce interval.
$GLOBALS['report_interval'] = $btit_settings['max_announce'];
//Minimum reannounce interval. Optional.
$GLOBALS['min_interval'] = $btit_settings['min_announce'];
//Number of peers to send in one request.
$GLOBALS['maxpeers'] = $btit_settings['max_peers_per_announce'];
//If set to true, then the tracker will accept any and all
//torrents given to it. Not recommended, but available if you need it.
Beispiel #2
0
    /// Continue with the instalation
    $db->debug = false;
    if ($status) {
        //ugly hack - install new groups: MDL-9217
        require "{$CFG->dirroot}/group/version.php";
        set_config('group_version', $group_version);
        //install_group_db();
        // Install the roles system.
        moodle_install_roles();
        set_config('statsrolesupgraded', time());
        // Write default settings unconditionally (i.e. even if a setting is already set, overwrite it)
        // (this should only have any effect during initial install).
        $adminroot = admin_get_root();
        $adminroot->prune('backups');
        // backup settings table not created yet
        apply_default_settings($adminroot);
        /// This is used to handle any settings that must exist in $CFG but which do not exist in
        /// admin_get_root()/$ADMIN as admin_setting objects (there are some exceptions).
        apply_default_exception_settings(array('alternateloginurl' => '', 'auth' => 'email', 'auth_pop3mailbox' => 'INBOX', 'changepassword' => '', 'enrol' => 'manual', 'enrol_plugins_enabled' => 'manual', 'guestloginbutton' => 1, 'registerauth' => 'email', 'style' => 'default', 'template' => 'default', 'theme' => 'standardwhite', 'filter_multilang_converted' => 1));
        notify($strdatabasesuccess, "green");
        require_once $CFG->dirroot . '/mnet/lib.php';
    } else {
        error("Error: Main databases NOT set up successfully");
    }
    print_continue('index.php');
    print_footer('none');
    die;
}
/// Check version of Moodle code on disk compared with database
/// and upgrade if possible.
if (file_exists("{$CFG->dirroot}/lib/db/{$CFG->dbtype}.php")) {
Beispiel #3
0
function upgrade_backup_db($continueto)
{
    /// This function upgrades the backup tables, if necessary
    /// It's called from admin/index.php, also backup.php and restore.php
    global $CFG, $db;
    require_once "{$CFG->dirroot}/backup/version.php";
    // Get code versions
    if (empty($CFG->backup_version)) {
        // Backup has never been installed.
        $strdatabaseupgrades = get_string("databaseupgrades");
        $navlinks = array();
        $navlinks[] = array('name' => $strdatabaseupgrades, 'link' => null, 'type' => 'misc');
        $navigation = build_navigation($navlinks);
        print_header($strdatabaseupgrades, $strdatabaseupgrades, $navigation, "", upgrade_get_javascript(), false, " ", " ");
        upgrade_log_start();
        print_heading('backup');
        $db->debug = true;
        /// Both old .sql files and new install.xml are supported
        /// but we priorize install.xml (XMLDB) if present
        $status = false;
        if (file_exists($CFG->dirroot . '/backup/db/install.xml')) {
            $status = install_from_xmldb_file($CFG->dirroot . '/backup/db/install.xml');
            //New method
        } else {
            if (file_exists($CFG->dirroot . '/backup/db/' . $CFG->dbtype . '.sql')) {
                $status = modify_database($CFG->dirroot . '/backup/db/' . $CFG->dbtype . '.sql');
                //Old method
            }
        }
        $db->debug = false;
        if ($status) {
            if (set_config("backup_version", $backup_version) and set_config("backup_release", $backup_release)) {
                //initialize default backup settings now
                $adminroot = admin_get_root();
                apply_default_settings($adminroot->locate('backups'));
                notify(get_string("databasesuccess"), "green");
                notify(get_string("databaseupgradebackups", "", $backup_version), "green");
                print_continue($continueto);
                print_footer('none');
                exit;
            } else {
                error("Upgrade of backup system failed! (Could not update version in config table)");
            }
        } else {
            error("Backup tables could NOT be set up successfully!");
        }
    }
    /// Upgrading code starts here
    $oldupgrade = false;
    $newupgrade = false;
    if (is_readable($CFG->dirroot . '/backup/db/' . $CFG->dbtype . '.php')) {
        include_once $CFG->dirroot . '/backup/db/' . $CFG->dbtype . '.php';
        // defines old upgrading function
        $oldupgrade = true;
    }
    if (is_readable($CFG->dirroot . '/backup/db/upgrade.php')) {
        include_once $CFG->dirroot . '/backup/db/upgrade.php';
        // defines new upgrading function
        $newupgrade = true;
    }
    if ($backup_version > $CFG->backup_version) {
        // Upgrade tables
        $strdatabaseupgrades = get_string("databaseupgrades");
        $navigation = array(array('name' => $strdatabaseupgrades, 'link' => null, 'type' => 'misc'));
        print_header($strdatabaseupgrades, $strdatabaseupgrades, build_navigation($navigation), '', upgrade_get_javascript());
        upgrade_log_start();
        print_heading('backup');
        /// Run de old and new upgrade functions for the module
        $oldupgrade_function = 'backup_upgrade';
        $newupgrade_function = 'xmldb_backup_upgrade';
        /// First, the old function if exists
        $oldupgrade_status = true;
        if ($oldupgrade && function_exists($oldupgrade_function)) {
            $db->debug = true;
            $oldupgrade_status = $oldupgrade_function($CFG->backup_version);
        } else {
            if ($oldupgrade) {
                notify('Upgrade function ' . $oldupgrade_function . ' was not available in ' . '/backup/db/' . $CFG->dbtype . '.php');
            }
        }
        /// Then, the new function if exists and the old one was ok
        $newupgrade_status = true;
        if ($newupgrade && function_exists($newupgrade_function) && $oldupgrade_status) {
            $db->debug = true;
            $newupgrade_status = $newupgrade_function($CFG->backup_version);
        } else {
            if ($newupgrade) {
                notify('Upgrade function ' . $newupgrade_function . ' was not available in ' . '/backup/db/upgrade.php');
            }
        }
        $db->debug = false;
        /// Now analyze upgrade results
        if ($oldupgrade_status && $newupgrade_status) {
            // No upgrading failed
            if (set_config("backup_version", $backup_version) and set_config("backup_release", $backup_release)) {
                notify(get_string("databasesuccess"), "green");
                notify(get_string("databaseupgradebackups", "", $backup_version), "green");
                print_continue($continueto);
                print_footer('none');
                exit;
            } else {
                error("Upgrade of backup system failed! (Could not update version in config table)");
            }
        } else {
            error("Upgrade failed!  See backup/version.php");
        }
    } else {
        if ($backup_version < $CFG->backup_version) {
            upgrade_log_start();
            notify("WARNING!!!  The code you are using is OLDER than the version that made these databases!");
        }
    }
    upgrade_log_finish();
}
    // update forum track preference
    useredit_update_trackforums($user, $usernew);
    // save custom profile fields data
    profile_save_data($usernew);
    if ($user->id == $USER->id) {
        // Override old $USER session variable
        $usernew = (array) get_record('user', 'id', $usernew->id);
        // reload from db
        foreach ($usernew as $variable => $value) {
            $USER->{$variable} = $value;
        }
        if (!empty($USER->newadminuser)) {
            unset($USER->newadminuser);
            // try to apply defaults again - some of them might depend on admin user info
            $adminroot = admin_get_root();
            apply_default_settings($adminroot, false);
            // redirect to admin/ to continue with installation
            redirect("{$CFG->wwwroot}/{$CFG->admin}/");
        } else {
            redirect("{$CFG->wwwroot}/user/view.php?id={$USER->id}&course={$course->id}");
        }
    } else {
        redirect("{$CFG->wwwroot}/{$CFG->admin}/user.php");
    }
    //never reached
}
/// Display page header
if ($user->id == -1 or $user->id != $USER->id) {
    if ($user->id == -1) {
        admin_externalpage_setup('addnewuser');
        admin_externalpage_print_header();
Beispiel #5
0
function apply_default_settings(&$node)
{
    global $CFG;
    if (is_a($node, 'admin_category')) {
        $entries = array_keys($node->children);
        foreach ($entries as $entry) {
            apply_default_settings($node->children[$entry]);
        }
        return;
    }
    if (is_a($node, 'admin_settingpage')) {
        foreach ($node->settings as $setting) {
            $CFG->{$setting->name} = $setting->defaultsetting;
            $setting->write_setting($setting->defaultsetting);
            unset($setting);
            // needed to prevent odd (imho) reference behaviour
            // see http://www.php.net/manual/en/language.references.whatdo.php#AEN6399
        }
        return;
    }
    return;
}
/**
 * This function applies default settings.
 * @param object $node
 * @param bool $uncoditional if true overrides all values with defaults
 * @return void
 */
function apply_default_settings(&$node, $unconditional = true)
{
    global $CFG;
    if (is_a($node, 'admin_category')) {
        $entries = array_keys($node->children);
        foreach ($entries as $entry) {
            apply_default_settings($node->children[$entry]);
        }
        return;
    }
    if (is_a($node, 'admin_settingpage')) {
        foreach ($node->settings as $setting) {
            if (!$unconditional and !is_null($setting->get_setting)) {
                //do not override existing defaults
                continue;
            }
            $defaultsetting = $setting->get_defaultsetting();
            if (is_null($defaultsetting)) {
                // no value yet - default maybe applied after admin user creation or in upgradesettings
                continue;
            }
            $CFG->{$setting->name} = $defaultsetting;
            $setting->write_setting($defaultsetting);
            unset($setting);
            // needed to prevent odd (imho) reference behaviour
            // see http://www.php.net/manual/en/language.references.whatdo.php#AEN6399
        }
        return;
    }
    return;
}