Comunque nel frattempo ti allego le istruzioni in .mht, che puoi aprire con explorer stesso o con firefox (con l'installazione dell'addons "unMht")....ricordati di modificare il contenuto del file:
Codice: Seleziona tutto
<?php
class CSAlternateLogin
{
function page_header(&$hook)
{
global $template, $user, $phpbb_root_path, $phpEx, $config;
$result = $hook->previous_hook_result('phpbb_user_session_handler');
// Begin Alternate Login code
require_once($phpbb_root_path . 'includes/functions_alternatelogin.php'); // Include the functions for Alternate Login module
$user->add_lang('mods/info_ucp_alternatelogin');
if($user->data['session_fb_access_token'])
{
$graph_url = "https://graph.facebook.com/me?" . $user->data['session_fb_access_token'];
$fb_user = json_decode(get_fb_data($graph_url));
$fb_lang = $fb_user->locale;
}
$template->assign_vars(array(
'S_AL_FB_ENABLED' => isset($config['al_fb_login']) ? $config['al_fb_login'] : false,
'S_AL_TW_ENABLED' => isset($config['al_tw_login']) ? $config['al_tw_login'] : false,
'S_AL_WL_ENABLED' => isset($config['al_wl_login']) ? $config['al_wl_login'] : false,
'S_AL_OI_ENABLED' => isset($config['al_oi_login']) ? $config['al_oi_login'] : false,
'S_AL_WL_USER' => isset($user->data['al_wl_id']) ? $user->data['al_wl_id'] : false,
'S_AL_FB_USER' => isset($user->data['al_fb_id']) ? $user->data['al_fb_id'] : false,
'S_AL_TW_USER' => isset($user->data['al_tw_id']) ? $user->data['al_tw_id'] : false,
'S_AL_OI_USER' => isset($user->data['al_oi_id']) ? $user->data['al_oi_id'] : false,
'AL_FB_APPID' => isset($config['al_fb_id']) ? $config['al_fb_id'] : false,
'AL_FB_SITE_DOMAIN' => isset($config['al_site_domain']) ? $config['al_site_domain'] : false,
'AL_FB_ACTIVITY' => isset($config['al_fb_activity']) ? $config['al_fb_activity'] : false,
'AL_FB_FACEPILE' => isset($config['al_fb_facepile']) ? $config['al_fb_facepile'] : false,
'AL_FB_STREAM' => isset($config['al_fb_stream']) ? $config['al_fb_stream'] : false,
'AL_FB_LIKE_BOX' => isset($config['al_fb_like_box']) ? $config['al_fb_like_box'] : false,
'S_AL_WL_CLIENT_ID' => isset($config['al_wl_client_id']) ? $config['al_wl_client_id'] : false,
'S_AL_WL_WRAP_CALLBACK' => isset($config['al_wl_callback']) ? $config['al_wl_callback'] : false,
'S_AL_WL_WRAP_CHANNEL' => isset($config['al_wl_channel']) ? $config['al_wl_channel'] : false,
'AL_FB_APP_ID' => isset($config['al_fb_id']) ? $config['al_fb_id'] : false,
'AL_FB_PAGE_URL' => isset($config['al_fb_page_url']) ? $config['al_fb_page_url'] : false,
'FB_APP_ID' => isset($config['al_fb_id']) ? $config['al_fb_id'] : false,
'AL_FB_USER_HIDE_ACTIVITY' => isset($user->data['al_fb_hide_activity']) ? $user->data['al_fb_hide_activity'] : false,
'AL_FB_USER_HIDE_STREAM' => isset($user->data['al_fb_hide_stream']) ? $user->data['al_fb_hide_stream'] : false,
'AL_FB_USER_HIDE_FACEPILE' => isset($user->data['al_fb_hide_facepile']) ? $user->data['al_fb_hide_facepile'] : false,
'AL_FB_USER_HIDE_LIKE_BOX' => isset($user->data['al_fb_hide_like_box']) ? $user->data['al_fb_hide_like_box'] : false,
'U_AL_WL_AUTHORIZE' => "https://oauth.live.com/authorize?client_id={$config['al_wl_client_id']}&scope=wl.signin%20wl.basic%20wl.birthday%20wl.emails%20wl.work_profile%20wl.postal_addresses&response_type=code&redirect_uri=" . urlencode($config['al_wl_callback']),
'U_AL_TW_REQUEST' => "{$phpbb_root_path}alternatelogin/al_tw_connect.{$phpEx}?authentication=1",
'U_AL_OI_LOGIN' => "{$phpbb_root_path}alternatelogin/al_oi_auth.{$phpEx}",
'S_FB_LOCALE' => ($fb_lang) ? $fb_lang : 'en_GB',
'S_RETURN_TO_PAGE' => "?return_to_page=" . base64_encode(build_url()),
'U_PAGE_URL' => generate_board_url() . "/viewtopic.$phpEx?f=$forum_id&t=$topic_id",
));
}
}
$phpbb_hook->register('phpbb_user_session_handler', array('CSAlternateLogin', 'page_header'));
?>
Codice: Seleziona tutto
<?php
/*
COPYRIGHT 2009 Michael J Goonawardena
This file is part of ConSof Alternate Login.
ConSof Alternate Login is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
ConSof Alternate Login is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with ConSof Alternate Login. If not, see <http://www.gnu.org/licenses/>.*/
if (!defined('IN_PHPBB'))
{
exit;
}
define('AL_FACEBOOK_LOGIN', 0);
define('AL_OPENID_LOGIN', 2);
define('AL_OPENID_PROFILE', 3);
define('AL_GOOGLE_LOGIN', 4);
define('AL_GOOGLE_PROFILE', 5);
define('AL_TWITTER_LOGIN', 6);
define('AL_TWITTER_PROFILE', 7);
define('AL_WINDOWSLIVE_LOGIN', 8);
define('AL_WINDOWSLIVE_PROFILE', 9);
define('AL_FB_SYNC_PROFILE', 1);
define('AL_FB_SYNC_AVATAR', 11);
define('AL_FB_SYNC_STATUS', 12);
define('AL_HIDE_POST_LOGON', 10); // Does the user want to be asked if they want to see the 'hide online' and autologin screen after verification?
define('AL_USER_OPTION_COUNT', 13);
define('WL_COOKIE', 'webauthtoken');
define('PCOOKIE', time() + (10 * 365 * 24 * 60 * 60));
define('HTTP_GET', 0);
define('HTTP_POST', 1);
if(!function_exists('get_wl_tokens'))
{
function get_wl_tokens($cid, $authorization_code, $refresh_token)
{
global $config, $user;
$url = "https://oauth.live.com/token?";
$url .= "client_id={$config['al_wl_client_id']}";
$url .= "&redirect_uri=" . urlencode($config['al_wl_callback']);
$url .= "&client_secret={$config['al_wl_secret']}";
if($authorization_code)
{
$url .= "&code={$authorization_code}";
$url .= "&grant_type=authorization_code";
}
elseif($refresh_token)
{
$url .= "&refresh_token={$refresh_token}";
$url .= "&grant_type=refresh_token";
}
else
{
trigger_error($user->lang['MISSING_AUTH_OR_REFRESH']);
}
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
if(curl_errno($ch))
{
add_log('critical', 'WL_GET_ACCESS_TOKEN_ERROR', $user->data['user_id'], 'WL_GET_ACCESS_TOKEN_ERROR', curl_error($ch));
trigger_error($user->lang['ERROR_RETRIEVING_TOKENS']);
}
curl_close($ch);
$data_decoded = json_decode($data);
if($data_decoded->error)
{
trigger_error($data_decoded->error);
}
return $data_decoded;
}
}
if(!function_exists('get_wl_rest_request'))
{
function get_wl_rest_request($access_token, $path, $method = HTTP_GET, $headers = NULL, $method_data = NULL)
{
$url = "https://apis.live.net/v5.0/{$path}/?access_token={$access_token}";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
if($method == HTTP_GET)
{
curl_setopt($ch, CURLOPT_HTTPGET, true);
}
elseif($method == HTTP_POST)
{
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $method_data);
}
else
{
trigger_error($user->lang['ERROR_UNDETERMINED_HTTP_METHOD']);
}
$data = curl_exec($ch);
if(curl_errno($ch))
{
add_log('critical', 'WL_CURL_REQUEST_ERROR', $user->data['user_id'], 'WL_CURL_REQUEST_ERROR', curl_error($ch));
return false;
}
curl_close($ch);
return json_decode($data);
}
}
if(!function_exists('get_fb_access_token'))
{
function get_fb_access_token($return_to_page)
{
global $config, $db, $user, $template;
$my_url = generate_board_url() . "/alternatelogin/al_fb_connect.php";
if($return_to_page != null && $return_to_page != '')
{
//$return_to_page = urlencode($return_to_page);
$my_url .= "?return_to_page=" . urlencode($return_to_page);
}
$code = request_var('code', '');
if(empty($code)) {
$dialog_url = "http://www.facebook.com/dialog/oauth?client_id="
. $config['al_fb_id'] . "&redirect_uri=" . urlencode($my_url) . "&scope=user_location,user_activities,user_birthday,user_interests,user_status,user_website,user_work_history,email";
page_header($user->lang['FB_REDIRECT']);
$template->set_filenames(array(
'body' => 'al_redirect.html',
));
$template->assign_vars(array(
'S_DIALOG_URL' => $dialog_url,
));
page_footer();
}
$token_url = "https://graph.facebook.com/oauth/access_token?client_id="
. $config['al_fb_id'] . "&redirect_uri=" . urlencode($my_url) . "&client_secret="
. $config['al_fb_secret'] . "&code=" . $code;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $token_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPGET, true);
$access_token = curl_exec($ch);
if(curl_errno($ch))
{
add_log('critical', 'FB_GET_ACCESS_TOKEN_ERROR', $user->data['user_id'], 'FB_GET_ACCESS_TOKEN_ERROR', curl_error($ch));
return false;
}
curl_close($ch);
//$access_token = file_get_contents($token_url);
return $access_token;
}
}
if(!function_exists('refresh_fb_access_token'))
{
function refresh_fb_access_token($return_to_page)
{
global $config, $db, $user, $template;
$my_url = $return_to_page;
$code = request_var('code', '');
if(empty($code)) {
$dialog_url = "http://www.facebook.com/dialog/oauth?client_id="
. $config['al_fb_id'] . "&redirect_uri=" . urlencode($my_url) . "&scope=user_location,user_activities,user_birthday,user_interests,user_status,user_website,user_work_history,email";
page_header($user->lang['FB_REDIRECT']);
$template->set_filenames(array(
'body' => 'al_redirect.html',
));
$template->assign_vars(array(
'S_DIALOG_URL' => $dialog_url,
));
page_footer();
}
$token_url = "https://graph.facebook.com/oauth/access_token?client_id="
. $config['al_fb_id'] . "&redirect_uri=" . urlencode($my_url) . "&client_secret="
. $config['al_fb_secret'] . "&code=" . $code;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $token_url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPGET, true);
$access_token = curl_exec($ch);
if(curl_errno($ch))
{
add_log('critical', 'FB_GET_ACCESS_TOKEN_ERROR', $user->data['user_id'], 'FB_GET_ACCESS_TOKEN_ERROR', curl_error($ch));
return false;
}
curl_close($ch);
$sql_array = array(
'session_fb_access_token' => $access_token,
);
$sql = "UPDATE " . SESSIONS_TABLE . " SET " . $db->sql_build_array('UPDATE', $sql_array) . " WHERE session_id='" . $user->data['session_id'] . "'";
$db->sql_query($sql);
redirect($my_url);
}
}
if(!function_exists('get_fb_data'))
{
function get_fb_data($url)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPGET, true);
$data = curl_exec($ch);
if(curl_errno($ch))
{
add_log('critical', 'FB_GET_USER_ERROR', $user->data['user_id'], 'FB_GET_USER_ERROR', curl_error($ch));
return false;
}
$error_check = json_decode($data);
if(isset($error_check->error))
{
if(($error_check->error->code == 2500) || ($error_check->error->error_subcode == 463))
{
refresh_fb_access_token(generate_board_url() . '/' . $user->data['session_page']);
}
}
curl_close($ch);
return $data;
}
}
if(!function_exists('php_self'))
{
function php_self($dropqs=true) {
$url = sprintf('%s://%s%s',
empty($_SERVER['HTTPS']) ? (@$_SERVER['SERVER_PORT'] == '443' ? 'https' : 'http') : 'http',
$_SERVER['SERVER_NAME'],
$_SERVER['REQUEST_URI']
);
$parts = parse_url($url);
$port = $_SERVER['SERVER_PORT'];
$scheme = $parts['scheme'];
$host = $parts['host'];
$path = @$parts['path'];
$qs = @$parts['query'];
$port or $port = ($scheme == 'https') ? '443' : '80';
if (($scheme == 'https' && $port != '443')
|| ($scheme == 'http' && $port != '80')) {
$host = "$host:$port";
}
$url = "$scheme://$host$path";
if ( ! $dropqs)
return "{$url}?{$qs}";
else
return $url;
}
}
?>