예제 #1
0
<?php

include_once "googleopenid.inc";
//fetch an association handle
$association_handle = GoogleOpenID::getAssociationHandle();
setcookie("google_association_handle", $association_handle, time() + 60 * 60 * 24 * 7 * 2, "/");
setcookie("page_before_google_oauth", $_SERVER['HTTP_REFERER'], time() + 60 * 10, "/");
$googleLogin = GoogleOpenID::createRequest('/oauth/return.php', $association_handle, true);
$googleLogin->redirect();
?>

예제 #2
0
 private function GoogleOpenID($mode, $op_endpoint, $response_nonce, $return_to, $realm, $assoc_handle, $claimed_id, $signed, $sig, $email, $require_email)
 {
     //if assoc_handle is null, fetch one
     if (is_null($assoc_handle)) {
         $assoc_handle = GoogleOpenID::getAssociationHandle();
     }
     //if return_to is a relative URL, make it absolute
     if (stripos($return_to, "http://") == false && stripos($return_to, "https://") == false) {
         //if the first character is a slash, delete it
         if (substr($return_to, 0, 1) == "/") {
             $return_to = substr($return_to, 1);
         }
         //get the position of server_name
         $server_name_pos = stripos($return_to, $_SERVER['SERVER_NAME']);
         //if server_name is already at position zero
         if ($server_name_pos != false && $server_name_pos == 0) {
             $return_to = "http://" . $return_to;
         } else {
             $return_to = "http://" . $_SERVER['SERVER_NAME'] . "/" . $return_to;
         }
         //else (server name not at position zero)
     }
     //if return_to is relative
     //if realm is null, attempt to set it via return_to
     if (is_null($realm)) {
         //if return_to is set
         if (!is_null($return_to)) {
             $pieces = parse_url($return_to);
             $realm = $pieces['scheme'] . "://" . $pieces['host'];
         }
         //if return_to set
     }
     //if realm null
     $this->mode = $mode;
     $this->op_endpoint = $op_endpoint;
     $this->response_nonce = $response_nonce;
     $this->return_to = $return_to;
     $this->realm = $realm;
     $this->assoc_handle = $assoc_handle;
     $this->claimed_id = $claimed_id;
     $this->identity = $claimed_id;
     $this->signed = $signed;
     $this->sig = $sig;
     $this->email = $email;
     $this->require_email = $require_email ? true : false;
 }