- $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1",
- intval($_SESSION['uid'])
- );
- if(count($r)) {
- $a->contact = $r[0];
- $a->cid = $r[0]['id'];
- $_SESSION['cid'] = $a->cid;
+ if ($a->config['register_policy'] == REGISTER_CLOSED) {
+ notice( t('Account not found and OpenID registration is not permitted on this site.') . EOL);
+ goaway(z_root());
+ }
+
+ unset($_SESSION['register']);
+ $args = '';
+ $attr = $openid->getAttributes();
+ if (is_array($attr) && count($attr)) {
+ foreach ($attr as $k => $v) {
+ if ($k === 'namePerson/friendly') {
+ $nick = notags(trim($v));
+ }
+ if($k === 'namePerson/first') {
+ $first = notags(trim($v));
+ }
+ if($k === 'namePerson') {
+ $args .= '&username=' . urlencode(notags(trim($v)));
+ }
+ if ($k === 'contact/email') {
+ $args .= '&email=' . urlencode(notags(trim($v)));
+ }
+ if ($k === 'media/image/aspect11') {
+ $photosq = bin2hex(trim($v));
+ }
+ if ($k === 'media/image/default') {
+ $photo = bin2hex(trim($v));
+ }
+ }
+ }
+ if ($nick) {
+ $args .= '&nickname=' . urlencode($nick);
+ }
+ elseif ($first) {
+ $args .= '&nickname=' . urlencode($first);