if (!isset($_SESSION['RequestToken']) || $_SESSION['RequestToken'] != $oauth_token) { session_destroy(); go_home(); } include HCPATH . HCINC . '/api/twitter/AccessToken.php'; if (isset($authUser) && isset($authUserID) && isset($authToken) && isset($authSecret) && $authUser . $authUserID . $authToken . $authSecret != '') { $result = doQuery("SELECT PkID, Email, Birthdate FROM " . HC_TblPrefix . "users WHERE NetworkType = '1' AND NetworkID = '" . cIn($authUserID) . "'"); if (!hasRows($result)) { $local_id = user_register_new(1, $authUser, $authUserID); $_SESSION['new_user'] = true; } else { $local_id = mysql_result($result, 0, 0); if (mysql_result($result, 0, 1) == '' || mysql_result($result, 0, 2) == '') { $_SESSION['new_user'] = true; } } $_SESSION['UserNetToken'] = $authToken; $_SESSION['UserNetSecret'] = $authSecret; user_update_status(1, $authUser, $authUserID, 1); user_update_history($local_id); $target = CalRoot . '/index.php?com=acc'; } } else { $oauth_token = $oauth_verifier = ''; include HCPATH . HCINC . '/api/twitter/RequestToken.php'; if (isset($_SESSION['RequestToken']) && $_SESSION['RequestToken'] != '') { $target = 'https://api.twitter.com/oauth/authenticate?oauth_token=' . $_SESSION['RequestToken']; } } } header('Location: ' . $target);
/** * @package Helios Calendar * @license GNU General Public License version 2 or later; see LICENSE */ if (!defined('isHC')) { exit(-1); } header("X-Frame-Options: SAMEORIGIN"); if (function_exists('ini_set')) { ini_set("session.cookie_httponly", true); } session_name($hc_cfg[201]); session_start(); if (user_check_status() && $_SESSION['UserLoginTime'] + 300 < date("U")) { user_update_status($_SESSION['UserNetType'], $_SESSION['UserNetName'], $_SESSION['UserNetID'], $_SESSION['UserLoggedIn']); } if (!isset($_SESSION['LangSet'])) { $_SESSION['LangSet'] = $hc_cfg[28]; } if (!isset($_SESSION['Theme'])) { $_SESSION['Theme'] = !isset($_SERVER['HTTP_USER_AGENT']) || !preg_match("{$hc_cfg['86']}i", $_SERVER['HTTP_USER_AGENT']) ? $hc_cfg[83] : $hc_cfg[84]; } if (isset($_GET['theme']) && $_GET['theme'] != '') { $theme = cIn(strip_tags($_GET['theme'])); if (is_dir(HCPATH . '/themes/' . $theme . '/')) { $_SESSION['Theme'] = strtolower($theme); } } if (!isset($_SESSION['hc_favCat']) && isset($_COOKIE[$hc_cfg[201] . '_fn'])) { $_SESSION['hc_favCat'] = cIn(strip_tags(base64_decode($_COOKIE[$hc_cfg[201] . '_fn'])));
if (isset($user->birthday)) { $_SESSION['new_user_bday'] = $user->birthday; } if (isset($user->email)) { $_SESSION['new_user_email'] = $user->email; } } else { $local_id = mysql_result($result, 0, 0); if (mysql_result($result, 0, 1) == '' || mysql_result($result, 0, 2) == '') { $_SESSION['new_user'] = true; if (isset($user->birthday)) { $_SESSION['new_user_bday'] = $user->birthday; } if (isset($user->email)) { $_SESSION['new_user_email'] = $user->email; } } } $_SESSION['UserNetToken'] = $response->access_token; $_SESSION['UserNetSecret'] = NULL; user_update_status(3, $user_name, $user->id, 1); user_update_history($local_id); unset($_SESSION['Google_State']); $target = CalRoot . '/index.php?com=acc'; } } } else { $target = 'https://accounts.google.com/o/oauth2/auth?client_id=' . urlencode($client_id) . '&redirect_uri=' . urlencode($callback_url) . '&state=' . urlencode($_SESSION['Google_State']) . '&response_type=code&scope=' . urlencode('https://www.googleapis.com/auth/userinfo.profile'); } } header('Location: ' . $target);
$response = file_get_contents('https://graph.facebook.com/oauth/access_token?client_id=' . $app_id . '&redirect_uri=' . urlencode($callback_url) . '&client_secret=' . $app_secret . '&code=' . $code); $params = null; parse_str($response, $params); $user = json_decode(file_get_contents('https://graph.facebook.com/me?access_token=' . $params['access_token'])); if (isset($user) && isset($params)) { $result = doQuery("SELECT PkID, Email, Birthdate FROM " . HC_TblPrefix . "users WHERE NetworkType = '2' AND NetworkID = '" . cIn($user->id) . "'"); if (!hasRows($result)) { $local_id = user_register_new(2, $user->name, $user->id); $_SESSION['new_user'] = true; $_SESSION['new_user_bday'] = $user->birthday; $_SESSION['new_user_email'] = $user->email; } else { $local_id = mysql_result($result, 0, 0); if (mysql_result($result, 0, 1) == '' || mysql_result($result, 0, 2) == '') { $_SESSION['new_user'] = true; $_SESSION['new_user_bday'] = $user->birthday; $_SESSION['new_user_email'] = $user->email; } } $_SESSION['UserNetToken'] = $params['access_token']; $_SESSION['UserNetSecret'] = NULL; user_update_status(2, $user->name, $user->id, 1); user_update_history($local_id); unset($_SESSION['FB_State']); $target = CalRoot . '/index.php?com=acc'; } } else { $target = 'https://www.facebook.com/dialog/oauth?client_id=' . urlencode($app_id) . '&redirect_uri=' . urlencode($callback_url) . '&state=' . urlencode($_SESSION['FB_State']) . '&display=page&scope=' . urlencode('email,user_birthday'); } } header('Location: ' . $target);