예제 #1
0
 /**
  * @brief openid로그인
  **/
 function procMemberOpenIDLogin($validator = "procMemberOpenIDValidate")
 {
     $oModuleModel =& getModel('module');
     $config = $oModuleModel->getModuleConfig('member');
     if ($config->enable_openid != 'Y') {
         $this->stop('msg_invalid_request');
     }
     ob_start();
     require './modules/member/openid_lib/class.openid.php';
     require_once './modules/member/openid_lib/libcurlemu.inc.php';
     $user_id = Context::get('user_id');
     if (!$user_id) {
         $user_id = Context::get('openid');
     }
     $referer_url = Context::get('referer_url');
     if (!$referer_url) {
         $referer_url = $_SERVER['HTTP_REFERER'];
     }
     if (!$referer_url) {
         $referer_url = htmlspecialchars_decode(getRequestUri(RELEASE_SSL));
     }
     $openid = new SimpleOpenID();
     $openid->SetIdentity($user_id);
     $openid->SetTrustRoot('http://' . $_SERVER["HTTP_HOST"]);
     $openid->SetRequiredFields(array('email'));
     $openid->SetOptionalFields(array('dob'));
     if (!$openid->GetOpenIDServer()) {
         $error = $openid->GetError();
         $this->setError(-1);
         $this->setMessage($error['description']);
         if (Context::getRequestMethod() == 'POST') {
             header("location:" . $referer_url);
         }
     } else {
         $goto = urlencode($referer_url);
         $ApprovedURL = Context::getRequestUri(RELEASE_SSL) . "?module=member&act=" . $validator . "&goto=" . $goto;
         $openid->SetApprovedURL($ApprovedURL);
         $url = $openid->GetRedirectURL();
         $this->add('redirect_url', $url);
         if (Context::getRequestMethod() == 'POST') {
             header("location:" . $url);
         }
     }
     ob_clean();
 }
예제 #2
0
function start_simple_openid()
{
    global $request;
    include_once $GLOBALS['PATH']['library'] . 'openid.php';
    $openid = new SimpleOpenID();
    $openid->SetIdentity($request->openid_url);
    $openid->SetApprovedURL($request->url_for('openid_continue') . '/');
    // y'all come back now
    $openid->SetTrustRoot($request->protected_url);
    // protected site
    $openid->SetOptionalFields(array('nickname', 'email', 'fullname'));
    $openid->SetRequiredFields(array());
    $server_url = $openid->GetOpenIDServer();
    $_SESSION['openid_server_url'] = $server_url;
    #echo $server_url; exit;
    $openid->SetOpenIDServer($server_url);
    if ($openid->IsError()) {
        trigger_error('sorry there was an openid error: ' . serialize($openid->GetError()), E_USER_ERROR);
    }
    $url = trim($server_url);
    if (empty($url)) {
        trigger_error('sorry there was an openid error: the server url is not set ' . serialize($_SESSION), E_USER_ERROR);
    }
    redirect_to($openid->GetRedirectURL());
}