X-Git-Url: https://git.cweiske.de/phorkie.git/blobdiff_plain/f5bdbfca6e34e35231ab7ae72241c152b047f86b..2017065c9b89d4f435e86d03d28c219edcdf5bf9:/www/login.php diff --git a/www/login.php b/www/login.php index 00d1877..e4438a4 100644 --- a/www/login.php +++ b/www/login.php @@ -18,6 +18,7 @@ set_include_path( . PATH_SEPARATOR . get_include_path() ); +$pageRequiresLogin = false; require_once 'www-header.php'; require_once 'openid/config.php'; @@ -52,7 +53,7 @@ if (isset($_POST['openid_url'])) { } try { - $o = new OpenID_RelyingParty($returnTo, $realm, $openid_url); + $o = new \OpenID_RelyingParty($returnTo, $realm, $openid_url); } catch (OpenID_Exception $e) { $contents = "
\n"; $contents .= "
" . $e->getMessage() . "
\n"; @@ -66,8 +67,8 @@ if (!empty($_POST['disable_associations']) || !empty($_SESSION['disable_associat $_SESSION['disable_associations'] = true; } -$log = new OpenID_Observer_Log; -OpenID::attach($log); +$log = new \OpenID_Observer_Log; +\OpenID::attach($log); if (isset($_POST['start'])) { @@ -88,13 +89,12 @@ if (isset($_POST['start'])) { } // SREG - $sreg = new OpenID_Extension_SREG11(OpenID_Extension::REQUEST); - $sreg->set('required', 'email,firstname,lastname,nickname'); - $sreg->set('optional', 'gender,dob'); + $sreg = new \OpenID_Extension_SREG11(\OpenID_Extension::REQUEST); + $sreg->set('required', 'email,fullname'); $authRequest->addExtension($sreg); // AX - $ax = new OpenID_Extension_AX(OpenID_Extension::REQUEST); + $ax = new \OpenID_Extension_AX(\OpenID_Extension::REQUEST); $ax->set('type.email', 'http://axschema.org/contact/email'); $ax->set('type.firstname', 'http://axschema.org/namePerson/first'); $ax->set('type.lastname', 'http://axschema.org/namePerson/last'); @@ -104,7 +104,7 @@ if (isset($_POST['start'])) { // UI if (!empty($_POST['ui'])) { - $ui = new OpenID_Extension_UI(OpenID_Extension::REQUEST); + $ui = new \OpenID_Extension_UI(\OpenID_Extension::REQUEST); $ui->set('mode', 'popup'); $ui->set('language', 'en-US'); $authRequest->addExtension($ui); @@ -112,7 +112,7 @@ if (isset($_POST['start'])) { // OAuth if (!empty($_POST['oauth'])) { - $oauth = new OpenID_Extension_OAuth(OpenID_Extension::REQUEST); + $oauth = new \OpenID_Extension_OAuth(\OpenID_Extension::REQUEST); $oauth->set('consumer', $_POST['oauth_consumer_key']); $_SESSION['OAuth_consumer_key'] = $_POST['oauth_consumer_key']; $_SESSION['OAuth_consumer_secret'] = $_POST['oauth_consumer_secret']; @@ -150,12 +150,12 @@ if (isset($_POST['start'])) { $queryString = file_get_contents('php://input'); } - $message = new OpenID_Message($queryString, OpenID_Message::FORMAT_HTTP); + $message = new \OpenID_Message($queryString, \OpenID_Message::FORMAT_HTTP); $id = $message->get('openid.claimed_id'); $mode = $message->get('openid.mode'); try { - $result = $o->verify(new Net_URL2($returnTo . '?' . $queryString), $message); + $result = $o->verify(new \Net_URL2($returnTo . '?' . $queryString), $message); if ($result->success()) { $status = "Status:SUCCESS!"; @@ -176,7 +176,7 @@ if (isset($_POST['start'])) { $_SESSION['OAuth_access_token_method'])) { try { - $oauth = new OpenID_Extension_OAuth(OpenID_Extension::RESPONSE, + $oauth = new \OpenID_Extension_OAuth(\OpenID_Extension::RESPONSE, $message); // Fix line lengths. @@ -197,17 +197,32 @@ if (isset($_POST['start'])) { $openid = $message->getArrayFormat(); - $email = (isset($openid['openid.ext1.value.email'])) ? $openid['openid.ext1.value.email'] : null; - $email = (isset($openid['openid.ext2.value.email']) && !isset($email)) ? $openid['openid.ext2.value.email'] : $email; - $email = (isset($openid['openid.sreg.email']) && !isset($email)) ? $openid['openid.sreg.email'] : $email; - $email = (isset($openid['openid.ax.value.email']) && !isset($email)) ? $openid['openid.ax.value.email'] : $email; - $_SESSION['email'] = (isset($email)) ? $email : $GLOBALS['phorkie']['auth']['anonymousEmail']; - - $name = (isset($openid['openid.ext1.value.firstname']) && isset($openid['openid.ext1.value.lastname'])) ? $openid['openid.ext1.value.firstname']." ".$openid['openid.ext1.value.lastname'] : null; - $name = (isset($openid['openid.sreg.firstname']) && isset($openid['openid.sreg.lastname']) && !isset($name)) ? $openid['openid.sreg.firstname']." ".$openid['openid.sreg.lastname'] : $name; - $name = (isset($openid['openid.sreg.nickname']) && !isset($name)) ? $openid['openid.sreg.nickname'] : $name; - $_SESSION['name'] = (isset($name)) ? $name : $_SERVER['REMOTE_ADDR']; - + $email = isset($openid['openid.ext1.value.email']) + ? $openid['openid.ext1.value.email'] + : null; + $email = isset($openid['openid.ext2.value.email']) && !isset($email) + ? $openid['openid.ext2.value.email'] + : $email; + $email = isset($openid['openid.sreg.email']) && !isset($email) + ? $openid['openid.sreg.email'] + : $email; + $email = isset($openid['openid.ax.value.email']) && !isset($email) + ? $openid['openid.ax.value.email'] + : $email; + $_SESSION['email'] = isset($email) + ? $email + : $GLOBALS['phorkie']['auth']['anonymousEmail']; + + $name = isset($openid['openid.ext1.value.firstname']) + && isset($openid['openid.ext1.value.lastname']) + ? $openid['openid.ext1.value.firstname'] . ' ' + . $openid['openid.ext1.value.lastname'] + : null; + $name = isset($openid['openid.sreg.fullname']) && !isset($name) + ? $openid['openid.sreg.fullname'] + : $name; + + $_SESSION['name'] = isset($name) ? $name : $_SERVER['REMOTE_ADDR']; $_SESSION['identity'] = $openid['openid.identity']; $redirect = 'http://' . $_SERVER['HTTP_HOST'] . $_SESSION['REQUEST_URI'];