Example #1
0
        $this->username = preg_replace('/.+?\\/.*?([\\w\\.\\-_]+)$/', '$1', $user_profile['username']);
        // Most Facebook users don't have a name, only profile number
        if (!$this->username || preg_match('/^\\d+$/', $this->username)) {
            // Create a name like a uri used in stories
            if (strlen($user_profile['name']) > 2) {
                $this->username = User::get_valid_username($user_profile['name']);
            } else {
                $this->username = '******' . $this->username;
            }
        }
        $db->transaction();
        if (!$this->user_exists()) {
            $this->url = $user_profile['link'];
            $this->names = $user_profile['name'];
            if ($user_profile['username']) {
                $this->avatar = "http://graph.facebook.com/" . $user_profile['username'] . "/picture";
            }
            $this->store_user();
        }
        $this->store_auth();
        $db->commit();
        $this->user_login();
    }
}
$auth = new FBConnect();
// syslog(LOG_INFO, "FBconnect: ".$_SERVER["REQUEST_URI"]);
if ($auth->user) {
    $auth->authorize();
} else {
    $auth->authRequest();
}