• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP mnet_peer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中mnet_peer的典型用法代码示例。如果您正苦于以下问题:PHP mnet_peer类的具体用法?PHP mnet_peer怎么用?PHP mnet_peer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了mnet_peer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: mnet_get_externalprofilefields

function mnet_get_externalprofilefields($hostid)
{
    /// Setup MNET environment
    global $MNET, $CFG;
    if (empty($MNET)) {
        $MNET = new mnet_environment();
        $MNET->init();
    }
    /// Setup the server
    $host = get_record('mnet_host', 'id', $hostid);
    //we retrieve the server(host) from the 'mnet_host' table
    if (empty($host)) {
        error('Invalid Hostid');
    }
    $mnet_peer = new mnet_peer();
    //we create a new mnet_peer (server/host)
    $mnet_peer->set_wwwroot($host->wwwroot);
    //we set this mnet_peer with the host http address
    $client = new mnet_xmlrpc_client();
    //create a new client
    $client->set_method('auth/mnet/auth.php/get_user_profile_fields');
    //tell it which method we're going to call
    $client->send($mnet_peer);
    //Call the server
    if (!empty($client->response['faultString'])) {
        error("Mnet error:" . $client->response['faultString']);
    }
    return $client->response;
}
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:29,代码来源:mnet_userprofile.php


示例2: refresh_key

 function refresh_key()
 {
     global $CFG;
     // set up an RPC request
     require_once $CFG->dirroot . '/mnet/xmlrpc/client.php';
     $mnetrequest = new mnet_xmlrpc_client();
     // Use any method - listServices is pretty lightweight.
     $mnetrequest->set_method('system/listServices');
     // Do RPC call and store response
     if ($mnetrequest->send($this) === true) {
         // Ok - we actually don't care about the result
         $temp = new mnet_peer();
         $temp->set_id($this->id);
         if ($this->public_key != $temp->public_key) {
             $newkey = clean_param($temp->public_key, PARAM_PEM);
             if (!empty($newkey)) {
                 $this->public_key = $newkey;
                 $this->updateparams->public_key = $newkey;
                 $this->commit();
                 return true;
             }
         }
     }
     return false;
 }
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:25,代码来源:remote_client.php


示例3: 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();
 }
开发者ID:gabrielrosset,项目名称:moodle-local_vmoodle,代码行数:61,代码来源:Command_Role_Allow_Compare.php


示例4: 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;
 }
开发者ID:gabrielrosset,项目名称:moodle-local_vmoodle,代码行数:60,代码来源:Command_SetConfig.php


示例5: 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;
}
开发者ID:gabrielrosset,项目名称:moodle-local_vmoodle,代码行数:58,代码来源:lib.php


示例6: vmoodle_get_remote_config

/**
 * fetches remotely a configuration value
 * @param object $mnethost a mnet host record.
 * @param string $configkey the configuration key
 * @param string $module the module (frankenstyle). If empty, will fetch into the global config scope.
 */
function vmoodle_get_remote_config($mnethost, $configkey, $module = '')
{
    global $CFG, $USER, $DB, $OUTPUT;
    if (empty($mnethost)) {
        return '';
    }
    if (!isset($USER)) {
        $user = $DB->get_record('user', array('username' => 'guest'));
    } else {
        if (empty($USER->id)) {
            $user = $DB->get_record('user', array('username' => 'guest'));
        } else {
            $user = $DB->get_record('user', array('id' => $USER->id));
        }
    }
    if (!($userhost = $DB->get_record('mnet_host', array('id' => $user->mnethostid)))) {
        return '';
    }
    $user->remoteuserhostroot = $userhost->wwwroot;
    $user->remotehostroot = $CFG->wwwroot;
    // get the sessions for each vmoodle that have same ID Number
    $rpcclient = new mnet_xmlrpc_client();
    $rpcclient->set_method('local/vmoodle/plugins/generic/rpclib.php/dataexchange_rpc_fetch_config');
    $rpcclient->add_param($user, 'struct');
    $rpcclient->add_param($configkey, 'string');
    $rpcclient->add_param($module, 'string');
    $mnet_host = new mnet_peer();
    if (empty($mnet_host)) {
        return;
    }
    $mnet_host->set_wwwroot($mnethost->wwwroot);
    if ($rpcclient->send($mnet_host)) {
        $response = json_decode($rpcclient->response);
        if ($response->status == 200) {
            return $response->value;
        } else {
            if (debugging()) {
                echo $OUTPUT->notification('Remote RPC error ' . implode('<br/>', $response->errors));
            }
        }
    } else {
        if (debugging()) {
            echo $OUTPUT->notification('Remote RPC failure ' . implode('<br/', $rpcclient->error));
        }
    }
}
开发者ID:gabrielrosset,项目名称:moodle-local_vmoodle,代码行数:52,代码来源:lib.php


示例7: call

 function call($paramArray = null)
 {
     global $CFG;
     // For the demo, our 'remote' host is actually our local host.
     $wwwroot = $CFG->wwwroot;
     // mnet_peer pulls information about a remote host from the database.
     $mnet_peer = new mnet_peer();
     $mnet_peer->set_wwwroot($wwwroot);
     //$mnethostid = 1010000003;
     //$mnethostid = 1010000001;
     //$mnet_peer->set_id($mnethostid);
     $method = 'synch/mnet/synch.php/testResponse';
     //$paramArray = array();
     // Create a new request object
     $mnet_request = new mnet_xmlrpc_client();
     // Tell it the path to the method that we want to execute
     $mnet_request->set_method($method);
     global $Out;
     //$Out->print_r($paramArray, '$paramArray = ');
     if (!empty($paramArray)) {
         // Add parameters for your function. The mnet_concatenate_strings takes three
         // parameters, like mnet_concatenate_strings($string1, $string2, $string3)
         // PHP is weakly typed, so you can get away with calling most things strings,
         // unless it's non-scalar (i.e. an array or object or something).
         foreach ($paramArray as $param) {
             $mnet_request->add_param($param[0], $param[1]);
         }
     }
     //$Out->print_r($mnet_request->params, '$mnet_request->params = ');
     if (false && count($mnet_request->params)) {
         $Out->append('Your parameters are:<br />');
         while (list($key, $val) = each($mnet_request->params)) {
             $Out->append('&nbsp;&nbsp; <strong>' . $key . ':</strong> ' . $val . "<br/>\n");
         }
     }
     // We send the request:
     $mnet_request->send($mnet_peer);
     //$Out->append('$mnet_request->response = '.$mnet_request->response);
     //$Out->flush();
     return $mnet_request->response;
 }
开发者ID:r007,项目名称:PMoodle,代码行数:41,代码来源:test_localWebService.php


示例8: refresh_key

 function refresh_key()
 {
     // set up an RPC request
     $mnetrequest = new mnet_xmlrpc_client();
     // Use any method - listServices is pretty lightweight.
     $mnetrequest->set_method('system/listServices');
     // Do RPC call and store response
     if ($mnetrequest->send($this) === true) {
         // Ok - we actually don't care about the result
         $temp = new mnet_peer();
         $temp->set_id($this->id);
         if ($this->public_key != $temp->public_key) {
             $newkey = param_clean($temp->public_key, PARAM_PEM);
             if (!empty($newkey)) {
                 $this->public_key = $newkey;
                 return true;
             }
         }
     }
     return false;
 }
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:21,代码来源:remote_client.php


示例9: admin_externalpage_setup

}
$PAGE->set_url('/admin/mnet/peers.php');
admin_externalpage_setup($adminsection);
if (!extension_loaded('openssl')) {
    print_error('requiresopenssl', 'mnet');
}
if (!function_exists('curl_init')) {
    print_error('nocurl', 'mnet');
}
if (!function_exists('xmlrpc_encode_request')) {
    print_error('xmlrpc-missing', 'mnet');
}
if (!isset($CFG->mnet_dispatcher_mode)) {
    set_config('mnet_dispatcher_mode', 'off');
}
$mnet_peer = new mnet_peer();
$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));
开发者ID:saurabh947,项目名称:MoodleLearning,代码行数:31,代码来源:peers.php


示例10: taoview_call_mnet

function taoview_call_mnet($viewtype)
{
    /// Setup MNET environment
    global $MNET, $CFG;
    if (empty($MNET)) {
        $MNET = new mnet_environment();
        $MNET->init();
    }
    /// Setup the server
    $host = get_record('mnet_host', 'name', 'localmahara');
    //we retrieve the server(host) from the 'mnet_host' table
    if (empty($host)) {
        error('Mahara not configured');
    }
    $a = new stdclass();
    $a->link = $CFG->wwwroot . '/auth/mnet/jump.php?hostid=' . $host->id . '&wantsurl=local/taoview.php?view=' . $viewtype;
    echo '<div class="taoviwdesc">';
    print_string('toaddartefacts', 'local', $a);
    echo '</div>';
    $mnet_peer = new mnet_peer();
    //we create a new mnet_peer (server/host)
    $mnet_peer->set_wwwroot($host->wwwroot);
    //we set this mnet_peer with the host http address
    $client = new mnet_xmlrpc_client();
    //create a new client
    $client->set_method('local/mahara/rpclib.php/get_artefacts_by_viewtype');
    //tell it which method we're going to call
    $client->add_param($viewtype);
    $client->send($mnet_peer);
    //Call the server
    if (!empty($client->response['faultString'])) {
        error("Mahara error:" . $artefacts['faultString']);
    }
    return $client->response;
}
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:35,代码来源:taoviewlib.php


示例11: resolve_theme

    /**
     * Work out the theme this page should use.
     *
     * This depends on numerous $CFG settings, and the properties of this page.
     *
     * @return string the name of the theme that should be used on this page.
     */
    protected function resolve_theme() {
        global $CFG, $USER, $SESSION;

        if (empty($CFG->themeorder)) {
            $themeorder = array('course', 'category', 'session', 'user', 'site');
        } else {
            $themeorder = $CFG->themeorder;
            // Just in case, make sure we always use the site theme if nothing else matched.
            $themeorder[] = 'site';
        }

        $mnetpeertheme = '';
        if (isloggedin() and isset($CFG->mnet_localhost_id) and $USER->mnethostid != $CFG->mnet_localhost_id) {
            require_once($CFG->dirroot.'/mnet/peer.php');
            $mnetpeer = new mnet_peer();
            $mnetpeer->set_id($USER->mnethostid);
            if ($mnetpeer->force_theme == 1 && $mnetpeer->theme != '') {
                $mnetpeertheme = $mnetpeer->theme;
            }
        }

        foreach ($themeorder as $themetype) {
            switch ($themetype) {
                case 'course':
                    if (!empty($CFG->allowcoursethemes) && !empty($this->_course->theme) && $this->devicetypeinuse == 'default') {
                        return $this->_course->theme;
                    }

                case 'category':
                    if (!empty($CFG->allowcategorythemes) && $this->devicetypeinuse == 'default') {
                        $categories = $this->categories;
                        foreach ($categories as $category) {
                            if (!empty($category->theme)) {
                                return $category->theme;
                            }
                        }
                    }

                case 'session':
                    if (!empty($SESSION->theme)) {
                        return $SESSION->theme;
                    }

                case 'user':
                    if (!empty($CFG->allowuserthemes) && !empty($USER->theme) && $this->devicetypeinuse == 'default') {
                        if ($mnetpeertheme) {
                            return $mnetpeertheme;
                        } else {
                            return $USER->theme;
                        }
                    }

                case 'site':
                    if ($mnetpeertheme) {
                        return $mnetpeertheme;
                    }
                    // First try for the device the user is using.
                    $devicetheme = get_selected_theme_for_device_type($this->devicetypeinuse);
                    if (!empty($devicetheme)) {
                        return $devicetheme;
                    }
                    // Next try for the default device (as a fallback)
                    $devicetheme = get_selected_theme_for_device_type('default');
                    if (!empty($devicetheme)) {
                        return $devicetheme;
                    }
                    // The default device theme isn't set up - use the overall default theme.
                    return theme_config::DEFAULT_THEME;
            }
        }
    }
开发者ID:nottmoo,项目名称:moodle,代码行数:78,代码来源:pagelib.php


示例12: mnet_peer

        continue;
    }
    // Skip localhost
    if ($host->wwwroot == $CFG->wwwroot) {
        continue;
    }
    // Skip non-moodle hosts
    if ($host->applicationid != 1 && $host->applicationid != 2) {
        continue;
    }
    //TODO: get rid of magic numbers.
    echo '<p><a href="testclient.php?hostid=' . $host->id . '">' . $host->wwwroot . "</a></p>\n";
}
if (!empty($_GET['hostid']) && array_key_exists($_GET['hostid'], $hosts)) {
    $host = $hosts[$_GET['hostid']];
    $mnet_peer = new mnet_peer();
    $mnet_peer->set_wwwroot($host->wwwroot);
    $mnet_request = new mnet_xmlrpc_client();
    // Tell it the path to the method that we want to execute
    $mnet_request->set_method('system/listServices');
    $mnet_request->send($mnet_peer);
    $services = $mnet_request->response;
    $yesno = array('No', 'Yes');
    $servicenames = array();
    echo '<hr /><br /><h3>Services available on host: ' . $host->wwwroot . '</h3><table><tr valign="top"><th>&nbsp;&nbsp;Service ID&nbsp;&nbsp;</th><th>&nbsp;&nbsp;Service&nbsp;&nbsp;</th><th>&nbsp;&nbsp;Version&nbsp;&nbsp;</th><th>&nbsp;&nbsp;They Publish&nbsp;&nbsp;</th><th>&nbsp;&nbsp;They Subscribe&nbsp;&nbsp;</th><th></th></tr>';
    foreach ($services as $id => $service) {
        $sql = 'select c.id, c.parent_type, c.parent from ' . $CFG->prefix . 'mnet_service2rpc a,' . $CFG->prefix . 'mnet_service b, ' . $CFG->prefix . 'mnet_rpc c where a.serviceid = b.id and b.name=\'' . addslashes($service['name']) . '\' and c.id = a.rpcid ';
        echo '<tr valign="top">
                <td>' . $service['name'] . '</td>';
        if ($detail = get_record_sql($sql)) {
            $service['humanname'] = get_string($service['name'] . '_name', $detail->parent_type . '_' . $detail->parent);
开发者ID:nadavkav,项目名称:MoodleTAO,代码行数:31,代码来源:testclient.php


示例13: print_error

                print_error("hostexists", 'mnet', 'peers.php?step=update&amp;hostid=' . $mnet_peer->id, $mnet_peer->id);
            }
        }
        if ('input' == $form->step) {
            include './mnet_review.html';
        } elseif ('commit' == $form->step) {
            $bool = $mnet_peer->commit();
            if ($bool) {
                redirect('peers.php?step=update&amp;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, 
开发者ID:ajv,项目名称:Offline-Caching,代码行数:31,代码来源:peers.php


示例14: req_unenrol_user

 /**
  * Does Foo
  *
  * @param int    $mnethostid The id of the remote mnethost
  * @return array              Whether the user can login from the remote host
  */
 function req_unenrol_user($userid, $courseid)
 {
     global $CFG;
     global $USER;
     global $MNET;
     require_once $CFG->dirroot . '/mnet/xmlrpc/client.php';
     // in case the remote host doesn't have it
     $username = get_field('user', 'username', 'id', $userid);
     $course = get_record('mnet_enrol_course', 'id', $courseid);
     // get the Service Provider info
     $mnet_sp = new mnet_peer();
     $mnet_sp->set_id($course->hostid);
     // set up the RPC request
     $mnetrequest = new mnet_xmlrpc_client();
     $mnetrequest->set_method('enrol/mnet/enrol.php/unenrol_user');
     $mnetrequest->add_param($username);
     $mnetrequest->add_param($course->remoteid);
     // TODO - prevent removal of enrolments that are not of
     // type mnet...
     // Thunderbirds are go! Do RPC call and store response
     if ($mnetrequest->send($mnet_sp) === true) {
         if ($mnetrequest->response == true) {
             // remove enrolment cached in mnet_enrol_assignments
             delete_records_select('mnet_enrol_assignments', "userid={$userid} AND courseid={$course->id}");
             return true;
         }
     }
     return false;
 }
开发者ID:r007,项目名称:PMoodle,代码行数:35,代码来源:enrol.php


示例15: dirname

 * @copyright  2007 Martin Langhoff
 * @copyright  2010 Penny Leach
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
 */
require_once dirname(dirname(dirname(__FILE__))) . '/config.php';
require_once $CFG->libdir . '/adminlib.php';
$step = optional_param('step', 'verify', PARAM_ALPHA);
$hostid = required_param('hostid', PARAM_INT);
require_login();
$context = get_context_instance(CONTEXT_SYSTEM);
require_capability('moodle/site:config', $context, $USER->id, true, "nopermissions");
$mnet = get_mnet_environment();
$PAGE->set_url('/admin/mnet/delete.php');
admin_externalpage_setup('mnetpeer' . $hostid);
require_sesskey();
$mnet_peer = new mnet_peer();
$mnet_peer->set_id($hostid);
if ('verify' == $step) {
    echo $OUTPUT->header();
    echo $OUTPUT->heading(get_string('deleteaserver', 'mnet'));
    if ($live_users = $mnet_peer->count_live_sessions() > 0) {
        echo $OUTPUT->notification(get_string('usersareonline', 'mnet', $live_users));
    }
    $yesurl = new moodle_url('/admin/mnet/delete.php', array('hostid' => $mnet_peer->id, 'step' => 'delete'));
    $nourl = new moodle_url('/admin/mnet/peers.php');
    echo $OUTPUT->confirm(get_string('reallydeleteserver', 'mnet') . ': ' . $mnet_peer->name, $yesurl, $nourl);
    echo $OUTPUT->footer();
} elseif ('delete' == $step) {
    $mnet_peer->delete();
    redirect(new moodle_url('/admin/mnet/peers.php'), get_string('hostdeleted', 'mnet'), 5);
}
开发者ID:vuchannguyen,项目名称:web,代码行数:31,代码来源:delete.php


示例16: kill_children

 /**
  * The IdP uses this function to kill child sessions on other hosts
  *
  * @param   string  $username       Username for session to kill
  * @param   string  $useragent      SHA1 hash of user agent to look for
  * @return  string                  A plaintext report of what has happened
  */
 function kill_children($username, $useragent)
 {
     global $CFG, $USER, $DB;
     $remoteclient = null;
     if (defined('MNET_SERVER')) {
         $remoteclient = get_mnet_remote_client();
     }
     require_once $CFG->dirroot . '/mnet/xmlrpc/client.php';
     $userid = $DB->get_field('user', 'id', array('mnethostid' => $CFG->mnet_localhost_id, 'username' => $username));
     $returnstring = '';
     $mnetsessions = $DB->get_records('mnet_session', array('userid' => $userid, 'useragent' => $useragent));
     if (false == $mnetsessions) {
         $returnstring .= "Could find no remote sessions\n";
         $mnetsessions = array();
     }
     foreach ($mnetsessions as $mnetsession) {
         // If this script is being executed by a remote peer, that means the user has clicked
         // logout on that peer, and the session on that peer can be deleted natively.
         // Skip over it.
         if (isset($remoteclient->id) && $mnetsession->mnethostid == $remoteclient->id) {
             continue;
         }
         $returnstring .= "Deleting session\n";
         $mnet_peer = new mnet_peer();
         $mnet_peer->set_id($mnetsession->mnethostid);
         $mnet_request = new mnet_xmlrpc_client();
         $mnet_request->set_method('auth/mnet/auth.php/kill_child');
         // set $token and $useragent parameters
         $mnet_request->add_param($username);
         $mnet_request->add_param($useragent);
         if ($mnet_request->send($mnet_peer) === false) {
             debugging("Server side error has occured on host {$mnetsession->mnethostid}: " . join("\n", $mnet_request->error));
         }
     }
     $ignore = $DB->delete_records('mnet_session', array('useragent' => $useragent, 'userid' => $userid));
     if (isset($remoteclient) && isset($remoteclient->id)) {
         session_kill_user($userid);
     }
     return $returnstring;
 }
开发者ID:sebastiansanio,项目名称:tallerdeprogramacion2fiuba,代码行数:47,代码来源:auth.php


示例17: mtrace

     mtrace("forced mode");
 }
 if ($havetorenew || $force) {
     mtrace("Local key will expire very soon. Renew MNET keys now !!...\n");
     // renew local key
     $mnet->replace_keys();
     // send new key using key exchange transportation
     // make a key and exchange it with all known and active peers
     $mnet_peers = $DB->get_records('mnet_host', array('deleted' => 0));
     if ($mnet_peers) {
         foreach ($mnet_peers as $peer) {
             if ($peer->id == $CFG->mnet_all_hosts_id || $peer->id == $CFG->mnet_localhost_id) {
                 continue;
             }
             $application = $DB->get_record('mnet_application', array('id' => $peer->applicationid));
             $mnet_peer = new mnet_peer();
             $mnet_peer->set_wwwroot($peer->wwwroot);
             // get the sessions for each vmoodle that have same ID Number
             // we use a force parameter to force fetching the key remotely anyway
             $currentkey = mnet_get_public_key($mnet_peer->wwwroot, $application, 1);
             if ($currentkey) {
                 $mnet_peer->public_key = clean_param($currentkey, PARAM_PEM);
                 $mnet_peer->updateparams = new StdClass();
                 $mnet_peer->updateparams->public_key = clean_param($currentkey, PARAM_PEM);
                 $mnet_peer->public_key_expires = $mnet_peer->check_common_name($currentkey);
                 $mnet_peer->updateparams->public_key_expires = $mnet_peer->check_common_name($currentkey);
                 $mnet_peer->commit();
                 mtrace('My key renewed at ' . $peer->wwwroot . ' till ' . userdate($mnet_peer->public_key_expires));
                 $trace .= userdate(time()) . ' KEY RENEW from ' . $CFG->wwwroot . ' to ' . $peer->wwwroot . " suceeded\n";
             } else {
                 mtrace('Failed renewing key with ' . $peer->wwwroot . "\n");
开发者ID:gabrielrosset,项目名称:moodle-local_vmoodle,代码行数:31,代码来源:mnetcron.php


示例18: admin_externalpage_setup

admin_externalpage_setup('mnetpeers');
$context = get_context_instance(CONTEXT_SYSTEM);
require_capability('moodle/site:config', $context, $USER->id, true, "nopermissions");
if (!($site = get_site())) {
    print_error('nosite', '', '', NULL, true);
}
/// Initialize variables.
$hostid = required_param('hostid', PARAM_INT);
$stradministration = get_string('administration');
$strconfiguration = get_string('configuration');
$strmnetedithost = get_string('reviewhostdetails', 'mnet');
$strmnetsettings = get_string('mnetsettings', 'mnet');
$strmnetservices = get_string('mnetservices', 'mnet');
$strmnetthemes = get_string('mnetthemes', 'mnet');
$strmnetlog = get_string('mnetlog', 'mnet');
$mnet_peer = new mnet_peer();
if (is_int($hostid)) {
    $mnet_peer->set_id($hostid);
}
$choose = optional_param("choose", '', PARAM_FILE);
// set this theme as default
$stradministration = get_string("administration");
$strconfiguration = get_string("configuration");
$strthemes = get_string("themes");
$strpreview = get_string("preview");
$strchoose = get_string("choose");
$strinfo = get_string("info");
$strtheme = get_string("theme");
$strthemesaved = get_string("themesaved");
$strscreenshot = get_string("screenshot");
$stroldtheme = get_string("oldtheme");
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:31,代码来源:mnet_themes.php


示例19: send

 /**
  * Send the request to the server - decode and return the response
  *
  * @param  object   $mnet_peer      A mnet_peer object with details of the
  *                                  remote host we're connecting to
  * @return mixed                    A PHP variable, as returned by the
  *                                  remote function
  */
 function send($mnet_peer)
 {
     global $CFG, $MNET;
     $this->uri = $mnet_peer->wwwroot . $mnet_peer->application->xmlrpc_server_url;
     // Initialize with the target URL
     $ch = curl_init($this->uri);
     $system_methods = array('system/listMethods', 'system/methodSignature', 'system/methodHelp', 'system/listServices');
     if (in_array($this->method, $system_methods)) {
         // Executing any system method is permitted.
     } else {
         $id_list = $mnet_peer->id;
         if (!empty($CFG->mnet_all_hosts_id)) {
             $id_list .= ', ' . $CFG->mnet_all_hosts_id;
         }
         // At this point, we don't care if the remote host implements the
         // method we're trying to call. We just want to know that:
         // 1. The method belongs to some service, as far as OUR host knows
         // 2. We are allowed to subscribe to that service on this mnet_peer
         // Find methods that we subscribe to on this host
         $sql = "\n                SELECT\n                    r.id\n                FROM\n                    {$CFG->prefix}mnet_rpc r,\n                    {$CFG->prefix}mnet_service2rpc s2r,\n                    {$CFG->prefix}mnet_host2service h2s\n                WHERE\n                    r.xmlrpc_path = '{$this->method}' AND\n                    s2r.rpcid = r.id AND\n                    s2r.serviceid = h2s.serviceid AND\n                    h2s.subscribe = '1' AND\n                    h2s.hostid in ({$id_list})";
         if (!record_exists_sql($sql)) {
             global $USER;
             $this->error[] = '7:User with ID ' . $USER->id . ' attempted to call unauthorised method ' . $this->method . ' on host ' . $mnet_peer->wwwroot;
             return false;
         }
     }
     $this->requesttext = xmlrpc_encode_request($this->method, $this->params, array("encoding" => "utf-8", "escaping" => "markup"));
     $rq = $this->requesttext;
     $rq = mnet_sign_message($this->requesttext);
     $this->signedrequest = $rq;
     $rq = mnet_encrypt_message($rq, $mnet_peer->public_key);
     $this->encryptedrequest = $rq;
     curl_setopt($ch, CURLOPT_TIMEOUT, $this->timeout);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_POST, true);
     curl_setopt($ch, CURLOPT_USERAGENT, 'Moodle');
     curl_setopt($ch, CURLOPT_POSTFIELDS, $rq);
     curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: text/xml charset=UTF-8"));
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
     curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
     $timestamp_send = time();
     $this->rawresponse = curl_exec($ch);
     $timestamp_receive = time();
     if ($this->rawresponse === false) {
         $this->error[] = curl_errno($ch) . ':' . curl_error($ch);
         return false;
     }
     $this->rawresponse = trim($this->rawresponse);
     $mnet_peer->touch();
     $crypt_parser = new mnet_encxml_parser();
     $crypt_parser->parse($this->rawresponse);
     if ($crypt_parser->payload_encrypted) {
         $key = array_pop($crypt_parser->cipher);
         $data = array_pop($crypt_parser->cipher);
         $crypt_parser->free_resource();
         // Initialize payload var
         $payload = '';
         //                                          &$payload
         $isOpen = openssl_open(base64_decode($data), $payload, base64_decode($key), $MNET->get_private_key());
         if (!$isOpen) {
             // Decryption failed... let's try our archived keys
             $openssl_history = get_config('mnet', 'openssl_history');
             if (empty($openssl_history)) {
                 $openssl_history = array();
                 set_config('openssl_history', serialize($openssl_history), 'mnet');
             } else {
                 $openssl_history = unserialize($openssl_history);
             }
             foreach ($openssl_history as $keyset) {
                 $keyresource = openssl_pkey_get_private($keyset['keypair_PEM']);
                 $isOpen = openssl_open(base64_decode($data), $payload, base64_decode($key), $keyresource);
                 if ($isOpen) {
                     // It's an older code, sir, but it checks out
                     break;
                 }
             }
         }
         if (!$isOpen) {
             trigger_error("None of our keys could open the payload from host {$mnet_peer->wwwroot} with id {$mnet_peer->id}.");
             $this->error[] = '3:No key match';
             return false;
         }
         if (strpos(substr($payload, 0, 100), '<signedMessage>')) {
             $sig_parser = new mnet_encxml_parser();
             $sig_parser->parse($payload);
         } else {
             $this->error[] = '2:Payload not signed: ' . $payload;
             return false;
         }
     } else {
         if (!empty($crypt_parser->remoteerror)) {
             $this->error[] = '4: remote server error: ' . $crypt_parser->remoteerror;
//.........这里部分代码省略.........
开发者ID:edwinphillips,项目名称:moodle-485cb39,代码行数:101,代码来源:client.php


示例20: report_log_print_mnet_selector_form

该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP mnet_xmlrpc_client类代码示例发布时间:2022-05-23
下一篇:
PHP mnet_environment类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap