} $facebook = new Facebook(array('appId' => $settings['facebookappid'], 'secret' => $settings['facebookappsecret'])); $user = $facebook->getUser(); if ($user) { try { // Proceed knowing you have a logged in user who's authenticated. $user_profile = $facebook->api('/me'); if (!isset($user_profile['email'])) { $params = array('scope' => 'email', 'redirect_uri' => getUrl() . '/facebookOAuth/', 'auth_type' => 'rerequest'); $loginUrl = $facebook->getLoginUrl($params); header('location: ' . $loginUrl); exit; } else { $data = array('fullname' => $user_profile['first_name'] . ' ' . $user_profile['last_name'], 'email' => $user_profile['email']); $user_id = hdz_registerAccount($data); hdz_loginAccount($user_profile['email'], 48); unset($_SESSION['access_token']); header('location: ' . getUrl('view_tickets')); exit; } } catch (FacebookApiException $e) { $params = array('scope' => 'email', 'redirect_uri' => getUrl() . '/facebookOAuth/'); $loginUrl = $facebook->getLoginUrl($params); header('location: ' . $loginUrl); exit; } } else { $params = array('scope' => 'email', 'redirect_uri' => getUrl() . '/facebookOAuth/'); $loginUrl = $facebook->getLoginUrl($params); header('location: ' . $loginUrl); exit;
$redirect = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']; header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL)); } if (isset($_SESSION['access_token']) && $_SESSION['access_token']) { $client->setAccessToken($_SESSION['access_token']); } else { $authUrl = $client->createAuthUrl(); } if ($client->getAccessToken()) { $_SESSION['access_token'] = $client->getAccessToken(); //$token_data = $client->verifyIdToken()->getAttributes(); $objOAuthService = new Google_Service_Oauth2($client); $userData = $objOAuthService->userinfo->get(); } if (strpos($client_id, "googleusercontent") == false) { echo missingClientSecretsWarning(); exit; } if (isset($authUrl)) { header('location: ' . $authUrl); exit; } if (isset($userData)) { $userData = $objOAuthService->userinfo->get(); $data = array('fullname' => $userData->givenName . ' ' . $userData->familyName, 'email' => $userData->email); $user_id = hdz_registerAccount($data); hdz_loginAccount($userData->email, 48); unset($_SESSION['access_token']); header('location: ' . getUrl('view_tickets')); exit; }
if ($xml !== false) { if ($xml->result == 1 && !empty($xml->user->fullname) && !empty($xml->user->email)) { hdz_registerAccount(array('fullname' => $xml->user->fullname, 'email' => $xml->user->email, 'password' => $input->p['password']), FALSE, TRUE); $data = array('fullname' => $xml->user->fullname, 'email' => $xml->user->email, 'password' => sha1($input->p['password'])); $chk = $db->fetchOne("SELECT COUNT(id) AS NUM FROM " . TABLE_PREFIX . "users WHERE email='" . $db->real_escape_string($input->p['email']) . "'"); if ($chk == 0) { $db->insert(TABLE_PREFIX . "users", $data); } else { $db->update(TABLE_PREFIX . "users", $data, "email='" . $db->real_escape_string($input->p['email']) . "'"); } } } } $password = sha1($input->p['password']); $chk = $db->fetchOne("SELECT COUNT(id) AS NUM FROM " . TABLE_PREFIX . "users WHERE email='" . $db->real_escape_string($input->p['email']) . "' AND password='******'"); if ($chk == 0) { $error_msg = $LANG['INVALID_EMAIL_OR_PASSWORD']; } else { if ($input->p['remember'] == 1) { $cookie_time = 48; } else { $cookie_time = 1; } hdz_loginAccount($input->p['email'], $cookie_time); header('location: ' . getUrl('view_tickets')); exit; } } } include CONTROLLERS . 'home_controller.php'; exit;