コード例 #1
0
// whatever the case, the master record is always added as an "extra" mnet_host record, after "self", and "all Hosts".
$remotehost = $DB->get_record_select('mnet_host', " TRIM(REPLACE(public_key, '\r', '')) = TRIM(REPLACE('{$masterpk}', '\r', '')) AND id > 1 ");
if ($remotehost || $test) {
    // $CFG->bootstrap_init is a key that has been added by master when postprocessing the deployment template
    // We check that the public key given matches the identity of the master who initiated the platform restoring.
    // get it hard !!
    $initroot = $DB->get_field('config', array('name' => 'bootstrap_init'));
    if ($test || $initroot == $remotehost->wwwroot) {
        // at this time, the local platform may not have self key, or may inherit
        // an obsolete key from the template SQL backup.
        // we must fix that forcing a local key replacement
        $MNET = new mnet_environment();
        $MNET->init();
        $MNET->name = '';
        $oldkey = $MNET->public_key;
        $MNET->replace_keys();
        // debug_trace("REMOTE : Replaced keys from \n$oldkey\nto\n{$MNET->public_key}\n");
        // Finally we disable the keyboot script locking definitively the door.
        set_config('bootstrap_init', null);
        echo "SUCCESS";
    } else {
        echo "ERROR : Calling net booting host {$remotehost->wwwroot} don't match with master : {$initroot}";
    }
} else {
    echo "ERROR : Master host not found or master host key is empty";
}
function getRealPOST()
{
    $pairs = explode("&", file_get_contents("php://input"));
    $vars = array();
    if (!empty($pairs)) {