|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00015 if (!defined('MOODLE_INTERNAL')) { 00016 die('Direct access to this script is forbidden.'); 00017 } 00018 00019 require_once($CFG->libdir.'/authlib.php'); 00020 00024 class auth_plugin_nntp extends auth_plugin_base { 00025 00029 function auth_plugin_nntp() { 00030 $this->authtype = 'nntp'; 00031 $this->config = get_config('auth/nntp'); 00032 } 00033 00042 function user_login ($username, $password) { 00043 if (! function_exists('imap_open')) { 00044 print_error('auth_nntpnotinstalled','auth_nntp'); 00045 exit; 00046 } 00047 00048 global $CFG; 00049 00050 // try each multiple host 00051 $hosts = explode(';', $this->config->host); 00052 foreach ($hosts as $host) { 00053 $host = '{' . trim($host) . ':' . $this->config->port . '/nntp}'; 00054 00055 error_reporting(0); 00056 $connection = imap_open($host, $username, $password, OP_HALFOPEN); 00057 error_reporting($CFG->debug); 00058 00059 if ($connection) { 00060 imap_close($connection); 00061 return true; 00062 } 00063 } 00064 return false; 00065 } 00066 00067 function prevent_local_passwords() { 00068 return true; 00069 } 00070 00076 function is_internal() { 00077 return false; 00078 } 00079 00086 function can_change_password() { 00087 return false; 00088 } 00089 00098 function config_form($config, $err, $user_fields) { 00099 include "config.html"; 00100 } 00101 00105 function process_config($config) { 00106 // set to defaults if undefined 00107 if (!isset ($config->host)) { 00108 $config->host = '127.0.0.1'; 00109 } 00110 if (!isset ($config->port)) { 00111 $config->port = '119'; 00112 } 00113 if (!isset($config->changepasswordurl)) { 00114 $config->changepasswordurl = ''; 00115 } 00116 00117 // save settings 00118 set_config('host', $config->host, 'auth/nntp'); 00119 set_config('port', $config->port, 'auth/nntp'); 00120 set_config('changepasswordurl', $config->changepasswordurl, 'auth/nntp'); 00121 00122 return true; 00123 } 00124 00125 } 00126 00127