Differences Between: [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403]
1 <?php 2 // Allows the admin to configure services for remote hosts 3 4 require(__DIR__.'/../../config.php'); 5 require_once($CFG->libdir.'/adminlib.php'); 6 include_once($CFG->dirroot.'/mnet/lib.php'); 7 8 admin_externalpage_setup('trustedhosts'); 9 10 11 if (!extension_loaded('openssl')) { 12 echo $OUTPUT->header(); 13 print_error('requiresopenssl', 'mnet', '', NULL, true); 14 } 15 16 $site = get_site(); 17 18 $trusted_hosts = '';//array(); 19 $old_trusted_hosts = get_config('mnet', 'mnet_trusted_hosts'); 20 if (!empty($old_trusted_hosts)) { 21 $old_trusted_hosts = explode(',', $old_trusted_hosts); 22 } else { 23 $old_trusted_hosts = array(); 24 } 25 26 $test_ip_address = optional_param('testipaddress', NULL, PARAM_HOST); 27 $in_range = false; 28 if (!empty($test_ip_address)) { 29 foreach($old_trusted_hosts as $host) { 30 if (address_in_subnet($test_ip_address, $host)) { 31 $in_range = true; 32 $validated_by = $host; 33 break; 34 } 35 } 36 } 37 38 /// If data submitted, process and store 39 if (($form = data_submitted()) && confirm_sesskey()) { 40 $hostlist = preg_split("/[\s,]+/", $form->hostlist); 41 foreach($hostlist as $host) { 42 list($address, $mask) = explode('/', $host.'/'); 43 if (empty($address)) continue; 44 if (strlen($mask) == 0) $mask = 32; 45 $trusted_hosts .= trim($address).'/'.trim($mask)."\n"; 46 unset($address, $mask); 47 } 48 set_config('mnet_trusted_hosts', str_replace("\n", ',', $trusted_hosts), 'mnet'); 49 } elseif (!empty($old_trusted_hosts)) { 50 foreach($old_trusted_hosts as $host) { 51 list($address, $mask) = explode('/', $host.'/'); 52 if (empty($address)) continue; 53 if (strlen($mask) == 0) $mask = 32; 54 $trusted_hosts .= trim($address).'/'.trim($mask)."\n"; 55 unset($address, $mask); 56 } 57 } 58 59 include('./trustedhosts.html');
title
Description
Body
title
Description
Body
title
Description
Body
title
Body