| [ Index ] |
PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008] |
[Summary view] [Print] [Text view]
1 <?php // $Id: remote_client.php,v 1.3.2.2 2008/09/25 09:57:33 peterbulmer Exp $ 2 /** 3 * An object to represent lots of information about an RPC-peer machine 4 * 5 * @author Donal McMullan donal@catalyst.net.nz 6 * @version 0.0.1 7 * @license http://www.gnu.org/copyleft/gpl.html GNU Public License 8 * @package mnet 9 */ 10 11 class mnet_remote_client extends mnet_peer { 12 13 // If the remote client is trying to execute a method on an object instead 14 // of just a function, we'll instantiate the proper class and store it in 15 // this 'object_to_call' property. 16 var $object_to_call = false; 17 var $request_was_encrypted = false; 18 var $request_was_signed = false; 19 20 function was_encrypted() { 21 $this->request_was_encrypted = true; 22 } 23 24 function was_signed() { 25 $this->request_was_signed = true; 26 } 27 28 function object_to_call($object) { 29 $this->object_to_call = $object; 30 } 31 32 function plaintext_is_ok() { 33 global $CFG; 34 35 $trusted_hosts = explode(',', get_config('mnet', 'mnet_trusted_hosts')); 36 37 foreach($trusted_hosts as $host) { 38 list($network, $mask) = explode('/', $host.'/'); 39 if (empty($network)) continue; 40 if (strlen($mask) == 0) $mask = 32; 41 42 if (ip_in_range($_SERVER['REMOTE_ADDR'], $network, $mask)) { 43 return true; 44 } 45 } 46 47 return false; 48 } 49 50 function refresh_key() { 51 global $CFG; 52 // set up an RPC request 53 require_once $CFG->dirroot.'/mnet/xmlrpc/client.php'; 54 $mnetrequest = new mnet_xmlrpc_client(); 55 // Use any method - listServices is pretty lightweight. 56 $mnetrequest->set_method('system/listServices'); 57 58 // Do RPC call and store response 59 if ($mnetrequest->send($this) === true) { 60 // Ok - we actually don't care about the result 61 $temp = new mnet_peer(); 62 $temp->set_id($this->id); 63 if($this->public_key != $temp->public_key) { 64 $newkey = clean_param($temp->public_key, PARAM_PEM); 65 if(!empty($newkey)) { 66 $this->public_key = $newkey; 67 return true; 68 } 69 } 70 } 71 return false; 72 } 73 } 74 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Wed Jan 14 11:33:29 2009 | Cross-referenced by PHPXref 0.7 |