Exemplo n.º 1
0
/**
 * Output a dump of a variable
 *
 * @param string $var variable which will be dumped
 * @deprecated	Use icms_core_Debug::vardump() instead
 */
function icms_debug_vardump($var)
{
    icms_core_Debug::setDeprecated('icms_core_Debug::vardump');
    return icms_core_Debug::vardump($var);
}
Exemplo n.º 2
0
 /**
  * Authenticate using the OpenID protocol
  *
  * @param bool $debug Turn debug on or not
  * @return bool successful?
  */
 public function authenticate($debug = FALSE)
 {
     // check to see if we already have an OpenID response in SESSION
     if (isset($_SESSION['openid_response'])) {
         if ($debug) {
             icms_core_Debug::message(_CORE_OID_INSESSIONS);
         }
         $this->response = unserialize($_SESSION['openid_response']);
     } else {
         if ($debug) {
             icms_core_Debug::message(_CORE_OID_FETCHING);
         }
         // Complete the authentication process using the server's response.
         $consumer = getConsumer();
         $return_to = getReturnTo();
         //$this->response = $consumer->complete($_GET);
         $this->response = $consumer->complete($return_to);
         $_SESSION['openid_response'] = serialize($this->response);
     }
     if ($this->response->status == Auth_OpenID_CANCEL) {
         if ($debug) {
             icms_core_Debug::message(_CORE_OID_STATCANCEL);
         }
         // This means the authentication was cancelled.
         $this->setErrors('100', _CORE_OID_VERIFCANCEL);
     } elseif ($this->response->status == Auth_OpenID_FAILURE) {
         if ($debug) {
             icms_core_Debug::message(_CORE_OID_SERVERFAILED);
         }
         $this->setErrors('101', _CORE_OID_FAILED . $this->response->message);
         if ($debug) {
             icms_core_Debug::message(_CORE_OID_DUMPREQ);
             icms_core_Debug::vardump($_REQUEST);
         }
         return FALSE;
     } elseif ($this->response->status == Auth_OpenID_SUCCESS) {
         // This means the authentication succeeded.
         $this->displayid = $this->response->getDisplayIdentifier();
         $this->openid = $this->response->identity_url;
         $sreg_resp = Auth_OpenID_SRegResponse::fromSuccessResponse($this->response);
         $sreg = $sreg_resp->contents();
         $_SESSION['openid_sreg'] = $sreg;
         if ($debug) {
             icms_core_Debug::message(_CORE_OID_SERVERSUCCESS);
             icms_core_Debug::message(_CORE_OID_DISPID . $this->displayid);
             icms_core_Debug::message(_CORE_OID_OPENID . $this->openid);
             icms_core_Debug::message(_CORE_OID_DUMPING);
             icms_core_Debug::vardump($sreg);
         }
         $esc_identity = htmlspecialchars($this->openid, ENT_QUOTES);
         $success = sprintf(_CORE_OID_SUCESSFULLYIDENTIFIED, $esc_identity, $this->displayid);
         if ($this->response->endpoint->canonicalID) {
             $success .= sprintf(_CORE_OID_CANONID, $this->response->endpoint->canonicalID);
         }
         /**
          * Now, where are we in the process, just back from OpenID server or trying to register or
          * trying to link to an existing account
          */
         if (isset($_POST['openid_register'])) {
             if ($debug) {
                 icms_core_Debug::message(_CORE_OID_STEPIS . 'OPENID_STEP_REGISTER');
             }
             $this->step = OPENID_STEP_REGISTER;
         } elseif (isset($_POST['openid_link'])) {
             if ($debug) {
                 icms_core_Debug::message(_CORE_OID_STEPIS . 'OPENID_STEP_LINK');
             }
             $this->step = OPENID_STEP_LINK;
         } elseif (isset($_SESSION['openid_step'])) {
             if ($debug) {
                 icms_core_Debug::message(_CORE_OID_STEPIS . $_SESSION['openid_step']);
             }
             $this->step = $_SESSION['openid_step'];
         } else {
             if ($debug) {
                 icms_core_Debug::message(_CORE_OID_CHECKINGID);
             }
             // Do we already have a user with this openid
             $member_handler = icms::handler('icms_member');
             $criteria = new icms_db_criteria_Compo();
             $criteria->add(new icms_db_criteria_Item('openid', $this->openid));
             $users =& $member_handler->getUsers($criteria);
             if ($users && count($users) > 0) {
                 $this->step = OPENID_STEP_USER_FOUND;
                 if ($debug) {
                     icms_core_Debug::message(_CORE_OID_FOUNDSTEPIS . 'OPENID_STEP_USER_FOUND');
                 }
                 return $users[0];
             } else {
                 /*
                  * This openid was not found in the users table. Let's ask the user if he wants
                  * to create a new user account on the site or else login with his already registered
                  * account
                  */
                 if ($debug) {
                     icms_core_Debug::message(_CORE_OID_NOTFOUNDSTEPIS . 'OPENID_STEP_NO_USER_FOUND');
                 }
                 $this->step = OPENID_STEP_NO_USER_FOUND;
                 return FALSE;
             }
         }
     }
 }