dh = false; * However, the latter one would disable stateful mode, unless connecting via HTTPS. */ require 'library/openid/provider/provider.php'; function getUserData($handle=null) { if(! local_channel()) { notice( t('Permission denied.') . EOL); get_app()->page['content'] = login(); } logger('handle: ' . $handle); if($handle) { $r = q("select * from channel left join xchan on channel_hash = xchan_hash where channel_address = '%s' limit 1", dbesc($handle) ); } else { $r = q("select * from channel left join xchan on channel_hash = xchan_hash where channel_id = %d", intval(local_channel()) ); } return $r[0]; /* if(isset($_POST['login'],$_POST['password'])) { $login = mysql_real_escape_string($_POST['login']); $password = sha1($_POST['password']); $q = mysql_query("SELECT * FROM Users WHERE login = '$login' AND password = '$password'"); if($data = mysql_fetch_assoc($q)) { return $data; } if($handle) { echo 'Wrong login/password.'; } } if($handle) { ?>
'First name', 'namePerson/last' => 'Last name', 'namePerson/friendly' => 'Nickname (login)' ); private $attrFieldMap = array( 'namePerson/first' => 'firstName', 'namePerson/last' => 'lastName', 'namePerson/friendly' => 'login' ); function setup($identity, $realm, $assoc_handle, $attributes) { logger('identity: ' . $identity); logger('realm: ' . $realm); logger('assoc_handle: ' . $assoc_handle); logger('attributes: ' . print_r($attributes,true)); $data = getUserData($assoc_handle); $o .= ''; get_app()->page['content'] .= $o; } function checkid($realm, &$attributes) { logger('checkid: ' . $realm); logger('checkid attrs: ' . print_r($attributes,true)); if(isset($_POST['cancel'])) { $this->cancel(); } $data = getUserData(); if(! $data) { return false; } logger('checkid: checkpoint1'); $q = get_pconfig(local_channel(),'openid',$realm); $attrs = array(); if($q) { $attrs = $q; } elseif(isset($_POST['attributes'])) { $attrs = array_keys($_POST['attributes']); } elseif(!isset($_POST['once']) && !isset($_POST['always'])) { return false; } $attributes = array(); foreach($attrs as $attr) { if(isset($this->attrFieldMap[$attr])) { $attributes[$attr] = $data[$this->attrFieldMap[$attr]]; } } if(isset($_POST['always'])) { set_pconfig(local_channel(),'openid',$realm,array_keys($attributes)); } return z_root() . '/id/' . $data['channel_address']; } function assoc_handle() { $channel = get_app()->get_channel(); return z_root() . '/id/' . $channel['channel_address']; } function setAssoc($handle, $data) { logger('setAssoc'); $channel = channelx_by_nick(basename($handle)); if($channel) set_pconfig($channel['channel_id'],'openid','associate',$data); } function getAssoc($handle) { logger('getAssoc: ' . $handle); $channel = channelx_by_nick(basename($handle)); if($channel) return get_pconfig($channel['channel_id'],'openid','associate'); return false; } function delAssoc($handle) { logger('delAssoc'); $channel = channelx_by_nick(basename($handle)); if($channel) return del_pconfig($channel['channel_id'],'openid','associate'); } } $op = new MysqlProvider; $op->server(); }