本文整理汇总了PHP中mnet_peer::bootstrap方法的典型用法代码示例。如果您正苦于以下问题:PHP mnet_peer::bootstrap方法的具体用法?PHP mnet_peer::bootstrap怎么用?PHP mnet_peer::bootstrap使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mnet_peer
的用法示例。
在下文中一共展示了mnet_peer::bootstrap方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* Execute the command.
* @param mixed $hosts The host where run the command (may be wwwroot or an array).
* @throws Command_Exception.
*/
public function run($hosts)
{
global $CFG, $USER;
// Adding constants.
require_once $CFG->dirroot . '/local/vmoodle/rpclib.php';
// Checking capabilities.
if (!has_capability('local/vmoodle:execute', \context_system::instance())) {
throw new Command_Exception('insuffisantcapabilities');
}
// Getting role
$table = $this->getParameter('table')->getValue();
// Creating XMLRPC client to read role configuration
$rpc_client = new \local_vmoodle\XmlRpc_Client();
$rpc_client->set_method('local/vmoodle/plugins/roles/rpclib.php/mnetadmin_rpc_get_role_allow_table');
$rpc_client->add_param($table, 'string');
$rpc_client->add_param('', 'string');
// get for all roles
// Initializing responses
$responses = array();
// Creating peers.
$mnet_hosts = array();
foreach ($hosts as $host => $name) {
$mnet_host = new \mnet_peer();
if ($mnet_host->bootstrap($host, null, 'moodle')) {
$mnet_hosts[] = $mnet_host;
} else {
$responses[$host] = (object) array('status' => MNET_FAILURE, 'error' => get_string('couldnotcreateclient', 'local_vmoodle', $host));
}
}
// Sending requests.
foreach ($mnet_hosts as $mnet_host) {
// Sending request.
if (!$rpc_client->send($mnet_host)) {
$response = new \StdClass();
$response->status = MNET_FAILURE;
$response->errors[] = implode('<br/>', $rpc_client->getErrors($mnet_host));
if (debugging()) {
echo '<pre>';
var_dump($rpc_client);
echo '</pre>';
}
} else {
$response = json_decode($rpc_client->response);
}
// Recording response.
$responses[$mnet_host->wwwroot] = $response;
// Recording capabilities.
if ($response->status == RPC_SUCCESS) {
$this->capabilities[$mnet_host->wwwroot] = $response->value;
}
}
// Saving results.
$this->results = $responses + $this->results;
// Processing results.
$this->_process();
}
示例2: run
/**
* Execute the command.
* @param mixed $host The hosts where run the command (may be wwwroot or an array).
* @throws Command_SetConfig_Exception
*/
public function run($hosts)
{
global $CFG, $USER;
// Adding constants.
require_once $CFG->dirroot . '/local/vmoodle/rpclib.php';
// Checking host.
if (!is_array($hosts)) {
$hosts = array($hosts => 'Unnamed host');
}
// Checking capabilities.
if (!has_capability('local/vmoodle:execute', \context_system::instance())) {
throw new Command_SetConfig_Exception('insuffisantcapabilities');
}
// Initializing responses.
$responses = array();
// Creating peers.
$mnet_hosts = array();
foreach ($hosts as $host => $name) {
$mnet_host = new \mnet_peer();
if ($mnet_host->bootstrap($host, null, 'moodle')) {
$mnet_hosts[] = $mnet_host;
} else {
$responses[$host] = (object) array('status' => MNET_FAILURE, 'error' => get_string('couldnotcreateclient', 'local_vmoodle', $host));
}
}
// Getting command.
$command = $this->isReturned();
// Creating XMLRPC client.
$rpc_client = new \local_vmoodle\XmlRpc_Client();
$rpc_client->set_method('local/vmoodle/plugins/generic/rpclib.php/mnetadmin_rpc_set_config');
$rpc_client->add_param($this->getParameter('key')->getValue(), 'string');
$rpc_client->add_param($this->getParameter('value')->getValue(), 'string');
$rpc_client->add_param(null, 'string');
$rpc_client->add_param($command, 'boolean');
// Sending requests.
foreach ($mnet_hosts as $mnet_host) {
// Sending request.
if (!$rpc_client->send($mnet_host)) {
$response = new StdClass();
$response->status = MNET_FAILURE;
$response->errors[] = implode('<br/>', $rpc_client->getErrors($mnet_host));
if (debugging()) {
echo '<pre>';
var_dump($rpc_client);
echo '</pre>';
}
} else {
$response = json_decode($rpc_client->response);
}
// Recording response.
$responses[$mnet_host->wwwroot] = $response;
}
// Saving results.
$this->results = $responses + $this->results;
}
示例3: vmoodle_get_field
/**
* Get fields values of a virtual platform via MNET service.
* @param string $host The virtual platform to aim.
* @param string $table The table to read.
* @param mixed $select The value of id or alternative field.
* @param string $fields The fileds to retrieve (optional).
* @throws Vmoodle_Command_Sql_Exception.
*/
function vmoodle_get_field($host, $table, $select, $fields = '*')
{
global $CFG, $USER, $DB;
// Checking capabilities.
if (!has_capability('local/vmoodle:execute', context_system::instance())) {
throw new Command_Sql_Exception('unsiffisantcapability');
}
// Checking host.
if (!$DB->get_record('mnet_host', array('wwwroot' => $host))) {
throw new Command_Sql_Exception('invalidhost');
}
// Checking table.
if (empty($table) || !is_string($table)) {
throw new Command_Sql_Exception('invalidtable');
}
// Checking select.
if (empty($select) || !is_array($select) && !is_int($select)) {
throw new Command_Sql_Exception('invalidselect');
}
if (!is_array($select)) {
$select = array('id' => $select);
}
// Checking field.
if (empty($fields)) {
throw new Command_Sql_Exception('invalidfields');
}
if (!is_array($fields)) {
$fields = array($fields);
}
// Creating peer.
$mnet_host = new mnet_peer();
if (!$mnet_host->bootstrap($host, null, 'moodle')) {
return (object) array('status' => MNET_FAILURE, 'error' => get_string('couldnotcreateclient', 'vmoodleadminset_sql', $host));
}
// Creating XMLRPC client.
$rpc_client = new \bock_vmoodle\XmlRpc_Client();
$rpc_client->add_param($table, 'string');
$rpc_client->add_param($fields, 'array');
$rpc_client->add_param($select, 'array');
// Sending request.
if (!$rpc_client->send($mnet_host)) {
if (debugging()) {
echo '<pre>';
var_dump($rpc_client);
echo '</pre>';
}
}
// Returning result.
return $rpc_client->response;
}
示例4: trim
$simpleform = new mnet_simple_host_form();
// the one that goes on the bottom of the main page
$reviewform = null;
// set up later in different code branches, so mnet_peer can be passed to the constructor
// if the first form has been submitted, bootstrap the peer and load up the review form
if ($formdata = $simpleform->get_data()) {
// ensure we remove trailing slashes
$formdata->wwwroot = trim($formdata->wwwroot);
$formdata->wwwroot = rtrim($formdata->wwwroot, '/');
// ensure the wwwroot starts with a http or https prefix
if (strtolower(substr($formdata->wwwroot, 0, 4)) != 'http') {
$formdata->wwwroot = 'http://' . $formdata->wwwroot;
}
$mnet_peer->set_applicationid($formdata->applicationid);
$application = $DB->get_field('mnet_application', 'name', array('id' => $formdata->applicationid));
$mnet_peer->bootstrap($formdata->wwwroot, null, $application);
// bootstrap the second form straight with the data from the first form
$reviewform = new mnet_review_host_form(null, array('peer' => $mnet_peer));
// the second step (also the edit host form)
$formdata->oldpublickey = $mnet_peer->public_key;
// set this so we can confirm on form post without having to recreate the mnet_peer object
$reviewform->set_data($mnet_peer);
echo $OUTPUT->header();
echo $OUTPUT->box_start();
$reviewform->display();
echo $OUTPUT->box_end();
echo $OUTPUT->footer();
exit;
} else {
if ($simpleform->is_submitted()) {
// validation failed
示例5: mnet_keyswap
/**
* Accepts a public key from a new remote host and returns the public key for
* this host. If 'register all hosts' is turned on, it will bootstrap a record
* for the remote host in the mnet_host table (if it's not already there)
*
* @param string $function XML-RPC requires this but we don't... discard!
* @param array $params Array of parameters
* $params[0] is the remote wwwroot
* $params[1] is the remote public key
* @return string The XML-RPC response
*/
function mnet_keyswap($function, $params) {
global $CFG;
$return = array();
$mnet = get_mnet_environment();
if (!empty($CFG->mnet_register_allhosts)) {
$mnet_peer = new mnet_peer();
@list($wwwroot, $pubkey, $application) = each($params);
$keyok = $mnet_peer->bootstrap($wwwroot, $pubkey, $application);
if ($keyok) {
$mnet_peer->commit();
}
}
return $mnet->public_key;
}
示例6: run
public function run($hosts)
{
global $CFG, $USER, $DB;
// Adding constants.
require_once $CFG->dirroot . '/local/vmoodle/rpclib.php';
// Checking host.
if (!is_array($hosts)) {
$hosts = array($hosts => 'Unnamed host');
}
// Checking capabilities.
if (!has_capability('local/vmoodle:execute', \context_system::instance())) {
throw new Command_Upgrade_Exception('insuffisantcapabilities');
}
// Initializing responses.
$responses = array();
// Creating peers.
$mnet_hosts = array();
foreach ($hosts as $host => $name) {
$mnet_host = new \mnet_peer();
if ($mnet_host->bootstrap($host, null, 'moodle')) {
$mnet_hosts[] = $mnet_host;
} else {
$responses[$host] = (object) array('status' => RPC_FAILURE, 'error' => get_string('couldnotcreateclient', 'local_vmoodle', $host));
}
}
// Creating XMLRPC client.
$rpc_client = new \local_vmoodle\XmlRpc_Client();
$rpc_client->set_method('local/vmoodle/plugins/upgrade/rpclib.php/mnetadmin_rpc_upgrade');
// Sending requests
foreach ($mnet_hosts as $mnet_host) {
/**
* just for testing
if ($mnet_host->wwwroot == $CFG->wwwroot){
require_once $CFG->dirroot.'/local/vmoodle/plugins/upgrade/rpclib.php';
if (!($user_mnet_host = $DB->get_record('mnet_host', array('id' => $USER->mnethostid))))
throw new Command_Exception('unknownuserhost');
$user = array(
'username' => $USER->username,
'remoteuserhostroot' => $user_mnet_host->wwwroot,
'remotehostroot' => $CFG->wwwroot
);
$response = mnetadmin_rpc_upgrade($user, true);
$responses[$mnet_host->wwwroot] = $response;
continue;
}
*/
// Sending request
if (!$rpc_client->send($mnet_host)) {
$response = new StdClass();
$response->status = RPC_FAILURE;
$response->errors[] = implode('<br/>', $rpc_client->getErrors($mnet_host));
if (debugging()) {
// echo '<pre>';
// var_dump($rpc_client);
// echo '</pre>';
}
} else {
$response = json_decode($rpc_client->response);
}
// Recording response.
$responses[$mnet_host->wwwroot] = $response;
}
// Saving results.
$this->results = $responses + $this->results;
}
示例7: run
/**
* Execute the command.
* @param mixed $hosts The host where run the command (may be wwwroot or an array).
* @throws Command_Exception.
*/
public function run($hosts)
{
global $CFG, $USER;
// Adding constants.
require_once $CFG->dirroot . '/local/vmoodle/rpclib.php';
// Checking capabilities.
if (!has_capability('local/vmoodle:execute', \context_system::instance())) {
throw new Command_Exception('insuffisantcapabilities');
}
// Getting role.
$role = $this->getParameter('role')->getValue();
// Getting platform.
$platform = $this->getParameter('platform')->getValue();
// Getting capability.
$capability = $this->getParameter('capability')->getValue();
// Checking hosts.
if (array_key_exists($platform, $hosts)) {
$platforms = get_available_platforms();
throw new Command_Role_Exception('syncwithitself', (object) array('role' => $role, 'platform' => $platforms[$platform]));
}
// Creating peer to read role configuration.
$mnet_host = new \mnet_peer();
if (!$mnet_host->bootstrap($this->getParameter('platform')->getValue(), null, 'moodle')) {
$response = (object) array('status' => MNET_FAILURE, 'error' => get_string('couldnotcreateclient', 'local_vmoodle', $platform));
foreach ($hosts as $host => $name) {
$this->results[$host] = $response;
}
return;
}
// Creating XMLRPC client to read role configuration.
$rpc_client = new \local_vmoodle\XmlRpc_Client();
$rpc_client->set_method('local/vmoodle/plugins/roles/rpclib.php/mnetadmin_rpc_get_role_capabilities');
$rpc_client->add_param($role, 'string');
$rpc_client->add_param($capability, 'string');
// Checking result.
if (!($rpc_client->send($mnet_host) && ($response = json_decode($rpc_client->response)) && ($response->status == RPC_SUCCESS || $response->status == RPC_FAILURE_RECORD && (in_array($response->errors, 'No capabilites for this role.') || in_array($response->error, 'No role capability found.'))))) {
// Creating response.
if (!isset($response)) {
$response = new \StdClass();
$response->status = MNET_FAILURE;
$response->errors[] = implode('<br/>', $rpc_client->getErrors($mnet_host));
}
if (debugging()) {
echo '<pre>';
var_dump($rpc_client);
ob_flush();
echo '</pre>';
}
// Saving results.
foreach ($hosts as $host => $name) {
$this->results[$host] = $response;
}
return;
}
// Getting role configuration.
if ($response->status == RPC_FAILURE_RECORD) {
$role_capability = array($capability => null);
} else {
$role_capability = (array) $response->value;
}
unset($response);
// Initializing responses.
$responses = array();
// Creating peers.
$mnet_hosts = array();
foreach ($hosts as $host => $name) {
$mnet_host = new \mnet_peer();
if ($mnet_host->bootstrap($host, null, 'moodle')) {
$mnet_hosts[] = $mnet_host;
} else {
$responses[$host] = (object) array('status' => MNET_FAILURE, 'error' => get_string('couldnotcreateclient', 'local_vmoodle', $host));
}
}
// Creating XMLRPC client.
$rpc_client = new \local_vmoodle\XmlRpc_Client();
$rpc_client->set_method('local/vmoodle/plugins/roles/rpclib.php/mnetadmin_rpc_set_role_capabilities');
$rpc_client->add_param($role, 'string');
$rpc_client->add_param($role_capability, 'string');
$rpc_client->add_param(false, 'boolean');
// Sending requests.
foreach ($mnet_hosts as $mnet_host) {
// Sending request.
if (!$rpc_client->send($mnet_host)) {
$response = new \StdClass();
$response->status = MNET_FAILURE;
$response->errors[] = implode('<br/>', $rpc_client->getErrors($mnet_host));
$response->error = 'Remote Set role capability : Remote proc error';
if (debugging()) {
echo '<pre>';
var_dump($rpc_client);
ob_flush();
echo '</pre>';
}
} else {
$response = json_decode($rpc_client->response);
//.........这里部分代码省略.........
示例8: mnet_keyswap
/**
* Accepts a public key from a new remote host and returns the public key for
* this host. If 'register all hosts' is turned on, it will bootstrap a record
* for the remote host in the mnet_host table (if it's not already there)
*
* @param string $function XML-RPC requires this but we don't... discard!
* @param array $params Array of parameters
* $params[0] is the remote wwwroot
* $params[1] is the remote public key
* @return string The XML-RPC response
*/
function mnet_keyswap($function, $params)
{
global $CFG, $MNET;
$return = array();
if (!empty($CFG->mnet_register_allhosts)) {
$mnet_peer = new mnet_peer();
$keyok = $mnet_peer->bootstrap($params[0], $params[1]);
if ($keyok) {
$mnet_peer->commit();
}
}
return $MNET->public_key;
}
示例9: run
/**
* Execute the command.
* @param $hosts mixed The host where run the command (may be wwwroot or an array).
* @throws Command_Exception.
*/
public function run($hosts)
{
global $CFG, $USER;
// Adding constants.
require_once $CFG->dirroot . '/local/vmoodle/rpclib.php';
// Checking capability to run.
if (!has_capability('local/vmoodle:execute', \context_system::instance())) {
throw new Command_Exception('insuffisantcapabilities');
}
// Getting plugin.
list($type, $plugin) = explode('/', $this->getParameter('plugin')->getValue());
// Getting the state.
$state = $this->getParameter('state')->getValue();
$pm = \plugin_manager::instance();
$plugininfo = $pm->get_plugin_info($plugin);
if (empty($plugininfo->type)) {
if (empty($plugininfo)) {
$plugininfo = new \StdClass();
}
$plugininfo->type = $type;
}
$plugininfo->action = $state;
$plugininfos[$plugin] = (array) $plugininfo;
// Creating XMLRPC client to change remote configuration.
$rpc_client = new \local_vmoodle\XmlRpc_Client();
$rpc_client->set_method('local/vmoodle/plugins/plugins/rpclib.php/mnetadmin_rpc_set_plugins_states');
$rpc_client->add_param($plugininfos, 'array');
// Initializing responses.
$responses = array();
// Creating peers.
$mnet_hosts = array();
if (!empty($hosts)) {
foreach ($hosts as $host => $name) {
$mnet_host = new \mnet_peer();
if ($mnet_host->bootstrap($host, null, 'moodle')) {
$mnet_hosts[] = $mnet_host;
} else {
$responses[$host] = (object) array('status' => MNET_FAILURE, 'error' => get_string('couldnotcreateclient', 'local_vmoodle', $host));
}
}
}
// Sending requests.
foreach ($mnet_hosts as $mnet_host) {
// Sending request.
if (!$rpc_client->send($mnet_host)) {
$response = new \StdClass();
$response->status = MNET_FAILURE;
$response->errors[] = implode('<br/>', $rpc_client->getErrors($mnet_host));
if (debugging()) {
echo '<pre>';
var_dump($rpc_client);
echo '</pre>';
}
} else {
$response = json_decode($rpc_client->response);
}
// Recording response.
$responses[$mnet_host->wwwroot] = $response;
// Recording plugin descriptors.
if ($response->status == RPC_SUCCESS) {
$this->plugins[$mnet_host->wwwroot] = @$response->value;
}
}
// Saving results
$this->results = $responses + $this->results;
}
示例10: run
/**
* Execute the command.
* @param mixed $hosts The host where run the command (may be wwwroot or an array).
* @throws Command_Exception
*/
function run($hosts)
{
global $CFG, $USER;
// Adding constants.
require_once $CFG->dirroot . '/local/vmoodle/rpclib.php';
// Checking capabilities.
if (!has_capability('local/vmoodle:execute', context_system::instance())) {
throw new Command_Exception('insuffisantcapabilities');
}
// Getting plugintype.
$plugintype = $this->getParameter('plugintype')->getValue();
// Checking hosts.
$platform = $this->getParameter('platform')->getValue();
if (array_key_exists($platform, $hosts)) {
$platforms = get_available_platforms();
throw new Command_Plugins_Exception('syncwithitself');
}
// Creating peer to read plugins configuration from the designated peer.
$mnet_host = new mnet_peer();
if (!$mnet_host->bootstrap($this->getParameter('platform')->getValue(), null, 'moodle')) {
$response = (object) array('status' => MNET_FAILURE, 'error' => get_string('couldnotcreateclient', 'local_vmoodle', $platform));
// if we fail, we fail for all.
foreach ($hosts as $host => $name) {
$this->results[$host] = $response;
}
return;
}
// Creating XMLRPC client to read plugins configuration.
$rpc_client = new \local_vmoodle\XmlRpc_Client();
$rpc_client->set_method('local/vmoodle/plugins/plugins/rpclib.php/mnetadmin_rpc_get_plugins_info');
$rpc_client->add_param($plugintype, 'string');
// Checking result.
if (!($rpc_client->send($mnet_host) && ($response = json_decode($rpc_client->response)) && $response->status == RPC_SUCCESS)) {
// Creating response.
if (!isset($response)) {
$response = new Stdclass();
$response->status = MNET_FAILURE;
$response->errors[] = implode('<br/>', $rpc_client->getErrors($mnet_host));
$response->error = implode('<br/>', $rpc_client->getErrors($mnet_host));
}
if (debugging()) {
echo '<pre>';
var_dump($rpc_client);
ob_flush();
echo '</pre>';
}
// result is a plugin info structure that needs be replicated remotely to all targets.
$plugininfos = $response->value;
return;
}
// Initializing responses.
$responses = array();
// Creating peers
$mnet_hosts = array();
foreach ($hosts as $host => $name) {
$mnet_host = new mnet_peer();
if ($mnet_host->bootstrap($host, null, 'moodle')) {
$mnet_hosts[] = $mnet_host;
} else {
$responses[$host] = (object) array('status' => MNET_FAILURE, 'error' => get_string('couldnotcreateclient', 'local_vmoodle', $host));
}
}
// Creating XMLRPC client
$rpc_client = new \local_vmoodle\XmlRpc_Client();
$rpc_client->set_method('local/vmoodle/plugins/plugins/rpclib.php/mnetadmin_rpc_set_plugins_states');
$rpc_client->add_param($plugininfos, 'object');
// plugininfos structure
// Sending requests.
foreach ($mnet_hosts as $mnet_host) {
// Sending request
if (!$rpc_client->send($mnet_host)) {
$response = new Stdclass();
$response->status = MNET_FAILURE;
$response->errors[] = implode('<br/>', $rpc_client->getErrors($mnet_host));
$response->error = 'Set plugin state failed : Remote call error';
if (debugging()) {
echo '<pre>';
var_dump($rpc_client);
ob_flush();
echo '</pre>';
}
} else {
$response = json_decode($rpc_client->response);
}
// Recording response.
$responses[$mnet_host->wwwroot] = $response;
}
// Saving results.
$this->results = $responses + $this->results;
}
示例11: redirect
redirect('peers.php', get_string('changessaved'));
} else {
$mnet_peer = new mnet_peer();
if (!empty($form->id)) {
$form->id = clean_param($form->id, PARAM_INT);
$mnet_peer->set_id($form->id);
} else {
// PARAM_URL requires a genuine TLD (I think) This breaks my testing
$temp_wwwroot = clean_param($form->wwwroot, PARAM_URL);
if ($temp_wwwroot !== $form->wwwroot) {
trigger_error("We now parse the wwwroot with PARAM_URL. Your URL will need to have a valid TLD, etc.");
error(get_string("invalidurl", 'mnet'), 'peers.php');
exit;
}
unset($temp_wwwroot);
$mnet_peer->bootstrap($form->wwwroot);
}
if (isset($form->name) && $form->name != $mnet_peer->name) {
$form->name = clean_param($form->name, PARAM_NOTAGS);
$mnet_peer->set_name($form->name);
}
if (isset($form->deleted) && ($form->deleted == '0' || $form->deleted == '1')) {
$mnet_peer->deleted = $form->deleted;
$mnet_peer->updateparams->deleted = $form->deleted;
}
if (isset($form->public_key)) {
$form->public_key = clean_param($form->public_key, PARAM_PEM);
if (empty($form->public_key)) {
error(get_string("invalidpubkey", 'mnet'), 'peers.php?step=update&hostid=' . $mnet_peer->id);
exit;
} else {
示例12: fopen
$fh = fopen($mfile, 'r');
$maharawebroot = fread($fh, filesize($mfile));
fclose($fh);
if (empty($maharawebroot)) {
error('Step3 - could not find maharawebroot. Config failed.');
}
$strheader = get_string('mahoodle', 'configmahoodle');
$navlinks = array();
$navlinks[] = array('name' => $strheader, 'link' => null, 'type' => 'misc');
$navigation = build_navigation($navlinks);
print_header($strheader, $strheader, $navigation, "");
//now set up pubkey stuff in Moodle
$mnet_peer = new mnet_peer();
$application = get_record('mnet_application', 'name', 'mahara');
$mnet_peer->set_applicationid($application->id);
$mnet_peer->bootstrap($maharawebroot, null, $application->name);
$mnet_peer->set_name('localmahara');
$mnet_peer->commit();
//now configure Networking in Moodle.
//first get hostid.
$hostid = get_field('mnet_host', 'id', 'name', 'localmahara');
$host2service = new stdClass();
$host2service->hostid = $hostid;
$host2service->serviceid = get_field('mnet_service', 'id', 'name', 'sso_idp');
$host2service->publish = 1;
$host2service->subscribe = 0;
if ($hostrec = get_record('mnet_host2service', 'hostid', $hostid, 'serviceid', $host2service->serviceid)) {
$host2service->id = $hostrec->id;
update_record('mnet_host2service', $host2service);
} else {
insert_record('mnet_host2service', $host2service);
示例13: mnetadmin_keyswap
/**
* NOT WORKING
* reimplementation of system.keyswapcall with capability of forcing the local renew
*
*/
function mnetadmin_keyswap($function, $params)
{
global $CFG, $MNET;
$return = array();
$wwwroot = $params[0];
$pubkey = $params[1];
$application = $params[2];
$forcerenew = $params[3];
if ($forcerenew == 0) {
// standard keyswap for first key recording
if (!empty($CFG->mnet_register_allhosts)) {
$mnet_peer = new mnet_peer();
$keyok = $mnet_peer->bootstrap($wwwroot, $pubkey, $application);
if ($keyok) {
$mnet_peer->commit();
}
}
} else {
$mnet_peer = new mnet_peer();
// we can only renew hosts that we know something about.
if ($mnet_peer->set_wwwroot($wwwroot)) {
$mnet_peer->public_key = clean_param($pubkey, PARAM_PEM);
$mnet_peer->public_key_expires = $mnet_peer->check_common_name($pubkey);
$mnet_peer->updateparams->public_key = clean_param($pubkey, PARAM_PEM);
$mnet_peer->updateparams->public_key_expires = $mnet_peer->check_common_name($pubkey);
$mnet_peer->commit();
} else {
return false;
// avoid giving our key to unkown hosts.
}
}
return $MNET->public_key;
}