<?php
class Yours extends Controller {
function Yours()
{
parent::Controller();
// load the OpenID library
$this->load->library('openid');
}
function index()
{
// get the link data
$data['openid_links'] = $this->openid->build_auth(
'yours/try_auth', array('openid', 'google', 'yahoo'), 'yours/load_icon');
// load the sign in page
$this->load->view('signin', $data);
}
function try_auth()
{
// figure out which provider we're loading
$which = $this->uri->segment(3);
switch ($which)
{
// handle standard OpenID
case 'openid':
if (array_key_exists('openid', $_POST))
{
$result = $this->openid->try_auth($_POST['openid'], 'yours/finish_auth');
}
else
{
$data['message'] = 'No Provider Given';
}
break;
// handle Google Accounts
case 'google':
$result = $this->openid->try_auth_google('yours/finish_auth');
break;
// handle Yahoo!
case 'yahoo':
$result = $this->openid->try_auth_yahoo('yours/finish_auth');
break;
// handle errors
default:
$data['message'] = 'Invalid Provider';
break;
}
// handle errors
if (isset($result) && is_int($result))
{
$data['message'] = $this->openid->last_error();
}
$this->load->view('signin', $data);
}
function finish_auth()
{
// finish authentication
$result = $this->openid->finish_auth();
// check for errors
if (is_int($result))
{
$data['error'] = $this->openid->last_error();
}
else
{
$data['user_data'] = $result;
}
// load the next page
$this->load->view('next/page', $data);
}
// create the icon loader
function load_icon()
{
$this->openid->icon_loader();
}
}
/* End of file *