4 require_once('library/openid.php');
7 function openid_content(&$a) {
9 $noid = get_config('system','no_openid');
13 if((x($_GET,'openid_mode')) && (x($_SESSION,'openid'))) {
14 $openid = new LightOpenID;
16 if($openid->validate()) {
18 if(x($_SESSION,'register')) {
19 unset($_SESSION['register']);
21 $attr = $openid->getAttributes();
22 if(is_array($attr) && count($attr)) {
23 foreach($attr as $k => $v) {
24 if($k === 'namePerson/friendly')
25 $nick = notags(trim($v));
26 if($k === 'namePerson/first')
27 $first = notags(trim($v));
28 if($k === 'namePerson')
29 $args .= '&username=' . notags(trim($v));
30 if($k === 'contact/email')
31 $args .= '&email=' . notags(trim($v));
32 if($k === 'media/image/aspect11')
33 $photosq = bin2hex(trim($v));
34 if($k === 'media/image/default')
35 $photo = bin2hex(trim($v));
39 $args .= '&nickname=' . $nick;
41 $args .= '&nickname=' . $first;
44 $args .= '&photo=' . $photosq;
46 $args .= '&photo=' . $photo;
48 $args .= '&openid_url=' . notags(trim($_SESSION['openid']));
49 if($a->config['register_policy'] != REGISTER_CLOSED)
50 goaway($a->get_baseurl() . '/register' . $args);
58 $r = q("SELECT `user`.*, `user`.`pubkey` as `upubkey`, `user`.`prvkey` as `uprvkey`
59 FROM `user` WHERE `openid` = '%s' AND `blocked` = 0 AND `account_expired` = 0 AND `verified` = 1 LIMIT 1",
60 dbesc($_SESSION['openid'])
63 notice( t('Login failed.') . EOL );
66 unset($_SESSION['openid']);
68 require_once('include/security.php');
69 authenticate_success($r[0],true,true);
71 // just in case there was no return url set
72 // and we fell through
77 notice( t('Login failed.') . EOL);