[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
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 require_login(); 9 admin_externalpage_setup('trustedhosts'); 10 11 $context = context_system::instance(); 12 13 require_capability('moodle/site:config', $context, $USER->id, true, "nopermissions"); 14 15 if (!extension_loaded('openssl')) { 16 echo $OUTPUT->header(); 17 print_error('requiresopenssl', 'mnet', '', NULL, true); 18 } 19 20 $site = get_site(); 21 22 $trusted_hosts = '';//array(); 23 $old_trusted_hosts = get_config('mnet', 'mnet_trusted_hosts'); 24 if (!empty($old_trusted_hosts)) { 25 $old_trusted_hosts = explode(',', $old_trusted_hosts); 26 } else { 27 $old_trusted_hosts = array(); 28 } 29 30 $test_ip_address = optional_param('testipaddress', NULL, PARAM_HOST); 31 $in_range = false; 32 if (!empty($test_ip_address)) { 33 foreach($old_trusted_hosts as $host) { 34 if (address_in_subnet($test_ip_address, $host)) { 35 $in_range = true; 36 $validated_by = $host; 37 break; 38 } 39 } 40 } 41 42 /// If data submitted, process and store 43 if (($form = data_submitted()) && confirm_sesskey()) { 44 $hostlist = preg_split("/[\s,]+/", $form->hostlist); 45 foreach($hostlist as $host) { 46 list($address, $mask) = explode('/', $host.'/'); 47 if (empty($address)) continue; 48 if (strlen($mask) == 0) $mask = 32; 49 $trusted_hosts .= trim($address).'/'.trim($mask)."\n"; 50 unset($address, $mask); 51 } 52 set_config('mnet_trusted_hosts', str_replace("\n", ',', $trusted_hosts), 'mnet'); 53 } elseif (!empty($old_trusted_hosts)) { 54 foreach($old_trusted_hosts as $host) { 55 list($address, $mask) = explode('/', $host.'/'); 56 if (empty($address)) continue; 57 if (strlen($mask) == 0) $mask = 32; 58 $trusted_hosts .= trim($address).'/'.trim($mask)."\n"; 59 unset($address, $mask); 60 } 61 } 62 63 include ('./trustedhosts.html');
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |