function AuthCallback($type) { TypeCheck($type); $func = 'AuthCallback_' . $type; if (function_exists($func)) { return $func(); } else { die('FATAL ERROR:AuthCallback'); } }
function authlogin($type) { $zhtype = TypeCheck($type); $document = JFactory::getDocument(); $viewType = $document->getType(); $viewLayout = JRequest::getCmd('layout', 'default'); if (version_compare(JVERSION, '1.6.0', 'ge')) { // Joomla! 1.7 $viewName = $this->default_view; $view = $this->getView($viewName, $viewType, '', array('base_path' => $this->basePath)); } else { // Joomla! 1.5 $viewName = JRequest::getCmd('view'); $view = $this->getView($viewName, $viewType); } $view->return = JRequest::getCmd('rid'); // 这里准备一套假的用户名与密码,以备后面的认证插件认证不通过 $view->showusername = '******'; $view->showpassword = '******'; $_SESSION['weibouserlogin'] = 0; $last_key = AuthCallback($type); if ($last_key) { // 如果认证通过,以"用户ID@xxxxxweibo" 为joomla中的用户名 if ($type == 'qq') { $view->showusername = $last_key['user_id'] . '@' . $type; } else { $view->showusername = $last_key['user_id'] . '@' . $type . 'weibo'; } $view->showpassword = base64_encode($view->showusername); // 以“用户昵称(来自某某微博)”用户昵称 $_SESSION['weibousername'] = $last_key['user_name'] . '(来自' . $zhtype . ')'; if (array_key_exists('user_email', $last_key)) { $_SESSION['weibouseremail'] = $last_key['user_email']; } else { unset($_SESSION['weibouseremail']); } $_SESSION['weibouserlogin'] = 1; $view->weibologin(); } else { $view->weibologinerror($type, $zhtype); } return $this; }