Built on the technologies developed and maintained by April-Child.com
Copyright (c)2007,2008 Petr Krontorad, April-Child.com.
Author: Petr Krontorad, petr@krontorad.com
All rights reserved.
------------------------------------------------------------------------------------------
User and session management library
------------------------------------------------------------------------------------------
public function on_user_register($pars) { $user = new AmyUser($this->configuration); try { $user->register($pars['username'], $pars['password'], 'amy', $pars); $user->create_session(); } catch (Exception $e) { self::raiseError('Unable to register: ' . $e->getMessage()); } self::setResult($user); }
$callback_url = 'http://www.april-child.com/amy/amy.php?act_as=facebook'; try { if (!$facebook->api_client->users_isAppAdded()) { $facebook->redirect($facebook->get_add_url()); } } catch (Exception $e) { // this will clear cookies for your application and // redirect them to a login prompt $facebook->set_user(null, null); $facebook->redirect($callback_url); } if (!isset($_REQUEST['iframe_skipped'])) { echo '<html><head><body><script type="text/javascript">top.location.href="' . $callback_url . '&auth_token=' . $_GET['auth_token'] . '&iframe_skipped=true' . '" + ((top.opener&&top.opener.location.host==\'www.april-child.com\') ? "&external_service=true" : "");</script></body></html>'; exit; } $amy_user = new AmyUser($_AMY_CONF); try { $amy_user->authorize($user, null, 'facebook'); } catch (Exception $e) { } if (!$amy_user->is_authorized()) { // first time visit from Facebook // let's register user try { $user_info = $facebook->api_client->users_getInfo(array($user), array('name', 'pic_square')); $credentials = array('nickname' => $user_info[0]['name'], 'picture' => $user_info[0]['pic_square']); $amy_user->register($user, null, 'facebook', $credentials); } catch (Exception $e) { } } else { if ($_REQUEST['external_service']) {
} } if (isset($GLOBALS['amy_user']) && $GLOBALS['amy_user'] instanceof AmyUser) { $amy_user = $GLOBALS['amy_user']; } else { try { $session = new AmySession($_AMY_CONF); $session->authorize(); $amy_user = new AmyUser($_AMY_CONF); $amy_user->load_from_session($session); } catch (Exception $e) { } } try { if (!is_object($amy_user)) { $amy_user = new AmyUser($_AMY_CONF); } if (!$amy_user->is_authorized()) { $amy_user->make_default(); } $amy_session = $amy_user->create_session(); } catch (Exception $e) { if ('development' == $GLOBALS['_AMY_CONF']['environment']) { echo '<h1>Amy Editor Exception</h1>'; echo $e->getMessage(); echo '<hr/><pre>'; print_r($e); die; } } ?>