示例#1
0
                redirect('peers.php?step=update&hostid=' . $mnet_peer->id, get_string('changessaved'));
            } else {
                print_error('invalidaction', 'error', 'index.php');
            }
        }
    }
} elseif (is_int($hostid)) {
    $mnet_peer = new mnet_peer();
    $mnet_peer->set_id($hostid);
    $currentkey = mnet_get_public_key($mnet_peer->wwwroot, $mnet_peer->application);
    if ($currentkey == $mnet_peer->public_key) {
        unset($currentkey);
    }
    $form = new stdClass();
    if ($hostid != $CFG->mnet_all_hosts_id) {
        $credentials = $mnet_peer->check_credentials($mnet_peer->public_key);
        include './mnet_review.html';
    } else {
        include './mnet_review_allhosts.html';
    }
} else {
    $hosts = $DB->get_records_sql('  SELECT 
                                    h.id, 
                                    h.wwwroot, 
                                    h.ip_address, 
                                    h.name, 
                                    h.public_key, 
                                    h.public_key_expires, 
                                    h.transport, 
                                    h.portno, 
                                    h.last_connect_time, 
示例#2
0
 function validation($data, $files)
 {
     $errors = array();
     if ($data['oldpublickey'] == $data['public_key']) {
         return;
     }
     $mnet_peer = new mnet_peer();
     // idiotic api
     $mnet_peer->wwwroot = $data['wwwroot'];
     // just hard-set this rather than bootstrap the object
     if (empty($data['public_key'])) {
         $errors['public_key'] = get_string('publickeyrequired', 'mnet');
     } else {
         if (!($credentials = $mnet_peer->check_credentials($data['public_key']))) {
             $errmsg = '';
             foreach ($mnet_peer->error as $err) {
                 $errmsg .= $err['code'] . ': ' . $err['text'] . '<br />';
             }
             $errors['public_key'] = get_string('invalidpubkey', 'mnet', $errmsg);
         }
     }
     unset($mnet_peer);
     return $errors;
 }