//check that the PHP xmlrpc extension is enabled
if (!extension_loaded('xmlrpc')) {
    echo $OUTPUT->header();
    $xmlrpcnotification = $OUTPUT->doc_link('admin/environment/php_extension/xmlrpc', '');
    $xmlrpcnotification .= get_string('xmlrpcdisabled', 'local_hub');
    echo $OUTPUT->notification($xmlrpcnotification);
    echo $OUTPUT->footer();
    die;
}
$hub = new local_hub();
/// Check if the page has been called with trust argument
$delete = optional_param('delete', -1, PARAM_INTEGER);
$confirm = optional_param('confirm', false, PARAM_INTEGER);
if ($delete != -1 and $confirm and confirm_sesskey()) {
    $unregistercourses = optional_param('unregistercourses', false, PARAM_BOOL);
    $hub->delete_site($delete, $unregistercourses);
}
/// Check if the page has been called with trust argument
$trust = optional_param('trust', -1, PARAM_INTEGER);
if ($trust != -1 and confirm_sesskey()) {
    $id = required_param('id', PARAM_INTEGER);
    $site = $hub->get_site($id);
    if (!empty($site)) {
        $site->trusted = $trust;
        $hub->update_site($site);
    }
}
$search = optional_param('search', '', PARAM_TEXT);
$renderer = $PAGE->get_renderer('local_hub');
$contenthtml = "";
$moresiteshtml = "";
 */
require '../../../config.php';
require_once $CFG->libdir . '/adminlib.php';
require_once $CFG->dirroot . '/local/hub/lib.php';
require_once $CFG->dirroot . "/local/hub/admin/forms.php";
admin_externalpage_setup('hubstolensecret');
$hub = new local_hub();
$renderer = $PAGE->get_renderer('local_hub');
$stolen = optional_param('stolen', 0, PARAM_INT);
if ($stolen and sesskey()) {
    $confirm = optional_param('confirm', 0, PARAM_INT);
    if ($confirm) {
        //mark the token as stolen
        $hub->marksecretstolen($stolen);
        //delete site and web service token
        $hub->delete_site($stolen);
        $confirmmsg = $OUTPUT->notification(get_string('secretblocked', 'local_hub'), 'notifysuccess');
    } else {
        $hackedsite = $hub->get_site($stolen);
        echo $OUTPUT->header();
        echo $OUTPUT->heading(get_string('stolensecret', 'local_hub'));
        echo $renderer->stolensecret_confirmation($hackedsite);
        echo $OUTPUT->footer();
        die;
    }
}
$mform = new hub_search_stolen_secret();
if ($data = $mform->get_data()) {
    $sites = array();
    //search site
    if (!empty($data->secret)) {