*/ class auth_plugin_authsmf extends DokuWiki_Auth_Plugin { /** * Constructor * * checks if the smf forum path is set correct, otherwise * set the variable $success of the basis class to false * * @author Matthias Grimm */ public function __construct() { parent::__construct(); $this->cando['external'] = true; $this->cando['logout'] = true; $this->success = is_file($_SERVER['DOCUMENT_ROOT'].$GLOBALS['conf']['plugin']['authsmf']['smfPath'].'/SSI.php'); } /** * Do all authentication * * @param string $user Username * @param string $pass Cleartext Password * @param bool $sticky Cookie should not expire * @return bool true on successful auth */ function trustExternal($user, $pass, $sticky = false) { global $context; global $sc; global $conf; global $USERINFO; if(!empty($user)){ $hash_passwrd = sha1(sha1(strtolower($user) . $pass) . $sc); header('Location: '.$conf['plugin']['authsmf']['smfPath'].'?action=login2&user='.$user.'&hash_passwrd='.$hash_passwrd.($sticky ? '&cookieneverexp=1' : '')); exit; } if (isset($context['user']) && !$context['user']['is_guest']) { $USERINFO['name'] = $context['user']['name']; $USERINFO['mail'] = $context['user']['email']; $USERINFO['grps'] = array(); $USERINFO['grps'][] = 'user'; if ($context['user']['can_mod']) $USERINFO['grps'][] = 'moderator'; if ($context['user']['is_admin']) $USERINFO['grps'][] = 'admin'; $_SERVER['REMOTE_USER'] = utf8_decode($context['user']['username']); $_SESSION[DOKU_COOKIE]['auth']['user'] = $context['user']['username']; $_SESSION[DOKU_COOKIE]['auth']['info'] = $USERINFO; return true; } // to be sure auth_logoff(); $USERINFO['grps'] = array(); return false; } /** * Log off the current user */ public function logOff() { global $context; global $conf; if (isset($context['user']) && !$context['user']['is_guest']) { header('Location: '.$conf['plugin']['authsmf']['smfPath'].'?action=logout;'.$context['session_var'].'='.$context['session_id']); exit; } } }