예제 #1
0
 function eventCheckOpenIdCallBack(EventControler $eventControler)
 {
     if (!file_exists("Zend/OpenId/Consumer.php")) {
         return false;
     }
     $message_status = "";
     if ($_GET['openid_mode'] == 'id_res') {
         $consumer = new Zend_OpenId_Consumer();
         if ($consumer->verify($_GET, $this->openid_identifier)) {
             //$conx = $eventControler->getDbCon();
             $qCheck = new sqlQuery($this->getDbCon());
             $eventControler->setLog("\n OpenId check," . $this->openid_identifier . " table:" . $this->getTable());
             $this->query("select * from `" . $this->getTable() . "` where `openid`='" . $this->openid_identifier . "'");
             $eventControler->setLog("\n Query executed for sign on:" . $this->getSqlQuery());
             $eventControler->setLog("\n RegPage:" . $this->openid_regPage . " goto:" . $this->openid_goto . " errPage:" . $this->openid_errPage);
             if ($qCheck->getNumrows() == 1) {
                 $userdata = array();
                 $userdata['id'] = $this->getPrimaryKeyValue();
                 //$userdata['id'] = $this->iduser;
                 $userdata['firstname'] = $this->firstname;
                 $userdata['lastname'] = $this->lastname;
                 $userdata['email'] = $this->{$this->getEmailField()};
                 $userdata['username'] = $this->{$this->getUsernameField()};
                 if ($this->isadmin) {
                     $userdata['isadmin'] = 1;
                 }
                 $userdata['user_table'] = $user_table;
                 $_SESSION['userdata'] = $userdata;
                 if (!$this->isPersistent()) {
                     $this->sessionPersistent("do_" . $this->getObjectName(), "signout.php", 36000);
                 }
                 $eventControler->goto = $this->openid_goto;
                 $eventControler->setUrlNext($this->openid_goto);
                 return true;
             } else {
                 $eventControler->setLog("\n this user need to register:" . $this->openid_regPage);
                 $eventControler->goto = $this->openid_regPage;
                 $eventControler->setUrlNext($this->openid_regPage);
                 $eventControler->setLog("\n Redirected set to:" . $eventControler->getUrlNext());
                 return true;
             }
         } else {
             $message_status = 'The OpenID is invalid.';
         }
     } elseif ($_GET['openid_mode'] == 'cancel') {
         $message_status = 'The OpenID login was cancelled.';
     } else {
         $message_status = 'The OpenID is invalid.';
     }
     if (!empty($message_status)) {
         $err_disp = new Display($this->openid_errPage);
         $err_disp->addParam("openidmessage", $message_status);
         $eventControler->setDisplayNext($err_disp);
         return false;
     }
 }
예제 #2
0
 * @version 1.3
 */
//session_start();
require_once 'config.php';
require_once 'Zend/OpenId/Consumer.php';
$eventControler = new EventControler($GLOBALS['conx']);
$eventControler->setLogRun(true);
$eventControler->setMyDbPath($cfg_local_mydbdir);
$eventControler->setMessagePage("message.php");
$eventControler->setCheckReferer(false);
//echo $_SESSION['openid_userclass'];
if (!isset($_SESSION['openid_userclass'])) {
    $eventControler->setUrlNext("index.php");
    $eventControler->doForward();
    exit;
} else {
    $cur_userclass = $_SESSION['openid_userclass'];
}
$eventControler->setLog("\n--- OpenId Call back --");
$eventControler->setLog("\n userclass:" . $_SESSION['openid_userclass']);
$eventControler->setLog("\n openid_mode:" . $_GET['openid_mode']);
$events = array();
$events[50] = $cur_userclass . "->eventCheckOpenIdCallBack";
$events[40] = "mydb.gotoPage";
if (isset($_GET['openid_mode'])) {
    $eventControler->addParam("goto", "sess_test2.php");
    $eventControler->listenEvents($events);
    $eventControler->doForward();
    //echo $eventControler->getUrlNext();
}
//unset($_SESSION['openid_userclass']);